@dile/crud 2.15.6 → 2.16.1
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.
|
@@ -205,6 +205,7 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
|
|
|
205
205
|
?disablePagination=${this.config.customization?.disablePagination}
|
|
206
206
|
language="${this.language}"
|
|
207
207
|
.maxBatchActionItems=${this.batchLimit}
|
|
208
|
+
.selectedCount=${this.actionIds.length}
|
|
208
209
|
></dile-crud-select-all>
|
|
209
210
|
`
|
|
210
211
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import '@dile/ui/components/button/button-icon.js';
|
|
3
|
-
import { checkboxBlankIcon, arrowDropDownIcon, checkboxCheckedIcon } from '@dile/icons';
|
|
3
|
+
import { checkboxBlankIcon, arrowDropDownIcon, checkboxCheckedIcon, closeIcon } from '@dile/icons';
|
|
4
4
|
import '@dile/ui/components/icon/icon.js';
|
|
5
5
|
import '@dile/ui/components/menu-overlay/menu-overlay.js';
|
|
6
6
|
import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
|
|
@@ -44,20 +44,62 @@ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
|
|
|
44
44
|
padding: 0.5rem;
|
|
45
45
|
font-size: 1rem;
|
|
46
46
|
}
|
|
47
|
+
/* Native buttons, so they get the focus with Tab and activate with Enter and Space.
|
|
48
|
+
Same space between options as between the separator line and the text of .clear */
|
|
47
49
|
.option {
|
|
48
50
|
display: flex;
|
|
49
51
|
align-items: center;
|
|
52
|
+
width: 100%;
|
|
53
|
+
box-sizing: border-box;
|
|
50
54
|
cursor: pointer;
|
|
55
|
+
margin: 0.75rem 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
border: none;
|
|
58
|
+
border-radius: 3px;
|
|
59
|
+
background: none;
|
|
60
|
+
color: inherit;
|
|
61
|
+
font: inherit;
|
|
62
|
+
text-align: left;
|
|
63
|
+
}
|
|
64
|
+
.option:focus-visible {
|
|
65
|
+
outline: 2px solid var(--dile-crud-select-all-focus-outline-color, #2563eb);
|
|
66
|
+
outline-offset: 2px;
|
|
51
67
|
}
|
|
52
68
|
.option.disabled {
|
|
53
69
|
cursor: default;
|
|
70
|
+
}
|
|
71
|
+
/* With the limit message below the label, the icon stays next to the first line */
|
|
72
|
+
.option.has-limit {
|
|
73
|
+
align-items: flex-start;
|
|
74
|
+
}
|
|
75
|
+
.option.disabled .label {
|
|
54
76
|
opacity: 0.6;
|
|
55
77
|
}
|
|
78
|
+
.option.disabled dile-icon {
|
|
79
|
+
--dile-icon-color: var(--dile-crud-select-all-overlay-checkbox-disabled-color, #c0c0c0);
|
|
80
|
+
}
|
|
81
|
+
.text {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
}
|
|
56
85
|
.limit {
|
|
57
|
-
margin: 0
|
|
58
|
-
font-size: var(--dile-crud-select-all-limit-font-size, 0.
|
|
86
|
+
margin-top: 0.125rem;
|
|
87
|
+
font-size: var(--dile-crud-select-all-limit-font-size, 0.8rem);
|
|
88
|
+
line-height: 1.25;
|
|
59
89
|
color: var(--dile-crud-select-all-limit-color, inherit);
|
|
60
90
|
}
|
|
91
|
+
/* The same space above the first option as below the last one (.clear) */
|
|
92
|
+
.option:first-child {
|
|
93
|
+
margin-top: 0.25rem;
|
|
94
|
+
}
|
|
95
|
+
/* A separate element, so the focus outline of .clear doesn't wrap the line */
|
|
96
|
+
.separator {
|
|
97
|
+
border-top: 1px solid var(--dile-crud-select-all-separator-color, #ddd);
|
|
98
|
+
}
|
|
99
|
+
/* The bottom margin plus the padding of .content matches the space above the text */
|
|
100
|
+
.clear {
|
|
101
|
+
margin-bottom: 0.25rem;
|
|
102
|
+
}
|
|
61
103
|
.option dile-icon {
|
|
62
104
|
--dile-icon-size: var(--dile-crud-select-all-checkbox-size, 1.5rem);
|
|
63
105
|
--dile-icon-color: var(--dile-crud-select-all-overlay-checkbox-color, #303030);
|
|
@@ -87,6 +129,7 @@ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
|
|
|
87
129
|
numItems: { type: Number },
|
|
88
130
|
disablePagination: { type: Boolean },
|
|
89
131
|
maxBatchActionItems: { type: Number },
|
|
132
|
+
selectedCount: { type: Number },
|
|
90
133
|
};
|
|
91
134
|
}
|
|
92
135
|
|
|
@@ -94,6 +137,7 @@ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
|
|
|
94
137
|
super();
|
|
95
138
|
this.checked = false;
|
|
96
139
|
this.disablePagination = false;
|
|
140
|
+
this.selectedCount = 0;
|
|
97
141
|
}
|
|
98
142
|
|
|
99
143
|
render() {
|
|
@@ -114,33 +158,62 @@ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
|
|
|
114
158
|
this.translations.all_in_page,
|
|
115
159
|
this.pageItemsCount,
|
|
116
160
|
this.pageChecked,
|
|
117
|
-
this.checkPageItems
|
|
161
|
+
this.checkPageItems,
|
|
162
|
+
this.translations.select_page_limit_exceeded
|
|
118
163
|
)
|
|
119
164
|
}
|
|
120
165
|
${this.optionTemplate(
|
|
121
166
|
this.translations.select_matching,
|
|
122
167
|
this.numItems,
|
|
123
168
|
this.allChecked,
|
|
124
|
-
this.checkAllItems
|
|
169
|
+
this.checkAllItems,
|
|
170
|
+
this.translations.select_matching_limit_exceeded
|
|
125
171
|
)}
|
|
126
|
-
${this.
|
|
127
|
-
? html`<p class="limit">${this.translations.select_limit_exceeded(this.numItems, this.maxBatchActionItems)}</p>`
|
|
128
|
-
: ''
|
|
129
|
-
}
|
|
172
|
+
${this.clearSelectionTemplate}
|
|
130
173
|
</div>
|
|
131
174
|
</dile-menu-overlay>
|
|
132
175
|
`;
|
|
133
176
|
}
|
|
134
177
|
|
|
135
|
-
// Options over the limit are shown disabled instead of hidden,
|
|
136
|
-
// they can't select
|
|
137
|
-
|
|
178
|
+
// Options over the limit are shown disabled instead of hidden, with the reason just below
|
|
179
|
+
// their label, so the user knows why they can't select those items. They use aria-disabled
|
|
180
|
+
// instead of disabled so they stay in the tab order and keyboard users can reach that reason.
|
|
181
|
+
optionTemplate(label, count, checked, handler, limitMessage) {
|
|
138
182
|
const disabled = this.exceedsLimit(count);
|
|
139
183
|
return html`
|
|
140
|
-
<
|
|
184
|
+
<button
|
|
185
|
+
type="button"
|
|
186
|
+
class="option ${disabled ? 'disabled has-limit' : ''}"
|
|
187
|
+
aria-pressed=${checked ? 'true' : 'false'}
|
|
188
|
+
aria-disabled=${disabled ? 'true' : 'false'}
|
|
189
|
+
@click=${disabled ? null : handler}
|
|
190
|
+
>
|
|
141
191
|
<dile-icon .icon=${this.selectIcon(checked)} class="drop"></dile-icon>
|
|
142
|
-
<span
|
|
143
|
-
|
|
192
|
+
<span class="text">
|
|
193
|
+
<span class="label">${label} (${count})</span>
|
|
194
|
+
${disabled
|
|
195
|
+
? html`<span class="limit">${limitMessage(this.maxBatchActionItems)}</span>`
|
|
196
|
+
: ''
|
|
197
|
+
}
|
|
198
|
+
</span>
|
|
199
|
+
</button>
|
|
200
|
+
`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Always visible so the user knows it exists, disabled while nothing is selected.
|
|
204
|
+
get clearSelectionTemplate() {
|
|
205
|
+
const disabled = !(this.selectedCount > 0);
|
|
206
|
+
return html`
|
|
207
|
+
<div class="separator" aria-hidden="true"></div>
|
|
208
|
+
<button
|
|
209
|
+
type="button"
|
|
210
|
+
class="option clear ${disabled ? 'disabled' : ''}"
|
|
211
|
+
aria-disabled=${disabled ? 'true' : 'false'}
|
|
212
|
+
@click=${disabled ? null : this.clearSelection}
|
|
213
|
+
>
|
|
214
|
+
<dile-icon .icon=${closeIcon} class="drop"></dile-icon>
|
|
215
|
+
<span class="label">${this.translations.clear_selection}${disabled ? '' : ` (${this.selectedCount})`}</span>
|
|
216
|
+
</button>
|
|
144
217
|
`;
|
|
145
218
|
}
|
|
146
219
|
|
|
@@ -193,6 +266,12 @@ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
|
|
|
193
266
|
}));
|
|
194
267
|
}
|
|
195
268
|
|
|
269
|
+
// Unchecking both options makes dile-crud-list empty the selection, including the items
|
|
270
|
+
// checked one by one.
|
|
271
|
+
clearSelection() {
|
|
272
|
+
this.reset();
|
|
273
|
+
}
|
|
274
|
+
|
|
196
275
|
reset() {
|
|
197
276
|
this.resetWithoutDispatch();
|
|
198
277
|
this.dispatchCheked();
|
package/lib/DileI18nMixin.js
CHANGED
|
@@ -9,7 +9,8 @@ export const DileI18nMixin = (superclass) =>
|
|
|
9
9
|
error_operation: () => '',
|
|
10
10
|
showing_page_size: () => '',
|
|
11
11
|
current_page: () => '',
|
|
12
|
-
|
|
12
|
+
select_page_limit_exceeded: () => '',
|
|
13
|
+
select_matching_limit_exceeded: () => '',
|
|
13
14
|
action_limit_exceeded: () => '',
|
|
14
15
|
};
|
|
15
16
|
}
|
package/lib/i18n/en.js
CHANGED
|
@@ -43,7 +43,9 @@ export const translations = {
|
|
|
43
43
|
all: "all",
|
|
44
44
|
all_in_page: "All in this page",
|
|
45
45
|
select_matching: "Select all matching",
|
|
46
|
-
|
|
46
|
+
clear_selection: "Clear selection",
|
|
47
|
+
select_page_limit_exceeded: (max) => `Reduce the page size: up to ${max} items per action.`,
|
|
48
|
+
select_matching_limit_exceeded: (max) => `Filter the list: up to ${max} items per action.`,
|
|
47
49
|
select_all_count_changed: "The list changed while you were selecting. Check the items and select them again.",
|
|
48
50
|
select_all_error: "All items could not be selected.",
|
|
49
51
|
action_limit_exceeded: (count, max) => `You selected ${count} items and an action accepts up to ${max}. Remove some items from the selection.`,
|
package/lib/i18n/es.js
CHANGED
|
@@ -43,7 +43,9 @@ export const translations = {
|
|
|
43
43
|
all: "todos",
|
|
44
44
|
all_in_page: "Todos de esta página",
|
|
45
45
|
select_matching: "Seleccionar coincidentes",
|
|
46
|
-
|
|
46
|
+
clear_selection: "Quitar selección",
|
|
47
|
+
select_page_limit_exceeded: (max) => `Reduce el tamaño de página: máximo ${max} ítems por acción.`,
|
|
48
|
+
select_matching_limit_exceeded: (max) => `Filtra la lista: máximo ${max} ítems por acción.`,
|
|
47
49
|
select_all_count_changed: "La lista ha cambiado mientras seleccionabas. Revisa los elementos y vuelve a seleccionarlos.",
|
|
48
50
|
select_all_error: "No se han podido seleccionar todos los elementos.",
|
|
49
51
|
action_limit_exceeded: (count, max) => `Has seleccionado ${count} elementos y una acción admite un máximo de ${max}. Quita elementos de la selección.`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"homepage": "https://dile-components.com/",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@dile/image-cropper": "^0.1.1",
|
|
29
|
-
"@dile/ui": "^3.22.
|
|
29
|
+
"@dile/ui": "^3.22.1",
|
|
30
30
|
"axios": "^1.19.0",
|
|
31
31
|
"lit": "^2.7.0 || ^3.0.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "cef9349e18ff89a24a206a541f8129fd30ccb553"
|
|
37
37
|
}
|