@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,156 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
4
|
+
import { define } from "./define.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
|
+
class OkDetailList extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.items = [];
|
|
18
|
+
this.columns = 1;
|
|
19
|
+
this.dense = false;
|
|
20
|
+
this.placeholder = "—";
|
|
21
|
+
}
|
|
22
|
+
static {
|
|
23
|
+
this.styles = css`
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
width: 100%;
|
|
27
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
28
|
+
--label-color: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
29
|
+
--value-color: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
30
|
+
--row-gap: 0.75rem;
|
|
31
|
+
--col-gap: 1rem;
|
|
32
|
+
--label-width: minmax(120px, 30%);
|
|
33
|
+
--divider-color: var(--ok-border-color, var(--ion-border-color, #e0e0e0));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.dl {
|
|
37
|
+
display: grid;
|
|
38
|
+
grid-template-columns: 1fr;
|
|
39
|
+
gap: var(--row-gap) var(--col-gap);
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* 2 columnas en desktop; se apila a 1 en pantallas estrechas. */
|
|
46
|
+
:host([columns='2']) .dl {
|
|
47
|
+
grid-template-columns: 1fr 1fr;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Modo denso: menos separación vertical. */
|
|
51
|
+
:host([dense]) {
|
|
52
|
+
--row-gap: 0.375rem;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.row {
|
|
56
|
+
display: grid;
|
|
57
|
+
grid-template-columns: var(--label-width) 1fr;
|
|
58
|
+
gap: 0.25rem var(--col-gap);
|
|
59
|
+
align-items: baseline;
|
|
60
|
+
min-width: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Un par puede forzar ancho completo en layout de 2 columnas. */
|
|
64
|
+
.row.full {
|
|
65
|
+
grid-column: 1 / -1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.label {
|
|
69
|
+
margin: 0;
|
|
70
|
+
font-size: 0.8125rem;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
color: var(--label-color);
|
|
73
|
+
min-width: 0;
|
|
74
|
+
overflow-wrap: anywhere;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.value {
|
|
78
|
+
margin: 0;
|
|
79
|
+
font-size: 0.9375rem;
|
|
80
|
+
line-height: 1.4;
|
|
81
|
+
color: var(--value-color);
|
|
82
|
+
min-width: 0;
|
|
83
|
+
overflow-wrap: anywhere;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([dense]) .value {
|
|
87
|
+
font-size: 0.875rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.value.empty {
|
|
91
|
+
color: var(--label-color);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* El valor enriquecido puede traer enlaces/badges: que hereden bien. */
|
|
95
|
+
.value ::slotted(*),
|
|
96
|
+
.value a {
|
|
97
|
+
color: inherit;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Apilado en móvil: la etiqueta encima del valor, full width. */
|
|
101
|
+
@media (max-width: 600px) {
|
|
102
|
+
:host([columns='2']) .dl {
|
|
103
|
+
grid-template-columns: 1fr;
|
|
104
|
+
}
|
|
105
|
+
.row {
|
|
106
|
+
grid-template-columns: 1fr;
|
|
107
|
+
gap: 0.125rem;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
renderValue(item) {
|
|
113
|
+
const raw = item.value;
|
|
114
|
+
if (raw === void 0 || raw === null || raw === "") {
|
|
115
|
+
return html`<dd class="value empty">${this.placeholder}</dd>`;
|
|
116
|
+
}
|
|
117
|
+
if (item.html) {
|
|
118
|
+
return html`<dd class="value">${unsafeHTML(raw)}</dd>`;
|
|
119
|
+
}
|
|
120
|
+
return html`<dd class="value">${raw}</dd>`;
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
const items = this.items ?? [];
|
|
124
|
+
if (items.length === 0) {
|
|
125
|
+
return nothing;
|
|
126
|
+
}
|
|
127
|
+
return html`
|
|
128
|
+
<dl class="dl">
|
|
129
|
+
${items.map(
|
|
130
|
+
(item) => html`
|
|
131
|
+
<div class="row ${item.full ? "full" : ""}" role="presentation">
|
|
132
|
+
<dt class="label">${item.label}</dt>
|
|
133
|
+
${this.renderValue(item)}
|
|
134
|
+
</div>
|
|
135
|
+
`
|
|
136
|
+
)}
|
|
137
|
+
</dl>
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
__decorateClass([
|
|
142
|
+
property({ attribute: false })
|
|
143
|
+
], OkDetailList.prototype, "items");
|
|
144
|
+
__decorateClass([
|
|
145
|
+
property({ type: Number, reflect: true })
|
|
146
|
+
], OkDetailList.prototype, "columns");
|
|
147
|
+
__decorateClass([
|
|
148
|
+
property({ type: Boolean, reflect: true })
|
|
149
|
+
], OkDetailList.prototype, "dense");
|
|
150
|
+
__decorateClass([
|
|
151
|
+
property()
|
|
152
|
+
], OkDetailList.prototype, "placeholder");
|
|
153
|
+
define("ok-detail-list", OkDetailList);
|
|
154
|
+
export {
|
|
155
|
+
OkDetailList
|
|
156
|
+
};
|
package/dist/ok-diff.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
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
|
+
const _OkDiff = class _OkDiff2 extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.lines = [];
|
|
17
|
+
this.raw = "";
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.styles = css`
|
|
21
|
+
:host {
|
|
22
|
+
display: block;
|
|
23
|
+
width: 100%;
|
|
24
|
+
/* Tokens propios estilo Ionic (overridables): cadena --ok-* → --ion-* → hex. */
|
|
25
|
+
--bg: var(--ok-surface, var(--ion-background-color, #ffffff));
|
|
26
|
+
--bg-hunk: var(--ok-surface-2, var(--ion-color-step-100, #f3f4f6));
|
|
27
|
+
--border: var(--ok-border-color, var(--ion-border-color, #e2e4e8));
|
|
28
|
+
--text: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
29
|
+
--text-muted: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
30
|
+
--num: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
31
|
+
/* "leaf" = verde de adición; "danger" = rojo de eliminación. */
|
|
32
|
+
--add: var(--ok-success, var(--ion-color-success, #2dd36f));
|
|
33
|
+
--del: var(--ok-danger, var(--ion-color-danger, #eb445a));
|
|
34
|
+
--radius: var(--ok-radius-md, 8px);
|
|
35
|
+
--mono: var(
|
|
36
|
+
--ok-font-mono,
|
|
37
|
+
ui-monospace,
|
|
38
|
+
SFMono-Regular,
|
|
39
|
+
'SF Mono',
|
|
40
|
+
Menlo,
|
|
41
|
+
Consolas,
|
|
42
|
+
monospace
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.diff {
|
|
47
|
+
font-family: var(--mono);
|
|
48
|
+
font-size: 12.5px;
|
|
49
|
+
line-height: 1.6;
|
|
50
|
+
background: var(--bg);
|
|
51
|
+
border: 1px solid var(--border);
|
|
52
|
+
border-radius: var(--radius);
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
color: var(--text);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.line {
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: 44px 44px 1fr;
|
|
61
|
+
padding: 0 12px 0 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.num {
|
|
65
|
+
text-align: right;
|
|
66
|
+
padding: 0 8px;
|
|
67
|
+
color: var(--num);
|
|
68
|
+
user-select: none;
|
|
69
|
+
font-size: 11px;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.content {
|
|
74
|
+
white-space: pre-wrap;
|
|
75
|
+
overflow-wrap: anywhere;
|
|
76
|
+
color: inherit;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Línea añadida: tinte leaf 8% + numeración verdosa + glifo "+". */
|
|
80
|
+
.line--add {
|
|
81
|
+
background: color-mix(in srgb, var(--add) 8%, transparent);
|
|
82
|
+
}
|
|
83
|
+
.line--add .num {
|
|
84
|
+
color: color-mix(in srgb, var(--add) 70%, var(--num));
|
|
85
|
+
}
|
|
86
|
+
.line--add .content::before {
|
|
87
|
+
content: '+ ';
|
|
88
|
+
color: var(--add);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Línea eliminada: tinte danger 8% + numeración rojiza + glifo "−". */
|
|
92
|
+
.line--del {
|
|
93
|
+
background: color-mix(in srgb, var(--del) 8%, transparent);
|
|
94
|
+
}
|
|
95
|
+
.line--del .num {
|
|
96
|
+
color: color-mix(in srgb, var(--del) 70%, var(--num));
|
|
97
|
+
}
|
|
98
|
+
.line--del .content::before {
|
|
99
|
+
content: '− ';
|
|
100
|
+
color: var(--del);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Cabecera de hunk (@@ … @@): fondo elevado, cursiva, ocupa todo el ancho. */
|
|
104
|
+
.line--hunk {
|
|
105
|
+
grid-template-columns: 1fr;
|
|
106
|
+
background: var(--bg-hunk);
|
|
107
|
+
color: var(--text-muted);
|
|
108
|
+
font-style: italic;
|
|
109
|
+
}
|
|
110
|
+
.line--hunk .content {
|
|
111
|
+
padding-left: 12px;
|
|
112
|
+
}
|
|
113
|
+
.line--hunk .content::before {
|
|
114
|
+
content: '';
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
/** Devuelve las líneas a renderizar: `.lines` si existe, si no parsea `raw`. */
|
|
119
|
+
resolveLines() {
|
|
120
|
+
if (this.lines && this.lines.length) return this.lines;
|
|
121
|
+
if (this.raw) return _OkDiff2.parseUnified(this.raw);
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parsea un diff unificado (texto) a OkDiffLine[]. CSP-safe (sin eval):
|
|
126
|
+
* solo recorre líneas y lleva la cuenta de oldNo/newNo según las cabeceras
|
|
127
|
+
* de hunk `@@ -a,b +c,d @@`. Ignora cabeceras de fichero (---, +++).
|
|
128
|
+
*/
|
|
129
|
+
static parseUnified(raw) {
|
|
130
|
+
const out = [];
|
|
131
|
+
let oldNo = 0;
|
|
132
|
+
let newNo = 0;
|
|
133
|
+
const hunkRe = /^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/;
|
|
134
|
+
for (const line of raw.replace(/\r\n?/g, "\n").split("\n")) {
|
|
135
|
+
if (line.startsWith("+++") || line.startsWith("---") || line.startsWith("diff ")) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const hunk = hunkRe.exec(line);
|
|
139
|
+
if (hunk) {
|
|
140
|
+
oldNo = Number(hunk[1]);
|
|
141
|
+
newNo = Number(hunk[2]);
|
|
142
|
+
out.push({ type: "hunk", content: line });
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const head = line.charAt(0);
|
|
146
|
+
if (head === "+") {
|
|
147
|
+
out.push({ type: "add", content: line.slice(1), newNo });
|
|
148
|
+
newNo += 1;
|
|
149
|
+
} else if (head === "-") {
|
|
150
|
+
out.push({ type: "del", content: line.slice(1), oldNo });
|
|
151
|
+
oldNo += 1;
|
|
152
|
+
} else {
|
|
153
|
+
const content = head === " " ? line.slice(1) : line;
|
|
154
|
+
out.push({ type: "ctx", content, oldNo, newNo });
|
|
155
|
+
oldNo += 1;
|
|
156
|
+
newNo += 1;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
/** Texto de la columna numérica (vacío si no hay número). */
|
|
162
|
+
static numText(n) {
|
|
163
|
+
return n === void 0 || n === null ? "" : String(n);
|
|
164
|
+
}
|
|
165
|
+
renderLine(line) {
|
|
166
|
+
if (line.type === "hunk") {
|
|
167
|
+
return html`
|
|
168
|
+
<div class="line line--hunk" role="row">
|
|
169
|
+
<div class="content" role="cell">${line.content}</div>
|
|
170
|
+
</div>
|
|
171
|
+
`;
|
|
172
|
+
}
|
|
173
|
+
return html`
|
|
174
|
+
<div class="line line--${line.type}" role="row">
|
|
175
|
+
<span class="num" role="cell" aria-hidden="true">${_OkDiff2.numText(line.oldNo)}</span>
|
|
176
|
+
<span class="num" role="cell" aria-hidden="true">${_OkDiff2.numText(line.newNo)}</span>
|
|
177
|
+
<span class="content" role="cell">${line.content}</span>
|
|
178
|
+
</div>
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
render() {
|
|
182
|
+
const lines = this.resolveLines();
|
|
183
|
+
return html`
|
|
184
|
+
<div class="diff" role="table" aria-label="Diff de líneas">
|
|
185
|
+
${lines.map((l) => this.renderLine(l))}
|
|
186
|
+
</div>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
__decorateClass([
|
|
191
|
+
property({ attribute: false })
|
|
192
|
+
], _OkDiff.prototype, "lines");
|
|
193
|
+
__decorateClass([
|
|
194
|
+
property()
|
|
195
|
+
], _OkDiff.prototype, "raw");
|
|
196
|
+
let OkDiff = _OkDiff;
|
|
197
|
+
define("ok-diff", OkDiff);
|
|
198
|
+
export {
|
|
199
|
+
OkDiff
|
|
200
|
+
};
|
package/dist/ok-donut.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { LitElement, css, svg, 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
|
+
const DEFAULT_PALETTE = [
|
|
14
|
+
"var(--ok-primary, var(--ion-color-primary, #3880ff))",
|
|
15
|
+
"var(--ok-success, var(--ion-color-success, #2dd36f))",
|
|
16
|
+
"var(--ok-warning, var(--ion-color-warning, #ffc409))",
|
|
17
|
+
"var(--ok-tertiary, var(--ion-color-tertiary, #5260ff))",
|
|
18
|
+
"var(--ok-danger, var(--ion-color-danger, #eb445a))",
|
|
19
|
+
"var(--ok-secondary, var(--ion-color-secondary, #3dc2ff))"
|
|
20
|
+
];
|
|
21
|
+
class OkDonut extends LitElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.slices = [];
|
|
25
|
+
this.size = 140;
|
|
26
|
+
this.thickness = 16;
|
|
27
|
+
this.centerLabel = "";
|
|
28
|
+
this.centerValue = "";
|
|
29
|
+
this.legend = true;
|
|
30
|
+
this.legendSide = "side";
|
|
31
|
+
}
|
|
32
|
+
static {
|
|
33
|
+
this.styles = css`
|
|
34
|
+
:host {
|
|
35
|
+
display: block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
/* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
|
|
39
|
+
--value-color: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
40
|
+
--label-color: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
41
|
+
--track-color: var(--ok-donut-track, var(--ion-color-step-100, #ebedf0));
|
|
42
|
+
--legend-color: var(--ok-color-medium-shade, var(--ion-color-medium-shade, #808289));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.donut {
|
|
46
|
+
display: grid;
|
|
47
|
+
gap: 18px;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
/* Leyenda al lado: SVG de ancho fijo + leyenda flexible. */
|
|
51
|
+
.donut.side {
|
|
52
|
+
grid-template-columns: auto 1fr;
|
|
53
|
+
}
|
|
54
|
+
/* Leyenda abajo: una sola columna, todo centrado. */
|
|
55
|
+
.donut.bottom {
|
|
56
|
+
grid-template-columns: 1fr;
|
|
57
|
+
justify-items: center;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
svg {
|
|
61
|
+
display: block;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.track {
|
|
65
|
+
fill: none;
|
|
66
|
+
stroke: var(--track-color);
|
|
67
|
+
}
|
|
68
|
+
.slice {
|
|
69
|
+
fill: none;
|
|
70
|
+
transform: rotate(-90deg);
|
|
71
|
+
transform-origin: center;
|
|
72
|
+
/* Animación al cambiar proporciones (mismo espíritu que el CSS original). */
|
|
73
|
+
transition: stroke-dasharray 0.6s cubic-bezier(0.22, 1, 0.36, 1);
|
|
74
|
+
}
|
|
75
|
+
/* Modo pie: el segmento se rellena en vez de trazarse. */
|
|
76
|
+
.pie {
|
|
77
|
+
stroke: none;
|
|
78
|
+
transform: rotate(-90deg);
|
|
79
|
+
transform-origin: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.center-value {
|
|
83
|
+
fill: var(--value-color);
|
|
84
|
+
text-anchor: middle;
|
|
85
|
+
font-weight: 700;
|
|
86
|
+
letter-spacing: -0.04em;
|
|
87
|
+
}
|
|
88
|
+
.center-label {
|
|
89
|
+
fill: var(--label-color);
|
|
90
|
+
text-anchor: middle;
|
|
91
|
+
text-transform: uppercase;
|
|
92
|
+
letter-spacing: 0.06em;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.legend {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
gap: 6px;
|
|
99
|
+
font-size: 12px;
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
.legend-row {
|
|
103
|
+
display: grid;
|
|
104
|
+
grid-template-columns: 10px 1fr auto;
|
|
105
|
+
gap: 8px;
|
|
106
|
+
align-items: center;
|
|
107
|
+
color: var(--legend-color);
|
|
108
|
+
}
|
|
109
|
+
.legend-dot {
|
|
110
|
+
width: 10px;
|
|
111
|
+
height: 10px;
|
|
112
|
+
border-radius: 3px;
|
|
113
|
+
}
|
|
114
|
+
.legend-pct {
|
|
115
|
+
color: var(--value-color);
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
font-variant-numeric: tabular-nums;
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
// Total de los valores (sin negativos), con guarda contra 0.
|
|
122
|
+
get total() {
|
|
123
|
+
const sum = (this.slices ?? []).reduce(
|
|
124
|
+
(acc, s) => acc + Math.max(0, s.value || 0),
|
|
125
|
+
0
|
|
126
|
+
);
|
|
127
|
+
return sum;
|
|
128
|
+
}
|
|
129
|
+
// Color efectivo de un slice (su color o el de la paleta por índice).
|
|
130
|
+
colorAt(slice, i) {
|
|
131
|
+
return slice.color || DEFAULT_PALETTE[i % DEFAULT_PALETTE.length];
|
|
132
|
+
}
|
|
133
|
+
// Porcentaje (0–100) de un slice sobre el total.
|
|
134
|
+
pct(value) {
|
|
135
|
+
const total = this.total;
|
|
136
|
+
if (total <= 0) return 0;
|
|
137
|
+
return Math.max(0, value) / total * 100;
|
|
138
|
+
}
|
|
139
|
+
// Dibuja el donut (anillos trazados) o el pie (cuñas macizas) según thickness.
|
|
140
|
+
renderChart() {
|
|
141
|
+
const size = this.size;
|
|
142
|
+
const cx = size / 2;
|
|
143
|
+
const cy = size / 2;
|
|
144
|
+
const isPie = this.thickness <= 0;
|
|
145
|
+
const total = this.total;
|
|
146
|
+
const slices = this.slices ?? [];
|
|
147
|
+
const stroke = isPie ? 0 : this.thickness;
|
|
148
|
+
const r = isPie ? size / 2 : (size - stroke) / 2;
|
|
149
|
+
const circumference = 2 * Math.PI * r;
|
|
150
|
+
const pieStroke = size / 2;
|
|
151
|
+
const pieR = size / 4;
|
|
152
|
+
const pieCircumference = 2 * Math.PI * pieR;
|
|
153
|
+
let offset = 0;
|
|
154
|
+
const segments = slices.map((s, i) => {
|
|
155
|
+
const fraction = total > 0 ? Math.max(0, s.value) / total : 0;
|
|
156
|
+
const dash = fraction * (isPie ? pieCircumference : circumference);
|
|
157
|
+
const dashoffset = -offset;
|
|
158
|
+
offset += dash;
|
|
159
|
+
const color = this.colorAt(s, i);
|
|
160
|
+
if (isPie) {
|
|
161
|
+
return svg`<circle
|
|
162
|
+
class="pie"
|
|
163
|
+
cx=${cx}
|
|
164
|
+
cy=${cy}
|
|
165
|
+
r=${pieR}
|
|
166
|
+
fill="none"
|
|
167
|
+
stroke=${color}
|
|
168
|
+
stroke-width=${pieStroke}
|
|
169
|
+
stroke-dasharray=${`${dash} ${pieCircumference}`}
|
|
170
|
+
stroke-dashoffset=${dashoffset}
|
|
171
|
+
/>`;
|
|
172
|
+
}
|
|
173
|
+
return svg`<circle
|
|
174
|
+
class="slice"
|
|
175
|
+
cx=${cx}
|
|
176
|
+
cy=${cy}
|
|
177
|
+
r=${r}
|
|
178
|
+
stroke=${color}
|
|
179
|
+
stroke-width=${stroke}
|
|
180
|
+
stroke-dasharray=${`${dash} ${circumference}`}
|
|
181
|
+
stroke-dashoffset=${dashoffset}
|
|
182
|
+
stroke-linecap="butt"
|
|
183
|
+
/>`;
|
|
184
|
+
});
|
|
185
|
+
const valueSize = Math.max(14, Math.round(size * 0.16));
|
|
186
|
+
const labelSize = Math.max(8, Math.round(size * 0.065));
|
|
187
|
+
const showCenter = !isPie && (this.centerValue || this.centerLabel);
|
|
188
|
+
return svg`
|
|
189
|
+
${!isPie ? svg`<circle
|
|
190
|
+
class="track"
|
|
191
|
+
cx=${cx}
|
|
192
|
+
cy=${cy}
|
|
193
|
+
r=${r}
|
|
194
|
+
stroke-width=${stroke}
|
|
195
|
+
/>` : svg``}
|
|
196
|
+
${segments}
|
|
197
|
+
${showCenter ? svg`
|
|
198
|
+
${this.centerValue ? svg`<text
|
|
199
|
+
class="center-value"
|
|
200
|
+
x=${cx}
|
|
201
|
+
y=${this.centerLabel ? cy + valueSize * 0.05 : cy + valueSize * 0.35}
|
|
202
|
+
font-size=${valueSize}
|
|
203
|
+
>${this.centerValue}</text>` : svg``}
|
|
204
|
+
${this.centerLabel ? svg`<text
|
|
205
|
+
class="center-label"
|
|
206
|
+
x=${cx}
|
|
207
|
+
y=${this.centerValue ? cy + valueSize * 0.7 : cy + labelSize * 0.35}
|
|
208
|
+
font-size=${labelSize}
|
|
209
|
+
>${this.centerLabel}</text>` : svg``}
|
|
210
|
+
` : svg``}
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
// Filas de leyenda: cuadradito de color + nombre + porcentaje calculado.
|
|
214
|
+
renderLegend() {
|
|
215
|
+
const slices = this.slices ?? [];
|
|
216
|
+
if (!this.legend || slices.length === 0) return null;
|
|
217
|
+
return html`
|
|
218
|
+
<div class="legend" role="list">
|
|
219
|
+
${slices.map((s, i) => {
|
|
220
|
+
const pct = this.pct(s.value);
|
|
221
|
+
return html`
|
|
222
|
+
<div class="legend-row" role="listitem">
|
|
223
|
+
<span
|
|
224
|
+
class="legend-dot"
|
|
225
|
+
style=${`background:${this.colorAt(s, i)}`}
|
|
226
|
+
></span>
|
|
227
|
+
<span>${s.label}</span>
|
|
228
|
+
<span class="legend-pct">${Math.round(pct)}%</span>
|
|
229
|
+
</div>
|
|
230
|
+
`;
|
|
231
|
+
})}
|
|
232
|
+
</div>
|
|
233
|
+
`;
|
|
234
|
+
}
|
|
235
|
+
render() {
|
|
236
|
+
const size = this.size;
|
|
237
|
+
const showLegend = this.legend && (this.slices ?? []).length > 0;
|
|
238
|
+
const side = this.legendSide === "bottom" ? "bottom" : "side";
|
|
239
|
+
const ariaLabel = (this.slices ?? []).map((s) => `${s.label}: ${Math.round(this.pct(s.value))}%`).join(", ");
|
|
240
|
+
return html`
|
|
241
|
+
<div class=${`donut ${showLegend ? side : "bottom"}`}>
|
|
242
|
+
<svg
|
|
243
|
+
width=${size}
|
|
244
|
+
height=${size}
|
|
245
|
+
viewBox=${`0 0 ${size} ${size}`}
|
|
246
|
+
role="img"
|
|
247
|
+
aria-label=${ariaLabel || "donut chart"}
|
|
248
|
+
>
|
|
249
|
+
${this.renderChart()}
|
|
250
|
+
</svg>
|
|
251
|
+
${showLegend ? this.renderLegend() : null}
|
|
252
|
+
</div>
|
|
253
|
+
`;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
__decorateClass([
|
|
257
|
+
property({ attribute: false })
|
|
258
|
+
], OkDonut.prototype, "slices");
|
|
259
|
+
__decorateClass([
|
|
260
|
+
property({ type: Number })
|
|
261
|
+
], OkDonut.prototype, "size");
|
|
262
|
+
__decorateClass([
|
|
263
|
+
property({ type: Number })
|
|
264
|
+
], OkDonut.prototype, "thickness");
|
|
265
|
+
__decorateClass([
|
|
266
|
+
property({ attribute: "center-label" })
|
|
267
|
+
], OkDonut.prototype, "centerLabel");
|
|
268
|
+
__decorateClass([
|
|
269
|
+
property({ attribute: "center-value" })
|
|
270
|
+
], OkDonut.prototype, "centerValue");
|
|
271
|
+
__decorateClass([
|
|
272
|
+
property({ type: Boolean })
|
|
273
|
+
], OkDonut.prototype, "legend");
|
|
274
|
+
__decorateClass([
|
|
275
|
+
property({ attribute: "legend-side" })
|
|
276
|
+
], OkDonut.prototype, "legendSide");
|
|
277
|
+
define("ok-donut", OkDonut);
|
|
278
|
+
export {
|
|
279
|
+
OkDonut
|
|
280
|
+
};
|