@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,366 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing } 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 OkPagination extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.total = 0;
|
|
17
|
+
this.page = 1;
|
|
18
|
+
this.pageSize = 20;
|
|
19
|
+
this.siblingCount = 1;
|
|
20
|
+
this.boundaryCount = 1;
|
|
21
|
+
this.variant = "default";
|
|
22
|
+
this.info = false;
|
|
23
|
+
this.label = "Paginación";
|
|
24
|
+
}
|
|
25
|
+
static {
|
|
26
|
+
this.styles = css`
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
width: 100%;
|
|
30
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
31
|
+
--bg: var(--ok-surface, var(--ion-background-color, #ffffff));
|
|
32
|
+
--bg-soft: var(--ok-surface-soft, var(--ion-color-light, #f4f5f8));
|
|
33
|
+
--line: var(--ok-border-color, var(--ion-border-color, #e0e2e7));
|
|
34
|
+
--line-strong: var(--ok-border-color-strong, var(--ion-color-step-200, #cdd0d6));
|
|
35
|
+
--ink: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
36
|
+
--ink-2: var(--ok-text-color-soft, var(--ion-color-step-650, #545b66));
|
|
37
|
+
--ink-3: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
38
|
+
--brand: var(--ok-color-primary, var(--ion-color-primary, #3880ff));
|
|
39
|
+
--brand-fg: var(--ok-color-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
|
|
40
|
+
--radius: var(--ok-radius, var(--ion-border-radius, 8px));
|
|
41
|
+
--radius-sm: calc(var(--radius) - 2px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.wrap {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
flex-wrap: wrap;
|
|
48
|
+
gap: 14px;
|
|
49
|
+
width: 100%;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
font-size: 0.875rem;
|
|
52
|
+
color: var(--ink-3);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* La info y el page-size quedan a los extremos; el paginador empuja al centro/derecha. */
|
|
56
|
+
.info {
|
|
57
|
+
font-variant-numeric: tabular-nums;
|
|
58
|
+
}
|
|
59
|
+
.info b {
|
|
60
|
+
color: var(--ink-2);
|
|
61
|
+
font-weight: 500;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.spacer {
|
|
65
|
+
flex: 1 1 auto;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nav {
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
}
|
|
73
|
+
.nav.compact {
|
|
74
|
+
border: 1px solid var(--line);
|
|
75
|
+
border-radius: var(--radius);
|
|
76
|
+
padding: 1px;
|
|
77
|
+
background: var(--bg-soft);
|
|
78
|
+
gap: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Botón de página: ion-button fill=clear restyleado a la estética del paginador. */
|
|
82
|
+
ion-button.page {
|
|
83
|
+
--padding-start: 8px;
|
|
84
|
+
--padding-end: 8px;
|
|
85
|
+
--border-radius: var(--radius-sm);
|
|
86
|
+
--background-hover: var(--bg-soft);
|
|
87
|
+
--color: var(--ink-2);
|
|
88
|
+
--color-hover: var(--ink);
|
|
89
|
+
min-width: 32px;
|
|
90
|
+
height: 32px;
|
|
91
|
+
margin: 0;
|
|
92
|
+
font-size: 0.875rem;
|
|
93
|
+
font-variant-numeric: tabular-nums;
|
|
94
|
+
--border-width: 1px;
|
|
95
|
+
--border-style: solid;
|
|
96
|
+
--border-color: var(--line);
|
|
97
|
+
--background: var(--bg);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Chevrons prev/next: sin borde de caja, look ligero. */
|
|
101
|
+
ion-button.chev {
|
|
102
|
+
--border-width: 0;
|
|
103
|
+
--background: transparent;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Página activa: relleno de marca. */
|
|
107
|
+
ion-button.page.active {
|
|
108
|
+
--background: var(--brand);
|
|
109
|
+
--background-hover: var(--brand);
|
|
110
|
+
--border-color: var(--brand);
|
|
111
|
+
--color: var(--brand-fg);
|
|
112
|
+
--color-hover: var(--brand-fg);
|
|
113
|
+
font-weight: 600;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.nav.compact ion-button.page {
|
|
117
|
+
--border-width: 0;
|
|
118
|
+
--background: transparent;
|
|
119
|
+
}
|
|
120
|
+
.nav.compact .value {
|
|
121
|
+
min-width: 56px;
|
|
122
|
+
height: 32px;
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
font-variant-numeric: tabular-nums;
|
|
127
|
+
color: var(--ink);
|
|
128
|
+
font-weight: 500;
|
|
129
|
+
user-select: none;
|
|
130
|
+
padding: 0 8px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.gap {
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
justify-content: center;
|
|
137
|
+
min-width: 28px;
|
|
138
|
+
height: 32px;
|
|
139
|
+
color: var(--ink-3);
|
|
140
|
+
user-select: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.pgsize {
|
|
144
|
+
display: inline-flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
gap: 6px;
|
|
147
|
+
font-size: 0.8125rem;
|
|
148
|
+
}
|
|
149
|
+
ion-select.pgsize-select {
|
|
150
|
+
--padding-start: 8px;
|
|
151
|
+
--padding-end: 4px;
|
|
152
|
+
min-height: 30px;
|
|
153
|
+
border: 1px solid var(--line);
|
|
154
|
+
border-radius: var(--radius-sm);
|
|
155
|
+
background: var(--bg-soft);
|
|
156
|
+
color: var(--ink);
|
|
157
|
+
font-size: 0.8125rem;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@media (max-width: 480px) {
|
|
161
|
+
.info {
|
|
162
|
+
order: 3;
|
|
163
|
+
width: 100%;
|
|
164
|
+
text-align: center;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
/** Nº total de páginas (mínimo 1). */
|
|
170
|
+
get pageCount() {
|
|
171
|
+
const size = Math.max(1, this.pageSize);
|
|
172
|
+
return Math.max(1, Math.ceil(Math.max(0, this.total) / size));
|
|
173
|
+
}
|
|
174
|
+
/** Página actual saneada al rango [1, pageCount]. */
|
|
175
|
+
get current() {
|
|
176
|
+
return Math.min(Math.max(1, this.page), this.pageCount);
|
|
177
|
+
}
|
|
178
|
+
/** Construye la lista de tokens (números + elipsis) según sibling/boundary counts. */
|
|
179
|
+
get range() {
|
|
180
|
+
const count = this.pageCount;
|
|
181
|
+
const current = this.current;
|
|
182
|
+
const siblings = Math.max(0, this.siblingCount);
|
|
183
|
+
const boundaries = Math.max(1, this.boundaryCount);
|
|
184
|
+
const totalSlots = boundaries * 2 + siblings * 2 + 3;
|
|
185
|
+
if (count <= totalSlots) {
|
|
186
|
+
return this.seq(1, count);
|
|
187
|
+
}
|
|
188
|
+
const leftSibling = Math.max(current - siblings, boundaries + 2);
|
|
189
|
+
const rightSibling = Math.min(current + siblings, count - boundaries - 1);
|
|
190
|
+
const showLeftGap = leftSibling > boundaries + 2;
|
|
191
|
+
const showRightGap = rightSibling < count - boundaries - 1;
|
|
192
|
+
const tokens = [];
|
|
193
|
+
tokens.push(...this.seq(1, boundaries));
|
|
194
|
+
if (showLeftGap) {
|
|
195
|
+
tokens.push("ellipsis-start");
|
|
196
|
+
} else {
|
|
197
|
+
tokens.push(...this.seq(boundaries + 1, leftSibling - 1));
|
|
198
|
+
}
|
|
199
|
+
tokens.push(...this.seq(leftSibling, rightSibling));
|
|
200
|
+
if (showRightGap) {
|
|
201
|
+
tokens.push("ellipsis-end");
|
|
202
|
+
} else {
|
|
203
|
+
tokens.push(...this.seq(rightSibling + 1, count - boundaries));
|
|
204
|
+
}
|
|
205
|
+
tokens.push(...this.seq(count - boundaries + 1, count));
|
|
206
|
+
return tokens;
|
|
207
|
+
}
|
|
208
|
+
/** Rango entero [from, to] como array (vacío si from > to). */
|
|
209
|
+
seq(from, to) {
|
|
210
|
+
const out = [];
|
|
211
|
+
for (let i = from; i <= to; i++) out.push(i);
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
214
|
+
goTo(target) {
|
|
215
|
+
const next = Math.min(Math.max(1, target), this.pageCount);
|
|
216
|
+
if (next === this.current) return;
|
|
217
|
+
this.dispatchEvent(
|
|
218
|
+
new CustomEvent("ok-page-change", {
|
|
219
|
+
detail: { page: next },
|
|
220
|
+
bubbles: true,
|
|
221
|
+
composed: true
|
|
222
|
+
})
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
onSizeChange(value) {
|
|
226
|
+
if (!Number.isFinite(value) || value === this.pageSize) return;
|
|
227
|
+
this.dispatchEvent(
|
|
228
|
+
new CustomEvent("ok-page-size-change", {
|
|
229
|
+
detail: { size: value },
|
|
230
|
+
bubbles: true,
|
|
231
|
+
composed: true
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
/** Chevron SVG (izq/der) dibujado a mano. */
|
|
236
|
+
chevron(dir) {
|
|
237
|
+
const d = dir === "prev" ? "M15 18l-6-6 6-6" : "M9 6l6 6-6 6";
|
|
238
|
+
return html`<svg
|
|
239
|
+
width="16"
|
|
240
|
+
height="16"
|
|
241
|
+
viewBox="0 0 24 24"
|
|
242
|
+
fill="none"
|
|
243
|
+
stroke="currentColor"
|
|
244
|
+
stroke-width="2"
|
|
245
|
+
stroke-linecap="round"
|
|
246
|
+
stroke-linejoin="round"
|
|
247
|
+
aria-hidden="true"
|
|
248
|
+
>
|
|
249
|
+
<path d="${d}"></path>
|
|
250
|
+
</svg>`;
|
|
251
|
+
}
|
|
252
|
+
renderInfo() {
|
|
253
|
+
if (!this.info) return nothing;
|
|
254
|
+
if (this.total <= 0) {
|
|
255
|
+
return html`<span class="info"><b>0</b> elementos</span>`;
|
|
256
|
+
}
|
|
257
|
+
const size = Math.max(1, this.pageSize);
|
|
258
|
+
const from = (this.current - 1) * size + 1;
|
|
259
|
+
const to = Math.min(this.current * size, this.total);
|
|
260
|
+
return html`<span class="info"><b>${from}–${to}</b> de <b>${this.total}</b></span>`;
|
|
261
|
+
}
|
|
262
|
+
renderPageSize() {
|
|
263
|
+
const opts = this.pageSizeOptions;
|
|
264
|
+
if (!opts || opts.length === 0) return nothing;
|
|
265
|
+
return html`<span class="pgsize">
|
|
266
|
+
<span>Filas</span>
|
|
267
|
+
<ion-select
|
|
268
|
+
class="pgsize-select"
|
|
269
|
+
interface="popover"
|
|
270
|
+
aria-label="Filas por página"
|
|
271
|
+
.value=${this.pageSize}
|
|
272
|
+
@ionChange=${(e) => this.onSizeChange(Number(e.target.value))}
|
|
273
|
+
>
|
|
274
|
+
${opts.map((n) => html`<ion-select-option .value=${n}>${n}</ion-select-option>`)}
|
|
275
|
+
</ion-select>
|
|
276
|
+
</span>`;
|
|
277
|
+
}
|
|
278
|
+
renderNav() {
|
|
279
|
+
const current = this.current;
|
|
280
|
+
const count = this.pageCount;
|
|
281
|
+
const atStart = current <= 1;
|
|
282
|
+
const atEnd = current >= count;
|
|
283
|
+
const prev = html`<ion-button
|
|
284
|
+
class="page chev"
|
|
285
|
+
fill="clear"
|
|
286
|
+
aria-label="Página anterior"
|
|
287
|
+
?disabled=${atStart}
|
|
288
|
+
@click=${() => this.goTo(current - 1)}
|
|
289
|
+
>${this.chevron("prev")}</ion-button
|
|
290
|
+
>`;
|
|
291
|
+
const next = html`<ion-button
|
|
292
|
+
class="page chev"
|
|
293
|
+
fill="clear"
|
|
294
|
+
aria-label="Página siguiente"
|
|
295
|
+
?disabled=${atEnd}
|
|
296
|
+
@click=${() => this.goTo(current + 1)}
|
|
297
|
+
>${this.chevron("next")}</ion-button
|
|
298
|
+
>`;
|
|
299
|
+
if (this.variant === "compact") {
|
|
300
|
+
return html`<nav class="nav compact" role="navigation" aria-label=${this.label}>
|
|
301
|
+
${prev}
|
|
302
|
+
<span class="value" aria-current="page" aria-live="polite">${current} / ${count}</span>
|
|
303
|
+
${next}
|
|
304
|
+
</nav>`;
|
|
305
|
+
}
|
|
306
|
+
return html`<nav class="nav" role="navigation" aria-label=${this.label}>
|
|
307
|
+
${prev}
|
|
308
|
+
${this.range.map((tok) => {
|
|
309
|
+
if (tok === "ellipsis-start" || tok === "ellipsis-end") {
|
|
310
|
+
return html`<span class="gap" aria-hidden="true">…</span>`;
|
|
311
|
+
}
|
|
312
|
+
const active = tok === current;
|
|
313
|
+
return html`<ion-button
|
|
314
|
+
class="page ${active ? "active" : ""}"
|
|
315
|
+
fill="clear"
|
|
316
|
+
aria-label="Página ${tok}"
|
|
317
|
+
aria-current=${active ? "page" : nothing}
|
|
318
|
+
@click=${() => this.goTo(tok)}
|
|
319
|
+
>${tok}</ion-button
|
|
320
|
+
>`;
|
|
321
|
+
})}
|
|
322
|
+
${next}
|
|
323
|
+
</nav>`;
|
|
324
|
+
}
|
|
325
|
+
render() {
|
|
326
|
+
return html`
|
|
327
|
+
<div class="wrap">
|
|
328
|
+
${this.renderInfo()}
|
|
329
|
+
<span class="spacer"></span>
|
|
330
|
+
${this.renderNav()}
|
|
331
|
+
${this.renderPageSize()}
|
|
332
|
+
</div>
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
__decorateClass([
|
|
337
|
+
property({ type: Number })
|
|
338
|
+
], OkPagination.prototype, "total");
|
|
339
|
+
__decorateClass([
|
|
340
|
+
property({ type: Number })
|
|
341
|
+
], OkPagination.prototype, "page");
|
|
342
|
+
__decorateClass([
|
|
343
|
+
property({ type: Number, attribute: "page-size" })
|
|
344
|
+
], OkPagination.prototype, "pageSize");
|
|
345
|
+
__decorateClass([
|
|
346
|
+
property({ type: Number, attribute: "sibling-count" })
|
|
347
|
+
], OkPagination.prototype, "siblingCount");
|
|
348
|
+
__decorateClass([
|
|
349
|
+
property({ type: Number, attribute: "boundary-count" })
|
|
350
|
+
], OkPagination.prototype, "boundaryCount");
|
|
351
|
+
__decorateClass([
|
|
352
|
+
property()
|
|
353
|
+
], OkPagination.prototype, "variant");
|
|
354
|
+
__decorateClass([
|
|
355
|
+
property({ type: Boolean })
|
|
356
|
+
], OkPagination.prototype, "info");
|
|
357
|
+
__decorateClass([
|
|
358
|
+
property({ type: Array, attribute: "page-size-options" })
|
|
359
|
+
], OkPagination.prototype, "pageSizeOptions");
|
|
360
|
+
__decorateClass([
|
|
361
|
+
property()
|
|
362
|
+
], OkPagination.prototype, "label");
|
|
363
|
+
define("ok-pagination", OkPagination);
|
|
364
|
+
export {
|
|
365
|
+
OkPagination
|
|
366
|
+
};
|
package/dist/ok-pdf.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
const DEFAULT_LABELS = {
|
|
14
|
+
documentTitle: "PDF document",
|
|
15
|
+
open: "Open",
|
|
16
|
+
openAria: "Open or download PDF",
|
|
17
|
+
cannotDisplay: "This PDF cannot be displayed here.",
|
|
18
|
+
download: "Download"
|
|
19
|
+
};
|
|
20
|
+
class OkPdf extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.src = "";
|
|
24
|
+
this.title = "";
|
|
25
|
+
this.height = "480px";
|
|
26
|
+
this.labels = {};
|
|
27
|
+
}
|
|
28
|
+
static {
|
|
29
|
+
this.styles = css`
|
|
30
|
+
:host {
|
|
31
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
32
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
33
|
+
--color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.55));
|
|
34
|
+
--surface-bg: var(--ok-surface, var(--ion-card-background, #ffffff));
|
|
35
|
+
--viewer-bg: var(--ok-pdf-bg, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.04));
|
|
36
|
+
--border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.1));
|
|
37
|
+
--border-radius: var(--ok-radius, 10px);
|
|
38
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
39
|
+
|
|
40
|
+
/* Responsive: bloque al ancho del contenedor. */
|
|
41
|
+
display: block;
|
|
42
|
+
width: 100%;
|
|
43
|
+
color: var(--color);
|
|
44
|
+
font-family: var(--font);
|
|
45
|
+
}
|
|
46
|
+
.frame {
|
|
47
|
+
box-sizing: border-box;
|
|
48
|
+
width: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
background: var(--surface-bg);
|
|
52
|
+
border: 1px solid var(--border-color);
|
|
53
|
+
border-radius: var(--border-radius);
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
}
|
|
56
|
+
/* Barra superior mínima: título a la izquierda, acción a la derecha. */
|
|
57
|
+
.toolbar {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: 0.5rem;
|
|
61
|
+
padding: 0.4rem 0.4rem 0.4rem 0.75rem;
|
|
62
|
+
border-bottom: 1px solid var(--border-color);
|
|
63
|
+
}
|
|
64
|
+
.toolbar .title {
|
|
65
|
+
flex: 1 1 auto;
|
|
66
|
+
min-width: 0;
|
|
67
|
+
font-size: 0.88rem;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
text-overflow: ellipsis;
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
}
|
|
73
|
+
ion-button {
|
|
74
|
+
margin: 0;
|
|
75
|
+
flex: 0 0 auto;
|
|
76
|
+
}
|
|
77
|
+
/* Zona del visor: el <object> ocupa todo el alto indicado. */
|
|
78
|
+
.viewer {
|
|
79
|
+
position: relative;
|
|
80
|
+
width: 100%;
|
|
81
|
+
background: var(--viewer-bg);
|
|
82
|
+
}
|
|
83
|
+
object {
|
|
84
|
+
display: block;
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: 100%;
|
|
87
|
+
border: 0;
|
|
88
|
+
}
|
|
89
|
+
/* Fallback visible si el navegador no incrusta el PDF. */
|
|
90
|
+
.fallback {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
gap: 0.6rem;
|
|
96
|
+
height: 100%;
|
|
97
|
+
padding: 1.5rem;
|
|
98
|
+
text-align: center;
|
|
99
|
+
color: var(--color-muted);
|
|
100
|
+
}
|
|
101
|
+
.fallback ion-icon {
|
|
102
|
+
font-size: 2.2rem;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
get t() {
|
|
107
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
108
|
+
}
|
|
109
|
+
// Abre el PDF en una pestaña nueva (descarga / vista a pantalla completa del navegador).
|
|
110
|
+
open() {
|
|
111
|
+
if (this.src) window.open(this.src, "_blank", "noopener");
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
return html`
|
|
115
|
+
<div class="frame">
|
|
116
|
+
<div class="toolbar">
|
|
117
|
+
<span class="title">${this.title || this.t.documentTitle}</span>
|
|
118
|
+
<ion-button
|
|
119
|
+
fill="clear"
|
|
120
|
+
size="small"
|
|
121
|
+
aria-label=${this.t.openAria}
|
|
122
|
+
@click=${this.open}
|
|
123
|
+
>
|
|
124
|
+
<ion-icon slot="start" name="open-outline"></ion-icon>
|
|
125
|
+
${this.t.open}
|
|
126
|
+
</ion-button>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="viewer" style=${`height:${this.height}`}>
|
|
129
|
+
<object data=${this.src} type="application/pdf">
|
|
130
|
+
<!-- Fallback: el navegador no pudo incrustar el PDF → enlace de descarga. -->
|
|
131
|
+
<div class="fallback">
|
|
132
|
+
<ion-icon name="document-text-outline"></ion-icon>
|
|
133
|
+
<span>${this.t.cannotDisplay}</span>
|
|
134
|
+
<ion-button fill="solid" size="small" @click=${this.open}>
|
|
135
|
+
<ion-icon slot="start" name="download-outline"></ion-icon>
|
|
136
|
+
${this.t.download}
|
|
137
|
+
</ion-button>
|
|
138
|
+
</div>
|
|
139
|
+
</object>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
__decorateClass([
|
|
146
|
+
property()
|
|
147
|
+
], OkPdf.prototype, "src");
|
|
148
|
+
__decorateClass([
|
|
149
|
+
property()
|
|
150
|
+
], OkPdf.prototype, "title");
|
|
151
|
+
__decorateClass([
|
|
152
|
+
property()
|
|
153
|
+
], OkPdf.prototype, "height");
|
|
154
|
+
__decorateClass([
|
|
155
|
+
property({ attribute: false })
|
|
156
|
+
], OkPdf.prototype, "labels");
|
|
157
|
+
define("ok-pdf", OkPdf);
|
|
158
|
+
export {
|
|
159
|
+
OkPdf
|
|
160
|
+
};
|