@emamid/svelte-data-table 0.0.22 → 1.0.2

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.
Files changed (81) hide show
  1. package/dist/DataTable.svelte +303 -239
  2. package/dist/DataTable.svelte.d.ts +30 -60
  3. package/dist/DataTableDataCell.svelte +157 -90
  4. package/dist/DataTableDataCell.svelte.d.ts +18 -27
  5. package/dist/DataTableHeaderCell.svelte +63 -21
  6. package/dist/DataTableHeaderCell.svelte.d.ts +9 -23
  7. package/dist/DataTableIcon.svelte +25 -0
  8. package/dist/DataTableIcon.svelte.d.ts +9 -0
  9. package/dist/DataTableRow.svelte +150 -80
  10. package/dist/DataTableRow.svelte.d.ts +26 -34
  11. package/dist/cells/Actions.d.ts +1 -1
  12. package/dist/cells/Actions.js +10 -11
  13. package/dist/cells/ActionsCell.svelte +56 -33
  14. package/dist/cells/ActionsCell.svelte.d.ts +9 -47
  15. package/dist/cells/ButtonCell.svelte +58 -16
  16. package/dist/cells/ButtonCell.svelte.d.ts +11 -20
  17. package/dist/cells/CheckboxCell.svelte +72 -19
  18. package/dist/cells/CheckboxCell.svelte.d.ts +11 -22
  19. package/dist/cells/InputCell.svelte +93 -48
  20. package/dist/cells/InputCell.svelte.d.ts +14 -25
  21. package/dist/cells/MultiSelectCell.svelte +85 -25
  22. package/dist/cells/MultiSelectCell.svelte.d.ts +15 -26
  23. package/dist/cells/NumberInputCell.svelte +90 -44
  24. package/dist/cells/NumberInputCell.svelte.d.ts +13 -24
  25. package/dist/cells/RadioCell.svelte +66 -0
  26. package/dist/cells/RadioCell.svelte.d.ts +12 -0
  27. package/dist/cells/RangeCell.svelte +66 -17
  28. package/dist/cells/RangeCell.svelte.d.ts +13 -22
  29. package/dist/cells/SelectCell.svelte +87 -25
  30. package/dist/cells/SelectCell.svelte.d.ts +15 -26
  31. package/dist/cells/SpinCell.svelte +91 -42
  32. package/dist/cells/SpinCell.svelte.d.ts +13 -28
  33. package/dist/cells/TabWrapper.svelte +23 -21
  34. package/dist/cells/TabWrapper.svelte.d.ts +10 -22
  35. package/dist/cells/index.d.ts +3 -5
  36. package/dist/cells/index.js +3 -5
  37. package/dist/common.d.ts +199 -53
  38. package/dist/common.js +30 -11
  39. package/dist/index.d.ts +8 -2
  40. package/dist/index.js +8 -1
  41. package/dist/themes/active.d.ts +4 -0
  42. package/dist/themes/active.js +12 -0
  43. package/dist/themes/daisyUI.d.ts +2 -0
  44. package/dist/themes/daisyUI.js +47 -0
  45. package/dist/themes/default.d.ts +2 -0
  46. package/dist/themes/default.js +57 -0
  47. package/dist/themes/iconify.d.ts +2 -0
  48. package/dist/themes/iconify.js +33 -0
  49. package/dist/themes/index.d.ts +4 -0
  50. package/dist/themes/index.js +4 -0
  51. package/package.json +28 -32
  52. package/dist/DataTable.doc.d.ts +0 -81
  53. package/dist/DataTable.doc.js +0 -81
  54. package/dist/cells/ActionsCell.doc.d.ts +0 -28
  55. package/dist/cells/ActionsCell.doc.js +0 -28
  56. package/dist/cells/ButtonCell.doc.d.ts +0 -9
  57. package/dist/cells/ButtonCell.doc.js +0 -9
  58. package/dist/cells/CheckboxCell.doc.d.ts +0 -6
  59. package/dist/cells/CheckboxCell.doc.js +0 -6
  60. package/dist/cells/InputCell.doc.d.ts +0 -6
  61. package/dist/cells/InputCell.doc.js +0 -6
  62. package/dist/cells/MultiSelectCell.doc.d.ts +0 -8
  63. package/dist/cells/MultiSelectCell.doc.js +0 -8
  64. package/dist/cells/NumberInputCell.doc.d.ts +0 -6
  65. package/dist/cells/NumberInputCell.doc.js +0 -6
  66. package/dist/cells/RangeCell.doc.d.ts +0 -7
  67. package/dist/cells/RangeCell.doc.js +0 -7
  68. package/dist/cells/RatingCell.doc.d.ts +0 -7
  69. package/dist/cells/RatingCell.doc.js +0 -7
  70. package/dist/cells/RatingCell.svelte +0 -13
  71. package/dist/cells/RatingCell.svelte.d.ts +0 -22
  72. package/dist/cells/SelectCell.doc.d.ts +0 -8
  73. package/dist/cells/SelectCell.doc.js +0 -8
  74. package/dist/cells/SpinCell.doc.d.ts +0 -13
  75. package/dist/cells/SpinCell.doc.js +0 -13
  76. package/dist/cells/TabWrapper.doc.d.ts +0 -5
  77. package/dist/cells/TabWrapper.doc.js +0 -5
  78. package/dist/cells/ToggleCell.doc.d.ts +0 -6
  79. package/dist/cells/ToggleCell.doc.js +0 -6
  80. package/dist/cells/ToggleCell.svelte +0 -21
  81. package/dist/cells/ToggleCell.svelte.d.ts +0 -23
