@honed/table 0.13.0 → 0.14.0

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.
package/dist/index.d.ts CHANGED
@@ -84,6 +84,14 @@ export declare interface HonedTable<T extends Record<string, any> = Record<strin
84
84
  executeInline: (operation: InlineOperation, data: TableEntry<T>, options?: VisitOptions) => void;
85
85
  executeBulk: (operation: BulkOperation, options?: VisitOptions) => void;
86
86
  executePage: (operation: PageOperation, data?: PageOperationData, options?: VisitOptions) => void;
87
+ getBulkData: () => {
88
+ all: boolean;
89
+ only: Identifier[];
90
+ except: Identifier[];
91
+ };
92
+ getRecordData: (record: TableEntry<T>) => {
93
+ id: Identifier;
94
+ };
87
95
  applyPage: (page: PageOption, options?: VisitOptions) => void;
88
96
  selection: BulkSelection<Identifier>;
89
97
  select: (record: TableEntry<T>) => void;
package/dist/index.es.js CHANGED
@@ -100,7 +100,7 @@ function le(a, m = {}) {
100
100
  });
101
101
  };
102
102
  }
103
- function K(a, m = 200, c = {}) {
103
+ function q(a, m = 200, c = {}) {
104
104
  return ne(
105
105
  le(m, c),
106
106
  a
@@ -116,7 +116,7 @@ function ae(a, m, c = {}) {
116
116
  ...n,
117
117
  apply: (o, e = {}) => A(n, o, e),
118
118
  clear: (o = {}) => $(n, o),
119
- bind: () => C(n.name)
119
+ bind: () => O(n.name)
120
120
  }));
121
121
  }
122
122
  ), x = v(
@@ -125,8 +125,8 @@ function ae(a, m, c = {}) {
125
125
  return (t = i.value.sorts) == null ? void 0 : t.map((n) => ({
126
126
  ...n,
127
127
  apply: (o = {}) => g(n, n.direction, o),
128
- clear: (o = {}) => D(o),
129
- bind: () => O(n)
128
+ clear: (o = {}) => U(o),
129
+ bind: () => W(n)
130
130
  }));
131
131
  }
132
132
  ), k = v(
@@ -136,7 +136,7 @@ function ae(a, m, c = {}) {
136
136
  ...n,
137
137
  apply: (o = {}) => F(n, o),
138
138
  clear: (o = {}) => F(n, o),
139
- bind: () => G(n)
139
+ bind: () => K(n)
140
140
  }));
141
141
  }
