@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,376 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property, state, 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
|
+
title: "Drag & drop files here or {browse}",
|
|
15
|
+
browse: "browse",
|
|
16
|
+
errorType: "“{name}” is not an accepted file type.",
|
|
17
|
+
errorSize: "“{name}” exceeds the maximum size ({size}).",
|
|
18
|
+
removeLabel: "Remove {name}"
|
|
19
|
+
};
|
|
20
|
+
class OkDropzone extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.accept = "";
|
|
24
|
+
this.multiple = false;
|
|
25
|
+
this.labels = {};
|
|
26
|
+
this.files = [];
|
|
27
|
+
this.dragging = false;
|
|
28
|
+
this.error = "";
|
|
29
|
+
}
|
|
30
|
+
static {
|
|
31
|
+
this.styles = css`
|
|
32
|
+
:host {
|
|
33
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
34
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
35
|
+
--color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.55));
|
|
36
|
+
--primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
37
|
+
--primary-tint: var(--ok-primary-tint, var(--ion-color-primary-tint, #4c8dff));
|
|
38
|
+
--danger-color: var(--ok-danger, var(--ion-color-danger, #c5000f));
|
|
39
|
+
--border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.22));
|
|
40
|
+
--hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.04));
|
|
41
|
+
--primary-bg: var(--ok-primary-soft, rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.08));
|
|
42
|
+
--surface: var(--ok-surface, var(--ion-card-background, #ffffff));
|
|
43
|
+
--border-radius: var(--ok-radius, 10px);
|
|
44
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
45
|
+
|
|
46
|
+
/* Responsive: ocupa el ancho del contenedor con un tope legible. */
|
|
47
|
+
display: block;
|
|
48
|
+
width: 100%;
|
|
49
|
+
max-width: var(--ok-dropzone-max-width, 480px);
|
|
50
|
+
color: var(--color);
|
|
51
|
+
font-family: var(--font);
|
|
52
|
+
font-size: 0.95rem;
|
|
53
|
+
}
|
|
54
|
+
.zone {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
gap: 0.4rem;
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
width: 100%;
|
|
62
|
+
padding: 1.5rem 1rem;
|
|
63
|
+
text-align: center;
|
|
64
|
+
border: 2px dashed var(--border-color);
|
|
65
|
+
border-radius: var(--border-radius);
|
|
66
|
+
background: var(--surface);
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
transition: background-color var(--ok-transition, 150ms ease),
|
|
69
|
+
color var(--ok-transition, 150ms ease),
|
|
70
|
+
border-color var(--ok-transition, 150ms ease),
|
|
71
|
+
box-shadow var(--ok-transition, 150ms ease), transform 120ms ease;
|
|
72
|
+
}
|
|
73
|
+
@media (hover: hover) {
|
|
74
|
+
.zone:hover {
|
|
75
|
+
background: var(--hover-bg);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.zone:active {
|
|
79
|
+
transform: scale(var(--ok-press-scale, 0.97));
|
|
80
|
+
}
|
|
81
|
+
/* Estado mientras se arrastra un fichero por encima. */
|
|
82
|
+
.zone.dragging {
|
|
83
|
+
border-color: var(--primary-color);
|
|
84
|
+
background: var(--primary-bg);
|
|
85
|
+
}
|
|
86
|
+
@media (prefers-reduced-motion: reduce) {
|
|
87
|
+
.zone:active,
|
|
88
|
+
.file .remove:active {
|
|
89
|
+
transform: none;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
.zone .big-icon {
|
|
93
|
+
font-size: 2rem;
|
|
94
|
+
color: var(--primary-color);
|
|
95
|
+
}
|
|
96
|
+
.zone .title {
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
}
|
|
99
|
+
.zone .title .link {
|
|
100
|
+
color: var(--primary-color);
|
|
101
|
+
text-decoration: underline;
|
|
102
|
+
}
|
|
103
|
+
.zone .hint {
|
|
104
|
+
font-size: 0.82rem;
|
|
105
|
+
color: var(--color-muted);
|
|
106
|
+
}
|
|
107
|
+
/* Lista de archivos elegidos. */
|
|
108
|
+
.files {
|
|
109
|
+
list-style: none;
|
|
110
|
+
margin: 0.7rem 0 0;
|
|
111
|
+
padding: 0;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 0.4rem;
|
|
115
|
+
}
|
|
116
|
+
.file {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 0.5rem;
|
|
120
|
+
box-sizing: border-box;
|
|
121
|
+
padding: 0.4rem 0.6rem;
|
|
122
|
+
border: 1px solid var(--border-color);
|
|
123
|
+
border-radius: var(--border-radius);
|
|
124
|
+
background: var(--surface);
|
|
125
|
+
}
|
|
126
|
+
.file .file-icon {
|
|
127
|
+
flex: 0 0 auto;
|
|
128
|
+
font-size: 1.15rem;
|
|
129
|
+
color: var(--color-muted);
|
|
130
|
+
}
|
|
131
|
+
.file .meta {
|
|
132
|
+
flex: 1 1 auto;
|
|
133
|
+
min-width: 0;
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
}
|
|
137
|
+
.file .name {
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
text-overflow: ellipsis;
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
}
|
|
142
|
+
.file .size {
|
|
143
|
+
font-size: 0.78rem;
|
|
144
|
+
color: var(--color-muted);
|
|
145
|
+
}
|
|
146
|
+
.file .remove {
|
|
147
|
+
flex: 0 0 auto;
|
|
148
|
+
display: inline-flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
width: 26px;
|
|
152
|
+
height: 26px;
|
|
153
|
+
padding: 0;
|
|
154
|
+
border: 0;
|
|
155
|
+
background: none;
|
|
156
|
+
color: var(--color-muted);
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
border-radius: 50%;
|
|
159
|
+
transition: background-color var(--ok-transition, 150ms ease),
|
|
160
|
+
color var(--ok-transition, 150ms ease),
|
|
161
|
+
border-color var(--ok-transition, 150ms ease),
|
|
162
|
+
box-shadow var(--ok-transition, 150ms ease), transform 120ms ease;
|
|
163
|
+
}
|
|
164
|
+
@media (hover: hover) {
|
|
165
|
+
.file .remove:hover {
|
|
166
|
+
background: var(--hover-bg);
|
|
167
|
+
color: var(--danger-color);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
.file .remove:active {
|
|
171
|
+
transform: scale(var(--ok-press-scale, 0.97));
|
|
172
|
+
}
|
|
173
|
+
/* Error inline (tipo/tamaño no admitido). */
|
|
174
|
+
.error {
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
gap: 0.4rem;
|
|
178
|
+
margin-top: 0.5rem;
|
|
179
|
+
color: var(--danger-color);
|
|
180
|
+
font-size: 0.82rem;
|
|
181
|
+
}
|
|
182
|
+
input[type='file'] {
|
|
183
|
+
display: none;
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
// Textos efectivos: defaults inglés sobreescritos por los pasados desde fuera.
|
|
188
|
+
get t() {
|
|
189
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
190
|
+
}
|
|
191
|
+
// Formatea bytes a una etiqueta legible (B, KB, MB…).
|
|
192
|
+
formatSize(bytes) {
|
|
193
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
194
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
195
|
+
let value = bytes / 1024;
|
|
196
|
+
let i = 0;
|
|
197
|
+
while (value >= 1024 && i < units.length - 1) {
|
|
198
|
+
value /= 1024;
|
|
199
|
+
i += 1;
|
|
200
|
+
}
|
|
201
|
+
return `${value.toFixed(value >= 10 || i === 0 ? 0 : 1)} ${units[i]}`;
|
|
202
|
+
}
|
|
203
|
+
// Comprueba si un archivo casa con `accept` (extensiones, mime exacto o `tipo/*`).
|
|
204
|
+
matchesAccept(file) {
|
|
205
|
+
if (!this.accept.trim()) return true;
|
|
206
|
+
const tokens = this.accept.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
207
|
+
const name = file.name.toLowerCase();
|
|
208
|
+
const mime = file.type.toLowerCase();
|
|
209
|
+
return tokens.some((token) => {
|
|
210
|
+
if (token.startsWith(".")) return name.endsWith(token);
|
|
211
|
+
if (token.endsWith("/*")) return mime.startsWith(token.slice(0, -1));
|
|
212
|
+
return mime === token;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// Emite `ok-error` con el mensaje dado y lo guarda para mostrarlo inline.
|
|
216
|
+
reportError(message) {
|
|
217
|
+
this.error = message;
|
|
218
|
+
this.dispatchEvent(
|
|
219
|
+
new CustomEvent("ok-error", {
|
|
220
|
+
detail: { message },
|
|
221
|
+
bubbles: true,
|
|
222
|
+
composed: true
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
// Emite `ok-change` con la lista actual de archivos válidos.
|
|
227
|
+
emitChange() {
|
|
228
|
+
this.dispatchEvent(
|
|
229
|
+
new CustomEvent("ok-change", {
|
|
230
|
+
detail: { files: this.files },
|
|
231
|
+
bubbles: true,
|
|
232
|
+
composed: true
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
// Procesa un FileList (de input o de drop), valida y añade los aceptados.
|
|
237
|
+
ingest(list) {
|
|
238
|
+
if (!list || !list.length) return;
|
|
239
|
+
this.error = "";
|
|
240
|
+
const incoming = Array.from(list);
|
|
241
|
+
const next = this.multiple ? [...this.files] : [];
|
|
242
|
+
for (const file of incoming) {
|
|
243
|
+
if (!this.matchesAccept(file)) {
|
|
244
|
+
this.reportError(this.t.errorType.replace("{name}", file.name));
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (this.maxSize != null && file.size > this.maxSize) {
|
|
248
|
+
this.reportError(
|
|
249
|
+
this.t.errorSize.replace("{name}", file.name).replace("{size}", this.formatSize(this.maxSize))
|
|
250
|
+
);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const dup = next.some((f) => f.name === file.name && f.size === file.size);
|
|
254
|
+
if (!dup) next.push(file);
|
|
255
|
+
if (!this.multiple) break;
|
|
256
|
+
}
|
|
257
|
+
this.files = next;
|
|
258
|
+
this.emitChange();
|
|
259
|
+
}
|
|
260
|
+
// Quita un archivo de la lista por índice y re-emite el cambio.
|
|
261
|
+
removeAt(index) {
|
|
262
|
+
this.files = this.files.filter((_, i) => i !== index);
|
|
263
|
+
this.error = "";
|
|
264
|
+
this.emitChange();
|
|
265
|
+
}
|
|
266
|
+
openPicker() {
|
|
267
|
+
this.input?.click();
|
|
268
|
+
}
|
|
269
|
+
onInputChange(e) {
|
|
270
|
+
const target = e.target;
|
|
271
|
+
this.ingest(target.files);
|
|
272
|
+
target.value = "";
|
|
273
|
+
}
|
|
274
|
+
onDragOver(e) {
|
|
275
|
+
e.preventDefault();
|
|
276
|
+
this.dragging = true;
|
|
277
|
+
}
|
|
278
|
+
onDragLeave(e) {
|
|
279
|
+
e.preventDefault();
|
|
280
|
+
this.dragging = false;
|
|
281
|
+
}
|
|
282
|
+
onDrop(e) {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
this.dragging = false;
|
|
285
|
+
this.ingest(e.dataTransfer?.files ?? null);
|
|
286
|
+
}
|
|
287
|
+
render() {
|
|
288
|
+
const [titleBefore, titleAfter = ""] = this.t.title.split("{browse}");
|
|
289
|
+
return html`
|
|
290
|
+
<div
|
|
291
|
+
class=${`zone ${this.dragging ? "dragging" : ""}`.trim()}
|
|
292
|
+
role="button"
|
|
293
|
+
tabindex="0"
|
|
294
|
+
@click=${this.openPicker}
|
|
295
|
+
@keydown=${(e) => {
|
|
296
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
this.openPicker();
|
|
299
|
+
}
|
|
300
|
+
}}
|
|
301
|
+
@dragover=${this.onDragOver}
|
|
302
|
+
@dragleave=${this.onDragLeave}
|
|
303
|
+
@drop=${this.onDrop}
|
|
304
|
+
>
|
|
305
|
+
<ion-icon class="big-icon" name="cloud-upload-outline"></ion-icon>
|
|
306
|
+
<span class="title">
|
|
307
|
+
${titleBefore}<span class="link">${this.t.browse}</span>${titleAfter}
|
|
308
|
+
</span>
|
|
309
|
+
${this.hint ? html`<span class="hint">${this.hint}</span>` : ""}
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<input
|
|
313
|
+
type="file"
|
|
314
|
+
?multiple=${this.multiple}
|
|
315
|
+
accept=${this.accept || ""}
|
|
316
|
+
@change=${this.onInputChange}
|
|
317
|
+
/>
|
|
318
|
+
|
|
319
|
+
${this.error ? html`<div class="error"><ion-icon name="alert-circle-outline"></ion-icon>${this.error}</div>` : ""}
|
|
320
|
+
|
|
321
|
+
${this.files.length ? html`<ul class="files">
|
|
322
|
+
${this.files.map(
|
|
323
|
+
(file, i) => html`<li class="file">
|
|
324
|
+
<ion-icon class="file-icon" name="document-outline"></ion-icon>
|
|
325
|
+
<span class="meta">
|
|
326
|
+
<span class="name">${file.name}</span>
|
|
327
|
+
<span class="size">${this.formatSize(file.size)}</span>
|
|
328
|
+
</span>
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
class="remove"
|
|
332
|
+
aria-label=${this.t.removeLabel.replace("{name}", file.name)}
|
|
333
|
+
@click=${(e) => {
|
|
334
|
+
e.stopPropagation();
|
|
335
|
+
this.removeAt(i);
|
|
336
|
+
}}
|
|
337
|
+
>
|
|
338
|
+
<ion-icon name="close-outline"></ion-icon>
|
|
339
|
+
</button>
|
|
340
|
+
</li>`
|
|
341
|
+
)}
|
|
342
|
+
</ul>` : ""}
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
__decorateClass([
|
|
347
|
+
property()
|
|
348
|
+
], OkDropzone.prototype, "accept");
|
|
349
|
+
__decorateClass([
|
|
350
|
+
property({ type: Boolean })
|
|
351
|
+
], OkDropzone.prototype, "multiple");
|
|
352
|
+
__decorateClass([
|
|
353
|
+
property({ type: Number, attribute: "max-size" })
|
|
354
|
+
], OkDropzone.prototype, "maxSize");
|
|
355
|
+
__decorateClass([
|
|
356
|
+
property()
|
|
357
|
+
], OkDropzone.prototype, "hint");
|
|
358
|
+
__decorateClass([
|
|
359
|
+
property({ attribute: false })
|
|
360
|
+
], OkDropzone.prototype, "labels");
|
|
361
|
+
__decorateClass([
|
|
362
|
+
state()
|
|
363
|
+
], OkDropzone.prototype, "files");
|
|
364
|
+
__decorateClass([
|
|
365
|
+
state()
|
|
366
|
+
], OkDropzone.prototype, "dragging");
|
|
367
|
+
__decorateClass([
|
|
368
|
+
state()
|
|
369
|
+
], OkDropzone.prototype, "error");
|
|
370
|
+
__decorateClass([
|
|
371
|
+
query('input[type="file"]')
|
|
372
|
+
], OkDropzone.prototype, "input");
|
|
373
|
+
define("ok-dropzone", OkDropzone);
|
|
374
|
+
export {
|
|
375
|
+
OkDropzone
|
|
376
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
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 OkEmptyState extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.icon = "file-tray-outline";
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.styles = css`
|
|
20
|
+
/* Ancho máximo del contenedor; bloque a 100%. */
|
|
21
|
+
:host {
|
|
22
|
+
display: block;
|
|
23
|
+
width: 100%;
|
|
24
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
25
|
+
--icon-color: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
26
|
+
--heading-color: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
27
|
+
--message-color: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
28
|
+
--icon-size: 64px;
|
|
29
|
+
--padding: 2.5rem 1.25rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Centrado vertical y horizontal del contenido. */
|
|
33
|
+
.wrap {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
text-align: center;
|
|
39
|
+
gap: 0.5rem;
|
|
40
|
+
padding: var(--padding);
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
width: 100%;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ion-icon {
|
|
46
|
+
font-size: var(--icon-size);
|
|
47
|
+
color: var(--icon-color);
|
|
48
|
+
opacity: 0.5; /* atenuado */
|
|
49
|
+
margin-bottom: 0.25rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.heading {
|
|
53
|
+
margin: 0;
|
|
54
|
+
font-size: 1.125rem;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
color: var(--heading-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.message {
|
|
60
|
+
margin: 0;
|
|
61
|
+
font-size: 0.9375rem;
|
|
62
|
+
color: var(--message-color);
|
|
63
|
+
max-width: 38ch;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Acción debajo del texto. */
|
|
67
|
+
.action {
|
|
68
|
+
margin-top: 1rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Oculta los wrappers si no hay contenido. */
|
|
72
|
+
.heading:empty,
|
|
73
|
+
.message:empty {
|
|
74
|
+
display: none;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return html`
|
|
80
|
+
<div class="wrap">
|
|
81
|
+
<ion-icon name=${this.icon} aria-hidden="true"></ion-icon>
|
|
82
|
+
${this.heading ? html`<h2 class="heading">${this.heading}</h2>` : null}
|
|
83
|
+
${this.message ? html`<p class="message">${this.message}</p>` : null}
|
|
84
|
+
<slot></slot>
|
|
85
|
+
<div class="action">
|
|
86
|
+
<slot name="action"></slot>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
__decorateClass([
|
|
93
|
+
property()
|
|
94
|
+
], OkEmptyState.prototype, "icon");
|
|
95
|
+
__decorateClass([
|
|
96
|
+
property()
|
|
97
|
+
], OkEmptyState.prototype, "heading");
|
|
98
|
+
__decorateClass([
|
|
99
|
+
property()
|
|
100
|
+
], OkEmptyState.prototype, "message");
|
|
101
|
+
define("ok-empty-state", OkEmptyState);
|
|
102
|
+
export {
|
|
103
|
+
OkEmptyState
|
|
104
|
+
};
|