@@ -1,4 +1,4 @@
1
- export * from './Actions.js';
1
+ export * from './Actions.ts';
2
2
  export * from './ActionsCell.svelte';
3
3
  export { default as ActionsCell } from './ActionsCell.svelte';
4
4
  export * from './ButtonCell.svelte';
@@ -11,15 +11,13 @@ export * from './MultiSelectCell.svelte';
11
11
  export { default as MultiSelectCell } from './MultiSelectCell.svelte';
12
12
  export * from './NumberInputCell.svelte';
13
13
  export { default as NumberInputCell } from './NumberInputCell.svelte';
14
+ export * from './RadioCell.svelte';
15
+ export { default as RadioCell } from './RadioCell.svelte';
14
16
  export * from './RangeCell.svelte';
15
17
  export { default as RangeCell } from './RangeCell.svelte';
16
- export * from './RatingCell.svelte';
17
- export { default as RatingCell } from './RatingCell.svelte';
18
18
  export * from './SelectCell.svelte';
19
19
  export { default as SelectCell } from './SelectCell.svelte';
20
20
  export * from './SpinCell.svelte';
21
21
  export { default as SpinCell } from './SpinCell.svelte';
22
22
  export * from './TabWrapper.svelte';
23
23
  export { default as TabWrapper } from './TabWrapper.svelte';
24
- export * from './ToggleCell.svelte';
25
- export { default as ToggleCell } from './ToggleCell.svelte';
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, returned by cellRenderer (or the default renderer).
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 {CellValue}
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<CellValue>;
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
- defaultClass: string,
39
- /** tdClassAppend from DataTable. */
40
- appendClass: string,
41
- /** tdClassOveride from DataTable. */
42
- overrideClass: string) => string;
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?: ConstructorOfATypedSvelteComponent;
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
- tdClassAppend?: string;
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?: ConstructorOfATypedSvelteComponent;
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 termined by grid properties. */
116
- calcClass: string,
117
- /** Default classes for a TableBodyRow component as defined by FlowBite. */
118
- defaultClass: string,
119
- /** trClassAppend from DataTable. */
120
- appendClass: string,
121
- /** trClassOveride from DataTable. */
122
- overrideClass: string) => string;
123
- /**
124
- * Joins an array of classes into a string, removing any falsey values.
125
- * @function joinClasses
126
- * @param {...string} items - Strings of CSS classes to join.
127
- * @returns {string}
128
- */
129
- export declare const joinClasses: (...classes: (string | false | null | undefined)[]) => string;
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
- interface DataTableContext {
166
- draggedColumn?: InternalColumnConfig;
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, setContext } from 'svelte';
2
- /**
3
- * Joins an array of classes into a string, removing any falsey values.
4
- * @function joinClasses
5
- * @param {...string} items - Strings of CSS classes to join.
6
- * @returns {string}
7
- */
8
- export const joinClasses = (...classes) => (classes || []).filter((value) => !!value).join(' ');
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,10 @@
1
1
  import DataTable from './DataTable.svelte';
2
- export type { CellRenderer, ColumnConfig, DataCellClassFunction, RowClassFunction, SortFunction, } from './common.js';
3
- export * from './cells/index.js';
2
+ export { default as DataTable } from './DataTable.svelte';
3
+ export { default as DataTableDataCell } from './DataTableDataCell.svelte';
4
+ export { default as DataTableHeaderCell } from './DataTableHeaderCell.svelte';
5
+ export { default as DataTableIcon } from './DataTableIcon.svelte';
6
+ export { default as DataTableRow } from './DataTableRow.svelte';
7
+ export * from './common.ts';
8
+ export * from './cells/index.ts';
9
+ export * from './themes/index.ts';
4
10
  export default DataTable;
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
1
  import DataTable from './DataTable.svelte';
2
- export * from './cells/index.js';
2
+ export { default as DataTable } from './DataTable.svelte';
3
+ export { default as DataTableDataCell } from './DataTableDataCell.svelte';
4
+ export { default as DataTableHeaderCell } from './DataTableHeaderCell.svelte';
5
+ export { default as DataTableIcon } from './DataTableIcon.svelte';
6
+ export { default as DataTableRow } from './DataTableRow.svelte';
7
+ export * from './common.ts';
8
+ export * from './cells/index.ts';
9
+ export * from './themes/index.ts';
3
10
  export default DataTable;
@@ -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,2 @@
1
+ import type { DataTableTheme } from '../common';
2
+ export declare const daisyUITheme: DataTableTheme;
@@ -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,2 @@
1
+ import type { DataTableTheme } from '../common';
2
+ export declare const defaultTheme: DataTableTheme;
@@ -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,2 @@
1
+ import type { DataTableTheme } from '../common';
2
+ export declare const iconifyTheme: DataTableTheme;
@@ -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
+ };
@@ -0,0 +1,4 @@
1
+ export * from './active.ts';
2
+ export * from './default.ts';
3
+ export * from './daisyUI.ts';
4
+ export * from './iconify.ts';
@@ -0,0 +1,4 @@
1
+ export * from './active.ts';
2
+ export * from './default.ts';
3
+ export * from './daisyUI.ts';
4
+ export * from './iconify.ts';