@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
package/dist/ok-bento.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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 OkBento extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.cols = 6;
|
|
17
|
+
this.colsMd = 4;
|
|
18
|
+
this.gap = "1rem";
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
this.styles = css`
|
|
22
|
+
:host {
|
|
23
|
+
display: grid;
|
|
24
|
+
width: 100%;
|
|
25
|
+
grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
|
|
26
|
+
grid-auto-rows: var(--row-height, minmax(120px, auto));
|
|
27
|
+
gap: var(--gap, 1rem);
|
|
28
|
+
}
|
|
29
|
+
@media (max-width: 900px) {
|
|
30
|
+
:host {
|
|
31
|
+
grid-template-columns: repeat(var(--cols-md, 4), minmax(0, 1fr));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
@media (max-width: 560px) {
|
|
35
|
+
:host {
|
|
36
|
+
grid-template-columns: 1fr;
|
|
37
|
+
grid-auto-rows: auto;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
updated() {
|
|
43
|
+
this.style.setProperty("--cols", String(this.cols));
|
|
44
|
+
this.style.setProperty("--cols-md", String(this.colsMd));
|
|
45
|
+
this.style.setProperty("--gap", this.gap);
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return html`<slot></slot>`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
__decorateClass([
|
|
52
|
+
property({ type: Number })
|
|
53
|
+
], OkBento.prototype, "cols");
|
|
54
|
+
__decorateClass([
|
|
55
|
+
property({ type: Number, attribute: "cols-md" })
|
|
56
|
+
], OkBento.prototype, "colsMd");
|
|
57
|
+
__decorateClass([
|
|
58
|
+
property()
|
|
59
|
+
], OkBento.prototype, "gap");
|
|
60
|
+
define("ok-bento", OkBento);
|
|
61
|
+
export {
|
|
62
|
+
OkBento
|
|
63
|
+
};
|
|
@@ -0,0 +1,406 @@
|
|
|
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
|
+
const KEYS = [
|
|
14
|
+
{ label: "AC", kind: "fn", wide: true },
|
|
15
|
+
{ label: "⌫", kind: "fn" },
|
|
16
|
+
{ label: "÷", kind: "op", op: "/" },
|
|
17
|
+
{ label: "7", kind: "digit" },
|
|
18
|
+
{ label: "8", kind: "digit" },
|
|
19
|
+
{ label: "9", kind: "digit" },
|
|
20
|
+
{ label: "×", kind: "op", op: "*" },
|
|
21
|
+
{ label: "4", kind: "digit" },
|
|
22
|
+
{ label: "5", kind: "digit" },
|
|
23
|
+
{ label: "6", kind: "digit" },
|
|
24
|
+
{ label: "−", kind: "op", op: "-" },
|
|
25
|
+
{ label: "1", kind: "digit" },
|
|
26
|
+
{ label: "2", kind: "digit" },
|
|
27
|
+
{ label: "3", kind: "digit" },
|
|
28
|
+
{ label: "+", kind: "op", op: "+" },
|
|
29
|
+
{ label: "0", kind: "digit", wide: true },
|
|
30
|
+
{ label: ".", kind: "dot" },
|
|
31
|
+
{ label: "=", kind: "equals" }
|
|
32
|
+
];
|
|
33
|
+
const OP_SYMBOL = {
|
|
34
|
+
"+": "+",
|
|
35
|
+
"-": "−",
|
|
36
|
+
"*": "×",
|
|
37
|
+
"/": "÷"
|
|
38
|
+
};
|
|
39
|
+
class OkCalculator extends LitElement {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this._display = "0";
|
|
43
|
+
this._prev = "";
|
|
44
|
+
this._op = "";
|
|
45
|
+
this._stored = 0;
|
|
46
|
+
this._justEvaluated = false;
|
|
47
|
+
}
|
|
48
|
+
static {
|
|
49
|
+
this.styles = css`
|
|
50
|
+
:host {
|
|
51
|
+
display: block;
|
|
52
|
+
width: 100%;
|
|
53
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
54
|
+
--bg: var(--ok-surface-2, var(--ion-color-step-50, #f7f7f8));
|
|
55
|
+
--display-bg: var(--ok-surface-3, var(--ion-color-step-100, #eeeef0));
|
|
56
|
+
--line: var(--ok-border-color, var(--ion-border-color, #d7d8da));
|
|
57
|
+
--ink: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
58
|
+
--ink-2: var(--ok-color-medium-shade, var(--ion-color-medium-shade, #5a5e62));
|
|
59
|
+
--ink-3: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
60
|
+
--key-bg: var(--ok-surface-3, var(--ion-color-step-100, #eeeef0));
|
|
61
|
+
--key-bg-hover: var(--ok-surface-4, var(--ion-color-step-150, #e3e3e6));
|
|
62
|
+
--radius-md: var(--ok-radius-md, 10px);
|
|
63
|
+
--radius-lg: var(--ok-radius-lg, 14px);
|
|
64
|
+
--radius-xl: var(--ok-radius-xl, 18px);
|
|
65
|
+
/* Operador ámbar (warn). */
|
|
66
|
+
--op-bg: var(--ok-color-warning-tint, var(--ion-color-warning-tint, #ffd965));
|
|
67
|
+
--op-fg: var(--ok-color-warning-shade, var(--ion-color-warning-shade, #b88a00));
|
|
68
|
+
--op-active-bg: var(--ok-color-warning, var(--ion-color-warning, #ffc409));
|
|
69
|
+
--op-active-fg: var(--ok-color-warning-contrast, var(--ion-color-warning-contrast, #1f2933));
|
|
70
|
+
/* Equals en color de marca. */
|
|
71
|
+
--equals-bg: var(--ok-color-primary, var(--ion-color-primary, #3880ff));
|
|
72
|
+
--equals-bg-hover: var(--ok-color-primary-shade, var(--ion-color-primary-shade, #3171e0));
|
|
73
|
+
--equals-fg: var(--ok-color-primary-contrast, var(--ion-color-primary-contrast, #fff));
|
|
74
|
+
--glow: var(--ok-focus-ring, 0 0 0 3px rgba(56, 128, 255, 0.35));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.calc {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: 12px;
|
|
81
|
+
width: 280px;
|
|
82
|
+
max-width: 100%;
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
padding: 14px;
|
|
85
|
+
background: var(--bg);
|
|
86
|
+
border: 1px solid var(--line);
|
|
87
|
+
border-radius: var(--radius-xl);
|
|
88
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.display {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
align-items: flex-end;
|
|
95
|
+
justify-content: flex-end;
|
|
96
|
+
gap: 4px;
|
|
97
|
+
min-height: 78px;
|
|
98
|
+
padding: 12px 14px;
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
background: var(--display-bg);
|
|
101
|
+
border: 1px solid var(--line);
|
|
102
|
+
border-radius: var(--radius-lg);
|
|
103
|
+
text-align: right;
|
|
104
|
+
font-variant-numeric: tabular-nums;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.display-prev {
|
|
109
|
+
width: 100%;
|
|
110
|
+
font-size: 0.8125rem;
|
|
111
|
+
color: var(--ink-3);
|
|
112
|
+
letter-spacing: -0.01em;
|
|
113
|
+
line-height: 1.2;
|
|
114
|
+
white-space: nowrap;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
text-overflow: ellipsis;
|
|
117
|
+
min-height: 14px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.display-value {
|
|
121
|
+
width: 100%;
|
|
122
|
+
font-size: 1.875rem; /* 3xl */
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
color: var(--ink);
|
|
125
|
+
letter-spacing: -0.03em;
|
|
126
|
+
line-height: 1.05;
|
|
127
|
+
white-space: nowrap;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
text-overflow: ellipsis;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.keys {
|
|
133
|
+
display: grid;
|
|
134
|
+
grid-template-columns: repeat(4, 1fr);
|
|
135
|
+
gap: 6px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.key {
|
|
139
|
+
height: 48px;
|
|
140
|
+
display: inline-flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
box-sizing: border-box;
|
|
144
|
+
background: var(--key-bg);
|
|
145
|
+
border: 1px solid var(--line);
|
|
146
|
+
border-radius: var(--radius-md);
|
|
147
|
+
color: var(--ink);
|
|
148
|
+
font: inherit;
|
|
149
|
+
font-size: 1.125rem;
|
|
150
|
+
font-weight: 500;
|
|
151
|
+
font-variant-numeric: tabular-nums;
|
|
152
|
+
letter-spacing: -0.02em;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
user-select: none;
|
|
155
|
+
transition: background 120ms ease, transform 120ms ease;
|
|
156
|
+
}
|
|
157
|
+
.key:hover {
|
|
158
|
+
background: var(--key-bg-hover);
|
|
159
|
+
}
|
|
160
|
+
.key:active {
|
|
161
|
+
transform: scale(0.96);
|
|
162
|
+
}
|
|
163
|
+
.key:focus-visible {
|
|
164
|
+
outline: none;
|
|
165
|
+
box-shadow: var(--glow);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.key--op {
|
|
169
|
+
background: var(--op-bg);
|
|
170
|
+
color: var(--op-fg);
|
|
171
|
+
border-color: transparent;
|
|
172
|
+
}
|
|
173
|
+
.key--op:hover {
|
|
174
|
+
background: var(--op-bg);
|
|
175
|
+
filter: brightness(0.96);
|
|
176
|
+
}
|
|
177
|
+
.key--op.is-active {
|
|
178
|
+
background: var(--op-active-bg);
|
|
179
|
+
color: var(--op-active-fg);
|
|
180
|
+
border-color: transparent;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.key--equals {
|
|
184
|
+
background: var(--equals-bg);
|
|
185
|
+
color: var(--equals-fg);
|
|
186
|
+
border-color: transparent;
|
|
187
|
+
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.18);
|
|
188
|
+
}
|
|
189
|
+
.key--equals:hover {
|
|
190
|
+
background: var(--equals-bg-hover);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.key--fn {
|
|
194
|
+
background: transparent;
|
|
195
|
+
color: var(--ink-2);
|
|
196
|
+
font-size: 0.875rem;
|
|
197
|
+
font-weight: 500;
|
|
198
|
+
text-transform: uppercase;
|
|
199
|
+
letter-spacing: 0.04em;
|
|
200
|
+
}
|
|
201
|
+
.key--fn:hover {
|
|
202
|
+
background: var(--key-bg);
|
|
203
|
+
color: var(--ink);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.key--wide {
|
|
207
|
+
grid-column: span 2;
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
// Devuelve el display efectivo (controlado si `value` está definido).
|
|
212
|
+
get _shownValue() {
|
|
213
|
+
return this.value !== void 0 ? this.value : this._display;
|
|
214
|
+
}
|
|
215
|
+
render() {
|
|
216
|
+
return html`
|
|
217
|
+
<div class="calc" role="group" aria-label="Calculadora">
|
|
218
|
+
<div class="display">
|
|
219
|
+
<div class="display-prev" aria-hidden="true">${this._prev}</div>
|
|
220
|
+
<div class="display-value" role="status" aria-live="polite">
|
|
221
|
+
${this._shownValue}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
<div class="keys">
|
|
225
|
+
${KEYS.map((k) => this._renderKey(k))}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
_renderKey(k) {
|
|
231
|
+
const classes = ["key"];
|
|
232
|
+
if (k.kind === "op") classes.push("key--op");
|
|
233
|
+
if (k.kind === "equals") classes.push("key--equals");
|
|
234
|
+
if (k.kind === "fn") classes.push("key--fn");
|
|
235
|
+
if (k.wide) classes.push("key--wide");
|
|
236
|
+
const active = k.kind === "op" && k.op === this._op;
|
|
237
|
+
if (active) classes.push("is-active");
|
|
238
|
+
return html`
|
|
239
|
+
<button
|
|
240
|
+
type="button"
|
|
241
|
+
class=${classes.join(" ")}
|
|
242
|
+
aria-pressed=${k.kind === "op" ? String(active) : "false"}
|
|
243
|
+
aria-label=${this._ariaForKey(k)}
|
|
244
|
+
@click=${() => this._onKey(k)}
|
|
245
|
+
>
|
|
246
|
+
${k.label}
|
|
247
|
+
</button>
|
|
248
|
+
`;
|
|
249
|
+
}
|
|
250
|
+
// Etiqueta accesible legible para teclas con símbolos.
|
|
251
|
+
_ariaForKey(k) {
|
|
252
|
+
switch (k.label) {
|
|
253
|
+
case "÷":
|
|
254
|
+
return "Dividir";
|
|
255
|
+
case "×":
|
|
256
|
+
return "Multiplicar";
|
|
257
|
+
case "−":
|
|
258
|
+
return "Restar";
|
|
259
|
+
case "+":
|
|
260
|
+
return "Sumar";
|
|
261
|
+
case "=":
|
|
262
|
+
return "Igual";
|
|
263
|
+
case "⌫":
|
|
264
|
+
return "Borrar";
|
|
265
|
+
case "AC":
|
|
266
|
+
return "Borrar todo";
|
|
267
|
+
case ".":
|
|
268
|
+
return "Coma decimal";
|
|
269
|
+
default:
|
|
270
|
+
return k.label;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Despacha la pulsación según el tipo de tecla y emite los eventos.
|
|
274
|
+
_onKey(k) {
|
|
275
|
+
this._emitInput(k.label);
|
|
276
|
+
switch (k.kind) {
|
|
277
|
+
case "digit":
|
|
278
|
+
this._inputDigit(k.label);
|
|
279
|
+
break;
|
|
280
|
+
case "dot":
|
|
281
|
+
this._inputDot();
|
|
282
|
+
break;
|
|
283
|
+
case "op":
|
|
284
|
+
this._applyOperator(k.op, k.label);
|
|
285
|
+
break;
|
|
286
|
+
case "equals":
|
|
287
|
+
this._evaluate();
|
|
288
|
+
break;
|
|
289
|
+
case "fn":
|
|
290
|
+
if (k.label === "AC") this._clear();
|
|
291
|
+
else this._backspace();
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Lee el display actual sincronizado con el modo controlado.
|
|
296
|
+
get _cur() {
|
|
297
|
+
return this._shownValue;
|
|
298
|
+
}
|
|
299
|
+
_inputDigit(d) {
|
|
300
|
+
const cur = this._cur;
|
|
301
|
+
const next = cur === "0" || this._justEvaluated ? d : cur + d;
|
|
302
|
+
this._justEvaluated = false;
|
|
303
|
+
this._setDisplay(next);
|
|
304
|
+
}
|
|
305
|
+
_inputDot() {
|
|
306
|
+
const cur = this._cur;
|
|
307
|
+
const next = cur.includes(".") ? cur : cur + ".";
|
|
308
|
+
this._justEvaluated = false;
|
|
309
|
+
this._setDisplay(next);
|
|
310
|
+
}
|
|
311
|
+
_applyOperator(op, sym) {
|
|
312
|
+
this._stored = parseFloat(this._cur);
|
|
313
|
+
this._op = op;
|
|
314
|
+
this._prev = `${this._cur} ${sym}`;
|
|
315
|
+
this._justEvaluated = false;
|
|
316
|
+
this._setDisplay("0");
|
|
317
|
+
}
|
|
318
|
+
_evaluate() {
|
|
319
|
+
const b = parseFloat(this._cur);
|
|
320
|
+
const a = this._stored;
|
|
321
|
+
let r;
|
|
322
|
+
switch (this._op) {
|
|
323
|
+
case "+":
|
|
324
|
+
r = a + b;
|
|
325
|
+
break;
|
|
326
|
+
case "-":
|
|
327
|
+
r = a - b;
|
|
328
|
+
break;
|
|
329
|
+
case "*":
|
|
330
|
+
r = a * b;
|
|
331
|
+
break;
|
|
332
|
+
case "/":
|
|
333
|
+
r = b === 0 ? 0 : a / b;
|
|
334
|
+
break;
|
|
335
|
+
default:
|
|
336
|
+
r = b;
|
|
337
|
+
}
|
|
338
|
+
const opSym = this._op ? OP_SYMBOL[this._op] : "";
|
|
339
|
+
this._prev = this._op ? `${a} ${opSym} ${b} =` : "";
|
|
340
|
+
const result = Number.isFinite(r) ? +r.toFixed(8) : 0;
|
|
341
|
+
this._op = "";
|
|
342
|
+
this._stored = 0;
|
|
343
|
+
this._justEvaluated = true;
|
|
344
|
+
this._setDisplay(String(result));
|
|
345
|
+
}
|
|
346
|
+
_clear() {
|
|
347
|
+
this._prev = "";
|
|
348
|
+
this._op = "";
|
|
349
|
+
this._stored = 0;
|
|
350
|
+
this._justEvaluated = false;
|
|
351
|
+
this._setDisplay("0");
|
|
352
|
+
}
|
|
353
|
+
_backspace() {
|
|
354
|
+
const cur = this._cur;
|
|
355
|
+
const next = cur.length > 1 ? cur.slice(0, -1) : "0";
|
|
356
|
+
this._setDisplay(next);
|
|
357
|
+
}
|
|
358
|
+
// Aplica el nuevo display y emite ok-change. En modo controlado no muta
|
|
359
|
+
// el estado interno: el consumidor decide si actualiza `value`.
|
|
360
|
+
_setDisplay(next) {
|
|
361
|
+
if (this.value === void 0) {
|
|
362
|
+
this._display = next;
|
|
363
|
+
}
|
|
364
|
+
this._emitChange(next);
|
|
365
|
+
}
|
|
366
|
+
_emitInput(key) {
|
|
367
|
+
this.dispatchEvent(
|
|
368
|
+
new CustomEvent("ok-input", {
|
|
369
|
+
detail: { key },
|
|
370
|
+
bubbles: true,
|
|
371
|
+
composed: true
|
|
372
|
+
})
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
_emitChange(value) {
|
|
376
|
+
this.dispatchEvent(
|
|
377
|
+
new CustomEvent("ok-change", {
|
|
378
|
+
detail: { value },
|
|
379
|
+
bubbles: true,
|
|
380
|
+
composed: true
|
|
381
|
+
})
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
__decorateClass([
|
|
386
|
+
property()
|
|
387
|
+
], OkCalculator.prototype, "value");
|
|
388
|
+
__decorateClass([
|
|
389
|
+
state()
|
|
390
|
+
], OkCalculator.prototype, "_display");
|
|
391
|
+
__decorateClass([
|
|
392
|
+
state()
|
|
393
|
+
], OkCalculator.prototype, "_prev");
|
|
394
|
+
__decorateClass([
|
|
395
|
+
state()
|
|
396
|
+
], OkCalculator.prototype, "_op");
|
|
397
|
+
__decorateClass([
|
|
398
|
+
state()
|
|
399
|
+
], OkCalculator.prototype, "_stored");
|
|
400
|
+
__decorateClass([
|
|
401
|
+
state()
|
|
402
|
+
], OkCalculator.prototype, "_justEvaluated");
|
|
403
|
+
define("ok-calculator", OkCalculator);
|
|
404
|
+
export {
|
|
405
|
+
OkCalculator
|
|
406
|
+
};
|