@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.
Files changed (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +457 -0
  3. package/dist/base/anchor.d.ts +13 -0
  4. package/dist/base/define.d.ts +1 -0
  5. package/dist/base/relay.d.ts +1 -0
  6. package/dist/cdn.d.ts +96 -0
  7. package/dist/components/ok-app-launcher/ok-app-launcher.d.ts +57 -0
  8. package/dist/components/ok-audio/ok-audio.d.ts +45 -0
  9. package/dist/components/ok-avatar/ok-avatar.d.ts +36 -0
  10. package/dist/components/ok-avatar-group/ok-avatar-group.d.ts +38 -0
  11. package/dist/components/ok-bar-list/ok-bar-list.d.ts +36 -0
  12. package/dist/components/ok-bento/ok-bento.d.ts +17 -0
  13. package/dist/components/ok-bento-item/ok-bento-item.d.ts +34 -0
  14. package/dist/components/ok-calculator/ok-calculator.d.ts +46 -0
  15. package/dist/components/ok-calendar/ok-calendar.d.ts +63 -0
  16. package/dist/components/ok-carousel/ok-carousel.d.ts +48 -0
  17. package/dist/components/ok-chart/ok-chart.d.ts +55 -0
  18. package/dist/components/ok-chat/ok-chat.d.ts +54 -0
  19. package/dist/components/ok-coachmark/ok-coachmark.d.ts +69 -0
  20. package/dist/components/ok-code/ok-code.d.ts +28 -0
  21. package/dist/components/ok-color-picker/ok-color-picker.d.ts +63 -0
  22. package/dist/components/ok-combo/ok-combo.d.ts +46 -0
  23. package/dist/components/ok-command-palette/ok-command-palette.d.ts +72 -0
  24. package/dist/components/ok-contact-form/ok-contact-form.d.ts +54 -0
  25. package/dist/components/ok-cropper/ok-cropper.d.ts +60 -0
  26. package/dist/components/ok-cta-band/ok-cta-band.d.ts +18 -0
  27. package/dist/components/ok-currency/ok-currency.d.ts +31 -0
  28. package/dist/components/ok-data-table/ok-data-table.d.ts +312 -0
  29. package/dist/components/ok-date-picker/ok-date-picker.d.ts +81 -0
  30. package/dist/components/ok-detail-list/ok-detail-list.d.ts +30 -0
  31. package/dist/components/ok-diff/ok-diff.d.ts +38 -0
  32. package/dist/components/ok-donut/ok-donut.d.ts +38 -0
  33. package/dist/components/ok-drawer/ok-drawer.d.ts +56 -0
  34. package/dist/components/ok-dropzone/ok-dropzone.d.ts +48 -0
  35. package/dist/components/ok-empty-state/ok-empty-state.d.ts +16 -0
  36. package/dist/components/ok-error-page/ok-error-page.d.ts +77 -0
  37. package/dist/components/ok-event-card/ok-event-card.d.ts +56 -0
  38. package/dist/components/ok-feature-card/ok-feature-card.d.ts +23 -0
  39. package/dist/components/ok-file-item/ok-file-item.d.ts +31 -0
  40. package/dist/components/ok-file-manager/ok-file-manager.d.ts +145 -0
  41. package/dist/components/ok-footer/ok-footer.d.ts +10 -0
  42. package/dist/components/ok-funnel/ok-funnel.d.ts +31 -0
  43. package/dist/components/ok-gallery/ok-gallery.d.ts +34 -0
  44. package/dist/components/ok-gauge/ok-gauge.d.ts +49 -0
  45. package/dist/components/ok-heatmap/ok-heatmap.d.ts +45 -0
  46. package/dist/components/ok-hero/ok-hero.d.ts +10 -0
  47. package/dist/components/ok-hover-card/ok-hover-card.d.ts +76 -0
  48. package/dist/components/ok-icon-tile/ok-icon-tile.d.ts +24 -0
  49. package/dist/components/ok-image/ok-image.d.ts +56 -0
  50. package/dist/components/ok-inline-feedback/ok-inline-feedback.d.ts +33 -0
  51. package/dist/components/ok-invoice/ok-invoice.d.ts +137 -0
  52. package/dist/components/ok-json-viewer/ok-json-viewer.d.ts +31 -0
  53. package/dist/components/ok-kanban/ok-kanban.d.ts +56 -0
  54. package/dist/components/ok-kbd/ok-kbd.d.ts +21 -0
  55. package/dist/components/ok-keyboard/ok-keyboard.d.ts +35 -0
  56. package/dist/components/ok-kpi/ok-kpi.d.ts +24 -0
  57. package/dist/components/ok-language-select/ok-language-select.d.ts +31 -0
  58. package/dist/components/ok-lightbox/ok-lightbox.d.ts +59 -0
  59. package/dist/components/ok-logo-cloud/ok-logo-cloud.d.ts +14 -0
  60. package/dist/components/ok-loyalty-card/ok-loyalty-card.d.ts +35 -0
  61. package/dist/components/ok-mail/ok-mail.d.ts +117 -0
  62. package/dist/components/ok-menu/ok-menu.d.ts +75 -0
  63. package/dist/components/ok-menubar/ok-menubar.d.ts +75 -0
  64. package/dist/components/ok-navbar/ok-navbar.d.ts +42 -0
  65. package/dist/components/ok-notification-center/ok-notification-center.d.ts +79 -0
  66. package/dist/components/ok-org-chart/ok-org-chart.d.ts +67 -0
  67. package/dist/components/ok-otp/ok-otp.d.ts +31 -0
  68. package/dist/components/ok-page-header/ok-page-header.d.ts +23 -0
  69. package/dist/components/ok-pagination/ok-pagination.d.ts +44 -0
  70. package/dist/components/ok-pdf/ok-pdf.d.ts +32 -0
  71. package/dist/components/ok-phone/ok-phone.d.ts +48 -0
  72. package/dist/components/ok-pinpad/ok-pinpad.d.ts +29 -0
  73. package/dist/components/ok-pricing-card/ok-pricing-card.d.ts +31 -0
  74. package/dist/components/ok-product-card/ok-product-card.d.ts +25 -0
  75. package/dist/components/ok-qr/ok-qr.d.ts +24 -0
  76. package/dist/components/ok-qty-stepper/ok-qty-stepper.d.ts +35 -0
  77. package/dist/components/ok-range-dual/ok-range-dual.d.ts +38 -0
  78. package/dist/components/ok-rating/ok-rating.d.ts +33 -0
  79. package/dist/components/ok-receipt/ok-receipt.d.ts +103 -0
  80. package/dist/components/ok-reveal/ok-reveal.d.ts +21 -0
  81. package/dist/components/ok-rich-text/ok-rich-text.d.ts +46 -0
  82. package/dist/components/ok-scheduler/ok-scheduler.d.ts +74 -0
  83. package/dist/components/ok-select-card/ok-select-card.d.ts +37 -0
  84. package/dist/components/ok-signature/ok-signature.d.ts +55 -0
  85. package/dist/components/ok-skeleton/ok-skeleton.d.ts +40 -0
  86. package/dist/components/ok-sparkline/ok-sparkline.d.ts +27 -0
  87. package/dist/components/ok-split-button/ok-split-button.d.ts +49 -0
  88. package/dist/components/ok-splitter/ok-splitter.d.ts +36 -0
  89. package/dist/components/ok-stat/ok-stat.d.ts +16 -0
  90. package/dist/components/ok-status-dot/ok-status-dot.d.ts +24 -0
  91. package/dist/components/ok-status-pill/ok-status-pill.d.ts +22 -0
  92. package/dist/components/ok-stepper/ok-stepper.d.ts +33 -0
  93. package/dist/components/ok-store/ok-store.d.ts +33 -0
  94. package/dist/components/ok-tag-input/ok-tag-input.d.ts +39 -0
  95. package/dist/components/ok-testimonial/ok-testimonial.d.ts +21 -0
  96. package/dist/components/ok-time-picker/ok-time-picker.d.ts +50 -0
  97. package/dist/components/ok-timeline/ok-timeline.d.ts +33 -0
  98. package/dist/components/ok-tree/ok-tree.d.ts +46 -0
  99. package/dist/components/ok-video/ok-video.d.ts +49 -0
  100. package/dist/components/ok-widget-board/ok-widget-board.d.ts +71 -0
  101. package/dist/components/ok-wizard/ok-wizard.d.ts +30 -0
  102. package/dist/define.js +8 -0
  103. package/dist/erplora.css +112 -0
  104. package/dist/index.d.ts +158 -0
  105. package/dist/index.js +197 -0
  106. package/dist/layout.css +338 -0
  107. package/dist/ok-app-launcher.js +396 -0
  108. package/dist/ok-audio.js +308 -0
  109. package/dist/ok-avatar-group.js +158 -0
  110. package/dist/ok-avatar.js +179 -0
  111. package/dist/ok-bar-list.js +189 -0
  112. package/dist/ok-bento-item.js +168 -0
  113. package/dist/ok-bento.js +63 -0
  114. package/dist/ok-calculator.js +406 -0
  115. package/dist/ok-calendar.js +541 -0
  116. package/dist/ok-carousel.js +352 -0
  117. package/dist/ok-chart.js +325 -0
  118. package/dist/ok-chat.js +320 -0
  119. package/dist/ok-coachmark.js +500 -0
  120. package/dist/ok-code.js +190 -0
  121. package/dist/ok-color-picker.js +569 -0
  122. package/dist/ok-combo.js +294 -0
  123. package/dist/ok-command-palette.js +448 -0
  124. package/dist/ok-contact-form.js +288 -0
  125. package/dist/ok-cropper.js +404 -0
  126. package/dist/ok-cta-band.js +134 -0
  127. package/dist/ok-currency.js +172 -0
  128. package/dist/ok-data-table.js +1281 -0
  129. package/dist/ok-date-picker.js +736 -0
  130. package/dist/ok-detail-list.js +156 -0
  131. package/dist/ok-diff.js +200 -0
  132. package/dist/ok-donut.js +280 -0
  133. package/dist/ok-drawer.js +357 -0
  134. package/dist/ok-dropzone.js +376 -0
  135. package/dist/ok-empty-state.js +104 -0
  136. package/dist/ok-error-page.js +547 -0
  137. package/dist/ok-event-card.js +384 -0
  138. package/dist/ok-feature-card.js +152 -0
  139. package/dist/ok-file-item.js +259 -0
  140. package/dist/ok-file-manager.js +1116 -0
  141. package/dist/ok-footer.js +67 -0
  142. package/dist/ok-funnel.js +181 -0
  143. package/dist/ok-gallery.js +293 -0
  144. package/dist/ok-gauge.js +385 -0
  145. package/dist/ok-heatmap.js +268 -0
  146. package/dist/ok-hero.js +43 -0
  147. package/dist/ok-hover-card.js +480 -0
  148. package/dist/ok-icon-tile.js +123 -0
  149. package/dist/ok-image.js +471 -0
  150. package/dist/ok-inline-feedback.js +221 -0
  151. package/dist/ok-invoice.js +229 -0
  152. package/dist/ok-json-viewer.js +330 -0
  153. package/dist/ok-kanban.js +427 -0
  154. package/dist/ok-kbd.js +159 -0
  155. package/dist/ok-keyboard.js +402 -0
  156. package/dist/ok-kpi.js +147 -0
  157. package/dist/ok-language-select.js +188 -0
  158. package/dist/ok-lightbox.js +490 -0
  159. package/dist/ok-logo-cloud.js +92 -0
  160. package/dist/ok-loyalty-card.js +353 -0
  161. package/dist/ok-mail.js +562 -0
  162. package/dist/ok-menu.js +529 -0
  163. package/dist/ok-menubar.js +628 -0
  164. package/dist/ok-navbar.js +306 -0
  165. package/dist/ok-notification-center.js +545 -0
  166. package/dist/ok-org-chart.js +619 -0
  167. package/dist/ok-otp.js +199 -0
  168. package/dist/ok-page-header.js +202 -0
  169. package/dist/ok-pagination.js +366 -0
  170. package/dist/ok-pdf.js +160 -0
  171. package/dist/ok-phone.js +225 -0
  172. package/dist/ok-pinpad.js +171 -0
  173. package/dist/ok-pricing-card.js +184 -0
  174. package/dist/ok-product-card.js +178 -0
  175. package/dist/ok-qr.js +652 -0
  176. package/dist/ok-qty-stepper.js +212 -0
  177. package/dist/ok-range-dual.js +280 -0
  178. package/dist/ok-rating.js +199 -0
  179. package/dist/ok-receipt.js +183 -0
  180. package/dist/ok-reveal.js +94 -0
  181. package/dist/ok-rich-text.js +538 -0
  182. package/dist/ok-scheduler.js +518 -0
  183. package/dist/ok-select-card.js +231 -0
  184. package/dist/ok-signature.js +267 -0
  185. package/dist/ok-skeleton.js +345 -0
  186. package/dist/ok-sparkline.js +150 -0
  187. package/dist/ok-split-button.js +251 -0
  188. package/dist/ok-splitter.js +289 -0
  189. package/dist/ok-stat.js +77 -0
  190. package/dist/ok-status-dot.js +163 -0
  191. package/dist/ok-status-pill.js +123 -0
  192. package/dist/ok-stepper.js +299 -0
  193. package/dist/ok-store.js +83 -0
  194. package/dist/ok-tag-input.js +358 -0
  195. package/dist/ok-testimonial.js +136 -0
  196. package/dist/ok-time-picker.js +472 -0
  197. package/dist/ok-timeline.js +251 -0
  198. package/dist/ok-tree.js +266 -0
  199. package/dist/ok-video.js +362 -0
  200. package/dist/ok-widget-board.js +265 -0
  201. package/dist/ok-wizard.js +153 -0
  202. package/dist/outfitkit.js +96 -0
  203. package/dist/shared/anchor.js +14 -0
  204. package/dist/store/controller.d.ts +17 -0
  205. package/dist/store/idb.d.ts +16 -0
  206. package/dist/store/store.d.ts +39 -0
  207. package/dist/store-controller.js +31 -0
  208. package/dist/store.js +182 -0
  209. package/dist/theme.example.css +70 -0
  210. package/package.json +147 -0
@@ -0,0 +1,480 @@
1
+ import { LitElement, css, html, nothing } from "lit";
2
+ import { property, state, query } from "lit/decorators.js";
3
+ import { define } from "./define.js";
4
+ import { c as computeAnchor } from "./shared/anchor.js";
5
+ var __defProp = Object.defineProperty;
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = void 0;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
+ if (decorator = decorators[i])
10
+ result = decorator(target, key, result) || result;
11
+ if (result) __defProp(target, key, result);
12
+ return result;
13
+ };
14
+ const DEFAULT_LABELS = {
15
+ card: "Preview"
16
+ };
17
+ class OkHoverCard extends LitElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.stats = [];
21
+ this.actions = [];
22
+ this.placement = "bottom";
23
+ this.openDelay = 220;
24
+ this.closeDelay = 180;
25
+ this.labels = {};
26
+ this.open = false;
27
+ this.shown = false;
28
+ this.end = false;
29
+ this.above = false;
30
+ this.onKeydown = (e) => {
31
+ if (e.key === "Escape" && this.open) {
32
+ this.clearTimers();
33
+ this.hide();
34
+ }
35
+ };
36
+ }
37
+ static {
38
+ this.styles = css`
39
+ :host {
40
+ /* Tokens propios estilo Ionic, default = cadena --ok-* → --ion-* → hex. */
41
+ --color: var(--ok-text-color, var(--ion-text-color, #1c1b17));
42
+ --color-muted: var(--ok-color-medium, var(--ion-color-medium, #6b6b76));
43
+ --color-faint: var(--ok-color-medium, var(--ion-color-step-450, #92949c));
44
+ --panel-bg: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #ffffff)));
45
+ --avatar-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.06));
46
+ --border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.12));
47
+ --border-soft: var(--ok-border-soft, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.08));
48
+ --primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
49
+ --primary-contrast: var(--ok-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
50
+ --primary-shade: var(--ok-primary-shade, var(--ion-color-primary-shade, #3171e0));
51
+ --action-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.05));
52
+ --action-bg-hover: var(--ok-hover-strong, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.1));
53
+ --radius: var(--ok-radius, 12px);
54
+ --radius-sm: var(--ok-radius-sm, 7px);
55
+ --shadow: var(--ok-shadow, 0 12px 32px rgba(0, 0, 0, 0.16));
56
+ --font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
57
+ --font-mono: var(--ok-font-mono, ui-monospace, 'SF Mono', 'Menlo', monospace);
58
+ --width: var(--ok-hover-card-width, 280px);
59
+
60
+ /* INLINE: el host envuelve solo el disparador en línea con el texto. */
61
+ display: inline;
62
+ position: relative;
63
+ font-family: var(--font);
64
+ }
65
+
66
+ /* Ancla: contenedor inline del disparador (slot por defecto). */
67
+ .trigger {
68
+ display: inline;
69
+ position: relative;
70
+ }
71
+
72
+ /* Panel flotante. position:absolute relativo al host (no fixed). */
73
+ .card {
74
+ position: absolute;
75
+ top: 100%;
76
+ left: 0;
77
+ z-index: 1000;
78
+ width: var(--width);
79
+ max-width: calc(100vw - 24px);
80
+ margin-top: 8px;
81
+ box-sizing: border-box;
82
+ padding: 14px;
83
+ background: var(--panel-bg);
84
+ border: 1px solid var(--border-color);
85
+ border-radius: var(--radius);
86
+ box-shadow: var(--shadow);
87
+ font-size: 0.8125rem;
88
+ color: var(--color-muted);
89
+ line-height: 1.5;
90
+ text-align: left;
91
+ cursor: default;
92
+ /* Estado oculto: invisible y no interactivo, listo para animar. */
93
+ opacity: 0;
94
+ transform: translateY(4px);
95
+ pointer-events: none;
96
+ transition: opacity var(--ok-transition, 160ms ease), transform var(--ok-transition, 160ms ease);
97
+ }
98
+ /* Abre hacia la izquierda (alinea borde derecho con el del disparador). */
99
+ .card.end {
100
+ left: auto;
101
+ right: 0;
102
+ }
103
+ /* Abre hacia arriba. */
104
+ .card.above {
105
+ top: auto;
106
+ bottom: 100%;
107
+ margin-top: 0;
108
+ margin-bottom: 8px;
109
+ transform: translateY(-4px);
110
+ }
111
+ .card.shown {
112
+ opacity: 1;
113
+ transform: translateY(0);
114
+ pointer-events: auto;
115
+ }
116
+ @media (prefers-reduced-motion: reduce) {
117
+ .card {
118
+ transition: opacity 120ms ease;
119
+ transform: none;
120
+ }
121
+ .card.above {
122
+ transform: none;
123
+ }
124
+ }
125
+
126
+ /* Cabecera: avatar + título/handle. */
127
+ .head {
128
+ display: flex;
129
+ align-items: flex-start;
130
+ gap: 10px;
131
+ margin-bottom: 8px;
132
+ }
133
+ .avatar {
134
+ width: 38px;
135
+ height: 38px;
136
+ flex-shrink: 0;
137
+ border-radius: 10px;
138
+ background: var(--avatar-bg);
139
+ display: grid;
140
+ place-items: center;
141
+ overflow: hidden;
142
+ font-weight: 600;
143
+ font-size: 13px;
144
+ color: var(--color);
145
+ }
146
+ .avatar img {
147
+ width: 100%;
148
+ height: 100%;
149
+ object-fit: cover;
150
+ }
151
+ .title {
152
+ display: flex;
153
+ align-items: center;
154
+ flex-wrap: wrap;
155
+ gap: 6px;
156
+ font-weight: 600;
157
+ font-size: 0.9375rem;
158
+ letter-spacing: -0.01em;
159
+ color: var(--color);
160
+ }
161
+ /* Badge inline junto al título (estilo brand). */
162
+ .badge {
163
+ display: inline-flex;
164
+ align-items: center;
165
+ padding: 1px 7px;
166
+ border-radius: 999px;
167
+ font-size: 0.6875rem;
168
+ font-weight: 600;
169
+ line-height: 1.4;
170
+ background: var(--primary-color);
171
+ color: var(--primary-contrast);
172
+ }
173
+ .handle {
174
+ margin-top: 1px;
175
+ font-family: var(--font-mono);
176
+ font-size: 0.6875rem;
177
+ color: var(--color-faint);
178
+ }
179
+
180
+ .body {
181
+ font-size: 0.8125rem;
182
+ color: var(--color-muted);
183
+ line-height: 1.5;
184
+ }
185
+ ::slotted([slot='content']) {
186
+ font-size: 0.8125rem;
187
+ color: var(--color-muted);
188
+ line-height: 1.5;
189
+ }
190
+
191
+ /* Fila de 3 cifras tabulares. */
192
+ .stats {
193
+ display: flex;
194
+ gap: 14px;
195
+ margin-top: 10px;
196
+ padding-top: 10px;
197
+ border-top: 1px solid var(--border-soft);
198
+ font-size: 0.6875rem;
199
+ color: var(--color-faint);
200
+ }
201
+ .stat b {
202
+ display: block;
203
+ font-size: 0.875rem;
204
+ font-weight: 600;
205
+ color: var(--color);
206
+ font-variant-numeric: tabular-nums;
207
+ }
208
+
209
+ /* Pie: hasta 2 botones (el realce brand). */
210
+ .footer {
211
+ display: flex;
212
+ gap: 6px;
213
+ margin-top: 10px;
214
+ }
215
+ .action {
216
+ flex: 1;
217
+ height: 28px;
218
+ display: inline-flex;
219
+ align-items: center;
220
+ justify-content: center;
221
+ padding: 0 8px;
222
+ border: 1px solid var(--border-color);
223
+ border-radius: var(--radius-sm);
224
+ background: var(--action-bg);
225
+ color: var(--color);
226
+ font: inherit;
227
+ font-size: 0.6875rem;
228
+ font-weight: 500;
229
+ text-decoration: none;
230
+ cursor: pointer;
231
+ transition: background-color var(--ok-transition, 150ms ease),
232
+ border-color var(--ok-transition, 150ms ease);
233
+ }
234
+ @media (hover: hover) {
235
+ .action:hover {
236
+ background: var(--action-bg-hover);
237
+ }
238
+ }
239
+ .action.brand {
240
+ background: var(--primary-color);
241
+ border-color: var(--primary-color);
242
+ color: var(--primary-contrast);
243
+ }
244
+ @media (hover: hover) {
245
+ .action.brand:hover {
246
+ background: var(--primary-shade);
247
+ border-color: var(--primary-shade);
248
+ }
249
+ }
250
+ `;
251
+ }
252
+ // Textos efectivos: defaults en inglés + overrides del consumidor.
253
+ get t() {
254
+ return { ...DEFAULT_LABELS, ...this.labels };
255
+ }
256
+ disconnectedCallback() {
257
+ super.disconnectedCallback();
258
+ this.clearTimers();
259
+ }
260
+ clearTimers() {
261
+ if (this.openTimer) window.clearTimeout(this.openTimer);
262
+ if (this.closeTimer) window.clearTimeout(this.closeTimer);
263
+ this.openTimer = void 0;
264
+ this.closeTimer = void 0;
265
+ }
266
+ // Programa la apertura tras `openDelay` (cancela cualquier cierre pendiente).
267
+ scheduleOpen() {
268
+ if (this.closeTimer) {
269
+ window.clearTimeout(this.closeTimer);
270
+ this.closeTimer = void 0;
271
+ }
272
+ if (this.open) return;
273
+ if (this.openTimer) return;
274
+ this.openTimer = window.setTimeout(() => {
275
+ this.openTimer = void 0;
276
+ this.show();
277
+ }, Math.max(0, this.openDelay));
278
+ }
279
+ // Programa el cierre tras `closeDelay` (cancela cualquier apertura pendiente).
280
+ scheduleClose() {
281
+ if (this.openTimer) {
282
+ window.clearTimeout(this.openTimer);
283
+ this.openTimer = void 0;
284
+ }
285
+ if (!this.open) return;
286
+ if (this.closeTimer) return;
287
+ this.closeTimer = window.setTimeout(() => {
288
+ this.closeTimer = void 0;
289
+ this.hide();
290
+ }, Math.max(0, this.closeDelay));
291
+ }
292
+ show() {
293
+ if (this.open) return;
294
+ this.open = true;
295
+ this.dispatchEvent(
296
+ new CustomEvent("ok-open", { detail: { open: true }, bubbles: true, composed: true })
297
+ );
298
+ requestAnimationFrame(() => {
299
+ this.anchor();
300
+ requestAnimationFrame(() => this.shown = true);
301
+ });
302
+ }
303
+ hide() {
304
+ if (!this.open) return;
305
+ this.shown = false;
306
+ const card = this.cardEl;
307
+ const finish = () => {
308
+ this.open = false;
309
+ };
310
+ if (card && !this.prefersReducedMotion()) {
311
+ card.addEventListener("transitionend", finish, { once: true });
312
+ } else {
313
+ finish();
314
+ }
315
+ this.dispatchEvent(
316
+ new CustomEvent("ok-open", { detail: { open: false }, bubbles: true, composed: true })
317
+ );
318
+ }
319
+ // Resuelve los lados (derecha/arriba) con computeAnchor; respeta la `placement` preferida.
320
+ anchor() {
321
+ const trigger = this.triggerEl;
322
+ const card = this.cardEl;
323
+ if (!trigger || !card) return;
324
+ const { end, above } = computeAnchor(trigger, card, { gap: 8, margin: 12 });
325
+ this.end = end;
326
+ this.above = this.placement === "top" ? !this.fitsBelow() || above : above;
327
+ }
328
+ // ¿Cabe la tarjeta debajo del disparador dentro del viewport?
329
+ fitsBelow() {
330
+ const trigger = this.triggerEl;
331
+ const card = this.cardEl;
332
+ if (!trigger || !card) return true;
333
+ const t = trigger.getBoundingClientRect();
334
+ const p = card.getBoundingClientRect();
335
+ return t.bottom + 8 + p.height <= window.innerHeight - 12;
336
+ }
337
+ prefersReducedMotion() {
338
+ return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
339
+ }
340
+ // Click en un botón del pie: si tiene `href` navega; si no, emite `ok-action`. Cierra siempre.
341
+ runAction(action) {
342
+ if (action.href) {
343
+ window.location.href = action.href;
344
+ return;
345
+ }
346
+ this.dispatchEvent(
347
+ new CustomEvent("ok-action", {
348
+ detail: { id: action.id, action },
349
+ bubbles: true,
350
+ composed: true
351
+ })
352
+ );
353
+ this.clearTimers();
354
+ this.hide();
355
+ }
356
+ renderAvatar() {
357
+ if (this.avatarSrc) {
358
+ return html`<img src=${this.avatarSrc} alt="" />`;
359
+ }
360
+ return this.avatar ?? "";
361
+ }
362
+ render() {
363
+ const hasStats = this.stats.length > 0;
364
+ const hasActions = this.actions.length > 0;
365
+ const cardCls = `card${this.shown ? " shown" : ""}${this.end ? " end" : ""}${this.above ? " above" : ""}`;
366
+ return html`
367
+ <span
368
+ class="trigger"
369
+ @mouseenter=${() => this.scheduleOpen()}
370
+ @mouseleave=${() => this.scheduleClose()}
371
+ @focusin=${() => this.scheduleOpen()}
372
+ @focusout=${() => this.scheduleClose()}
373
+ @keydown=${this.onKeydown}
374
+ >
375
+ <slot></slot>
376
+ ${this.open ? html`
377
+ <span
378
+ class=${cardCls}
379
+ role="dialog"
380
+ aria-label=${this.name ?? this.t.card}
381
+ @mouseenter=${() => this.scheduleOpen()}
382
+ @mouseleave=${() => this.scheduleClose()}
383
+ >
384
+ <span class="head">
385
+ <span class="avatar">${this.renderAvatar()}</span>
386
+ <span>
387
+ ${this.name ? html`<span class="title"
388
+ >${this.name}${this.badge ? html`<span class="badge">${this.badge}</span>` : nothing}</span
389
+ >` : nothing}
390
+ ${this.handle ? html`<span class="handle">${this.handle}</span>` : nothing}
391
+ </span>
392
+ </span>
393
+ <slot name="content"
394
+ >${this.body ? html`<span class="body">${this.body}</span>` : nothing}</slot
395
+ >
396
+ ${hasStats ? html`<span class="stats">
397
+ ${this.stats.slice(0, 3).map(
398
+ (s) => html`<span class="stat"><b>${s.value}</b>${s.label}</span>`
399
+ )}
400
+ </span>` : nothing}
401
+ ${hasActions ? html`<span class="footer">
402
+ ${this.actions.slice(0, 2).map(
403
+ (a) => a.href ? html`<a
404
+ class="action${a.brand ? " brand" : ""}"
405
+ href=${a.href}
406
+ @click=${() => this.clearTimers()}
407
+ >${a.label}</a
408
+ >` : html`<button
409
+ type="button"
410
+ class="action${a.brand ? " brand" : ""}"
411
+ @click=${() => this.runAction(a)}
412
+ >
413
+ ${a.label}
414
+ </button>`
415
+ )}
416
+ </span>` : nothing}
417
+ </span>
418
+ ` : nothing}
419
+ </span>
420
+ `;
421
+ }
422
+ }
423
+ __decorateClass([
424
+ property()
425
+ ], OkHoverCard.prototype, "name");
426
+ __decorateClass([
427
+ property()
428
+ ], OkHoverCard.prototype, "badge");
429
+ __decorateClass([
430
+ property()
431
+ ], OkHoverCard.prototype, "handle");
432
+ __decorateClass([
433
+ property()
434
+ ], OkHoverCard.prototype, "avatar");
435
+ __decorateClass([
436
+ property({ attribute: "avatar-src" })
437
+ ], OkHoverCard.prototype, "avatarSrc");
438
+ __decorateClass([
439
+ property()
440
+ ], OkHoverCard.prototype, "body");
441
+ __decorateClass([
442
+ property({ attribute: false })
443
+ ], OkHoverCard.prototype, "stats");
444
+ __decorateClass([
445
+ property({ attribute: false })
446
+ ], OkHoverCard.prototype, "actions");
447
+ __decorateClass([
448
+ property()
449
+ ], OkHoverCard.prototype, "placement");
450
+ __decorateClass([
451
+ property({ type: Number, attribute: "open-delay" })
452
+ ], OkHoverCard.prototype, "openDelay");
453
+ __decorateClass([
454
+ property({ type: Number, attribute: "close-delay" })
455
+ ], OkHoverCard.prototype, "closeDelay");
456
+ __decorateClass([
457
+ property({ attribute: false })
458
+ ], OkHoverCard.prototype, "labels");
459
+ __decorateClass([
460
+ state()
461
+ ], OkHoverCard.prototype, "open");
462
+ __decorateClass([
463
+ state()
464
+ ], OkHoverCard.prototype, "shown");
465
+ __decorateClass([
466
+ state()
467
+ ], OkHoverCard.prototype, "end");
468
+ __decorateClass([
469
+ state()
470
+ ], OkHoverCard.prototype, "above");
471
+ __decorateClass([
472
+ query(".card")
473
+ ], OkHoverCard.prototype, "cardEl");
474
+ __decorateClass([
475
+ query(".trigger")
476
+ ], OkHoverCard.prototype, "triggerEl");
477
+ define("ok-hover-card", OkHoverCard);
478
+ export {
479
+ OkHoverCard
480
+ };
@@ -0,0 +1,123 @@
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 OkIconTile extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.color = "neutral";
17
+ this.size = "md";
18
+ this.shape = "rounded";
19
+ }
20
+ static {
21
+ this.styles = css`
22
+ :host {
23
+ /* Inline atom: no ocupa el ancho del contenedor. */
24
+ display: inline-flex;
25
+ /* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
26
+ --fg: var(--ok-text-color, var(--ion-text-color, #1f2933));
27
+ /* Fondo SOFT derivado del PROPIO color del icono (lavado ~13%), no del --ion-color-*-tint
28
+ * del tema (que suele ser saturado y tapaba el icono). Así el icono va a color pleno (--fg)
29
+ * sobre un lavado apenas perceptible y SIEMPRE se ve. Override con --bg si se quiere otro. */
30
+ --bg: color-mix(in srgb, var(--fg) 13%, transparent);
31
+ --size: 2rem; /* 32px (md) */
32
+ --radius: 0.5rem; /* 8px */
33
+ --icon-size: 1.125rem; /* 18px */
34
+ }
35
+
36
+ /* Solo el color del icono (--fg); el fondo se deriva del lavado soft del propio --fg (arriba). */
37
+ :host([color='brand']) { --fg: var(--ok-brand, var(--ion-color-primary, #3880ff)); }
38
+ :host([color='leaf']) { --fg: var(--ok-leaf, var(--ion-color-success, #2dad62)); }
39
+ :host([color='warn']) { --fg: var(--ok-warn, var(--ion-color-warning, #c79100)); }
40
+ :host([color='danger']) { --fg: var(--ok-danger, var(--ion-color-danger, #d8553f)); }
41
+ :host([color='info']) { --fg: var(--ok-info, var(--ion-color-tertiary, #5b8cd9)); }
42
+ :host([color='neutral']) { --fg: var(--ok-color-medium, var(--ion-color-medium, #6b7280)); }
43
+
44
+ /* Tamaños. */
45
+ :host([size='lg']) {
46
+ --size: 2.5rem; /* 40px */
47
+ --icon-size: 1.375rem; /* 22px */
48
+ }
49
+
50
+ /* Forma circular. */
51
+ :host([shape='circle']) {
52
+ --radius: 9999px;
53
+ }
54
+
55
+ .tile {
56
+ display: inline-grid;
57
+ place-items: center;
58
+ width: var(--size);
59
+ height: var(--size);
60
+ border-radius: var(--radius);
61
+ background: var(--bg);
62
+ color: var(--fg);
63
+ flex-shrink: 0;
64
+ }
65
+
66
+ /* Tanto ion-icon como iconify-icon respetan el tamaño. */
67
+ ion-icon,
68
+ iconify-icon,
69
+ ::slotted(*) {
70
+ font-size: var(--icon-size);
71
+ width: var(--icon-size);
72
+ height: var(--icon-size);
73
+ }
74
+
75
+ iconify-icon {
76
+ display: inline-flex;
77
+ }
78
+ `;
79
+ }
80
+ // Render del icono: `iconify-icon` si el nombre trae prefijo de set ("set:name");
81
+ // si no, `ion-icon` (que resuelve por nombre Ionicons). Ambos los registra el host.
82
+ renderIcon() {
83
+ if (!this.icon) {
84
+ return html`<slot></slot>`;
85
+ }
86
+ if (this.icon.includes(":")) {
87
+ return html`<iconify-icon icon=${this.icon} aria-hidden="true"></iconify-icon>`;
88
+ }
89
+ return html`<ion-icon name=${this.icon} aria-hidden="true"></ion-icon>`;
90
+ }
91
+ render() {
92
+ const decorative = !this.label;
93
+ return html`
94
+ <span
95
+ class="tile"
96
+ role="img"
97
+ aria-hidden=${decorative ? "true" : "false"}
98
+ aria-label=${this.label ?? ""}
99
+ >
100
+ ${this.renderIcon()}
101
+ </span>
102
+ `;
103
+ }
104
+ }
105
+ __decorateClass([
106
+ property()
107
+ ], OkIconTile.prototype, "icon");
108
+ __decorateClass([
109
+ property({ reflect: true })
110
+ ], OkIconTile.prototype, "color");
111
+ __decorateClass([
112
+ property({ reflect: true })
113
+ ], OkIconTile.prototype, "size");
114
+ __decorateClass([
115
+ property({ reflect: true })
116
+ ], OkIconTile.prototype, "shape");
117
+ __decorateClass([
118
+ property()
119
+ ], OkIconTile.prototype, "label");
120
+ define("ok-icon-tile", OkIconTile);
121
+ export {
122
+ OkIconTile
123
+ };