@erplora/outfitkit 0.1.29 → 0.1.31

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.
@@ -0,0 +1 @@
1
+ import './ok-data-table.js';
@@ -231,6 +231,9 @@ export declare class OkDataTable extends LitElement {
231
231
  private filterDraft;
232
232
  private panel;
233
233
  private viewMode;
234
+ private isMobile;
235
+ private mq?;
236
+ private static readonly MOBILE_BREAKPOINT;
234
237
  private hiddenKeys;
235
238
  private internalSelection;
236
239
  private menuOpen;
@@ -95,7 +95,7 @@ const ES_LABELS = {
95
95
  recordSingular: "registro",
96
96
  recordPlural: "registros"
97
97
  };
98
- class OkDataTable extends LitElement {
98
+ const _OkDataTable = class _OkDataTable2 extends LitElement {
99
99
  constructor() {
100
100
  super(...arguments);
101
101
  this.columns = [];
@@ -133,6 +133,7 @@ class OkDataTable extends LitElement {
133
133
  this.filterDraft = {};
134
134
  this.panel = "none";
135
135
  this.viewMode = "table";
136
+ this.isMobile = false;
136
137
  this.hiddenKeys = /* @__PURE__ */ new Set();
137
138
  this.internalSelection = /* @__PURE__ */ new Set();
138
139
  this.menuOpen = false;
@@ -379,16 +380,37 @@ class OkDataTable extends LitElement {
379
380
  ion-button { --box-shadow: none; }
380
381
  `;
381
382
  }
383
+ static {
384
+ this.MOBILE_BREAKPOINT = 640;
385
+ }
382
386
  connectedCallback() {
383
387
  super.connectedCallback();
384
388
  if (typeof window !== "undefined") {
385
389
  window.addEventListener("erplora:locale-changed", this.onLocaleChanged);
386
390
  }
391
+ if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
392
+ this.mq = window.matchMedia(`(max-width: ${_OkDataTable2.MOBILE_BREAKPOINT}px)`);
393
+ this.isMobile = this.mq.matches;
394
+ const handler = (e) => {
395
+ const matches = "matches" in e ? e.matches : this.mq?.matches ?? false;
396
+ if (this.isMobile === matches) return;
397
+ this.isMobile = matches;
398
+ if (matches && this.cardViewEnabled) this.viewMode = "cards";
399
+ else if (!matches && this.viewMode === "cards") this.viewMode = "table";
400
+ };
401
+ this.mq.addEventListener("change", handler);
402
+ this._mqHandler = handler;
403
+ }
387
404
  }
388
405
  disconnectedCallback() {
389
406
  if (typeof window !== "undefined") {
390
407
  window.removeEventListener("erplora:locale-changed", this.onLocaleChanged);
391
408
  }
409
+ if (this.mq) {
410
+ const handler = this._mqHandler;
411
+ if (handler) this.mq.removeEventListener("change", handler);
412
+ this.mq = void 0;
413
+ }
392
414
  super.disconnectedCallback();
393
415
  }
394
416
  // ── i18n: idioma del documento ← overrides explícitos de `.labels` ─────────────────────────
@@ -747,8 +769,13 @@ class OkDataTable extends LitElement {
747
769
  // forma robusta de arrancar en tarjetas sin depender de fijar `viewMode` por referencia (que
748
770
  // falla si la tabla monta detrás de un `v-if`/loading y el ref aún es null).
749
771
  firstUpdated() {
750
- if (this.defaultView === "cards" && this.cardViewEnabled) this.viewMode = "cards";
751
- else if (this.defaultView === "table") this.viewMode = "table";
772
+ if (this.isMobile && this.cardViewEnabled) {
773
+ this.viewMode = "cards";
774
+ } else if (this.defaultView === "cards" && this.cardViewEnabled) {
775
+ this.viewMode = "cards";
776
+ } else if (this.defaultView === "table") {
777
+ this.viewMode = "table";
778
+ }
752
779
  }
753
780
  setViewMode(mode) {
754
781
  if (this.viewMode === mode) return;
@@ -1229,154 +1256,158 @@ class OkDataTable extends LitElement {
1229
1256
  </div>
1230
1257
  `;
1231
1258
  }
1232
- }
1259
+ };
1233
1260
  __decorateClass([
1234
1261
  property({ attribute: false })
1235
- ], OkDataTable.prototype, "columns");
1262
+ ], _OkDataTable.prototype, "columns");
1236
1263
  __decorateClass([
1237
1264
  property({ attribute: false })
1238
- ], OkDataTable.prototype, "rows");
1265
+ ], _OkDataTable.prototype, "rows");
1239
1266
  __decorateClass([
1240
1267
  property({ attribute: false })
1241
- ], OkDataTable.prototype, "searchKeys");
1268
+ ], _OkDataTable.prototype, "searchKeys");
1242
1269
  __decorateClass([
1243
1270
  property({ attribute: "row-key-field" })
1244
- ], OkDataTable.prototype, "rowKeyField");
1271
+ ], _OkDataTable.prototype, "rowKeyField");
1245
1272
  __decorateClass([
1246
1273
  property({ attribute: false })
1247
- ], OkDataTable.prototype, "rowKey");
1274
+ ], _OkDataTable.prototype, "rowKey");
1248
1275
  __decorateClass([
1249
1276
  property({ type: Number, attribute: "page-size" })
1250
- ], OkDataTable.prototype, "pageSize");
1277
+ ], _OkDataTable.prototype, "pageSize");
1251
1278
  __decorateClass([
1252
1279
  property({ attribute: "empty-message" })
1253
- ], OkDataTable.prototype, "emptyMessage");
1280
+ ], _OkDataTable.prototype, "emptyMessage");
1254
1281
  __decorateClass([
1255
1282
  property({ attribute: "search-placeholder" })
1256
- ], OkDataTable.prototype, "searchPlaceholder");
1283
+ ], _OkDataTable.prototype, "searchPlaceholder");
1257
1284
  __decorateClass([
1258
1285
  property({ attribute: false })
1259
- ], OkDataTable.prototype, "labels");
1286
+ ], _OkDataTable.prototype, "labels");
1260
1287
  __decorateClass([
1261
1288
  property({ attribute: false })
1262
- ], OkDataTable.prototype, "actions");
1289
+ ], _OkDataTable.prototype, "actions");
1263
1290
  __decorateClass([
1264
1291
  property({ type: Boolean })
1265
- ], OkDataTable.prototype, "addable");
1292
+ ], _OkDataTable.prototype, "addable");
1266
1293
  __decorateClass([
1267
1294
  property({ attribute: false })
1268
- ], OkDataTable.prototype, "pageSizeOptions");
1295
+ ], _OkDataTable.prototype, "pageSizeOptions");
1269
1296
  __decorateClass([
1270
1297
  property({ type: Boolean, reflect: true })
1271
- ], OkDataTable.prototype, "fill");
1298
+ ], _OkDataTable.prototype, "fill");
1272
1299
  __decorateClass([
1273
1300
  property({ type: Boolean, attribute: "column-picker" })
1274
- ], OkDataTable.prototype, "columnPicker");
1301
+ ], _OkDataTable.prototype, "columnPicker");
1275
1302
  __decorateClass([
1276
1303
  property({ type: Boolean })
1277
- ], OkDataTable.prototype, "csv");
1304
+ ], _OkDataTable.prototype, "csv");
1278
1305
  __decorateClass([
1279
1306
  property({ attribute: "csv-name" })
1280
- ], OkDataTable.prototype, "csvName");
1307
+ ], _OkDataTable.prototype, "csvName");
1281
1308
  __decorateClass([
1282
1309
  property({ type: Boolean, attribute: "server-side" })
1283
- ], OkDataTable.prototype, "serverSide");
1310
+ ], _OkDataTable.prototype, "serverSide");
1284
1311
  __decorateClass([
1285
1312
  property({ type: Number })
1286
- ], OkDataTable.prototype, "total");
1313
+ ], _OkDataTable.prototype, "total");
1287
1314
  __decorateClass([
1288
1315
  property({ type: Number })
1289
- ], OkDataTable.prototype, "page");
1316
+ ], _OkDataTable.prototype, "page");
1290
1317
  __decorateClass([
1291
1318
  property({ type: Boolean })
1292
- ], OkDataTable.prototype, "searchable");
1319
+ ], _OkDataTable.prototype, "searchable");
1293
1320
  __decorateClass([
1294
1321
  property({ type: String })
1295
- ], OkDataTable.prototype, "sort");
1322
+ ], _OkDataTable.prototype, "sort");
1296
1323
  __decorateClass([
1297
1324
  property({ attribute: "sort-dir" })
1298
- ], OkDataTable.prototype, "sortDir");
1325
+ ], _OkDataTable.prototype, "sortDir");
1299
1326
  __decorateClass([
1300
1327
  property()
1301
- ], OkDataTable.prototype, "title");
1328
+ ], _OkDataTable.prototype, "title");
1302
1329
  __decorateClass([
1303
1330
  property({ attribute: false })
1304
- ], OkDataTable.prototype, "views");
1331
+ ], _OkDataTable.prototype, "views");
1305
1332
  __decorateClass([
1306
1333
  property({ attribute: "default-view" })
1307
- ], OkDataTable.prototype, "defaultView");
1334
+ ], _OkDataTable.prototype, "defaultView");
1308
1335
  __decorateClass([
1309
1336
  property({ type: Boolean })
1310
- ], OkDataTable.prototype, "exportable");
1337
+ ], _OkDataTable.prototype, "exportable");
1311
1338
  __decorateClass([
1312
1339
  property({ type: Boolean })
1313
- ], OkDataTable.prototype, "importable");
1340
+ ], _OkDataTable.prototype, "importable");
1314
1341
  __decorateClass([
1315
1342
  property({ type: Boolean, attribute: "column-selector" })
1316
- ], OkDataTable.prototype, "columnSelector");
1343
+ ], _OkDataTable.prototype, "columnSelector");
1317
1344
  __decorateClass([
1318
1345
  property({ attribute: false })
1319
- ], OkDataTable.prototype, "pageSizes");
1346
+ ], _OkDataTable.prototype, "pageSizes");
1320
1347
  __decorateClass([
1321
1348
  property({ type: Boolean })
1322
- ], OkDataTable.prototype, "selectable");
1349
+ ], _OkDataTable.prototype, "selectable");
1323
1350
  __decorateClass([
1324
1351
  property({ attribute: false })
1325
- ], OkDataTable.prototype, "selectedKeys");
1352
+ ], _OkDataTable.prototype, "selectedKeys");
1326
1353
  __decorateClass([
1327
1354
  property({ attribute: false })
1328
- ], OkDataTable.prototype, "primaryAction");
1355
+ ], _OkDataTable.prototype, "primaryAction");
1329
1356
  __decorateClass([
1330
1357
  property({ type: Boolean })
1331
- ], OkDataTable.prototype, "inlineFilters");
1358
+ ], _OkDataTable.prototype, "inlineFilters");
1332
1359
  __decorateClass([
1333
1360
  property({ attribute: false })
1334
- ], OkDataTable.prototype, "menuActions");
1361
+ ], _OkDataTable.prototype, "menuActions");
1335
1362
  __decorateClass([
1336
1363
  property({ attribute: false })
1337
- ], OkDataTable.prototype, "cardTitle");
1364
+ ], _OkDataTable.prototype, "cardTitle");
1338
1365
  __decorateClass([
1339
1366
  property({ attribute: false })
1340
- ], OkDataTable.prototype, "cardIcon");
1367
+ ], _OkDataTable.prototype, "cardIcon");
1341
1368
  __decorateClass([
1342
1369
  property({ attribute: false })
1343
- ], OkDataTable.prototype, "renderCard");
1370
+ ], _OkDataTable.prototype, "renderCard");
1371
+ __decorateClass([
1372
+ state()
1373
+ ], _OkDataTable.prototype, "q");
1344
1374
  __decorateClass([
1345
1375
  state()
1346
- ], OkDataTable.prototype, "q");
1376
+ ], _OkDataTable.prototype, "clientPage");
1347
1377
  __decorateClass([
1348
1378
  state()
1349
- ], OkDataTable.prototype, "clientPage");
1379
+ ], _OkDataTable.prototype, "clientPageSize");
1350
1380
  __decorateClass([
1351
1381
  state()
1352
- ], OkDataTable.prototype, "clientPageSize");
1382
+ ], _OkDataTable.prototype, "clientSort");
1353
1383
  __decorateClass([
1354
1384
  state()
1355
- ], OkDataTable.prototype, "clientSort");
1385
+ ], _OkDataTable.prototype, "clientSortDir");
1356
1386
  __decorateClass([
1357
1387
  state()
1358
- ], OkDataTable.prototype, "clientSortDir");
1388
+ ], _OkDataTable.prototype, "clientFilters");
1359
1389
  __decorateClass([
1360
1390
  state()
1361
- ], OkDataTable.prototype, "clientFilters");
1391
+ ], _OkDataTable.prototype, "filterDraft");
1362
1392
  __decorateClass([
1363
1393
  state()
1364
- ], OkDataTable.prototype, "filterDraft");
1394
+ ], _OkDataTable.prototype, "panel");
1365
1395
  __decorateClass([
1366
1396
  state()
1367
- ], OkDataTable.prototype, "panel");
1397
+ ], _OkDataTable.prototype, "viewMode");
1368
1398
  __decorateClass([
1369
1399
  state()
1370
- ], OkDataTable.prototype, "viewMode");
1400
+ ], _OkDataTable.prototype, "isMobile");
1371
1401
  __decorateClass([
1372
1402
  state()
1373
- ], OkDataTable.prototype, "hiddenKeys");
1403
+ ], _OkDataTable.prototype, "hiddenKeys");
1374
1404
  __decorateClass([
1375
1405
  state()
1376
- ], OkDataTable.prototype, "internalSelection");
1406
+ ], _OkDataTable.prototype, "internalSelection");
1377
1407
  __decorateClass([
1378
1408
  state()
1379
- ], OkDataTable.prototype, "menuOpen");
1409
+ ], _OkDataTable.prototype, "menuOpen");
1410
+ let OkDataTable = _OkDataTable;
1380
1411
  define("ok-data-table", OkDataTable);
