selectic 3.0.21 → 3.1.0
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/selectic.common.js +545 -67
- package/dist/selectic.esm.js +546 -69
- package/doc/changeIcons.md +118 -0
- package/doc/changeText.md +1 -1
- package/doc/domProperties.md +57 -19
- package/doc/extendedProperties.md +83 -72
- package/doc/main.md +2 -0
- package/doc/params.md +177 -112
- package/doc/properties.md +42 -0
- package/package.json +4 -4
- package/src/ExtendedList.tsx +53 -6
- package/src/Filter.tsx +11 -9
- package/src/Icon.tsx +199 -0
- package/src/List.tsx +12 -6
- package/src/MainInput.tsx +15 -11
- package/src/Store.tsx +290 -123
- package/src/css/selectic.css +24 -0
- package/src/icons/caret-down.tsx +21 -0
- package/src/icons/caret-up.tsx +21 -0
- package/src/icons/check.tsx +23 -0
- package/src/icons/question.tsx +21 -0
- package/src/icons/search.tsx +21 -0
- package/src/icons/spinner.tsx +21 -0
- package/src/icons/strikeThrough.tsx +21 -0
- package/src/icons/times.tsx +21 -0
- package/src/index.tsx +78 -37
- package/test/Store/Store_computed.spec.js +84 -0
- package/test/Store/changeIcons.spec.js +154 -0
- package/test/Store/selectGroup.spec.js +389 -0
- package/test/Store/selectItem.spec.js +100 -46
- package/test/helper.js +38 -34
- package/types/ExtendedList.d.ts +7 -2
- package/types/Icon.d.ts +25 -0
- package/types/Store.d.ts +142 -5
- package/types/icons/caret-down.d.ts +6 -0
- package/types/icons/caret-up.d.ts +6 -0
- package/types/icons/check.d.ts +6 -0
- package/types/icons/question.d.ts +6 -0
- package/types/icons/search.d.ts +6 -0
- package/types/icons/spinner.d.ts +6 -0
- package/types/icons/strikeThrough.d.ts +6 -0
- package/types/icons/times.d.ts +6 -0
- package/types/index.d.ts +74 -1
package/src/css/selectic.css
CHANGED
|
@@ -259,6 +259,10 @@
|
|
|
259
259
|
cursor: default;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
.selectic-item__is-group.selectable {
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
}
|
|
265
|
+
|
|
262
266
|
.selectic-item.selected {
|
|
263
267
|
color: var(--selectic-selected-item-color);
|
|
264
268
|
}
|
|
@@ -414,4 +418,24 @@
|
|
|
414
418
|
flex-wrap: wrap;
|
|
415
419
|
}
|
|
416
420
|
|
|
421
|
+
/* {{{ icons */
|
|
422
|
+
|
|
423
|
+
@keyframes selectic-animation-spin {
|
|
424
|
+
0% {
|
|
425
|
+
transform: rotate(0deg);
|
|
426
|
+
}
|
|
427
|
+
100% {
|
|
428
|
+
transform: rotate(359deg);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.selectic__icon {
|
|
433
|
+
height: 1em;
|
|
434
|
+
fill: currentColor;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.selectic-spin {
|
|
438
|
+
animation: selectic-animation-spin 2s infinite linear;
|
|
439
|
+
}
|
|
440
|
+
|
|
417
441
|
/* }}} */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconCaretDown extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M7,10L12,15L17,10H7Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconCaretUp extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M7,15L12,10L17,15H7Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconCheck extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path
|
|
18
|
+
d="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z"
|
|
19
|
+
/>
|
|
20
|
+
</svg>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconQuestion extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M10,19H13V22H10V19M12,2C17.35,2.22 19.68,7.62 16.5,11.67C15.67,12.67 14.33,13.33 13.67,14.17C13,15 13,16 13,17H10C10,15.33 10,13.92 10.67,12.92C11.33,11.92 12.67,11.33 13.5,10.67C15.92,8.43 15.32,5.26 12,5A3,3 0 0,0 9,8H6A6,6 0 0,1 12,2Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconSearch extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconSpinner extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconStrikeThrough extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M7.2 9.8C6 7.5 7.7 4.8 10.1 4.3C13.2 3.3 17.7 4.7 17.6 8.5H14.6C14.6 8.2 14.5 7.9 14.5 7.7C14.3 7.1 13.9 6.8 13.3 6.6C12.5 6.3 11.2 6.4 10.5 6.9C9 8.2 10.4 9.5 12 10H7.4C7.3 9.9 7.3 9.8 7.2 9.8M21 13V11H3V13H12.6C12.8 13.1 13 13.1 13.2 13.2C13.8 13.5 14.3 13.7 14.5 14.3C14.6 14.7 14.7 15.2 14.5 15.6C14.3 16.1 13.9 16.3 13.4 16.5C11.6 17 9.4 16.3 9.5 14.1H6.5C6.4 16.7 8.6 18.5 11 18.8C14.8 19.6 19.3 17.2 17.3 12.9L21 13Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* This icon is from <https://github.com/Templarian/MaterialDesign>,
|
|
2
|
+
* distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {Vue, Component, h} from 'vtyx';
|
|
6
|
+
|
|
7
|
+
export interface Props {}
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default class IconTimes extends Vue<Props> {
|
|
11
|
+
public render() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 24 24"
|
|
16
|
+
>
|
|
17
|
+
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import { deepClone } from './tools';
|
|
|
26
26
|
|
|
27
27
|
import Store, {
|
|
28
28
|
changeTexts as storeChangeTexts,
|
|
29
|
+
changeIcons as storeChangeIcons,
|
|
29
30
|
OptionProp,
|
|
30
31
|
OptionId,
|
|
31
32
|
StrictOptionId,
|
|
@@ -41,6 +42,8 @@ import Store, {
|
|
|
41
42
|
ListPosition,
|
|
42
43
|
HideFilter,
|
|
43
44
|
SelectAllOption,
|
|
45
|
+
PartialIcons,
|
|
46
|
+
IconFamily,
|
|
44
47
|
} from './Store';
|
|
45
48
|
import MainInput from './MainInput';
|
|
46
49
|
import ExtendedList from './ExtendedList';
|
|
@@ -76,22 +79,22 @@ export interface EventChangeOptions extends EventOptions {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
export interface ParamProps {
|
|
79
|
-
|
|
82
|
+
/** Method to call to fetch extra data */
|
|
80
83
|
fetchCallback?: FetchCallback;
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
/** Method to call to get specific items */
|
|
83
86
|
getItemsCallback?: GetCallback;
|
|
84
87
|
|
|
85
|
-
|
|
88
|
+
/** Number of elements to fetch.
|
|
86
89
|
* When scrolled too fast, a greater number of elements
|
|
87
90
|
* are going to be requested.
|
|
88
91
|
*/
|
|
89
92
|
pageSize?: number;
|
|
90
93
|
|
|
91
|
-
|
|
94
|
+
/** Hide the search control */
|
|
92
95
|
hideFilter?: HideFilter;
|
|
93
96
|
|
|
94
|
-
|
|
97
|
+
/** Allow to reverse selection.
|
|
95
98
|
* If true, parent should support the selectionIsExcluded property.
|
|
96
99
|
* If false, the action is never available.
|
|
97
100
|
* If undefined, the action is available only when it is not needed to
|
|
@@ -99,22 +102,22 @@ export interface ParamProps {
|
|
|
99
102
|
*/
|
|
100
103
|
allowRevert?: boolean;
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
/** If true, the "select All" is still available even if all data are not fetched yet. */
|
|
103
106
|
forceSelectAll?: SelectAllOption;
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
/** Allow user to clear the current selection */
|
|
106
109
|
allowClearSelection?: boolean;
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
/** If false, avoid selecting the first available option. */
|
|
109
112
|
autoSelect?: boolean;
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
/** Disable the select if no or only one option is given and must be selected. */
|
|
112
115
|
autoDisabled?: boolean;
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
/** If true, value can be only in existing options. */
|
|
115
118
|
strictValue?: boolean;
|
|
116
119
|
|
|
117
|
-
|
|
120
|
+
/** Define how to behave when selected items are too large for container.
|
|
118
121
|
* collapsed (default): Items are reduced in width and an ellipsis
|
|
119
122
|
* is displayed in their name.
|
|
120
123
|
* multiline: The container extends in height in order to display all
|
|
@@ -122,35 +125,39 @@ export interface ParamProps {
|
|
|
122
125
|
*/
|
|
123
126
|
selectionOverflow?: SelectionOverflow;
|
|
124
127
|
|
|
125
|
-
|
|
128
|
+
/** In single mode, if no selection, this value is returned (default=null). */
|
|
126
129
|
emptyValue?: SelectedValue;
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
/** Called when item is displayed in the list. */
|
|
129
132
|
formatOption?: FormatCallback;
|
|
130
133
|
|
|
131
|
-
|
|
134
|
+
/** Called when item is displayed in the selection area. */
|
|
132
135
|
formatSelection?: FormatCallback;
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
/** Define where the list should be displayed.
|
|
135
138
|
* With 'auto' it is displayed by default at bottom, but it can be at
|
|
136
139
|
* top if there is not enough space below. */
|
|
137
140
|
listPosition?: ListPosition;
|
|
138
141
|
|
|
139
|
-
|
|
142
|
+
/** Described behavior when options from several sources are set (static, dynamic, slots)
|
|
140
143
|
* It describe what to do (sort or force)
|
|
141
144
|
* and the order (O → static options, D → dynamic options, E → slot elements)
|
|
142
145
|
* Example: "sort-ODE"
|
|
143
146
|
*/
|
|
144
147
|
optionBehavior?: string;
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
/** Keep this component open if another Selectic component opens */
|
|
147
150
|
keepOpenWithOtherSelectic?: boolean;
|
|
151
|
+
|
|
152
|
+
/** Avoid click on group name to select all items in this group. */
|
|
153
|
+
disableGroupSelection?: boolean;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
export type OnCallback = (event: string, ...args: any[]) => void;
|
|
151
157
|
export type GetMethodsCallback = (methods: {
|
|
152
158
|
clearCache: Selectic['clearCache'];
|
|
153
159
|
changeTexts: Selectic['changeTexts'];
|
|
160
|
+
changeIcons: Selectic['changeIcons'];
|
|
154
161
|
getValue: Selectic['getValue'];
|
|
155
162
|
getSelectedItems: Selectic['getSelectedItems'];
|
|
156
163
|
isEmpty: Selectic['isEmpty'];
|
|
@@ -159,47 +166,53 @@ export type GetMethodsCallback = (methods: {
|
|
|
159
166
|
|
|
160
167
|
|
|
161
168
|
export interface Props {
|
|
162
|
-
|
|
169
|
+
/** Selectic's initial value */
|
|
163
170
|
value?: SelectedValue;
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
/** If true, the effective selection is the opposite */
|
|
166
173
|
selectionIsExcluded?: boolean;
|
|
167
174
|
|
|
168
|
-
|
|
175
|
+
/** List of options to display */
|
|
169
176
|
options?: OptionProp[];
|
|
170
177
|
|
|
171
|
-
|
|
178
|
+
/** Define groups of items (similar to optGroup) */
|
|
172
179
|
groups?: GroupValue[];
|
|
173
180
|
|
|
174
|
-
|
|
181
|
+
/** Equivalent of <select>'s "multiple" attribute */
|
|
175
182
|
multiple?: boolean;
|
|
176
183
|
|
|
177
|
-
|
|
184
|
+
/** Equivalent of <select>'s "disabled" attribute */
|
|
178
185
|
disabled?: boolean;
|
|
179
186
|
|
|
180
|
-
|
|
187
|
+
/** Equivalent of <input>'s "placeholder" attribute */
|
|
181
188
|
placeholder?: string;
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
/** id of the HTML element */
|
|
184
191
|
id?: string;
|
|
185
192
|
|
|
186
|
-
|
|
193
|
+
/** CSS class of the HTML element */
|
|
187
194
|
className?: string;
|
|
188
195
|
|
|
189
|
-
|
|
196
|
+
/** title on the HTML element */
|
|
190
197
|
title?: string;
|
|
191
198
|
|
|
192
|
-
|
|
199
|
+
/** Replace the default texts used in Selectic */
|
|
193
200
|
texts?: PartialMessages;
|
|
194
201
|
|
|
195
|
-
|
|
202
|
+
/** Replace the default icons used in Selectic */
|
|
203
|
+
icons?: PartialIcons;
|
|
204
|
+
|
|
205
|
+
/** Replace the default icon family used in Selectic */
|
|
206
|
+
iconFamily?: IconFamily;
|
|
207
|
+
|
|
208
|
+
/** If enabled, it resets the dynamic cache when selectic opens */
|
|
196
209
|
noCache?: Boolean;
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
*
|
|
211
|
+
/** If true, the component opens (at start or if it is closed).
|
|
212
|
+
* If false, the components closes (if it is opened). */
|
|
200
213
|
open?: Boolean;
|
|
201
214
|
|
|
202
|
-
|
|
215
|
+
/** Props which is not expected to change during the life time of the
|
|
203
216
|
* component.
|
|
204
217
|
* These parameters modify the component behavior but are not official
|
|
205
218
|
* attributes of select.
|
|
@@ -222,6 +235,10 @@ export function changeTexts(texts: PartialMessages) {
|
|
|
222
235
|
storeChangeTexts(texts);
|
|
223
236
|
}
|
|
224
237
|
|
|
238
|
+
export function changeIcons(icons: PartialIcons, iconFamily?: IconFamily) {
|
|
239
|
+
storeChangeIcons(icons, iconFamily);
|
|
240
|
+
}
|
|
241
|
+
|
|
225
242
|
@Component
|
|
226
243
|
export default class Selectic extends Vue<Props> {
|
|
227
244
|
public $refs: {
|
|
@@ -264,6 +281,12 @@ export default class Selectic extends Vue<Props> {
|
|
|
264
281
|
@Prop()
|
|
265
282
|
public texts?: PartialMessages;
|
|
266
283
|
|
|
284
|
+
@Prop()
|
|
285
|
+
public icons?: PartialIcons;
|
|
286
|
+
|
|
287
|
+
@Prop()
|
|
288
|
+
public iconFamily?: IconFamily;
|
|
289
|
+
|
|
267
290
|
@Prop({ default: false })
|
|
268
291
|
public noCache: boolean;
|
|
269
292
|
|
|
@@ -391,17 +414,22 @@ export default class Selectic extends Vue<Props> {
|
|
|
391
414
|
/* {{{ methods */
|
|
392
415
|
/* {{{ public methods */
|
|
393
416
|
|
|
394
|
-
|
|
417
|
+
/** Reset the inner cache (mainly for dynamic mode if context has changed) */
|
|
395
418
|
public clearCache(forceReset = false) {
|
|
396
419
|
this.store.clearCache(forceReset);
|
|
397
420
|
}
|
|
398
421
|
|
|
399
|
-
|
|
422
|
+
/** Allow to change all text of the component */
|
|
400
423
|
public changeTexts(texts: PartialMessages) {
|
|
401
424
|
this.store.changeTexts(texts);
|
|
402
425
|
}
|
|
403
426
|
|
|
404
|
-
|
|
427
|
+
/** Allow to change all icons of the component */
|
|
428
|
+
public changeIcons(icons: PartialIcons, iconFamily?: IconFamily) {
|
|
429
|
+
this.store.changeIcons(icons, iconFamily);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Return the current selection */
|
|
405
433
|
public getValue(): SelectedValue {
|
|
406
434
|
const value = this.store.state.internalValue;
|
|
407
435
|
if (value === null && typeof this.params.emptyValue !== 'undefined') {
|
|
@@ -410,7 +438,7 @@ export default class Selectic extends Vue<Props> {
|
|
|
410
438
|
return value;
|
|
411
439
|
}
|
|
412
440
|
|
|
413
|
-
|
|
441
|
+
/** Return the current selection in Item format */
|
|
414
442
|
public getSelectedItems(): OptionValue | OptionValue[] {
|
|
415
443
|
const values = this.store.state.internalValue;
|
|
416
444
|
|
|
@@ -428,7 +456,7 @@ export default class Selectic extends Vue<Props> {
|
|
|
428
456
|
return this.store.getItem(values);
|
|
429
457
|
}
|
|
430
458
|
|
|
431
|
-
|
|
459
|
+
/** Check if there are Options available in the components */
|
|
432
460
|
public isEmpty() {
|
|
433
461
|
const total = this.store.state.totalAllOptions;
|
|
434
462
|
|
|
@@ -577,6 +605,15 @@ export default class Selectic extends Vue<Props> {
|
|
|
577
605
|
}
|
|
578
606
|
}
|
|
579
607
|
|
|
608
|
+
@Watch('iconFamily')
|
|
609
|
+
@Watch('icons', { deep: true })
|
|
610
|
+
public onIconsChange() {
|
|
611
|
+
const icons = this.icons;
|
|
612
|
+
const iconFamily = this.iconFamily;
|
|
613
|
+
|
|
614
|
+
this.changeIcons(icons ?? {}, iconFamily);
|
|
615
|
+
}
|
|
616
|
+
|
|
580
617
|
@Watch('disabled')
|
|
581
618
|
public onDisabledChange() {
|
|
582
619
|
this.store.props.disabled = this.disabled;
|
|
@@ -791,6 +828,8 @@ export default class Selectic extends Vue<Props> {
|
|
|
791
828
|
selectionIsExcluded: this.selectionIsExcluded,
|
|
792
829
|
disabled: this.disabled,
|
|
793
830
|
texts: this.texts,
|
|
831
|
+
icons: this.icons,
|
|
832
|
+
iconFamily: this.iconFamily,
|
|
794
833
|
groups: deepClone(this.groups),
|
|
795
834
|
keepOpenWithOtherSelectic: !!this.params.keepOpenWithOtherSelectic,
|
|
796
835
|
params: {
|
|
@@ -813,6 +852,7 @@ export default class Selectic extends Vue<Props> {
|
|
|
813
852
|
listPosition: this.params.listPosition || 'auto',
|
|
814
853
|
optionBehavior: this.params.optionBehavior, /* it can be undefined */
|
|
815
854
|
isOpen: (this.open ?? false) !== false,
|
|
855
|
+
disableGroupSelection: this.params.disableGroupSelection,
|
|
816
856
|
},
|
|
817
857
|
fetchCallback: this.params.fetchCallback,
|
|
818
858
|
getItemsCallback: this.params.getItemsCallback,
|
|
@@ -822,6 +862,7 @@ export default class Selectic extends Vue<Props> {
|
|
|
822
862
|
this._getMethods({
|
|
823
863
|
clearCache: this.clearCache.bind(this),
|
|
824
864
|
changeTexts: this.changeTexts.bind(this),
|
|
865
|
+
changeIcons: this.changeIcons.bind(this),
|
|
825
866
|
getValue: this.getValue.bind(this),
|
|
826
867
|
getSelectedItems: this.getSelectedItems.bind(this),
|
|
827
868
|
isEmpty: this.isEmpty.bind(this),
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const tape = require('tape');
|
|
2
|
+
const {
|
|
3
|
+
getOptions,
|
|
4
|
+
buildFetchCb,
|
|
5
|
+
} = require('../helper.js');
|
|
6
|
+
const _ = require('../tools.js');
|
|
7
|
+
const StoreFile = require('../dist/Store.js');
|
|
8
|
+
const Store = StoreFile.default;
|
|
9
|
+
|
|
10
|
+
tape.test('computed', (subT) => {
|
|
11
|
+
subT.test('"allowGroupSelection"', (sTest) => {
|
|
12
|
+
sTest.test('should be allowed for classic case', async (t) => {
|
|
13
|
+
const store = new Store({
|
|
14
|
+
options: getOptions(20),
|
|
15
|
+
params: {
|
|
16
|
+
multiple: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await _.nextVueTick(store);
|
|
21
|
+
|
|
22
|
+
t.is(store.allowGroupSelection.value, true);
|
|
23
|
+
|
|
24
|
+
t.end();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
sTest.test('should not be allowed with dynamic mode', async (t) => {
|
|
28
|
+
/* {{{ preparation */
|
|
29
|
+
|
|
30
|
+
const store = new Store({
|
|
31
|
+
groups: [{
|
|
32
|
+
id: 'g1',
|
|
33
|
+
name: 'Group 1',
|
|
34
|
+
}],
|
|
35
|
+
fetchCallback: buildFetchCb({ total: 200, group: [{
|
|
36
|
+
name: 'g1',
|
|
37
|
+
offset: 0,
|
|
38
|
+
}] }),
|
|
39
|
+
params: {
|
|
40
|
+
multiple: true,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/* }}} */
|
|
45
|
+
|
|
46
|
+
await _.nextVueTick(store);
|
|
47
|
+
|
|
48
|
+
t.is(store.allowGroupSelection.value, false);
|
|
49
|
+
|
|
50
|
+
t.end();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
sTest.test('should not be allowed when not in multiple', async (t) => {
|
|
54
|
+
const store = new Store({
|
|
55
|
+
options: getOptions(20),
|
|
56
|
+
params: {
|
|
57
|
+
multiple: false,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
await _.nextVueTick(store);
|
|
62
|
+
|
|
63
|
+
t.is(store.allowGroupSelection.value, false);
|
|
64
|
+
|
|
65
|
+
t.end();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
sTest.test('should not be allowed with option disableGroupSelection', async (t) => {
|
|
69
|
+
const store = new Store({
|
|
70
|
+
options: getOptions(20),
|
|
71
|
+
params: {
|
|
72
|
+
multiple: true,
|
|
73
|
+
disableGroupSelection: true,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await _.nextVueTick(store);
|
|
78
|
+
|
|
79
|
+
t.is(store.allowGroupSelection.value, false);
|
|
80
|
+
|
|
81
|
+
t.end();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|