142
142
  ), _ = v(
@@ -156,13 +156,13 @@ function ae(a, m, c = {}) {
156
156
  if (!["", null, void 0, []].includes(t))
157
157
  return t;
158
158
  }
159
- function W(t) {
159
+ function z(t) {
160
160
  return [P, L, V].reduce(
161
161
  (n, o) => o(n),
162
162
  t
163
163
  );
164
164
  }
165
- function z(t, n) {
165
+ function B(t, n) {
166
166
  return n = Array.isArray(n) ? n : [n], n.includes(t) ? n.filter((o) => o !== t) : [...n, t];
167
167
  }
168
168
  function R(t) {
@@ -176,10 +176,10 @@ function ae(a, m, c = {}) {
176
176
  function j(t) {
177
177
  return typeof t != "string" ? t : k.value.find(({ name: n }) => n === t);
178
178
  }
179
- function q(t) {
179
+ function H(t) {
180
180
  return t ? typeof t == "string" ? _.value.some((n) => n.name === t) : t.active : !!_.value.length;
181
181
  }
182
- function H(t) {
182
+ function I(t) {
183
183
  var n;
184
184
  return t ? typeof t == "string" ? ((n = d.value) == null ? void 0 : n.name) === t : t.active : !!d.value;
185
185
  }
@@ -187,9 +187,9 @@ function ae(a, m, c = {}) {
187
187
  var n;
188
188
  return t ? typeof t == "string" ? (n = h.value) == null ? void 0 : n.some((o) => o.name === t) : t.active : !!i.value.term;
189
189
  }
190
- function B(t, n = {}) {
190
+ function D(t, n = {}) {
191
191
  const o = Object.fromEntries(
192
- Object.entries(t).map(([e, l]) => [e, W(l)])
192
+ Object.entries(t).map(([e, l]) => [e, z(l)])
193
193
  );
194
194
  b.reload({
195
195
  ...c,
@@ -204,7 +204,7 @@ function ae(a, m, c = {}) {
204
204
  ...c,
205
205
  ...o,
206
206
  data: {
207
- [e.name]: W(n)
207
+ [e.name]: z(n)
208
208
  }
209
209
  });
210
210
  }
@@ -240,7 +240,7 @@ function ae(a, m, c = {}) {
240
240
  return console.warn("Refine cannot perform matching.");
241
241
  const o = j(t);
242
242
  if (!o) return console.warn(`Match [${t}] does not exist.`);
243
- const e = z(
243
+ const e = B(
244
244
  o.name,
245
245
  h.value.map(({ name: l }) => l)
246
246
  );
@@ -262,7 +262,7 @@ function ae(a, m, c = {}) {
262
262
  )
263
263
  });
264
264
  }
265
- function D(t = {}) {
265
+ function U(t = {}) {
266
266
  if (!p.value)
267
267
  return console.warn("Refine cannot perform sorting.");
268
268
  b.reload({
@@ -273,7 +273,7 @@ function ae(a, m, c = {}) {
273
273
  }
274
274
  });
275
275
  }
276
- function I(t = {}) {
276
+ function G(t = {}) {
277
277
  w(null, t);
278
278
  }
279
279
  function M(t = {}) {
@@ -287,7 +287,7 @@ function ae(a, m, c = {}) {
287
287
  }
288
288
  });
289
289
  }
290
- function U(t = {}) {
290
+ function C(t = {}) {
291
291
  var n;
292
292
  b.reload({
293
293
  ...c,
@@ -305,7 +305,7 @@ function ae(a, m, c = {}) {
305
305
  }
306
306
  });
307
307
  }
308
- function C(t, n = {}) {
308
+ function O(t, n = {}) {
309
309
  const o = R(t);
310
310
  if (!o) return console.warn(`Filter [${t}] does not exist.`);
311
311
  const {
@@ -314,20 +314,20 @@ function ae(a, m, c = {}) {
314
314
  ...f
315
315
  } = n;
316
316
  return {
317
- "onUpdate:modelValue": K((S) => {
317
+ "onUpdate:modelValue": q((S) => {
318
318
  A(o, l(S), f);
319
319
  }, e),
320
320
  modelValue: o.value
321
321
  };
322
322
  }
323
- function O(t, n = {}) {
323
+ function W(t, n = {}) {
324
324
  if (!p.value)
325
325
  return console.warn("Refine cannot perform sorting.");
326
326
  const o = T(t);
327
327
  if (!o) return console.warn(`Sort [${t}] does not exist.`);
328
328
  const { debounce: e = 0, transform: l, ...f } = n;
329
329
  return {
330
- onClick: K(() => {
330
+ onClick: q(() => {
331
331
  var S;
332
332
  g(o, (S = d.value) == null ? void 0 : S.direction, f);
333
333
  }, e)
@@ -338,7 +338,7 @@ function ae(a, m, c = {}) {
338
338
  return console.warn("Refine cannot perform searching.");
339
339
  const { debounce: n = 700, transform: o, ...e } = t;
340
340
  return {
341
- "onUpdate:modelValue": K(
341
+ "onUpdate:modelValue": q(
342
342
  (l) => {
343
343
  w(l, e);
344
344
  },
@@ -347,14 +347,14 @@ function ae(a, m, c = {}) {
347
347
  modelValue: i.value.term ?? ""
348
348
  };
349
349
  }
350
- function G(t, n = {}) {
350
+ function K(t, n = {}) {
351
351
  if (!s.value)
352
352
  return console.warn("Refine cannot perform matching.");
353
353
  const o = j(t);
354
354
  if (!o) return console.warn(`Match [${t}] does not exist.`);
355
355
  const { debounce: e = 0, transform: l, ...f } = n;
356
356
  return {
357
- "onUpdate:modelValue": K((S) => {
357
+ "onUpdate:modelValue": q((S) => {
358
358
  F(S, f);
359
359
  }, e),
360
360
  modelValue: y(o),
@@ -371,29 +371,29 @@ function ae(a, m, c = {}) {
371
371
  isSortable: p,
372
372
  isSearchable: u,
373
373
  isMatchable: s,
374
- isFiltering: q,
375
- isSorting: H,
374
+ isFiltering: H,
375
+ isSorting: I,
376
376
  isSearching: y,
377
377
  getFilter: R,
378
378
  getSort: T,
379
379
  getSearch: j,
380
- apply: B,
380
+ apply: D,
381
381
  applyFilter: A,
382
382
  applySort: g,
383
383
  applySearch: w,
384
384
  applyMatch: F,
385
385
  clearFilter: $,
386
- clearSort: D,
387
- clearSearch: I,
386
+ clearSort: U,
387
+ clearSearch: G,
388
388
  clearMatch: M,
389
- reset: U,
390
- bindFilter: C,
391
- bindSort: O,
389
+ reset: C,
390
+ bindFilter: O,
391
+ bindSort: W,
392
392
  bindSearch: J,
393
- bindMatch: G,
393
+ bindMatch: K,
394
394
  stringValue: L,
395
395
  omitValue: V,
396
- toggleValue: z,
396
+ toggleValue: B,
397
397
  delimitArray: P
398
398
  });
399
399
  }
@@ -414,18 +414,18 @@ function ue(a, m, c = {}) {
414
414
  toggleSort: (f = {}) => r.applySort(e.sort, null, f)
415
415
  };
416
416
  })
417
- ), W = v(
417
+ ), z = v(
418
418
  () => u.value.columns.filter(({ hidden: e }) => !e).map((e) => ({
419
419
  ...e,
420
- toggle: (l = {}) => G(e.name, l)
420
+ toggle: (l = {}) => K(e.name, l)
421
421
  }))
422
- ), z = v(
422
+ ), B = v(
423
423
  () => u.value.records.map((e) => ({
424
424
  ...e,
425
425
  /** The operations available for the record */
426
426
  operations: e.operations.map((l) => ({
427
427
  ...l,
428
- execute: (f = {}) => U(l, e, f)
428
+ execute: (f = {}) => C(l, e, f)
429
429
  })),
430
430
  /** Determine if the record is selected */
431
431
  selected: s.selected(g(e)),
@@ -434,7 +434,7 @@ function ue(a, m, c = {}) {
434
434
  const f = e.operations.find(
435
435
  ({ default: S }) => S
436
436
  );
437
- f && U(f, e, l);
437
+ f && C(f, e, l);
438
438
  },
439
439
  /** Selects this record */
440
440
  select: () => s.select(g(e)),
@@ -454,16 +454,16 @@ function ue(a, m, c = {}) {
454
454
  ), R = v(() => !!u.value.operations.inline), T = v(
455
455
  () => u.value.operations.bulk.map((e) => ({
456
456
  ...e,
457
- execute: (l = {}) => C(e, l)
457
+ execute: (l = {}) => O(e, l)
458
458
  }))
459
459
  ), j = v(
460
460
  () => u.value.operations.page.map((e) => ({
461
461
  ...e,
462
- execute: (l = {}) => O(e, l)
462
+ execute: (l = {}) => W(e, l)
463
463
  }))
464
- ), q = v(
464
+ ), H = v(
465
465
  () => u.value.pages.find(({ active: e }) => e)
466
- ), H = v(() => u.value.pages), y = v(() => ({
466
+ ), I = v(() => u.value.pages), y = v(() => ({
467
467
  ...u.value.paginate,
468
468
  next: (e = {}) => {
469
469
  "nextLink" in y.value && y.value.nextLink && M(y.value.nextLink, e);
@@ -483,7 +483,7 @@ function ue(a, m, c = {}) {
483
483
  navigate: (l = {}) => e.url && M(e.url, l)
484
484
  }))
485
485
  } : {}
486
- })), B = v(
486
+ })), D = v(
487
487
  () => u.value.records.length > 0 && u.value.records.every(
488
488
  (e) => s.selected(g(e))
489
489
  )
@@ -506,10 +506,10 @@ function ue(a, m, c = {}) {
506
506
  var f;
507
507
  return (f = w(e, l)) == null ? void 0 : f.e;
508
508
  }
509
- function D(e) {
509
+ function U(e) {
510
510
  return { id: g(e) };
511
511
  }
512
- function I() {
512
+ function G() {
513
513
  return {
514
514
  all: s.selection.value.all,
515
515
  only: Array.from(s.selection.value.only),
@@ -525,15 +525,15 @@ function ue(a, m, c = {}) {
525
525
  method: "get"
526
526
  });
527
527
  }
528
- function U(e, l, f = {}) {
528
+ function C(e, l, f = {}) {
529
529
  var E;
530
- N(e, D(l), {
530
+ N(e, U(l), {
531
531
  ...c,
532
532
  ...f
533
533
  }) || (E = i == null ? void 0 : i[e.name]) == null || E.call(i, l);
534
534
  }
535
- function C(e, l = {}) {
536
- return N(e, I(), {
535
+ function O(e, l = {}) {
536
+ return N(e, G(), {
537
537
  ...c,
538
538
  ...l,
539
539
  onSuccess: (f) => {
@@ -542,7 +542,7 @@ function ue(a, m, c = {}) {
542
542
  }
543
543
  });
544
544
  }
545
- function O(e, l = {}, f = {}) {
545
+ function W(e, l = {}, f = {}) {
546
546
  return N(e, l, { ...c, ...f });
547
547
  }
548
548
  function J(e, l = {}) {
@@ -557,7 +557,7 @@ function ue(a, m, c = {}) {
557
557
  }
558
558
  });
559
559
  }
560
- function G(e, l = {}) {
560
+ function K(e, l = {}) {
561
561
  if (!L.value)
562
562
  return console.warn("The table does not support column toggling.");
563
563
  const f = A(e);
@@ -593,7 +593,7 @@ function ue(a, m, c = {}) {
593
593
  "onUpdate:modelValue": (e) => {
594
594
  e ? t() : n();
595
595
  },
596
- modelValue: B.value
596
+ modelValue: D.value
597
597
  };
598
598
  }
599
599
  return Z({
@@ -622,9 +622,9 @@ function ue(a, m, c = {}) {
622
622
  /** The heading columns for the table */
623
623
  headings: V,
624
624
  /** All of the table's columns */
625
- columns: W,
625
+ columns: z,
626
626
  /** The records of the table */
627
- records: z,
627
+ records: B,
628
628
  /** Whether the table has record operations */
629
629
  inline: R,
630
630
  /** The available bulk operations */
@@ -632,17 +632,21 @@ function ue(a, m, c = {}) {
632
632
  /** The available page operations */
633
633
  page: j,
634
634
  /** The available number of records to display per page */
635
- pages: H,
635
+ pages: I,
636
636
  /** The current record per page item */
637
- currentPage: q,
637
+ currentPage: H,
638
638
  /** The pagination metadata */
639
639
  paginator: y,
640
640
  /** Execute an inline operation */
641
- executeInline: U,
641
+ executeInline: C,
642
642
  /** Execute a bulk operation */
643
- executeBulk: C,
643
+ executeBulk: O,
644
644
  /** Execute a page operation */
645
- executePage: O,
645
+ executePage: W,
646
+ /** The bulk data */
647
+ getBulkData: G,
648
+ /** The record data */
649
+ getRecordData: U,
646
650
  /** Apply a new page by changing the number of records to display */
647
651
  applyPage: J,
648
652
  /** The current selection of records */
@@ -664,7 +668,7 @@ function ue(a, m, c = {}) {
664
668
  /** Deselect all records */
665
669
  deselectAll: s.deselectAll,
666
670
  /** Whether all records on the current page are selected */
667
- isPageSelected: B,
671
+ isPageSelected: D,
668
672
  /** Determine if any records are selected */
669
673
  hasSelected: s.hasSelected,
670
674
  /** Bind the given record to a checkbox */
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("@inertiajs/vue3"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3","axios"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x["@honed/table"]={},x.Vue,x.Inertia,x.axios))})(this,function(x,u,b,Y){"use strict";function K(a,m={},s={}){if(!a.href||!a.method)return!1;if(a.type==="inertia")a.method==="delete"?b.router.delete(a.href,s):b.router[a.method](a.href,m,s);else{const i=v=>{var c;return(c=s.onError)==null?void 0:c.call(s,v)};a.method==="get"?window.location.href=a.href:a.method==="delete"?Y.delete(a.href).catch(i):Y[a.method](a.href,m).catch(i)}return!0}function Z(){const a=u.ref({all:!1,only:new Set,except:new Set});function m(){a.value.all=!0,a.value.only.clear(),a.value.except.clear()}function s(){a.value.all=!1,a.value.only.clear(),a.value.except.clear()}function i(...p){p.forEach(h=>a.value.except.delete(h)),p.forEach(h=>a.value.only.add(h))}function v(...p){p.forEach(h=>a.value.except.add(h)),p.forEach(h=>a.value.only.delete(h))}function c(p,h){if(d(p)||h===!1)return v(p);if(!d(p)||h===!0)return i(p)}function d(p){return a.value.all?!a.value.except.has(p):a.value.only.has(p)}const l=u.computed(()=>a.value.all&&a.value.except.size===0),w=u.computed(()=>a.value.only.size>0||l.value);function k(p){return{"onUpdate:modelValue":h=>{h?i(p):v(p)},modelValue:d(p),value:p}}function _(){return{"onUpdate:modelValue":p=>{p?m():s()},modelValue:l.value}}return{allSelected:l,selection:a,hasSelected:w,selectAll:m,deselectAll:s,select:i,deselect:v,toggle:c,selected:d,bind:k,bindAll:_}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Q=()=>{};function ee(a,m){function s(...i){return new Promise((v,c)=>{Promise.resolve(a(()=>m.apply(this,i),{fn:m,thisArg:this,args:i})).then(v).catch(c)})}return s}function te(a,m={}){let s,i,v=Q;const c=l=>{clearTimeout(l),v(),v=Q};let d;return l=>{const w=u.toValue(a),k=u.toValue(m.maxWait);return s&&c(s),w<=0||k!==void 0&&k<=0?(i&&(c(i),i=null),Promise.resolve(l())):new Promise((_,p)=>{v=m.rejectOnCancel?p:_,d=l,k&&!i&&(i=setTimeout(()=>{s&&c(s),i=null,_(d())},k)),s=setTimeout(()=>{i&&c(i),i=null,_(l())},w)})}}function W(a,m=200,s={}){return ee(te(m,s),a)}function ne(a,m,s={}){if(!(a!=null&&a[m]))throw new Error("The refine must be provided with valid props and key.");const i=u.computed(()=>a[m]),v=u.computed(()=>!!i.value._sort_key),c=u.computed(()=>!!i.value._search_key),d=u.computed(()=>!!i.value._match_key),l=u.computed(()=>{var t;return(t=i.value.filters)==null?void 0:t.map(n=>({...n,apply:(o,e={})=>F(n,o,e),clear:(o={})=>U(n,o),bind:()=>O(n.name)}))}),w=u.computed(()=>{var t;return(t=i.value.sorts)==null?void 0:t.map(n=>({...n,apply:(o={})=>g(n,n.direction,o),clear:(o={})=>G(o),bind:()=>q(n)}))}),k=u.computed(()=>{var t;return(t=i.value.searches)==null?void 0:t.map(n=>({...n,apply:(o={})=>M(n,o),clear:(o={})=>M(n,o),bind:()=>I(n)}))}),_=u.computed(()=>l.value.filter(({active:t})=>t)),p=u.computed(()=>w.value.find(({active:t})=>t)),h=u.computed(()=>k.value.filter(({active:t})=>t));function E(t){return Array.isArray(t)?t.join(i.value._delimiter):t}function L(t){return typeof t!="string"?t:t.trim().replace(/\s+/g,"+")}function A(t){if(!["",null,void 0,[]].includes(t))return t}function z(t){return[E,L,A].reduce((n,o)=>o(n),t)}function B(t,n){return n=Array.isArray(n)?n:[n],n.includes(t)?n.filter(o=>o!==t):[...n,t]}function j(t){return typeof t!="string"?t:l.value.find(({name:n})=>n===t)}function R(t,n=null){return typeof t!="string"?t:w.value.find(({name:o,direction:e})=>o===t&&e===n)}function $(t){return typeof t!="string"?t:k.value.find(({name:n})=>n===t)}function H(t){return t?typeof t=="string"?_.value.some(n=>n.name===t):t.active:!!_.value.length}function J(t){var n;return t?typeof t=="string"?((n=p.value)==null?void 0:n.name)===t:t.active:!!p.value}function y(t){var n;return t?typeof t=="string"?(n=h.value)==null?void 0:n.some(o=>o.name===t):t.active:!!i.value.term}function D(t,n={}){const o=Object.fromEntries(Object.entries(t).map(([e,r])=>[e,z(r)]));b.router.reload({...s,...n,data:o})}function F(t,n,o={}){const e=j(t);if(!e)return console.warn(`Filter [${t}] does not exist.`);b.router.reload({...s,...o,data:{[e.name]:z(n)}})}function g(t,n=null,o={}){if(!v.value)return console.warn("Refine cannot perform sorting.");const e=R(t,n);if(!e)return console.warn(`Sort [${t}] does not exist.`);b.router.reload({...s,...o,data:{[i.value._sort_key]:A(e.next)}})}function V(t,n={}){if(!c.value)return console.warn("Refine cannot perform searching.");t=[L,A].reduce((o,e)=>e(o),t),b.router.reload({...s,...n,data:{[i.value._search_key]:t}})}function M(t,n={}){if(!d.value||!c.value)return console.warn("Refine cannot perform matching.");const o=$(t);if(!o)return console.warn(`Match [${t}] does not exist.`);const e=B(o.name,h.value.map(({name:r})=>r));b.router.reload({...s,...n,data:{[i.value._match_key]:E(e)}})}function U(t,n={}){if(t)return F(t,null,n);b.router.reload({...s,...n,data:Object.fromEntries(_.value.map(({name:o})=>[o,null]))})}function G(t={}){if(!v.value)return console.warn("Refine cannot perform sorting.");b.router.reload({...s,...t,data:{[i.value._sort_key]:null}})}function N(t={}){V(null,t)}function P(t={}){if(!d.value)return console.warn("Refine cannot perform matching.");b.router.reload({...s,...t,data:{[i.value._match_key]:null}})}function C(t={}){var n;b.router.reload({...s,...t,data:{[i.value._search_key??""]:void 0,[i.value._sort_key??""]:void 0,[i.value._match_key??""]:void 0,...Object.fromEntries(((n=i.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[])}})}function O(t,n={}){const o=j(t);if(!o)return console.warn(`Filter [${t}] does not exist.`);const{debounce:e=150,transform:r=S=>S,...f}=n;return{"onUpdate:modelValue":W(S=>{F(o,r(S),f)},e),modelValue:o.value}}function q(t,n={}){if(!v.value)return console.warn("Refine cannot perform sorting.");const o=R(t);if(!o)return console.warn(`Sort [${t}] does not exist.`);const{debounce:e=0,transform:r,...f}=n;return{onClick:W(()=>{var S;g(o,(S=p.value)==null?void 0:S.direction,f)},e)}}function X(t={}){if(!c.value)return console.warn("Refine cannot perform searching.");const{debounce:n=700,transform:o,...e}=t;return{"onUpdate:modelValue":W(r=>{V(r,e)},n),modelValue:i.value.term??""}}function I(t,n={}){if(!d.value)return console.warn("Refine cannot perform matching.");const o=$(t);if(!o)return console.warn(`Match [${t}] does not exist.`);const{debounce:e=0,transform:r,...f}=n;return{"onUpdate:modelValue":W(S=>{M(S,f)},e),modelValue:y(o),value:o.name}}return u.reactive({filters:l,sorts:w,searches:k,currentFilters:_,currentSort:p,currentSearches:h,isSortable:v,isSearchable:c,isMatchable:d,isFiltering:H,isSorting:J,isSearching:y,getFilter:j,getSort:R,getSearch:$,apply:D,applyFilter:F,applySort:g,applySearch:V,applyMatch:M,clearFilter:U,clearSort:G,clearSearch:N,clearMatch:P,reset:C,bindFilter:O,bindSort:q,bindSearch:X,bindMatch:I,stringValue:L,omitValue:A,toggleValue:B,delimitArray:E})}function re(a,m,s={}){if(!(a!=null&&a[m]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:i={},...v}={only:[...s.only??[],m.toString()],...s},c=u.computed(()=>a[m]),d=Z(),l=ne(a,m,v),w=u.computed(()=>c.value.meta),k=u.computed(()=>c.value.views??[]),_=u.computed(()=>c.value.state??null),p=u.computed(()=>c.value.placeholder??null),h=u.computed(()=>!!c.value.state),E=u.computed(()=>!!c.value._page_key&&!!c.value._record_key),L=u.computed(()=>!!c.value._column_key),A=u.computed(()=>c.value.columns.filter(({active:e,hidden:r})=>e&&!r).map(e=>{var r;return{...e,isSorting:!!((r=e.sort)!=null&&r.active),toggleSort:(f={})=>l.applySort(e.sort,null,f)}})),z=u.computed(()=>c.value.columns.filter(({hidden:e})=>!e).map(e=>({...e,toggle:(r={})=>I(e.name,r)}))),B=u.computed(()=>c.value.records.map(e=>({...e,operations:e.operations.map(r=>({...r,execute:(f={})=>C(r,e,f)})),selected:d.selected(g(e)),default:(r={})=>{const f=e.operations.find(({default:S})=>S);f&&C(f,e,r)},select:()=>d.select(g(e)),deselect:()=>d.deselect(g(e)),toggle:()=>d.toggle(g(e)),bind:()=>d.bind(g(e)),entry:r=>V(e,r),value:r=>M(e,r),extra:r=>U(e,r)}))),j=u.computed(()=>!!c.value.operations.inline),R=u.computed(()=>c.value.operations.bulk.map(e=>({...e,execute:(r={})=>O(e,r)}))),$=u.computed(()=>c.value.operations.page.map(e=>({...e,execute:(r={})=>q(e,r)}))),H=u.computed(()=>c.value.pages.find(({active:e})=>e)),J=u.computed(()=>c.value.pages),y=u.computed(()=>({...c.value.paginate,next:(e={})=>{"nextLink"in y.value&&y.value.nextLink&&P(y.value.nextLink,e)},previous:(e={})=>{"prevLink"in y.value&&y.value.prevLink&&P(y.value.prevLink,e)},first:(e={})=>{"firstLink"in y.value&&y.value.firstLink&&P(y.value.firstLink,e)},last:(e={})=>{"lastLink"in y.value&&y.value.lastLink&&P(y.value.lastLink,e)},..."links"in c.value.paginate&&c.value.paginate.links?{links:c.value.paginate.links.map(e=>({...e,navigate:(r={})=>e.url&&P(e.url,r)}))}:{}})),D=u.computed(()=>c.value.records.length>0&&c.value.records.every(e=>d.selected(g(e))));function F(e){return typeof e=="string"?e:e.name}function g(e){return e._key}function V(e,r){const f=F(r);return e[f]}function M(e,r){var f;return((f=V(e,r))==null?void 0:f.v)??null}function U(e,r){var f;return(f=V(e,r))==null?void 0:f.e}function G(e){return{id:g(e)}}function N(){return{all:d.selection.value.all,only:Array.from(d.selection.value.only),except:Array.from(d.selection.value.except)}}function P(e,r={}){b.router.visit(e,{preserveScroll:!0,preserveState:!0,...v,...r,method:"get"})}function C(e,r,f={}){var T;K(e,G(r),{...s,...f})||(T=i==null?void 0:i[e.name])==null||T.call(i,r)}function O(e,r={}){return K(e,N(),{...s,...r,onSuccess:f=>{var S,T;(S=r.onSuccess)==null||S.call(r,f),(T=s.onSuccess)==null||T.call(s,f),e.keep||d.deselectAll()}})}function q(e,r={},f={}){return K(e,r,{...s,...f})}function X(e,r={}){if(!E.value)return console.warn("The table does not support pagination changes.");b.router.reload({...v,...r,data:{[c.value._record_key]:e.value,[c.value._page_key]:void 0}})}function I(e,r={}){if(!L.value)return console.warn("The table does not support column toggling.");const f=F(e);if(!f)return console.log(`Column [${e}] does not exist.`);const S=l.toggleValue(f,A.value.map(({name:T})=>T));b.router.reload({...v,...r,data:{[c.value._column_key]:l.delimitArray(S)}})}function t(){d.select(...c.value.records.map(e=>g(e)))}function n(){d.deselect(...c.value.records.map(e=>g(e)))}function o(){return{"onUpdate:modelValue":e=>{e?t():n()},modelValue:D.value}}return u.reactive({meta:w,views:k,emptyState:_,placeholder:p,isEmpty:h,isPageable:E,isToggleable:L,getEntry:V,getValue:M,getExtra:U,getRecordKey:g,headings:A,columns:z,records:B,inline:j,bulk:R,page:$,pages:J,currentPage:H,paginator:y,executeInline:C,executeBulk:O,executePage:q,applyPage:X,selection:d.selection,select:e=>d.select(g(e)),deselect:e=>d.deselect(g(e)),selectPage:t,deselectPage:n,toggle:e=>d.toggle(g(e)),selected:e=>d.selected(g(e)),selectAll:d.selectAll,deselectAll:d.deselectAll,isPageSelected:D,hasSelected:d.hasSelected,bindCheckbox:e=>d.bind(g(e)),bindPage:o,bindAll:d.bindAll,filters:l.filters,sorts:l.sorts,searches:l.searches,currentFilters:l.currentFilters,currentSort:l.currentSort,currentSearches:l.currentSearches,isSortable:l.isSortable,isSearchable:l.isSearchable,isMatchable:l.isMatchable,isFiltering:l.isFiltering,isSorting:l.isSorting,isSearching:l.isSearching,getFilter:l.getFilter,getSort:l.getSort,getSearch:l.getSearch,apply:l.apply,applyFilter:l.applyFilter,applySort:l.applySort,applySearch:l.applySearch,applyMatch:l.applyMatch,clearFilter:l.clearFilter,clearSort:l.clearSort,clearSearch:l.clearSearch,clearMatch:l.clearMatch,reset:l.reset,bindFilter:l.bindFilter,bindSort:l.bindSort,bindSearch:l.bindSearch,bindMatch:l.bindMatch,stringValue:l.stringValue,omitValue:l.omitValue,toggleValue:l.toggleValue,delimitArray:l.delimitArray})}function ae(a,m){return a?typeof a=="object"?a.type===m:a===m:!1}x.is=ae,x.useTable=re,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
1
+ (function(x,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("@inertiajs/vue3"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3","axios"],u):(x=typeof globalThis<"u"?globalThis:x||self,u(x["@honed/table"]={},x.Vue,x.Inertia,x.axios))})(this,function(x,u,b,Y){"use strict";function H(a,m={},s={}){if(!a.href||!a.method)return!1;if(a.type==="inertia")a.method==="delete"?b.router.delete(a.href,s):b.router[a.method](a.href,m,s);else{const i=v=>{var c;return(c=s.onError)==null?void 0:c.call(s,v)};a.method==="get"?window.location.href=a.href:a.method==="delete"?Y.delete(a.href).catch(i):Y[a.method](a.href,m).catch(i)}return!0}function Z(){const a=u.ref({all:!1,only:new Set,except:new Set});function m(){a.value.all=!0,a.value.only.clear(),a.value.except.clear()}function s(){a.value.all=!1,a.value.only.clear(),a.value.except.clear()}function i(...p){p.forEach(h=>a.value.except.delete(h)),p.forEach(h=>a.value.only.add(h))}function v(...p){p.forEach(h=>a.value.except.add(h)),p.forEach(h=>a.value.only.delete(h))}function c(p,h){if(d(p)||h===!1)return v(p);if(!d(p)||h===!0)return i(p)}function d(p){return a.value.all?!a.value.except.has(p):a.value.only.has(p)}const l=u.computed(()=>a.value.all&&a.value.except.size===0),w=u.computed(()=>a.value.only.size>0||l.value);function k(p){return{"onUpdate:modelValue":h=>{h?i(p):v(p)},modelValue:d(p),value:p}}function _(){return{"onUpdate:modelValue":p=>{p?m():s()},modelValue:l.value}}return{allSelected:l,selection:a,hasSelected:w,selectAll:m,deselectAll:s,select:i,deselect:v,toggle:c,selected:d,bind:k,bindAll:_}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Q=()=>{};function ee(a,m){function s(...i){return new Promise((v,c)=>{Promise.resolve(a(()=>m.apply(this,i),{fn:m,thisArg:this,args:i})).then(v).catch(c)})}return s}function te(a,m={}){let s,i,v=Q;const c=l=>{clearTimeout(l),v(),v=Q};let d;return l=>{const w=u.toValue(a),k=u.toValue(m.maxWait);return s&&c(s),w<=0||k!==void 0&&k<=0?(i&&(c(i),i=null),Promise.resolve(l())):new Promise((_,p)=>{v=m.rejectOnCancel?p:_,d=l,k&&!i&&(i=setTimeout(()=>{s&&c(s),i=null,_(d())},k)),s=setTimeout(()=>{i&&c(i),i=null,_(l())},w)})}}function z(a,m=200,s={}){return ee(te(m,s),a)}function ne(a,m,s={}){if(!(a!=null&&a[m]))throw new Error("The refine must be provided with valid props and key.");const i=u.computed(()=>a[m]),v=u.computed(()=>!!i.value._sort_key),c=u.computed(()=>!!i.value._search_key),d=u.computed(()=>!!i.value._match_key),l=u.computed(()=>{var t;return(t=i.value.filters)==null?void 0:t.map(n=>({...n,apply:(o,e={})=>F(n,o,e),clear:(o={})=>U(n,o),bind:()=>q(n.name)}))}),w=u.computed(()=>{var t;return(t=i.value.sorts)==null?void 0:t.map(n=>({...n,apply:(o={})=>g(n,n.direction,o),clear:(o={})=>C(o),bind:()=>W(n)}))}),k=u.computed(()=>{var t;return(t=i.value.searches)==null?void 0:t.map(n=>({...n,apply:(o={})=>M(n,o),clear:(o={})=>M(n,o),bind:()=>K(n)}))}),_=u.computed(()=>l.value.filter(({active:t})=>t)),p=u.computed(()=>w.value.find(({active:t})=>t)),h=u.computed(()=>k.value.filter(({active:t})=>t));function E(t){return Array.isArray(t)?t.join(i.value._delimiter):t}function L(t){return typeof t!="string"?t:t.trim().replace(/\s+/g,"+")}function A(t){if(!["",null,void 0,[]].includes(t))return t}function B(t){return[E,L,A].reduce((n,o)=>o(n),t)}function D(t,n){return n=Array.isArray(n)?n:[n],n.includes(t)?n.filter(o=>o!==t):[...n,t]}function j(t){return typeof t!="string"?t:l.value.find(({name:n})=>n===t)}function R(t,n=null){return typeof t!="string"?t:w.value.find(({name:o,direction:e})=>o===t&&e===n)}function $(t){return typeof t!="string"?t:k.value.find(({name:n})=>n===t)}function J(t){return t?typeof t=="string"?_.value.some(n=>n.name===t):t.active:!!_.value.length}function N(t){var n;return t?typeof t=="string"?((n=p.value)==null?void 0:n.name)===t:t.active:!!p.value}function y(t){var n;return t?typeof t=="string"?(n=h.value)==null?void 0:n.some(o=>o.name===t):t.active:!!i.value.term}function G(t,n={}){const o=Object.fromEntries(Object.entries(t).map(([e,r])=>[e,B(r)]));b.router.reload({...s,...n,data:o})}function F(t,n,o={}){const e=j(t);if(!e)return console.warn(`Filter [${t}] does not exist.`);b.router.reload({...s,...o,data:{[e.name]:B(n)}})}function g(t,n=null,o={}){if(!v.value)return console.warn("Refine cannot perform sorting.");const e=R(t,n);if(!e)return console.warn(`Sort [${t}] does not exist.`);b.router.reload({...s,...o,data:{[i.value._sort_key]:A(e.next)}})}function V(t,n={}){if(!c.value)return console.warn("Refine cannot perform searching.");t=[L,A].reduce((o,e)=>e(o),t),b.router.reload({...s,...n,data:{[i.value._search_key]:t}})}function M(t,n={}){if(!d.value||!c.value)return console.warn("Refine cannot perform matching.");const o=$(t);if(!o)return console.warn(`Match [${t}] does not exist.`);const e=D(o.name,h.value.map(({name:r})=>r));b.router.reload({...s,...n,data:{[i.value._match_key]:E(e)}})}function U(t,n={}){if(t)return F(t,null,n);b.router.reload({...s,...n,data:Object.fromEntries(_.value.map(({name:o})=>[o,null]))})}function C(t={}){if(!v.value)return console.warn("Refine cannot perform sorting.");b.router.reload({...s,...t,data:{[i.value._sort_key]:null}})}function I(t={}){V(null,t)}function P(t={}){if(!d.value)return console.warn("Refine cannot perform matching.");b.router.reload({...s,...t,data:{[i.value._match_key]:null}})}function O(t={}){var n;b.router.reload({...s,...t,data:{[i.value._search_key??""]:void 0,[i.value._sort_key??""]:void 0,[i.value._match_key??""]:void 0,...Object.fromEntries(((n=i.value.filters)==null?void 0:n.map(o=>[o.name,void 0]))??[])}})}function q(t,n={}){const o=j(t);if(!o)return console.warn(`Filter [${t}] does not exist.`);const{debounce:e=150,transform:r=S=>S,...f}=n;return{"onUpdate:modelValue":z(S=>{F(o,r(S),f)},e),modelValue:o.value}}function W(t,n={}){if(!v.value)return console.warn("Refine cannot perform sorting.");const o=R(t);if(!o)return console.warn(`Sort [${t}] does not exist.`);const{debounce:e=0,transform:r,...f}=n;return{onClick:z(()=>{var S;g(o,(S=p.value)==null?void 0:S.direction,f)},e)}}function X(t={}){if(!c.value)return console.warn("Refine cannot perform searching.");const{debounce:n=700,transform:o,...e}=t;return{"onUpdate:modelValue":z(r=>{V(r,e)},n),modelValue:i.value.term??""}}function K(t,n={}){if(!d.value)return console.warn("Refine cannot perform matching.");const o=$(t);if(!o)return console.warn(`Match [${t}] does not exist.`);const{debounce:e=0,transform:r,...f}=n;return{"onUpdate:modelValue":z(S=>{M(S,f)},e),modelValue:y(o),value:o.name}}return u.reactive({filters:l,sorts:w,searches:k,currentFilters:_,currentSort:p,currentSearches:h,isSortable:v,isSearchable:c,isMatchable:d,isFiltering:J,isSorting:N,isSearching:y,getFilter:j,getSort:R,getSearch:$,apply:G,applyFilter:F,applySort:g,applySearch:V,applyMatch:M,clearFilter:U,clearSort:C,clearSearch:I,clearMatch:P,reset:O,bindFilter:q,bindSort:W,bindSearch:X,bindMatch:K,stringValue:L,omitValue:A,toggleValue:D,delimitArray:E})}function re(a,m,s={}){if(!(a!=null&&a[m]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:i={},...v}={only:[...s.only??[],m.toString()],...s},c=u.computed(()=>a[m]),d=Z(),l=ne(a,m,v),w=u.computed(()=>c.value.meta),k=u.computed(()=>c.value.views??[]),_=u.computed(()=>c.value.state??null),p=u.computed(()=>c.value.placeholder??null),h=u.computed(()=>!!c.value.state),E=u.computed(()=>!!c.value._page_key&&!!c.value._record_key),L=u.computed(()=>!!c.value._column_key),A=u.computed(()=>c.value.columns.filter(({active:e,hidden:r})=>e&&!r).map(e=>{var r;return{...e,isSorting:!!((r=e.sort)!=null&&r.active),toggleSort:(f={})=>l.applySort(e.sort,null,f)}})),B=u.computed(()=>c.value.columns.filter(({hidden:e})=>!e).map(e=>({...e,toggle:(r={})=>K(e.name,r)}))),D=u.computed(()=>c.value.records.map(e=>({...e,operations:e.operations.map(r=>({...r,execute:(f={})=>O(r,e,f)})),selected:d.selected(g(e)),default:(r={})=>{const f=e.operations.find(({default:S})=>S);f&&O(f,e,r)},select:()=>d.select(g(e)),deselect:()=>d.deselect(g(e)),toggle:()=>d.toggle(g(e)),bind:()=>d.bind(g(e)),entry:r=>V(e,r),value:r=>M(e,r),extra:r=>U(e,r)}))),j=u.computed(()=>!!c.value.operations.inline),R=u.computed(()=>c.value.operations.bulk.map(e=>({...e,execute:(r={})=>q(e,r)}))),$=u.computed(()=>c.value.operations.page.map(e=>({...e,execute:(r={})=>W(e,r)}))),J=u.computed(()=>c.value.pages.find(({active:e})=>e)),N=u.computed(()=>c.value.pages),y=u.computed(()=>({...c.value.paginate,next:(e={})=>{"nextLink"in y.value&&y.value.nextLink&&P(y.value.nextLink,e)},previous:(e={})=>{"prevLink"in y.value&&y.value.prevLink&&P(y.value.prevLink,e)},first:(e={})=>{"firstLink"in y.value&&y.value.firstLink&&P(y.value.firstLink,e)},last:(e={})=>{"lastLink"in y.value&&y.value.lastLink&&P(y.value.lastLink,e)},..."links"in c.value.paginate&&c.value.paginate.links?{links:c.value.paginate.links.map(e=>({...e,navigate:(r={})=>e.url&&P(e.url,r)}))}:{}})),G=u.computed(()=>c.value.records.length>0&&c.value.records.every(e=>d.selected(g(e))));function F(e){return typeof e=="string"?e:e.name}function g(e){return e._key}function V(e,r){const f=F(r);return e[f]}function M(e,r){var f;return((f=V(e,r))==null?void 0:f.v)??null}function U(e,r){var f;return(f=V(e,r))==null?void 0:f.e}function C(e){return{id:g(e)}}function I(){return{all:d.selection.value.all,only:Array.from(d.selection.value.only),except:Array.from(d.selection.value.except)}}function P(e,r={}){b.router.visit(e,{preserveScroll:!0,preserveState:!0,...v,...r,method:"get"})}function O(e,r,f={}){var T;H(e,C(r),{...s,...f})||(T=i==null?void 0:i[e.name])==null||T.call(i,r)}function q(e,r={}){return H(e,I(),{...s,...r,onSuccess:f=>{var S,T;(S=r.onSuccess)==null||S.call(r,f),(T=s.onSuccess)==null||T.call(s,f),e.keep||d.deselectAll()}})}function W(e,r={},f={}){return H(e,r,{...s,...f})}function X(e,r={}){if(!E.value)return console.warn("The table does not support pagination changes.");b.router.reload({...v,...r,data:{[c.value._record_key]:e.value,[c.value._page_key]:void 0}})}function K(e,r={}){if(!L.value)return console.warn("The table does not support column toggling.");const f=F(e);if(!f)return console.log(`Column [${e}] does not exist.`);const S=l.toggleValue(f,A.value.map(({name:T})=>T));b.router.reload({...v,...r,data:{[c.value._column_key]:l.delimitArray(S)}})}function t(){d.select(...c.value.records.map(e=>g(e)))}function n(){d.deselect(...c.value.records.map(e=>g(e)))}function o(){return{"onUpdate:modelValue":e=>{e?t():n()},modelValue:G.value}}return u.reactive({meta:w,views:k,emptyState:_,placeholder:p,isEmpty:h,isPageable:E,isToggleable:L,getEntry:V,getValue:M,getExtra:U,getRecordKey:g,headings:A,columns:B,records:D,inline:j,bulk:R,page:$,pages:N,currentPage:J,paginator:y,executeInline:O,executeBulk:q,executePage:W,getBulkData:I,getRecordData:C,applyPage:X,selection:d.selection,select:e=>d.select(g(e)),deselect:e=>d.deselect(g(e)),selectPage:t,deselectPage:n,toggle:e=>d.toggle(g(e)),selected:e=>d.selected(g(e)),selectAll:d.selectAll,deselectAll:d.deselectAll,isPageSelected:G,hasSelected:d.hasSelected,bindCheckbox:e=>d.bind(g(e)),bindPage:o,bindAll:d.bindAll,filters:l.filters,sorts:l.sorts,searches:l.searches,currentFilters:l.currentFilters,currentSort:l.currentSort,currentSearches:l.currentSearches,isSortable:l.isSortable,isSearchable:l.isSearchable,isMatchable:l.isMatchable,isFiltering:l.isFiltering,isSorting:l.isSorting,isSearching:l.isSearching,getFilter:l.getFilter,getSort:l.getSort,getSearch:l.getSearch,apply:l.apply,applyFilter:l.applyFilter,applySort:l.applySort,applySearch:l.applySearch,applyMatch:l.applyMatch,clearFilter:l.clearFilter,clearSort:l.clearSort,clearSearch:l.clearSearch,clearMatch:l.clearMatch,reset:l.reset,bindFilter:l.bindFilter,bindSort:l.bindSort,bindSearch:l.bindSearch,bindMatch:l.bindMatch,stringValue:l.stringValue,omitValue:l.omitValue,toggleValue:l.toggleValue,delimitArray:l.delimitArray})}function ae(a,m){return a?typeof a=="object"?a.type===m:a===m:!1}x.is=ae,x.useTable=re,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@honed/table",
3
3
  "private": false,
4
- "version": "0.13.0",
4
+ "version": "0.14.0",
5
5
  "license": "MIT",
6
6
  "description": "-",
7
7
  "keywords": [