@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,448 @@
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 DEFAULT_LABELS = {
14
+ searchPlaceholder: "Search command…",
15
+ dialogLabel: "Command palette",
16
+ escHint: "Esc",
17
+ noMatches: "No matches"
18
+ };
19
+ class OkCommandPalette extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.commands = [];
23
+ this.open = false;
24
+ this.placeholder = "";
25
+ this.hotkey = true;
26
+ this.labels = {};
27
+ this.queryText = "";
28
+ this.activeIndex = 0;
29
+ this.onGlobalKey = (e) => {
30
+ if ((e.metaKey || e.ctrlKey) && (e.key === "k" || e.key === "K")) {
31
+ e.preventDefault();
32
+ this.toggle();
33
+ }
34
+ };
35
+ }
36
+ static {
37
+ this.styles = css`
38
+ :host {
39
+ /* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
40
+ --color: var(--ok-text, var(--ion-text-color, #1c1b17));
41
+ --color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.6));
42
+ --primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
43
+ --primary-contrast: var(--ok-primary-contrast, var(--ion-color-primary-contrast, #ffffff));
44
+ --hover-bg: var(--ok-hover, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.06));
45
+ --active-bg: var(--ok-active, rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.14));
46
+ --panel-bg: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #ffffff)));
47
+ --scrim-bg: var(--ok-scrim, rgba(0, 0, 0, 0.4));
48
+ --border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.12));
49
+ --border-soft: var(--ok-border-soft, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.08));
50
+ --border-radius: var(--ok-radius, 14px);
51
+ --shadow: var(--ok-shadow, 0 18px 60px rgba(0, 0, 0, 0.28));
52
+ --font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
53
+
54
+ /* El host no ocupa caja: el overlay se posiciona fijo sobre todo. */
55
+ display: contents;
56
+ }
57
+
58
+ /* Scrim a pantalla completa (cierra al click fuera del panel). */
59
+ .scrim {
60
+ position: fixed;
61
+ inset: 0;
62
+ z-index: 2000;
63
+ display: flex;
64
+ align-items: flex-start;
65
+ justify-content: center;
66
+ padding: 12vh 16px 16px;
67
+ box-sizing: border-box;
68
+ background: var(--scrim-bg);
69
+ font-family: var(--font);
70
+ color: var(--color);
71
+ }
72
+
73
+ /* Panel centrado-arriba: ancho web estrechado (max 560px), responsive. */
74
+ .panel {
75
+ width: 100%;
76
+ max-width: 560px;
77
+ max-height: 70vh;
78
+ display: flex;
79
+ flex-direction: column;
80
+ overflow: hidden;
81
+ background: var(--panel-bg);
82
+ border: 1px solid var(--border-color);
83
+ border-radius: var(--border-radius);
84
+ box-shadow: var(--shadow);
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ /* Fila del input de búsqueda. */
89
+ .search {
90
+ display: flex;
91
+ align-items: center;
92
+ gap: 0.6rem;
93
+ padding: 0.85rem 1rem;
94
+ border-bottom: 1px solid var(--border-soft);
95
+ flex: 0 0 auto;
96
+ }
97
+ .search ion-icon {
98
+ flex: 0 0 auto;
99
+ font-size: 1.2rem;
100
+ color: var(--color-muted);
101
+ }
102
+ .search input {
103
+ flex: 1 1 auto;
104
+ min-width: 0;
105
+ border: 0;
106
+ outline: none;
107
+ background: none;
108
+ color: inherit;
109
+ font: inherit;
110
+ font-size: 1rem;
111
+ }
112
+ .search input::placeholder {
113
+ color: var(--color-muted);
114
+ }
115
+ /* Pista visual del atajo para cerrar. */
116
+ .esc {
117
+ flex: 0 0 auto;
118
+ padding: 0.1rem 0.4rem;
119
+ font-size: 0.72rem;
120
+ color: var(--color-muted);
121
+ border: 1px solid var(--border-color);
122
+ border-radius: 6px;
123
+ }
124
+
125
+ /* Lista de resultados (scrollable). */
126
+ .results {
127
+ flex: 1 1 auto;
128
+ overflow-y: auto;
129
+ padding: 0.35rem 0;
130
+ margin: 0;
131
+ list-style: none;
132
+ }
133
+ /* Cabecera de grupo. */
134
+ .group {
135
+ padding: 0.5rem 1rem 0.25rem;
136
+ font-size: 0.7rem;
137
+ font-weight: 600;
138
+ letter-spacing: 0.04em;
139
+ text-transform: uppercase;
140
+ color: var(--color-muted);
141
+ }
142
+ /* Item de comando. */
143
+ .item {
144
+ display: flex;
145
+ align-items: center;
146
+ gap: 0.7rem;
147
+ width: 100%;
148
+ box-sizing: border-box;
149
+ padding: 0.55rem 1rem;
150
+ cursor: pointer;
151
+ user-select: none;
152
+ transition: background-color var(--ok-transition, 150ms ease), color var(--ok-transition, 150ms ease),
153
+ border-color var(--ok-transition, 150ms ease), box-shadow var(--ok-transition, 150ms ease),
154
+ transform 120ms ease;
155
+ }
156
+ .item.active {
157
+ background: var(--active-bg);
158
+ }
159
+ @media (hover: hover) {
160
+ .item:hover {
161
+ background: var(--hover-bg);
162
+ }
163
+ .item.active:hover {
164
+ background: var(--active-bg);
165
+ }
166
+ }
167
+ .item:active {
168
+ transform: scale(var(--ok-press-scale, 0.97));
169
+ }
170
+ @media (prefers-reduced-motion: reduce) {
171
+ .item:hover,
172
+ .item:active {
173
+ transform: none;
174
+ }
175
+ }
176
+ .item .icon {
177
+ flex: 0 0 auto;
178
+ display: inline-flex;
179
+ align-items: center;
180
+ justify-content: center;
181
+ width: 22px;
182
+ font-size: 1.15rem;
183
+ color: var(--color-muted);
184
+ }
185
+ .item.active .icon {
186
+ color: var(--primary-color);
187
+ }
188
+ .item .body {
189
+ flex: 1 1 auto;
190
+ min-width: 0;
191
+ display: flex;
192
+ align-items: baseline;
193
+ gap: 0.5rem;
194
+ }
195
+ .item .label {
196
+ flex: 0 1 auto;
197
+ overflow: hidden;
198
+ text-overflow: ellipsis;
199
+ white-space: nowrap;
200
+ }
201
+ .item .hint {
202
+ flex: 1 1 auto;
203
+ min-width: 0;
204
+ overflow: hidden;
205
+ text-overflow: ellipsis;
206
+ white-space: nowrap;
207
+ font-size: 0.82rem;
208
+ color: var(--color-muted);
209
+ }
210
+ /* Atajo del comando, alineado a la derecha. */
211
+ .item .shortcut {
212
+ flex: 0 0 auto;
213
+ padding: 0.1rem 0.4rem;
214
+ font-size: 0.72rem;
215
+ color: var(--color-muted);
216
+ border: 1px solid var(--border-color);
217
+ border-radius: 6px;
218
+ white-space: nowrap;
219
+ }
220
+
221
+ /* Estado vacío (sin coincidencias). */
222
+ .empty {
223
+ padding: 1.5rem 1rem;
224
+ text-align: center;
225
+ font-size: 0.9rem;
226
+ color: var(--color-muted);
227
+ }
228
+
229
+ /* En móvil el overlay es casi pantalla completa. */
230
+ @media (max-width: 560px) {
231
+ .scrim {
232
+ padding: 0;
233
+ align-items: stretch;
234
+ }
235
+ .panel {
236
+ max-width: none;
237
+ max-height: none;
238
+ height: 100%;
239
+ border: 0;
240
+ border-radius: 0;
241
+ }
242
+ }
243
+ `;
244
+ }
245
+ /** Textos efectivos (defaults inglés + overrides). */
246
+ get t() {
247
+ return { ...DEFAULT_LABELS, ...this.labels };
248
+ }
249
+ /** Placeholder efectivo: prop explícita o el de labels. */
250
+ get effectivePlaceholder() {
251
+ return this.placeholder || this.t.searchPlaceholder;
252
+ }
253
+ connectedCallback() {
254
+ super.connectedCallback();
255
+ if (this.hotkey) document.addEventListener("keydown", this.onGlobalKey);
256
+ }
257
+ disconnectedCallback() {
258
+ super.disconnectedCallback();
259
+ document.removeEventListener("keydown", this.onGlobalKey);
260
+ }
261
+ // ── API pública ──────────────────────────────────────────────────────────
262
+ /** Abre la paleta (resetea búsqueda y resaltado, enfoca el input). */
263
+ openPalette() {
264
+ if (this.open) return;
265
+ this.open = true;
266
+ this.queryText = "";
267
+ this.activeIndex = 0;
268
+ this.emitOpen(true);
269
+ this.updateComplete.then(() => this.searchInput?.focus());
270
+ }
271
+ /** Cierra la paleta. */
272
+ close() {
273
+ if (!this.open) return;
274
+ this.open = false;
275
+ this.emitOpen(false);
276
+ }
277
+ /** Alterna abierto/cerrado. */
278
+ toggle() {
279
+ this.open ? this.close() : this.openPalette();
280
+ }
281
+ emitOpen(open) {
282
+ this.dispatchEvent(
283
+ new CustomEvent("ok-open", { detail: { open }, bubbles: true, composed: true })
284
+ );
285
+ }
286
+ // ── Filtrado / agrupado ─────────────────────────────────────────────────
287
+ // Decide si un comando casa con el texto de búsqueda (substring sobre label + keywords).
288
+ // (No se llama `matches` para no chocar con `Element.matches` en el tipo del custom element.)
289
+ commandMatches(cmd, q) {
290
+ if (!q) return true;
291
+ const hay = [cmd.label, cmd.hint ?? "", ...cmd.keywords ?? []].join(" ").toLowerCase();
292
+ return hay.includes(q);
293
+ }
294
+ // Devuelve la lista filtrada y plana (en orden), conservando el orden de entrada.
295
+ filtered() {
296
+ const q = this.queryText.trim().toLowerCase();
297
+ return this.commands.filter((c) => this.commandMatches(c, q));
298
+ }
299
+ // Agrupa la lista filtrada por `group` preservando el orden de aparición de cada grupo.
300
+ grouped(list) {
301
+ const order = [];
302
+ const byGroup = /* @__PURE__ */ new Map();
303
+ for (const cmd of list) {
304
+ const g = cmd.group ?? "";
305
+ if (!byGroup.has(g)) {
306
+ byGroup.set(g, []);
307
+ order.push(g);
308
+ }
309
+ byGroup.get(g).push(cmd);
310
+ }
311
+ return order.map((g) => ({ group: g, items: byGroup.get(g) }));
312
+ }
313
+ // ── Interacción ──────────────────────────────────────────────────────────
314
+ onInput(e) {
315
+ this.queryText = e.target.value;
316
+ this.activeIndex = 0;
317
+ }
318
+ // Teclado dentro del panel: flechas mueven el resaltado, Enter ejecuta, Esc cierra.
319
+ onPanelKey(e) {
320
+ const flat = this.filtered();
321
+ if (e.key === "Escape") {
322
+ e.preventDefault();
323
+ this.close();
324
+ return;
325
+ }
326
+ if (e.key === "ArrowDown") {
327
+ e.preventDefault();
328
+ if (flat.length) this.activeIndex = (this.activeIndex + 1) % flat.length;
329
+ return;
330
+ }
331
+ if (e.key === "ArrowUp") {
332
+ e.preventDefault();
333
+ if (flat.length) this.activeIndex = (this.activeIndex - 1 + flat.length) % flat.length;
334
+ return;
335
+ }
336
+ if (e.key === "Enter") {
337
+ e.preventDefault();
338
+ const cmd = flat[this.activeIndex];
339
+ if (cmd) this.execute(cmd);
340
+ }
341
+ }
342
+ // Ejecuta un comando: emite `ok-select` y cierra la paleta.
343
+ execute(cmd) {
344
+ this.dispatchEvent(
345
+ new CustomEvent("ok-select", {
346
+ detail: { id: cmd.id, command: cmd },
347
+ bubbles: true,
348
+ composed: true
349
+ })
350
+ );
351
+ this.close();
352
+ }
353
+ // Cierra al click en el scrim (fuera del panel).
354
+ onScrimClick(e) {
355
+ if (e.target === e.currentTarget) this.close();
356
+ }
357
+ // ── Render ────────────────────────────────────────────────────────────────
358
+ renderItem(cmd, flatIndex) {
359
+ const active = flatIndex === this.activeIndex;
360
+ return html`<li
361
+ class=${active ? "item active" : "item"}
362
+ role="option"
363
+ aria-selected=${active ? "true" : "false"}
364
+ @click=${() => this.execute(cmd)}
365
+ @mousemove=${() => {
366
+ if (this.activeIndex !== flatIndex) this.activeIndex = flatIndex;
367
+ }}
368
+ >
369
+ <span class="icon">
370
+ ${cmd.icon ? html`<ion-icon .name=${cmd.icon}></ion-icon>` : ""}
371
+ </span>
372
+ <span class="body">
373
+ <span class="label">${cmd.label}</span>
374
+ ${cmd.hint ? html`<span class="hint">${cmd.hint}</span>` : ""}
375
+ </span>
376
+ ${cmd.shortcut ? html`<span class="shortcut">${cmd.shortcut}</span>` : ""}
377
+ </li>`;
378
+ }
379
+ render() {
380
+ if (!this.open) return html``;
381
+ const flat = this.filtered();
382
+ const groups = this.grouped(flat);
383
+ let flatIndex = -1;
384
+ return html`<div
385
+ class="scrim"
386
+ role="dialog"
387
+ aria-modal="true"
388
+ aria-label=${this.t.dialogLabel}
389
+ @click=${(e) => this.onScrimClick(e)}
390
+ @keydown=${(e) => this.onPanelKey(e)}
391
+ >
392
+ <div class="panel">
393
+ <div class="search">
394
+ <ion-icon name="search-outline"></ion-icon>
395
+ <input
396
+ type="text"
397
+ .value=${this.queryText}
398
+ placeholder=${this.effectivePlaceholder}
399
+ aria-label=${this.effectivePlaceholder}
400
+ autocomplete="off"
401
+ spellcheck="false"
402
+ @input=${(e) => this.onInput(e)}
403
+ />
404
+ <span class="esc">${this.t.escHint}</span>
405
+ </div>
406
+ ${flat.length ? html`<ul class="results" role="listbox">
407
+ ${groups.map(
408
+ (g) => html`
409
+ ${g.group ? html`<li class="group" role="presentation">${g.group}</li>` : ""}
410
+ ${g.items.map((cmd) => {
411
+ flatIndex += 1;
412
+ return this.renderItem(cmd, flatIndex);
413
+ })}
414
+ `
415
+ )}
416
+ </ul>` : html`<div class="empty">${this.t.noMatches}</div>`}
417
+ </div>
418
+ </div>`;
419
+ }
420
+ }
421
+ __decorateClass([
422
+ property({ attribute: false })
423
+ ], OkCommandPalette.prototype, "commands");
424
+ __decorateClass([
425
+ property({ type: Boolean, reflect: true })
426
+ ], OkCommandPalette.prototype, "open");
427
+ __decorateClass([
428
+ property()
429
+ ], OkCommandPalette.prototype, "placeholder");
430
+ __decorateClass([
431
+ property({ type: Boolean })
432
+ ], OkCommandPalette.prototype, "hotkey");
433
+ __decorateClass([
434
+ property({ attribute: false })
435
+ ], OkCommandPalette.prototype, "labels");
436
+ __decorateClass([
437
+ state()
438
+ ], OkCommandPalette.prototype, "queryText");
439
+ __decorateClass([
440
+ state()
441
+ ], OkCommandPalette.prototype, "activeIndex");
442
+ __decorateClass([
443
+ query(".search input")
444
+ ], OkCommandPalette.prototype, "searchInput");
445
+ define("ok-command-palette", OkCommandPalette);
446
+ export {
447
+ OkCommandPalette
448
+ };