@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,529 @@
1
+ import { LitElement, css, html, nothing } from "lit";
2
+ import { property, state } 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
+ class OkMenu extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.items = [];
18
+ this.trigger = "click";
19
+ this.anchor = "bl";
20
+ this.width = "md";
21
+ this.open = false;
22
+ this.flipEnd = false;
23
+ this.flipAbove = false;
24
+ this.ctxX = 0;
25
+ this.ctxY = 0;
26
+ this.openSub = null;
27
+ this.onDocPointer = (e) => {
28
+ if (!this.open) return;
29
+ const path = e.composedPath();
30
+ if (!path.includes(this)) this.close();
31
+ };
32
+ this.onKeydown = (e) => {
33
+ if (!this.open) return;
34
+ if (e.key === "Escape") {
35
+ e.stopPropagation();
36
+ this.close();
37
+ return;
38
+ }
39
+ const focusables = this.focusableItems();
40
+ if (focusables.length === 0) return;
41
+ const active = this.shadowRoot?.activeElement ?? null;
42
+ const idx = active ? focusables.indexOf(active) : -1;
43
+ if (e.key === "ArrowDown") {
44
+ e.preventDefault();
45
+ focusables[(idx + 1) % focusables.length].focus();
46
+ } else if (e.key === "ArrowUp") {
47
+ e.preventDefault();
48
+ focusables[(idx - 1 + focusables.length) % focusables.length].focus();
49
+ } else if (e.key === "Home") {
50
+ e.preventDefault();
51
+ focusables[0].focus();
52
+ } else if (e.key === "End") {
53
+ e.preventDefault();
54
+ focusables[focusables.length - 1].focus();
55
+ }
56
+ };
57
+ this.onContextMenu = (e) => {
58
+ if (this.trigger !== "context") return;
59
+ e.preventDefault();
60
+ const rect = this.getBoundingClientRect();
61
+ this.ctxX = e.clientX - rect.left;
62
+ this.ctxY = e.clientY - rect.top;
63
+ this.openMenu();
64
+ };
65
+ this.onTriggerClick = () => {
66
+ if (this.trigger !== "click") return;
67
+ this.open ? this.close() : this.openMenu();
68
+ };
69
+ }
70
+ static {
71
+ this.styles = css`
72
+ :host {
73
+ /* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
74
+ --bg: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #ffffff)));
75
+ --color: var(--ok-text-color, var(--ion-text-color, #1f2933));
76
+ --color-muted: var(--ok-color-medium, var(--ion-color-medium, #92949c));
77
+ --hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 31, 41, 51), 0.06));
78
+ --border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 31, 41, 51), 0.12));
79
+ --divider-color: var(--ok-divider, rgba(var(--ion-text-color-rgb, 31, 41, 51), 0.1));
80
+ --primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
81
+ --danger-color: var(--ok-danger, var(--ion-color-danger, #eb445a));
82
+ --radius: var(--ok-radius, 12px);
83
+ --radius-item: var(--ok-radius-item, 8px);
84
+ --shadow: var(--ok-shadow, 0 8px 28px rgba(0, 0, 0, 0.16));
85
+ --font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
86
+ --font-mono: var(--ok-font-mono, ui-monospace, 'SF Mono', 'Roboto Mono', monospace);
87
+
88
+ display: block;
89
+ width: 100%;
90
+ position: relative;
91
+ color: var(--color);
92
+ font-family: var(--font);
93
+ }
94
+
95
+ /* Envoltorio del disparador (slot por defecto). Inline-block para no estirar el trigger. */
96
+ .anchor {
97
+ display: contents;
98
+ }
99
+
100
+ /* Panel flotante: absolute respecto al host (NO fixed, evita problemas con ancestros
101
+ transformados). El lado se decide con computeAnchor (.end / .above). */
102
+ .panel {
103
+ position: absolute;
104
+ z-index: 1000;
105
+ min-width: 200px;
106
+ background: var(--bg);
107
+ border: 1px solid var(--border-color);
108
+ border-radius: var(--radius);
109
+ box-shadow: var(--shadow);
110
+ padding: 6px;
111
+ box-sizing: border-box;
112
+ font-size: 0.875rem;
113
+ /* Posición base por anchor; computeAnchor puede voltear vía .end/.above. */
114
+ }
115
+ .panel.sm {
116
+ min-width: 160px;
117
+ }
118
+ .panel.md {
119
+ min-width: 200px;
120
+ }
121
+ .panel.lg {
122
+ min-width: 240px;
123
+ }
124
+
125
+ /* Anchors básicos (modo click). El default abre abajo-izquierda. */
126
+ .panel.bl {
127
+ left: 0;
128
+ top: 100%;
129
+ margin-top: 4px;
130
+ }
131
+ .panel.br {
132
+ right: 0;
133
+ top: 100%;
134
+ margin-top: 4px;
135
+ }
136
+ .panel.tl {
137
+ left: 0;
138
+ bottom: 100%;
139
+ margin-bottom: 4px;
140
+ }
141
+ .panel.tr {
142
+ right: 0;
143
+ bottom: 100%;
144
+ margin-bottom: 4px;
145
+ }
146
+ /* Volteos calculados en runtime por computeAnchor. */
147
+ .panel.flip-end {
148
+ left: auto;
149
+ right: 0;
150
+ }
151
+ .panel.flip-start {
152
+ right: auto;
153
+ left: 0;
154
+ }
155
+ .panel.flip-above {
156
+ top: auto;
157
+ bottom: 100%;
158
+ margin-top: 0;
159
+ margin-bottom: 4px;
160
+ }
161
+ .panel.flip-below {
162
+ bottom: auto;
163
+ top: 100%;
164
+ margin-bottom: 0;
165
+ margin-top: 4px;
166
+ }
167
+
168
+ /* Modo contextual: posicionado por coordenadas; animación pop scale+fade. */
169
+ .panel.context {
170
+ top: var(--ctx-y, 0);
171
+ left: var(--ctx-x, 0);
172
+ margin: 0;
173
+ animation: ok-menu-pop 120ms ease-out;
174
+ }
175
+ @keyframes ok-menu-pop {
176
+ from {
177
+ opacity: 0;
178
+ transform: scale(0.96) translateY(-2px);
179
+ }
180
+ to {
181
+ opacity: 1;
182
+ transform: scale(1) translateY(0);
183
+ }
184
+ }
185
+ @media (prefers-reduced-motion: reduce) {
186
+ .panel.context {
187
+ animation: none;
188
+ }
189
+ }
190
+
191
+ /* Cabecera de usuario opcional (slot=header). */
192
+ .header {
193
+ padding: 8px 10px 10px;
194
+ margin: -2px 0 4px;
195
+ border-bottom: 1px solid var(--divider-color);
196
+ }
197
+ .header::slotted(*) {
198
+ font-size: 0.8125rem;
199
+ }
200
+
201
+ ul {
202
+ list-style: none;
203
+ margin: 0;
204
+ padding: 0;
205
+ }
206
+
207
+ /* Entrada de menú (botón). */
208
+ .item {
209
+ display: flex;
210
+ align-items: center;
211
+ gap: 10px;
212
+ width: 100%;
213
+ box-sizing: border-box;
214
+ padding: 7px 10px;
215
+ border: 0;
216
+ background: transparent;
217
+ color: inherit;
218
+ font: inherit;
219
+ text-align: left;
220
+ cursor: pointer;
221
+ border-radius: var(--radius-item);
222
+ position: relative;
223
+ }
224
+ .item:hover:not(.disabled),
225
+ .item:focus-visible:not(.disabled) {
226
+ background: var(--hover-bg);
227
+ outline: none;
228
+ }
229
+ .item.disabled {
230
+ opacity: 0.4;
231
+ cursor: default;
232
+ pointer-events: none;
233
+ }
234
+ .item.danger {
235
+ color: var(--danger-color);
236
+ }
237
+ .item ion-icon {
238
+ width: 16px;
239
+ height: 16px;
240
+ font-size: 16px;
241
+ flex-shrink: 0;
242
+ color: var(--color-muted);
243
+ }
244
+ .item.danger ion-icon {
245
+ color: var(--danger-color);
246
+ }
247
+ .label {
248
+ flex: 1;
249
+ min-width: 0;
250
+ overflow: hidden;
251
+ text-overflow: ellipsis;
252
+ white-space: nowrap;
253
+ }
254
+
255
+ /* Atajo mono alineado a la derecha (look ok-kbd). */
256
+ .shortcut {
257
+ margin-left: auto;
258
+ flex-shrink: 0;
259
+ font-family: var(--font-mono);
260
+ font-size: 0.6875rem;
261
+ line-height: 1;
262
+ color: var(--color-muted);
263
+ padding: 2px 5px;
264
+ border: 1px solid var(--border-color);
265
+ border-radius: 5px;
266
+ background: var(--hover-bg);
267
+ }
268
+
269
+ /* Sangrado y check para checkbox/radio. */
270
+ .item.checkable {
271
+ padding-left: 30px;
272
+ }
273
+ .check {
274
+ position: absolute;
275
+ left: 10px;
276
+ top: 50%;
277
+ transform: translateY(-50%);
278
+ width: 13px;
279
+ height: 13px;
280
+ flex-shrink: 0;
281
+ }
282
+ .check.radio {
283
+ border-radius: 50%;
284
+ }
285
+ .check.checked.checkbox {
286
+ /* Tick dibujado con dos gradientes (sin SVG, CSP-safe). */
287
+ background: linear-gradient(45deg, transparent 28%, var(--primary-color) 28% 40%, transparent 40%)
288
+ bottom left / 55% 60% no-repeat,
289
+ linear-gradient(-45deg, transparent 28%, var(--primary-color) 28% 40%, transparent 40%) top right /
290
+ 70% 70% no-repeat;
291
+ }
292
+ .check.checked.radio {
293
+ background: var(--primary-color);
294
+ box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px var(--primary-color);
295
+ }
296
+
297
+ /* Chevron de submenú. */
298
+ .chevron {
299
+ margin-left: auto;
300
+ flex-shrink: 0;
301
+ width: 7px;
302
+ height: 7px;
303
+ border-right: 1.5px solid var(--color-muted);
304
+ border-top: 1.5px solid var(--color-muted);
305
+ transform: rotate(45deg);
306
+ }
307
+ .item.has-sub {
308
+ padding-right: 20px;
309
+ }
310
+
311
+ /* Divisor y etiqueta de sección. */
312
+ .divider {
313
+ height: 1px;
314
+ background: var(--divider-color);
315
+ margin: 6px 4px;
316
+ }
317
+ .section {
318
+ padding: 6px 10px 4px;
319
+ font-size: 0.6875rem;
320
+ font-weight: 600;
321
+ letter-spacing: 0.06em;
322
+ text-transform: uppercase;
323
+ color: var(--color-muted);
324
+ }
325
+
326
+ /* Submenú en cascada: absolute al lado de su <li> padre. */
327
+ li.sub-host {
328
+ position: relative;
329
+ }
330
+ .submenu {
331
+ position: absolute;
332
+ top: -7px;
333
+ left: calc(100% + 4px);
334
+ min-width: 190px;
335
+ background: var(--bg);
336
+ border: 1px solid var(--border-color);
337
+ border-radius: var(--radius);
338
+ box-shadow: var(--shadow);
339
+ padding: 6px;
340
+ box-sizing: border-box;
341
+ z-index: 1;
342
+ }
343
+ .submenu.left {
344
+ left: auto;
345
+ right: calc(100% + 4px);
346
+ }
347
+ `;
348
+ }
349
+ focusableItems() {
350
+ return Array.from(
351
+ this.renderRoot.querySelectorAll(".panel > ul > li > .item:not(.disabled)")
352
+ );
353
+ }
354
+ connectedCallback() {
355
+ super.connectedCallback();
356
+ document.addEventListener("pointerdown", this.onDocPointer, true);
357
+ document.addEventListener("keydown", this.onKeydown, true);
358
+ this.addEventListener("contextmenu", this.onContextMenu);
359
+ }
360
+ disconnectedCallback() {
361
+ super.disconnectedCallback();
362
+ document.removeEventListener("pointerdown", this.onDocPointer, true);
363
+ document.removeEventListener("keydown", this.onKeydown, true);
364
+ this.removeEventListener("contextmenu", this.onContextMenu);
365
+ }
366
+ openMenu() {
367
+ if (this.open) return;
368
+ this.openSub = null;
369
+ this.open = true;
370
+ this.dispatchEvent(
371
+ new CustomEvent("ok-open", { detail: { open: true }, bubbles: true, composed: true })
372
+ );
373
+ this.updateComplete.then(() => {
374
+ this.measureAnchor();
375
+ const first = this.focusableItems()[0];
376
+ first?.focus();
377
+ });
378
+ }
379
+ close() {
380
+ if (!this.open) return;
381
+ this.open = false;
382
+ this.openSub = null;
383
+ this.dispatchEvent(
384
+ new CustomEvent("ok-open", { detail: { open: false }, bubbles: true, composed: true })
385
+ );
386
+ }
387
+ // Recalcula volteo con computeAnchor (modo click). En contextual se respeta el cursor.
388
+ measureAnchor() {
389
+ if (this.trigger === "context") return;
390
+ const panel = this.renderRoot.querySelector(".panel");
391
+ if (!panel) return;
392
+ const side = computeAnchor(this, panel, { gap: 4 });
393
+ this.flipEnd = side.end;
394
+ this.flipAbove = side.above;
395
+ }
396
+ // Activa una entrada hoja: emite ok-select y cierra. Submenús/divisores/secciones no aplican.
397
+ activate(entry) {
398
+ if (entry.disabled || entry.divider || entry.section != null) return;
399
+ if (entry.children && entry.children.length) return;
400
+ if (entry.id != null) {
401
+ this.dispatchEvent(
402
+ new CustomEvent("ok-select", { detail: { id: entry.id }, bubbles: true, composed: true })
403
+ );
404
+ }
405
+ this.close();
406
+ }
407
+ // Un icono es «SVG ya resuelto» si empieza por `<` o es `data:` → va a la prop `icon` de ion-icon.
408
+ isResolvedSvg(icon) {
409
+ return /^\s*</.test(icon) || icon.startsWith("data:");
410
+ }
411
+ renderIcon(icon) {
412
+ return this.isResolvedSvg(icon) ? html`<ion-icon .icon=${icon}></ion-icon>` : html`<ion-icon .name=${icon}></ion-icon>`;
413
+ }
414
+ renderEntry(entry, key) {
415
+ if (entry.divider) return html`<li><div class="divider" role="separator"></div></li>`;
416
+ if (entry.section != null)
417
+ return html`<li><div class="section">${entry.section}</div></li>`;
418
+ const hasSub = !!(entry.children && entry.children.length);
419
+ const checkable = entry.role === "checkbox" || entry.role === "radio";
420
+ const ariaRole = entry.role === "checkbox" ? "menuitemcheckbox" : entry.role === "radio" ? "menuitemradio" : "menuitem";
421
+ return html`<li class=${hasSub ? "sub-host" : ""}>
422
+ <button
423
+ type="button"
424
+ class="item${entry.danger ? " danger" : ""}${entry.disabled ? " disabled" : ""}${checkable ? " checkable" : ""}${hasSub ? " has-sub" : ""}"
425
+ role=${ariaRole}
426
+ aria-disabled=${entry.disabled ? "true" : "false"}
427
+ aria-checked=${checkable ? entry.checked ? "true" : "false" : nothing}
428
+ aria-haspopup=${hasSub ? "menu" : nothing}
429
+ aria-expanded=${hasSub ? this.openSub === key ? "true" : "false" : nothing}
430
+ tabindex=${entry.disabled ? -1 : 0}
431
+ @click=${() => hasSub ? this.toggleSub(key) : this.activate(entry)}
432
+ @mouseenter=${() => hasSub && (this.openSub = key)}
433
+ @focus=${() => hasSub && (this.openSub = key)}
434
+ @keydown=${(e) => this.onItemKeydown(e, entry, key, hasSub)}
435
+ >
436
+ ${checkable ? html`<span
437
+ class="check ${entry.role} ${entry.checked ? "checked" : ""}"
438
+ aria-hidden="true"
439
+ ></span>` : entry.icon ? this.renderIcon(entry.icon) : nothing}
440
+ <span class="label">${entry.label ?? ""}</span>
441
+ ${entry.shortcut ? html`<kbd class="shortcut">${entry.shortcut}</kbd>` : nothing}
442
+ ${hasSub ? html`<span class="chevron" aria-hidden="true"></span>` : nothing}
443
+ </button>
444
+ ${hasSub && this.openSub === key ? html`<ul class="submenu${this.flipEnd ? " left" : ""}" role="menu">
445
+ ${entry.children.map((child, i) => this.renderEntry(child, `${key}.${i}`))}
446
+ </ul>` : nothing}
447
+ </li>`;
448
+ }
449
+ toggleSub(key) {
450
+ this.openSub = this.openSub === key ? null : key;
451
+ }
452
+ onItemKeydown(e, entry, key, hasSub) {
453
+ if (e.key === "Enter" || e.key === " ") {
454
+ e.preventDefault();
455
+ hasSub ? this.toggleSub(key) : this.activate(entry);
456
+ } else if (e.key === "ArrowRight" && hasSub) {
457
+ e.preventDefault();
458
+ this.openSub = key;
459
+ this.updateComplete.then(() => {
460
+ const first = this.renderRoot.querySelector(".submenu .item:not(.disabled)");
461
+ first?.focus();
462
+ });
463
+ } else if (e.key === "ArrowLeft" && key.includes(".")) {
464
+ e.preventDefault();
465
+ this.openSub = null;
466
+ }
467
+ }
468
+ render() {
469
+ const panelClasses = ["panel", this.width];
470
+ if (this.trigger === "context") {
471
+ panelClasses.push("context");
472
+ } else {
473
+ panelClasses.push(this.anchor);
474
+ if (this.flipEnd) panelClasses.push("flip-end");
475
+ if (this.flipAbove) panelClasses.push("flip-above");
476
+ }
477
+ const panelStyle = this.trigger === "context" ? `--ctx-x:${this.ctxX}px;--ctx-y:${this.ctxY}px` : "";
478
+ return html`
479
+ <span class="anchor" @click=${this.onTriggerClick}>
480
+ <slot></slot>
481
+ </span>
482
+ ${this.open ? html`<div
483
+ class=${panelClasses.join(" ")}
484
+ style=${panelStyle}
485
+ role="menu"
486
+ @click=${(e) => e.stopPropagation()}
487
+ >
488
+ <div class="header"><slot name="header"></slot></div>
489
+ <ul>
490
+ ${this.items.map((entry, i) => this.renderEntry(entry, String(i)))}
491
+ </ul>
492
+ </div>` : nothing}
493
+ `;
494
+ }
495
+ }
496
+ __decorateClass([
497
+ property({ attribute: false })
498
+ ], OkMenu.prototype, "items");
499
+ __decorateClass([
500
+ property()
501
+ ], OkMenu.prototype, "trigger");
502
+ __decorateClass([
503
+ property()
504
+ ], OkMenu.prototype, "anchor");
505
+ __decorateClass([
506
+ property()
507
+ ], OkMenu.prototype, "width");
508
+ __decorateClass([
509
+ property({ type: Boolean, reflect: true })
510
+ ], OkMenu.prototype, "open");
511
+ __decorateClass([
512
+ state()
513
+ ], OkMenu.prototype, "flipEnd");
514
+ __decorateClass([
515
+ state()
516
+ ], OkMenu.prototype, "flipAbove");
517
+ __decorateClass([
518
+ state()
519
+ ], OkMenu.prototype, "ctxX");
520
+ __decorateClass([
521
+ state()
522
+ ], OkMenu.prototype, "ctxY");
523
+ __decorateClass([
524
+ state()
525
+ ], OkMenu.prototype, "openSub");
526
+ define("ok-menu", OkMenu);
527
+ export {
528
+ OkMenu
529
+ };