@bexis2/bexis2-core-ui 0.0.23 → 0.0.25
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 +8 -7
- package/dist/TableView.svelte +1 -1
- package/dist/components/ListView.svelte +5 -5
- package/dist/components/Table/Table.svelte +167 -0
- package/dist/components/Table/Table.svelte.d.ts +17 -0
- package/dist/components/Table/TableFilter.svelte +168 -0
- package/dist/components/Table/TableFilter.svelte.d.ts +21 -0
- package/dist/components/Table/TablePagination.svelte +60 -0
- package/dist/components/Table/TablePagination.svelte.d.ts +17 -0
- package/dist/components/Table/filter.d.ts +4 -0
- package/dist/components/Table/filter.js +83 -0
- package/dist/components/file/FileIcon.svelte +45 -49
- package/dist/components/file/FileInfo.svelte +13 -14
- package/dist/components/file/FileUploader.svelte +34 -37
- package/dist/components/form/Checkbox.svelte +13 -17
- package/dist/components/form/CheckboxKvPList.svelte +10 -12
- package/dist/components/form/CheckboxList.svelte +10 -10
- package/dist/components/form/DateInput.svelte +17 -18
- package/dist/components/form/DateInput.svelte.d.ts +4 -4
- package/dist/components/form/DropdownKvP.svelte +44 -52
- package/dist/components/form/InputContainer.svelte +18 -20
- package/dist/components/form/InputContainer.svelte.d.ts +1 -1
- package/dist/components/form/MultiSelect.svelte +89 -101
- package/dist/components/form/NumberInput.svelte +17 -18
- package/dist/components/form/NumberInput.svelte.d.ts +4 -4
- package/dist/components/form/TextArea.svelte +16 -18
- package/dist/components/form/TextArea.svelte.d.ts +4 -5
- package/dist/components/form/TextInput.svelte +17 -21
- package/dist/components/form/TextInput.svelte.d.ts +4 -4
- package/dist/components/spinner/Spinner.svelte +9 -8
- package/dist/css/core.ui.css +5 -2
- package/dist/css/themes/theme-bexis2.css +96 -100
- package/dist/css/themes/theme-crimson.css +3 -2
- package/dist/css/themes/theme-hamlindigo.css +3 -2
- package/dist/css/themes/theme-seafoam.css +3 -2
- package/dist/models/Models.d.ts +28 -0
- package/dist/services/Api.js +12 -11
- package/dist/stores/apistore.js +13 -13
- package/package.json +101 -86
- package/src/lib/TableView.svelte +1 -1
- package/src/lib/components/ListView.svelte +11 -13
- package/src/lib/components/Table/Table.svelte +184 -0
- package/src/lib/components/Table/TableFilter.svelte +176 -0
- package/src/lib/components/Table/TablePagination.svelte +61 -0
- package/src/lib/components/Table/filter.ts +94 -0
- package/src/lib/components/file/FileIcon.svelte +45 -49
- package/src/lib/components/file/FileInfo.svelte +13 -14
- package/src/lib/components/file/FileUploader.svelte +184 -217
- package/src/lib/components/form/Checkbox.svelte +24 -32
- package/src/lib/components/form/CheckboxKvPList.svelte +21 -24
- package/src/lib/components/form/CheckboxList.svelte +21 -22
- package/src/lib/components/form/DateInput.svelte +24 -30
- package/src/lib/components/form/DropdownKvP.svelte +44 -52
- package/src/lib/components/form/InputContainer.svelte +22 -27
- package/src/lib/components/form/MultiSelect.svelte +89 -101
- package/src/lib/components/form/NumberInput.svelte +24 -30
- package/src/lib/components/form/TextArea.svelte +23 -28
- package/src/lib/components/form/TextInput.svelte +24 -33
- package/src/lib/components/spinner/Spinner.svelte +9 -8
- package/src/lib/css/core.ui.css +5 -2
- package/src/lib/css/themes/theme-bexis2.css +96 -100
- package/src/lib/css/themes/theme-crimson.css +3 -2
- package/src/lib/css/themes/theme-hamlindigo.css +3 -2
- package/src/lib/css/themes/theme-seafoam.css +3 -2
- package/src/lib/index.ts +31 -23
- package/src/lib/models/Models.ts +70 -39
- package/src/lib/services/Api.ts +55 -58
- package/src/lib/stores/apistore.ts +28 -32
package/package.json
CHANGED
|
@@ -1,88 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
2
|
+
"name": "@bexis2/bexis2-core-ui",
|
|
3
|
+
"version": "0.0.25",
|
|
4
|
+
"private": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite dev --host",
|
|
7
|
+
"package": "svelte-package --watch",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"build package": "svelte-kit sync && svelte-package --watch",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"test": "playwright test",
|
|
12
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
13
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
14
|
+
"test:unit": "vitest",
|
|
15
|
+
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
|
16
|
+
"format": "prettier --plugin-search-dir . --write .",
|
|
17
|
+
"init": "npm init --scope bexis2",
|
|
18
|
+
"link": "npm link",
|
|
19
|
+
"publish": "npm publish --access public",
|
|
20
|
+
"install bexis2-core-ui localy": "npm install ../bexis2-core-ui"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@bexis2/bexis2-core-ui": "file:../bexis2-core-ui/dist",
|
|
24
|
+
"@playwright/test": "^1.28.1",
|
|
25
|
+
"@skeletonlabs/skeleton": "^1.2.5",
|
|
26
|
+
"@sveltejs/adapter-auto": "^2.0.0",
|
|
27
|
+
"@sveltejs/adapter-static": "^2.0.2",
|
|
28
|
+
"@sveltejs/kit": "^1.5.0",
|
|
29
|
+
"@sveltejs/package": "^2.0.2",
|
|
30
|
+
"@tailwindcss/forms": "^0.5.3",
|
|
31
|
+
"@tailwindcss/line-clamp": "^0.4.2",
|
|
32
|
+
"@tailwindcss/typography": "^0.5.9",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
34
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
35
|
+
"autoprefixer": "^10.4.14",
|
|
36
|
+
"eslint": "^8.28.0",
|
|
37
|
+
"eslint-config-prettier": "^8.5.0",
|
|
38
|
+
"eslint-plugin-svelte3": "^4.0.0",
|
|
39
|
+
"postcss": "^8.4.23",
|
|
40
|
+
"prettier": "^2.8.0",
|
|
41
|
+
"prettier-plugin-svelte": "^2.8.1",
|
|
42
|
+
"raw-loader": "^4.0.2",
|
|
43
|
+
"svelte": "^3.54.0",
|
|
44
|
+
"svelte-check": "^3.0.1",
|
|
45
|
+
"svelte-fa": "^3.0.3",
|
|
46
|
+
"svelte-headless-table": "^0.17.3",
|
|
47
|
+
"tailwindcss": "^3.3.2",
|
|
48
|
+
"tslib": "^2.4.1",
|
|
49
|
+
"typescript": "^5.0.0",
|
|
50
|
+
"vite": "^4.3.0",
|
|
51
|
+
"vitest": "^0.25.3"
|
|
52
|
+
},
|
|
53
|
+
"type": "module",
|
|
54
|
+
"module": "./src/lib/index.ts",
|
|
55
|
+
"types": "./src/lib/index.d.ts",
|
|
56
|
+
"description": "Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).",
|
|
57
|
+
"main": "./src/lib/index.d.ts",
|
|
58
|
+
"directories": {
|
|
59
|
+
"test": "tests"
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"src/lib"
|
|
64
|
+
],
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@floating-ui/dom": "^1.2.7",
|
|
67
|
+
"@fortawesome/fontawesome-free": "^6.2.1",
|
|
68
|
+
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
69
|
+
"@fortawesome/free-regular-svg-icons": "^6.2.1",
|
|
70
|
+
"@fortawesome/free-solid-svg-icons": "^6.2.1",
|
|
71
|
+
"axios": "^1.2.1",
|
|
72
|
+
"highlight.js": "^11.8.0",
|
|
73
|
+
"highlightjs-svelte": "^1.0.6",
|
|
74
|
+
"svelte": "^3.54.0",
|
|
75
|
+
"svelte-file-dropzone": "^2.0.1",
|
|
76
|
+
"svelte-select": "^5.6.0",
|
|
77
|
+
"vest": "^4.6.11"
|
|
78
|
+
},
|
|
79
|
+
"author": "David Schöne",
|
|
80
|
+
"license": "ISC",
|
|
81
|
+
"repository": {
|
|
82
|
+
"type": "git",
|
|
83
|
+
"url": "git+https://github.com/BEXIS2/bexis2-core-ui.git"
|
|
84
|
+
},
|
|
85
|
+
"bugs": {
|
|
86
|
+
"url": "https://github.com/BEXIS2/bexis2-core-ui/issues"
|
|
87
|
+
},
|
|
88
|
+
"homepage": "https://github.com/BEXIS2/bexis2-core-ui#readme",
|
|
89
|
+
"keywords": [
|
|
90
|
+
"bexis2",
|
|
91
|
+
"libary"
|
|
92
|
+
],
|
|
93
|
+
"exports": {
|
|
94
|
+
".": {
|
|
95
|
+
"types": "./dist/index.d.ts",
|
|
96
|
+
"svelte": "./dist/index.js"
|
|
97
|
+
},
|
|
98
|
+
"./dist/index.css": {
|
|
99
|
+
"import": "./dist/index.css",
|
|
100
|
+
"require": "./dist/index.css"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
88
103
|
}
|
package/src/lib/TableView.svelte
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<h1>table</h1>
|
|
1
|
+
<h1>table</h1>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
{result.name}
|
|
13
|
-
<b>from bexis-lib</b>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type x = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
let result: x = { name: 'david' };
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<h1>MyList</h1>
|
|
10
|
+
{result.name}
|
|
11
|
+
<b>from bexis-lib</b>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createTable, Subscribe, Render, createRender } from 'svelte-headless-table';
|
|
3
|
+
import {
|
|
4
|
+
addSortBy,
|
|
5
|
+
addPagination,
|
|
6
|
+
addExpandedRows,
|
|
7
|
+
addColumnFilters,
|
|
8
|
+
addTableFilter
|
|
9
|
+
} from 'svelte-headless-table/plugins';
|
|
10
|
+
|
|
11
|
+
import TableFilter from './TableFilter.svelte';
|
|
12
|
+
import TablePagination from './TablePagination.svelte';
|
|
13
|
+
import { columnFilter, searchFilter } from './filter';
|
|
14
|
+
import type { TableConfig } from '$lib/models/Models';
|
|
15
|
+
|
|
16
|
+
export let config: TableConfig<any>;
|
|
17
|
+
let {
|
|
18
|
+
id: tableId,
|
|
19
|
+
data,
|
|
20
|
+
columns,
|
|
21
|
+
optionsComponent,
|
|
22
|
+
defaultPageSize = 10,
|
|
23
|
+
pageSizes = [5, 10, 15, 20]
|
|
24
|
+
} = config;
|
|
25
|
+
|
|
26
|
+
type AccessorType = keyof (typeof $data)[0];
|
|
27
|
+
|
|
28
|
+
const table = createTable(data, {
|
|
29
|
+
colFilter: addColumnFilters(),
|
|
30
|
+
tableFilter: addTableFilter({
|
|
31
|
+
fn: searchFilter
|
|
32
|
+
}),
|
|
33
|
+
sort: addSortBy({ disableMultiSort: true }),
|
|
34
|
+
page: addPagination({ initialPageSize: defaultPageSize }),
|
|
35
|
+
expand: addExpandedRows()
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const accessors: AccessorType[] = Object.keys($data[0]) as AccessorType[];
|
|
39
|
+
|
|
40
|
+
const tableColumns = [
|
|
41
|
+
...accessors
|
|
42
|
+
.filter((accessor) => {
|
|
43
|
+
const key = accessor as string;
|
|
44
|
+
if (columns !== undefined && key in columns && columns[key].exclude === true) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
})
|
|
49
|
+
.map((accessor) => {
|
|
50
|
+
const key = accessor as string;
|
|
51
|
+
if (columns !== undefined && key in columns) {
|
|
52
|
+
const { header, colFilterFn, colFilterComponent } = columns[key];
|
|
53
|
+
return table.column({
|
|
54
|
+
header: header ?? key,
|
|
55
|
+
accessor: accessor,
|
|
56
|
+
plugins: {
|
|
57
|
+
sort: { invert: true },
|
|
58
|
+
colFilter: {
|
|
59
|
+
fn: colFilterFn ?? columnFilter,
|
|
60
|
+
render: ({ filterValue, values, id }) =>
|
|
61
|
+
createRender(colFilterComponent ?? TableFilter, {
|
|
62
|
+
filterValue,
|
|
63
|
+
values,
|
|
64
|
+
id,
|
|
65
|
+
tableId
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
return table.column({
|
|
72
|
+
header: key,
|
|
73
|
+
accessor: accessor,
|
|
74
|
+
plugins: {
|
|
75
|
+
sort: { invert: true },
|
|
76
|
+
colFilter: {
|
|
77
|
+
fn: columnFilter,
|
|
78
|
+
render: ({ filterValue, values, id }) =>
|
|
79
|
+
createRender(TableFilter, { filterValue, values, id, tableId })
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
if (optionsComponent !== undefined) {
|
|
88
|
+
tableColumns.push(
|
|
89
|
+
table.display({
|
|
90
|
+
id: 'options',
|
|
91
|
+
header: '',
|
|
92
|
+
cell: ({ row }, _) => {
|
|
93
|
+
return createRender(optionsComponent!, {
|
|
94
|
+
row: row.isData() ? row.original : null
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}) as any
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const createdTableColumns = table.createColumns(tableColumns);
|
|
102
|
+
|
|
103
|
+
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates } =
|
|
104
|
+
table.createViewModel(createdTableColumns);
|
|
105
|
+
const { filterValue } = pluginStates.tableFilter;
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<div class="grid gap-2">
|
|
109
|
+
<div class="table-container">
|
|
110
|
+
<input
|
|
111
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
112
|
+
type="text"
|
|
113
|
+
bind:value={$filterValue}
|
|
114
|
+
placeholder="Search rows..."
|
|
115
|
+
/>
|
|
116
|
+
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
117
|
+
<thead>
|
|
118
|
+
{#each $headerRows as headerRow (headerRow.id)}
|
|
119
|
+
<Subscribe
|
|
120
|
+
rowAttrs={headerRow.attrs()}
|
|
121
|
+
let:rowAttrs
|
|
122
|
+
rowProps={headerRow.props()}
|
|
123
|
+
let:rowProps
|
|
124
|
+
>
|
|
125
|
+
<tr {...rowAttrs} class="bg-primary-300">
|
|
126
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
127
|
+
<Subscribe attrs={cell.attrs()} props={cell.props()} let:props let:attrs>
|
|
128
|
+
<th scope="col" class="!p-2" {...attrs}>
|
|
129
|
+
<div class="flex w-full justify-between items-center">
|
|
130
|
+
<div class="flex gap-1">
|
|
131
|
+
<span
|
|
132
|
+
class:underline={props.sort.order}
|
|
133
|
+
class:normal-case={cell.id !== cell.label}
|
|
134
|
+
on:click={props.sort.toggle}
|
|
135
|
+
on:keydown={props.sort.toggle}
|
|
136
|
+
>
|
|
137
|
+
{cell.render()}
|
|
138
|
+
</span>
|
|
139
|
+
<div class="w-2">
|
|
140
|
+
{#if props.sort.order === 'asc'}
|
|
141
|
+
▾
|
|
142
|
+
{:else if props.sort.order === 'desc'}
|
|
143
|
+
▴
|
|
144
|
+
{/if}
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
{#if cell.isData()}
|
|
148
|
+
{#if props.colFilter?.render}
|
|
149
|
+
<div>
|
|
150
|
+
<Render of={props.colFilter.render} />
|
|
151
|
+
</div>
|
|
152
|
+
{/if}
|
|
153
|
+
{/if}
|
|
154
|
+
</div>
|
|
155
|
+
</th>
|
|
156
|
+
</Subscribe>
|
|
157
|
+
{/each}
|
|
158
|
+
</tr>
|
|
159
|
+
</Subscribe>
|
|
160
|
+
{/each}
|
|
161
|
+
</thead>
|
|
162
|
+
|
|
163
|
+
<tbody class="" {...$tableBodyAttrs}>
|
|
164
|
+
{#each $pageRows as row (row.id)}
|
|
165
|
+
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
|
166
|
+
<tr {...rowAttrs}>
|
|
167
|
+
{#each row.cells as cell (cell?.id)}
|
|
168
|
+
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
169
|
+
<td {...attrs} class="!p-2">
|
|
170
|
+
<div class="flex items-center w-full h-full table-cell-fit">
|
|
171
|
+
<Render of={cell.render()} />
|
|
172
|
+
</div>
|
|
173
|
+
</td>
|
|
174
|
+
</Subscribe>
|
|
175
|
+
{/each}
|
|
176
|
+
</tr>
|
|
177
|
+
</Subscribe>
|
|
178
|
+
{/each}
|
|
179
|
+
</tbody>
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
184
|
+
</div>
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Fa from 'svelte-fa/src/fa.svelte';
|
|
3
|
+
import { faFilter } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { popup } from '@skeletonlabs/skeleton';
|
|
5
|
+
import type { PopupSettings } from '@skeletonlabs/skeleton';
|
|
6
|
+
|
|
7
|
+
export let filterValue;
|
|
8
|
+
export let values;
|
|
9
|
+
export let id;
|
|
10
|
+
export let tableId;
|
|
11
|
+
|
|
12
|
+
let firstOption;
|
|
13
|
+
let firstValue;
|
|
14
|
+
let secondOption;
|
|
15
|
+
let secondValue;
|
|
16
|
+
let active = false;
|
|
17
|
+
|
|
18
|
+
const options = {
|
|
19
|
+
number: [
|
|
20
|
+
{
|
|
21
|
+
value: 'isequal',
|
|
22
|
+
label: 'Is equal to'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 'isgreaterorequal',
|
|
26
|
+
label: 'Is greater than or equal to'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'isgreater',
|
|
30
|
+
label: 'Is greater than'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: 'islessorequal',
|
|
34
|
+
label: 'Is less than or equal to'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: 'isless',
|
|
38
|
+
label: 'Is less than'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: 'isnotequal',
|
|
42
|
+
label: 'Is not equal to'
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
string: [
|
|
46
|
+
{
|
|
47
|
+
value: 'isequal',
|
|
48
|
+
label: 'Is equal to'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
value: 'isnotequal',
|
|
52
|
+
label: 'Is not equal to'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
value: 'starts',
|
|
56
|
+
label: 'Starts with'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: 'contains',
|
|
60
|
+
label: 'Contains'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: 'notcontains',
|
|
64
|
+
label: 'Does not contain'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: 'ends',
|
|
68
|
+
label: 'Ends with'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const popupId = `${tableId}-${id}`;
|
|
74
|
+
|
|
75
|
+
const popupFeatured: PopupSettings = {
|
|
76
|
+
event: 'click',
|
|
77
|
+
target: popupId,
|
|
78
|
+
placement: 'bottom-start'
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const type = typeof $values[0];
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<form class="">
|
|
85
|
+
<button
|
|
86
|
+
class:variant-filled-primary={active}
|
|
87
|
+
class="btn w-max p-2"
|
|
88
|
+
type="button"
|
|
89
|
+
use:popup={popupFeatured}
|
|
90
|
+
>
|
|
91
|
+
<Fa icon={faFilter} size="12" />
|
|
92
|
+
</button>
|
|
93
|
+
|
|
94
|
+
<div data-popup={`${popupId}`}>
|
|
95
|
+
<div class="card p-3 absolute grid gap-2 shadow-lg z-10 w-min">
|
|
96
|
+
<button
|
|
97
|
+
class="btn variant-filled-primary btn-sm"
|
|
98
|
+
type="submit"
|
|
99
|
+
on:click={() => {
|
|
100
|
+
firstOption = 'isequal';
|
|
101
|
+
firstValue = undefined;
|
|
102
|
+
secondOption = 'isequal';
|
|
103
|
+
secondValue = undefined;
|
|
104
|
+
|
|
105
|
+
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
106
|
+
active = false;
|
|
107
|
+
}}>Clear Filter</button
|
|
108
|
+
>
|
|
109
|
+
|
|
110
|
+
<label for="" class="label normal-case text-sm">Show rows with value that</label>
|
|
111
|
+
<div class="grid gap-2 w-full">
|
|
112
|
+
<select
|
|
113
|
+
class="select border border-primary-500 text-sm p-1"
|
|
114
|
+
aria-label="Show rows with value that"
|
|
115
|
+
bind:value={firstOption}
|
|
116
|
+
on:click|stopPropagation
|
|
117
|
+
>
|
|
118
|
+
{#each options[type] as option (option)}
|
|
119
|
+
<option value={option.value}>{option.label}</option>
|
|
120
|
+
{/each}
|
|
121
|
+
</select>
|
|
122
|
+
{#if type === 'number'}
|
|
123
|
+
<input
|
|
124
|
+
type="number"
|
|
125
|
+
class="input p-1 border border-primary-500"
|
|
126
|
+
bind:value={firstValue}
|
|
127
|
+
on:click|stopPropagation
|
|
128
|
+
/>
|
|
129
|
+
{:else}
|
|
130
|
+
<input
|
|
131
|
+
type="text"
|
|
132
|
+
class="input p-1 border border-primary-500"
|
|
133
|
+
bind:value={firstValue}
|
|
134
|
+
on:click|stopPropagation
|
|
135
|
+
/>
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
<label for="" class="label normal-case">And</label>
|
|
139
|
+
<div class="grid gap-2 w-max">
|
|
140
|
+
<select
|
|
141
|
+
class="select border border-primary-500 text-sm p-1"
|
|
142
|
+
aria-label="Show rows with value that"
|
|
143
|
+
bind:value={secondOption}
|
|
144
|
+
on:click|stopPropagation
|
|
145
|
+
>
|
|
146
|
+
{#each options[type] as option (option)}
|
|
147
|
+
<option value={option.value}>{option.label}</option>
|
|
148
|
+
{/each}
|
|
149
|
+
</select>
|
|
150
|
+
{#if type === 'number'}
|
|
151
|
+
<input
|
|
152
|
+
type="number"
|
|
153
|
+
class="input p-1 border border-primary-500"
|
|
154
|
+
bind:value={secondValue}
|
|
155
|
+
on:click|stopPropagation
|
|
156
|
+
/>
|
|
157
|
+
{:else}
|
|
158
|
+
<input
|
|
159
|
+
type="text"
|
|
160
|
+
class="input p-1 border border-primary-500"
|
|
161
|
+
bind:value={secondValue}
|
|
162
|
+
on:click|stopPropagation
|
|
163
|
+
/>
|
|
164
|
+
{/if}
|
|
165
|
+
</div>
|
|
166
|
+
<button
|
|
167
|
+
class="btn variant-filled-primary btn-sm"
|
|
168
|
+
type="submit"
|
|
169
|
+
on:click={() => {
|
|
170
|
+
active = firstValue?.toString().length > 0 || secondValue?.toString().length > 0;
|
|
171
|
+
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
172
|
+
}}>Submit</button
|
|
173
|
+
>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</form>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Fa from 'svelte-fa/src/fa.svelte';
|
|
3
|
+
import {
|
|
4
|
+
faAnglesRight,
|
|
5
|
+
faAngleRight,
|
|
6
|
+
faAnglesLeft,
|
|
7
|
+
faAngleLeft
|
|
8
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
9
|
+
|
|
10
|
+
export let pageConfig;
|
|
11
|
+
export let pageSizes;
|
|
12
|
+
|
|
13
|
+
const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
|
|
14
|
+
|
|
15
|
+
const goToFirstPage = () => ($pageIndex = 0);
|
|
16
|
+
const goToLastPage = () => ($pageIndex = $pageCount - 1);
|
|
17
|
+
const goToNextPage = () => ($pageIndex += 1);
|
|
18
|
+
const goToPreviousPage = () => ($pageIndex -= 1);
|
|
19
|
+
|
|
20
|
+
$: goToFirstPageDisabled = !$pageIndex;
|
|
21
|
+
$: goToLastPageDisabled = $pageIndex == $pageCount - 1;
|
|
22
|
+
$: goToNextPageDisabled = !$hasNextPage;
|
|
23
|
+
$: goToPreviousPageDisabled = !$hasPreviousPage;
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<div class="flex justify-center gap-1">
|
|
27
|
+
<button
|
|
28
|
+
class="btn btn-sm variant-filled-primary"
|
|
29
|
+
on:click={goToFirstPage}
|
|
30
|
+
disabled={goToFirstPageDisabled}
|
|
31
|
+
>
|
|
32
|
+
<Fa icon={faAnglesLeft} /></button
|
|
33
|
+
>
|
|
34
|
+
<button
|
|
35
|
+
class="btn btn-sm variant-filled-primary"
|
|
36
|
+
on:click={goToPreviousPage}
|
|
37
|
+
disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
<select
|
|
41
|
+
name="pageSize"
|
|
42
|
+
id="pageSize"
|
|
43
|
+
class="select btn btn-sm variant-filled-primary w-min font-bold"
|
|
44
|
+
bind:value={$pageSize}
|
|
45
|
+
>
|
|
46
|
+
{#each pageSizes as size}
|
|
47
|
+
<option value={size}>{size}</option>
|
|
48
|
+
{/each}
|
|
49
|
+
</select>
|
|
50
|
+
|
|
51
|
+
<button
|
|
52
|
+
class="btn btn-sm variant-filled-primary"
|
|
53
|
+
on:click={goToNextPage}
|
|
54
|
+
disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
|
|
55
|
+
>
|
|
56
|
+
<button
|
|
57
|
+
class="btn btn-sm variant-filled-primary"
|
|
58
|
+
on:click={goToLastPage}
|
|
59
|
+
disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
|
|
60
|
+
>
|
|
61
|
+
</div>
|