@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,472 @@
|
|
|
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
|
+
};
|