@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,538 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property, state, query } 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 _OkRichText = class _OkRichText2 extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.value = "";
|
|
17
|
+
this.placeholder = "Escribe aquí…";
|
|
18
|
+
this.size = "md";
|
|
19
|
+
this.toolbar = true;
|
|
20
|
+
this.footer = true;
|
|
21
|
+
this.focused = false;
|
|
22
|
+
this.activeFmts = /* @__PURE__ */ new Set();
|
|
23
|
+
this.activeBlock = "p";
|
|
24
|
+
this.words = 0;
|
|
25
|
+
this.syncingFromInput = false;
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = css`
|
|
29
|
+
:host {
|
|
30
|
+
display: block;
|
|
31
|
+
width: 100%;
|
|
32
|
+
/* Tokens propios estilo Ionic: --ok-* → --ion-* → hex. */
|
|
33
|
+
--bg: var(--ok-surface, var(--ion-background-color, #fff));
|
|
34
|
+
--toolbar-bg: var(--ok-toolbar-bg, var(--ion-color-light, #f4f5f8));
|
|
35
|
+
--footer-bg: var(--ok-toolbar-bg, var(--ion-color-light, #f4f5f8));
|
|
36
|
+
--line: var(--ok-border-color, var(--ion-border-color, #dfe1e6));
|
|
37
|
+
--ink: var(--ok-text-color, var(--ion-text-color, #1f2933));
|
|
38
|
+
--ink-2: var(--ok-color-medium-shade, var(--ion-color-medium-shade, #5c6470));
|
|
39
|
+
--ink-muted: var(--ok-color-medium, var(--ion-color-medium, #92949c));
|
|
40
|
+
--brand: var(--ok-color-primary, var(--ion-color-primary, #0091ce));
|
|
41
|
+
--brand-contrast: var(--ok-color-primary-contrast, var(--ion-color-primary-contrast, #fff));
|
|
42
|
+
--brand-soft: color-mix(in srgb, var(--brand) 14%, transparent);
|
|
43
|
+
--warn: var(--ok-color-warning, var(--ion-color-warning, #ffc409));
|
|
44
|
+
--radius: var(--ok-radius-lg, 12px);
|
|
45
|
+
--radius-sm: var(--ok-radius-sm, 6px);
|
|
46
|
+
--font-display: var(--ok-font-display, var(--ion-font-family, inherit));
|
|
47
|
+
--font-mono: var(--ok-font-mono, ui-monospace, 'SFMono-Regular', Menlo, monospace);
|
|
48
|
+
--pad: 0.75rem;
|
|
49
|
+
--min-h: 200px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.rt {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
width: 100%;
|
|
57
|
+
background: var(--bg);
|
|
58
|
+
border: 1px solid var(--line);
|
|
59
|
+
border-radius: var(--radius);
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
color: var(--ink);
|
|
62
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
63
|
+
}
|
|
64
|
+
.rt.is-focus {
|
|
65
|
+
border-color: var(--brand);
|
|
66
|
+
box-shadow: 0 0 0 3px var(--brand-soft);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* ── Toolbar ───────────────────────────────────────────── */
|
|
70
|
+
.toolbar {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
flex-wrap: wrap;
|
|
74
|
+
gap: 0.25rem;
|
|
75
|
+
padding: 0.25rem 0.5rem;
|
|
76
|
+
background: var(--toolbar-bg);
|
|
77
|
+
border-bottom: 1px solid var(--line);
|
|
78
|
+
min-height: 38px;
|
|
79
|
+
}
|
|
80
|
+
.select {
|
|
81
|
+
height: 26px;
|
|
82
|
+
padding: 0 0.5rem;
|
|
83
|
+
background: var(--bg);
|
|
84
|
+
border: 1px solid var(--line);
|
|
85
|
+
border-radius: var(--radius-sm);
|
|
86
|
+
color: var(--ink);
|
|
87
|
+
font: inherit;
|
|
88
|
+
font-size: 0.75rem;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
.select:focus-visible {
|
|
92
|
+
outline: 2px solid var(--brand);
|
|
93
|
+
outline-offset: 1px;
|
|
94
|
+
}
|
|
95
|
+
.btn {
|
|
96
|
+
width: 28px;
|
|
97
|
+
height: 28px;
|
|
98
|
+
display: inline-grid;
|
|
99
|
+
place-items: center;
|
|
100
|
+
border: 0;
|
|
101
|
+
background: transparent;
|
|
102
|
+
border-radius: var(--radius-sm);
|
|
103
|
+
color: var(--ink-2);
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
font-family: inherit;
|
|
106
|
+
transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
|
|
107
|
+
}
|
|
108
|
+
.btn:hover {
|
|
109
|
+
background: color-mix(in srgb, var(--ink) 8%, transparent);
|
|
110
|
+
color: var(--ink);
|
|
111
|
+
}
|
|
112
|
+
.btn:active { transform: scale(0.96); }
|
|
113
|
+
.btn:focus-visible {
|
|
114
|
+
outline: 2px solid var(--brand);
|
|
115
|
+
outline-offset: 1px;
|
|
116
|
+
}
|
|
117
|
+
.btn[aria-pressed='true'] {
|
|
118
|
+
background: var(--brand-soft);
|
|
119
|
+
color: var(--ink);
|
|
120
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent);
|
|
121
|
+
}
|
|
122
|
+
.btn svg {
|
|
123
|
+
width: 14px;
|
|
124
|
+
height: 14px;
|
|
125
|
+
stroke-width: 2;
|
|
126
|
+
}
|
|
127
|
+
.divider {
|
|
128
|
+
width: 1px;
|
|
129
|
+
height: 18px;
|
|
130
|
+
background: var(--line);
|
|
131
|
+
margin: 0 0.25rem;
|
|
132
|
+
}
|
|
133
|
+
.spacer { flex: 1; }
|
|
134
|
+
|
|
135
|
+
/* ── Área de contenido ─────────────────────────────────── */
|
|
136
|
+
.content {
|
|
137
|
+
min-height: var(--min-h);
|
|
138
|
+
padding: var(--pad);
|
|
139
|
+
outline: 0;
|
|
140
|
+
font-size: 0.9375rem;
|
|
141
|
+
line-height: 1.6;
|
|
142
|
+
color: var(--ink);
|
|
143
|
+
overflow-y: auto;
|
|
144
|
+
box-sizing: border-box;
|
|
145
|
+
}
|
|
146
|
+
.content:empty::before {
|
|
147
|
+
content: attr(data-placeholder);
|
|
148
|
+
color: var(--ink-muted);
|
|
149
|
+
pointer-events: none;
|
|
150
|
+
}
|
|
151
|
+
.content > *:first-child { margin-top: 0; }
|
|
152
|
+
.content > *:last-child { margin-bottom: 0; }
|
|
153
|
+
|
|
154
|
+
.content p { margin: 0 0 0.75rem; }
|
|
155
|
+
.content h1,
|
|
156
|
+
.content h2,
|
|
157
|
+
.content h3,
|
|
158
|
+
.content h4 {
|
|
159
|
+
font-family: var(--font-display);
|
|
160
|
+
letter-spacing: -0.01em;
|
|
161
|
+
color: var(--ink);
|
|
162
|
+
margin: 1rem 0 0.5rem;
|
|
163
|
+
line-height: 1.2;
|
|
164
|
+
font-weight: 600;
|
|
165
|
+
}
|
|
166
|
+
.content h1 { font-size: 1.625rem; }
|
|
167
|
+
.content h2 { font-size: 1.375rem; }
|
|
168
|
+
.content h3 { font-size: 1.15rem; }
|
|
169
|
+
.content h4 { font-size: 1rem; }
|
|
170
|
+
|
|
171
|
+
.content ul,
|
|
172
|
+
.content ol {
|
|
173
|
+
margin: 0 0 0.75rem;
|
|
174
|
+
padding-left: 1.5rem;
|
|
175
|
+
}
|
|
176
|
+
.content li { margin-bottom: 0.25rem; }
|
|
177
|
+
|
|
178
|
+
.content a {
|
|
179
|
+
color: var(--brand);
|
|
180
|
+
text-decoration: underline;
|
|
181
|
+
text-underline-offset: 2px;
|
|
182
|
+
text-decoration-color: color-mix(in srgb, var(--brand) 50%, transparent);
|
|
183
|
+
}
|
|
184
|
+
.content a:hover { text-decoration-color: var(--brand); }
|
|
185
|
+
|
|
186
|
+
.content code {
|
|
187
|
+
font-family: var(--font-mono);
|
|
188
|
+
font-size: 0.9em;
|
|
189
|
+
background: color-mix(in srgb, var(--ink) 6%, transparent);
|
|
190
|
+
border: 1px solid var(--line);
|
|
191
|
+
border-radius: 4px;
|
|
192
|
+
padding: 1px 6px;
|
|
193
|
+
color: var(--ink);
|
|
194
|
+
}
|
|
195
|
+
.content pre {
|
|
196
|
+
font-family: var(--font-mono);
|
|
197
|
+
font-size: 0.85rem;
|
|
198
|
+
background: color-mix(in srgb, var(--ink) 4%, transparent);
|
|
199
|
+
border: 1px solid var(--line);
|
|
200
|
+
border-radius: 8px;
|
|
201
|
+
padding: 0.75rem 1rem;
|
|
202
|
+
overflow-x: auto;
|
|
203
|
+
margin: 0 0 0.75rem;
|
|
204
|
+
line-height: 1.55;
|
|
205
|
+
}
|
|
206
|
+
.content pre code {
|
|
207
|
+
background: transparent;
|
|
208
|
+
border: 0;
|
|
209
|
+
padding: 0;
|
|
210
|
+
}
|
|
211
|
+
.content blockquote {
|
|
212
|
+
margin: 0 0 0.75rem;
|
|
213
|
+
padding: 0.25rem 0.75rem;
|
|
214
|
+
border-left: 3px solid var(--brand);
|
|
215
|
+
color: var(--ink-2);
|
|
216
|
+
background: color-mix(in srgb, var(--brand) 6%, transparent);
|
|
217
|
+
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
|
218
|
+
font-style: italic;
|
|
219
|
+
}
|
|
220
|
+
.content hr {
|
|
221
|
+
border: 0;
|
|
222
|
+
border-top: 1px solid var(--line);
|
|
223
|
+
margin: 1rem 0;
|
|
224
|
+
}
|
|
225
|
+
.content strong { font-weight: 600; color: var(--ink); }
|
|
226
|
+
.content em { font-style: italic; }
|
|
227
|
+
.content u { text-decoration: underline; text-underline-offset: 2px; }
|
|
228
|
+
.content mark {
|
|
229
|
+
background: color-mix(in srgb, var(--warn) 28%, transparent);
|
|
230
|
+
color: var(--ink);
|
|
231
|
+
padding: 0 2px;
|
|
232
|
+
border-radius: 2px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* ── Footer ────────────────────────────────────────────── */
|
|
236
|
+
.footer {
|
|
237
|
+
display: flex;
|
|
238
|
+
justify-content: space-between;
|
|
239
|
+
align-items: center;
|
|
240
|
+
gap: 0.75rem;
|
|
241
|
+
padding: 0.25rem 0.75rem;
|
|
242
|
+
border-top: 1px solid var(--line);
|
|
243
|
+
background: var(--footer-bg);
|
|
244
|
+
font-size: 0.6875rem;
|
|
245
|
+
color: var(--ink-muted);
|
|
246
|
+
font-family: var(--font-mono);
|
|
247
|
+
font-variant-numeric: tabular-nums;
|
|
248
|
+
letter-spacing: 0.04em;
|
|
249
|
+
text-transform: uppercase;
|
|
250
|
+
min-height: 26px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* ── Tamaños ───────────────────────────────────────────── */
|
|
254
|
+
:host([size='sm']) { --min-h: 120px; --pad: 0.5rem; }
|
|
255
|
+
:host([size='sm']) .content { font-size: 0.875rem; }
|
|
256
|
+
:host([size='lg']) { --min-h: 320px; --pad: 1.25rem; }
|
|
257
|
+
:host([size='lg']) .content { font-size: 1rem; }
|
|
258
|
+
:host([size='lg']) .btn { width: 32px; height: 32px; }
|
|
259
|
+
:host([size='lg']) .btn svg { width: 16px; height: 16px; }
|
|
260
|
+
|
|
261
|
+
/* ── Minimal — sin toolbar/footer, edición inline ─────── */
|
|
262
|
+
:host([size='minimal']) .rt {
|
|
263
|
+
background: transparent;
|
|
264
|
+
border-radius: var(--radius-sm);
|
|
265
|
+
}
|
|
266
|
+
:host([size='minimal']) .content { min-height: auto; }
|
|
267
|
+
`;
|
|
268
|
+
}
|
|
269
|
+
static {
|
|
270
|
+
this.icons = {
|
|
271
|
+
bold: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M6 4h8a4 4 0 0 1 0 8H6z"/><path d="M6 12h9a4 4 0 0 1 0 8H6z"/></svg>`,
|
|
272
|
+
italic: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><line x1="19" y1="4" x2="10" y2="4"/><line x1="14" y1="20" x2="5" y2="20"/><line x1="15" y1="4" x2="9" y2="20"/></svg>`,
|
|
273
|
+
underline: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M6 3v7a6 6 0 0 0 12 0V3"/><line x1="4" y1="21" x2="20" y2="21"/></svg>`,
|
|
274
|
+
ul: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><line x1="9" y1="6" x2="20" y2="6"/><line x1="9" y1="12" x2="20" y2="12"/><line x1="9" y1="18" x2="20" y2="18"/><circle cx="4" cy="6" r="1"/><circle cx="4" cy="12" r="1"/><circle cx="4" cy="18" r="1"/></svg>`,
|
|
275
|
+
ol: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 16a1.5 1.5 0 1 0-2 1.5L6 19H4"/></svg>`,
|
|
276
|
+
code: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,
|
|
277
|
+
quote: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M3 11h5V6H4a1 1 0 0 0-1 1z"/><path d="M3 11v3a4 4 0 0 0 4 4"/><path d="M14 11h5V6h-4a1 1 0 0 0-1 1z"/><path d="M14 11v3a4 4 0 0 0 4 4"/></svg>`,
|
|
278
|
+
link: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-1.5 1.5"/><path d="M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l1.5-1.5"/></svg>`,
|
|
279
|
+
undo: html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><polyline points="3 7 3 13 9 13"/><path d="M3 13a9 9 0 1 0 3-7"/></svg>`
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
// Botones inline (no bloque) de la toolbar.
|
|
283
|
+
get inlineButtons() {
|
|
284
|
+
return [
|
|
285
|
+
{ cmd: "bold", active: "bold", label: "Negrita", icon: _OkRichText2.icons.bold },
|
|
286
|
+
{ cmd: "italic", active: "italic", label: "Cursiva", icon: _OkRichText2.icons.italic },
|
|
287
|
+
{ cmd: "underline", active: "underline", label: "Subrayado", icon: _OkRichText2.icons.underline }
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
get listButtons() {
|
|
291
|
+
return [
|
|
292
|
+
{ cmd: "insertUnorderedList", active: "insertUnorderedList", label: "Lista", icon: _OkRichText2.icons.ul },
|
|
293
|
+
{ cmd: "insertOrderedList", active: "insertOrderedList", label: "Lista numerada", icon: _OkRichText2.icons.ol }
|
|
294
|
+
];
|
|
295
|
+
}
|
|
296
|
+
firstUpdated() {
|
|
297
|
+
this.renderValueIntoDom();
|
|
298
|
+
this.recountWords();
|
|
299
|
+
}
|
|
300
|
+
updated(changed) {
|
|
301
|
+
if (changed.has("value") && !this.syncingFromInput) {
|
|
302
|
+
this.renderValueIntoDom();
|
|
303
|
+
this.recountWords();
|
|
304
|
+
}
|
|
305
|
+
this.syncingFromInput = false;
|
|
306
|
+
}
|
|
307
|
+
// Vuelca el HTML de `value` en el área editable solo si difiere (evita
|
|
308
|
+
// perder el caret mientras se teclea).
|
|
309
|
+
renderValueIntoDom() {
|
|
310
|
+
const el = this.contentEl;
|
|
311
|
+
if (el && el.innerHTML !== this.value) el.innerHTML = this.value ?? "";
|
|
312
|
+
}
|
|
313
|
+
recountWords() {
|
|
314
|
+
const text = (this.contentEl?.innerText ?? "").trim();
|
|
315
|
+
this.words = text ? text.split(/\s+/).filter(Boolean).length : 0;
|
|
316
|
+
}
|
|
317
|
+
// Lee el estado de formato/bloque de la selección actual.
|
|
318
|
+
refreshActiveState() {
|
|
319
|
+
const next = /* @__PURE__ */ new Set();
|
|
320
|
+
const cmds = ["bold", "italic", "underline", "insertUnorderedList", "insertOrderedList"];
|
|
321
|
+
for (const c of cmds) {
|
|
322
|
+
try {
|
|
323
|
+
if (document.queryCommandState(c)) next.add(c);
|
|
324
|
+
} catch {
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
this.activeFmts = next;
|
|
328
|
+
let block = "p";
|
|
329
|
+
try {
|
|
330
|
+
const v = document.queryCommandValue("formatBlock");
|
|
331
|
+
if (typeof v === "string" && v) block = v.toLowerCase();
|
|
332
|
+
} catch {
|
|
333
|
+
}
|
|
334
|
+
this.activeBlock = block;
|
|
335
|
+
}
|
|
336
|
+
// Mantiene el foco/selección en el área antes de ejecutar un comando.
|
|
337
|
+
exec(cmd, arg) {
|
|
338
|
+
this.contentEl?.focus();
|
|
339
|
+
try {
|
|
340
|
+
document.execCommand(cmd, false, arg);
|
|
341
|
+
} catch {
|
|
342
|
+
}
|
|
343
|
+
this.onInput();
|
|
344
|
+
this.refreshActiveState();
|
|
345
|
+
}
|
|
346
|
+
onHeadingChange(e) {
|
|
347
|
+
const tag = e.target.value;
|
|
348
|
+
this.exec("formatBlock", tag === "p" ? "p" : tag);
|
|
349
|
+
}
|
|
350
|
+
onLink() {
|
|
351
|
+
const url = window.prompt("URL del enlace:", "https://");
|
|
352
|
+
if (url) this.exec("createLink", url);
|
|
353
|
+
}
|
|
354
|
+
// Cada cambio en el área editable: sincroniza value + emite ok-input.
|
|
355
|
+
onInput() {
|
|
356
|
+
const el = this.contentEl;
|
|
357
|
+
if (!el) return;
|
|
358
|
+
const htmlOut = el.innerHTML;
|
|
359
|
+
this.syncingFromInput = true;
|
|
360
|
+
this.value = htmlOut;
|
|
361
|
+
this.recountWords();
|
|
362
|
+
this.dispatchEvent(
|
|
363
|
+
new CustomEvent("ok-input", {
|
|
364
|
+
detail: { html: htmlOut },
|
|
365
|
+
bubbles: true,
|
|
366
|
+
composed: true
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
onFocus() {
|
|
371
|
+
this.focused = true;
|
|
372
|
+
this.refreshActiveState();
|
|
373
|
+
}
|
|
374
|
+
onBlur() {
|
|
375
|
+
this.focused = false;
|
|
376
|
+
}
|
|
377
|
+
// Refresca el estado activo al mover el caret / seleccionar.
|
|
378
|
+
onSelect() {
|
|
379
|
+
if (this.focused) this.refreshActiveState();
|
|
380
|
+
}
|
|
381
|
+
toolBtn(b) {
|
|
382
|
+
const pressed = this.activeFmts.has(b.active);
|
|
383
|
+
return html`
|
|
384
|
+
<button
|
|
385
|
+
type="button"
|
|
386
|
+
class="btn"
|
|
387
|
+
aria-label=${b.label}
|
|
388
|
+
title=${b.label}
|
|
389
|
+
aria-pressed=${pressed ? "true" : "false"}
|
|
390
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
391
|
+
@click=${() => this.exec(b.cmd, b.arg)}
|
|
392
|
+
>
|
|
393
|
+
${b.icon}
|
|
394
|
+
</button>
|
|
395
|
+
`;
|
|
396
|
+
}
|
|
397
|
+
renderToolbar() {
|
|
398
|
+
return html`
|
|
399
|
+
<div class="toolbar" role="toolbar" aria-label="Formato">
|
|
400
|
+
<select
|
|
401
|
+
class="select"
|
|
402
|
+
aria-label="Estilo de párrafo"
|
|
403
|
+
.value=${this.activeBlock === "div" ? "p" : this.activeBlock}
|
|
404
|
+
@mousedown=${(e) => e.stopPropagation()}
|
|
405
|
+
@change=${this.onHeadingChange}
|
|
406
|
+
>
|
|
407
|
+
<option value="p">Párrafo</option>
|
|
408
|
+
<option value="h1">Título 1</option>
|
|
409
|
+
<option value="h2">Título 2</option>
|
|
410
|
+
<option value="h3">Título 3</option>
|
|
411
|
+
<option value="h4">Título 4</option>
|
|
412
|
+
</select>
|
|
413
|
+
<span class="divider"></span>
|
|
414
|
+
${this.inlineButtons.map((b) => this.toolBtn(b))}
|
|
415
|
+
<span class="divider"></span>
|
|
416
|
+
${this.listButtons.map((b) => this.toolBtn(b))}
|
|
417
|
+
<span class="divider"></span>
|
|
418
|
+
<button
|
|
419
|
+
type="button"
|
|
420
|
+
class="btn"
|
|
421
|
+
aria-label="Código"
|
|
422
|
+
title="Código"
|
|
423
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
424
|
+
@click=${() => this.exec("formatBlock", "pre")}
|
|
425
|
+
>
|
|
426
|
+
${_OkRichText2.icons.code}
|
|
427
|
+
</button>
|
|
428
|
+
<button
|
|
429
|
+
type="button"
|
|
430
|
+
class="btn"
|
|
431
|
+
aria-label="Cita"
|
|
432
|
+
title="Cita"
|
|
433
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
434
|
+
@click=${() => this.exec("formatBlock", "blockquote")}
|
|
435
|
+
>
|
|
436
|
+
${_OkRichText2.icons.quote}
|
|
437
|
+
</button>
|
|
438
|
+
<button
|
|
439
|
+
type="button"
|
|
440
|
+
class="btn"
|
|
441
|
+
aria-label="Enlace"
|
|
442
|
+
title="Enlace"
|
|
443
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
444
|
+
@click=${() => this.onLink()}
|
|
445
|
+
>
|
|
446
|
+
${_OkRichText2.icons.link}
|
|
447
|
+
</button>
|
|
448
|
+
<span class="spacer"></span>
|
|
449
|
+
<button
|
|
450
|
+
type="button"
|
|
451
|
+
class="btn"
|
|
452
|
+
aria-label="Deshacer"
|
|
453
|
+
title="Deshacer"
|
|
454
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
455
|
+
@click=${() => this.exec("undo")}
|
|
456
|
+
>
|
|
457
|
+
${_OkRichText2.icons.undo}
|
|
458
|
+
</button>
|
|
459
|
+
</div>
|
|
460
|
+
`;
|
|
461
|
+
}
|
|
462
|
+
renderFooter() {
|
|
463
|
+
const fmts = [];
|
|
464
|
+
if (this.activeBlock && this.activeBlock !== "p" && this.activeBlock !== "div")
|
|
465
|
+
fmts.push(this.activeBlock);
|
|
466
|
+
if (this.activeFmts.has("bold")) fmts.push("negrita");
|
|
467
|
+
if (this.activeFmts.has("italic")) fmts.push("cursiva");
|
|
468
|
+
if (this.activeFmts.has("underline")) fmts.push("subrayado");
|
|
469
|
+
if (this.activeFmts.has("insertUnorderedList")) fmts.push("lista");
|
|
470
|
+
if (this.activeFmts.has("insertOrderedList")) fmts.push("lista num.");
|
|
471
|
+
const wordLabel = `${this.words} ${this.words === 1 ? "palabra" : "palabras"}`;
|
|
472
|
+
return html`
|
|
473
|
+
<div class="footer">
|
|
474
|
+
<span>${wordLabel}</span>
|
|
475
|
+
<span>${fmts.length ? `formato: ${fmts.join(", ")}` : "sin formato"}</span>
|
|
476
|
+
</div>
|
|
477
|
+
`;
|
|
478
|
+
}
|
|
479
|
+
render() {
|
|
480
|
+
const isMinimal = this.size === "minimal";
|
|
481
|
+
const showToolbar = !isMinimal && this.toolbar;
|
|
482
|
+
const showFooter = !isMinimal && this.footer;
|
|
483
|
+
return html`
|
|
484
|
+
<div class="rt ${this.focused ? "is-focus" : ""}">
|
|
485
|
+
${showToolbar ? this.renderToolbar() : null}
|
|
486
|
+
<div
|
|
487
|
+
class="content"
|
|
488
|
+
contenteditable="true"
|
|
489
|
+
role="textbox"
|
|
490
|
+
aria-multiline="true"
|
|
491
|
+
aria-label=${this.placeholder}
|
|
492
|
+
data-placeholder=${this.placeholder}
|
|
493
|
+
@input=${this.onInput}
|
|
494
|
+
@focus=${this.onFocus}
|
|
495
|
+
@blur=${this.onBlur}
|
|
496
|
+
@keyup=${this.onSelect}
|
|
497
|
+
@mouseup=${this.onSelect}
|
|
498
|
+
></div>
|
|
499
|
+
${showFooter ? this.renderFooter() : null}
|
|
500
|
+
</div>
|
|
501
|
+
`;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
__decorateClass([
|
|
505
|
+
property()
|
|
506
|
+
], _OkRichText.prototype, "value");
|
|
507
|
+
__decorateClass([
|
|
508
|
+
property()
|
|
509
|
+
], _OkRichText.prototype, "placeholder");
|
|
510
|
+
__decorateClass([
|
|
511
|
+
property({ reflect: true })
|
|
512
|
+
], _OkRichText.prototype, "size");
|
|
513
|
+
__decorateClass([
|
|
514
|
+
property({ type: Boolean })
|
|
515
|
+
], _OkRichText.prototype, "toolbar");
|
|
516
|
+
__decorateClass([
|
|
517
|
+
property({ type: Boolean })
|
|
518
|
+
], _OkRichText.prototype, "footer");
|
|
519
|
+
__decorateClass([
|
|
520
|
+
state()
|
|
521
|
+
], _OkRichText.prototype, "focused");
|
|
522
|
+
__decorateClass([
|
|
523
|
+
state()
|
|
524
|
+
], _OkRichText.prototype, "activeFmts");
|
|
525
|
+
__decorateClass([
|
|
526
|
+
state()
|
|
527
|
+
], _OkRichText.prototype, "activeBlock");
|
|
528
|
+
__decorateClass([
|
|
529
|
+
state()
|
|
530
|
+
], _OkRichText.prototype, "words");
|
|
531
|
+
__decorateClass([
|
|
532
|
+
query(".content")
|
|
533
|
+
], _OkRichText.prototype, "contentEl");
|
|
534
|
+
let OkRichText = _OkRichText;
|
|
535
|
+
define("ok-rich-text", OkRichText);
|
|
536
|
+
export {
|
|
537
|
+
OkRichText
|
|
538
|
+
};
|