@pequity/squirrel 6.0.8 → 6.0.9
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.
|
@@ -231,6 +231,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
231
231
|
return rest;
|
|
232
232
|
});
|
|
233
233
|
const style = vue.computed(() => $attrs.style);
|
|
234
|
+
const selectableItemsCount = vue.computed(
|
|
235
|
+
() => internalItems.value.filter((item) => !isDisabled(item) || isSelected(item[props.itemValue])).length
|
|
236
|
+
);
|
|
234
237
|
vue.watch(
|
|
235
238
|
dropdownShow,
|
|
236
239
|
(nV) => {
|
|
@@ -440,7 +443,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
440
443
|
key: 1,
|
|
441
444
|
item: __props.multiple ? vue.unref(selectedItems) : vue.unref(selectedItems)[0]
|
|
442
445
|
}, () => [
|
|
443
|
-
vue.createElementVNode("div", _hoisted_3, vue.toDisplayString(__props.multiple
|
|
446
|
+
vue.createElementVNode("div", _hoisted_3, vue.toDisplayString(__props.multiple ? vue.unref(selectedItems).length === selectableItemsCount.value ? "All options selected" : `${vue.unref(selectedItems).length} option${vue.unref(selectedItems).length > 1 ? "s" : ""} selected` : vue.unref(selectedItems)[0][__props.itemText]), 1)
|
|
444
447
|
]),
|
|
445
448
|
__props.clearable && vue.unref(selectedItems).length ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
446
449
|
key: 2,
|
|
@@ -230,6 +230,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
230
230
|
return rest;
|
|
231
231
|
});
|
|
232
232
|
const style = computed(() => $attrs.style);
|
|
233
|
+
const selectableItemsCount = computed(
|
|
234
|
+
() => internalItems.value.filter((item) => !isDisabled(item) || isSelected(item[props.itemValue])).length
|
|
235
|
+
);
|
|
233
236
|
watch(
|
|
234
237
|
dropdownShow,
|
|
235
238
|
(nV) => {
|
|
@@ -439,7 +442,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
439
442
|
key: 1,
|
|
440
443
|
item: __props.multiple ? unref(selectedItems) : unref(selectedItems)[0]
|
|
441
444
|
}, () => [
|
|
442
|
-
createElementVNode("div", _hoisted_3, toDisplayString(__props.multiple
|
|
445
|
+
createElementVNode("div", _hoisted_3, toDisplayString(__props.multiple ? unref(selectedItems).length === selectableItemsCount.value ? "All options selected" : `${unref(selectedItems).length} option${unref(selectedItems).length > 1 ? "s" : ""} selected` : unref(selectedItems)[0][__props.itemText]), 1)
|
|
443
446
|
]),
|
|
444
447
|
__props.clearable && unref(selectedItems).length ? (openBlock(), createElementBlock("button", {
|
|
445
448
|
key: 2,
|
package/package.json
CHANGED
|
@@ -193,6 +193,42 @@ describe('PDropdownSelect.vue', () => {
|
|
|
193
193
|
|
|
194
194
|
expect(selectedItems.length).toBe(selectedItemsOptions.length);
|
|
195
195
|
expect(wrapper.vm.$data.selected.length).toBe(items.length);
|
|
196
|
+
expect(wrapper.find('button').text()).toBe('All options selected');
|
|
197
|
+
|
|
198
|
+
cleanup(wrapper);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('shows "All options selected" when all selectable options and disabled-selected options are selected', async () => {
|
|
202
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
203
|
+
|
|
204
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
205
|
+
items[0].disabled = true;
|
|
206
|
+
items[1].disabled = true;
|
|
207
|
+
// Pre-select one disabled item
|
|
208
|
+
const wrapper = createWrapper({ selected: [1], items }, { multiple: true });
|
|
209
|
+
|
|
210
|
+
await wrapper.find('button').trigger('click');
|
|
211
|
+
await wrapper.findByText('Select all').trigger('click');
|
|
212
|
+
|
|
213
|
+
const selectedItemsOptions = wrapper.findAll('[p-select-list-option-item]');
|
|
214
|
+
const selectedItems = wrapper.findAll('[p-select-list-option-item].selected');
|
|
215
|
+
|
|
216
|
+
// Should have all non-disabled items (8) plus the pre-selected disabled item (1)
|
|
217
|
+
expect(selectedItems.length).toBe(selectedItemsOptions.length - 1);
|
|
218
|
+
expect(wrapper.vm.$data.selected.length).toBe(items.length - 1);
|
|
219
|
+
expect(wrapper.find('button').text()).toBe('All options selected');
|
|
220
|
+
|
|
221
|
+
cleanup(wrapper);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('shows number of selected options when not all non-disabled options are selected', async () => {
|
|
225
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
226
|
+
|
|
227
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
228
|
+
items[0].disabled = true;
|
|
229
|
+
const wrapper = createWrapper({ selected: [2, 3], items }, { multiple: true });
|
|
230
|
+
|
|
231
|
+
expect(wrapper.find('button').text()).toBe('2 options selected');
|
|
196
232
|
|
|
197
233
|
cleanup(wrapper);
|
|
198
234
|
});
|
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
<slot v-else name="selected-item" :item="multiple ? selectedItems : selectedItems[0]">
|
|
33
33
|
<div class="truncate text-left">
|
|
34
34
|
{{
|
|
35
|
-
multiple
|
|
36
|
-
?
|
|
35
|
+
multiple
|
|
36
|
+
? selectedItems.length === selectableItemsCount
|
|
37
|
+
? 'All options selected'
|
|
38
|
+
: `${selectedItems.length} option${selectedItems.length > 1 ? 's' : ''} selected`
|
|
37
39
|
: selectedItems[0][itemText]
|
|
38
40
|
}}
|
|
39
41
|
</div>
|
|
@@ -419,6 +421,10 @@ const attrs = computed(() => {
|
|
|
419
421
|
|
|
420
422
|
const style = computed(() => $attrs.style as StyleValue);
|
|
421
423
|
|
|
424
|
+
const selectableItemsCount = computed(
|
|
425
|
+
() => internalItems.value.filter((item) => !isDisabled(item) || isSelected(item[props.itemValue])).length
|
|
426
|
+
);
|
|
427
|
+
|
|
422
428
|
// Watch
|
|
423
429
|
// Sorts internalItems putting the selected ones first
|
|
424
430
|
watch(
|