@emamid/svelte-data-table 0.0.21 → 1.0.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/DataTable.svelte +303 -239
- package/dist/DataTable.svelte.d.ts +30 -60
- package/dist/DataTableDataCell.svelte +157 -90
- package/dist/DataTableDataCell.svelte.d.ts +18 -27
- package/dist/DataTableHeaderCell.svelte +63 -21
- package/dist/DataTableHeaderCell.svelte.d.ts +9 -23
- package/dist/DataTableIcon.svelte +25 -0
- package/dist/DataTableIcon.svelte.d.ts +9 -0
- package/dist/DataTableRow.svelte +150 -80
- package/dist/DataTableRow.svelte.d.ts +26 -34
- package/dist/cells/Actions.d.ts +1 -1
- package/dist/cells/Actions.js +10 -11
- package/dist/cells/ActionsCell.svelte +58 -23
- package/dist/cells/ActionsCell.svelte.d.ts +9 -34
- package/dist/cells/ButtonCell.svelte +58 -16
- package/dist/cells/ButtonCell.svelte.d.ts +11 -20
- package/dist/cells/CheckboxCell.svelte +72 -19
- package/dist/cells/CheckboxCell.svelte.d.ts +11 -22
- package/dist/cells/InputCell.svelte +93 -49
- package/dist/cells/InputCell.svelte.d.ts +14 -25
- package/dist/cells/MultiSelectCell.svelte +85 -26
- package/dist/cells/MultiSelectCell.svelte.d.ts +15 -26
- package/dist/cells/NumberInputCell.svelte +90 -45
- package/dist/cells/NumberInputCell.svelte.d.ts +13 -24
- package/dist/cells/RadioCell.svelte +66 -0
- package/dist/cells/RadioCell.svelte.d.ts +12 -0
- package/dist/cells/RangeCell.svelte +66 -17
- package/dist/cells/RangeCell.svelte.d.ts +13 -22
- package/dist/cells/SelectCell.svelte +87 -26
- package/dist/cells/SelectCell.svelte.d.ts +15 -26
- package/dist/cells/SpinCell.svelte +91 -42
- package/dist/cells/SpinCell.svelte.d.ts +13 -28
- package/dist/cells/TabWrapper.svelte +23 -21
- package/dist/cells/TabWrapper.svelte.d.ts +10 -22
- package/dist/cells/index.d.ts +2 -4
- package/dist/cells/index.js +2 -4
- package/dist/common.d.ts +199 -53
- package/dist/common.js +30 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/themes/active.d.ts +4 -0
- package/dist/themes/active.js +12 -0
- package/dist/themes/daisyUI.d.ts +2 -0
- package/dist/themes/daisyUI.js +47 -0
- package/dist/themes/default.d.ts +2 -0
- package/dist/themes/default.js +57 -0
- package/dist/themes/iconify.d.ts +2 -0
- package/dist/themes/iconify.js +33 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.js +4 -0
- package/package.json +28 -30
- package/dist/DataTable.doc.d.ts +0 -81
- package/dist/DataTable.doc.js +0 -81
- package/dist/cells/ActionsCell.doc.d.ts +0 -28
- package/dist/cells/ActionsCell.doc.js +0 -28
- package/dist/cells/ButtonCell.doc.d.ts +0 -9
- package/dist/cells/ButtonCell.doc.js +0 -9
- package/dist/cells/CheckboxCell.doc.d.ts +0 -6
- package/dist/cells/CheckboxCell.doc.js +0 -6
- package/dist/cells/InputCell.doc.d.ts +0 -6
- package/dist/cells/InputCell.doc.js +0 -6
- package/dist/cells/MultiSelectCell.doc.d.ts +0 -8
- package/dist/cells/MultiSelectCell.doc.js +0 -8
- package/dist/cells/NumberInputCell.doc.d.ts +0 -6
- package/dist/cells/NumberInputCell.doc.js +0 -6
- package/dist/cells/RangeCell.doc.d.ts +0 -7
- package/dist/cells/RangeCell.doc.js +0 -7
- package/dist/cells/RatingCell.doc.d.ts +0 -7
- package/dist/cells/RatingCell.doc.js +0 -7
- package/dist/cells/RatingCell.svelte +0 -13
- package/dist/cells/RatingCell.svelte.d.ts +0 -22
- package/dist/cells/SelectCell.doc.d.ts +0 -8
- package/dist/cells/SelectCell.doc.js +0 -8
- package/dist/cells/SpinCell.doc.d.ts +0 -13
- package/dist/cells/SpinCell.doc.js +0 -13
- package/dist/cells/TabWrapper.doc.d.ts +0 -5
- package/dist/cells/TabWrapper.doc.js +0 -5
- package/dist/cells/ToggleCell.doc.d.ts +0 -6
- package/dist/cells/ToggleCell.doc.js +0 -6
- package/dist/cells/ToggleCell.svelte +0 -21
- package/dist/cells/ToggleCell.svelte.d.ts +0 -23
package/dist/common.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
export type IconifyProps = {
|
|
3
|
+
color?: string;
|
|
4
|
+
flip?: string;
|
|
5
|
+
height?: string | number;
|
|
6
|
+
hFlip?: boolean;
|
|
7
|
+
icon: string;
|
|
8
|
+
inline?: boolean;
|
|
9
|
+
rotate?: number;
|
|
10
|
+
vFlip?: boolean;
|
|
11
|
+
width?: string | number;
|
|
12
|
+
};
|
|
13
|
+
export type IconProp = Component<any, any, any> | string | IconifyProps;
|
|
1
14
|
/**
|
|
2
|
-
* Values for a given column/row
|
|
15
|
+
* Values for a given column/row
|
|
3
16
|
* @typedef {object} CellValue
|
|
4
17
|
* @property {any} dataValue The data value for the cell.
|
|
5
18
|
* @property {any} [displayValue] The value to be displayed for the cell. If this is not set, value will be used instead.
|
|
@@ -8,16 +21,30 @@ export interface CellValue {
|
|
|
8
21
|
dataValue: any;
|
|
9
22
|
displayValue?: any;
|
|
10
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Return result of a cell renderer
|
|
26
|
+
* @typedef {object} CellValue
|
|
27
|
+
* @property {any} dataValue The data value for the cell.
|
|
28
|
+
* @property {any} [displayValue] The value to be displayed for the cell. If this is not set, value will be used instead.
|
|
29
|
+
* @property {ComponentProps} [focusComponentConfig]
|
|
30
|
+
* @property {string} [tdClass]
|
|
31
|
+
* @property {ComponentProps} [viewComponentConfig]
|
|
32
|
+
*/
|
|
33
|
+
export interface CellRendererResult extends CellValue {
|
|
34
|
+
focusComponentConfig?: Record<string, any>;
|
|
35
|
+
tdClass?: string;
|
|
36
|
+
viewComponentConfig?: Record<string, any>;
|
|
37
|
+
}
|
|
11
38
|
/**
|
|
12
39
|
* Returns the value for a given column/row combination.
|
|
13
40
|
* @callback CellRenderer
|
|
14
|
-
* @returns {
|
|
41
|
+
* @returns {CellRendererResult}
|
|
15
42
|
*/
|
|
16
43
|
export type CellRenderer = (
|
|
17
44
|
/** Configuration for the cell's column. */
|
|
18
45
|
column: ColumnConfig,
|
|
19
46
|
/** Data for the cell's row. */
|
|
20
|
-
item: any) => Promise<
|
|
47
|
+
item: any, isFocused: boolean, baseClass: string) => Promise<CellRendererResult>;
|
|
21
48
|
/**
|
|
22
49
|
* Returns the a class string for a data cell.
|
|
23
50
|
* @callback DataCellClassFunction
|
|
@@ -32,14 +59,45 @@ column: ColumnConfig,
|
|
|
32
59
|
value: CellValue,
|
|
33
60
|
/** True if the cell is focused. */
|
|
34
61
|
isFocused: boolean,
|
|
35
|
-
/** Classes as determined by grid and column properties and focus state. */
|
|
36
|
-
calcClass: string,
|
|
37
62
|
/** Default classes for a TableBodyCell component as defined by FlowBite. */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
63
|
+
baseClass: string) => string;
|
|
64
|
+
export interface DataCellDragEvent extends DragEvent {
|
|
65
|
+
sourceColumn: ColumnConfig;
|
|
66
|
+
sourceItem: any;
|
|
67
|
+
}
|
|
68
|
+
export interface DataCellDropEvent extends DragEvent {
|
|
69
|
+
sourceColumn: ColumnConfig;
|
|
70
|
+
sourceItem: any;
|
|
71
|
+
targetColumn: ColumnConfig;
|
|
72
|
+
targetItem: any;
|
|
73
|
+
}
|
|
74
|
+
export interface DataCellEvent {
|
|
75
|
+
column: ColumnConfig;
|
|
76
|
+
item: any;
|
|
77
|
+
}
|
|
78
|
+
export interface DataCellChangedEvent extends DataCellEvent {
|
|
79
|
+
oldValue: any;
|
|
80
|
+
newValue: any;
|
|
81
|
+
}
|
|
82
|
+
export interface DataCellMouseEvent extends MouseEvent {
|
|
83
|
+
column: ColumnConfig;
|
|
84
|
+
item: any;
|
|
85
|
+
}
|
|
86
|
+
export type ActionDisablementFunction = (item: any, column: ColumnConfig, action: Action) => boolean;
|
|
87
|
+
export interface Action {
|
|
88
|
+
buttonClass?: string;
|
|
89
|
+
caption?: string;
|
|
90
|
+
name: string;
|
|
91
|
+
icon?: IconProp;
|
|
92
|
+
iconClass?: string;
|
|
93
|
+
iconify?: IconifyProps;
|
|
94
|
+
isDisabled?: ActionDisablementFunction;
|
|
95
|
+
theme?: ActionTheme;
|
|
96
|
+
tooltip?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface ActionEvent extends DataCellEvent {
|
|
99
|
+
action: Action;
|
|
100
|
+
}
|
|
43
101
|
/**
|
|
44
102
|
* Returns a comparison between two values, used for sorting.
|
|
45
103
|
* @callback SortFunction
|
|
@@ -50,6 +108,99 @@ export type SortFunction = (
|
|
|
50
108
|
a: any,
|
|
51
109
|
/** Second value to compare. */
|
|
52
110
|
b: any) => number;
|
|
111
|
+
type ThemeValue = {
|
|
112
|
+
append?: string;
|
|
113
|
+
override?: string;
|
|
114
|
+
};
|
|
115
|
+
type DataCell = {
|
|
116
|
+
td?: ThemeValue;
|
|
117
|
+
tdFocused?: ThemeValue;
|
|
118
|
+
};
|
|
119
|
+
type HeaderCell = {
|
|
120
|
+
sortAscending?: IconProp;
|
|
121
|
+
sortDescending?: IconProp;
|
|
122
|
+
span?: ThemeValue;
|
|
123
|
+
th?: ThemeValue;
|
|
124
|
+
titleSpan?: ThemeValue;
|
|
125
|
+
};
|
|
126
|
+
type Row = {
|
|
127
|
+
tr?: ThemeValue;
|
|
128
|
+
trFocused?: ThemeValue;
|
|
129
|
+
};
|
|
130
|
+
type Table = {
|
|
131
|
+
table?: ThemeValue;
|
|
132
|
+
tbody?: ThemeValue;
|
|
133
|
+
thead?: ThemeValue;
|
|
134
|
+
theadTR?: ThemeValue;
|
|
135
|
+
};
|
|
136
|
+
interface ColumnParts {
|
|
137
|
+
dataCell?: DataCell;
|
|
138
|
+
headerCell?: HeaderCell;
|
|
139
|
+
}
|
|
140
|
+
interface TableParts extends ColumnParts {
|
|
141
|
+
row?: Row;
|
|
142
|
+
table?: Table;
|
|
143
|
+
}
|
|
144
|
+
export type ActionTheme = {
|
|
145
|
+
button?: ThemeValue;
|
|
146
|
+
icon?: ThemeValue;
|
|
147
|
+
};
|
|
148
|
+
type Button = {
|
|
149
|
+
button?: ThemeValue;
|
|
150
|
+
icon?: ThemeValue;
|
|
151
|
+
};
|
|
152
|
+
type Checkbox = {
|
|
153
|
+
input?: ThemeValue;
|
|
154
|
+
label?: ThemeValue;
|
|
155
|
+
};
|
|
156
|
+
type Input = {
|
|
157
|
+
input?: ThemeValue;
|
|
158
|
+
};
|
|
159
|
+
type MultiSelect = {
|
|
160
|
+
option?: ThemeValue;
|
|
161
|
+
select?: ThemeValue;
|
|
162
|
+
};
|
|
163
|
+
type NumberInput = {
|
|
164
|
+
input?: ThemeValue;
|
|
165
|
+
};
|
|
166
|
+
type Radio = {
|
|
167
|
+
span?: ThemeValue;
|
|
168
|
+
input?: ThemeValue;
|
|
169
|
+
};
|
|
170
|
+
type Range = {
|
|
171
|
+
input?: ThemeValue;
|
|
172
|
+
};
|
|
173
|
+
type Select = {
|
|
174
|
+
option?: ThemeValue;
|
|
175
|
+
select?: ThemeValue;
|
|
176
|
+
};
|
|
177
|
+
type Spinner = {
|
|
178
|
+
div?: ThemeValue;
|
|
179
|
+
minusButton?: ThemeValue;
|
|
180
|
+
minusIcon?: IconProp;
|
|
181
|
+
plusButton?: ThemeValue;
|
|
182
|
+
plusIcon?: IconProp;
|
|
183
|
+
};
|
|
184
|
+
type Inputs = {
|
|
185
|
+
action?: ActionTheme;
|
|
186
|
+
button?: Button;
|
|
187
|
+
checkbox?: Checkbox;
|
|
188
|
+
input?: Input;
|
|
189
|
+
multiSelect?: MultiSelect;
|
|
190
|
+
numberInput?: NumberInput;
|
|
191
|
+
radio?: Radio;
|
|
192
|
+
range?: Range;
|
|
193
|
+
select?: Select;
|
|
194
|
+
spinner?: Spinner;
|
|
195
|
+
};
|
|
196
|
+
export type DataTableColumnTheme = {
|
|
197
|
+
parts?: ColumnParts;
|
|
198
|
+
};
|
|
199
|
+
export type DataTableTheme = {
|
|
200
|
+
inputs?: Inputs;
|
|
201
|
+
parts?: TableParts;
|
|
202
|
+
};
|
|
203
|
+
type Theme = DataTableColumnTheme & DataTableTheme;
|
|
53
204
|
/**
|
|
54
205
|
* Configuration options for a grid column
|
|
55
206
|
* @typedef {object} ColumnConfig
|
|
@@ -63,17 +214,9 @@ b: any) => number;
|
|
|
63
214
|
* @property {object} [viewComponentConfig] - Properties to be passed when creating viewComponent.
|
|
64
215
|
* @property {ConstructorOfATypedSvelteComponent} [focusComponent] - Svelte component class to be displayed in the cell when it has focus.
|
|
65
216
|
* @property {object} [focusComponentConfig] - Properties to be passed when creating focusComponent.
|
|
66
|
-
* @property {string} [tdClassAppend] - Classes to append to existing CSS when not focused.
|
|
67
|
-
* @property {string} [tdClassOverride] - Classes to replace existing CSS with when not focused.
|
|
68
|
-
* @property {string} [tdFocusedClassAppend] - Classes to append to existing CSS when focused.
|
|
69
|
-
* @property {string} [tdFocusedClassOverride] - Classes to replace existing CSS with when focused.
|
|
70
217
|
* @property {DataCellClassFunction} [tdClassGetter] - Dynamically determines CSS classes for a cell.
|
|
71
|
-
* @property {string} [thClassAppend] - Classes to append to existing CSS for header cells.
|
|
72
|
-
* @property {string} [thClassOverride] - Class to replace existing CSS for header cells.
|
|
73
218
|
* @property {boolean} [canFocus] - True if cells in this column can be focused.
|
|
74
219
|
* @property {boolean} [canSort] - If true, clicking the column's header will set sorting to sortFunction or sortKey, or reverse it if already set.
|
|
75
|
-
* @property {ConstructorOfATypedSvelteComponent} [sortAscendingIcon] - Svelte component class to be displayed in the column is sorting ascended (overrides table).
|
|
76
|
-
* @property {ConstructorOfATypedSvelteComponent} [sortDescendingIcon] - Svelte component class to be displayed in the column is sorting descended (overrides table).
|
|
77
220
|
* @property {SortFunction} [sortFunction] - Comparison function for complex sorting.
|
|
78
221
|
* @property {string} [sortKey] - Item property to sort by, if sortFunction is not defined.
|
|
79
222
|
*/
|
|
@@ -83,24 +226,25 @@ export interface ColumnConfig {
|
|
|
83
226
|
canFocus?: boolean;
|
|
84
227
|
canSort?: boolean;
|
|
85
228
|
cellRenderer?: CellRenderer;
|
|
86
|
-
focusComponent?:
|
|
87
|
-
focusComponentConfig?: any
|
|
229
|
+
focusComponent?: Component<any, any, any>;
|
|
230
|
+
focusComponentConfig?: Record<string, any>;
|
|
88
231
|
id?: string;
|
|
89
232
|
key?: string;
|
|
90
|
-
sortAscendingIcon?: ConstructorOfATypedSvelteComponent;
|
|
91
|
-
sortDescendingIcon?: ConstructorOfATypedSvelteComponent;
|
|
92
233
|
sortFunction?: SortFunction;
|
|
93
234
|
sortKey?: string;
|
|
94
|
-
|
|
95
|
-
tdClassOverride?: string;
|
|
96
|
-
tdFocusedClassAppend?: string;
|
|
97
|
-
tdFocusedClassOverride?: string;
|
|
98
|
-
tdClassGetter?: DataCellClassFunction;
|
|
99
|
-
thClassAppend?: string;
|
|
100
|
-
thClassOverride?: string;
|
|
235
|
+
theme?: DataTableColumnTheme;
|
|
101
236
|
title?: string;
|
|
102
|
-
viewComponent?:
|
|
103
|
-
viewComponentConfig?: any
|
|
237
|
+
viewComponent?: Component<any, any, any>;
|
|
238
|
+
viewComponentConfig?: Record<string, any>;
|
|
239
|
+
}
|
|
240
|
+
interface ColumnEvent {
|
|
241
|
+
column: ColumnConfig;
|
|
242
|
+
}
|
|
243
|
+
export interface HeaderEvent extends ColumnEvent {
|
|
244
|
+
reverseSort?: boolean;
|
|
245
|
+
sortColumnID?: string;
|
|
246
|
+
sortFunction?: SortFunction;
|
|
247
|
+
sortKey?: string;
|
|
104
248
|
}
|
|
105
249
|
/**
|
|
106
250
|
* Returns the a class string for a data row.
|
|
@@ -112,21 +256,22 @@ export type RowClassFunction = (
|
|
|
112
256
|
item: any,
|
|
113
257
|
/** True if a cell on this row is focused. */
|
|
114
258
|
isFocused: boolean,
|
|
115
|
-
/** Classes as
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
export declare const
|
|
259
|
+
/** Classes as determined by grid properties. */
|
|
260
|
+
baseClass: string) => string;
|
|
261
|
+
export interface RowDragEvent extends DragEvent {
|
|
262
|
+
sourceItem: any;
|
|
263
|
+
}
|
|
264
|
+
export interface RowDropEvent extends DragEvent {
|
|
265
|
+
sourceItem: any;
|
|
266
|
+
targetItem: any;
|
|
267
|
+
}
|
|
268
|
+
export type RowEvent = {
|
|
269
|
+
item: any;
|
|
270
|
+
};
|
|
271
|
+
export declare const joinInputClasses: (input: string, element: string, themes: (Theme | undefined)[], isFocused?: boolean) => string;
|
|
272
|
+
export declare const joinPartClasses: (part: string, element: string, themes: (Theme | undefined)[], isFocused?: boolean) => string;
|
|
273
|
+
export declare const getInputIcon: (part: string, propName: string, themes: (Theme | undefined)[]) => IconProp;
|
|
274
|
+
export declare const getPartIcon: (part: string, propName: string, themes: (Theme | undefined)[]) => IconProp;
|
|
130
275
|
/**
|
|
131
276
|
* Values for enterAction on DataTable.
|
|
132
277
|
* @enum {string} EnterAction
|
|
@@ -134,10 +279,6 @@ export declare const joinClasses: (...classes: (string | false | null | undefine
|
|
|
134
279
|
export type EnterAction = 'next' | 'down' | 'stay';
|
|
135
280
|
export type GetItemKeyFunction = (item?: any) => any;
|
|
136
281
|
export type GetTDClassFunction = (item: any, value: any, isFocused: boolean) => string;
|
|
137
|
-
export type GetTRClassFunction = (item: any, isRowFocused: boolean) => string;
|
|
138
|
-
export interface InternalColumnConfig extends ColumnConfig {
|
|
139
|
-
getTDClass: GetTDClassFunction;
|
|
140
|
-
}
|
|
141
282
|
type CellDropBooleanFunction = (sourceItem: any, targetItem: any, targetColumn: ColumnConfig) => boolean;
|
|
142
283
|
/**
|
|
143
284
|
* @callback CellDropBoolean
|
|
@@ -162,10 +303,15 @@ export declare const evalRowBoolean: (item: any, rowBoolean?: RowBoolean) => boo
|
|
|
162
303
|
export declare const evalRowDropBoolean: (sourceItem: any, targetItem: any, rowDropBoolean?: RowDropBoolean) => boolean | undefined;
|
|
163
304
|
export declare const defaultCellRenderer: CellRenderer;
|
|
164
305
|
export declare const getColumnID: (column?: ColumnConfig | null) => string | null;
|
|
165
|
-
|
|
166
|
-
|
|
306
|
+
export type DragType = 'cell' | 'column' | // Not yet implemented
|
|
307
|
+
'row';
|
|
308
|
+
export interface DataTableContext {
|
|
309
|
+
draggedColumn?: ColumnConfig;
|
|
167
310
|
draggedItem?: any;
|
|
311
|
+
dragType?: DragType;
|
|
312
|
+
items: any[];
|
|
313
|
+
theme?: DataTableTheme;
|
|
168
314
|
}
|
|
315
|
+
export declare const dataTableContextName = "data-grid";
|
|
169
316
|
export declare const getDataTableContext: () => DataTableContext;
|
|
170
|
-
export declare const setDataTableContext: (context: DataTableContext) => DataTableContext;
|
|
171
317
|
export {};
|
package/dist/common.js
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import { getContext
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getContext } from 'svelte';
|
|
2
|
+
import { get } from 'lodash';
|
|
3
|
+
const joinThemeClasses = (path, themes, isFocused) => {
|
|
4
|
+
const result = (themes || []).reduce((classValue, theme) => {
|
|
5
|
+
const themeValue = get(theme, path);
|
|
6
|
+
const focusedValue = isFocused ? get(theme, `${path}Focused`) : null;
|
|
7
|
+
return (focusedValue?.override || themeValue?.override || classValue) + ' ' + (themeValue?.append || '') + ' ' + (focusedValue?.append || '');
|
|
8
|
+
}, '');
|
|
9
|
+
return result?.trim();
|
|
10
|
+
};
|
|
11
|
+
export const joinInputClasses = (input, element, themes, isFocused) => {
|
|
12
|
+
return joinThemeClasses(`inputs.${input}.${element}`, themes, isFocused);
|
|
13
|
+
};
|
|
14
|
+
export const joinPartClasses = (part, element, themes, isFocused) => {
|
|
15
|
+
return joinThemeClasses(`parts.${part}.${element}`, themes, isFocused);
|
|
16
|
+
};
|
|
17
|
+
const getThemeIcon = (path, themes) => {
|
|
18
|
+
const result = (themes || []).reduce((currentValue, theme) => {
|
|
19
|
+
return get(theme, path) || currentValue;
|
|
20
|
+
}, '');
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
export const getInputIcon = (part, propName, themes) => {
|
|
24
|
+
return getThemeIcon(`inputs.${part}.${propName}`, themes);
|
|
25
|
+
};
|
|
26
|
+
export const getPartIcon = (part, propName, themes) => {
|
|
27
|
+
return getThemeIcon(`parts.${part}.${propName}`, themes);
|
|
28
|
+
};
|
|
9
29
|
export const blankCellValue = {
|
|
10
30
|
dataValue: null,
|
|
11
31
|
displayValue: '',
|
|
@@ -28,10 +48,9 @@ export const evalRowDropBoolean = (sourceItem, targetItem, rowDropBoolean) => {
|
|
|
28
48
|
}
|
|
29
49
|
return rowDropBoolean && rowDropBoolean(sourceItem, targetItem);
|
|
30
50
|
};
|
|
31
|
-
export const defaultCellRenderer = async (column, item) => column.key
|
|
51
|
+
export const defaultCellRenderer = async (column, item, _isFocused, _baseClass) => column.key
|
|
32
52
|
? { dataValue: item[column.key], displayValue: item[column.key] || '' }
|
|
33
53
|
: blankCellValue;
|
|
34
54
|
export const getColumnID = (column) => (column ? column.id || null : null);
|
|
35
|
-
const dataTableContextName = 'data-grid';
|
|
55
|
+
export const dataTableContextName = 'data-grid';
|
|
36
56
|
export const getDataTableContext = () => getContext(dataTableContextName);
|
|
37
|
-
export const setDataTableContext = (context) => setContext(dataTableContextName, context);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import DataTable from './DataTable.svelte';
|
|
2
|
-
export type { CellRenderer, ColumnConfig, DataCellClassFunction, RowClassFunction, SortFunction, } from './common.
|
|
3
|
-
export * from './cells/index.
|
|
2
|
+
export type { CellRenderer, ColumnConfig, DataCellClassFunction, RowClassFunction, SortFunction, } from './common.ts';
|
|
3
|
+
export * from './cells/index.ts';
|
|
4
4
|
export default DataTable;
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataTableTheme } from '../common';
|
|
2
|
+
export declare let activeTheme: DataTableTheme;
|
|
3
|
+
export declare const mergeThemes: (themes: DataTableTheme | DataTableTheme[]) => DataTableTheme;
|
|
4
|
+
export declare const setActiveTheme: (themes: DataTableTheme | DataTableTheme[]) => DataTableTheme;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { merge } from 'lodash';
|
|
2
|
+
import { defaultTheme } from './default';
|
|
3
|
+
export let activeTheme = defaultTheme;
|
|
4
|
+
export const mergeThemes = (themes) => {
|
|
5
|
+
return (Array.isArray(themes) ? themes : [themes]).reduce((processedThemes, theme) => {
|
|
6
|
+
return merge(processedThemes, theme);
|
|
7
|
+
}, {});
|
|
8
|
+
};
|
|
9
|
+
export const setActiveTheme = (themes) => {
|
|
10
|
+
activeTheme = mergeThemes(themes);
|
|
11
|
+
return activeTheme;
|
|
12
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const daisyUITheme = {
|
|
2
|
+
inputs: {
|
|
3
|
+
button: {
|
|
4
|
+
button: {
|
|
5
|
+
override: 'btn btn-primary',
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
checkbox: {
|
|
9
|
+
input: {
|
|
10
|
+
override: 'toggle',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
input: {
|
|
14
|
+
input: {
|
|
15
|
+
override: 'input',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
multiSelect: {
|
|
19
|
+
select: {
|
|
20
|
+
override: 'select',
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
numberInput: {
|
|
24
|
+
input: {
|
|
25
|
+
override: 'input',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
radio: {
|
|
29
|
+
input: {
|
|
30
|
+
override: 'mask mask-star',
|
|
31
|
+
},
|
|
32
|
+
span: {
|
|
33
|
+
override: 'rating',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
range: {
|
|
37
|
+
input: {
|
|
38
|
+
override: 'range',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
select: {
|
|
42
|
+
select: {
|
|
43
|
+
override: 'select',
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const defaultTheme = {
|
|
2
|
+
inputs: {
|
|
3
|
+
action: {
|
|
4
|
+
button: {
|
|
5
|
+
override: 'border-0 p-1',
|
|
6
|
+
},
|
|
7
|
+
icon: {
|
|
8
|
+
override: 'w-4 h-4',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
spinner: {
|
|
12
|
+
div: {
|
|
13
|
+
override: 'spinner',
|
|
14
|
+
},
|
|
15
|
+
minusButton: {
|
|
16
|
+
override: 'pr-1',
|
|
17
|
+
},
|
|
18
|
+
minusIcon: '-',
|
|
19
|
+
plusButton: {
|
|
20
|
+
override: 'pl-1',
|
|
21
|
+
},
|
|
22
|
+
plusIcon: '+',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
parts: {
|
|
26
|
+
dataCell: {
|
|
27
|
+
td: {
|
|
28
|
+
override: 'px-6 py-4 whitespace-nowrap font-medium',
|
|
29
|
+
},
|
|
30
|
+
tdFocused: {
|
|
31
|
+
override: 'px-6 py-4 whitespace-nowrap font-medium',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
headerCell: {
|
|
35
|
+
sortAscending: '▲',
|
|
36
|
+
sortDescending: '▼',
|
|
37
|
+
span: {
|
|
38
|
+
override: 'inline-flex items-center',
|
|
39
|
+
},
|
|
40
|
+
th: {},
|
|
41
|
+
titleSpan: {},
|
|
42
|
+
},
|
|
43
|
+
row: {
|
|
44
|
+
tr: {},
|
|
45
|
+
},
|
|
46
|
+
table: {
|
|
47
|
+
table: {
|
|
48
|
+
override: 'table-fixed',
|
|
49
|
+
},
|
|
50
|
+
tbody: {},
|
|
51
|
+
thead: {
|
|
52
|
+
override: 'text-xs uppercase sticky top-0 z-10',
|
|
53
|
+
},
|
|
54
|
+
theadTR: {},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const iconifyTheme = {
|
|
2
|
+
inputs: {
|
|
3
|
+
spinner: {
|
|
4
|
+
minusIcon: {
|
|
5
|
+
height: '24px',
|
|
6
|
+
icon: 'ic:sharp-remove-circle',
|
|
7
|
+
width: '24px',
|
|
8
|
+
},
|
|
9
|
+
plusIcon: {
|
|
10
|
+
height: '24px',
|
|
11
|
+
icon: 'ic:sharp-add-circle',
|
|
12
|
+
width: '24px',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
parts: {
|
|
17
|
+
headerCell: {
|
|
18
|
+
sortAscending: {
|
|
19
|
+
height: '24px',
|
|
20
|
+
icon: 'ic:sharp-keyboard-arrow-up',
|
|
21
|
+
width: '24px',
|
|
22
|
+
},
|
|
23
|
+
sortDescending: {
|
|
24
|
+
height: '24px',
|
|
25
|
+
icon: 'ic:sharp-keyboard-arrow-down',
|
|
26
|
+
width: '24px',
|
|
27
|
+
},
|
|
28
|
+
th: {
|
|
29
|
+
override: 'h-8',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emamid/svelte-data-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"homepage": "https://github.com/emamid/svelte-data-table",
|
|
5
|
+
"repository": "github:emamid/svelte-data-table",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"dev": "vite dev",
|
|
7
8
|
"build": "vite build && npm run package",
|
|
8
9
|
"preview": "vite preview",
|
|
9
|
-
"package": "svelte-kit sync && svelte-package &&
|
|
10
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
10
11
|
"prepublishOnly": "npm run package",
|
|
11
12
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
12
13
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
13
14
|
"test": "vitest",
|
|
14
15
|
"lint": "prettier --check . && eslint .",
|
|
15
|
-
"format": "prettier --write ."
|
|
16
|
-
"jsdoc": "jsdoc -c jsdoc.json"
|
|
16
|
+
"format": "prettier --write ."
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
@@ -27,34 +27,32 @@
|
|
|
27
27
|
"!dist/**/*.spec.*"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"svelte": "^
|
|
30
|
+
"svelte": "^5.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@sveltejs/
|
|
35
|
-
"@sveltejs/
|
|
36
|
-
"@sveltejs/
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"eslint": "^8.
|
|
42
|
-
"eslint
|
|
43
|
-
"eslint-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"vite": "^5.0.3",
|
|
57
|
-
"vitest": "^1.0.0"
|
|
33
|
+
"@iconify/svelte": "^5.2.1",
|
|
34
|
+
"@sveltejs/adapter-auto": "^7.0.0",
|
|
35
|
+
"@sveltejs/kit": "^2.50.0",
|
|
36
|
+
"@sveltejs/package": "^2.5.7",
|
|
37
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
38
|
+
"@types/eslint": "9.6.1",
|
|
39
|
+
"@types/lodash": "^4.17.23",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
41
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
42
|
+
"eslint": "^9.39.2",
|
|
43
|
+
"eslint-config-prettier": "^10.1.8",
|
|
44
|
+
"eslint-plugin-svelte": "^3.14.0",
|
|
45
|
+
"lodash": "^4.17.21",
|
|
46
|
+
"prettier": "^3.8.0",
|
|
47
|
+
"prettier-plugin-svelte": "^3.4.1",
|
|
48
|
+
"publint": "^0.3.16",
|
|
49
|
+
"svelte": "^5.43.8",
|
|
50
|
+
"svelte-check": "^4.3.4",
|
|
51
|
+
"tailwindcss": "^4.1.18",
|
|
52
|
+
"tslib": "^2.8.1",
|
|
53
|
+
"typescript": "~5.9.3",
|
|
54
|
+
"vite": "^7.2.4",
|
|
55
|
+
"vitest": "^4.0.17"
|
|
58
56
|
},
|
|
59
57
|
"svelte": "./dist/index.js",
|
|
60
58
|
"types": "./dist/index.d.ts",
|