vue3-extended-multiselect 0.1.4 → 0.2.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/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ tests/unit
2
+ tests/utils/mount.js
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Patch notes
2
2
 
3
- Current `vue3-extended-multiselect` version: **0.1.4**
3
+ Current `vue3-extended-multiselect` version: **0.2.1**
4
4
 
5
5
  ***
6
6
 
@@ -30,7 +30,7 @@ Relocation of main.js file for local qa tests.
30
30
 
31
31
  ### 0.1.0 (2022-12-01)
32
32
 
33
- * Changing the style language from `sass` to `css` for for greater package accessibility.
33
+ * Changing the style language from `sass` to `css` for greater package accessibility.
34
34
  * Removal of dev-dependency "sass".
35
35
  * Removal of dev-dependency "sass-loader".
36
36
 
@@ -48,4 +48,18 @@ Adding .nvmrc file.
48
48
 
49
49
  ### 0.1.4 (2022-12-05)
50
50
 
51
- Adding descriptive comments for some types in typings.
51
+ Adding descriptive comments for some types in typings.
52
+
53
+ ### 0.2.0 (2022-12-07)
54
+
55
+ * Fix bug with hidden "noOptions" slot when list of available options is empty.
56
+ * Fix warning with incorrect array type reactive field initialization.
57
+ * Adding .eslintignore file.
58
+ * Replacing some of default exports with common exports.
59
+ * Arranging CSS-variabled in alphabetical order.
60
+ * Adding customizing section in documentation.
61
+
62
+ ### 0.2.1 (2022-12-08)
63
+
64
+ * Replacing all common exports with default exports.
65
+ * Removal of excess emitter import in composition.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v0.1.4
1
+ # vue3-extended-multiselect v0.2.1
2
2
 
3
3
  ***
4
4
 
@@ -26,6 +26,14 @@ import Vue3ExtendedMultiselect from "vue3-extended-multiselect"
26
26
  import { UnionOptionType } from "vue3-extended-multiselect"
