do-ui-design-system 1.1.14 → 1.1.16
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/do-theme/form.css +53 -0
- package/dist/do-theme/table.css +83 -7
- package/dist/organisms/TableBasic/TableBasic.svelte +133 -67
- package/dist/organisms/TableBasic/TableBasic.svelte.d.ts +3 -40
- package/dist/organisms/TableBasic/TableBasic.svelte.d.ts.map +1 -1
- package/dist/organisms/TableBasic/TableBasic.types.d.ts +41 -0
- package/dist/organisms/TableBasic/TableBasic.types.d.ts.map +1 -0
- package/dist/organisms/TableBasic/TableBasic.types.js +1 -0
- package/package.json +1 -1
package/dist/do-theme/form.css
CHANGED
|
@@ -39,4 +39,57 @@
|
|
|
39
39
|
.do-select {
|
|
40
40
|
background-color: #27272A;
|
|
41
41
|
border: 1px solid #52525B;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.do-checkbox {
|
|
45
|
+
width: 16px;
|
|
46
|
+
height: 16px;
|
|
47
|
+
padding: 0;
|
|
48
|
+
margin: 0;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
position: relative;
|
|
51
|
+
appearance: none;
|
|
52
|
+
-webkit-appearance: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.do-checkbox::before {
|
|
56
|
+
content: '';
|
|
57
|
+
display: block;
|
|
58
|
+
width: 16px;
|
|
59
|
+
height: 16px;
|
|
60
|
+
background-color: var(--Zinc-400, #a1a1aa);
|
|
61
|
+
border: 1px solid var(--Zinc-800, #27272a);
|
|
62
|
+
border-radius: 3.5px;
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.do-checkbox::after {
|
|
67
|
+
content: '';
|
|
68
|
+
position: absolute;
|
|
69
|
+
top: 50%;
|
|
70
|
+
left: 50%;
|
|
71
|
+
transform: translate(-50%, -50%);
|
|
72
|
+
background-repeat: no-repeat;
|
|
73
|
+
background-position: center;
|
|
74
|
+
display: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.do-checkbox:indeterminate::after {
|
|
78
|
+
background-color: var(--Zinc-400, #a1a1aa);
|
|
79
|
+
width: 10px;
|
|
80
|
+
height: 2px;
|
|
81
|
+
display: block;
|
|
82
|
+
background-color: var(--Zinc-800, #27272a);
|
|
83
|
+
border-radius: 3.5px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.do-checkbox:checked::after {
|
|
87
|
+
display: block;
|
|
88
|
+
width: 16px;
|
|
89
|
+
height: 16px;
|
|
90
|
+
top: 0;
|
|
91
|
+
left: 0;
|
|
92
|
+
transform: none;
|
|
93
|
+
background-color: transparent;
|
|
94
|
+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path d="M13 4.5L6.7 11.7L4 9" stroke="%233F3F46" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>');
|
|
42
95
|
}
|
package/dist/do-theme/table.css
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
.do-table-wrapper {
|
|
16
|
+
overflow-x: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
.do-table__content {
|
|
16
20
|
border-radius: 12px;
|
|
17
21
|
overflow: hidden;
|
|
@@ -31,11 +35,13 @@
|
|
|
31
35
|
font-size: 1rem;
|
|
32
36
|
font-weight: 500;
|
|
33
37
|
cursor: pointer;
|
|
34
|
-
user-select: none;
|
|
35
|
-
white-space: nowrap;
|
|
36
38
|
transition: color 0.15s;
|
|
37
39
|
color: #ffffff;
|
|
38
40
|
|
|
41
|
+
&:not(.col-check):not(.do-table__content__th-action) {
|
|
42
|
+
min-width: 120px;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
.do-table__content__th__sort {
|
|
40
46
|
display: inline-block;
|
|
41
47
|
font-size: 0.8rem;
|
|
@@ -67,7 +73,7 @@
|
|
|
67
73
|
|
|
68
74
|
.col-check {
|
|
69
75
|
padding: 0.75rem 1rem;
|
|
70
|
-
width:
|
|
76
|
+
width: 1px;
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
.do-row {
|
|
@@ -93,17 +99,24 @@
|
|
|
93
99
|
|
|
94
100
|
.do-table__content__th-filter {
|
|
95
101
|
padding: 0.2rem 0.5rem;
|
|
96
|
-
|
|
102
|
+
|
|
103
|
+
input {
|
|
104
|
+
max-width: 80%;
|
|
105
|
+
}
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
.do-table__content__th-action {
|
|
100
109
|
padding: 0.2rem 0.5rem;
|
|
101
|
-
|
|
110
|
+
width: 1px;
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
td {
|
|
105
114
|
padding: 0.75rem 1rem;
|
|
106
115
|
color: inherit;
|
|
116
|
+
|
|
117
|
+
&:not(.col-check):not(.do-table__content__th-action) {
|
|
118
|
+
min-width: 120px;
|
|
119
|
+
}
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
td:first-child {
|
|
@@ -135,12 +148,75 @@
|
|
|
135
148
|
font-size: 1rem;
|
|
136
149
|
|
|
137
150
|
.selected-count {
|
|
138
|
-
color: #
|
|
151
|
+
color: #5e5e5e;
|
|
139
152
|
}
|
|
140
153
|
|
|
141
154
|
.sort-label strong {
|
|
142
|
-
color: #
|
|
155
|
+
color: #5e5e5e;
|
|
143
156
|
font-weight: 500;
|
|
144
157
|
}
|
|
145
158
|
}
|
|
159
|
+
|
|
160
|
+
.do-table__header__dates {
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: flex-end;
|
|
163
|
+
gap: 0.75rem;
|
|
164
|
+
flex-wrap: wrap;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.do-table__date-toggle {
|
|
168
|
+
display: flex;
|
|
169
|
+
border: 1px solid var(--do-border, #3f3f46);
|
|
170
|
+
border-radius: 6px;
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.do-table__date-toggle__btn {
|
|
175
|
+
padding: 0.375rem 0.75rem;
|
|
176
|
+
font-size: 0.875rem;
|
|
177
|
+
background: transparent;
|
|
178
|
+
border: none;
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
color: inherit;
|
|
181
|
+
transition: background 0.15s;
|
|
182
|
+
|
|
183
|
+
&.active {
|
|
184
|
+
background: var(--do-bg-secondary, #3f3f46);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
&:hover:not(.active) {
|
|
188
|
+
background: var(--do-bg-secondary-hover, #52525b);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.do-table__date-range {
|
|
193
|
+
display: flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
gap: 0.5rem;
|
|
196
|
+
flex-wrap: wrap;
|
|
197
|
+
position: relative;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.do-table__date-fields {
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: center;
|
|
203
|
+
gap: 0.5rem;
|
|
204
|
+
flex-wrap: wrap;
|
|
205
|
+
position: relative;
|
|
206
|
+
|
|
207
|
+
.do-table__date-fields__field {
|
|
208
|
+
display: flex;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
gap: 0.25rem;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.do-table__date-error {
|
|
215
|
+
position: absolute;
|
|
216
|
+
white-space: nowrap;
|
|
217
|
+
bottom: -1rem;
|
|
218
|
+
left: 0;
|
|
219
|
+
font-size: 0.75rem;
|
|
220
|
+
color: red;
|
|
221
|
+
}
|
|
146
222
|
}
|
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Button,
|
|
2
|
+
import { Button, Icon } from '../../atoms/index.js';
|
|
3
3
|
import type { IconNames } from '../../do-theme/index.ts';
|
|
4
4
|
import IconButton from '../../molecules/IconButton/IconButton.svelte';
|
|
5
5
|
import Pagination from '../../molecules/Pagination/Pagination.svelte';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type ActionColumnDef<T> = {
|
|
21
|
-
key: string;
|
|
22
|
-
icon: IconNames;
|
|
23
|
-
label?: string;
|
|
24
|
-
showHeader?: boolean;
|
|
25
|
-
onClick: (row: T) => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type ColumnDef<T> = {
|
|
29
|
-
key: keyof T;
|
|
30
|
-
label: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
type Props<T extends { id: string | number }> = {
|
|
6
|
+
import type {
|
|
7
|
+
SortDirection,
|
|
8
|
+
DateMode,
|
|
9
|
+
TagConfig,
|
|
10
|
+
DateConfig,
|
|
11
|
+
HeaderAction,
|
|
12
|
+
ActionColumnDef,
|
|
13
|
+
ColumnDef,
|
|
14
|
+
TableProps
|
|
15
|
+
} from './TableBasic.types.ts';
|
|
16
|
+
|
|
17
|
+
type Props<T extends Record<string, any>> = {
|
|
34
18
|
data: T[];
|
|
35
19
|
columns: ColumnDef<T>[];
|
|
36
20
|
actionColumns?: ActionColumnDef<T>[];
|
|
37
21
|
tagConfig?: TagConfig<T>;
|
|
22
|
+
dateConfig?: DateConfig<T>;
|
|
38
23
|
idKey?: keyof T;
|
|
39
24
|
headerActions?: HeaderAction[];
|
|
40
25
|
pageSize?: number;
|
|
@@ -47,9 +32,10 @@
|
|
|
47
32
|
columns = [],
|
|
48
33
|
actionColumns = [],
|
|
49
34
|
tagConfig,
|
|
35
|
+
dateConfig,
|
|
50
36
|
idKey = 'id',
|
|
51
37
|
headerActions = [],
|
|
52
|
-
pageSize =
|
|
38
|
+
pageSize = 25,
|
|
53
39
|
showCheckbox = true,
|
|
54
40
|
onSelectionChange
|
|
55
41
|
}: Props<any> = $props();
|
|
@@ -59,6 +45,31 @@
|
|
|
59
45
|
let selected: Set<string | number> = $state(new Set());
|
|
60
46
|
let columnFilters: Record<string, string> = $state({});
|
|
61
47
|
|
|
48
|
+
const dateMode = $derived(dateConfig?.mode ?? 'year');
|
|
49
|
+
let dateFrom: string = $state('');
|
|
50
|
+
let dateTo: string = $state('');
|
|
51
|
+
const currentYear = new Date().getFullYear();
|
|
52
|
+
const years = Array.from({ length: 30 }, (_, i) => String(currentYear - i));
|
|
53
|
+
|
|
54
|
+
const clearDates = () => {
|
|
55
|
+
dateFrom = '';
|
|
56
|
+
dateTo = '';
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
let dateError: string = $state('');
|
|
60
|
+
|
|
61
|
+
$effect(() => {
|
|
62
|
+
if (dateFrom && dateTo) {
|
|
63
|
+
if (dateFrom > dateTo) {
|
|
64
|
+
dateError = 'Fecha inicio debe ser menor o igual a fecha fin';
|
|
65
|
+
} else {
|
|
66
|
+
dateError = '';
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
dateError = '';
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
62
73
|
const tagOptions = $derived(() => {
|
|
63
74
|
if (!tagConfig?.column) return [];
|
|
64
75
|
return [...new Set(data.map((row) => String(row[tagConfig?.column])))];
|
|
@@ -72,6 +83,10 @@
|
|
|
72
83
|
activeTags = next;
|
|
73
84
|
};
|
|
74
85
|
|
|
86
|
+
const clearTags = () => {
|
|
87
|
+
activeTags = new Set();
|
|
88
|
+
};
|
|
89
|
+
|
|
75
90
|
const filtered = $derived(() => {
|
|
76
91
|
return data.filter((row) => {
|
|
77
92
|
const passesTag = activeTags.size === 0 || activeTags.has(String(row[tagConfig?.column!]));
|
|
@@ -82,7 +97,33 @@
|
|
|
82
97
|
return String(row[col.key]).toLowerCase().includes(filterVal.toLowerCase());
|
|
83
98
|
});
|
|
84
99
|
|
|
85
|
-
|
|
100
|
+
const passesDate = (() => {
|
|
101
|
+
if (!dateConfig || (!dateFrom && !dateTo) || dateError) return true;
|
|
102
|
+
|
|
103
|
+
const normalize = (val: string) =>
|
|
104
|
+
dateMode === 'year' && val.length > 4
|
|
105
|
+
? new Date(val).getFullYear().toString()
|
|
106
|
+
: val;
|
|
107
|
+
|
|
108
|
+
if (dateConfig.columnFrom && dateConfig.columnTo) {
|
|
109
|
+
const from = normalize(String(row[dateConfig.columnFrom]));
|
|
110
|
+
const to = normalize(String(row[dateConfig.columnTo]));
|
|
111
|
+
if (dateFrom && from < dateFrom) return false;
|
|
112
|
+
if (dateTo && to > dateTo) return false;
|
|
113
|
+
} else if (dateConfig.columnFrom) {
|
|
114
|
+
const from = normalize(String(row[dateConfig.columnFrom]));
|
|
115
|
+
if (dateFrom && from < dateFrom) return false;
|
|
116
|
+
if (dateTo && from > dateTo) return false;
|
|
117
|
+
} else if (dateConfig.columnTo) {
|
|
118
|
+
const to = normalize(String(row[dateConfig.columnTo]));
|
|
119
|
+
if (dateFrom && to < dateFrom) return false;
|
|
120
|
+
if (dateTo && to > dateTo) return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return true;
|
|
124
|
+
})();
|
|
125
|
+
|
|
126
|
+
return passesTag && passesColumns && passesDate;
|
|
86
127
|
});
|
|
87
128
|
});
|
|
88
129
|
|
|
@@ -165,46 +206,23 @@
|
|
|
165
206
|
pagination.currentPage = 1;
|
|
166
207
|
};
|
|
167
208
|
|
|
168
|
-
const clearTags = () => {
|
|
169
|
-
activeTags = new Set();
|
|
170
|
-
};
|
|
171
|
-
|
|
172
209
|
let columnName = columns.find((c) => c.key === tagConfig?.column)?.label;
|
|
173
210
|
</script>
|
|
174
211
|
|
|
175
|
-
<!-- @component
|
|
176
|
-
```Svelte
|
|
177
|
-
<TableBasic
|
|
178
|
-
data={[{ "customID": "...", "otherProperty": "..." }]}
|
|
179
|
-
tagColumn="name"
|
|
180
|
-
idKey="customID"
|
|
181
|
-
showCheckbox
|
|
182
|
-
onSelectionChange={onSelectionChange}
|
|
183
|
-
/>
|
|
184
|
-
```
|
|
185
|
-
- `data`: Object[]
|
|
186
|
-
- `tagColumn?`: string
|
|
187
|
-
- `idKey?`: string
|
|
188
|
-
- `showCheckbox?`: boolean
|
|
189
|
-
- `onSelectionChange`: () => void
|
|
190
|
-
-->
|
|
191
|
-
|
|
192
212
|
<div class="do-table">
|
|
193
213
|
<section class="do-table__header">
|
|
194
214
|
{#if tagConfig?.column}
|
|
195
215
|
<div class="do-table__header__tags">
|
|
196
216
|
{#if tagConfig.label}
|
|
197
217
|
<Button
|
|
198
|
-
label={tagConfig
|
|
218
|
+
label={tagConfig.label}
|
|
199
219
|
ariaLabel="Ver todos"
|
|
200
220
|
rounded
|
|
201
221
|
variant={activeTags.size === 0 ? 'do-btn-accent' : 'do-btn-primary'}
|
|
202
222
|
onClick={clearTags}
|
|
203
223
|
/>
|
|
204
224
|
{:else}
|
|
205
|
-
<p>
|
|
206
|
-
{columnName}:
|
|
207
|
-
</p>
|
|
225
|
+
<p>{columnName}:</p>
|
|
208
226
|
{/if}
|
|
209
227
|
{#each tagOptions() as value}
|
|
210
228
|
<Button
|
|
@@ -218,6 +236,55 @@
|
|
|
218
236
|
</div>
|
|
219
237
|
{/if}
|
|
220
238
|
|
|
239
|
+
{#if dateConfig}
|
|
240
|
+
<div class="do-table__header__dates">
|
|
241
|
+
<div class="do-table__date-range">
|
|
242
|
+
<h5>Rango fechas</h5>
|
|
243
|
+
<div class="do-table__date-fields">
|
|
244
|
+
<div class="do-table__date-fields__field">
|
|
245
|
+
{#if dateMode === 'year'}
|
|
246
|
+
<select bind:value={dateFrom} class="do-select">
|
|
247
|
+
<option value="">Desde</option>
|
|
248
|
+
{#each years as year}
|
|
249
|
+
<option value={year}>{year}</option>
|
|
250
|
+
{/each}
|
|
251
|
+
</select>
|
|
252
|
+
{:else}
|
|
253
|
+
<input type="date" bind:value={dateFrom} class="do-input" />
|
|
254
|
+
{/if}
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<div class="do-table__date-fields__field">
|
|
258
|
+
{#if dateMode === 'year'}
|
|
259
|
+
<select bind:value={dateTo} class="do-select">
|
|
260
|
+
<option value="">Hasta</option>
|
|
261
|
+
{#each years as year}
|
|
262
|
+
<option value={year}>{year}</option>
|
|
263
|
+
{/each}
|
|
264
|
+
</select>
|
|
265
|
+
{:else}
|
|
266
|
+
<input type="date" bind:value={dateTo} class="do-input" />
|
|
267
|
+
{/if}
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
{#if dateError}
|
|
271
|
+
<span class="do-table__date-error">{dateError}</span>
|
|
272
|
+
{/if}
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
{#if dateFrom || dateTo}
|
|
276
|
+
<IconButton
|
|
277
|
+
iconName="icon-close"
|
|
278
|
+
ariaLabel="limpiar fechas"
|
|
279
|
+
variant="do-btn-secondary"
|
|
280
|
+
circle
|
|
281
|
+
onClick={clearDates}
|
|
282
|
+
/>
|
|
283
|
+
{/if}
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
{/if}
|
|
287
|
+
|
|
221
288
|
{#if headerActions.length}
|
|
222
289
|
<div class="do-table__actions">
|
|
223
290
|
{#each headerActions as action}
|
|
@@ -226,7 +293,6 @@
|
|
|
226
293
|
ariaLabel={action.label}
|
|
227
294
|
label={action.label}
|
|
228
295
|
variant="do-btn-accent"
|
|
229
|
-
title="descargar"
|
|
230
296
|
onClick={action.onClick}
|
|
231
297
|
/>
|
|
232
298
|
{/each}
|
|
@@ -270,16 +336,15 @@
|
|
|
270
336
|
</th>
|
|
271
337
|
{/each}
|
|
272
338
|
{#each actionColumns as col}
|
|
273
|
-
<th class="do-table__content__th">
|
|
339
|
+
<th class="do-table__content__th do-table__content__th-action">
|
|
274
340
|
{col.showHeader !== false ? (col.label ?? '') : ''}
|
|
275
341
|
</th>
|
|
276
342
|
{/each}
|
|
277
343
|
</tr>
|
|
278
344
|
|
|
279
|
-
<!--filtros x columna -->
|
|
280
345
|
<tr class="do-table__content__filters">
|
|
281
346
|
{#if showCheckbox}
|
|
282
|
-
<th
|
|
347
|
+
<th></th>
|
|
283
348
|
{/if}
|
|
284
349
|
{#each columns as col}
|
|
285
350
|
<th class="do-table__content__th-filter">
|
|
@@ -298,6 +363,9 @@
|
|
|
298
363
|
/>
|
|
299
364
|
</th>
|
|
300
365
|
{/each}
|
|
366
|
+
{#each actionColumns as _}
|
|
367
|
+
<th></th>
|
|
368
|
+
{/each}
|
|
301
369
|
</tr>
|
|
302
370
|
</thead>
|
|
303
371
|
|
|
@@ -306,7 +374,7 @@
|
|
|
306
374
|
{@const isSelected = selected.has(row[idKey])}
|
|
307
375
|
<tr class="do-row" class:selected={isSelected}>
|
|
308
376
|
{#if showCheckbox}
|
|
309
|
-
<td class="">
|
|
377
|
+
<td class="col-check">
|
|
310
378
|
<input
|
|
311
379
|
type="checkbox"
|
|
312
380
|
class="do-checkbox"
|
|
@@ -318,12 +386,11 @@
|
|
|
318
386
|
{#each columns as col}
|
|
319
387
|
<td>{row[col.key]}</td>
|
|
320
388
|
{/each}
|
|
321
|
-
|
|
322
389
|
{#each actionColumns as col}
|
|
323
390
|
<td class="do-table__content__th-action">
|
|
324
391
|
<IconButton
|
|
325
392
|
iconName={col.icon}
|
|
326
|
-
ariaLabel="ver
|
|
393
|
+
ariaLabel="ver fila"
|
|
327
394
|
title={col.label}
|
|
328
395
|
square
|
|
329
396
|
onClick={() => col.onClick(row)}
|
|
@@ -344,9 +411,9 @@
|
|
|
344
411
|
: `${filtered().length} de ${data.length} registros`}
|
|
345
412
|
</span>
|
|
346
413
|
{#if selected.size > 0}
|
|
347
|
-
<span class="selected-count"
|
|
348
|
-
|
|
349
|
-
>
|
|
414
|
+
<span class="selected-count">
|
|
415
|
+
{selected.size} seleccionado{selected.size > 1 ? 's' : ''}
|
|
416
|
+
</span>
|
|
350
417
|
{/if}
|
|
351
418
|
{#if sortKey}
|
|
352
419
|
<span class="sort-label">
|
|
@@ -356,7 +423,6 @@
|
|
|
356
423
|
</span>
|
|
357
424
|
{/if}
|
|
358
425
|
</div>
|
|
359
|
-
|
|
360
426
|
<div class="do-table_footer__right">
|
|
361
427
|
<Pagination {pagination} {goToPage} {pageSizeChange} />
|
|
362
428
|
</div>
|
|
@@ -1,53 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type
|
|
3
|
-
column: keyof T;
|
|
4
|
-
label: string;
|
|
5
|
-
};
|
|
6
|
-
export type HeaderAction = {
|
|
7
|
-
icon: IconNames;
|
|
8
|
-
label: string;
|
|
9
|
-
onClick: () => void;
|
|
10
|
-
};
|
|
11
|
-
export type ActionColumnDef<T> = {
|
|
12
|
-
key: string;
|
|
13
|
-
icon: IconNames;
|
|
14
|
-
label?: string;
|
|
15
|
-
showHeader?: boolean;
|
|
16
|
-
onClick: (row: T) => void;
|
|
17
|
-
};
|
|
18
|
-
export type ColumnDef<T> = {
|
|
19
|
-
key: keyof T;
|
|
20
|
-
label: string;
|
|
21
|
-
};
|
|
22
|
-
type Props<T extends {
|
|
23
|
-
id: string | number;
|
|
24
|
-
}> = {
|
|
1
|
+
import type { TagConfig, DateConfig, HeaderAction, ActionColumnDef, ColumnDef } from './TableBasic.types.ts';
|
|
2
|
+
type Props<T extends Record<string, any>> = {
|
|
25
3
|
data: T[];
|
|
26
4
|
columns: ColumnDef<T>[];
|
|
27
5
|
actionColumns?: ActionColumnDef<T>[];
|
|
28
6
|
tagConfig?: TagConfig<T>;
|
|
7
|
+
dateConfig?: DateConfig<T>;
|
|
29
8
|
idKey?: keyof T;
|
|
30
9
|
headerActions?: HeaderAction[];
|
|
31
10
|
pageSize?: number;
|
|
32
11
|
showCheckbox?: boolean;
|
|
33
12
|
onSelectionChange?: (ids: (string | number)[]) => void;
|
|
34
13
|
};
|
|
35
|
-
/**
|
|
36
|
-
* ```Svelte
|
|
37
|
-
* <TableBasic
|
|
38
|
-
* data={[{ "customID": "...", "otherProperty": "..." }]}
|
|
39
|
-
* tagColumn="name"
|
|
40
|
-
* idKey="customID"
|
|
41
|
-
* showCheckbox
|
|
42
|
-
* onSelectionChange={onSelectionChange}
|
|
43
|
-
* />
|
|
44
|
-
* ```
|
|
45
|
-
* - `data`: Object[]
|
|
46
|
-
* - `tagColumn?`: string
|
|
47
|
-
* - `idKey?`: string
|
|
48
|
-
* - `showCheckbox?`: boolean
|
|
49
|
-
* - `onSelectionChange`: () => void
|
|
50
|
-
*/
|
|
51
14
|
declare const TableBasic: import("svelte").Component<Props<any>, {}, "">;
|
|
52
15
|
type TableBasic = ReturnType<typeof TableBasic>;
|
|
53
16
|
export default TableBasic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableBasic.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/TableBasic/TableBasic.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableBasic.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/TableBasic/TableBasic.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,SAAS,EAET,MAAM,uBAAuB,CAAC;AAG/B,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IAC3C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAChB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CACvD,CAAC;AAuWH,QAAA,MAAM,UAAU,gDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IconNames } from "../../do-theme/index.ts";
|
|
2
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
3
|
+
export type DateMode = 'year' | 'date';
|
|
4
|
+
export type TagConfig<T> = {
|
|
5
|
+
column: keyof T;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
export type DateConfig<T> = {
|
|
9
|
+
columnFrom?: keyof T;
|
|
10
|
+
columnTo?: keyof T;
|
|
11
|
+
mode?: DateMode;
|
|
12
|
+
};
|
|
13
|
+
export type HeaderAction = {
|
|
14
|
+
icon: IconNames;
|
|
15
|
+
label: string;
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
};
|
|
18
|
+
export type ActionColumnDef<T> = {
|
|
19
|
+
key: string;
|
|
20
|
+
icon: IconNames;
|
|
21
|
+
label?: string;
|
|
22
|
+
showHeader?: boolean;
|
|
23
|
+
onClick: (row: T) => void;
|
|
24
|
+
};
|
|
25
|
+
export type ColumnDef<T> = {
|
|
26
|
+
key: keyof T;
|
|
27
|
+
label: string;
|
|
28
|
+
};
|
|
29
|
+
export type TableProps<T extends Record<string, any>> = {
|
|
30
|
+
data: T[];
|
|
31
|
+
columns: ColumnDef<T>[];
|
|
32
|
+
actionColumns?: ActionColumnDef<T>[];
|
|
33
|
+
tagConfig?: TagConfig<T>;
|
|
34
|
+
dateConfig?: DateConfig<T>;
|
|
35
|
+
idKey?: keyof T;
|
|
36
|
+
headerActions?: HeaderAction[];
|
|
37
|
+
pageSize?: number;
|
|
38
|
+
showCheckbox?: boolean;
|
|
39
|
+
onSelectionChange?: (ids: (string | number)[]) => void;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=TableBasic.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBasic.types.d.ts","sourceRoot":"","sources":["../../../src/lib/organisms/TableBasic/TableBasic.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;AAClD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACvB,MAAM,EAAE,MAAM,CAAC,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACvB,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACpD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAChB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;CAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|