svelte-tably 1.5.0 → 1.6.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/__svelte-origin-runtime.js +1 -0
- package/dist/column/Column.svelte +22 -23
- package/dist/column/Column.svelte.d.ts +14 -31
- package/dist/column/column-state.svelte.d.ts +260 -64
- package/dist/column/column-state.svelte.js +123 -64
- package/dist/expandable/Expandable.svelte +31 -11
- package/dist/expandable/Expandable.svelte.d.ts +14 -30
- package/dist/expandable/expandable-state.svelte.d.ts +49 -40
- package/dist/expandable/expandable-state.svelte.js +50 -26
- package/dist/index.d.ts +19 -14
- package/dist/index.js +7 -0
- package/dist/panel/Panel.svelte +18 -9
- package/dist/panel/Panel.svelte.d.ts +14 -30
- package/dist/panel/panel-state.svelte.d.ts +44 -17
- package/dist/panel/panel-state.svelte.js +43 -18
- package/dist/row/Row.svelte +22 -12
- package/dist/row/Row.svelte.d.ts +14 -30
- package/dist/row/row-state.svelte.d.ts +64 -28
- package/dist/row/row-state.svelte.js +57 -31
- package/dist/table/Table.svelte +207 -150
- package/dist/table/Table.svelte.d.ts +14 -84
- package/dist/table/csv.d.ts +4 -4
- package/dist/table/data.svelte.d.ts +42 -6
- package/dist/table/data.svelte.js +159 -85
- package/dist/table/table-state.svelte.d.ts +278 -54
- package/dist/table/table-state.svelte.js +244 -219
- package/dist/table/virtualization.svelte.d.ts +3 -3
- package/dist/table/virtualization.svelte.js +32 -3
- package/dist/test/GenericTest.svelte +8 -0
- package/dist/test/GenericTest.svelte.d.ts +21 -0
- package/dist/test/generic-test-state.svelte.d.ts +12 -0
- package/dist/test/generic-test-state.svelte.js +9 -0
- package/dist/utility.svelte.d.ts +7 -7
- package/dist/utility.svelte.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createAttachmentKey as P}from"svelte/attachments";function V(H,J){let C=J&&typeof J==="object"?J:{},U={},X=new Set;return new Proxy(C,{get(Q,z){if(X.has(z))return U[z];if(typeof z==="symbol")return Q[z];let Y=Q[z];if(Y===void 0&&z in H&&H[z].hasDefault)return H[z].default;return Y},set(Q,z,Y){U[z]=Y;try{Q[z]=Y}catch{X.add(z)}return!0},has(Q,z){return typeof z==="symbol"?z in Q:(z in Q)||(z in H)},ownKeys(Q){return[...new Set([...Reflect.ownKeys(Q),...Object.keys(H)])]},getOwnPropertyDescriptor(Q,z){if(typeof z==="symbol")return Object.getOwnPropertyDescriptor(Q,z);if(z in Q)return Object.getOwnPropertyDescriptor(Q,z);if(z in H)return{configurable:!0,enumerable:!0,value:H[z].hasDefault?H[z].default:void 0};return}})}function E(H,J=new Set){if(J.has(H))return{};J.add(H);let C=H.__parents||[],U={};for(let X of C)Object.assign(U,E(X,J));return Object.assign(U,H.__attrSchema),U}function S(H,J,C=new Set){let U={};for(let X of J){if(C.has(X))continue;Object.assign(U,E(X,new Set(C)))}return Object.assign(U,H),U}function k(H){let{__attrSchema:J,__parents:C=[],__create:U,__onInit:X,__attachments:Q={}}=H;function z(Y,...N){let G,q;if(Y===null||Y===void 0)G={},q=N;else if(typeof Y!=="object"||Array.isArray(Y))G={},q=[Y,...N];else G=Y,q=N;let j=S(J,C),b=V(j,G),B=C.map((Z)=>Z(b)),F=B.length===1?B[0]:B.length>1?B:void 0,D=U(b,F);if(D===null||D===void 0)throw Error("[svelte-origin] __create returned null/undefined");let R=D,T=F?new Proxy(R,{get(Z,$,L){if($ in Z){let x=Reflect.get(Z,$,L);return typeof x==="function"?x.bind(L):x}if(F&&$ in F){let x=Reflect.get(F,$,F);return typeof x==="function"?x.bind(F):x}return},has(Z,$){return $ in Z||F&&$ in F},ownKeys(Z){let $=Reflect.ownKeys(Z);return F?[...new Set([...$,...Reflect.ownKeys(F)])]:$},getOwnPropertyDescriptor(Z,$){return Reflect.getOwnPropertyDescriptor(Z,$)||(F?Reflect.getOwnPropertyDescriptor(F,$):void 0)}}):R;if(X){let Z=X.call(T,...q);if(typeof Z==="function")Object.defineProperty(T,"__cleanup",{value:Z,writable:!0,enumerable:!0,configurable:!0})}let K=new Map;for(let Z of Object.keys(Q))K.set(Z,P());return Object.defineProperty(T,"$attachments",{get(){let Z={};for(let[$,L]of Object.entries(Q))Z[K.get($)]=(x)=>L.call(T,x);for(let $ of Object.getOwnPropertySymbols(G)){let L=G[$];if(typeof L==="function")Z[$]=L}return Z},enumerable:!0,configurable:!0}),T}if(Object.defineProperty(z,"__origin",{value:!0,writable:!1,enumerable:!0}),Object.defineProperty(z,"__attrSchema",{value:J,writable:!1,enumerable:!0}),Object.defineProperty(z,"__parents",{value:C,writable:!1,enumerable:!0}),Object.defineProperty(z,"__create",{value:U,writable:!1,enumerable:!0}),X)Object.defineProperty(z,"__onInit",{value:X,writable:!1,enumerable:!0});return z}function _(H,J){let U=E(H),X={},Q=new Set,z=(G,q)=>{X[G]=q;try{return J[G]=q,!0}catch{return Q.add(G),!1}},Y={},N=(G,q)=>{if(Object.prototype.hasOwnProperty.call(Y,G))return;let j={get(){return Q.has(G)?X[G]:J[G]},enumerable:!0,configurable:!0};if(q.bindable)j.set=function(b){z(G,b)};Object.defineProperty(Y,G,j)};for(let[G,q]of Object.entries(U)){let j=J[G];if(!q.bindable||!q.hasDefault||j!==void 0)N(G,q)}for(let G of Object.getOwnPropertySymbols(J))Object.defineProperty(Y,G,{get(){return J[G]},enumerable:!1,configurable:!0});return new Proxy(Y,{get(G,q){if(typeof q==="string"){if(Q.has(q))return X[q];if(q in U)return J[q]}return q in G?G[q]:J[q]},set(G,q,j){if(typeof q==="string"&&q in U){if(!Object.prototype.hasOwnProperty.call(Y,q))N(q,U[q]);if(U[q].bindable)z(q,j);return!0}if(q in G){try{G[q]=j}catch{}return!0}try{J[q]=j}catch{if(typeof q==="string")X[q]=j,Q.add(q)}return!0},has(G,q){return q in G||q in J},ownKeys(){return[...Object.keys(Y),...Object.getOwnPropertySymbols(J)]},getOwnPropertyDescriptor(G,q){return q in G?Object.getOwnPropertyDescriptor(G,q):Object.getOwnPropertyDescriptor(J,q)}})}function w(H){return{__attrs:!0,__attrSchema:H.__attrSchema,__parents:H.__parents||[]}}var M=Symbol.for("svelte-origin:bindable");function I(H,J){return{[M]:!0,get:H,set:J}}function W(H){return H!==null&&typeof H==="object"&&M in H}function d(H,J){let C=typeof H==="function"&&!("__origin"in H)?H():H,U={};for(let[X,Q]of Object.entries(J))if(W(Q))Object.defineProperty(U,X,{get(){return Q.get()},set(z){Q.set(z)},enumerable:!0,configurable:!0});else Object.defineProperty(U,X,{get(){return Q},enumerable:!0,configurable:!0});return C(U)}export{d as __createOriginInstance,k as __createOrigin,w as __createAttrs,I as __bindable,_ as __attrsFor};
|
|
@@ -9,31 +9,30 @@
|
|
|
9
9
|
-->
|
|
10
10
|
|
|
11
11
|
<script module lang='ts'>
|
|
12
|
-
|
|
13
|
-
export function getDefaultHeader<T, V>(title: string) {
|
|
14
|
-
return (
|
|
15
|
-
(anchor: Comment) => snippetLiteral(defaultHeader)(anchor, () => title)
|
|
16
|
-
) as unknown as () => any
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
</script>
|
|
20
13
|
|
|
21
|
-
<script lang='ts'>
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
<script lang='ts' generics='T, V'>
|
|
15
|
+
import { onMount, onDestroy, untrack } from 'svelte'
|
|
16
|
+
import { ColumnState } from './column-state.svelte.js'
|
|
17
|
+
|
|
18
|
+
let { id: ___id = "", header: ___header, row: ___row, statusbar: ___statusbar, sticky: ___sticky = false, show: ___show = true, sortby: ___sortby = false, width: ___width = 150, fixed: ___fixed = false, value: ___value, sort: ___sort = false, resizeable: ___resizeable = true, filter: ___filter, style: ___style, class: ___class, onclick: ___onclick = undefined as
|
|
19
|
+
| ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void)
|
|
20
|
+
| undefined, pad: ___pad, _table: ____table }: $origin.Props<ReturnType<typeof ColumnState<T, V>>> = $props()
|
|
21
|
+
let column = ColumnState<T, V>()({ get id() { return ___id }, get header() { return ___header }, get row() { return ___row }, get statusbar() { return ___statusbar }, get sticky() { return ___sticky }, get show() { return ___show }, get sortby() { return ___sortby }, get width() { return ___width }, get fixed() { return ___fixed }, get value() { return ___value }, get sort() { return ___sort }, get resizeable() { return ___resizeable }, get filter() { return ___filter }, get style() { return ___style }, get class() { return ___class }, get onclick() { return ___onclick }, get pad() { return ___pad }, get _table() { return ____table } })
|
|
22
|
+
|
|
23
|
+
// Initialize column on mount (runs once)
|
|
24
|
+
onMount(() => {
|
|
25
|
+
if (typeof column.init === 'function') {
|
|
26
|
+
column.init()
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Workaround for svelte-origin not calling cleanup on component destroy
|
|
31
|
+
onDestroy(() => {
|
|
32
|
+
if (typeof column.cleanup === 'function') {
|
|
33
|
+
column.cleanup()
|
|
34
|
+
}
|
|
35
|
+
})
|
|
34
36
|
</script>
|
|
35
37
|
|
|
36
38
|
|
|
37
|
-
{#snippet defaultHeader(title: string)}
|
|
38
|
-
{title}
|
|
39
|
-
{/snippet}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
slots: {};
|
|
8
|
-
events: {};
|
|
9
|
-
};
|
|
10
|
-
declare class __sveltets_Render<T, V> {
|
|
11
|
-
props(): ReturnType<typeof $$render<T, V>>['props'];
|
|
12
|
-
events(): ReturnType<typeof $$render<T, V>>['events'];
|
|
13
|
-
slots(): ReturnType<typeof $$render<T, V>>['slots'];
|
|
14
|
-
bindings(): "";
|
|
15
|
-
exports(): {};
|
|
16
|
-
}
|
|
17
|
-
interface $$IsomorphicComponent {
|
|
18
|
-
new <T, V>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, V>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, V>['props']>, ReturnType<__sveltets_Render<T, V>['events']>, ReturnType<__sveltets_Render<T, V>['slots']>> & {
|
|
19
|
-
$$bindings?: ReturnType<__sveltets_Render<T, V>['bindings']>;
|
|
20
|
-
} & ReturnType<__sveltets_Render<T, V>['exports']>;
|
|
21
|
-
<T, V>(internal: unknown, props: ReturnType<__sveltets_Render<T, V>['props']> & {}): ReturnType<__sveltets_Render<T, V>['exports']>;
|
|
22
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
23
|
-
}
|
|
1
|
+
// Auto-generated by svelte-origin
|
|
2
|
+
// Do not edit manually - regenerated on save
|
|
3
|
+
|
|
4
|
+
import type { SvelteComponent } from 'svelte';
|
|
5
|
+
import type { ColumnState } from './column-state.svelte.js';
|
|
6
|
+
|
|
24
7
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* <Component />
|
|
8
|
+
* Props derived from ColumnState origin factory.
|
|
9
|
+
*
|
|
10
|
+
* Bindable props: none
|
|
11
|
+
* Generic parameters: <T, V>
|
|
30
12
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
type __Props<T, V> = $origin.Props<ReturnType<typeof ColumnState<T, V>>>;
|
|
14
|
+
|
|
15
|
+
declare class __component<T, V> extends SvelteComponent<__Props<T, V>> {}
|
|
16
|
+
export default __component;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import { type Snippet } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
2
|
+
import { type RowCtx } from "../table/table-state.svelte.js";
|
|
3
|
+
/** Creates a default header snippet that displays the title string */
|
|
4
|
+
export declare function getDefaultHeader<T>(title: string): Snippet<[ctx: HeaderCtx<T>]>;
|
|
5
|
+
export interface ColumnSelfRef {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly isHidden: boolean;
|
|
8
|
+
toggleVisiblity(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface ColumnTableRef {
|
|
11
|
+
dataState: {
|
|
12
|
+
current: unknown[];
|
|
13
|
+
sortBy(column: string): void;
|
|
14
|
+
};
|
|
15
|
+
positions: {
|
|
16
|
+
hidden: ColumnSelfRef[];
|
|
17
|
+
};
|
|
18
|
+
/** Internal: position state arrays for direct manipulation */
|
|
19
|
+
_positionsState: {
|
|
20
|
+
fixed: ColumnSelfRef[];
|
|
21
|
+
sticky: ColumnSelfRef[];
|
|
22
|
+
scroll: ColumnSelfRef[];
|
|
23
|
+
hidden: ColumnSelfRef[];
|
|
24
|
+
};
|
|
25
|
+
/** Internal: version counter for reactivity */
|
|
26
|
+
_positionsVersion: number;
|
|
27
|
+
/** Internal: callback to notify Table.svelte of changes */
|
|
28
|
+
_saveCallback?: () => void;
|
|
29
|
+
add(column: unknown): (() => void) | undefined;
|
|
30
|
+
}
|
|
9
31
|
export interface HeaderCtx<T> {
|
|
10
32
|
readonly data: T[];
|
|
11
33
|
/**
|
|
@@ -22,104 +44,278 @@ export interface RowColumnCtx<T, V> extends RowCtx<T> {
|
|
|
22
44
|
export type StatusbarCtx<T> = {
|
|
23
45
|
readonly data: T[];
|
|
24
46
|
};
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
export declare const ColumnState: <T, V = unknown>() => import("svelte-origin/globals").SvelteOriginFactory<{
|
|
48
|
+
props: import("svelte-origin/globals").SvelteOriginAttrsFactory<{
|
|
49
|
+
id: string;
|
|
50
|
+
header: Snippet<[ctx: HeaderCtx<T>]> | string | undefined;
|
|
51
|
+
row: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
52
|
+
statusbar: Snippet<[ctx: StatusbarCtx<T>]> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Is this column sticky by default?
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
sticky: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Is this column visible by default?
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
show: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Is this column sorted by default?
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
sortby: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The width of the column in pixels by default
|
|
70
|
+
* @default 150
|
|
71
|
+
*/
|
|
72
|
+
width: number;
|
|
73
|
+
/**
|
|
74
|
+
* Fixed is like sticky, but in its own category meant to not be moved/hidden ex. select-boxes
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
fixed: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The value of the row. Required for sorting/filtering
|
|
80
|
+
* @example row => row.name
|
|
81
|
+
*/
|
|
82
|
+
value: ((item: T) => V) | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Makes the column sortable. Sorts based of a sorting function.
|
|
85
|
+
*
|
|
86
|
+
* **Important** ``value``-attribute is required adjacent to this.
|
|
87
|
+
*
|
|
88
|
+
* If ``true`` uses the default ``.sort()`` algorithm.
|
|
89
|
+
*
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
sort: boolean | ((a: V, b: V) => number);
|
|
93
|
+
/**
|
|
94
|
+
* Is this column resizeable?
|
|
95
|
+
* Can not be resized if Table is marked as ``resizeable={false}``
|
|
96
|
+
* @default true
|
|
97
|
+
*/
|
|
98
|
+
resizeable: boolean;
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @example (value) => value.includes(search)
|
|
102
|
+
*/
|
|
103
|
+
filter: ((value: V) => boolean) | undefined;
|
|
104
|
+
/** Styling for the column element (td) */
|
|
105
|
+
style: string | undefined;
|
|
106
|
+
/** Class for the column element (td) */
|
|
107
|
+
class: string | undefined;
|
|
108
|
+
/** Event when the row-column is clicked */
|
|
109
|
+
onclick: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Pad child element of ``td``/``th`` instead of the column element itself.
|
|
112
|
+
* This ensures the child element "fills" the whole column.
|
|
113
|
+
* Ex. good if you want to make the column an anchor link ``<a href='...'>``
|
|
114
|
+
*/
|
|
115
|
+
pad: "row" | "header" | "statusbar" | "both" | undefined;
|
|
116
|
+
/** @internal */
|
|
117
|
+
_table: ColumnTableRef | undefined;
|
|
118
|
+
}> & {
|
|
119
|
+
id: string;
|
|
120
|
+
header: Snippet<[ctx: HeaderCtx<T>]> | string | undefined;
|
|
121
|
+
row: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
122
|
+
statusbar: Snippet<[ctx: StatusbarCtx<T>]> | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Is this column sticky by default?
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
sticky: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Is this column visible by default?
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
show: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Is this column sorted by default?
|
|
135
|
+
* @default false
|
|
136
|
+
*/
|
|
137
|
+
sortby: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The width of the column in pixels by default
|
|
140
|
+
* @default 150
|
|
141
|
+
*/
|
|
142
|
+
width: number;
|
|
143
|
+
/**
|
|
144
|
+
* Fixed is like sticky, but in its own category meant to not be moved/hidden ex. select-boxes
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
fixed: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* The value of the row. Required for sorting/filtering
|
|
150
|
+
* @example row => row.name
|
|
151
|
+
*/
|
|
152
|
+
value: ((item: T) => V) | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Makes the column sortable. Sorts based of a sorting function.
|
|
155
|
+
*
|
|
156
|
+
* **Important** ``value``-attribute is required adjacent to this.
|
|
157
|
+
*
|
|
158
|
+
* If ``true`` uses the default ``.sort()`` algorithm.
|
|
159
|
+
*
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
sort: boolean | ((a: V, b: V) => number);
|
|
163
|
+
/**
|
|
164
|
+
* Is this column resizeable?
|
|
165
|
+
* Can not be resized if Table is marked as ``resizeable={false}``
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
resizeable: boolean;
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @example (value) => value.includes(search)
|
|
172
|
+
*/
|
|
173
|
+
filter: ((value: V) => boolean) | undefined;
|
|
174
|
+
/** Styling for the column element (td) */
|
|
175
|
+
style: string | undefined;
|
|
176
|
+
/** Class for the column element (td) */
|
|
177
|
+
class: string | undefined;
|
|
178
|
+
/** Event when the row-column is clicked */
|
|
179
|
+
onclick: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Pad child element of ``td``/``th`` instead of the column element itself.
|
|
182
|
+
* This ensures the child element "fills" the whole column.
|
|
183
|
+
* Ex. good if you want to make the column an anchor link ``<a href='...'>``
|
|
184
|
+
*/
|
|
185
|
+
pad: "row" | "header" | "statusbar" | "both" | undefined;
|
|
186
|
+
/** @internal */
|
|
187
|
+
_table: ColumnTableRef | undefined;
|
|
188
|
+
};
|
|
189
|
+
_table: ColumnTableRef | undefined;
|
|
190
|
+
readonly id: any;
|
|
191
|
+
readonly table: any;
|
|
192
|
+
readonly snippets: {
|
|
193
|
+
header: any;
|
|
194
|
+
/** Title is the header-snippet, with header-ctx: ``{ header: false }`` */
|
|
195
|
+
title: Snippet | undefined;
|
|
196
|
+
row: any;
|
|
197
|
+
statusbar: any;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Variables that can be saved (e.g. localStorage)
|
|
201
|
+
* and re-provided, where these are default-fallbacks
|
|
202
|
+
*/
|
|
203
|
+
readonly defaults: {
|
|
204
|
+
sticky: any;
|
|
205
|
+
show: any;
|
|
206
|
+
sortby: any;
|
|
207
|
+
width: any;
|
|
208
|
+
};
|
|
209
|
+
/** Static options */
|
|
210
|
+
readonly options: {
|
|
211
|
+
fixed: any;
|
|
212
|
+
sort: any;
|
|
213
|
+
filter: any;
|
|
214
|
+
value: any;
|
|
215
|
+
resizeable: any;
|
|
216
|
+
style: any;
|
|
217
|
+
class: any;
|
|
218
|
+
onclick: any;
|
|
219
|
+
padRow: boolean;
|
|
220
|
+
padHeader: boolean;
|
|
221
|
+
padStatusbar: boolean;
|
|
222
|
+
};
|
|
223
|
+
/** Whether this column is currently hidden */
|
|
224
|
+
readonly isHidden: any;
|
|
225
|
+
toggleVisiblity(): void;
|
|
226
|
+
/** Stored cleanup function */
|
|
227
|
+
_cleanup: (() => void) | undefined;
|
|
228
|
+
/** Call to remove this column from the table */
|
|
229
|
+
cleanup(): void;
|
|
230
|
+
init(): (() => void) | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
id: string;
|
|
233
|
+
header: Snippet<[ctx: HeaderCtx<T>]> | string | undefined;
|
|
234
|
+
row: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
235
|
+
statusbar: Snippet<[ctx: StatusbarCtx<T>]> | undefined;
|
|
31
236
|
/**
|
|
32
237
|
* Is this column sticky by default?
|
|
33
238
|
* @default false
|
|
34
|
-
|
|
35
|
-
sticky
|
|
239
|
+
*/
|
|
240
|
+
sticky: boolean;
|
|
36
241
|
/**
|
|
37
242
|
* Is this column visible by default?
|
|
38
243
|
* @default true
|
|
39
244
|
*/
|
|
40
|
-
show
|
|
245
|
+
show: boolean;
|
|
41
246
|
/**
|
|
42
247
|
* Is this column sorted by default?
|
|
43
248
|
* @default false
|
|
44
|
-
|
|
45
|
-
sortby
|
|
249
|
+
*/
|
|
250
|
+
sortby: boolean;
|
|
46
251
|
/**
|
|
47
252
|
* The width of the column in pixels by default
|
|
48
253
|
* @default 150
|
|
49
254
|
*/
|
|
50
|
-
width
|
|
51
|
-
};
|
|
52
|
-
type ColumnOptions<T, V> = {
|
|
255
|
+
width: number;
|
|
53
256
|
/**
|
|
54
|
-
* Fixed is like sticky, but in its own category
|
|
257
|
+
* Fixed is like sticky, but in its own category meant to not be moved/hidden ex. select-boxes
|
|
55
258
|
* @default false
|
|
56
|
-
|
|
57
|
-
fixed
|
|
259
|
+
*/
|
|
260
|
+
fixed: boolean;
|
|
58
261
|
/**
|
|
59
262
|
* The value of the row. Required for sorting/filtering
|
|
60
263
|
* @example row => row.name
|
|
61
|
-
|
|
62
|
-
value
|
|
264
|
+
*/
|
|
265
|
+
value: ((item: T) => V) | undefined;
|
|
63
266
|
/**
|
|
64
267
|
* Makes the column sortable. Sorts based of a sorting function.
|
|
65
268
|
*
|
|
66
|
-
* **Important**
|
|
269
|
+
* **Important** ``value``-attribute is required adjacent to this.
|
|
67
270
|
*
|
|
68
|
-
* If
|
|
271
|
+
* If ``true`` uses the default ``.sort()`` algorithm.
|
|
69
272
|
*
|
|
70
273
|
* @default false
|
|
71
|
-
|
|
72
|
-
sort
|
|
274
|
+
*/
|
|
275
|
+
sort: boolean | ((a: V, b: V) => number);
|
|
73
276
|
/**
|
|
74
277
|
* Is this column resizeable?
|
|
75
|
-
* Can not be resized if Table is marked as
|
|
278
|
+
* Can not be resized if Table is marked as ``resizeable={false}``
|
|
76
279
|
* @default true
|
|
77
|
-
|
|
78
|
-
resizeable
|
|
280
|
+
*/
|
|
281
|
+
resizeable: boolean;
|
|
79
282
|
/**
|
|
80
283
|
*
|
|
81
284
|
* @example (value) => value.includes(search)
|
|
82
|
-
|
|
83
|
-
filter
|
|
285
|
+
*/
|
|
286
|
+
filter: ((value: V) => boolean) | undefined;
|
|
84
287
|
/** Styling for the column element (td) */
|
|
85
|
-
style
|
|
288
|
+
style: string | undefined;
|
|
86
289
|
/** Class for the column element (td) */
|
|
87
|
-
class
|
|
290
|
+
class: string | undefined;
|
|
88
291
|
/** Event when the row-column is clicked */
|
|
89
|
-
onclick
|
|
292
|
+
onclick: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
90
293
|
/**
|
|
91
|
-
* Pad child element of
|
|
294
|
+
* Pad child element of ``td``/``th`` instead of the column element itself.
|
|
92
295
|
* This ensures the child element "fills" the whole column.
|
|
93
|
-
* Ex. good if you want to make the column an anchor link
|
|
94
|
-
|
|
95
|
-
pad
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** Title is the header-snippet, with header-ctx: `{ header: false }` */
|
|
107
|
-
title: (...args: any[]) => any;
|
|
296
|
+
* Ex. good if you want to make the column an anchor link ``<a href='...'>``
|
|
297
|
+
*/
|
|
298
|
+
pad: "row" | "header" | "statusbar" | "both" | undefined;
|
|
299
|
+
/** @internal */
|
|
300
|
+
_table: ColumnTableRef | undefined;
|
|
301
|
+
}>;
|
|
302
|
+
/** ColumnInstance interface - defined explicitly to avoid circular ReturnType issues */
|
|
303
|
+
export interface ColumnInstance<T = unknown, V = unknown> {
|
|
304
|
+
readonly id: string;
|
|
305
|
+
readonly table: ColumnTableRef;
|
|
306
|
+
readonly snippets: {
|
|
307
|
+
header: Snippet<[ctx: HeaderCtx<T>]> | undefined;
|
|
308
|
+
title: Snippet | undefined;
|
|
108
309
|
row: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
109
310
|
statusbar: Snippet<[ctx: StatusbarCtx<T>]> | undefined;
|
|
110
311
|
};
|
|
111
|
-
|
|
112
|
-
* Variables that can be saved (e.g. localStorage)
|
|
113
|
-
* and re-provided, where these are default-fallbacks
|
|
114
|
-
*/
|
|
115
|
-
defaults: {
|
|
312
|
+
readonly defaults: {
|
|
116
313
|
sticky: boolean;
|
|
117
314
|
show: boolean;
|
|
118
315
|
sortby: boolean;
|
|
119
316
|
width: number;
|
|
120
317
|
};
|
|
121
|
-
|
|
122
|
-
options: {
|
|
318
|
+
readonly options: {
|
|
123
319
|
fixed: boolean;
|
|
124
320
|
sort: boolean | ((a: V, b: V) => number);
|
|
125
321
|
filter: ((value: V) => boolean) | undefined;
|
|
@@ -132,7 +328,7 @@ export declare class ColumnState<T = any, V = any> {
|
|
|
132
328
|
padHeader: boolean;
|
|
133
329
|
padStatusbar: boolean;
|
|
134
330
|
};
|
|
331
|
+
readonly isHidden: boolean;
|
|
135
332
|
toggleVisiblity(): void;
|
|
136
|
-
constructor(props: ColumnProps<T, V>);
|
|
137
333
|
}
|
|
138
|
-
export
|
|
334
|
+
export type ColumnProps<T = unknown, V = unknown> = $origin.Props<ReturnType<typeof ColumnState<T, V>>>;
|