27
27
  ```
28
28
 
29
+ ## Table of contents
30
+ * [Props list](#props-list)
31
+ * [Slots list](#slots-list)
32
+ * [Events list](#events-list)
33
+ * [Styling with css](#styling-with-css)
34
+ * [Styling with props](#styling-with-props)
35
+ * [License](#license)
36
+
29
37
  ## Props list
30
38
  Prop name | Prop type | Prop appointment | Prop default value | Prop values
31
39
  ----------|-----------|------------------|--------------------|------------
@@ -111,6 +119,144 @@ Event name | Event appointment | Listener method | Simplified event payload | Fi
111
119
  **close**|Rolling up dropdown options list.|@close|``options`` — array of selected options|``options`` — array of selected options,<br/>``inputId`` — id of search field set by "id" prop|
112
120
  **increase**|Increasing current limit of displayed elements with selected options.|@increase|``limit`` — current limit of options to be shown next|``limit`` — current limit of options to be shown next,<br/>``inputId`` — id of search field set by "id" prop|
113
121
 
122
+ ## Styling with css
123
+
124
+ Vue3 extended multiselect provides following css-variables:
125
+
126
+ ```css
127
+ --basic-color: #708090;
128
+ --basic-transparent: rgba(112, 128, 144, 0.6);
129
+ --cancel: #B22222;
130
+ --cancel-backgound-color: rgba(179, 33, 33, 0.1);
131
+ --dark-slate-blue: #483D8B;
132
+ --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
133
+ --dark-slate-grey: #2F4F4F;
134
+ --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
135
+ --disabled: rgba(176, 176, 176, 0.6);
136
+ --hover-color: #FFFFFF;
137
+ --loader-color: #00BFFF;
138
+ --strict: #000000;
139
+ --strict-transparent: rgba(0, 0, 0, 0.6);
140
+ --teal: #008080;
141
+ --teal-transparent: rgba(0, 128, 128, 0.6);
142
+
143
+ --block-border-radius: 4px;
144
+ --block-cancel-padding: 4px;
145
+ --block-gap: 6px;
146
+ --block-padding: 1px 3px 1px 7px;
147
+ --border-radius: 6px;
148
+ --border-radius-small: 3px;
149
+ --cancel-padding: 3px 8px;
150
+ --grid-columns: 1fr 36px 36px;
151
+ --grid-rows: 1fr 36px;
152
+ --half-size: 50%;
153
+ --icon-size-block: 14px;
154
+ --icon-size-large: 18px;
155
+ --icon-size-medium: 15px;
156
+ --icon-size-small: 12px;
157
+ --increaser-padding: 3px 7px;
158
+ --marker-padding: 6px 40px;
159
+ --max-size: 100%;
160
+ --min-block-height: 25px;
161
+ --options-padding: 6px 0;
162
+ --outer-gap: 10px;
163
+ --root-padding: 6px 10px;
164
+ --toggle-icon-gap: 1px;
165
+ --wide-text: 700;
166
+ --wrapper-padding: 5px 10px;
167
+
168
+ --border: 1px solid;
169
+ --default-cursor: default;
170
+ --icons-align-self: start;
171
+ --icons-justify-self: center;
172
+ --pointer-cursor: pointer;
173
+ ```
174
+
175
+ You can override it globally or by particular instance class name.
176
+
177
+ ```css
178
+ :root {
179
+ --basic-color: purple;
180
+ --outer-gap: 2rem;
181
+ --border: 1px dotted;
182
+ }
183
+ ```
184
+
185
+ ```html
186
+ <vue3-extended-multiselect class="instance-class" />
187
+ ```
188
+
189
+ ```css
190
+ .instance-class {
191
+ --basic-color: purple;
192
+ --outer-gap: 2rem;
193
+ --border: 1px dotted;
194
+ }
195
+ ```
196
+
197
+ ## Styling with props
198
+
199
+ Vue3 extended multiselect provides following props for customizing:
200
+
201
+ * errorBorderColor
202
+ * iconFilter
203
+ * iconSize
204
+ * loaderIconFilter
205
+ * themeType
206
+ * toggleIcon
207
+ * anyOptionWrapperBlockHeight
208
+ * toggleMaxHeight
209
+ * toggleMinHeight
210
+
211
+ #### Customizing examples
212
+
213
+ Changing border color when extended multiselect value is invalid.
214
+
215
+ ```html
216
+ <vue3-extended-multiselect error-border-color="#8B0000" />
217
+ ```
218
+ Changing svg color filter for icons.
219
+
220
+ ```html
221
+ <vue3-extended-multiselect icon-filter="green" />
222
+ ```
223
+ Resizing icons.
224
+
225
+ ```html
226
+ <vue3-extended-multiselect icon-size="small" />
227
+ ```
228
+ Changing svg color filter for loader icon.
229
+
230
+ ```html
231
+ <vue3-extended-multiselect icon-size="small" />
232
+ ```
233
+ Changing general color theme of extended multiselect.
234
+
235
+ ```html
236
+ <vue3-extended-multiselect theme-type="slate-blue" />
237
+ ```
238
+ Changing toggle icon form.
239
+
240
+ ```html
241
+ <vue3-extended-multiselect toggle-icon="triangle-arrow" />
242
+ ```
243
+ Resizing option blocks in options list.
244
+
245
+ ```html
246
+ <vue3-extended-multiselect :any-option-wrapper-block-height="60" />
247
+ ```
248
+ Changing "max-height" css-property of options list.
249
+
250
+ ```html
251
+ <vue3-extended-multiselect :toggle-max-height="500" />
252
+ ```
253
+
254
+ Changing "min-height" css-property of options list.
255
+
256
+ ```html
257
+ <vue3-extended-multiselect :toggle-min-height="500" />
258
+ ```
259
+
114
260
  ## License
115
261
 
116
262
  [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -29,6 +29,8 @@ import {
29
29
  toRefs,
30
30
  } from "vue";
31
31
 
32
+ import emitter from "tiny-emitter/instance";
33
+
32
34
  import useCancel from "../composition/cancel";
33
35
  import useSizes from "../composition/sizes";
34
36
 
@@ -115,6 +117,7 @@ const { cancel } = useCancel(
115
117
  disabled,
116
118
  showSearchField,
117
119
  selectedOptions,
120
+ emitter,
118
121
  );
119
122
  const { iconSizeClass } = useSizes(iconSize);
120
123
 
@@ -137,7 +137,6 @@ import {
137
137
  nextTick,
138
138
  onBeforeMount,
139
139
  onMounted,
140
- reactive,
141
140
  ref,
142
141
  toRefs,
143
142
  useAttrs,
@@ -359,7 +358,7 @@ const searchValue = ref("");
359
358
  const singleLabel = ref("");
360
359
  const blurSkipByToggleIcon = ref(0);
361
360
  const blurSkipByBlock = ref(0);
362
- const labelBlocks = reactive([]);
361
+ const labelBlocks = ref([]);
363
362
  const searchDebounce = ref(debounce(() => {
364
363
  const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
365
364
  emitter.emit("extended:search-pattern-changed", searchValue.value);
@@ -499,7 +499,8 @@ const classes = computed(() => {
499
499
  * @returns {boolean} emptiness
500
500
  */
501
501
  const emptyOptionsList = computed(() => {
502
- return !options.value.length || !options.value.filter((option) => !!option).length;
502
+ return (!options.value.length || !options.value.filter((option) => !!option).length
503
+ || !availableOptions.value.length) && !(createOnTheGo.value && searchState.searchValue);
503
504
  });
504
505
 
505
506
  /**
@@ -83,6 +83,8 @@ import {
83
83
  toRefs,
84
84
  } from "vue";
85
85
 
86
+ import emitter from "tiny-emitter/instance";
87
+
86
88
  import useToggle from "../composition/toggle";
87
89
  import useSizes from "../composition/sizes";
88
90
 
@@ -166,7 +168,12 @@ const {
166
168
  toggleIcon,
167
169
  } = toRefs(props);
168
170
 
169
- const { toggleSlotClass, toggleOptionsList } = useToggle(loading, disabled);
171
+ const { toggleSlotClass, toggleOptionsList } = useToggle(
172
+ loading,
173
+ disabled,
174
+ null,
175
+ emitter,
176
+ );
170
177
  const { iconSizeClass } = useSizes(iconSize);
171
178
 
172
179
  /**
@@ -894,8 +894,18 @@ provide("searchState", searchState);
894
894
  provide("setSearchValue", setSearchValue);
895
895
  provide("setSearchPattern", setSearchPattern);
896
896
 
897
- const { toggleOptionsList } = useToggle(loading, disabled, internalLoader);
898
- const { cancel } = useCancel(disabled, showSearchField, selectedOptions);
897
+ const { toggleOptionsList } = useToggle(
898
+ loading,
899
+ disabled,
900
+ internalLoader,
901
+ emitter,
902
+ );
903
+ const { cancel } = useCancel(
904
+ disabled,
905
+ showSearchField,
906
+ selectedOptions,
907
+ emitter,
908
+ );
899
909
  const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
900
910
  label,
901
911
  emptyObjectsPlaceholder,
@@ -1,8 +1,6 @@
1
- import emitter from 'tiny-emitter/instance';
2
-
3
1
  import useSearchValue from './search-value';
4
2
 
5
- export default function useCancel(disabled, showSearchField, selectedOptions) {
3
+ export default function useCancel(disabled, showSearchField, selectedOptions, emitter) {
6
4
  /**
7
5
  * Removes all selected options or single selected option
8
6
  * when "multiple" prop equals false
@@ -1,8 +1,6 @@
1
1
  import { computed, readonly } from "vue";
2
2
 
3
- import emitter from 'tiny-emitter/instance';
4
-
5
- export default function useToggle(loading, disabled, internalLoader) {
3
+ export default function useToggle(loading, disabled, internalLoader, emitter) {
6
4
  /**
7
5
  * Toggles classes of slots if "loading"
8
6
  * or "disabled" props equals true
@@ -16,4 +16,4 @@
16
16
  100% {
17
17
  transform: rotate(2turn);
18
18
  }
19
- }
19
+ }
@@ -5,7 +5,7 @@
5
5
  .extended__multiselect-wrapper--disabled {
6
6
  position: relative;
7
7
  width: var(--max-size);
8
- cursor: pointer;
8
+ cursor: var(--pointer-cursor);
9
9
  }
10
10
 
11
11
  .extended__multiselect-wrapper *,
@@ -19,12 +19,12 @@
19
19
  .extended__multiselect-wrapper--disabled #extended__multiselect {
20
20
  background-color: var(--disabled);
21
21
  user-select: none;
22
- cursor: default;
22
+ cursor: var(--default-cursor);
23
23
  }
24
24
 
25
25
  .extended__multiselect-wrapper--disabled .extended__multiselect-input,
26
26
  .extended__multiselect-wrapper--disabled .extended__multiselect-input--hidden {
27
- cursor: default;
27
+ cursor: --default-cursor;
28
28
  }
29
29
 
30
30
  .extended__multiselect,
@@ -77,7 +77,7 @@
77
77
  display: flex;
78
78
  flex-flow: column nowrap;
79
79
  position: absolute;
80
- cursor: pointer;
80
+ cursor: var(--pointer-cursor);
81
81
  border: var(--border);
82
82
  color: inherit;
83
83
  user-select: none;
@@ -114,11 +114,11 @@
114
114
  }
115
115
 
116
116
  .extended__multiselect-clear--active {
117
- grid-template-columns: 1fr 36px 36px;
117
+ grid-template-columns: var(--grid-columns);
118
118
  }
119
119
 
120
120
  .extended__multiselect-clear--locked {
121
- grid-template-columns: 1fr 36px;
121
+ grid-template-columns: var(--grid-rows);
122
122
  }
123
123
 
124
124
  .extended__multiselect,
@@ -148,7 +148,7 @@
148
148
 
149
149
  .extended__multiselect-input,
150
150
  .extended__multiselect-block {
151
- min-height: 25px;
151
+ min-height: var(--min-block-height);
152
152
  width: var(--max-size);
153
153
  border: none;
154
154
  outline: none;
@@ -179,7 +179,7 @@
179
179
 
180
180
  .extended__multiselect-input--hidden {
181
181
  position: absolute;
182
- cursor: pointer;
182
+ cursor: var(--pointer-cursor);
183
183
  border: none;
184
184
  width: 0;
185
185
  height: 0;
@@ -213,9 +213,9 @@
213
213
 
214
214
  .extended__multiselect-toggle,
215
215
  .extended__multiselect-cancel {
216
- align-self: start;
217
- justify-self: center;
218
- cursor: pointer;
216
+ align-self: var(--icons-align-self);
217
+ justify-self: var(--icons-justify-self);
218
+ cursor: var(--pointer-cursor);
219
219
  }
220
220
 
221
221
  .extended__multiselect-toggle {
@@ -266,7 +266,7 @@
266
266
 
267
267
  .extended__multiselect-cancel:active {
268
268
  border-color: var(--cancel);
269
- border-radius: 3px;
269
+ border-radius: var(--border-radius-small);
270
270
  background-color: var(--cancel-backgound-color);
271
271
  }
272
272
 
@@ -397,7 +397,7 @@
397
397
  .extended__multiselect-options_option--disabled {
398
398
  background-color: var(--disabled);
399
399
  user-select: none;
400
- cursor: default;
400
+ cursor: --default-cursor;
401
401
  }
402
402
 
403
403
  .extended__multiselect_deselect-block-icon {
@@ -422,7 +422,7 @@
422
422
 
423
423
  .extended__multiselect-block_cancel-wrapper:active {
424
424
  border-color: var(--cancel);
425
- border-radius: 3px;
425
+ border-radius: var(--border-radius-small);
426
426
  background-color: var(--cancel-backgound-color);
427
427
  }
428
428
 
@@ -430,5 +430,4 @@
430
430
  border: var(--border);
431
431
  border-color: transparent;
432
432
  padding: var(--increaser-padding);
433
- }
434
-
433
+ }
@@ -1,41 +1,49 @@
1
1
  .extended__multiselect-wrapper,
2
2
  .extended__multiselect-wrapper--disabled {
3
3
  --basic-color: #708090;
4
- --dark-slate-grey: #2F4F4F;
5
- --dark-slate-blue: #483D8B;
6
- --teal: #008080;
7
- --strict: #000000;
8
- --hover-color: #FFFFFF;
9
4
  --basic-transparent: rgba(112, 128, 144, 0.6);
10
- --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
11
- --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
12
- --teal-transparent: rgba(0, 128, 128, 0.6);
13
- --strict-transparent: rgba(0, 0, 0, 0.6);
14
5
  --cancel: #B22222;
15
6
  --cancel-backgound-color: rgba(179, 33, 33, 0.1);
7
+ --dark-slate-blue: #483D8B;
8
+ --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
9
+ --dark-slate-grey: #2F4F4F;
10
+ --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
16
11
  --disabled: rgba(176, 176, 176, 0.6);
12
+ --hover-color: #FFFFFF;
17
13
  --loader-color: #00BFFF;
14
+ --strict: #000000;
15
+ --strict-transparent: rgba(0, 0, 0, 0.6);
16
+ --teal: #008080;
17
+ --teal-transparent: rgba(0, 128, 128, 0.6);
18
18
 
19
- --wide-text: 700;
20
- --max-size: 100%;
19
+ --block-border-radius: 4px;
20
+ --block-cancel-padding: 4px;
21
+ --block-gap: 6px;
22
+ --block-padding: 1px 3px 1px 7px;
23
+ --border-radius: 6px;
24
+ --border-radius-small: 3px;
25
+ --cancel-padding: 3px 8px;
26
+ --grid-columns: 1fr 36px 36px;
27
+ --grid-rows: 1fr 36px;
21
28
  --half-size: 50%;
29
+ --icon-size-block: 14px;
22
30
  --icon-size-large: 18px;
23
31
  --icon-size-medium: 15px;
24
32
  --icon-size-small: 12px;
25
- --wrapper-padding: 5px 10px;
26
- --root-padding: 6px 10px;
33
+ --increaser-padding: 3px 7px;
27
34
  --marker-padding: 6px 40px;
35
+ --max-size: 100%;
36
+ --min-block-height: 25px;
28
37
  --options-padding: 6px 0;
29
- --border-radius: 6px;
30
- --block-border-radius: 4px;
31
- --icon-size-block: 14px;
32
- --block-gap: 6px;
33
38
  --outer-gap: 10px;
39
+ --root-padding: 6px 10px;
34
40
  --toggle-icon-gap: 1px;
35
- --block-padding: 1px 3px 1px 7px;
36
- --increaser-padding: 3px 7px;
37
- --cancel-padding: 3px 8px;
38
- --block-cancel-padding: 4px;
39
-
41
+ --wide-text: 700;
42
+ --wrapper-padding: 5px 10px;
43
+
40
44
  --border: 1px solid;
41
- }
45
+ --default-cursor: default;
46
+ --icons-align-self: start;
47
+ --icons-justify-self: center;
48
+ --pointer-cursor: pointer;
49
+ }