slim-select 2.2.3 → 2.3.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.
- package/README.md +2 -6
- package/dist/index.d.ts +1 -1
- package/dist/render.d.ts +4 -2
- package/dist/select.d.ts +6 -11
- package/dist/settings.d.ts +3 -1
- package/dist/slimselect.cjs.js +206 -173
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +206 -173
- package/dist/slimselect.global.js +206 -173
- package/dist/slimselect.js +206 -173
- package/dist/slimselect.min.js +1 -1
- package/dist/slimselect.umd.js +206 -173
- package/dist/slimselect.umd.min.js +1 -1
- package/jest.config.js +1 -0
- package/package.json +4 -4
- package/src/slim-select/index.ts +45 -35
- package/src/slim-select/render.ts +146 -97
- package/src/slim-select/select.test.ts +143 -23
- package/src/slim-select/select.ts +110 -91
- package/src/slim-select/settings.ts +6 -2
- package/src/slim-select/slimselect.scss +33 -10
- package/src/slim-select/store.test.ts +22 -0
- package/src/vue/dist/slim-select/index.d.ts +1 -1
- package/src/vue/dist/slim-select/render.d.ts +4 -2
- package/src/vue/dist/slim-select/select.d.ts +6 -11
- package/src/vue/dist/slim-select/settings.d.ts +3 -1
- package/src/vue/dist/slimselectvue.es.js +225 -186
- package/src/vue/dist/slimselectvue.global.js +225 -186
- package/src/vue/dist/slimselectvue.ssr.js +225 -186
- package/src/vue/dist/vue/slimselect.vue.d.ts +21 -17
- package/src/vue/package.json +1 -1
- package/src/vue/slimselect.vue +27 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PropType } from 'vue';
|
|
3
3
|
import SlimSelect, { Events } from '../slim-select';
|
|
4
|
-
import Settings from '../slim-select/settings';
|
|
5
4
|
import { DataArrayPartial, Option } from '../slim-select/store';
|
|
6
5
|
declare const _default: import("vue").DefineComponent<{
|
|
7
6
|
modelValue: {
|
|
@@ -15,7 +14,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
15
14
|
type: PropType<DataArrayPartial>;
|
|
16
15
|
};
|
|
17
16
|
settings: {
|
|
18
|
-
type: PropType<
|
|
17
|
+
type: PropType<Partial<import("../slim-select/settings").default>>;
|
|
19
18
|
};
|
|
20
19
|
events: {
|
|
21
20
|
type: PropType<Events>;
|
|
@@ -44,7 +43,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
44
43
|
ref: () => NodeJS.Timeout;
|
|
45
44
|
unref: () => NodeJS.Timeout;
|
|
46
45
|
} | null;
|
|
47
|
-
|
|
46
|
+
disabled: boolean;
|
|
48
47
|
alwaysOpen: boolean;
|
|
49
48
|
showSearch: boolean;
|
|
50
49
|
searchPlaceholder: string;
|
|
@@ -62,21 +61,21 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
62
61
|
minSelected: number;
|
|
63
62
|
maxSelected: number;
|
|
64
63
|
timeoutDelay: number;
|
|
64
|
+
maxValuesShown: number;
|
|
65
|
+
maxValuesMessage: string;
|
|
65
66
|
};
|
|
66
67
|
select: {
|
|
67
68
|
select: HTMLSelectElement;
|
|
68
|
-
listen: boolean;
|
|
69
|
-
onSelectChange?: ((data: DataArrayPartial) => void) | undefined;
|
|
70
69
|
onValueChange?: ((value: string[]) => void) | undefined;
|
|
70
|
+
onClassChange?: ((classes: string[]) => void) | undefined;
|
|
71
|
+
onDisabledChange?: ((disabled: boolean) => void) | undefined;
|
|
72
|
+
onOptionsChange?: ((data: DataArrayPartial) => void) | undefined;
|
|
73
|
+
listen: boolean;
|
|
71
74
|
enable: () => void;
|
|
72
75
|
disable: () => void;
|
|
73
76
|
hideUI: () => void;
|
|
74
77
|
showUI: () => void;
|
|
75
|
-
changeListen: (
|
|
76
|
-
addSelectChangeListener: (func: (data: DataArrayPartial) => void) => void;
|
|
77
|
-
removeSelectChangeListener: () => void;
|
|
78
|
-
addValueChangeListener: (func: (value: string[]) => void) => void;
|
|
79
|
-
removeValueChangeListener: () => void;
|
|
78
|
+
changeListen: (listen: boolean) => void;
|
|
80
79
|
valueChange: (ev: Event) => boolean;
|
|
81
80
|
getData: () => DataArrayPartial;
|
|
82
81
|
getDataFromOptgroup: (optgroup: HTMLOptGroupElement) => import("../slim-select/store").OptgroupOptional;
|
|
@@ -97,7 +96,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
96
|
getData: () => import("../slim-select/store").DataArray;
|
|
98
97
|
getDataOptions: () => Option[];
|
|
99
98
|
addOption: (option: import("../slim-select/store").OptionOptional) => void;
|
|
100
|
-
setSelectedBy: (selectedType: "
|
|
99
|
+
setSelectedBy: (selectedType: "id" | "value", selectedValues: string[]) => void;
|
|
101
100
|
getSelected: () => string[];
|
|
102
101
|
getSelectedOptions: () => Option[];
|
|
103
102
|
getSelectedIDs: () => string[];
|
|
@@ -121,7 +120,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
121
120
|
ref: () => NodeJS.Timeout;
|
|
122
121
|
unref: () => NodeJS.Timeout;
|
|
123
122
|
} | null;
|
|
124
|
-
|
|
123
|
+
disabled: boolean;
|
|
125
124
|
alwaysOpen: boolean;
|
|
126
125
|
showSearch: boolean;
|
|
127
126
|
searchPlaceholder: string;
|
|
@@ -139,6 +138,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
139
138
|
minSelected: number;
|
|
140
139
|
maxSelected: number;
|
|
141
140
|
timeoutDelay: number;
|
|
141
|
+
maxValuesShown: number;
|
|
142
|
+
maxValuesMessage: string;
|
|
142
143
|
};
|
|
143
144
|
store: {
|
|
144
145
|
validateDataArray: (data: DataArrayPartial | import("../slim-select/store").DataArray) => Error | null;
|
|
@@ -148,7 +149,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
148
149
|
getData: () => import("../slim-select/store").DataArray;
|
|
149
150
|
getDataOptions: () => Option[];
|
|
150
151
|
addOption: (option: import("../slim-select/store").OptionOptional) => void;
|
|
151
|
-
setSelectedBy: (selectedType: "
|
|
152
|
+
setSelectedBy: (selectedType: "id" | "value", selectedValues: string[]) => void;
|
|
152
153
|
getSelected: () => string[];
|
|
153
154
|
getSelectedOptions: () => Option[];
|
|
154
155
|
getSelectedIDs: () => string[];
|
|
@@ -161,7 +162,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
161
162
|
open: () => void;
|
|
162
163
|
close: () => void;
|
|
163
164
|
addable?: ((value: string) => string | import("../slim-select/store").OptionOptional | Promise<string | import("../slim-select/store").OptionOptional>) | undefined;
|
|
164
|
-
setSelected: (value: string[]) => void;
|
|
165
|
+
setSelected: (value: string[], runAfterChange: boolean) => void;
|
|
165
166
|
addOption: (option: Option) => void;
|
|
166
167
|
search: (search: string) => void;
|
|
167
168
|
beforeChange?: ((newVal: Option[], oldVal: Option[]) => boolean | void) | undefined;
|
|
@@ -198,6 +199,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
198
199
|
placeholder: string;
|
|
199
200
|
values: string;
|
|
200
201
|
single: string;
|
|
202
|
+
max: string;
|
|
201
203
|
value: string;
|
|
202
204
|
valueText: string;
|
|
203
205
|
valueDelete: string;
|
|
@@ -238,6 +240,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
238
240
|
disable: () => void;
|
|
239
241
|
open: () => void;
|
|
240
242
|
close: () => void;
|
|
243
|
+
updateClassStyles: () => void;
|
|
241
244
|
mainDiv: () => import("../slim-select/render").Main;
|
|
242
245
|
mainFocus: (trigger: boolean) => void;
|
|
243
246
|
placeholder: () => HTMLDivElement;
|
|
@@ -258,7 +261,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
258
261
|
moveContentAbove: () => void;
|
|
259
262
|
moveContentBelow: () => void;
|
|
260
263
|
ensureElementInView: (container: HTMLElement, element: HTMLElement) => void;
|
|
261
|
-
putContent: (
|
|
264
|
+
putContent: () => "up" | "down";
|
|
262
265
|
};
|
|
263
266
|
events: {
|
|
264
267
|
search?: ((searchValue: string, currentData: import("../slim-select/store").DataArray) => DataArrayPartial | Promise<DataArrayPartial>) | undefined;
|
|
@@ -277,13 +280,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
277
280
|
getData: () => import("../slim-select/store").DataArray;
|
|
278
281
|
setData: (data: DataArrayPartial) => void;
|
|
279
282
|
getSelected: () => string[];
|
|
280
|
-
setSelected: (value: string | string[]) => void;
|
|
283
|
+
setSelected: (value: string | string[], runAfterChange?: boolean) => void;
|
|
281
284
|
addOption: (option: import("../slim-select/store").OptionOptional) => void;
|
|
282
285
|
open: () => void;
|
|
283
286
|
close: () => void;
|
|
284
287
|
search: (value: string) => void;
|
|
285
288
|
destroy: () => void;
|
|
286
289
|
} | null;
|
|
290
|
+
getCleanValue(val: string | string[] | undefined): string | string[];
|
|
287
291
|
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
288
292
|
modelValue: {
|
|
289
293
|
type: PropType<string | string[] | undefined>;
|
|
@@ -296,7 +300,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
296
300
|
type: PropType<DataArrayPartial>;
|
|
297
301
|
};
|
|
298
302
|
settings: {
|
|
299
|
-
type: PropType<
|
|
303
|
+
type: PropType<Partial<import("../slim-select/settings").default>>;
|
|
300
304
|
};
|
|
301
305
|
events: {
|
|
302
306
|
type: PropType<Events>;
|
package/src/vue/package.json
CHANGED
package/src/vue/slimselect.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defineComponent, PropType } from 'vue'
|
|
3
3
|
|
|
4
4
|
import SlimSelect, { Config, Events } from '../slim-select'
|
|
5
|
-
import
|
|
5
|
+
import { SettingsPartial } from '../slim-select/settings'
|
|
6
6
|
import { DataArrayPartial, Option } from '../slim-select/store'
|
|
7
7
|
|
|
8
8
|
export default defineComponent({
|
|
@@ -19,7 +19,7 @@ export default defineComponent({
|
|
|
19
19
|
type: Array as PropType<DataArrayPartial>,
|
|
20
20
|
},
|
|
21
21
|
settings: {
|
|
22
|
-
type: Object as PropType<
|
|
22
|
+
type: Object as PropType<SettingsPartial>,
|
|
23
23
|
},
|
|
24
24
|
events: {
|
|
25
25
|
type: Object as PropType<Events>,
|
|
@@ -54,7 +54,7 @@ export default defineComponent({
|
|
|
54
54
|
config.events = {}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// Wrap config.events.afterChange to run
|
|
57
|
+
// Wrap config.events.afterChange to run value update
|
|
58
58
|
const ogAfterChange = config.events.afterChange
|
|
59
59
|
config.events.afterChange = (newVal: Option[]) => {
|
|
60
60
|
const value = this.multiple ? newVal.map((option) => option.value) : newVal[0].value
|
|
@@ -79,7 +79,7 @@ export default defineComponent({
|
|
|
79
79
|
// Check if modelValue is the same as the value of the select
|
|
80
80
|
if (this.value !== selected) {
|
|
81
81
|
// If not, set the value of the select to the modelValue
|
|
82
|
-
this.value
|
|
82
|
+
this.slim.setSelected(this.value)
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
beforeUnmount() {
|
|
@@ -88,6 +88,13 @@ export default defineComponent({
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
watch: {
|
|
91
|
+
modelValue: {
|
|
92
|
+
handler: function (newVal: string | string[] | undefined) {
|
|
93
|
+
// Set the value of the select to the newVal
|
|
94
|
+
this.slim?.setSelected(this.getCleanValue(newVal))
|
|
95
|
+
},
|
|
96
|
+
immediate: true,
|
|
97
|
+
},
|
|
91
98
|
data: {
|
|
92
99
|
handler: function (newData) {
|
|
93
100
|
if (this.slim) {
|
|
@@ -100,25 +107,7 @@ export default defineComponent({
|
|
|
100
107
|
computed: {
|
|
101
108
|
value: {
|
|
102
109
|
get(): string | string[] {
|
|
103
|
-
|
|
104
|
-
const val = this.$props.modelValue
|
|
105
|
-
|
|
106
|
-
// If modelValue is undefined, return empty string or array
|
|
107
|
-
if (val === undefined) {
|
|
108
|
-
return multi ? [] : ''
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// If its multiple and the modelValue is a string, return an array with the string
|
|
112
|
-
if (multi && typeof val === 'string') {
|
|
113
|
-
return [val]
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// If its not multiple and the modelValue is an array, return the first item
|
|
117
|
-
if (!multi && Array.isArray(val)) {
|
|
118
|
-
return val[0]
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return multi ? [] : ''
|
|
110
|
+
return this.getCleanValue(this.$props.modelValue)
|
|
122
111
|
},
|
|
123
112
|
set(value: string | string[]) {
|
|
124
113
|
this.$emit('update:modelValue', value)
|
|
@@ -130,6 +119,21 @@ export default defineComponent({
|
|
|
130
119
|
getSlimSelect() {
|
|
131
120
|
return this.slim
|
|
132
121
|
},
|
|
122
|
+
getCleanValue(val: string | string[] | undefined): string | string[] {
|
|
123
|
+
const multi = this.$props.multiple
|
|
124
|
+
|
|
125
|
+
// If its multiple and the modelValue is a string, return an array with the string
|
|
126
|
+
if (typeof val === 'string') {
|
|
127
|
+
return multi ? [val] : val
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// If its not multiple and the modelValue is an array, return the first item
|
|
131
|
+
if (Array.isArray(val)) {
|
|
132
|
+
return multi ? val : val[0]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return multi ? [] : ''
|
|
136
|
+
},
|
|
133
137
|
},
|
|
134
138
|
})
|
|
135
139
|
</script>
|