@erplora/outfitkit 0.1.20 → 0.1.22
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/README.md +5 -6
- package/dist/cdn.d.ts +0 -5
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -10
- package/dist/layout.css +58 -5
- package/dist/ok-data-table.js +1 -1
- package/dist/ok-file-manager.js +1 -1
- package/dist/ok-lightbox.js +1 -1
- package/dist/outfitkit.bundle.js +3634 -5572
- package/dist/outfitkit.js +0 -5
- package/dist/shared/icons.js +3 -3
- package/dist/showcase/auth-login-saas-parity.test.d.ts +1 -0
- package/dist/showcase/component-catalog-completeness.test.d.ts +1 -0
- package/dist/showcase/current-page-contract.test.d.ts +1 -0
- package/dist/showcase/hub-access-dashboard-parity.test.d.ts +1 -0
- package/dist/showcase/hub-apps-billing-pages-parity.test.d.ts +1 -0
- package/dist/showcase/hub-employee-forms-parity.test.d.ts +1 -0
- package/dist/showcase/hub-shell-parity.test.d.ts +1 -0
- package/dist/showcase/hub-system-settings-shell-parity.test.d.ts +1 -0
- package/dist/showcase/hub-table-pages-parity.test.d.ts +1 -0
- package/dist/showcase/ionic-boundary.test.d.ts +1 -0
- package/dist/showcase/ionic-ios-default.test.d.ts +1 -0
- package/dist/showcase/module-appointments-parity.test.d.ts +1 -0
- package/dist/showcase/module-backup-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-cart-checkout-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-cash-register-parity.test.d.ts +1 -0
- package/dist/showcase/module-customers-fields-parity.test.d.ts +1 -0
- package/dist/showcase/module-customers-groups-parity.test.d.ts +1 -0
- package/dist/showcase/module-customers-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-customers-tags-parity.test.d.ts +1 -0
- package/dist/showcase/module-inventory-categories-parity.test.d.ts +1 -0
- package/dist/showcase/module-inventory-dashboard-parity.test.d.ts +1 -0
- package/dist/showcase/module-inventory-products-parity.test.d.ts +1 -0
- package/dist/showcase/module-invoice-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-invoice-series-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-invoice-settings-parity.test.d.ts +1 -0
- package/dist/showcase/module-kitchen-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-online-booking-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-pages-data.test.d.ts +1 -0
- package/dist/showcase/module-payment-gateways-parity.test.d.ts +1 -0
- package/dist/showcase/module-payments-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-pricing-lists-parity.test.d.ts +1 -0
- package/dist/showcase/module-printing-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-reservations-availability-parity.test.d.ts +1 -0
- package/dist/showcase/module-reservations-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-reservations-waitlist-parity.test.d.ts +1 -0
- package/dist/showcase/module-sales-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-sales-pos-parity.test.d.ts +1 -0
- package/dist/showcase/module-schedules-hours-parity.test.d.ts +1 -0
- package/dist/showcase/module-services-parity.test.d.ts +1 -0
- package/dist/showcase/module-staff-members-parity.test.d.ts +1 -0
- package/dist/showcase/module-staff-roles-parity.test.d.ts +1 -0
- package/dist/showcase/module-staff-schedules-parity.test.d.ts +1 -0
- package/dist/showcase/module-staff-time-off-parity.test.d.ts +1 -0
- package/dist/showcase/module-tables-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-tasks-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-tasks-projects-parity.test.d.ts +1 -0
- package/dist/showcase/module-taxes-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-tickets-list-parity.test.d.ts +1 -0
- package/dist/showcase/module-tickets-sla-parity.test.d.ts +1 -0
- package/dist/showcase/module-verifactu-pages-parity.test.d.ts +1 -0
- package/dist/showcase/module-whatsapp-inbox-pages-parity.test.d.ts +1 -0
- package/dist/showcase/page-catalog.test.d.ts +1 -0
- package/dist/showcase/page-navigation.test.d.ts +1 -0
- package/dist/showcase/saas-account-help-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-auth-account-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-billing-table-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-dashboard-shell-parity.test.d.ts +1 -0
- package/dist/showcase/saas-developer-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-developer-table-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-hub-detail-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-hubs-table-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-operations-marketplace-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-organizations-page-parity.test.d.ts +1 -0
- package/dist/showcase/saas-organizations-users-detail-pages-parity.test.d.ts +1 -0
- package/dist/showcase/saas-public-error-pages-parity.test.d.ts +1 -0
- package/package.json +2 -6
- package/dist/components/ok-date-picker/ok-date-picker.d.ts +0 -81
- package/dist/components/ok-drawer/ok-drawer.d.ts +0 -56
- package/dist/components/ok-range-dual/ok-range-dual.d.ts +0 -38
- package/dist/components/ok-skeleton/ok-skeleton.d.ts +0 -40
- package/dist/components/ok-time-picker/ok-time-picker.d.ts +0 -50
- package/dist/ok-date-picker.js +0 -737
- package/dist/ok-drawer.js +0 -358
- package/dist/ok-range-dual.js +0 -280
- package/dist/ok-skeleton.js +0 -345
- package/dist/ok-time-picker.js +0 -472
package/dist/ok-time-picker.js
DELETED
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
import { LitElement, css, html } from "lit";
|
|
2
|
-
import { property, state } from "lit/decorators.js";
|
|
3
|
-
import { define } from "./define.js";
|
|
4
|
-
import { c as computeAnchor } from "./shared/anchor.js";
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
-
var result = void 0;
|
|
8
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
-
if (decorator = decorators[i])
|
|
10
|
-
result = decorator(target, key, result) || result;
|
|
11
|
-
if (result) __defProp(target, key, result);
|
|
12
|
-
return result;
|
|
13
|
-
};
|
|
14
|
-
function parseHHMM(v) {
|
|
15
|
-
if (!v) return null;
|
|
16
|
-
const m = /^(\d{1,2}):(\d{1,2})$/.exec(v.trim());
|
|
17
|
-
if (!m) return null;
|
|
18
|
-
const h = Number(m[1]);
|
|
19
|
-
const mm = Number(m[2]);
|
|
20
|
-
if (h < 0 || h > 23 || mm < 0 || mm > 59) return null;
|
|
21
|
-
return h * 60 + mm;
|
|
22
|
-
}
|
|
23
|
-
function toHHMM(total) {
|
|
24
|
-
const t = (total % 1440 + 1440) % 1440;
|
|
25
|
-
const h = Math.floor(t / 60);
|
|
26
|
-
const mm = t % 60;
|
|
27
|
-
return `${String(h).padStart(2, "0")}:${String(mm).padStart(2, "0")}`;
|
|
28
|
-
}
|
|
29
|
-
const pad2 = (n) => String(n).padStart(2, "0");
|
|
30
|
-
class OkTimePicker extends LitElement {
|
|
31
|
-
constructor() {
|
|
32
|
-
super(...arguments);
|
|
33
|
-
this.value = "";
|
|
34
|
-
this.step = 5;
|
|
35
|
-
this.useAmpm = false;
|
|
36
|
-
this.min = "";
|
|
37
|
-
this.max = "";
|
|
38
|
-
this.disabled = false;
|
|
39
|
-
this.open = false;
|
|
40
|
-
this.end = false;
|
|
41
|
-
this.above = false;
|
|
42
|
-
this.onDocPointer = (e) => {
|
|
43
|
-
if (!this.open) return;
|
|
44
|
-
if (e.composedPath().includes(this)) return;
|
|
45
|
-
this.close();
|
|
46
|
-
};
|
|
47
|
-
this.onKeydown = (e) => {
|
|
48
|
-
if (e.key === "Escape" && this.open) {
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
this.close();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
static {
|
|
55
|
-
this.styles = css`
|
|
56
|
-
:host {
|
|
57
|
-
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
58
|
-
--color: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
59
|
-
--color-muted: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
60
|
-
--surface: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #ffffff)));
|
|
61
|
-
--border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 31, 41, 51), 0.14));
|
|
62
|
-
--hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 31, 41, 51), 0.06));
|
|
63
|
-
--primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
64
|
-
--primary-contrast: var(--ok-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
|
|
65
|
-
--primary-soft: var(--ok-primary-soft, rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.14));
|
|
66
|
-
--radius: var(--ok-radius, 10px);
|
|
67
|
-
--shadow: var(--ok-shadow, 0 8px 28px rgba(0, 0, 0, 0.18));
|
|
68
|
-
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
69
|
-
|
|
70
|
-
/* Inline: ocupa solo lo que mide la pastilla. */
|
|
71
|
-
display: inline-block;
|
|
72
|
-
position: relative;
|
|
73
|
-
color: var(--color);
|
|
74
|
-
font-family: var(--font);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* Pastilla disparadora: HH : MM (+ AM/PM) en mono tabular. */
|
|
78
|
-
.pill {
|
|
79
|
-
display: inline-flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
gap: 0.1rem;
|
|
82
|
-
padding: 0.3rem 0.6rem;
|
|
83
|
-
border: 1px solid var(--border-color);
|
|
84
|
-
border-radius: var(--radius);
|
|
85
|
-
background: var(--surface);
|
|
86
|
-
color: inherit;
|
|
87
|
-
font-family: inherit;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
|
|
90
|
-
}
|
|
91
|
-
@media (hover: hover) {
|
|
92
|
-
.pill:hover:not([disabled]) {
|
|
93
|
-
background: var(--hover-bg);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
.pill:focus-visible {
|
|
97
|
-
outline: none;
|
|
98
|
-
border-color: var(--primary-color);
|
|
99
|
-
box-shadow: 0 0 0 3px var(--primary-soft);
|
|
100
|
-
}
|
|
101
|
-
.pill[disabled] {
|
|
102
|
-
opacity: 0.5;
|
|
103
|
-
cursor: not-allowed;
|
|
104
|
-
}
|
|
105
|
-
.pill.open {
|
|
106
|
-
border-color: var(--primary-color);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/* Campos numéricos: mono + tabular-nums para que HH/MM no "bailen". */
|
|
110
|
-
.field {
|
|
111
|
-
font-size: 1.05rem;
|
|
112
|
-
font-weight: 600;
|
|
113
|
-
line-height: 1;
|
|
114
|
-
font-variant-numeric: tabular-nums;
|
|
115
|
-
font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
|
|
116
|
-
min-width: 1.7ch;
|
|
117
|
-
text-align: center;
|
|
118
|
-
}
|
|
119
|
-
.colon {
|
|
120
|
-
font-size: 1.05rem;
|
|
121
|
-
font-weight: 600;
|
|
122
|
-
line-height: 1;
|
|
123
|
-
opacity: 0.7;
|
|
124
|
-
padding: 0 0.05rem;
|
|
125
|
-
}
|
|
126
|
-
.meridiem {
|
|
127
|
-
margin-left: 0.3rem;
|
|
128
|
-
font-size: 0.7rem;
|
|
129
|
-
font-weight: 700;
|
|
130
|
-
letter-spacing: 0.04em;
|
|
131
|
-
color: var(--color-muted);
|
|
132
|
-
}
|
|
133
|
-
.caret {
|
|
134
|
-
margin-left: 0.35rem;
|
|
135
|
-
font-size: 0.95rem;
|
|
136
|
-
color: var(--color-muted);
|
|
137
|
-
transition: transform 180ms ease;
|
|
138
|
-
}
|
|
139
|
-
.pill.open .caret {
|
|
140
|
-
transform: rotate(180deg);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/* Popover propio: absolute (NO fixed) para no romperse bajo ancestros transformados. */
|
|
144
|
-
.panel {
|
|
145
|
-
position: absolute;
|
|
146
|
-
top: 100%;
|
|
147
|
-
left: 0;
|
|
148
|
-
margin-top: 6px;
|
|
149
|
-
z-index: 50;
|
|
150
|
-
display: flex;
|
|
151
|
-
background: var(--surface);
|
|
152
|
-
border: 1px solid var(--border-color);
|
|
153
|
-
border-radius: var(--radius);
|
|
154
|
-
box-shadow: var(--shadow);
|
|
155
|
-
overflow: hidden;
|
|
156
|
-
}
|
|
157
|
-
.panel.end {
|
|
158
|
-
left: auto;
|
|
159
|
-
right: 0;
|
|
160
|
-
}
|
|
161
|
-
.panel.above {
|
|
162
|
-
top: auto;
|
|
163
|
-
bottom: 100%;
|
|
164
|
-
margin-top: 0;
|
|
165
|
-
margin-bottom: 6px;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* Columna desplazable de opciones (horas / minutos / meridiano). */
|
|
169
|
-
.col {
|
|
170
|
-
display: flex;
|
|
171
|
-
flex-direction: column;
|
|
172
|
-
max-height: 220px;
|
|
173
|
-
overflow-y: auto;
|
|
174
|
-
scrollbar-width: thin;
|
|
175
|
-
border-right: 1px solid var(--border-color);
|
|
176
|
-
padding: 0.25rem 0;
|
|
177
|
-
}
|
|
178
|
-
.col:last-child {
|
|
179
|
-
border-right: 0;
|
|
180
|
-
}
|
|
181
|
-
.opt {
|
|
182
|
-
padding: 0.35rem 1rem;
|
|
183
|
-
font-size: 0.85rem;
|
|
184
|
-
font-variant-numeric: tabular-nums;
|
|
185
|
-
font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
|
|
186
|
-
background: transparent;
|
|
187
|
-
border: 0;
|
|
188
|
-
color: var(--color-muted);
|
|
189
|
-
cursor: pointer;
|
|
190
|
-
text-align: center;
|
|
191
|
-
min-width: 56px;
|
|
192
|
-
transition: background-color 120ms ease, color 120ms ease;
|
|
193
|
-
}
|
|
194
|
-
@media (hover: hover) {
|
|
195
|
-
.opt:hover:not([disabled]) {
|
|
196
|
-
background: var(--hover-bg);
|
|
197
|
-
color: var(--color);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
.opt[aria-selected='true'] {
|
|
201
|
-
background: var(--primary-soft);
|
|
202
|
-
color: var(--primary-color);
|
|
203
|
-
font-weight: 700;
|
|
204
|
-
}
|
|
205
|
-
.opt[disabled] {
|
|
206
|
-
opacity: 0.35;
|
|
207
|
-
cursor: not-allowed;
|
|
208
|
-
}
|
|
209
|
-
.opt:focus-visible {
|
|
210
|
-
outline: none;
|
|
211
|
-
background: var(--primary-soft);
|
|
212
|
-
color: var(--primary-color);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
@media (prefers-reduced-motion: reduce) {
|
|
216
|
-
.pill,
|
|
217
|
-
.caret,
|
|
218
|
-
.opt {
|
|
219
|
-
transition: none;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
`;
|
|
223
|
-
}
|
|
224
|
-
disconnectedCallback() {
|
|
225
|
-
super.disconnectedCallback();
|
|
226
|
-
this.unbind();
|
|
227
|
-
}
|
|
228
|
-
bind() {
|
|
229
|
-
document.addEventListener("pointerdown", this.onDocPointer, true);
|
|
230
|
-
document.addEventListener("keydown", this.onKeydown);
|
|
231
|
-
}
|
|
232
|
-
unbind() {
|
|
233
|
-
document.removeEventListener("pointerdown", this.onDocPointer, true);
|
|
234
|
-
document.removeEventListener("keydown", this.onKeydown);
|
|
235
|
-
}
|
|
236
|
-
// Minutos canónicos del valor actual (null si vacío/ inválido).
|
|
237
|
-
get current() {
|
|
238
|
-
return parseHHMM(this.value);
|
|
239
|
-
}
|
|
240
|
-
get minMin() {
|
|
241
|
-
return parseHHMM(this.min);
|
|
242
|
-
}
|
|
243
|
-
get maxMin() {
|
|
244
|
-
return parseHHMM(this.max);
|
|
245
|
-
}
|
|
246
|
-
// ¿Un total de minutos cae dentro de [min, max]?
|
|
247
|
-
inRange(total) {
|
|
248
|
-
const lo = this.minMin;
|
|
249
|
-
const hi = this.maxMin;
|
|
250
|
-
if (lo !== null && total < lo) return false;
|
|
251
|
-
if (hi !== null && total > hi) return false;
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
toggle() {
|
|
255
|
-
if (this.disabled) return;
|
|
256
|
-
this.open ? this.close() : this.openPanel();
|
|
257
|
-
}
|
|
258
|
-
openPanel() {
|
|
259
|
-
if (this.open) return;
|
|
260
|
-
this.open = true;
|
|
261
|
-
this.bind();
|
|
262
|
-
this.updateComplete.then(() => {
|
|
263
|
-
this.reanchor();
|
|
264
|
-
this.scrollToSelected();
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
close() {
|
|
268
|
-
if (!this.open) return;
|
|
269
|
-
this.open = false;
|
|
270
|
-
this.unbind();
|
|
271
|
-
}
|
|
272
|
-
// Recalcula alineación del popover según el espacio en viewport.
|
|
273
|
-
reanchor() {
|
|
274
|
-
const trigger = this.renderRoot.querySelector(".pill");
|
|
275
|
-
const panel = this.renderRoot.querySelector(".panel");
|
|
276
|
-
if (!trigger || !panel) return;
|
|
277
|
-
const side = computeAnchor(trigger, panel);
|
|
278
|
-
this.end = side.end;
|
|
279
|
-
this.above = side.above;
|
|
280
|
-
}
|
|
281
|
-
// Centra (sin animación brusca) la opción seleccionada en cada columna al abrir.
|
|
282
|
-
scrollToSelected() {
|
|
283
|
-
const sel = this.renderRoot.querySelectorAll('.opt[aria-selected="true"]');
|
|
284
|
-
sel.forEach((el) => {
|
|
285
|
-
const col = el.parentElement;
|
|
286
|
-
if (col) col.scrollTop = el.offsetTop - col.clientHeight / 2 + el.clientHeight / 2;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
// Emite el nuevo valor canónico y lo refleja en la prop.
|
|
290
|
-
commit(total) {
|
|
291
|
-
const next = toHHMM(total);
|
|
292
|
-
if (next === this.value) return;
|
|
293
|
-
this.value = next;
|
|
294
|
-
this.dispatchEvent(
|
|
295
|
-
new CustomEvent("ok-change", {
|
|
296
|
-
detail: { value: next },
|
|
297
|
-
bubbles: true,
|
|
298
|
-
composed: true
|
|
299
|
-
})
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
// Selecciona la hora (manteniendo los minutos actuales o 0).
|
|
303
|
-
pickHour(h) {
|
|
304
|
-
const cur = this.current;
|
|
305
|
-
const mm = cur !== null ? cur % 60 : 0;
|
|
306
|
-
this.commit(h * 60 + mm);
|
|
307
|
-
}
|
|
308
|
-
// Selecciona el minuto (manteniendo la hora actual o 0).
|
|
309
|
-
pickMinute(mm) {
|
|
310
|
-
const cur = this.current;
|
|
311
|
-
const h = cur !== null ? Math.floor(cur / 60) : 0;
|
|
312
|
-
this.commit(h * 60 + mm);
|
|
313
|
-
}
|
|
314
|
-
// Cambia el meridiano (AM/PM) desplazando la hora ±12 si hace falta.
|
|
315
|
-
pickMeridiem(pm) {
|
|
316
|
-
const cur = this.current ?? 0;
|
|
317
|
-
let h = Math.floor(cur / 60);
|
|
318
|
-
const mm = cur % 60;
|
|
319
|
-
const isPm = h >= 12;
|
|
320
|
-
if (pm && !isPm) h += 12;
|
|
321
|
-
else if (!pm && isPm) h -= 12;
|
|
322
|
-
this.commit(h * 60 + mm);
|
|
323
|
-
}
|
|
324
|
-
// Lista de horas válidas (0..23). El filtrado de rango se aplica por opción.
|
|
325
|
-
hourOptions() {
|
|
326
|
-
return Array.from({ length: 24 }, (_, i) => i);
|
|
327
|
-
}
|
|
328
|
-
// Lista de minutos según `step` (siempre ≥1, ≤30 por seguridad).
|
|
329
|
-
minuteOptions() {
|
|
330
|
-
const step = Math.min(Math.max(Math.floor(this.step) || 5, 1), 30);
|
|
331
|
-
const out = [];
|
|
332
|
-
for (let m = 0; m < 60; m += step) out.push(m);
|
|
333
|
-
return out;
|
|
334
|
-
}
|
|
335
|
-
// Texto del campo HH para la pastilla (12h si use-ampm, con la hora canónica si existe).
|
|
336
|
-
displayHour() {
|
|
337
|
-
const cur = this.current;
|
|
338
|
-
if (cur === null) return "--";
|
|
339
|
-
const h24 = Math.floor(cur / 60);
|
|
340
|
-
if (this.useAmpm) {
|
|
341
|
-
const h12 = h24 % 12 === 0 ? 12 : h24 % 12;
|
|
342
|
-
return pad2(h12);
|
|
343
|
-
}
|
|
344
|
-
return pad2(h24);
|
|
345
|
-
}
|
|
346
|
-
displayMinute() {
|
|
347
|
-
const cur = this.current;
|
|
348
|
-
if (cur === null) return "--";
|
|
349
|
-
return pad2(cur % 60);
|
|
350
|
-
}
|
|
351
|
-
// Etiqueta de hora dentro de la columna (respeta 12h/24h).
|
|
352
|
-
hourLabel(h24) {
|
|
353
|
-
if (this.useAmpm) {
|
|
354
|
-
const h12 = h24 % 12 === 0 ? 12 : h24 % 12;
|
|
355
|
-
return pad2(h12);
|
|
356
|
-
}
|
|
357
|
-
return pad2(h24);
|
|
358
|
-
}
|
|
359
|
-
get isPm() {
|
|
360
|
-
const cur = this.current;
|
|
361
|
-
return cur !== null && Math.floor(cur / 60) >= 12;
|
|
362
|
-
}
|
|
363
|
-
render() {
|
|
364
|
-
const cur = this.current;
|
|
365
|
-
const selHour = cur !== null ? Math.floor(cur / 60) : -1;
|
|
366
|
-
const selMinute = cur !== null ? cur % 60 : -1;
|
|
367
|
-
return html`
|
|
368
|
-
<button
|
|
369
|
-
type="button"
|
|
370
|
-
class="pill ${this.open ? "open" : ""}"
|
|
371
|
-
?disabled=${this.disabled}
|
|
372
|
-
aria-haspopup="listbox"
|
|
373
|
-
aria-expanded=${this.open ? "true" : "false"}
|
|
374
|
-
aria-label="Time picker"
|
|
375
|
-
@click=${() => this.toggle()}
|
|
376
|
-
>
|
|
377
|
-
<span class="field" aria-hidden="true">${this.displayHour()}</span>
|
|
378
|
-
<span class="colon" aria-hidden="true">:</span>
|
|
379
|
-
<span class="field" aria-hidden="true">${this.displayMinute()}</span>
|
|
380
|
-
${this.useAmpm ? html`<span class="meridiem">${this.isPm ? "PM" : "AM"}</span>` : null}
|
|
381
|
-
<span class="caret" aria-hidden="true">▾</span>
|
|
382
|
-
</button>
|
|
383
|
-
${this.open ? this.panelTemplate(selHour, selMinute) : null}
|
|
384
|
-
`;
|
|
385
|
-
}
|
|
386
|
-
panelTemplate(selHour, selMinute) {
|
|
387
|
-
const cls = `panel ${this.end ? "end" : ""} ${this.above ? "above" : ""}`;
|
|
388
|
-
return html`
|
|
389
|
-
<div class=${cls} role="dialog" aria-label="Choose time">
|
|
390
|
-
<div class="col" role="listbox" aria-label="Hours">
|
|
391
|
-
${this.hourOptions().map((h) => {
|
|
392
|
-
const enabled = this.minuteOptions().some((mm) => this.inRange(h * 60 + mm));
|
|
393
|
-
const selected = h === selHour;
|
|
394
|
-
return html`<button
|
|
395
|
-
type="button"
|
|
396
|
-
class="opt"
|
|
397
|
-
role="option"
|
|
398
|
-
aria-selected=${selected ? "true" : "false"}
|
|
399
|
-
?disabled=${!enabled}
|
|
400
|
-
@click=${() => this.pickHour(h)}
|
|
401
|
-
>
|
|
402
|
-
${this.hourLabel(h)}
|
|
403
|
-
</button>`;
|
|
404
|
-
})}
|
|
405
|
-
</div>
|
|
406
|
-
<div class="col" role="listbox" aria-label="Minutes">
|
|
407
|
-
${this.minuteOptions().map((mm) => {
|
|
408
|
-
const baseHour = selHour >= 0 ? selHour : 0;
|
|
409
|
-
const enabled = this.inRange(baseHour * 60 + mm);
|
|
410
|
-
const selected = mm === selMinute;
|
|
411
|
-
return html`<button
|
|
412
|
-
type="button"
|
|
413
|
-
class="opt"
|
|
414
|
-
role="option"
|
|
415
|
-
aria-selected=${selected ? "true" : "false"}
|
|
416
|
-
?disabled=${!enabled}
|
|
417
|
-
@click=${() => this.pickMinute(mm)}
|
|
418
|
-
>
|
|
419
|
-
${pad2(mm)}
|
|
420
|
-
</button>`;
|
|
421
|
-
})}
|
|
422
|
-
</div>
|
|
423
|
-
${this.useAmpm ? html`<div class="col" role="listbox" aria-label="AM/PM">
|
|
424
|
-
${["AM", "PM"].map((m, i) => {
|
|
425
|
-
const pm = i === 1;
|
|
426
|
-
const selected = this.current !== null && pm === this.isPm;
|
|
427
|
-
return html`<button
|
|
428
|
-
type="button"
|
|
429
|
-
class="opt"
|
|
430
|
-
role="option"
|
|
431
|
-
aria-selected=${selected ? "true" : "false"}
|
|
432
|
-
@click=${() => this.pickMeridiem(pm)}
|
|
433
|
-
>
|
|
434
|
-
${m}
|
|
435
|
-
</button>`;
|
|
436
|
-
})}
|
|
437
|
-
</div>` : null}
|
|
438
|
-
</div>
|
|
439
|
-
`;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
__decorateClass([
|
|
443
|
-
property()
|
|
444
|
-
], OkTimePicker.prototype, "value");
|
|
445
|
-
__decorateClass([
|
|
446
|
-
property({ type: Number })
|
|
447
|
-
], OkTimePicker.prototype, "step");
|
|
448
|
-
__decorateClass([
|
|
449
|
-
property({ type: Boolean, attribute: "use-ampm" })
|
|
450
|
-
], OkTimePicker.prototype, "useAmpm");
|
|
451
|
-
__decorateClass([
|
|
452
|
-
property()
|
|
453
|
-
], OkTimePicker.prototype, "min");
|
|
454
|
-
__decorateClass([
|
|
455
|
-
property()
|
|
456
|
-
], OkTimePicker.prototype, "max");
|
|
457
|
-
__decorateClass([
|
|
458
|
-
property({ type: Boolean, reflect: true })
|
|
459
|
-
], OkTimePicker.prototype, "disabled");
|
|
460
|
-
__decorateClass([
|
|
461
|
-
state()
|
|
462
|
-
], OkTimePicker.prototype, "open");
|
|
463
|
-
__decorateClass([
|
|
464
|
-
state()
|
|
465
|
-
], OkTimePicker.prototype, "end");
|
|
466
|
-
__decorateClass([
|
|
467
|
-
state()
|
|
468
|
-
], OkTimePicker.prototype, "above");
|
|
469
|
-
define("ok-time-picker", OkTimePicker);
|
|
470
|
-
export {
|
|
471
|
-
OkTimePicker
|
|
472
|
-
};
|