@pequity/squirrel 5.4.5 → 5.4.6
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/dist/cjs/chunks/p-action-bar.js +4 -2181
- package/dist/cjs/chunks/p-dropdown-select.js +30 -8
- package/dist/cjs/chunks/p-icon.js +2180 -0
- package/dist/cjs/index.js +2 -1
- package/dist/es/chunks/p-action-bar.js +3 -2180
- package/dist/es/chunks/p-dropdown-select.js +31 -9
- package/dist/es/chunks/p-icon.js +2181 -0
- package/dist/es/index.js +25 -24
- package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +9 -0
- package/package.json +1 -1
- package/squirrel/components/p-dropdown-select/p-dropdown-select.spec.js +37 -1
- package/squirrel/components/p-dropdown-select/p-dropdown-select.stories.js +23 -0
- package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +21 -0
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { config } from "./config.js";
|
|
2
|
-
import { _
|
|
2
|
+
import { _ } from "./chunks/p-action-bar.js";
|
|
3
3
|
import { default as default2 } from "./p-alert.js";
|
|
4
4
|
import { default as default3 } from "./p-avatar.js";
|
|
5
5
|
import { default as default4 } from "./p-btn.js";
|
|
@@ -11,7 +11,7 @@ import { _ as _3 } from "./chunks/p-date-picker.js";
|
|
|
11
11
|
import { default as default8 } from "./p-drawer.js";
|
|
12
12
|
import { default as default9 } from "./p-dropdown.js";
|
|
13
13
|
import { _ as _imports_0$2 } from "./chunks/p-dropdown-select.js";
|
|
14
|
-
import { a
|
|
14
|
+
import { a } from "./chunks/p-dropdown-select.js";
|
|
15
15
|
import { defineComponent, shallowRef, ref, computed, onMounted, openBlock, createElementBlock, normalizeClass, unref, toDisplayString, createCommentVNode, createElementVNode, withModifiers, createTextVNode, Fragment, renderList, withDirectives, vShow, useAttrs, resolveDirective, normalizeStyle, createVNode, isRef, renderSlot, provide, onBeforeUnmount, watch, mergeProps, toHandlers } from "vue";
|
|
16
16
|
import { formatBytes, getFileExtension } from "./p-file-upload.js";
|
|
17
17
|
import { uniq, kebabCase } from "lodash-es";
|
|
@@ -19,21 +19,22 @@ import { useInputClasses } from "./useInputClasses.js";
|
|
|
19
19
|
import { useToast } from "vue-toastification";
|
|
20
20
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
21
21
|
import { default as default10 } from "./p-table-filter-icon.js";
|
|
22
|
+
import { _ as _4 } from "./chunks/p-icon.js";
|
|
22
23
|
import { default as default11 } from "./p-info-icon.js";
|
|
23
|
-
import { _ as
|
|
24
|
+
import { _ as _5 } from "./chunks/p-inline-date-picker.js";
|
|
24
25
|
import { default as default12 } from "./p-input.js";
|
|
25
26
|
import { default as default13 } from "./p-input-number.js";
|
|
26
|
-
import { _ as
|
|
27
|
+
import { _ as _6 } from "./chunks/p-input-percent.js";
|
|
27
28
|
import PInputSearch from "./p-input-search.js";
|
|
28
|
-
import { _ as
|
|
29
|
+
import { _ as _7 } from "./chunks/p-link.js";
|
|
29
30
|
import { default as default14 } from "./p-loading.js";
|
|
30
31
|
import { default as default15 } from "./p-modal.js";
|
|
31
|
-
import { _ as
|
|
32
|
-
import { _ as
|
|
32
|
+
import { _ as _8 } from "./chunks/p-pagination.js";
|
|
33
|
+
import { _ as _9 } from "./chunks/p-pagination-info.js";
|
|
33
34
|
import { default as default16 } from "./p-progress-bar.js";
|
|
34
|
-
import { _ as
|
|
35
|
-
import { _ as
|
|
36
|
-
import { _ as
|
|
35
|
+
import { _ as _10 } from "./chunks/p-ring-loader.js";
|
|
36
|
+
import { _ as _11 } from "./chunks/p-select.js";
|
|
37
|
+
import { _ as _12 } from "./chunks/p-select-btn.js";
|
|
37
38
|
import { SIZES } from "./p-select-list.js";
|
|
38
39
|
import { splitStringForHighlight } from "./text.js";
|
|
39
40
|
import { toString } from "./string.js";
|
|
@@ -44,10 +45,10 @@ import PTableHeaderCell from "./p-table-header-cell.js";
|
|
|
44
45
|
import { colsInjectionKey, isFirstColFixedInjectionKey, isLastColFixedInjectionKey, isColsResizableInjectionKey } from "./p-table.js";
|
|
45
46
|
import { MIN_WIDTH_COL_RESIZE } from "./p-table.js";
|
|
46
47
|
import { usePTableColResize } from "./usePTableColResize.js";
|
|
47
|
-
import { _ as
|
|
48
|
+
import { _ as _13 } from "./chunks/p-table-loader.js";
|
|
48
49
|
import { SORTING_TYPES } from "./p-table-sort.js";
|
|
49
50
|
import { default as default19 } from "./p-table-td.js";
|
|
50
|
-
import { _ as
|
|
51
|
+
import { _ as _14 } from "./chunks/p-tabs.js";
|
|
51
52
|
import { default as default20 } from "./p-textarea.js";
|
|
52
53
|
import { default as default21 } from "./p-toggle.js";
|
|
53
54
|
import { P_ICON_ALIASES } from "./p-icon.js";
|
|
@@ -974,34 +975,34 @@ export {
|
|
|
974
975
|
_3 as PDatePicker,
|
|
975
976
|
default8 as PDrawer,
|
|
976
977
|
default9 as PDropdown,
|
|
977
|
-
|
|
978
|
+
a as PDropdownSelect,
|
|
978
979
|
pFileUpload as PFileUpload,
|
|
979
980
|
default10 as PFilterIcon,
|
|
980
|
-
|
|
981
|
+
_4 as PIcon,
|
|
981
982
|
default11 as PInfoIcon,
|
|
982
|
-
|
|
983
|
+
_5 as PInlineDatePicker,
|
|
983
984
|
default12 as PInput,
|
|
984
985
|
default13 as PInputNumber,
|
|
985
|
-
|
|
986
|
+
_6 as PInputPercent,
|
|
986
987
|
PInputSearch,
|
|
987
|
-
|
|
988
|
+
_7 as PLink,
|
|
988
989
|
default14 as PLoading,
|
|
989
990
|
default15 as PModal,
|
|
990
|
-
|
|
991
|
-
|
|
991
|
+
_8 as PPagination,
|
|
992
|
+
_9 as PPaginationInfo,
|
|
992
993
|
default16 as PProgressBar,
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
994
|
+
_10 as PRingLoader,
|
|
995
|
+
_11 as PSelect,
|
|
996
|
+
_12 as PSelectBtn,
|
|
996
997
|
_sfc_main$2 as PSelectList,
|
|
997
998
|
default17 as PSelectPill,
|
|
998
999
|
default18 as PSkeletonLoader,
|
|
999
1000
|
pTable as PTable,
|
|
1000
1001
|
PTableHeaderCell,
|
|
1001
|
-
|
|
1002
|
+
_13 as PTableLoader,
|
|
1002
1003
|
pTableSort as PTableSort,
|
|
1003
1004
|
default19 as PTableTd,
|
|
1004
|
-
|
|
1005
|
+
_14 as PTabs,
|
|
1005
1006
|
default20 as PTextarea,
|
|
1006
1007
|
default21 as PToggle,
|
|
1007
1008
|
P_ICON_ALIASES,
|
|
@@ -307,6 +307,10 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
307
307
|
type: BooleanConstructor;
|
|
308
308
|
default: boolean;
|
|
309
309
|
};
|
|
310
|
+
clearable: {
|
|
311
|
+
type: BooleanConstructor;
|
|
312
|
+
default: boolean;
|
|
313
|
+
};
|
|
310
314
|
/**
|
|
311
315
|
* Enables multiple selection
|
|
312
316
|
*/
|
|
@@ -433,6 +437,10 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
433
437
|
type: BooleanConstructor;
|
|
434
438
|
default: boolean;
|
|
435
439
|
};
|
|
440
|
+
clearable: {
|
|
441
|
+
type: BooleanConstructor;
|
|
442
|
+
default: boolean;
|
|
443
|
+
};
|
|
436
444
|
/**
|
|
437
445
|
* Enables multiple selection
|
|
438
446
|
*/
|
|
@@ -489,6 +497,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
489
497
|
dropdownMenuStyle: Record<string, any>;
|
|
490
498
|
pDropdownProps: Record<string, any>;
|
|
491
499
|
searchable: boolean;
|
|
500
|
+
clearable: boolean;
|
|
492
501
|
multiple: boolean;
|
|
493
502
|
placeholderSearch: string;
|
|
494
503
|
selectedTopShown: boolean;
|
package/package.json
CHANGED
|
@@ -555,7 +555,6 @@ describe('PDropdownSelect.vue', () => {
|
|
|
555
555
|
expect(item.classes()).not.toContain('pointer-events-none');
|
|
556
556
|
}
|
|
557
557
|
});
|
|
558
|
-
|
|
559
558
|
cleanup(wrapper);
|
|
560
559
|
});
|
|
561
560
|
|
|
@@ -581,7 +580,44 @@ describe('PDropdownSelect.vue', () => {
|
|
|
581
580
|
expect(item.classes()).not.toContain('pointer-events-none');
|
|
582
581
|
}
|
|
583
582
|
});
|
|
583
|
+
cleanup(wrapper);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
it('renders clear button when clearable is true and a value is selected', async () => {
|
|
587
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
588
|
+
|
|
589
|
+
const wrapper = createWrapper({ selected: 17 }, { clearable: true });
|
|
590
|
+
|
|
591
|
+
const clearButton = wrapper.find('button[aria-label="Clear selection"]');
|
|
592
|
+
expect(clearButton.exists()).toBe(true);
|
|
593
|
+
|
|
594
|
+
await clearButton.trigger('click');
|
|
595
|
+
expect(wrapper.vm.$data.selected).toEqual([]);
|
|
596
|
+
|
|
597
|
+
cleanup(wrapper);
|
|
598
|
+
});
|
|
584
599
|
|
|
600
|
+
it('does not render clear button when clearable is false', async () => {
|
|
601
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
602
|
+
|
|
603
|
+
const wrapper = createWrapper({ selected: 17 }, { clearable: false });
|
|
604
|
+
|
|
605
|
+
const clearButton = wrapper.find('button[aria-label="Clear selection"]');
|
|
606
|
+
expect(clearButton.exists()).toBe(false);
|
|
607
|
+
|
|
608
|
+
cleanup(wrapper);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it('clears multiple selections when clearable is true', async () => {
|
|
612
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
613
|
+
|
|
614
|
+
const wrapper = createWrapper({ selected: [4, 5] }, { multiple: true, clearable: true });
|
|
615
|
+
|
|
616
|
+
const clearButton = wrapper.find('button[aria-label="Clear selection"]');
|
|
617
|
+
expect(clearButton.exists()).toBe(true);
|
|
618
|
+
|
|
619
|
+
await clearButton.trigger('click');
|
|
620
|
+
expect(wrapper.vm.$data.selected).toEqual([]);
|
|
585
621
|
cleanup(wrapper);
|
|
586
622
|
});
|
|
587
623
|
});
|
|
@@ -69,6 +69,10 @@ export default {
|
|
|
69
69
|
}),
|
|
70
70
|
argTypes: {
|
|
71
71
|
...fieldArgTypes,
|
|
72
|
+
clearable: {
|
|
73
|
+
control: 'boolean',
|
|
74
|
+
description: 'Whether the dropdown should be clearable',
|
|
75
|
+
},
|
|
72
76
|
},
|
|
73
77
|
parameters: {
|
|
74
78
|
docs: {
|
|
@@ -289,3 +293,22 @@ export const SelectedOnTop = {
|
|
|
289
293
|
selectedTopShown: true,
|
|
290
294
|
},
|
|
291
295
|
};
|
|
296
|
+
|
|
297
|
+
export const Clearable = {
|
|
298
|
+
render: createRenderFunction({ selectedVal: 17 }),
|
|
299
|
+
args: {
|
|
300
|
+
...Default.args,
|
|
301
|
+
label: 'Clearable dropdown',
|
|
302
|
+
clearable: true,
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export const ClearableMultiple = {
|
|
307
|
+
render: createRenderFunction({ selectedVal: [33, 34, 36] }),
|
|
308
|
+
args: {
|
|
309
|
+
...Default.args,
|
|
310
|
+
label: 'Clearable multiple dropdown',
|
|
311
|
+
multiple: true,
|
|
312
|
+
clearable: true,
|
|
313
|
+
},
|
|
314
|
+
};
|
|
@@ -36,6 +36,16 @@
|
|
|
36
36
|
}}
|
|
37
37
|
</div>
|
|
38
38
|
</slot>
|
|
39
|
+
<!-- Add clear button -->
|
|
40
|
+
<button
|
|
41
|
+
v-if="clearable && internalValue.length"
|
|
42
|
+
class="absolute top-1/2 flex -translate-y-1/2 items-center justify-center text-p-gray-40 hover:text-p-gray-60"
|
|
43
|
+
:class="[SIZES[size], CLEAR_BUTTON_SPACING[size]]"
|
|
44
|
+
aria-label="Clear selection"
|
|
45
|
+
@click.stop="clearAll"
|
|
46
|
+
>
|
|
47
|
+
<PIcon icon="fe:close" />
|
|
48
|
+
</button>
|
|
39
49
|
</button>
|
|
40
50
|
<!-- Dropdown -->
|
|
41
51
|
<template #popper>
|
|
@@ -148,6 +158,7 @@
|
|
|
148
158
|
|
|
149
159
|
<script setup lang="ts">
|
|
150
160
|
import PDropdown from '@squirrel/components/p-dropdown/p-dropdown.vue';
|
|
161
|
+
import PIcon from '@squirrel/components/p-icon/p-icon.vue';
|
|
151
162
|
import PInputSearch from '@squirrel/components/p-input-search/p-input-search.vue';
|
|
152
163
|
import {
|
|
153
164
|
type ComponentPublicInstance,
|
|
@@ -275,6 +286,10 @@ const props = defineProps({
|
|
|
275
286
|
type: Boolean,
|
|
276
287
|
default: false,
|
|
277
288
|
},
|
|
289
|
+
clearable: {
|
|
290
|
+
type: Boolean,
|
|
291
|
+
default: false,
|
|
292
|
+
},
|
|
278
293
|
/**
|
|
279
294
|
* Enables multiple selection
|
|
280
295
|
*/
|
|
@@ -326,6 +341,12 @@ const P_DROPDOWN_DEFAULTS = {
|
|
|
326
341
|
enableArrowNavigation: false,
|
|
327
342
|
};
|
|
328
343
|
|
|
344
|
+
const CLEAR_BUTTON_SPACING = {
|
|
345
|
+
sm: 'right-8',
|
|
346
|
+
md: 'right-9',
|
|
347
|
+
lg: 'right-10',
|
|
348
|
+
};
|
|
349
|
+
|
|
329
350
|
const width = ref('auto');
|
|
330
351
|
const listItemStyle = ref({ paddingTop: 0, paddingBottom: 0 });
|
|
331
352
|
const dropdownShow = ref(false);
|