@kws3/ui 1.1.0 → 1.2.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.
- package/buttons/SubmitButton.svelte +4 -4
- package/controls/NumberInput.svelte +4 -1
- package/datagrid/DataSearch/DataSearch.svelte +45 -11
- package/datagrid/DataSearch/SearchFilter.svelte +82 -19
- package/datagrid/DataSort/DataSort.svelte +16 -6
- package/datagrid/GridView/GridCell.svelte +23 -7
- package/datagrid/GridView/GridRow.svelte +60 -15
- package/datagrid/GridView/GridView.svelte +79 -19
- package/datagrid/Pagination/Pagination.svelte +8 -2
- package/datagrid/TileView/TileView.svelte +64 -16
- package/datagrid/TileView/TileViewItem.svelte +36 -9
- package/forms/Datepicker.svelte +4 -4
- package/forms/select/MultiSelect.svelte +581 -0
- package/forms/select/SearchableSelect.svelte +149 -0
- package/helpers/ClipboardCopier.svelte +2 -2
- package/helpers/FloatingUI/Floatie.svelte +141 -0
- package/helpers/FloatingUI/FloatingUIOutput.svelte +34 -0
- package/helpers/FloatingUI/index.js +156 -0
- package/helpers/Icon.svelte +2 -2
- package/index.js +8 -1
- package/package.json +2 -2
- package/settings.js +15 -3
- package/styles/FloatingUI.scss +163 -0
- package/styles/Panel.scss +2 -3
- package/styles/Select.scss +203 -0
- package/forms/SearchableSelect.svelte +0 -438
- package/styles/SearchableSelect.scss +0 -128
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
/**
|
|
119
119
|
* call this function after form saved
|
|
120
120
|
*/
|
|
121
|
-
export function saved(callback) {
|
|
121
|
+
export function saved(callback, timeout = 3000) {
|
|
122
122
|
tracker = {
|
|
123
123
|
saving: false,
|
|
124
124
|
saved: true,
|
|
@@ -136,13 +136,13 @@
|
|
|
136
136
|
*/
|
|
137
137
|
fire("saved");
|
|
138
138
|
callback && callback();
|
|
139
|
-
},
|
|
139
|
+
}, timeout);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* call this function on form error state
|
|
144
144
|
*/
|
|
145
|
-
export function error(callback) {
|
|
145
|
+
export function error(callback, timeout = 3000) {
|
|
146
146
|
tracker = {
|
|
147
147
|
saving: false,
|
|
148
148
|
saved: false,
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
*/
|
|
161
161
|
fire("error");
|
|
162
162
|
callback && callback();
|
|
163
|
-
},
|
|
163
|
+
}, timeout);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
$: err_text = error_text == "" ? text : error_text;
|
|
@@ -49,7 +49,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
49
49
|
max
|
|
50
50
|
step
|
|
51
51
|
{disabled}
|
|
52
|
-
readonly={typeable}
|
|
52
|
+
readonly={!typeable}
|
|
53
53
|
bind:value
|
|
54
54
|
on:blur={isBlurred()}
|
|
55
55
|
on:focus={isFocused()} />
|
|
@@ -82,6 +82,9 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
82
82
|
appearance: none;
|
|
83
83
|
margin: 0;
|
|
84
84
|
}
|
|
85
|
+
input[type="number"] {
|
|
86
|
+
-moz-appearance: textfield;
|
|
87
|
+
}
|
|
85
88
|
</style>
|
|
86
89
|
|
|
87
90
|
<script>
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {boolean} [hasSearch=true] -
|
|
6
|
-
@param {boolean} [hasFilters=true] -
|
|
7
|
-
@param {string} [placeholder=""] - Placeholder
|
|
8
|
-
@param {object} [filters={}] -
|
|
9
|
-
@param {string} [q=""] -
|
|
10
|
-
@param {string} [filter_in_use_class="is-in-use"] -
|
|
11
|
-
@param {string} [filter_not_in_use_class="is-not-in-use"] -
|
|
12
|
-
@param {object} [filterComponent=null] -
|
|
13
|
-
@param {object} [filter_label_map={}] -
|
|
5
|
+
@param {boolean} [hasSearch=true] - Determines whether there is a search input or not, Default: `true`
|
|
6
|
+
@param {boolean} [hasFilters=true] - Determines if there are filters on search, Default: `true`
|
|
7
|
+
@param {string} [placeholder=""] - Placeholder text for the search input, Default: `""`
|
|
8
|
+
@param {object} [filters={}] - Contains all the filter dropdown values, Default: `{}`
|
|
9
|
+
@param {string} [q=""] - Query string from the browser url, Default: `""`
|
|
10
|
+
@param {string} [filter_in_use_class="is-in-use"] - CSS class for in use filters, Default: `"is-in-use"`
|
|
11
|
+
@param {string} [filter_not_in_use_class="is-not-in-use"] - Css class for not in use filters, Default: `"is-not-in-use"`
|
|
12
|
+
@param {object} [filterComponent=null] - To use a custom component for filters, Default: `null`
|
|
13
|
+
@param {object} [filter_label_map={}] - Contains all the labels for the filter dropdowns, Default: `{}`
|
|
14
14
|
|
|
15
15
|
### Events
|
|
16
|
-
- `resetSearch`
|
|
17
|
-
- `search`
|
|
16
|
+
- `resetSearch` - Triggered when the search is reset
|
|
17
|
+
- `search` - Event triggered on search
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
|
+
|
|
20
21
|
<form on:submit|preventDefault={dosearch}>
|
|
21
22
|
<div class="field has-addons">
|
|
22
23
|
{#if hasSearch}
|
|
@@ -66,14 +67,41 @@
|
|
|
66
67
|
|
|
67
68
|
const fire = createEventDispatcher();
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Determines whether there is a search input or not
|
|
72
|
+
*/
|
|
69
73
|
export let hasSearch = true,
|
|
74
|
+
/**
|
|
75
|
+
* Determines if there are filters on search
|
|
76
|
+
*/
|
|
70
77
|
hasFilters = true,
|
|
78
|
+
/**
|
|
79
|
+
* Placeholder text for the search input
|
|
80
|
+
*/
|
|
71
81
|
placeholder = "",
|
|
82
|
+
/**
|
|
83
|
+
* Contains all the filter dropdown values
|
|
84
|
+
*/
|
|
72
85
|
filters = {},
|
|
86
|
+
/**
|
|
87
|
+
* Query string from the browser url
|
|
88
|
+
*/
|
|
73
89
|
q = "",
|
|
90
|
+
/**
|
|
91
|
+
* CSS class for in use filters
|
|
92
|
+
*/
|
|
74
93
|
filter_in_use_class = "is-in-use",
|
|
94
|
+
/**
|
|
95
|
+
* Css class for not in use filters
|
|
96
|
+
*/
|
|
75
97
|
filter_not_in_use_class = "is-not-in-use",
|
|
98
|
+
/**
|
|
99
|
+
* To use a custom component for filters
|
|
100
|
+
*/
|
|
76
101
|
filterComponent = null,
|
|
102
|
+
/**
|
|
103
|
+
* Contains all the labels for the filter dropdowns
|
|
104
|
+
*/
|
|
77
105
|
filter_label_map = {};
|
|
78
106
|
|
|
79
107
|
let query = "",
|
|
@@ -133,6 +161,9 @@
|
|
|
133
161
|
query = "";
|
|
134
162
|
filterVals = filterVals;
|
|
135
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Triggered when the search is reset
|
|
166
|
+
*/
|
|
136
167
|
fire("resetSearch");
|
|
137
168
|
}
|
|
138
169
|
|
|
@@ -142,6 +173,9 @@
|
|
|
142
173
|
for (var i in filterVals) {
|
|
143
174
|
filterVals[i] && ret.push(i + ":" + filterVals[i]);
|
|
144
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Event triggered on search
|
|
178
|
+
*/
|
|
145
179
|
fire("search", ret.join("~"));
|
|
146
180
|
}
|
|
147
181
|
</script>
|
|
@@ -2,16 +2,26 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {object} [filter={}] -
|
|
6
|
-
@param {object} [filterVals={}] -
|
|
7
|
-
@param {string} [filterWidthStyle=""] -
|
|
8
|
-
@param {string} [hilightClass=""] -
|
|
9
|
-
@param {object} [filter_label_map={}] -
|
|
5
|
+
@param {object} [filter={}] - Contains filter options for dropdown, Default: `{}`
|
|
6
|
+
@param {object} [filterVals={}] - Contains the selected filter values, Default: `{}`
|
|
7
|
+
@param {string} [filterWidthStyle=""] - Inline CSS style for the filters, Default: `""`
|
|
8
|
+
@param {string} [hilightClass=""] - CSS classes for highlighted filter, Default: `""`
|
|
9
|
+
@param {object} [filter_label_map={}] - Contains custom labels for the filter, Default: `{}`
|
|
10
10
|
|
|
11
11
|
-->
|
|
12
12
|
|
|
13
13
|
{#if filter.type == "multiselect"}
|
|
14
|
-
<div class="control" style={filterWidthStyle}>
|
|
14
|
+
<div class="control" style={filterWidthStyle}>
|
|
15
|
+
<MultiSelect
|
|
16
|
+
options={sanitizedOptions}
|
|
17
|
+
placeholder={`Any ${name}`}
|
|
18
|
+
bind:value={multiSelectValue}
|
|
19
|
+
on:change={convertValuesToString}
|
|
20
|
+
search_key="name"
|
|
21
|
+
value_key="id"
|
|
22
|
+
summary_mode
|
|
23
|
+
class={hilightClass} />
|
|
24
|
+
</div>
|
|
15
25
|
{:else if filter.type == "date"}
|
|
16
26
|
<div class="control" style={filterWidthStyle}>
|
|
17
27
|
<Datepicker
|
|
@@ -28,15 +38,15 @@
|
|
|
28
38
|
placeholder="{capitaliseFirstLetter(name)} Date Range" />
|
|
29
39
|
</div>
|
|
30
40
|
{:else if filter.options.length > 10}
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
<div class="control" style={filterWidthStyle}>
|
|
42
|
+
<SearchableSelect
|
|
43
|
+
options={sanitizedOptions}
|
|
44
|
+
placeholder={`Any ${name}`}
|
|
45
|
+
bind:value={filterVals[filter.name]}
|
|
46
|
+
search_key="name"
|
|
47
|
+
value_key="id"
|
|
48
|
+
class={hilightClass} />
|
|
49
|
+
</div>
|
|
40
50
|
{:else}
|
|
41
51
|
<div
|
|
42
52
|
class="select {hilightClass}"
|
|
@@ -47,26 +57,79 @@
|
|
|
47
57
|
class="is-radiusless {hilightClass}"
|
|
48
58
|
style="max-width:100%"
|
|
49
59
|
data-cy={cy}>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
{#each sanitizedOptions as option}
|
|
61
|
+
{#if option}
|
|
62
|
+
<option value={option.id}>{option.name}</option>
|
|
63
|
+
{/if}
|
|
53
64
|
{/each}
|
|
54
65
|
</select>
|
|
55
66
|
</div>
|
|
56
67
|
{/if}
|
|
57
68
|
|
|
58
69
|
<script>
|
|
59
|
-
import {
|
|
70
|
+
import { tick } from "svelte";
|
|
71
|
+
import { SearchableSelect, MultiSelect, Datepicker } from "@kws3/ui";
|
|
60
72
|
import { capitaliseFirstLetter } from "@kws3/ui/utils";
|
|
61
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Contains filter options for dropdown
|
|
76
|
+
*/
|
|
62
77
|
export let filter = {},
|
|
78
|
+
/**
|
|
79
|
+
* Contains the selected filter values
|
|
80
|
+
*/
|
|
63
81
|
filterVals = {},
|
|
82
|
+
/**
|
|
83
|
+
* Inline CSS style for the filters
|
|
84
|
+
*/
|
|
64
85
|
filterWidthStyle = "",
|
|
86
|
+
/**
|
|
87
|
+
* CSS classes for highlighted filter
|
|
88
|
+
*/
|
|
65
89
|
hilightClass = "",
|
|
90
|
+
/**
|
|
91
|
+
* Contains custom labels for the filter
|
|
92
|
+
*/
|
|
66
93
|
filter_label_map = {};
|
|
67
94
|
|
|
95
|
+
let sanitizedOptions = [],
|
|
96
|
+
multiSelectValue = [];
|
|
97
|
+
|
|
68
98
|
$: name = filter_label_map[filter.name]
|
|
69
99
|
? filter_label_map[filter.name]
|
|
70
100
|
: filter.name.replace(/_/g, " ");
|
|
101
|
+
$: filter, name, sanitizeOptions();
|
|
71
102
|
$: cy = name ? name.replace(/\s+/g, "-").toLowerCase() : "";
|
|
103
|
+
|
|
104
|
+
$: filterVals, filter, convertToValuesArray();
|
|
105
|
+
|
|
106
|
+
function convertValuesToString() {
|
|
107
|
+
tick().then(() => {
|
|
108
|
+
filterVals[filter.name] = multiSelectValue
|
|
109
|
+
? multiSelectValue.join("|")
|
|
110
|
+
: "";
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function convertToValuesArray() {
|
|
114
|
+
if (filter && filter.type == "multiselect") {
|
|
115
|
+
multiSelectValue = filterVals[filter.name]
|
|
116
|
+
? filterVals[filter.name].split("|")
|
|
117
|
+
: [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function sanitizeOptions() {
|
|
122
|
+
let options = filter.options || [];
|
|
123
|
+
if (options.length) {
|
|
124
|
+
options =
|
|
125
|
+
filter.type == "multiselect"
|
|
126
|
+
? options
|
|
127
|
+
: [{ id: "", name: `Any ${name}` }, ...options];
|
|
128
|
+
options = options.map((el) => {
|
|
129
|
+
el.id = el.id + "";
|
|
130
|
+
return el;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
sanitizedOptions = options;
|
|
134
|
+
}
|
|
72
135
|
</script>
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {array} [options=[]] -
|
|
6
|
-
@param {string} [sort_by=""] -
|
|
7
|
-
@param {string} [value=""] - Value property, Default: `""`
|
|
5
|
+
@param {array} [options=[]] - List of options in the dropdown, Default: `[]`
|
|
6
|
+
@param {string} [sort_by=""] - Stores the selected option value, Default: `""`
|
|
8
7
|
|
|
9
8
|
-->
|
|
9
|
+
|
|
10
10
|
<div class="sorting-filters">
|
|
11
11
|
<div class="field is-grouped">
|
|
12
12
|
<div class="control">
|
|
@@ -30,10 +30,20 @@
|
|
|
30
30
|
|
|
31
31
|
const fire = createEventDispatcher();
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* List of options in the dropdown
|
|
35
|
+
*/
|
|
33
36
|
export let options = [],
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Stores the selected option value
|
|
39
|
+
*/
|
|
40
|
+
sort_by = "";
|
|
41
|
+
|
|
42
|
+
let value = "";
|
|
36
43
|
|
|
37
44
|
$: value, fire("sort", value);
|
|
38
|
-
|
|
45
|
+
|
|
46
|
+
$: {
|
|
47
|
+
value = sort_by.replace("%20", " ");
|
|
48
|
+
}
|
|
39
49
|
</script>
|
|
@@ -2,21 +2,37 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {string} [column=""] -
|
|
6
|
-
@param {object} [row={}] -
|
|
7
|
-
@param {object} [transforms={}] -
|
|
8
|
-
@param {object} [classNames={}] -
|
|
9
|
-
@param {object} [styles={}] -
|
|
5
|
+
@param {string} [column=""] - Name of the column in the DB, Default: `""`
|
|
6
|
+
@param {object} [row={}] - List of all values in a row, Default: `{}`
|
|
7
|
+
@param {object} [transforms={}] - Finds custom values for the column, Default: `{}`
|
|
8
|
+
@param {object} [classNames={}] - Finds CSS class for the column, Default: `{}`
|
|
9
|
+
@param {object} [styles={}] - Finds CSS styles for the column, Default: `{}`
|
|
10
10
|
|
|
11
11
|
-->
|
|
12
12
|
|
|
13
|
-
<td class={classNames(column, row)} style={styles(column, row)}
|
|
14
|
-
|
|
13
|
+
<td class={classNames(column, row)} style={styles(column, row)}>
|
|
14
|
+
{@html transforms(column, row)}
|
|
15
|
+
</td>
|
|
15
16
|
|
|
16
17
|
<script>
|
|
18
|
+
/**
|
|
19
|
+
* Name of the column in the DB
|
|
20
|
+
*/
|
|
17
21
|
export let column = "",
|
|
22
|
+
/**
|
|
23
|
+
* List of all values in a row
|
|
24
|
+
*/
|
|
18
25
|
row = {},
|
|
26
|
+
/**
|
|
27
|
+
* Finds custom values for the column
|
|
28
|
+
*/
|
|
19
29
|
transforms = {},
|
|
30
|
+
/**
|
|
31
|
+
* Finds CSS class for the column
|
|
32
|
+
*/
|
|
20
33
|
classNames = {},
|
|
34
|
+
/**
|
|
35
|
+
* Finds CSS styles for the column
|
|
36
|
+
*/
|
|
21
37
|
styles = {};
|
|
22
38
|
</script>
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {number} [row_index=0] -
|
|
6
|
-
@param {object} [row={}] -
|
|
7
|
-
@param {boolean} [rowActive=false] -
|
|
8
|
-
@param {object} [isVisible={}] -
|
|
9
|
-
@param {boolean} [clickableRows=false] -
|
|
10
|
-
@param {object} [transforms={}] -
|
|
11
|
-
@param {object} [classNames={}] -
|
|
12
|
-
@param {boolean} [transition=false] -
|
|
13
|
-
@param {object} [styles={}] -
|
|
5
|
+
@param {number} [row_index=0] - Row index value, Default: `0`
|
|
6
|
+
@param {object} [row={}] - Contains all the column values in a row, Default: `{}`
|
|
7
|
+
@param {boolean} [rowActive=false] - Determines whether the row is selected or not, Default: `false`
|
|
8
|
+
@param {object} [isVisible={}] - Determines whether column is visible or not, Default: `{}`
|
|
9
|
+
@param {boolean} [clickableRows=false] - Determines whether the row is clickable or not, Default: `false`
|
|
10
|
+
@param {object} [transforms={}] - Contains all custom values for each columns, Default: `{}`
|
|
11
|
+
@param {object} [classNames={}] - Contails all CSS class for each column, Default: `{}`
|
|
12
|
+
@param {boolean} [transition=false] - Determines whether the row has transition effect or not, Default: `false`
|
|
13
|
+
@param {object} [styles={}] - Contains all CSS styles for each column, Default: `{}`
|
|
14
14
|
@param {array} [column_keys=[]] - Column_keys property, Default: `[]`
|
|
15
|
-
@param {boolean} [bulk_actions=false] -
|
|
16
|
-
@param {boolean} [checked=false] -
|
|
17
|
-
@param {array} [selectedIds=[]] -
|
|
18
|
-
@param {string} [selectCheckboxColor="info"] -
|
|
19
|
-
@param {string} [selectCheckboxSize="medium"] -
|
|
20
|
-
@param {function} [cellComponent()] -
|
|
15
|
+
@param {boolean} [bulk_actions=false] - Determines if selecting multiple rows and doing multiple actions is allowed, Default: `false`
|
|
16
|
+
@param {boolean} [checked=false] - Determines whether the checkbox is checked or not, Default: `false`
|
|
17
|
+
@param {array} [selectedIds=[]] - List of unique IDs of all the selected rows, Default: `[]`
|
|
18
|
+
@param {string} [selectCheckboxColor="info"] - Selected checkbox color, Default: `"info"`
|
|
19
|
+
@param {string} [selectCheckboxSize="medium"] - selected checkbox size, Default: `"medium"`
|
|
20
|
+
@param {function} [cellComponent()] - Custom cell component for a column
|
|
21
21
|
|
|
22
22
|
### Events
|
|
23
23
|
- `rowSelectChecked`
|
|
@@ -90,21 +90,66 @@
|
|
|
90
90
|
|
|
91
91
|
const fire = createEventDispatcher();
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Row index value
|
|
95
|
+
*/
|
|
93
96
|
export let row_index = 0,
|
|
97
|
+
/**
|
|
98
|
+
* Contains all the column values in a row
|
|
99
|
+
*/
|
|
94
100
|
row = {},
|
|
101
|
+
/**
|
|
102
|
+
* Determines whether the row is selected or not
|
|
103
|
+
*/
|
|
95
104
|
rowActive = false,
|
|
105
|
+
/**
|
|
106
|
+
* Determines whether column is visible or not
|
|
107
|
+
*/
|
|
96
108
|
isVisible = {},
|
|
109
|
+
/**
|
|
110
|
+
* Determines whether the row is clickable or not
|
|
111
|
+
*/
|
|
97
112
|
clickableRows = false,
|
|
113
|
+
/**
|
|
114
|
+
* Contains all custom values for each columns
|
|
115
|
+
*/
|
|
98
116
|
transforms = {},
|
|
117
|
+
/**
|
|
118
|
+
* Contails all CSS class for each column
|
|
119
|
+
*/
|
|
99
120
|
classNames = {},
|
|
121
|
+
/**
|
|
122
|
+
* Determines whether the row has transition effect or not
|
|
123
|
+
*/
|
|
100
124
|
transition = false,
|
|
125
|
+
/**
|
|
126
|
+
* Contains all CSS styles for each column
|
|
127
|
+
*/
|
|
101
128
|
styles = {},
|
|
102
129
|
column_keys = [],
|
|
130
|
+
/**
|
|
131
|
+
* Determines if selecting multiple rows and doing multiple actions is allowed
|
|
132
|
+
*/
|
|
103
133
|
bulk_actions = false,
|
|
134
|
+
/**
|
|
135
|
+
* Determines whether the checkbox is checked or not
|
|
136
|
+
*/
|
|
104
137
|
checked = false,
|
|
138
|
+
/**
|
|
139
|
+
* List of unique IDs of all the selected rows
|
|
140
|
+
*/
|
|
105
141
|
selectedIds = [],
|
|
142
|
+
/**
|
|
143
|
+
* Selected checkbox color
|
|
144
|
+
*/
|
|
106
145
|
selectCheckboxColor = "info",
|
|
146
|
+
/**
|
|
147
|
+
* selected checkbox size
|
|
148
|
+
*/
|
|
107
149
|
selectCheckboxSize = "medium",
|
|
150
|
+
/**
|
|
151
|
+
* Custom cell component for a column
|
|
152
|
+
*/
|
|
108
153
|
cellComponent = () => null;
|
|
109
154
|
|
|
110
155
|
$: resolveComponent = (column, row) => {
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {string} [iteration_key="id"] -
|
|
6
|
-
@param {array} [data=[]] -
|
|
7
|
-
@param {object} [columns={}] -
|
|
8
|
-
@param {boolean} [transition=false] -
|
|
9
|
-
@param {boolean} [is_striped=true] -
|
|
10
|
-
@param {boolean} [clickableRows=false] -
|
|
11
|
-
@param {boolean} [bulk_actions=false] -
|
|
12
|
-
@param {boolean} [selectAll=false] -
|
|
13
|
-
@param {array} [selectedIds=[]] -
|
|
14
|
-
@param {string} [selectAllCheckboxColor="primary"] -
|
|
15
|
-
@param {string} [selectCheckboxColor="info"] -
|
|
16
|
-
@param {string} [selectCheckboxSize="medium"] -
|
|
17
|
-
@param {object} [valueTransformers={}] -
|
|
18
|
-
@param {object} [classTransformers={}] -
|
|
19
|
-
@param {object} [styleTransformers={}] -
|
|
20
|
-
@param {object} [visibilityMap={}] -
|
|
21
|
-
@param {object} [cellComponentMap={}] -
|
|
22
|
-
@param {any} [rowComponent=
|
|
5
|
+
@param {string} [iteration_key="id"] - Iteration key, Default: `"id"`
|
|
6
|
+
@param {array} [data=[]] - Contains all the results that needs to be displayed, Default: `[]`
|
|
7
|
+
@param {object} [columns={}] - Table column names. {db_field_name: column_name}, Default: `{}`
|
|
8
|
+
@param {boolean} [transition=false] - Determines if a transision effect is used, Default: `false`
|
|
9
|
+
@param {boolean} [is_striped=true] - Determines whether to use alternating row shading in the table view, Default: `true`
|
|
10
|
+
@param {boolean} [clickableRows=false] - Determines whether rows are clickable or not, Default: `false`
|
|
11
|
+
@param {boolean} [bulk_actions=false] - Determines if selecting multiple rows and doing multiple actions is allowed, Default: `false`
|
|
12
|
+
@param {boolean} [selectAll=false] - Determines if all rows are selected, Default: `false`
|
|
13
|
+
@param {array} [selectedIds=[]] - List of unique IDs of all the selected rows, Default: `[]`
|
|
14
|
+
@param {string} [selectAllCheckboxColor="primary"] - Colour of the `select all` checkbox, Default: `"primary"`
|
|
15
|
+
@param {string} [selectCheckboxColor="info"] - Color of the checkbox on each row, Default: `"info"`
|
|
16
|
+
@param {string} [selectCheckboxSize="medium"] - Size of the checkbox, Default: `"medium"`
|
|
17
|
+
@param {object} [valueTransformers={}] - Contains all custom values for each column, Default: `{}`
|
|
18
|
+
@param {object} [classTransformers={}] - CSS classes for each column, Default: `{}`
|
|
19
|
+
@param {object} [styleTransformers={}] - CSS styles for each column, Default: `{}`
|
|
20
|
+
@param {object} [visibilityMap={}] - Contains list of columns which can be visible or not, Default: `{}`
|
|
21
|
+
@param {object} [cellComponentMap={}] - Contains list of columns with its custom cell component, Default: `{}`
|
|
22
|
+
@param {any} [rowComponent="GridRow"] - Contains a custom row component, Default: `"GridRow"`
|
|
23
23
|
|
|
24
24
|
### Events
|
|
25
|
-
- `toggleSelectAll`
|
|
25
|
+
- `toggleSelectAll` - Fires an event every time the `select all` checkbox is toggled
|
|
26
26
|
- `rowClick`
|
|
27
27
|
- `rowSelectChecked`
|
|
28
28
|
- `_forwardEvent`
|
|
@@ -87,23 +87,79 @@
|
|
|
87
87
|
|
|
88
88
|
const fire = createEventDispatcher();
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Iteration key
|
|
92
|
+
*/
|
|
90
93
|
export let iteration_key = "id",
|
|
94
|
+
/**
|
|
95
|
+
* Contains all the results that needs to be displayed
|
|
96
|
+
*/
|
|
91
97
|
data = [],
|
|
98
|
+
/**
|
|
99
|
+
* Table column names. {db_field_name: column_name}
|
|
100
|
+
*/
|
|
92
101
|
columns = {},
|
|
102
|
+
/**
|
|
103
|
+
* Determines if a transision effect is used
|
|
104
|
+
*/
|
|
93
105
|
transition = false,
|
|
106
|
+
/**
|
|
107
|
+
* Determines whether to use alternating row shading in the table view
|
|
108
|
+
* @link https://bulma.io/documentation/elements/table/#modifiers
|
|
109
|
+
*/
|
|
94
110
|
is_striped = true,
|
|
111
|
+
/**
|
|
112
|
+
* Determines whether rows are clickable or not
|
|
113
|
+
*/
|
|
95
114
|
clickableRows = false,
|
|
115
|
+
/**
|
|
116
|
+
* Determines if selecting multiple rows and doing multiple actions is allowed
|
|
117
|
+
*/
|
|
96
118
|
bulk_actions = false,
|
|
119
|
+
/**
|
|
120
|
+
*Determines if all rows are selected
|
|
121
|
+
*/
|
|
97
122
|
selectAll = false,
|
|
123
|
+
/**
|
|
124
|
+
* List of unique IDs of all the selected rows
|
|
125
|
+
*/
|
|
98
126
|
selectedIds = [],
|
|
127
|
+
/**
|
|
128
|
+
* Colour of the `select all` checkbox
|
|
129
|
+
*/
|
|
99
130
|
selectAllCheckboxColor = "primary",
|
|
131
|
+
/**
|
|
132
|
+
* Color of the checkbox on each row
|
|
133
|
+
*/
|
|
100
134
|
selectCheckboxColor = "info",
|
|
135
|
+
/**
|
|
136
|
+
* Size of the checkbox
|
|
137
|
+
*/
|
|
101
138
|
selectCheckboxSize = "medium",
|
|
139
|
+
/**
|
|
140
|
+
* Contains all custom values for each column
|
|
141
|
+
*/
|
|
102
142
|
valueTransformers = {},
|
|
143
|
+
/**
|
|
144
|
+
* CSS classes for each column
|
|
145
|
+
*/
|
|
103
146
|
classTransformers = {},
|
|
147
|
+
/**
|
|
148
|
+
* CSS styles for each column
|
|
149
|
+
*/
|
|
104
150
|
styleTransformers = {},
|
|
151
|
+
/**
|
|
152
|
+
* Contains list of columns which can be visible or not
|
|
153
|
+
*/
|
|
105
154
|
visibilityMap = {},
|
|
155
|
+
/**
|
|
156
|
+
* Contains list of columns with its custom cell component
|
|
157
|
+
*/
|
|
106
158
|
cellComponentMap = {},
|
|
159
|
+
/**
|
|
160
|
+
* Contains a custom row component
|
|
161
|
+
* @default "GridRow"
|
|
162
|
+
*/
|
|
107
163
|
rowComponent = GridRow;
|
|
108
164
|
|
|
109
165
|
$: mainRowComponent = rowComponent ? rowComponent : GridRow;
|
|
@@ -143,6 +199,7 @@
|
|
|
143
199
|
|
|
144
200
|
return "";
|
|
145
201
|
};
|
|
202
|
+
|
|
146
203
|
$: cellComponent = (column, row) => {
|
|
147
204
|
if (cellComponentMap && cellComponentMap[column] && row) {
|
|
148
205
|
return cellComponentMap[column](row[column], row);
|
|
@@ -152,6 +209,9 @@
|
|
|
152
209
|
};
|
|
153
210
|
|
|
154
211
|
function changed() {
|
|
212
|
+
/**
|
|
213
|
+
* Fires an event every time the `select all` checkbox is toggled
|
|
214
|
+
*/
|
|
155
215
|
fire("toggleSelectAll", selectAll);
|
|
156
216
|
}
|
|
157
217
|
</script>
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
@component
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
@param {object} [meta={}] -
|
|
6
|
-
@param {boolean} [showTotal=true] -
|
|
5
|
+
@param {object} [meta={}] - Contains the total, count, limit, offset values, Default: `{}`
|
|
6
|
+
@param {boolean} [showTotal=true] - Determines whether to show total or not, Default: `true`
|
|
7
7
|
@param {boolean} [showCurrent=true] - ShowCurrent property, Default: `true`
|
|
8
8
|
@param {boolean} [showPerPage=true] - ShowPerPage property, Default: `true`
|
|
9
9
|
@param {number} [breakThreshold=10] - BreakThreshold property, Default: `10`
|
|
@@ -128,6 +128,9 @@
|
|
|
128
128
|
|
|
129
129
|
const fire = createEventDispatcher();
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Contains the total, count, limit, offset values
|
|
133
|
+
*/
|
|
131
134
|
export let meta = {
|
|
132
135
|
limit: 0,
|
|
133
136
|
total: 0,
|
|
@@ -135,6 +138,9 @@
|
|
|
135
138
|
offset: 0,
|
|
136
139
|
status: "",
|
|
137
140
|
},
|
|
141
|
+
/**
|
|
142
|
+
* Determines whether to show total or not
|
|
143
|
+
*/
|
|
138
144
|
showTotal = true,
|
|
139
145
|
showCurrent = true,
|
|
140
146
|
showPerPage = true,
|