1381
1412
  export {
1382
1413
  OkDataTable
@@ -100,6 +100,37 @@ class OkInvoice extends LitElement {
100
100
  .qr-note { font-size: 8px; max-width: 36mm; text-align: center; color: var(--muted); word-break: break-word; }
101
101
  .legal { margin-top: 8mm; padding-top: 3mm; border-top: 1px solid var(--rule); font-size: 9px; color: var(--muted); white-space: pre-line; text-align: center; }
102
102
  .empty { padding: 12mm; text-align: center; color: #999; font-style: italic; }
103
+
104
+ /* ── Papel ──────────────────────────────────────────────────────────────────────────────
105
+ Una factura es un documento fiscal: acaba impresa, y en pantalla y en papel no se
106
+ comporta igual. Lo que hay aquí resuelve lo que rompe al imprimir.
107
+
108
+ NOTA: aquí NO va \`@page\` (tamaño y márgenes del folio). Es una at-rule de DOCUMENTO y
109
+ dentro de un shadow root se IGNORA en silencio; la pone quien monta el documento —en el
110
+ Hub, \`lib/print.ts\` al escribir el iframe aislado. */
111
+ @media print {
112
+ .sheet {
113
+ /* En papel el ancho lo manda \`@page\`; forzar 210mm aquí provoca una segunda página
114
+ en blanco cuando el navegador ya ha restado los márgenes. */
115
+ width: auto;
116
+ max-width: none;
117
+ padding: 0;
118
+ }
119
+ /* Fondos y sombras: en pantalla ayudan a leer, en papel gastan tóner y salen sucios en
120
+ láser monocroma. Se sustituye el relleno del bloque de receptor por un filete. */
121
+ .bill-to {
122
+ background: transparent;
123
+ border: 1px solid var(--rule);
124
+ }
125
+ /* Que las cabeceras de la tabla se repitan en cada folio: una factura larga sin esto deja
126
+ las columnas sin rotular a partir de la página 2. */
127
+ table.lines thead { display: table-header-group; }
128
+ table.lines tbody tr { break-inside: avoid; page-break-inside: avoid; }
129
+ /* Los bloques que se leen como una unidad no se parten a la mitad. */
130
+ .summary, .foot, .legal, .bill-to { break-inside: avoid; page-break-inside: avoid; }
131
+ /* El total y el QR son lo que se comprueba de un vistazo: no deben quedar huérfanos. */
132
+ .summary { break-before: avoid; page-break-before: avoid; }
133
+ }
103
134
  `;
104
135
  }
105
136
  get t() {