@bexis2/bexis2-core-ui 0.0.29 → 0.0.31
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/README.md +26 -0
- package/dist/components/Table/Table.svelte +132 -94
- package/dist/components/Table/Table.svelte.d.ts +2 -0
- package/dist/components/Table/TableFilter.svelte +50 -5
- package/dist/components/Table/TablePagination.svelte +1 -1
- package/dist/components/Table/filter.js +43 -3
- package/dist/components/page/Alert.svelte +39 -0
- package/dist/components/page/Alert.svelte.d.ts +22 -0
- package/dist/components/page/Page.svelte +1 -1
- package/dist/components/spinner/Spinner.svelte +11 -1
- package/dist/components/spinner/Spinner.svelte.d.ts +9 -13
- package/dist/css/themes/theme-bexis2.css +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/models/Enums.d.ts +5 -0
- package/dist/models/Enums.js +6 -0
- package/dist/models/Models.d.ts +8 -0
- package/package.json +2 -3
- package/src/lib/components/Table/Table.svelte +230 -184
- package/src/lib/components/Table/TableFilter.svelte +50 -5
- package/src/lib/components/Table/TablePagination.svelte +1 -1
- package/src/lib/components/Table/filter.ts +141 -94
- package/src/lib/components/page/Alert.svelte +46 -0
- package/src/lib/components/page/Page.svelte +1 -1
- package/src/lib/components/spinner/Spinner.svelte +14 -1
- package/src/lib/css/themes/theme-bexis2.css +3 -3
- package/src/lib/index.ts +2 -1
- package/src/lib/models/Enums.ts +6 -0
- package/src/lib/models/Models.ts +88 -78
package/README.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# bexis-core-ui
|
|
2
2
|
|
|
3
|
+
## v0.0.31
|
|
4
|
+
### add
|
|
5
|
+
#### components
|
|
6
|
+
- Alert
|
|
7
|
+
|
|
8
|
+
### updates
|
|
9
|
+
#### components
|
|
10
|
+
- Spinner
|
|
11
|
+
- label
|
|
12
|
+
- color
|
|
13
|
+
- position
|
|
14
|
+
|
|
15
|
+
- Table
|
|
16
|
+
- Date filters
|
|
17
|
+
- Configuration for complex types
|
|
18
|
+
- Custom event dispatcher
|
|
19
|
+
- Updated docs.
|
|
20
|
+
- Disabling of filters
|
|
21
|
+
- Disabling of sorting
|
|
22
|
+
|
|
23
|
+
### fixes:
|
|
24
|
+
#### table
|
|
25
|
+
- Arrow in pageSize dropdown.
|
|
26
|
+
- Bug with number filter not working on zero values.
|
|
27
|
+
- Table of Contents on the right sidebar.
|
|
28
|
+
|
|
3
29
|
## v0.0.29
|
|
4
30
|
|
|
5
31
|
### add
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { createTable, Subscribe, Render, createRender } from "svelte-headless-table";
|
|
2
3
|
import {
|
|
3
4
|
addSortBy,
|
|
4
5
|
addPagination,
|
|
@@ -18,6 +19,8 @@ let {
|
|
|
18
19
|
defaultPageSize = 10,
|
|
19
20
|
pageSizes = [5, 10, 15, 20]
|
|
20
21
|
} = config;
|
|
22
|
+
const dispatch = createEventDispatcher();
|
|
23
|
+
const actionDispatcher = (obj) => dispatch("action", obj);
|
|
21
24
|
const table = createTable(data, {
|
|
22
25
|
colFilter: addColumnFilters(),
|
|
23
26
|
tableFilter: addTableFilter({
|
|
@@ -27,7 +30,7 @@ const table = createTable(data, {
|
|
|
27
30
|
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
28
31
|
expand: addExpandedRows()
|
|
29
32
|
});
|
|
30
|
-
const accessors = Object.keys($data[0]);
|
|
33
|
+
const accessors = $data.length > 0 ? Object.keys($data[0]) : [];
|
|
31
34
|
const tableColumns = [
|
|
32
35
|
...accessors.filter((accessor) => {
|
|
33
36
|
const key = accessor;
|
|
@@ -38,20 +41,47 @@ const tableColumns = [
|
|
|
38
41
|
}).map((accessor) => {
|
|
39
42
|
const key = accessor;
|
|
40
43
|
if (columns !== void 0 && key in columns) {
|
|
41
|
-
const {
|
|
44
|
+
const {
|
|
45
|
+
header,
|
|
46
|
+
colFilterFn,
|
|
47
|
+
colFilterComponent,
|
|
48
|
+
instructions,
|
|
49
|
+
disableFiltering = false,
|
|
50
|
+
disableSorting = false
|
|
51
|
+
} = columns[key];
|
|
52
|
+
const { toSortableValueFn, toFilterableValueFn, toStringFn } = instructions ?? {};
|
|
42
53
|
return table.column({
|
|
43
54
|
header: header ?? key,
|
|
44
55
|
accessor,
|
|
56
|
+
cell: ({ value }) => {
|
|
57
|
+
return toStringFn ? toStringFn(value) : value;
|
|
58
|
+
},
|
|
45
59
|
plugins: {
|
|
46
|
-
sort: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})
|
|
60
|
+
sort: {
|
|
61
|
+
disable: disableSorting,
|
|
62
|
+
invert: true,
|
|
63
|
+
getSortValue: (row) => {
|
|
64
|
+
return toSortableValueFn ? toSortableValueFn(row) : row;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
colFilter: !disableFiltering ? {
|
|
68
|
+
fn: ({ filterValue: filterValue2, value }) => {
|
|
69
|
+
const val = toFilterableValueFn ? toFilterableValueFn(value) : value;
|
|
70
|
+
return colFilterFn ? colFilterFn({ filterValue: filterValue2, value: val }) : columnFilter({ filterValue: filterValue2, value: val });
|
|
71
|
+
},
|
|
72
|
+
render: ({ filterValue: filterValue2, values, id }) => {
|
|
73
|
+
return createRender(colFilterComponent ?? TableFilter, {
|
|
74
|
+
filterValue: filterValue2,
|
|
75
|
+
id,
|
|
76
|
+
tableId,
|
|
77
|
+
values
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
} : void 0,
|
|
81
|
+
tableFilter: {
|
|
82
|
+
getFilterValue: (row) => {
|
|
83
|
+
return toStringFn ? toStringFn(row) : row;
|
|
84
|
+
}
|
|
55
85
|
}
|
|
56
86
|
}
|
|
57
87
|
});
|
|
@@ -60,10 +90,17 @@ const tableColumns = [
|
|
|
60
90
|
header: key,
|
|
61
91
|
accessor,
|
|
62
92
|
plugins: {
|
|
63
|
-
sort: {
|
|
93
|
+
sort: {
|
|
94
|
+
invert: true
|
|
95
|
+
},
|
|
64
96
|
colFilter: {
|
|
65
97
|
fn: columnFilter,
|
|
66
|
-
render: ({ filterValue: filterValue2, values, id }) => createRender(TableFilter, {
|
|
98
|
+
render: ({ filterValue: filterValue2, values, id }) => createRender(TableFilter, {
|
|
99
|
+
filterValue: filterValue2,
|
|
100
|
+
id,
|
|
101
|
+
tableId,
|
|
102
|
+
values
|
|
103
|
+
})
|
|
67
104
|
}
|
|
68
105
|
}
|
|
69
106
|
});
|
|
@@ -77,7 +114,8 @@ if (optionsComponent !== void 0) {
|
|
|
77
114
|
header: "",
|
|
78
115
|
cell: ({ row }, _) => {
|
|
79
116
|
return createRender(optionsComponent, {
|
|
80
|
-
row: row.isData() ? row.original : null
|
|
117
|
+
row: row.isData() ? row.original : null,
|
|
118
|
+
dispatchFn: actionDispatcher
|
|
81
119
|
});
|
|
82
120
|
}
|
|
83
121
|
})
|
|
@@ -86,82 +124,82 @@ if (optionsComponent !== void 0) {
|
|
|
86
124
|
const createdTableColumns = table.createColumns(tableColumns);
|
|
87
125
|
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } = table.createViewModel(createdTableColumns);
|
|
88
126
|
const { filterValue } = pluginStates.tableFilter;
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<div class="grid gap-2">
|
|
92
|
-
<div class="table-container">
|
|
93
|
-
<input
|
|
94
|
-
class="input p-2 mb-2 border border-primary-500"
|
|
95
|
-
type="text"
|
|
96
|
-
bind:value={$filterValue}
|
|
97
|
-
placeholder="Search rows..."
|
|
98
|
-
/>
|
|
99
|
-
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
100
|
-
<thead>
|
|
101
|
-
{#each $headerRows as headerRow (headerRow.id)}
|
|
102
|
-
<Subscribe
|
|
103
|
-
rowAttrs={headerRow.attrs()}
|
|
104
|
-
let:rowAttrs
|
|
105
|
-
rowProps={headerRow.props()}
|
|
106
|
-
let:rowProps
|
|
107
|
-
>
|
|
108
|
-
<tr {...rowAttrs} class="bg-primary-300">
|
|
109
|
-
{#each headerRow.cells as cell (cell.id)}
|
|
110
|
-
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
111
|
-
<th scope="col" class="!p-2" {...attrs}>
|
|
112
|
-
<div class="flex w-full justify-between items-center">
|
|
113
|
-
<div class="flex gap-1">
|
|
114
|
-
<span
|
|
115
|
-
class:underline={props.sort.order}
|
|
116
|
-
class:normal-case={cell.id !== cell.label}
|
|
117
|
-
on:click={props.sort.toggle}
|
|
118
|
-
on:keydown={props.sort.toggle}
|
|
119
|
-
>
|
|
120
|
-
{cell.render()}
|
|
121
|
-
</span>
|
|
122
|
-
<div class="w-2">
|
|
123
|
-
{#if props.sort.order === 'asc'}
|
|
124
|
-
▾
|
|
125
|
-
{:else if props.sort.order === 'desc'}
|
|
126
|
-
▴
|
|
127
|
-
{/if}
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
{#if cell.isData()}
|
|
131
|
-
{#if props.colFilter?.render}
|
|
132
|
-
<div>
|
|
133
|
-
<Render of={props.colFilter.render} />
|
|
134
|
-
</div>
|
|
135
|
-
{/if}
|
|
136
|
-
{/if}
|
|
137
|
-
</div>
|
|
138
|
-
</th>
|
|
139
|
-
</Subscribe>
|
|
140
|
-
{/each}
|
|
141
|
-
</tr>
|
|
142
|
-
</Subscribe>
|
|
143
|
-
{/each}
|
|
144
|
-
</thead>
|
|
145
|
-
|
|
146
|
-
<tbody class="" {...$tableBodyAttrs}>
|
|
147
|
-
{#each $pageRows as row (row.id)}
|
|
148
|
-
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
149
|
-
<tr {...rowAttrs}>
|
|
150
|
-
{#each row.cells as cell (cell?.id)}
|
|
151
|
-
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
152
|
-
<td {...attrs} class="!p-2">
|
|
153
|
-
<div class="flex items-center w-full h-full table-cell-fit">
|
|
154
|
-
<Render of={cell.render()} />
|
|
155
|
-
</div>
|
|
156
|
-
</td>
|
|
157
|
-
</Subscribe>
|
|
158
|
-
{/each}
|
|
159
|
-
</tr>
|
|
160
|
-
</Subscribe>
|
|
161
|
-
{/each}
|
|
162
|
-
</tbody>
|
|
163
|
-
</table>
|
|
164
|
-
</div>
|
|
165
|
-
|
|
166
|
-
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
167
|
-
</div>
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<div class="grid gap-2">
|
|
130
|
+
<div class="table-container">
|
|
131
|
+
<input
|
|
132
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
133
|
+
type="text"
|
|
134
|
+
bind:value={$filterValue}
|
|
135
|
+
placeholder="Search rows..."
|
|
136
|
+
/>
|
|
137
|
+
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
138
|
+
<thead>
|
|
139
|
+
{#each $headerRows as headerRow (headerRow.id)}
|
|
140
|
+
<Subscribe
|
|
141
|
+
rowAttrs={headerRow.attrs()}
|
|
142
|
+
let:rowAttrs
|
|
143
|
+
rowProps={headerRow.props()}
|
|
144
|
+
let:rowProps
|
|
145
|
+
>
|
|
146
|
+
<tr {...rowAttrs} class="bg-primary-300">
|
|
147
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
148
|
+
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
149
|
+
<th scope="col" class="!p-2" {...attrs}>
|
|
150
|
+
<div class="flex w-full justify-between items-center">
|
|
151
|
+
<div class="flex gap-1">
|
|
152
|
+
<span
|
|
153
|
+
class:underline={props.sort.order}
|
|
154
|
+
class:normal-case={cell.id !== cell.label}
|
|
155
|
+
on:click={props.sort.toggle}
|
|
156
|
+
on:keydown={props.sort.toggle}
|
|
157
|
+
>
|
|
158
|
+
{cell.render()}
|
|
159
|
+
</span>
|
|
160
|
+
<div class="w-2">
|
|
161
|
+
{#if props.sort.order === 'asc'}
|
|
162
|
+
▾
|
|
163
|
+
{:else if props.sort.order === 'desc'}
|
|
164
|
+
▴
|
|
165
|
+
{/if}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
{#if cell.isData()}
|
|
169
|
+
{#if props.colFilter?.render}
|
|
170
|
+
<div>
|
|
171
|
+
<Render of={props.colFilter.render} />
|
|
172
|
+
</div>
|
|
173
|
+
{/if}
|
|
174
|
+
{/if}
|
|
175
|
+
</div>
|
|
176
|
+
</th>
|
|
177
|
+
</Subscribe>
|
|
178
|
+
{/each}
|
|
179
|
+
</tr>
|
|
180
|
+
</Subscribe>
|
|
181
|
+
{/each}
|
|
182
|
+
</thead>
|
|
183
|
+
|
|
184
|
+
<tbody class="" {...$tableBodyAttrs}>
|
|
185
|
+
{#each $pageRows as row (row.id)}
|
|
186
|
+
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
187
|
+
<tr {...rowAttrs}>
|
|
188
|
+
{#each row.cells as cell (cell?.id)}
|
|
189
|
+
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
190
|
+
<td {...attrs} class="!p-2">
|
|
191
|
+
<div class="flex items-center w-full h-full table-cell-fit">
|
|
192
|
+
<Render of={cell.render()} />
|
|
193
|
+
</div>
|
|
194
|
+
</td>
|
|
195
|
+
</Subscribe>
|
|
196
|
+
{/each}
|
|
197
|
+
</tr>
|
|
198
|
+
</Subscribe>
|
|
199
|
+
{/each}
|
|
200
|
+
</tbody>
|
|
201
|
+
</table>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
205
|
+
</div>
|
|
@@ -62,6 +62,32 @@ const options = {
|
|
|
62
62
|
value: "ends",
|
|
63
63
|
label: "Ends with"
|
|
64
64
|
}
|
|
65
|
+
],
|
|
66
|
+
date: [
|
|
67
|
+
{
|
|
68
|
+
value: "ison",
|
|
69
|
+
label: "Is on"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: "isstartingfrom",
|
|
73
|
+
label: "Is starting from"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: "isafter",
|
|
77
|
+
label: "Is after"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: "isuntil",
|
|
81
|
+
label: "Is until"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "isbefore",
|
|
85
|
+
label: "Is before"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
value: "isnoton",
|
|
89
|
+
label: "Is not on"
|
|
90
|
+
}
|
|
65
91
|
]
|
|
66
92
|
};
|
|
67
93
|
const popupId = `${tableId}-${id}`;
|
|
@@ -70,7 +96,12 @@ const popupFeatured = {
|
|
|
70
96
|
target: popupId,
|
|
71
97
|
placement: "bottom-start"
|
|
72
98
|
};
|
|
73
|
-
|
|
99
|
+
let type = typeof $values[0];
|
|
100
|
+
if (type === "object") {
|
|
101
|
+
if ($values[0] instanceof Date) {
|
|
102
|
+
type = "date";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
74
105
|
</script>
|
|
75
106
|
|
|
76
107
|
<form class="">
|
|
@@ -87,7 +118,7 @@ const type = typeof $values[0];
|
|
|
87
118
|
<div class="card p-3 absolute grid gap-2 shadow-lg z-10 w-min">
|
|
88
119
|
<button
|
|
89
120
|
class="btn variant-filled-primary btn-sm"
|
|
90
|
-
type="
|
|
121
|
+
type="button"
|
|
91
122
|
on:click|preventDefault={() => {
|
|
92
123
|
firstOption = 'isequal';
|
|
93
124
|
firstValue = undefined;
|
|
@@ -118,13 +149,20 @@ const type = typeof $values[0];
|
|
|
118
149
|
bind:value={firstValue}
|
|
119
150
|
on:click|stopPropagation
|
|
120
151
|
/>
|
|
121
|
-
{:else}
|
|
152
|
+
{:else if type === 'string'}
|
|
122
153
|
<input
|
|
123
154
|
type="text"
|
|
124
155
|
class="input p-1 border border-primary-500"
|
|
125
156
|
bind:value={firstValue}
|
|
126
157
|
on:click|stopPropagation
|
|
127
158
|
/>
|
|
159
|
+
{:else}
|
|
160
|
+
<input
|
|
161
|
+
type="date"
|
|
162
|
+
class="input p-1 border border-primary-500"
|
|
163
|
+
bind:value={firstValue}
|
|
164
|
+
on:click|stopPropagation
|
|
165
|
+
/>
|
|
128
166
|
{/if}
|
|
129
167
|
</div>
|
|
130
168
|
<label for="" class="label normal-case">And</label>
|
|
@@ -146,18 +184,25 @@ const type = typeof $values[0];
|
|
|
146
184
|
bind:value={secondValue}
|
|
147
185
|
on:click|stopPropagation
|
|
148
186
|
/>
|
|
149
|
-
{:else}
|
|
187
|
+
{:else if type === 'string'}
|
|
150
188
|
<input
|
|
151
189
|
type="text"
|
|
152
190
|
class="input p-1 border border-primary-500"
|
|
153
191
|
bind:value={secondValue}
|
|
154
192
|
on:click|stopPropagation
|
|
155
193
|
/>
|
|
194
|
+
{:else}
|
|
195
|
+
<input
|
|
196
|
+
type="date"
|
|
197
|
+
class="input p-1 border border-primary-500"
|
|
198
|
+
bind:value={secondValue}
|
|
199
|
+
on:click|stopPropagation
|
|
200
|
+
/>
|
|
156
201
|
{/if}
|
|
157
202
|
</div>
|
|
158
203
|
<button
|
|
159
204
|
class="btn variant-filled-primary btn-sm"
|
|
160
|
-
type="
|
|
205
|
+
type="button"
|
|
161
206
|
on:click|preventDefault={() => {
|
|
162
207
|
active = firstValue?.toString().length > 0 || secondValue?.toString().length > 0;
|
|
163
208
|
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
@@ -34,15 +34,38 @@ const numberFilter = (filterOption, filterValue, value) => {
|
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
const dateFilter = (filterOption, filterValue, value) => {
|
|
38
|
+
const filter = new Date(filterValue);
|
|
39
|
+
switch (filterOption) {
|
|
40
|
+
case 'ison':
|
|
41
|
+
return value === filter;
|
|
42
|
+
case 'isstartingfrom':
|
|
43
|
+
return value >= filter;
|
|
44
|
+
case 'isafter':
|
|
45
|
+
return value > filter;
|
|
46
|
+
case 'isuntil':
|
|
47
|
+
return value <= filter;
|
|
48
|
+
case 'isbefore':
|
|
49
|
+
return value < filter;
|
|
50
|
+
case 'isnoton':
|
|
51
|
+
return value !== filter;
|
|
52
|
+
default:
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
37
56
|
const numericFilter = ({ filterValue, value }) => {
|
|
38
57
|
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
39
|
-
if (
|
|
58
|
+
if (firstFilterValue == null && !secondFilterValue == null) {
|
|
40
59
|
return true;
|
|
41
60
|
}
|
|
42
|
-
else if ((
|
|
61
|
+
else if ((firstFilterOption == null || firstFilterValue == null) &&
|
|
62
|
+
secondFilterOption != null &&
|
|
63
|
+
secondFilterValue != null) {
|
|
43
64
|
return numberFilter(secondFilterOption, secondFilterValue, value);
|
|
44
65
|
}
|
|
45
|
-
else if ((
|
|
66
|
+
else if ((secondFilterOption == null || secondFilterValue == null) &&
|
|
67
|
+
firstFilterOption != null &&
|
|
68
|
+
firstFilterValue != null) {
|
|
46
69
|
return numberFilter(firstFilterOption, firstFilterValue, value);
|
|
47
70
|
}
|
|
48
71
|
return (numberFilter(firstFilterOption, firstFilterValue, value) &&
|
|
@@ -66,6 +89,20 @@ const stringFilter = ({ filterValue, value }) => {
|
|
|
66
89
|
return (textFilter(firstFilterOption, firstFilterValue, value) &&
|
|
67
90
|
textFilter(secondFilterOption, secondFilterValue, value));
|
|
68
91
|
};
|
|
92
|
+
const dateTypeFilter = ({ filterValue, value }) => {
|
|
93
|
+
const [firstFilterOption, firstFilterValue, secondFilterOption, secondFilterValue] = filterValue;
|
|
94
|
+
if (!firstFilterValue && !secondFilterValue) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
else if ((!firstFilterOption || !firstFilterValue) && secondFilterOption && secondFilterValue) {
|
|
98
|
+
return dateFilter(secondFilterOption, secondFilterValue, value);
|
|
99
|
+
}
|
|
100
|
+
else if ((!secondFilterOption || !secondFilterValue) && firstFilterOption && firstFilterValue) {
|
|
101
|
+
return dateFilter(firstFilterOption, firstFilterValue, value);
|
|
102
|
+
}
|
|
103
|
+
return (dateFilter(firstFilterOption, firstFilterValue, value) &&
|
|
104
|
+
dateFilter(secondFilterOption, secondFilterValue, value));
|
|
105
|
+
};
|
|
69
106
|
export const columnFilter = ({ filterValue, value }) => {
|
|
70
107
|
if (typeof value === 'string') {
|
|
71
108
|
return stringFilter({ filterValue, value });
|
|
@@ -73,6 +110,9 @@ export const columnFilter = ({ filterValue, value }) => {
|
|
|
73
110
|
else if (typeof value === 'number') {
|
|
74
111
|
return numericFilter({ filterValue, value });
|
|
75
112
|
}
|
|
113
|
+
else if (typeof value === 'object' && value instanceof Date) {
|
|
114
|
+
return dateTypeFilter({ filterValue, value });
|
|
115
|
+
}
|
|
76
116
|
return false;
|
|
77
117
|
};
|
|
78
118
|
export const searchFilter = ({ filterValue, value }) => {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script>import Fa from "svelte-fa";
|
|
2
|
+
import { faXmark } from "@fortawesome/free-solid-svg-icons";
|
|
3
|
+
import { fade } from "svelte/transition";
|
|
4
|
+
export let title = "";
|
|
5
|
+
export let message = "";
|
|
6
|
+
export let cssClass = "";
|
|
7
|
+
export let deleteBtn = true;
|
|
8
|
+
$:
|
|
9
|
+
show = true;
|
|
10
|
+
</script>
|
|
11
|
+
{#if show}
|
|
12
|
+
|
|
13
|
+
<aside class="alert {cssClass}" transition:fade|local={{ duration: 100 }}>
|
|
14
|
+
<!-- Icon -->
|
|
15
|
+
<!-- <div>(icon)</div> -->
|
|
16
|
+
<!-- Message -->
|
|
17
|
+
<div class="alert-message">
|
|
18
|
+
|
|
19
|
+
{#if title}
|
|
20
|
+
<h3 class="h3">{title}</h3>
|
|
21
|
+
{/if}
|
|
22
|
+
<p>{message}
|
|
23
|
+
<slot></slot>
|
|
24
|
+
</p>
|
|
25
|
+
</div>
|
|
26
|
+
<!-- Actions -->
|
|
27
|
+
<div class="alert-actions">
|
|
28
|
+
<slot name="actions"/>
|
|
29
|
+
|
|
30
|
+
{#if deleteBtn}
|
|
31
|
+
<button class="btn hover:text-primary-100" on:click={()=>show = false}>
|
|
32
|
+
<Fa icon={faXmark} />
|
|
33
|
+
</button>
|
|
34
|
+
{/if}
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
</aside>
|
|
38
|
+
|
|
39
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
cssClass?: string | undefined;
|
|
7
|
+
deleteBtn?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
actions: {};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type AlertProps = typeof __propDef.props;
|
|
18
|
+
export type AlertEvents = typeof __propDef.events;
|
|
19
|
+
export type AlertSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Alert extends SvelteComponentTyped<AlertProps, AlertEvents, AlertSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
<script>import { Position } from "../../models/Enums";
|
|
2
|
+
export let textCss = "text-secundary-500";
|
|
3
|
+
export let label = "";
|
|
4
|
+
export let position = Position.start;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class="flex justify-{position} items-{position} h-full w-full gap-5 pt-2">
|
|
1
8
|
<div
|
|
2
|
-
class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]
|
|
9
|
+
class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite] {textCss}"
|
|
3
10
|
role="status"
|
|
4
11
|
>
|
|
5
12
|
<span
|
|
@@ -7,3 +14,6 @@
|
|
|
7
14
|
>Loading...</span
|
|
8
15
|
>
|
|
9
16
|
</div>
|
|
17
|
+
<span>{label}</span>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} SpinnerProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} SpinnerEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} SpinnerSlots */
|
|
4
|
-
export default class Spinner extends SvelteComponentTyped<{
|
|
5
|
-
[x: string]: never;
|
|
6
|
-
}, {
|
|
7
|
-
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
}
|
|
10
|
-
export type SpinnerProps = typeof __propDef.props;
|
|
11
|
-
export type SpinnerEvents = typeof __propDef.events;
|
|
12
|
-
export type SpinnerSlots = typeof __propDef.slots;
|
|
13
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { Position } from "../../models/Enums";
|
|
14
3
|
declare const __propDef: {
|
|
15
4
|
props: {
|
|
16
|
-
|
|
5
|
+
textCss?: string | undefined;
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
position?: Position | undefined;
|
|
17
8
|
};
|
|
18
9
|
events: {
|
|
19
10
|
[evt: string]: CustomEvent<any>;
|
|
20
11
|
};
|
|
21
12
|
slots: {};
|
|
22
13
|
};
|
|
14
|
+
export type SpinnerProps = typeof __propDef.props;
|
|
15
|
+
export type SpinnerEvents = typeof __propDef.events;
|
|
16
|
+
export type SpinnerSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Spinner extends SvelteComponentTyped<SpinnerProps, SpinnerEvents, SpinnerSlots> {
|
|
18
|
+
}
|
|
23
19
|
export {};
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
--theme-rounded-container: 4px;
|
|
9
9
|
--theme-border-base: 1px;
|
|
10
10
|
/* =~= Theme On-X Colors =~= */
|
|
11
|
-
--on-primary:
|
|
12
|
-
--on-secondary:
|
|
11
|
+
--on-primary: 255 255 255;
|
|
12
|
+
--on-secondary: 255 255 255;
|
|
13
13
|
--on-tertiary: 0 0 0;
|
|
14
|
-
--on-success:
|
|
14
|
+
--on-success: 255 255 255;
|
|
15
15
|
--on-warning: 255 255 255;
|
|
16
16
|
--on-error: 255 255 255;
|
|
17
17
|
--on-surface: 0 0 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import FileInfo from './components/file/FileInfo.svelte';
|
|
|
5
5
|
import FileUploader from './components/file/FileUploader.svelte';
|
|
6
6
|
import Spinner from './components/spinner/Spinner.svelte';
|
|
7
7
|
import Page from './components/page/Page.svelte';
|
|
8
|
+
import Alert from './components/page/Alert.svelte';
|
|
8
9
|
import Checkbox from './components/form/Checkbox.svelte';
|
|
9
10
|
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
10
11
|
import CheckboxList from './components/form/CheckboxList.svelte';
|
|
@@ -20,7 +21,7 @@ import { columnFilter, searchFilter } from './components/Table/filter';
|
|
|
20
21
|
import type { TableConfig, Columns, Column } from './models/Models';
|
|
21
22
|
export { Checkbox, CheckboxKVPList, CheckboxList, DateInput, DropdownKVP, MultiSelect, NumberInput, TextArea, TextInput };
|
|
22
23
|
export { FileInfo, FileIcon, FileUploader };
|
|
23
|
-
export { ListView, TableView, Spinner, Page };
|
|
24
|
+
export { ListView, TableView, Spinner, Page, Alert };
|
|
24
25
|
export { Api } from './services/Api.js';
|
|
25
26
|
export { host, username, password, setApiConfig } from './stores/apistore.js';
|
|
26
27
|
export type { user, Input, FileUploaderModel, Link } from './models/Models.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import FileUploader from './components/file/FileUploader.svelte';
|
|
|
7
7
|
//page
|
|
8
8
|
import Spinner from './components/spinner/Spinner.svelte';
|
|
9
9
|
import Page from './components/page/Page.svelte';
|
|
10
|
+
import Alert from './components/page/Alert.svelte';
|
|
10
11
|
// input
|
|
11
12
|
import Checkbox from './components/form/Checkbox.svelte';
|
|
12
13
|
import CheckboxKVPList from './components/form/CheckboxKvPList.svelte';
|
|
@@ -25,7 +26,7 @@ export { Checkbox, CheckboxKVPList, CheckboxList, DateInput, DropdownKVP, MultiS
|
|
|
25
26
|
//File
|
|
26
27
|
export { FileInfo, FileIcon, FileUploader };
|
|
27
28
|
//others
|
|
28
|
-
export { ListView, TableView, Spinner, Page };
|
|
29
|
+
export { ListView, TableView, Spinner, Page, Alert };
|
|
29
30
|
//Api
|
|
30
31
|
export { Api } from './services/Api.js';
|
|
31
32
|
export { host, username, password, setApiConfig } from './stores/apistore.js';
|