@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,134 @@
|
|
|
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 OkCtaBand extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.variant = "solid";
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.styles = css`
|
|
20
|
+
:host {
|
|
21
|
+
display: block;
|
|
22
|
+
width: 100%;
|
|
23
|
+
--primary: var(--ion-color-primary, #1496d6);
|
|
24
|
+
--primary-contrast: var(--ion-color-primary-contrast, #ffffff);
|
|
25
|
+
--color: var(--ok-text, var(--ion-text-color, #18181b));
|
|
26
|
+
--muted: var(--ok-muted, rgba(var(--ion-text-color-rgb, 24, 24, 27), 0.62));
|
|
27
|
+
--surface: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #fff)));
|
|
28
|
+
--radius: var(--ok-radius-lg, 28px);
|
|
29
|
+
font-family: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
30
|
+
}
|
|
31
|
+
.band {
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
position: relative;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
border-radius: var(--radius);
|
|
36
|
+
padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 5vw, 4rem);
|
|
37
|
+
text-align: center;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 1rem;
|
|
42
|
+
}
|
|
43
|
+
/* Sólido de marca (def): texto en contraste */
|
|
44
|
+
:host(:not([variant])) .band,
|
|
45
|
+
:host([variant='solid']) .band {
|
|
46
|
+
color: var(--primary-contrast);
|
|
47
|
+
background:
|
|
48
|
+
radial-gradient(80% 120% at 0% 0%, color-mix(in oklab, #fff 22%, transparent), transparent 60%),
|
|
49
|
+
radial-gradient(80% 120% at 100% 100%, color-mix(in oklab, #000 18%, transparent), transparent 55%),
|
|
50
|
+
linear-gradient(120deg, var(--primary), color-mix(in oklab, var(--primary) 60%, #6d28d9 40%));
|
|
51
|
+
}
|
|
52
|
+
:host([variant='solid']) .eyebrow,
|
|
53
|
+
:host(:not([variant])) .eyebrow { color: color-mix(in oklab, var(--primary-contrast) 85%, transparent); }
|
|
54
|
+
:host([variant='solid']) .sub,
|
|
55
|
+
:host(:not([variant])) .sub { color: color-mix(in oklab, var(--primary-contrast) 85%, transparent); }
|
|
56
|
+
/* Glass / sutil: hereda el color del tema */
|
|
57
|
+
:host([variant='soft']) .band {
|
|
58
|
+
color: var(--color);
|
|
59
|
+
background: linear-gradient(135deg, color-mix(in oklab, var(--primary) 10%, var(--surface)),
|
|
60
|
+
color-mix(in oklab, var(--primary) 3%, var(--surface)));
|
|
61
|
+
border: 1px solid color-mix(in oklab, var(--primary) 22%, transparent);
|
|
62
|
+
}
|
|
63
|
+
:host([variant='glass']) .band {
|
|
64
|
+
color: var(--color);
|
|
65
|
+
background: color-mix(in oklab, var(--surface) 55%, transparent);
|
|
66
|
+
-webkit-backdrop-filter: blur(18px) saturate(1.4);
|
|
67
|
+
backdrop-filter: blur(18px) saturate(1.4);
|
|
68
|
+
border: 1px solid color-mix(in oklab, var(--color) 12%, transparent);
|
|
69
|
+
}
|
|
70
|
+
.eyebrow {
|
|
71
|
+
font-size: 0.74rem;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
letter-spacing: 0.06em;
|
|
74
|
+
text-transform: uppercase;
|
|
75
|
+
color: var(--muted);
|
|
76
|
+
}
|
|
77
|
+
.title {
|
|
78
|
+
margin: 0;
|
|
79
|
+
font-size: clamp(1.7rem, 1.1rem + 2.8vw, 3rem);
|
|
80
|
+
line-height: 1.08;
|
|
81
|
+
letter-spacing: -0.03em;
|
|
82
|
+
font-weight: 680;
|
|
83
|
+
max-width: 22ch;
|
|
84
|
+
}
|
|
85
|
+
::slotted([slot='heading']) {
|
|
86
|
+
margin: 0;
|
|
87
|
+
font-size: clamp(1.7rem, 1.1rem + 2.8vw, 3rem);
|
|
88
|
+
line-height: 1.08;
|
|
89
|
+
letter-spacing: -0.03em;
|
|
90
|
+
font-weight: 680;
|
|
91
|
+
}
|
|
92
|
+
.sub {
|
|
93
|
+
margin: 0;
|
|
94
|
+
font-size: clamp(1rem, 0.95rem + 0.3vw, 1.2rem);
|
|
95
|
+
line-height: 1.5;
|
|
96
|
+
color: var(--muted);
|
|
97
|
+
max-width: 50ch;
|
|
98
|
+
}
|
|
99
|
+
.actions {
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-wrap: wrap;
|
|
102
|
+
gap: 0.75rem;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
margin-top: 0.6rem;
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
render() {
|
|
109
|
+
return html`
|
|
110
|
+
<div class="band">
|
|
111
|
+
${this.eyebrow ? html`<span class="eyebrow">${this.eyebrow}</span>` : null}
|
|
112
|
+
${this.heading ? html`<h2 class="title">${this.heading}</h2>` : html`<slot name="heading"></slot>`}
|
|
113
|
+
${this.subheading ? html`<p class="sub">${this.subheading}</p>` : null}
|
|
114
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
115
|
+
</div>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property()
|
|
121
|
+
], OkCtaBand.prototype, "eyebrow");
|
|
122
|
+
__decorateClass([
|
|
123
|
+
property()
|
|
124
|
+
], OkCtaBand.prototype, "heading");
|
|
125
|
+
__decorateClass([
|
|
126
|
+
property()
|
|
127
|
+
], OkCtaBand.prototype, "subheading");
|
|
128
|
+
__decorateClass([
|
|
129
|
+
property({ reflect: true })
|
|
130
|
+
], OkCtaBand.prototype, "variant");
|
|
131
|
+
define("ok-cta-band", OkCtaBand);
|
|
132
|
+
export {
|
|
133
|
+
OkCtaBand
|
|
134
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property, state } from "lit/decorators.js";
|
|
3
|
+
import { define } from "./define.js";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
|
+
var result = void 0;
|
|
7
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
|
+
if (decorator = decorators[i])
|
|
9
|
+
result = decorator(target, key, result) || result;
|
|
10
|
+
if (result) __defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
class OkCurrency extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.currency = "EUR";
|
|
17
|
+
this.locale = typeof navigator !== "undefined" && navigator.language || "es-ES";
|
|
18
|
+
this.placeholder = "";
|
|
19
|
+
this.display = "";
|
|
20
|
+
this.focused = false;
|
|
21
|
+
}
|
|
22
|
+
static {
|
|
23
|
+
this.styles = css`
|
|
24
|
+
:host {
|
|
25
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
26
|
+
--background: var(--ok-surface, var(--ion-item-background, #ffffff));
|
|
27
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
28
|
+
--border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.2));
|
|
29
|
+
--border-radius: var(--ok-radius, var(--ion-border-radius, 8px));
|
|
30
|
+
--primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
31
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
32
|
+
|
|
33
|
+
/* Ocupa el ancho del contenedor y es responsive. */
|
|
34
|
+
display: block;
|
|
35
|
+
width: 100%;
|
|
36
|
+
color: var(--color);
|
|
37
|
+
font-family: var(--font);
|
|
38
|
+
}
|
|
39
|
+
.control {
|
|
40
|
+
--background: var(--background);
|
|
41
|
+
--color: var(--color);
|
|
42
|
+
--border-color: var(--border-color);
|
|
43
|
+
--border-radius: var(--border-radius);
|
|
44
|
+
--highlight-color-focused: var(--primary-color);
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
// Construye un formateador de moneda (símbolo + miles + 2 decimales) para el locale actual.
|
|
50
|
+
currencyFormatter() {
|
|
51
|
+
return new Intl.NumberFormat(this.locale, {
|
|
52
|
+
style: "currency",
|
|
53
|
+
currency: this.currency
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Devuelve el separador decimal del locale (',' o '.') usando Intl.
|
|
57
|
+
decimalSeparator() {
|
|
58
|
+
const parts = new Intl.NumberFormat(this.locale).formatToParts(1.1);
|
|
59
|
+
return parts.find((p) => p.type === "decimal")?.value ?? ".";
|
|
60
|
+
}
|
|
61
|
+
// Limpia el texto crudo dejando sólo dígitos y un único separador decimal.
|
|
62
|
+
sanitize(raw) {
|
|
63
|
+
const sep = this.decimalSeparator();
|
|
64
|
+
let out = "";
|
|
65
|
+
let hasSep = false;
|
|
66
|
+
for (const ch of raw) {
|
|
67
|
+
if (ch >= "0" && ch <= "9") out += ch;
|
|
68
|
+
else if (ch === sep && !hasSep) {
|
|
69
|
+
out += sep;
|
|
70
|
+
hasSep = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
// Convierte el texto crudo (con separador del locale) a number. NaN si no hay número.
|
|
76
|
+
parse(raw) {
|
|
77
|
+
const sep = this.decimalSeparator();
|
|
78
|
+
const normalized = this.sanitize(raw).split(sep).join(".");
|
|
79
|
+
if (!normalized) return NaN;
|
|
80
|
+
return Number(normalized);
|
|
81
|
+
}
|
|
82
|
+
// Sincroniza el texto mostrado a partir del `value` cuando NO está enfocado.
|
|
83
|
+
syncDisplayFromValue() {
|
|
84
|
+
if (this.focused) return;
|
|
85
|
+
if (this.value == null || Number.isNaN(this.value)) {
|
|
86
|
+
this.display = "";
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.display = this.currencyFormatter().format(this.value);
|
|
90
|
+
}
|
|
91
|
+
// Recalcula el display ante cambios de props relevantes (value/currency/locale).
|
|
92
|
+
willUpdate(changed) {
|
|
93
|
+
if ((changed.has("value") || changed.has("currency") || changed.has("locale")) && !this.focused) {
|
|
94
|
+
this.syncDisplayFromValue();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Mientras escribe: filtra a dígitos + separador decimal y refleja el texto crudo.
|
|
98
|
+
onInput(e) {
|
|
99
|
+
const raw = e.detail?.value ?? "";
|
|
100
|
+
this.display = this.sanitize(String(raw));
|
|
101
|
+
}
|
|
102
|
+
// Al enfocar: muestra el número crudo (sin símbolo ni miles) para editar cómodamente.
|
|
103
|
+
onFocus() {
|
|
104
|
+
this.focused = true;
|
|
105
|
+
if (this.value != null && !Number.isNaN(this.value)) {
|
|
106
|
+
const sep = this.decimalSeparator();
|
|
107
|
+
this.display = String(this.value).split(".").join(sep);
|
|
108
|
+
} else {
|
|
109
|
+
this.display = "";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Al perder el foco: parsea, reformatea con símbolo y emite `ok-change` si cambió.
|
|
113
|
+
onBlur() {
|
|
114
|
+
this.focused = false;
|
|
115
|
+
const parsed = this.parse(this.display);
|
|
116
|
+
if (Number.isNaN(parsed)) {
|
|
117
|
+
this.value = void 0;
|
|
118
|
+
this.display = "";
|
|
119
|
+
} else {
|
|
120
|
+
this.value = parsed;
|
|
121
|
+
this.display = this.currencyFormatter().format(parsed);
|
|
122
|
+
}
|
|
123
|
+
this.dispatchEvent(
|
|
124
|
+
new CustomEvent("ok-change", {
|
|
125
|
+
detail: { value: Number.isNaN(parsed) ? NaN : parsed },
|
|
126
|
+
bubbles: true,
|
|
127
|
+
composed: true
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
render() {
|
|
132
|
+
return html`
|
|
133
|
+
<ion-input
|
|
134
|
+
class="control"
|
|
135
|
+
fill="outline"
|
|
136
|
+
inputmode="decimal"
|
|
137
|
+
label=${this.label ?? ""}
|
|
138
|
+
label-placement=${this.label ? "stacked" : "fixed"}
|
|
139
|
+
placeholder=${this.placeholder}
|
|
140
|
+
.value=${this.display}
|
|
141
|
+
@ionInput=${this.onInput}
|
|
142
|
+
@ionFocus=${this.onFocus}
|
|
143
|
+
@ionBlur=${this.onBlur}
|
|
144
|
+
></ion-input>
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
__decorateClass([
|
|
149
|
+
property({ type: Number })
|
|
150
|
+
], OkCurrency.prototype, "value");
|
|
151
|
+
__decorateClass([
|
|
152
|
+
property()
|
|
153
|
+
], OkCurrency.prototype, "currency");
|
|
154
|
+
__decorateClass([
|
|
155
|
+
property()
|
|
156
|
+
], OkCurrency.prototype, "locale");
|
|
157
|
+
__decorateClass([
|
|
158
|
+
property()
|
|
159
|
+
], OkCurrency.prototype, "placeholder");
|
|
160
|
+
__decorateClass([
|
|
161
|
+
property()
|
|
162
|
+
], OkCurrency.prototype, "label");
|
|
163
|
+
__decorateClass([
|
|
164
|
+
state()
|
|
165
|
+
], OkCurrency.prototype, "display");
|
|
166
|
+
__decorateClass([
|
|
167
|
+
state()
|
|
168
|
+
], OkCurrency.prototype, "focused");
|
|
169
|
+
define("ok-currency", OkCurrency);
|
|
170
|
+
export {
|
|
171
|
+
OkCurrency
|
|
172
|
+
};
|