@honed/table 0.10.0 → 0.11.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.
- package/dist/index.d.ts +4 -6
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,6 @@ import { Refine } from '@honed/refine';
|
|
|
13
13
|
import { Sort } from '@honed/refine';
|
|
14
14
|
import { VisitOptions } from '@inertiajs/core';
|
|
15
15
|
|
|
16
|
-
export declare interface Classes {
|
|
17
|
-
classes?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
export declare interface CollectionPaginate {
|
|
21
17
|
empty: boolean;
|
|
22
18
|
}
|
|
@@ -173,7 +169,9 @@ export declare type TableEntry<T extends Record<string, any> = Record<string, an
|
|
|
173
169
|
c: string | null;
|
|
174
170
|
f: boolean;
|
|
175
171
|
};
|
|
176
|
-
} &
|
|
172
|
+
} & {
|
|
173
|
+
class: string | null;
|
|
174
|
+
};
|
|
177
175
|
|
|
178
176
|
export declare interface TableOptions<T extends Record<string, any> = Record<string, any>> extends VisitOptions {
|
|
179
177
|
/**
|
|
@@ -184,7 +182,7 @@ export declare interface TableOptions<T extends Record<string, any> = Record<str
|
|
|
184
182
|
|
|
185
183
|
export declare interface TableRecord<T extends Record<string, any> = Record<string, any>> {
|
|
186
184
|
operations: Executable<InlineOperation>[];
|
|
187
|
-
|
|
185
|
+
class: string | null;
|
|
188
186
|
default: (options?: VisitOptions) => void;
|
|
189
187
|
select: () => void;
|
|
190
188
|
deselect: () => void;
|
package/dist/index.es.js
CHANGED
|
@@ -425,7 +425,7 @@ function ce(l, d, s = {}) {
|
|
|
425
425
|
/** The operations available for the record */
|
|
426
426
|
operations: z(t.operations),
|
|
427
427
|
/** The classes to apply to the record */
|
|
428
|
-
|
|
428
|
+
class: t.class ?? null,
|
|
429
429
|
/** Perform this operation when the record is clicked */
|
|
430
430
|
default: (r = {}) => {
|
|
431
431
|
const c = t.operations.find(
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(A,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],i):(A=typeof globalThis<"u"?globalThis:A||self,i(A["@honed/table"]={},A.Vue,A.Inertia))})(this,function(A,i,S){"use strict";function _(l,p,d,o={}){return l.route?(S.router.visit(l.route.url,{...o,method:l.route.method}),!0):l.action&&p?(S.router.post(p,{...d,name:l.name,type:l.type},o),!0):!1}function Q(l,p,d,o={},m={}){return _(l,p,{...o,id:d??void 0},m)}function ee(l,p,d,o={}){return l.map(m=>({...m,execute:(u={},c={})=>Q(m,p,d,u,{...o,...c})}))}function te(){const l=i.ref({all:!1,only:new Set,except:new Set});function p(){l.value.all=!0,l.value.only.clear(),l.value.except.clear()}function d(){l.value.all=!1,l.value.only.clear(),l.value.except.clear()}function o(...f){f.forEach(y=>l.value.except.delete(y)),f.forEach(y=>l.value.only.add(y))}function m(...f){f.forEach(y=>l.value.except.add(y)),f.forEach(y=>l.value.only.delete(y))}function u(f,y){if(c(f)||y===!1)return m(f);if(!c(f)||y===!0)return o(f)}function c(f){return l.value.all?!l.value.except.has(f):l.value.only.has(f)}const h=i.computed(()=>l.value.all&&l.value.except.size===0),x=i.computed(()=>l.value.only.size>0||h.value);function w(f){return{"onUpdate:modelValue":y=>{y?o(f):m(f)},modelValue:c(f),value:f}}function k(){return{"onUpdate:modelValue":f=>{f?p():d()},modelValue:h.value}}return{allSelected:h,selection:l,hasSelected:x,selectAll:p,deselectAll:d,select:o,deselect:m,toggle:u,selected:c,bind:w,bindAll:k}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Z=()=>{};function ne(l,p){function d(...o){return new Promise((m,u)=>{Promise.resolve(l(()=>p.apply(this,o),{fn:p,thisArg:this,args:o})).then(m).catch(u)})}return d}function le(l,p={}){let d,o,m=Z;const u=h=>{clearTimeout(h),m(),m=Z};let c;return h=>{const x=i.toValue(l),w=i.toValue(p.maxWait);return d&&u(d),x<=0||w!==void 0&&w<=0?(o&&(u(o),o=null),Promise.resolve(h())):new Promise((k,f)=>{m=p.rejectOnCancel?f:k,c=h,w&&!o&&(o=setTimeout(()=>{d&&u(d),o=null,k(c())},w)),d=setTimeout(()=>{o&&u(o),o=null,k(h())},x)})}}function I(l,p=200,d={}){return ne(le(p,d),l)}function ae(l,p,d={}){if(!(l!=null&&l[p]))throw new Error("The refine must be provided with valid props and key.");const o=i.computed(()=>l[p]),m=i.computed(()=>!!o.value.sort),u=i.computed(()=>!!o.value.search),c=i.computed(()=>!!o.value.match),h=i.computed(()=>{var e;return(e=o.value.filters)==null?void 0:e.map(n=>({...n,apply:(a,v={})=>T(n,a,v),clear:(a={})=>O(n,a),bind:()=>G(n.name)}))}),x=i.computed(()=>{var e;return(e=o.value.sorts)==null?void 0:e.map(n=>({...n,apply:(a={})=>F(n,n.direction,a),clear:(a={})=>W(a),bind:()=>D(n)}))}),w=i.computed(()=>{var e;return(e=o.value.searches)==null?void 0:e.map(n=>({...n,apply:(a={})=>V(n,a),clear:(a={})=>V(n,a),bind:()=>H(n)}))}),k=i.computed(()=>h.value.filter(({active:e})=>e)),f=i.computed(()=>x.value.find(({active:e})=>e)),y=i.computed(()=>w.value.filter(({active:e})=>e));function M(e){return Array.isArray(e)?e.join(o.value.delimiter):e}function j(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function P(e){if(!["",null,void 0,[]].includes(e))return e}function $(e){return[M,j,P].reduce((n,a)=>a(n),e)}function B(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(a=>a!==e):[...n,e]}function R(e){return typeof e!="string"?e:h.value.find(({name:n})=>n===e)}function U(e,n=null){return typeof e!="string"?e:x.value.find(({name:a,direction:v})=>a===e&&v===n)}function C(e){return typeof e!="string"?e:w.value.find(({name:n})=>n===e)}function N(e){return e?typeof e=="string"?k.value.some(n=>n.name===e):e.active:!!k.value.length}function X(e){var n;return e?typeof e=="string"?((n=f.value)==null?void 0:n.name)===e:e.active:!!f.value}function K(e){var n;return e?typeof e=="string"?(n=y.value)==null?void 0:n.some(a=>a.name===e):e.active:!!o.value.term}function b(e,n={}){const a=Object.fromEntries(Object.entries(e).map(([v,t])=>[v,$(t)]));S.router.reload({...d,...n,data:a})}function T(e,n,a={}){const v=R(e);if(!v)return console.warn(`Filter [${e}] does not exist.`);S.router.reload({...d,...a,data:{[v.name]:$(n)}})}function F(e,n=null,a={}){if(!m.value)return console.warn("Refine cannot perform sorting.");const v=U(e,n);if(!v)return console.warn(`Sort [${e}] does not exist.`);S.router.reload({...d,...a,data:{[o.value.sort]:P(v.next)}})}function g(e,n={}){if(!u.value)return console.warn("Refine cannot perform searching.");e=[j,P].reduce((a,v)=>v(a),e),S.router.reload({...d,...n,data:{[o.value.search]:e}})}function V(e,n={}){if(!c.value||!u.value)return console.warn("Refine cannot perform matching.");const a=C(e);if(!a)return console.warn(`Match [${e}] does not exist.`);const v=B(a.name,y.value.map(({name:t})=>t));S.router.reload({...d,...n,data:{[o.value.match]:M(v)}})}function O(e,n={}){if(e)return T(e,null,n);S.router.reload({...d,...n,data:Object.fromEntries(k.value.map(({name:a})=>[a,null]))})}function W(e={}){if(!m.value)return console.warn("Refine cannot perform sorting.");S.router.reload({...d,...e,data:{[o.value.sort]:null}})}function q(e={}){g(null,e)}function z(e={}){if(!c.value)return console.warn("Refine cannot perform matching.");S.router.reload({...d,...e,data:{[o.value.match]:null}})}function E(e={}){var n;S.router.reload({...d,...e,data:{[o.value.search??""]:void 0,[o.value.sort??""]:void 0,[o.value.match??""]:void 0,...Object.fromEntries(((n=o.value.filters)==null?void 0:n.map(a=>[a.name,void 0]))??[])}})}function G(e,n={}){const a=R(e);if(!a)return console.warn(`Filter [${e}] does not exist.`);const{debounce:v=250,transform:t=s=>s,...r}=n;return{"onUpdate:modelValue":I(s=>{T(a,t(s),r)},v),modelValue:a.value}}function D(e,n={}){const a=U(e);if(!a)return console.warn(`Sort [${e}] does not exist.`);const{debounce:v=0,transform:t,...r}=n;return{onClick:I(()=>{var s;F(a,(s=f.value)==null?void 0:s.direction,r)},v)}}function Y(e={}){const{debounce:n=700,transform:a,...v}=e;return{"onUpdate:modelValue":I(t=>{g(t,v)},n),modelValue:o.value.term??""}}function H(e,n={}){const a=C(e);if(!a)return console.warn(`Match [${e}] does not exist.`);const{debounce:v=0,transform:t,...r}=n;return{"onUpdate:modelValue":I(s=>{V(s,r)},v),modelValue:K(a),value:a.name}}return i.reactive({filters:h,sorts:x,searches:w,currentFilters:k,currentSort:f,currentSearches:y,isSortable:m,isSearchable:u,isMatchable:c,isFiltering:N,isSorting:X,isSearching:K,getFilter:R,getSort:U,getSearch:C,apply:b,applyFilter:T,applySort:F,applySearch:g,applyMatch:V,clearFilter:O,clearSort:W,clearSearch:q,clearMatch:z,reset:E,bindFilter:G,bindSort:D,bindSearch:Y,bindMatch:H,stringValue:j,omitValue:P,toggleValue:B,delimitArray:M})}function re(l,p,d={}){if(!(l!=null&&l[p]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:o={},...m}={only:[...d.only??[],p.toString()],...d},u=i.computed(()=>l[p]),c=te(),h=ae(l,p,m),x=i.computed(()=>u.value.id??null),w=i.computed(()=>u.value.meta),k=i.computed(()=>u.value.views??[]),f=i.computed(()=>u.value.emptyState??null),y=i.computed(()=>u.value.placeholder??null),M=i.computed(()=>!!u.value.emptyState),j=i.computed(()=>!!u.value.page&&!!u.value.record),P=i.computed(()=>!!u.value.column),$=i.computed(()=>u.value.columns.filter(({active:t,hidden:r})=>t&&!r).map(t=>{var r;return{...t,isSorting:!!((r=t.sort)!=null&&r.active),toggleSort:(s={})=>h.applySort(t.sort,null,s)}})),B=i.computed(()=>u.value.columns.filter(({hidden:t})=>!t).map(t=>({...t,toggle:(r={})=>e(t.name,r)}))),R=i.computed(()=>u.value.records.map(t=>({operations:z(t.operations),classes:t.classes??null,default:(r={})=>{const s=t.operations.find(({default:L})=>L);s&&G(s,t,r)},select:()=>c.select(g(t)),deselect:()=>c.deselect(g(t)),toggle:()=>c.toggle(g(t)),selected:c.selected(g(t)),bind:()=>c.bind(g(t)),entry:r=>V(t,r),value:r=>O(t,r),extra:r=>W(t,r)}))),U=i.computed(()=>!!u.value.operations.inline),C=i.computed(()=>z(u.value.operations.bulk)),N=i.computed(()=>z(u.value.operations.page)),X=i.computed(()=>u.value.pages.find(({active:t})=>t)),K=i.computed(()=>u.value.pages),b=i.computed(()=>({...u.value.paginate,next:(t={})=>{"nextLink"in b.value&&b.value.nextLink&&E(b.value.nextLink,t)},previous:(t={})=>{"prevLink"in b.value&&b.value.prevLink&&E(b.value.prevLink,t)},first:(t={})=>{"firstLink"in b.value&&b.value.firstLink&&E(b.value.firstLink,t)},last:(t={})=>{"lastLink"in b.value&&b.value.lastLink&&E(b.value.lastLink,t)},..."links"in u.value.paginate&&u.value.paginate.links?{links:u.value.paginate.links.map(t=>({...t,navigate:(r={})=>t.url&&E(t.url,r)}))}:{}})),T=i.computed(()=>u.value.records.length>0&&u.value.records.every(t=>c.selected(g(t))));function F(t){return typeof t=="string"?t:t.name}function g(t){var r;return(r=V(t,u.value.key))==null?void 0:r.v}function V(t,r){const s=F(r);return s in t&&s!=="classes"?t[s]:null}function O(t,r){var s;return((s=V(t,r))==null?void 0:s.v)??null}function W(t,r){var s;return(s=V(t,r))==null?void 0:s.e}function q(t,r={},s={}){return Q(t,u.value.endpoint,x.value,r,{...m,...s})}function z(t){return ee(t,u.value.endpoint,x.value,m)}function E(t,r={}){S.router.visit(t,{preserveScroll:!0,preserveState:!0,...m,...r,method:"get"})}function G(t,r,s={}){var J;q(t,{record:g(r)},s)||(J=o==null?void 0:o[t.name])==null||J.call(o,r)}function D(t,r={}){q(t,{all:c.selection.value.all,only:Array.from(c.selection.value.only),except:Array.from(c.selection.value.except)},{...r,onSuccess:s=>{var L;(L=r.onSuccess)==null||L.call(r,s),t.keepSelected||c.deselectAll()}})}function Y(t,r={},s={}){return q(t,r,s)}function H(t,r={}){if(!j.value)return console.warn("The table does not support pagination changes.");S.router.reload({...m,...r,data:{[u.value.record]:t.value,[u.value.page]:void 0}})}function e(t,r={}){if(!P.value)return console.warn("The table does not support column toggling.");const s=F(t);if(!s)return console.log(`Column [${t}] does not exist.`);const L=h.toggleValue(s,$.value.map(({name:J})=>J));S.router.reload({...m,...r,data:{[u.value.column]:h.delimitArray(L)}})}function n(){c.select(...u.value.records.map(t=>g(t)))}function a(){c.deselect(...u.value.records.map(t=>g(t)))}function v(){return{"onUpdate:modelValue":t=>{t?n():a()},modelValue:T.value}}return i.reactive({id:x,meta:w,views:k,emptyState:f,placeholder:y,isEmpty:M,isPageable:j,isToggleable:P,getEntry:V,getValue:O,getExtra:W,getRecordKey:g,headings:$,columns:B,records:R,inline:U,bulk:C,page:N,pages:K,currentPage:X,paginator:b,executeInline:G,executeBulk:D,executePage:Y,applyPage:H,selection:c.selection,select:t=>c.select(g(t)),deselect:t=>c.deselect(g(t)),selectPage:n,deselectPage:a,toggle:t=>c.toggle(g(t)),selected:t=>c.selected(g(t)),selectAll:c.selectAll,deselectAll:c.deselectAll,isPageSelected:T,hasSelected:c.hasSelected,bindCheckbox:t=>c.bind(g(t)),bindPage:v,bindAll:c.bindAll,...h})}function oe(l,p){return l?typeof l=="object"?l.type===p:l===p:!1}A.is=oe,A.useTable=re,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(A,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("@inertiajs/vue3")):typeof define=="function"&&define.amd?define(["exports","vue","@inertiajs/vue3"],i):(A=typeof globalThis<"u"?globalThis:A||self,i(A["@honed/table"]={},A.Vue,A.Inertia))})(this,function(A,i,S){"use strict";function _(l,p,d,o={}){return l.route?(S.router.visit(l.route.url,{...o,method:l.route.method}),!0):l.action&&p?(S.router.post(p,{...d,name:l.name,type:l.type},o),!0):!1}function Q(l,p,d,o={},m={}){return _(l,p,{...o,id:d??void 0},m)}function ee(l,p,d,o={}){return l.map(m=>({...m,execute:(u={},c={})=>Q(m,p,d,u,{...o,...c})}))}function te(){const l=i.ref({all:!1,only:new Set,except:new Set});function p(){l.value.all=!0,l.value.only.clear(),l.value.except.clear()}function d(){l.value.all=!1,l.value.only.clear(),l.value.except.clear()}function o(...f){f.forEach(y=>l.value.except.delete(y)),f.forEach(y=>l.value.only.add(y))}function m(...f){f.forEach(y=>l.value.except.add(y)),f.forEach(y=>l.value.only.delete(y))}function u(f,y){if(c(f)||y===!1)return m(f);if(!c(f)||y===!0)return o(f)}function c(f){return l.value.all?!l.value.except.has(f):l.value.only.has(f)}const h=i.computed(()=>l.value.all&&l.value.except.size===0),x=i.computed(()=>l.value.only.size>0||h.value);function w(f){return{"onUpdate:modelValue":y=>{y?o(f):m(f)},modelValue:c(f),value:f}}function k(){return{"onUpdate:modelValue":f=>{f?p():d()},modelValue:h.value}}return{allSelected:h,selection:l,hasSelected:x,selectAll:p,deselectAll:d,select:o,deselect:m,toggle:u,selected:c,bind:w,bindAll:k}}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Z=()=>{};function ne(l,p){function d(...o){return new Promise((m,u)=>{Promise.resolve(l(()=>p.apply(this,o),{fn:p,thisArg:this,args:o})).then(m).catch(u)})}return d}function le(l,p={}){let d,o,m=Z;const u=h=>{clearTimeout(h),m(),m=Z};let c;return h=>{const x=i.toValue(l),w=i.toValue(p.maxWait);return d&&u(d),x<=0||w!==void 0&&w<=0?(o&&(u(o),o=null),Promise.resolve(h())):new Promise((k,f)=>{m=p.rejectOnCancel?f:k,c=h,w&&!o&&(o=setTimeout(()=>{d&&u(d),o=null,k(c())},w)),d=setTimeout(()=>{o&&u(o),o=null,k(h())},x)})}}function I(l,p=200,d={}){return ne(le(p,d),l)}function ae(l,p,d={}){if(!(l!=null&&l[p]))throw new Error("The refine must be provided with valid props and key.");const o=i.computed(()=>l[p]),m=i.computed(()=>!!o.value.sort),u=i.computed(()=>!!o.value.search),c=i.computed(()=>!!o.value.match),h=i.computed(()=>{var e;return(e=o.value.filters)==null?void 0:e.map(n=>({...n,apply:(a,v={})=>T(n,a,v),clear:(a={})=>O(n,a),bind:()=>G(n.name)}))}),x=i.computed(()=>{var e;return(e=o.value.sorts)==null?void 0:e.map(n=>({...n,apply:(a={})=>F(n,n.direction,a),clear:(a={})=>W(a),bind:()=>D(n)}))}),w=i.computed(()=>{var e;return(e=o.value.searches)==null?void 0:e.map(n=>({...n,apply:(a={})=>V(n,a),clear:(a={})=>V(n,a),bind:()=>H(n)}))}),k=i.computed(()=>h.value.filter(({active:e})=>e)),f=i.computed(()=>x.value.find(({active:e})=>e)),y=i.computed(()=>w.value.filter(({active:e})=>e));function M(e){return Array.isArray(e)?e.join(o.value.delimiter):e}function j(e){return typeof e!="string"?e:e.trim().replace(/\s+/g,"+")}function P(e){if(!["",null,void 0,[]].includes(e))return e}function $(e){return[M,j,P].reduce((n,a)=>a(n),e)}function B(e,n){return n=Array.isArray(n)?n:[n],n.includes(e)?n.filter(a=>a!==e):[...n,e]}function R(e){return typeof e!="string"?e:h.value.find(({name:n})=>n===e)}function U(e,n=null){return typeof e!="string"?e:x.value.find(({name:a,direction:v})=>a===e&&v===n)}function C(e){return typeof e!="string"?e:w.value.find(({name:n})=>n===e)}function N(e){return e?typeof e=="string"?k.value.some(n=>n.name===e):e.active:!!k.value.length}function X(e){var n;return e?typeof e=="string"?((n=f.value)==null?void 0:n.name)===e:e.active:!!f.value}function K(e){var n;return e?typeof e=="string"?(n=y.value)==null?void 0:n.some(a=>a.name===e):e.active:!!o.value.term}function b(e,n={}){const a=Object.fromEntries(Object.entries(e).map(([v,t])=>[v,$(t)]));S.router.reload({...d,...n,data:a})}function T(e,n,a={}){const v=R(e);if(!v)return console.warn(`Filter [${e}] does not exist.`);S.router.reload({...d,...a,data:{[v.name]:$(n)}})}function F(e,n=null,a={}){if(!m.value)return console.warn("Refine cannot perform sorting.");const v=U(e,n);if(!v)return console.warn(`Sort [${e}] does not exist.`);S.router.reload({...d,...a,data:{[o.value.sort]:P(v.next)}})}function g(e,n={}){if(!u.value)return console.warn("Refine cannot perform searching.");e=[j,P].reduce((a,v)=>v(a),e),S.router.reload({...d,...n,data:{[o.value.search]:e}})}function V(e,n={}){if(!c.value||!u.value)return console.warn("Refine cannot perform matching.");const a=C(e);if(!a)return console.warn(`Match [${e}] does not exist.`);const v=B(a.name,y.value.map(({name:t})=>t));S.router.reload({...d,...n,data:{[o.value.match]:M(v)}})}function O(e,n={}){if(e)return T(e,null,n);S.router.reload({...d,...n,data:Object.fromEntries(k.value.map(({name:a})=>[a,null]))})}function W(e={}){if(!m.value)return console.warn("Refine cannot perform sorting.");S.router.reload({...d,...e,data:{[o.value.sort]:null}})}function q(e={}){g(null,e)}function z(e={}){if(!c.value)return console.warn("Refine cannot perform matching.");S.router.reload({...d,...e,data:{[o.value.match]:null}})}function E(e={}){var n;S.router.reload({...d,...e,data:{[o.value.search??""]:void 0,[o.value.sort??""]:void 0,[o.value.match??""]:void 0,...Object.fromEntries(((n=o.value.filters)==null?void 0:n.map(a=>[a.name,void 0]))??[])}})}function G(e,n={}){const a=R(e);if(!a)return console.warn(`Filter [${e}] does not exist.`);const{debounce:v=250,transform:t=s=>s,...r}=n;return{"onUpdate:modelValue":I(s=>{T(a,t(s),r)},v),modelValue:a.value}}function D(e,n={}){const a=U(e);if(!a)return console.warn(`Sort [${e}] does not exist.`);const{debounce:v=0,transform:t,...r}=n;return{onClick:I(()=>{var s;F(a,(s=f.value)==null?void 0:s.direction,r)},v)}}function Y(e={}){const{debounce:n=700,transform:a,...v}=e;return{"onUpdate:modelValue":I(t=>{g(t,v)},n),modelValue:o.value.term??""}}function H(e,n={}){const a=C(e);if(!a)return console.warn(`Match [${e}] does not exist.`);const{debounce:v=0,transform:t,...r}=n;return{"onUpdate:modelValue":I(s=>{V(s,r)},v),modelValue:K(a),value:a.name}}return i.reactive({filters:h,sorts:x,searches:w,currentFilters:k,currentSort:f,currentSearches:y,isSortable:m,isSearchable:u,isMatchable:c,isFiltering:N,isSorting:X,isSearching:K,getFilter:R,getSort:U,getSearch:C,apply:b,applyFilter:T,applySort:F,applySearch:g,applyMatch:V,clearFilter:O,clearSort:W,clearSearch:q,clearMatch:z,reset:E,bindFilter:G,bindSort:D,bindSearch:Y,bindMatch:H,stringValue:j,omitValue:P,toggleValue:B,delimitArray:M})}function re(l,p,d={}){if(!(l!=null&&l[p]))throw new Error("The table must be provided with valid props and key.");const{recordOperations:o={},...m}={only:[...d.only??[],p.toString()],...d},u=i.computed(()=>l[p]),c=te(),h=ae(l,p,m),x=i.computed(()=>u.value.id??null),w=i.computed(()=>u.value.meta),k=i.computed(()=>u.value.views??[]),f=i.computed(()=>u.value.emptyState??null),y=i.computed(()=>u.value.placeholder??null),M=i.computed(()=>!!u.value.emptyState),j=i.computed(()=>!!u.value.page&&!!u.value.record),P=i.computed(()=>!!u.value.column),$=i.computed(()=>u.value.columns.filter(({active:t,hidden:r})=>t&&!r).map(t=>{var r;return{...t,isSorting:!!((r=t.sort)!=null&&r.active),toggleSort:(s={})=>h.applySort(t.sort,null,s)}})),B=i.computed(()=>u.value.columns.filter(({hidden:t})=>!t).map(t=>({...t,toggle:(r={})=>e(t.name,r)}))),R=i.computed(()=>u.value.records.map(t=>({operations:z(t.operations),class:t.class??null,default:(r={})=>{const s=t.operations.find(({default:L})=>L);s&&G(s,t,r)},select:()=>c.select(g(t)),deselect:()=>c.deselect(g(t)),toggle:()=>c.toggle(g(t)),selected:c.selected(g(t)),bind:()=>c.bind(g(t)),entry:r=>V(t,r),value:r=>O(t,r),extra:r=>W(t,r)}))),U=i.computed(()=>!!u.value.operations.inline),C=i.computed(()=>z(u.value.operations.bulk)),N=i.computed(()=>z(u.value.operations.page)),X=i.computed(()=>u.value.pages.find(({active:t})=>t)),K=i.computed(()=>u.value.pages),b=i.computed(()=>({...u.value.paginate,next:(t={})=>{"nextLink"in b.value&&b.value.nextLink&&E(b.value.nextLink,t)},previous:(t={})=>{"prevLink"in b.value&&b.value.prevLink&&E(b.value.prevLink,t)},first:(t={})=>{"firstLink"in b.value&&b.value.firstLink&&E(b.value.firstLink,t)},last:(t={})=>{"lastLink"in b.value&&b.value.lastLink&&E(b.value.lastLink,t)},..."links"in u.value.paginate&&u.value.paginate.links?{links:u.value.paginate.links.map(t=>({...t,navigate:(r={})=>t.url&&E(t.url,r)}))}:{}})),T=i.computed(()=>u.value.records.length>0&&u.value.records.every(t=>c.selected(g(t))));function F(t){return typeof t=="string"?t:t.name}function g(t){var r;return(r=V(t,u.value.key))==null?void 0:r.v}function V(t,r){const s=F(r);return s in t&&s!=="classes"?t[s]:null}function O(t,r){var s;return((s=V(t,r))==null?void 0:s.v)??null}function W(t,r){var s;return(s=V(t,r))==null?void 0:s.e}function q(t,r={},s={}){return Q(t,u.value.endpoint,x.value,r,{...m,...s})}function z(t){return ee(t,u.value.endpoint,x.value,m)}function E(t,r={}){S.router.visit(t,{preserveScroll:!0,preserveState:!0,...m,...r,method:"get"})}function G(t,r,s={}){var J;q(t,{record:g(r)},s)||(J=o==null?void 0:o[t.name])==null||J.call(o,r)}function D(t,r={}){q(t,{all:c.selection.value.all,only:Array.from(c.selection.value.only),except:Array.from(c.selection.value.except)},{...r,onSuccess:s=>{var L;(L=r.onSuccess)==null||L.call(r,s),t.keepSelected||c.deselectAll()}})}function Y(t,r={},s={}){return q(t,r,s)}function H(t,r={}){if(!j.value)return console.warn("The table does not support pagination changes.");S.router.reload({...m,...r,data:{[u.value.record]:t.value,[u.value.page]:void 0}})}function e(t,r={}){if(!P.value)return console.warn("The table does not support column toggling.");const s=F(t);if(!s)return console.log(`Column [${t}] does not exist.`);const L=h.toggleValue(s,$.value.map(({name:J})=>J));S.router.reload({...m,...r,data:{[u.value.column]:h.delimitArray(L)}})}function n(){c.select(...u.value.records.map(t=>g(t)))}function a(){c.deselect(...u.value.records.map(t=>g(t)))}function v(){return{"onUpdate:modelValue":t=>{t?n():a()},modelValue:T.value}}return i.reactive({id:x,meta:w,views:k,emptyState:f,placeholder:y,isEmpty:M,isPageable:j,isToggleable:P,getEntry:V,getValue:O,getExtra:W,getRecordKey:g,headings:$,columns:B,records:R,inline:U,bulk:C,page:N,pages:K,currentPage:X,paginator:b,executeInline:G,executeBulk:D,executePage:Y,applyPage:H,selection:c.selection,select:t=>c.select(g(t)),deselect:t=>c.deselect(g(t)),selectPage:n,deselectPage:a,toggle:t=>c.toggle(g(t)),selected:t=>c.selected(g(t)),selectAll:c.selectAll,deselectAll:c.deselectAll,isPageSelected:T,hasSelected:c.hasSelected,bindCheckbox:t=>c.bind(g(t)),bindPage:v,bindAll:c.bindAll,...h})}function oe(l,p){return l?typeof l=="object"?l.type===p:l===p:!1}A.is=oe,A.useTable=re,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|