@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,288 @@
1
+ import { LitElement, css, html } from "lit";
2
+ import { property, state } 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
+ nameLabel: "Name",
15
+ emailLabel: "Email",
16
+ subjectLabel: "Subject (optional)",
17
+ messageLabel: "Message",
18
+ sending: "Sending…",
19
+ errorNameRequired: "Name is required.",
20
+ errorEmailRequired: "Email is required.",
21
+ errorEmailInvalid: "Enter a valid email.",
22
+ errorMessageRequired: "Message is required.",
23
+ errorSendFailed: "Could not send. Please try again.",
24
+ errorNetwork: "Could not send. Check your connection."
25
+ };
26
+ const _OkContactForm = class _OkContactForm2 extends LitElement {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.submitLabel = "Send";
30
+ this.successMessage = "Thanks! We’ll get back to you soon.";
31
+ this.labels = {};
32
+ this.values = { name: "", email: "", subject: "", message: "" };
33
+ this.errors = {};
34
+ this.sent = false;
35
+ this.sending = false;
36
+ }
37
+ static {
38
+ this.styles = css`
39
+ :host {
40
+ /* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
41
+ --background: var(--ok-surface, var(--ion-card-background, #ffffff));
42
+ --color: var(--ok-text, var(--ion-text-color, #1c1b17));
43
+ --color-muted: var(--ok-muted, rgba(var(--ion-text-color-rgb, 24, 24, 27), 0.55));
44
+ --border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 24, 24, 27), 0.12));
45
+ --primary-color: var(--ok-primary, var(--ion-color-primary, #3880ff));
46
+ --danger-color: var(--ok-danger, var(--ion-color-danger, #c5000f));
47
+ --success-color: var(--ok-success, var(--ion-color-success, #2dd55b));
48
+ --border-radius: var(--ok-radius, var(--ion-border-radius, 8px));
49
+ --max-width: var(--ok-container-max, 640px);
50
+ --padding: var(--ok-spacing, var(--ion-padding, 16px));
51
+ --font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
52
+
53
+ /* El host ocupa el ancho del contenedor; el formulario se centra con un max-width interno. */
54
+ display: block;
55
+ width: 100%;
56
+ color: var(--color);
57
+ font-family: var(--font);
58
+ }
59
+ .wrap {
60
+ box-sizing: border-box;
61
+ max-width: var(--max-width);
62
+ margin-inline: auto;
63
+ background: var(--background);
64
+ padding: var(--padding);
65
+ }
66
+ .heading {
67
+ margin: 0 0 1rem;
68
+ font-size: 1.4rem;
69
+ font-weight: 700;
70
+ }
71
+ /* Grid responsive: 2 columnas en desktop (nombre/email), apilado en móvil. */
72
+ .grid {
73
+ display: grid;
74
+ grid-template-columns: 1fr 1fr;
75
+ gap: 1rem;
76
+ }
77
+ .field {
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 0.25rem;
81
+ }
82
+ /* Mensaje y asunto a ancho completo (ocupan toda la fila del grid). */
83
+ .field.full {
84
+ grid-column: 1 / -1;
85
+ }
86
+ .control {
87
+ --border-color: var(--border-color);
88
+ --border-radius: var(--border-radius);
89
+ }
90
+ .control[data-invalid] {
91
+ --border-color: var(--danger-color);
92
+ --highlight-color-invalid: var(--danger-color);
93
+ }
94
+ .error {
95
+ color: var(--danger-color);
96
+ font-size: 0.8rem;
97
+ min-height: 1em;
98
+ }
99
+ .actions {
100
+ grid-column: 1 / -1;
101
+ display: flex;
102
+ justify-content: flex-end;
103
+ }
104
+ .success {
105
+ color: var(--success-color);
106
+ font-weight: 600;
107
+ padding: 0.5rem 0;
108
+ }
109
+ @media (max-width: 640px) {
110
+ /* Móvil: todo apilado y botón a ancho completo. */
111
+ .grid { grid-template-columns: 1fr; }
112
+ .actions { justify-content: stretch; }
113
+ .actions ion-button { flex: 1; }
114
+ }
115
+ `;
116
+ }
117
+ // Textos efectivos: defaults inglés sobreescritos por los pasados desde fuera.
118
+ get t() {
119
+ return { ...DEFAULT_LABELS, ...this.labels };
120
+ }
121
+ static {
122
+ this.EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
123
+ }
124
+ // Lee el valor del ion-input/ion-textarea y lo guarda en el campo correspondiente.
125
+ onInput(field) {
126
+ return (e) => {
127
+ const value = e.detail?.value ?? "";
128
+ this.values = { ...this.values, [field]: value };
129
+ if (this.errors[field]) {
130
+ const { [field]: _omit, ...rest } = this.errors;
131
+ this.errors = rest;
132
+ }
133
+ };
134
+ }
135
+ // Valida requeridos + patrón email. Devuelve true si todo es válido.
136
+ validate() {
137
+ const errors = {};
138
+ const { name, email, message } = this.values;
139
+ if (!name.trim()) errors.name = this.t.errorNameRequired;
140
+ if (!email.trim()) errors.email = this.t.errorEmailRequired;
141
+ else if (!_OkContactForm2.EMAIL_RE.test(email.trim())) errors.email = this.t.errorEmailInvalid;
142
+ if (!message.trim()) errors.message = this.t.errorMessageRequired;
143
+ this.errors = errors;
144
+ return Object.keys(errors).length === 0;
145
+ }
146
+ async onSubmit(e) {
147
+ e.preventDefault();
148
+ if (this.sending) return;
149
+ if (!this.validate()) return;
150
+ const detail = {
151
+ name: this.values.name.trim(),
152
+ email: this.values.email.trim(),
153
+ subject: this.values.subject.trim(),
154
+ message: this.values.message.trim()
155
+ };
156
+ this.dispatchEvent(
157
+ new CustomEvent("ok-submit", { detail, bubbles: true, composed: true })
158
+ );
159
+ if (!this.action) {
160
+ this.markSent();
161
+ return;
162
+ }
163
+ this.sending = true;
164
+ try {
165
+ const body = new URLSearchParams(detail);
166
+ const res = await fetch(this.action, {
167
+ method: "POST",
168
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
169
+ body
170
+ });
171
+ if (res.ok) this.markSent();
172
+ else this.errors = { ...this.errors, message: this.t.errorSendFailed };
173
+ } catch {
174
+ this.errors = { ...this.errors, message: this.t.errorNetwork };
175
+ } finally {
176
+ this.sending = false;
177
+ }
178
+ }
179
+ // Marca el formulario como enviado y limpia los campos.
180
+ markSent() {
181
+ this.sent = true;
182
+ this.values = { name: "", email: "", subject: "", message: "" };
183
+ this.errors = {};
184
+ }
185
+ render() {
186
+ if (this.sent) {
187
+ return html`<div class="wrap"><div class="success" role="status">${this.successMessage}</div></div>`;
188
+ }
189
+ return html`
190
+ <div class="wrap">
191
+ ${this.heading ? html`<h2 class="heading">${this.heading}</h2>` : null}
192
+ <form class="grid" novalidate @submit=${this.onSubmit}>
193
+ <div class="field">
194
+ <ion-input
195
+ class="control"
196
+ name="name"
197
+ label=${this.t.nameLabel}
198
+ label-placement="stacked"
199
+ fill="outline"
200
+ .value=${this.values.name}
201
+ ?data-invalid=${!!this.errors.name}
202
+ @ionInput=${this.onInput("name")}
203
+ ></ion-input>
204
+ <span class="error">${this.errors.name ?? ""}</span>
205
+ </div>
206
+ <div class="field">
207
+ <ion-input
208
+ class="control"
209
+ name="email"
210
+ type="email"
211
+ inputmode="email"
212
+ label=${this.t.emailLabel}
213
+ label-placement="stacked"
214
+ fill="outline"
215
+ .value=${this.values.email}
216
+ ?data-invalid=${!!this.errors.email}
217
+ @ionInput=${this.onInput("email")}
218
+ ></ion-input>
219
+ <span class="error">${this.errors.email ?? ""}</span>
220
+ </div>
221
+ <div class="field full">
222
+ <ion-input
223
+ class="control"
224
+ name="subject"
225
+ label=${this.t.subjectLabel}
226
+ label-placement="stacked"
227
+ fill="outline"
228
+ .value=${this.values.subject}
229
+ @ionInput=${this.onInput("subject")}
230
+ ></ion-input>
231
+ </div>
232
+ <div class="field full">
233
+ <ion-textarea
234
+ class="control"
235
+ name="message"
236
+ label=${this.t.messageLabel}
237
+ label-placement="stacked"
238
+ fill="outline"
239
+ auto-grow
240
+ rows="5"
241
+ .value=${this.values.message}
242
+ ?data-invalid=${!!this.errors.message}
243
+ @ionInput=${this.onInput("message")}
244
+ ></ion-textarea>
245
+ <span class="error">${this.errors.message ?? ""}</span>
246
+ </div>
247
+ <div class="actions">
248
+ <ion-button type="submit" ?disabled=${this.sending}>
249
+ ${this.sending ? this.t.sending : this.submitLabel}
250
+ </ion-button>
251
+ </div>
252
+ </form>
253
+ </div>
254
+ `;
255
+ }
256
+ };
257
+ __decorateClass([
258
+ property()
259
+ ], _OkContactForm.prototype, "heading");
260
+ __decorateClass([
261
+ property({ attribute: "submit-label" })
262
+ ], _OkContactForm.prototype, "submitLabel");
263
+ __decorateClass([
264
+ property()
265
+ ], _OkContactForm.prototype, "action");
266
+ __decorateClass([
267
+ property({ attribute: "success-message" })
268
+ ], _OkContactForm.prototype, "successMessage");
269
+ __decorateClass([
270
+ property({ attribute: false })
271
+ ], _OkContactForm.prototype, "labels");
272
+ __decorateClass([
273
+ state()
274
+ ], _OkContactForm.prototype, "values");
275
+ __decorateClass([
276
+ state()
277
+ ], _OkContactForm.prototype, "errors");
278
+ __decorateClass([
279
+ state()
280
+ ], _OkContactForm.prototype, "sent");
281
+ __decorateClass([
282
+ state()
283
+ ], _OkContactForm.prototype, "sending");
284
+ let OkContactForm = _OkContactForm;
285
+ define("ok-contact-form", OkContactForm);
286
+ export {
287
+ OkContactForm
288
+ };
@@ -0,0 +1,404 @@
1
+ import { LitElement, css, html } from "lit";
2
+ import { property, state } 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 ASPECTS = [
14
+ { key: "free", label: "Libre", ratio: null },
15
+ { key: "1:1", label: "1:1", ratio: 1 },
16
+ { key: "4:3", label: "4:3", ratio: 4 / 3 },
17
+ { key: "16:9", label: "16:9", ratio: 16 / 9 }
18
+ ];
19
+ const MIN_PCT = 8;
20
+ class OkCropper extends LitElement {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.aspect = "free";
24
+ this.cancelLabel = "Cancelar";
25
+ this.cropLabel = "Recortar";
26
+ this.rect = { x: 14, y: 18, width: 72, height: 64 };
27
+ this.dragMode = null;
28
+ this.startX = 0;
29
+ this.startY = 0;
30
+ this.startRect = { x: 0, y: 0, width: 0, height: 0 };
31
+ this.vpRect = null;
32
+ this.activePointer = null;
33
+ this.onPointerMove = (ev) => {
34
+ if (!this.dragMode || !this.vpRect) return;
35
+ if (this.activePointer != null && ev.pointerId !== this.activePointer) return;
36
+ const dxPct = (ev.clientX - this.startX) / this.vpRect.width * 100;
37
+ const dyPct = (ev.clientY - this.startY) / this.vpRect.height * 100;
38
+ const s = this.startRect;
39
+ if (this.dragMode === "move") {
40
+ this.rect = this.clampRect({ ...s, x: s.x + dxPct, y: s.y + dyPct });
41
+ return;
42
+ }
43
+ this.rect = this.resize(s, dxPct, dyPct, this.dragMode);
44
+ };
45
+ this.onPointerUp = (ev) => {
46
+ if (this.activePointer != null && ev.pointerId !== this.activePointer) return;
47
+ this.dragMode = null;
48
+ this.activePointer = null;
49
+ this.vpRect = null;
50
+ window.removeEventListener("pointermove", this.onPointerMove);
51
+ window.removeEventListener("pointerup", this.onPointerUp);
52
+ window.removeEventListener("pointercancel", this.onPointerUp);
53
+ };
54
+ }
55
+ static {
56
+ this.styles = css`
57
+ :host {
58
+ display: block;
59
+ width: 100%;
60
+ box-sizing: border-box;
61
+ /* Tokens propios estilo Ionic (overridables): --ok-* → --ion-* → hex. */
62
+ --bg: var(--ok-surface, var(--ion-background-color, #f7f7f9));
63
+ --border-color: var(--ok-border-color, var(--ion-border-color, #e0e0e6));
64
+ --radius: var(--ok-radius, 16px);
65
+ --radius-viewport: var(--ok-radius-md, 10px);
66
+ --check-a: var(--ok-checker-a, var(--ion-color-light, #ececed));
67
+ --check-b: var(--ok-checker-b, var(--ion-color-light-shade, #d7d8da));
68
+ --overlay: var(--ok-cropper-overlay, rgba(0, 0, 0, 0.55));
69
+ --crop-border: var(--ok-cropper-frame, #ffffff);
70
+ --guide: var(--ok-cropper-guide, rgba(255, 255, 255, 0.45));
71
+ }
72
+
73
+ .cropper {
74
+ background: var(--bg);
75
+ border: 1px solid var(--border-color);
76
+ border-radius: var(--radius);
77
+ padding: 16px;
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 12px;
81
+ box-sizing: border-box;
82
+ }
83
+
84
+ .viewport {
85
+ position: relative;
86
+ aspect-ratio: 4 / 3;
87
+ width: 100%;
88
+ /* Checkerboard de transparencia (conic) + overlay oscuro encima via ::before. */
89
+ background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 0 0 /
90
+ 16px 16px;
91
+ border-radius: var(--radius-viewport);
92
+ overflow: hidden;
93
+ touch-action: none;
94
+ user-select: none;
95
+ }
96
+
97
+ .viewport__img {
98
+ position: absolute;
99
+ inset: 0;
100
+ width: 100%;
101
+ height: 100%;
102
+ object-fit: contain;
103
+ display: block;
104
+ pointer-events: none;
105
+ }
106
+
107
+ /* Atenuado base del viewport (la zona fuera del crop se oscurece extra con el box-shadow). */
108
+ .viewport::before {
109
+ content: '';
110
+ position: absolute;
111
+ inset: 0;
112
+ background: var(--overlay);
113
+ pointer-events: none;
114
+ }
115
+
116
+ .crop {
117
+ position: absolute;
118
+ border: 2px solid var(--crop-border);
119
+ background: transparent;
120
+ /* Atenua todo lo de FUERA del recorte con una sombra gigantesca. */
121
+ box-shadow: 0 0 0 9999px var(--overlay);
122
+ cursor: move;
123
+ box-sizing: border-box;
124
+ }
125
+
126
+ /* Guías rule-of-thirds (dashed): línea central horizontal y vertical. */
127
+ .crop::before,
128
+ .crop::after {
129
+ content: '';
130
+ position: absolute;
131
+ inset: 0;
132
+ border: 1px dashed var(--guide);
133
+ pointer-events: none;
134
+ }
135
+ .crop::before {
136
+ border-left: none;
137
+ border-right: none;
138
+ top: 33.33%;
139
+ height: 33.34%;
140
+ }
141
+ .crop::after {
142
+ border-top: none;
143
+ border-bottom: none;
144
+ left: 33.33%;
145
+ width: 33.34%;
146
+ }
147
+
148
+ .handle {
149
+ position: absolute;
150
+ width: 8px;
151
+ height: 8px;
152
+ background: var(--crop-border);
153
+ border-radius: 1px;
154
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
155
+ }
156
+ .handle.tl {
157
+ top: -5px;
158
+ left: -5px;
159
+ cursor: nwse-resize;
160
+ }
161
+ .handle.tr {
162
+ top: -5px;
163
+ right: -5px;
164
+ cursor: nesw-resize;
165
+ }
166
+ .handle.bl {
167
+ bottom: -5px;
168
+ left: -5px;
169
+ cursor: nesw-resize;
170
+ }
171
+ .handle.br {
172
+ bottom: -5px;
173
+ right: -5px;
174
+ cursor: nwse-resize;
175
+ }
176
+
177
+ .toolbar {
178
+ display: flex;
179
+ gap: 8px;
180
+ flex-wrap: wrap;
181
+ align-items: center;
182
+ padding-top: 10px;
183
+ border-top: 1px solid var(--border-color);
184
+ }
185
+ .spacer {
186
+ flex: 1;
187
+ }
188
+
189
+ ion-button {
190
+ --padding-start: 12px;
191
+ --padding-end: 12px;
192
+ }
193
+ `;
194
+ }
195
+ willUpdate(changed) {
196
+ if (changed.has("value") && this.value) {
197
+ this.rect = this.clampRect(this.value);
198
+ }
199
+ if (changed.has("aspect") && !changed.has("value")) {
200
+ this.rect = this.applyAspect(this.rect);
201
+ }
202
+ }
203
+ // --- Geometría -----------------------------------------------------------
204
+ /** Limita un rect a los bordes [0..100] del viewport. */
205
+ clampRect(r) {
206
+ const width = Math.max(MIN_PCT, Math.min(100, r.width));
207
+ const height = Math.max(MIN_PCT, Math.min(100, r.height));
208
+ const x = Math.max(0, Math.min(100 - width, r.x));
209
+ const y = Math.max(0, Math.min(100 - height, r.y));
210
+ return { x, y, width, height };
211
+ }
212
+ /** Aspect ratio del viewport en px (para convertir proporciones de imagen ↔ % de viewport). */
213
+ vpAspect() {
214
+ const r = this.vpRect ?? this.renderRoot.querySelector(".viewport")?.getBoundingClientRect();
215
+ if (r && r.height > 0) return r.width / r.height;
216
+ return 4 / 3;
217
+ }
218
+ /** Re-encaja un rect para cumplir el aspect ratio activo (anclado en su esquina top-left). */
219
+ applyAspect(r) {
220
+ const def = ASPECTS.find((a) => a.key === this.aspect);
221
+ if (!def || def.ratio == null) return this.clampRect(r);
222
+ const va = this.vpAspect();
223
+ let width = r.width;
224
+ let height = width * va / def.ratio;
225
+ if (height > 100) {
226
+ height = 100;
227
+ width = height * def.ratio / va;
228
+ }
229
+ const x = Math.max(0, Math.min(100 - width, r.x));
230
+ const y = Math.max(0, Math.min(100 - height, r.y));
231
+ return { x, y, width, height };
232
+ }
233
+ // --- Pointer drag / resize ----------------------------------------------
234
+ onPointerDown(mode, ev) {
235
+ ev.preventDefault();
236
+ ev.stopPropagation();
237
+ const vp = this.renderRoot.querySelector(".viewport");
238
+ if (!vp) return;
239
+ this.vpRect = vp.getBoundingClientRect();
240
+ this.dragMode = mode;
241
+ this.startX = ev.clientX;
242
+ this.startY = ev.clientY;
243
+ this.startRect = { ...this.rect };
244
+ this.activePointer = ev.pointerId;
245
+ ev.currentTarget.setPointerCapture?.(ev.pointerId);
246
+ window.addEventListener("pointermove", this.onPointerMove);
247
+ window.addEventListener("pointerup", this.onPointerUp);
248
+ window.addEventListener("pointercancel", this.onPointerUp);
249
+ }
250
+ /** Redimensiona desde una esquina, respetando mínimo, bordes y aspect ratio. */
251
+ resize(s, dx, dy, mode) {
252
+ let { x, y, width, height } = s;
253
+ const right = s.x + s.width;
254
+ const bottom = s.y + s.height;
255
+ if (mode === "tl") {
256
+ x = Math.min(s.x + dx, right - MIN_PCT);
257
+ y = Math.min(s.y + dy, bottom - MIN_PCT);
258
+ x = Math.max(0, x);
259
+ y = Math.max(0, y);
260
+ width = right - x;
261
+ height = bottom - y;
262
+ } else if (mode === "tr") {
263
+ y = Math.min(s.y + dy, bottom - MIN_PCT);
264
+ y = Math.max(0, y);
265
+ width = Math.max(MIN_PCT, Math.min(100 - s.x, s.width + dx));
266
+ height = bottom - y;
267
+ } else if (mode === "bl") {
268
+ x = Math.min(s.x + dx, right - MIN_PCT);
269
+ x = Math.max(0, x);
270
+ width = right - x;
271
+ height = Math.max(MIN_PCT, Math.min(100 - s.y, s.height + dy));
272
+ } else {
273
+ width = Math.max(MIN_PCT, Math.min(100 - s.x, s.width + dx));
274
+ height = Math.max(MIN_PCT, Math.min(100 - s.y, s.height + dy));
275
+ }
276
+ let next = { x, y, width, height };
277
+ const def = ASPECTS.find((a) => a.key === this.aspect);
278
+ if (def && def.ratio != null) {
279
+ const va = this.vpAspect();
280
+ const newHeight = next.width * va / def.ratio;
281
+ const fixTop = mode === "tl" || mode === "tr";
282
+ const fixRight = mode === "tr" || mode === "br";
283
+ let nx = fixRight ? right - next.width : x;
284
+ let ny = fixTop ? bottom - newHeight : y;
285
+ let nh = newHeight;
286
+ let nw = next.width;
287
+ if (ny < 0 || ny + nh > 100) {
288
+ nh = Math.min(fixTop ? bottom : 100 - ny, 100);
289
+ nw = nh * def.ratio / va;
290
+ nx = fixRight ? right - nw : x;
291
+ ny = fixTop ? bottom - nh : y;
292
+ }
293
+ next = { x: nx, y: ny, width: nw, height: nh };
294
+ }
295
+ return this.clampRect(next);
296
+ }
297
+ disconnectedCallback() {
298
+ super.disconnectedCallback();
299
+ window.removeEventListener("pointermove", this.onPointerMove);
300
+ window.removeEventListener("pointerup", this.onPointerUp);
301
+ window.removeEventListener("pointercancel", this.onPointerUp);
302
+ }
303
+ // --- Acciones ------------------------------------------------------------
304
+ setAspect(a) {
305
+ this.aspect = a;
306
+ this.rect = this.applyAspect(this.rect);
307
+ }
308
+ emitCrop() {
309
+ this.dispatchEvent(
310
+ new CustomEvent("ok-crop", {
311
+ detail: { rect: { ...this.rect } },
312
+ bubbles: true,
313
+ composed: true
314
+ })
315
+ );
316
+ }
317
+ emitCancel() {
318
+ this.dispatchEvent(new CustomEvent("ok-cancel", { bubbles: true, composed: true }));
319
+ }
320
+ render() {
321
+ const r = this.rect;
322
+ const cropStyle = `top:${r.y}%;left:${r.x}%;width:${r.width}%;height:${r.height}%`;
323
+ return html`
324
+ <div class="cropper" part="cropper">
325
+ <div class="viewport" part="viewport">
326
+ ${this.src ? html`<img class="viewport__img" src=${this.src} alt="" draggable="false" />` : null}
327
+ <div
328
+ class="crop"
329
+ part="crop"
330
+ style=${cropStyle}
331
+ role="group"
332
+ aria-label="Área de recorte"
333
+ @pointerdown=${(e) => this.onPointerDown("move", e)}
334
+ >
335
+ <span
336
+ class="handle tl"
337
+ part="handle"
338
+ @pointerdown=${(e) => this.onPointerDown("tl", e)}
339
+ ></span>
340
+ <span
341
+ class="handle tr"
342
+ part="handle"
343
+ @pointerdown=${(e) => this.onPointerDown("tr", e)}
344
+ ></span>
345
+ <span
346
+ class="handle bl"
347
+ part="handle"
348
+ @pointerdown=${(e) => this.onPointerDown("bl", e)}
349
+ ></span>
350
+ <span
351
+ class="handle br"
352
+ part="handle"
353
+ @pointerdown=${(e) => this.onPointerDown("br", e)}
354
+ ></span>
355
+ </div>
356
+ </div>
357
+
358
+ <div class="toolbar" part="toolbar" role="toolbar" aria-label="Opciones de recorte">
359
+ ${ASPECTS.map(
360
+ (a) => html`
361
+ <ion-button
362
+ size="small"
363
+ fill=${this.aspect === a.key ? "solid" : "clear"}
364
+ aria-pressed=${this.aspect === a.key ? "true" : "false"}
365
+ @click=${() => this.setAspect(a.key)}
366
+ >
367
+ ${a.label}
368
+ </ion-button>
369
+ `
370
+ )}
371
+ <span class="spacer"></span>
372
+ <ion-button size="small" fill="clear" color="medium" @click=${() => this.emitCancel()}>
373
+ ${this.cancelLabel}
374
+ </ion-button>
375
+ <ion-button size="small" fill="solid" @click=${() => this.emitCrop()}>
376
+ ${this.cropLabel}
377
+ </ion-button>
378
+ </div>
379
+ </div>
380
+ `;
381
+ }
382
+ }
383
+ __decorateClass([
384
+ property()
385
+ ], OkCropper.prototype, "src");
386
+ __decorateClass([
387
+ property()
388
+ ], OkCropper.prototype, "aspect");
389
+ __decorateClass([
390
+ property({ attribute: false })
391
+ ], OkCropper.prototype, "value");
392
+ __decorateClass([
393
+ property({ attribute: "cancel-label" })
394
+ ], OkCropper.prototype, "cancelLabel");
395
+ __decorateClass([
396
+ property({ attribute: "crop-label" })
397
+ ], OkCropper.prototype, "cropLabel");
398
+ __decorateClass([
399
+ state()
400
+ ], OkCropper.prototype, "rect");
401
+ define("ok-cropper", OkCropper);
402
+ export {
403
+ OkCropper
404
+ };