@nethserver/ns8-ui-lib 0.1.26 → 0.1.28
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 +1 -22
- package/dist/ns8-ui-lib.esm.js +124 -86
- package/dist/ns8-ui-lib.min.js +1 -1
- package/dist/ns8-ui-lib.ssr.js +141 -107
- package/package.json +1 -1
- package/src/lib-components/NsMultiSelect.vue +119 -76
- package/src/lib-components/NsToggle.vue +1 -1
package/README.md
CHANGED
|
@@ -2,25 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
This library includes [Vue.js](https://vuejs.org/) UI components and mixins used by [NethServer 8](https://github.com/NethServer/ns8-core) UI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
// main.js
|
|
9
|
-
|
|
10
|
-
import ns8Lib from "@nethserver/ns8-ui-lib";
|
|
11
|
-
Vue.use(ns8Lib);
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
To import a mixin inside a component (e.g. `TaskService` mixin):
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
// ComponentName.vue
|
|
18
|
-
|
|
19
|
-
import { TaskService } from "@nethserver/ns8-ui-lib";
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
name: "ComponentName",
|
|
23
|
-
mixins: [TaskService],
|
|
24
|
-
...
|
|
25
|
-
}
|
|
26
|
-
```
|
|
5
|
+
Documentation of NS8 UI library can be found in [this section of the Developer manual](https://nethserver.github.io/ns8-core/ui/library/).
|
package/dist/ns8-ui-lib.esm.js
CHANGED
|
@@ -18105,7 +18105,7 @@ var __vue_render__$g = function () {
|
|
|
18105
18105
|
"for": _vm.uid,
|
|
18106
18106
|
"aria-label": _vm.hiddenLabel
|
|
18107
18107
|
}
|
|
18108
|
-
}, [_c('div', [_vm._v(
|
|
18108
|
+
}, [_c('div', [_c('span', [_vm._v(_vm._s(_vm.visibleLabel))]), _vm._v(" "), _vm.hasTooltipSlot && !_vm.hideLabel ? _c('cv-interactive-tooltip', {
|
|
18109
18109
|
staticClass: "tooltip info",
|
|
18110
18110
|
attrs: {
|
|
18111
18111
|
"alignment": _vm.tooltipAlignment,
|
|
@@ -18148,11 +18148,11 @@ var __vue_staticRenderFns__$g = [];
|
|
|
18148
18148
|
|
|
18149
18149
|
const __vue_inject_styles__$h = function (inject) {
|
|
18150
18150
|
if (!inject) return;
|
|
18151
|
-
inject("data-v-
|
|
18152
|
-
source: ".tooltip[data-v-
|
|
18151
|
+
inject("data-v-ce406b84_0", {
|
|
18152
|
+
source: ".tooltip[data-v-ce406b84]{display:inline-block;position:absolute}",
|
|
18153
18153
|
map: undefined,
|
|
18154
18154
|
media: undefined
|
|
18155
|
-
}), inject("data-v-
|
|
18155
|
+
}), inject("data-v-ce406b84_1", {
|
|
18156
18156
|
source: ".ns-toggle .bx--tooltip__label .bx--tooltip__trigger{margin-left:.25rem}",
|
|
18157
18157
|
map: undefined,
|
|
18158
18158
|
media: undefined
|
|
@@ -18161,7 +18161,7 @@ const __vue_inject_styles__$h = function (inject) {
|
|
|
18161
18161
|
/* scoped */
|
|
18162
18162
|
|
|
18163
18163
|
|
|
18164
|
-
const __vue_scope_id__$h = "data-v-
|
|
18164
|
+
const __vue_scope_id__$h = "data-v-ce406b84";
|
|
18165
18165
|
/* module identifier */
|
|
18166
18166
|
|
|
18167
18167
|
const __vue_module_identifier__$h = undefined;
|
|
@@ -20785,8 +20785,6 @@ var cloneDeep_1 = cloneDeep;
|
|
|
20785
20785
|
|
|
20786
20786
|
//
|
|
20787
20787
|
const TOP_AFTER_REOPEN = 0;
|
|
20788
|
-
const TOP = 1;
|
|
20789
|
-
const FIXED = 2;
|
|
20790
20788
|
const selectionFeedbackOptions = ["top-after-reopen", "top", "fixed"];
|
|
20791
20789
|
var script$5 = {
|
|
20792
20790
|
name: "NsMultiSelect",
|
|
@@ -20824,13 +20822,13 @@ var script$5 = {
|
|
|
20824
20822
|
default: "Choose"
|
|
20825
20823
|
},
|
|
20826
20824
|
highlight: String,
|
|
20825
|
+
// initial value of the multi-select,
|
|
20826
|
+
// options in the form
|
|
20827
|
+
// [{ label: '', value: '', name: ''}]
|
|
20827
20828
|
value: {
|
|
20828
20829
|
type: Array,
|
|
20829
20830
|
default: () => []
|
|
20830
20831
|
},
|
|
20831
|
-
// initial value of the multi-select,
|
|
20832
|
-
// options in the form
|
|
20833
|
-
// [{ label: '', value: '', name: ''}]
|
|
20834
20832
|
options: {
|
|
20835
20833
|
type: Array,
|
|
20836
20834
|
required: true,
|
|
@@ -20926,7 +20924,7 @@ var script$5 = {
|
|
|
20926
20924
|
data() {
|
|
20927
20925
|
return {
|
|
20928
20926
|
open: false,
|
|
20929
|
-
dataOptions: null,
|
|
20927
|
+
// dataOptions: null, ////
|
|
20930
20928
|
// includes user input items
|
|
20931
20929
|
internalOptions: [],
|
|
20932
20930
|
dataValue: "",
|
|
@@ -20951,17 +20949,15 @@ var script$5 = {
|
|
|
20951
20949
|
if (this.acceptUserInput) {
|
|
20952
20950
|
this.dataValue = this.value;
|
|
20953
20951
|
} else {
|
|
20954
|
-
this.dataValue = this.value.filter(item => this.
|
|
20952
|
+
this.dataValue = this.value.filter(item => this.internalOptions.some(opt => opt.value === item.trim()));
|
|
20955
20953
|
}
|
|
20956
20954
|
},
|
|
20957
20955
|
|
|
20958
20956
|
options() {
|
|
20959
|
-
this.internalOptions = cloneDeep_1(this.options);
|
|
20960
|
-
this.updateOptions();
|
|
20957
|
+
this.internalOptions = cloneDeep_1(this.options); // this.updateOptions(); ////
|
|
20961
20958
|
},
|
|
20962
20959
|
|
|
20963
|
-
selectionFeedback() {
|
|
20964
|
-
this.updateOptions();
|
|
20960
|
+
selectionFeedback() {// this.updateOptions(); ////
|
|
20965
20961
|
},
|
|
20966
20962
|
|
|
20967
20963
|
open() {
|
|
@@ -20981,12 +20977,16 @@ var script$5 = {
|
|
|
20981
20977
|
},
|
|
20982
20978
|
|
|
20983
20979
|
created() {
|
|
20984
|
-
|
|
20985
|
-
|
|
20986
|
-
this.
|
|
20980
|
+
console.log("ns-multi-select created"); ////
|
|
20981
|
+
|
|
20982
|
+
this.internalOptions = cloneDeep_1(this.options); // this.updateOptions(); ////
|
|
20983
|
+
|
|
20984
|
+
this.dataValue = this.value.filter(item => this.internalOptions.some(opt => opt.value === item.trim()));
|
|
20987
20985
|
},
|
|
20988
20986
|
|
|
20989
20987
|
mounted() {
|
|
20988
|
+
console.log("ns-multi-select mounted"); ////
|
|
20989
|
+
|
|
20990
20990
|
this.highlighted = this.value ? this.value : this.highlight; // override highlight with value if provided
|
|
20991
20991
|
|
|
20992
20992
|
this.checkSlots();
|
|
@@ -21003,11 +21003,11 @@ var script$5 = {
|
|
|
21003
21003
|
},
|
|
21004
21004
|
|
|
21005
21005
|
set(val) {
|
|
21006
|
-
let firstMatchIndex = this.
|
|
21006
|
+
let firstMatchIndex = this.internalOptions.findIndex(item => item.value === val);
|
|
21007
21007
|
|
|
21008
21008
|
if (firstMatchIndex < 0) {
|
|
21009
|
-
firstMatchIndex = this.
|
|
21010
|
-
this.dataHighlighted = firstMatchIndex >= 0 ? this.
|
|
21009
|
+
firstMatchIndex = this.internalOptions.length ? 0 : -1;
|
|
21010
|
+
this.dataHighlighted = firstMatchIndex >= 0 ? this.internalOptions[0].value : "";
|
|
21011
21011
|
} else {
|
|
21012
21012
|
this.dataHighlighted = val;
|
|
21013
21013
|
}
|
|
@@ -21042,7 +21042,7 @@ var script$5 = {
|
|
|
21042
21042
|
},
|
|
21043
21043
|
|
|
21044
21044
|
limitedDataOptions() {
|
|
21045
|
-
return this.
|
|
21045
|
+
return this.internalOptions.slice(0, this.maxDisplayOptions);
|
|
21046
21046
|
},
|
|
21047
21047
|
|
|
21048
21048
|
selectedItems() {
|
|
@@ -21051,6 +21051,36 @@ var script$5 = {
|
|
|
21051
21051
|
|
|
21052
21052
|
hasTooltipSlot() {
|
|
21053
21053
|
return !!this.$slots.tooltip;
|
|
21054
|
+
},
|
|
21055
|
+
|
|
21056
|
+
filteredOptions() {
|
|
21057
|
+
//// use this.dataFilter?
|
|
21058
|
+
if (!this.filter) {
|
|
21059
|
+
return this.limitedDataOptions;
|
|
21060
|
+
}
|
|
21061
|
+
|
|
21062
|
+
let results = this.internalOptions.filter(option => {
|
|
21063
|
+
return option.label.trim().toLowerCase().includes(this.filter.trim().toLowerCase());
|
|
21064
|
+
}); // user input
|
|
21065
|
+
|
|
21066
|
+
if (this.acceptUserInput && this.filter.trim()) {
|
|
21067
|
+
// suggest user input if not already present among options
|
|
21068
|
+
const trimmedFilter = this.filter.trim();
|
|
21069
|
+
const optionFound = results.find(option => option.label === trimmedFilter);
|
|
21070
|
+
|
|
21071
|
+
if (!optionFound) {
|
|
21072
|
+
results.push({
|
|
21073
|
+
name: trimmedFilter,
|
|
21074
|
+
label: trimmedFilter,
|
|
21075
|
+
value: trimmedFilter,
|
|
21076
|
+
type: this.userInputLabel
|
|
21077
|
+
});
|
|
21078
|
+
}
|
|
21079
|
+
} // limit results
|
|
21080
|
+
|
|
21081
|
+
|
|
21082
|
+
results = results.slice(0, this.maxDisplayOptions);
|
|
21083
|
+
return results;
|
|
21054
21084
|
}
|
|
21055
21085
|
|
|
21056
21086
|
},
|
|
@@ -21064,8 +21094,7 @@ var script$5 = {
|
|
|
21064
21094
|
clearFilter() {
|
|
21065
21095
|
this.filter = "";
|
|
21066
21096
|
this.$refs.input.focus();
|
|
21067
|
-
this.doOpen(true);
|
|
21068
|
-
this.updateOptions();
|
|
21097
|
+
this.doOpen(true); // this.updateOptions(); ////
|
|
21069
21098
|
},
|
|
21070
21099
|
|
|
21071
21100
|
checkHighlightPosition(newHiglight) {
|
|
@@ -21079,92 +21108,103 @@ var script$5 = {
|
|
|
21079
21108
|
},
|
|
21080
21109
|
|
|
21081
21110
|
doMove(up) {
|
|
21082
|
-
if (this.
|
|
21111
|
+
if (this.internalOptions.length > 0) {
|
|
21083
21112
|
// requery could have changed
|
|
21084
|
-
const currentHighlight = this.
|
|
21113
|
+
const currentHighlight = this.internalOptions.findIndex(item => item.value === this.highlighted);
|
|
21085
21114
|
let newHiglight;
|
|
21086
21115
|
|
|
21087
21116
|
if (up) {
|
|
21088
21117
|
if (currentHighlight <= 0) {
|
|
21089
|
-
newHiglight = this.
|
|
21118
|
+
newHiglight = this.internalOptions.length - 1;
|
|
21090
21119
|
} else {
|
|
21091
21120
|
newHiglight = currentHighlight - 1;
|
|
21092
21121
|
}
|
|
21093
21122
|
} else {
|
|
21094
|
-
if (currentHighlight >= this.
|
|
21123
|
+
if (currentHighlight >= this.internalOptions.length - 1) {
|
|
21095
21124
|
newHiglight = 0;
|
|
21096
21125
|
} else {
|
|
21097
21126
|
newHiglight = currentHighlight + 1;
|
|
21098
21127
|
}
|
|
21099
21128
|
}
|
|
21100
21129
|
|
|
21101
|
-
this.highlighted = this.
|
|
21102
|
-
}
|
|
21103
|
-
},
|
|
21104
|
-
|
|
21105
|
-
updateOptions() {
|
|
21106
|
-
if (this.autoFilter) {
|
|
21107
|
-
const escFilter = this.filter.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21108
|
-
const pat = new RegExp(escFilter, "iu");
|
|
21109
|
-
this.dataOptions = this.internalOptions.filter(opt => pat.test(opt.label)).slice(0);
|
|
21110
|
-
} else {
|
|
21111
|
-
this.dataOptions = this.internalOptions.slice(0);
|
|
21112
|
-
}
|
|
21113
|
-
|
|
21114
|
-
if (this.highlight !== this.highlighted) {
|
|
21115
|
-
this.highlighted = this.highlight;
|
|
21116
|
-
} // multi select unique part
|
|
21117
|
-
|
|
21118
|
-
|
|
21119
|
-
if (!this.sorting && this.selectionFeedback !== selectionFeedbackOptions[FIXED]) {
|
|
21120
|
-
// if included in data value move to top
|
|
21121
|
-
this.dataOptions.sort((a, b) => (this.dataValue.includes(a.value) ? -1 : 1) - (this.dataValue.includes(b.value) ? -1 : 1));
|
|
21122
|
-
} // added for ns-multi-select
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
if (this.acceptUserInput && this.filter.trim()) {
|
|
21126
|
-
// suggest user input
|
|
21127
|
-
const trimmedFilter = this.filter.trim();
|
|
21128
|
-
const itemFound = this.internalOptions.find(o => o.value.trim() === trimmedFilter);
|
|
21129
|
-
|
|
21130
|
-
if (!itemFound) {
|
|
21131
|
-
this.dataOptions.push({
|
|
21132
|
-
name: trimmedFilter,
|
|
21133
|
-
label: trimmedFilter,
|
|
21134
|
-
value: trimmedFilter,
|
|
21135
|
-
type: this.userInputLabel
|
|
21136
|
-
});
|
|
21137
|
-
}
|
|
21130
|
+
this.highlighted = this.internalOptions[newHiglight].value; // this.checkHighlightPosition(newHiglight);
|
|
21138
21131
|
}
|
|
21139
21132
|
},
|
|
21140
21133
|
|
|
21134
|
+
// updateOptions() { ////
|
|
21135
|
+
// console.log("ns-multi-select updateOptions"); ////
|
|
21136
|
+
// if (this.autoFilter) {
|
|
21137
|
+
// const escFilter = this.filter.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21138
|
+
// const pat = new RegExp(escFilter, "iu");
|
|
21139
|
+
// this.dataOptions = this.internalOptions
|
|
21140
|
+
// .filter((opt) => pat.test(opt.label))
|
|
21141
|
+
// .slice(0);
|
|
21142
|
+
// } else {
|
|
21143
|
+
// this.dataOptions = this.internalOptions.slice(0);
|
|
21144
|
+
// }
|
|
21145
|
+
// if (this.highlight !== this.highlighted) {
|
|
21146
|
+
// this.highlighted = this.highlight;
|
|
21147
|
+
// }
|
|
21148
|
+
// // multi select unique part
|
|
21149
|
+
// if (
|
|
21150
|
+
// !this.sorting &&
|
|
21151
|
+
// this.selectionFeedback !== selectionFeedbackOptions[FIXED]
|
|
21152
|
+
// ) {
|
|
21153
|
+
// // if included in data value move to top
|
|
21154
|
+
// this.dataOptions.sort(
|
|
21155
|
+
// (a, b) =>
|
|
21156
|
+
// (this.dataValue.includes(a.value) ? -1 : 1) -
|
|
21157
|
+
// (this.dataValue.includes(b.value) ? -1 : 1)
|
|
21158
|
+
// );
|
|
21159
|
+
// }
|
|
21160
|
+
// // added for ns-multi-select
|
|
21161
|
+
// if (this.acceptUserInput && this.filter.trim()) {
|
|
21162
|
+
// //// remove block?
|
|
21163
|
+
// // suggest user input
|
|
21164
|
+
// const trimmedFilter = this.filter.trim();
|
|
21165
|
+
// const itemFound = this.internalOptions.find(
|
|
21166
|
+
// (o) => o.value.trim() === trimmedFilter
|
|
21167
|
+
// );
|
|
21168
|
+
// if (!itemFound) {
|
|
21169
|
+
// this.dataOptions.push({
|
|
21170
|
+
// name: trimmedFilter,
|
|
21171
|
+
// label: trimmedFilter,
|
|
21172
|
+
// value: trimmedFilter,
|
|
21173
|
+
// type: this.userInputLabel,
|
|
21174
|
+
// });
|
|
21175
|
+
// }
|
|
21176
|
+
// }
|
|
21177
|
+
// },
|
|
21141
21178
|
updateHighlight() {
|
|
21142
21179
|
let firstMatchIndex;
|
|
21143
21180
|
|
|
21144
|
-
if (this.autoHighlight && this.
|
|
21181
|
+
if (this.autoHighlight && this.internalOptions.length > 0) {
|
|
21145
21182
|
// then highlight first match
|
|
21146
21183
|
const filterRegex = new RegExp(this.filter, "iu");
|
|
21147
|
-
firstMatchIndex = this.
|
|
21184
|
+
firstMatchIndex = this.internalOptions.findIndex(item => filterRegex.test(item.label));
|
|
21148
21185
|
|
|
21149
21186
|
if (firstMatchIndex < 0) {
|
|
21150
21187
|
firstMatchIndex = 0;
|
|
21151
21188
|
}
|
|
21152
21189
|
|
|
21153
|
-
this.highlighted = this.
|
|
21190
|
+
this.highlighted = this.internalOptions[firstMatchIndex].value; // this.checkHighlightPosition(firstMatchIndex);
|
|
21154
21191
|
}
|
|
21155
21192
|
},
|
|
21156
21193
|
|
|
21157
21194
|
onInput() {
|
|
21158
|
-
this.doOpen(true);
|
|
21159
|
-
|
|
21195
|
+
this.doOpen(true); // this.updateOptions(); ////
|
|
21196
|
+
|
|
21160
21197
|
this.updateHighlight();
|
|
21161
21198
|
},
|
|
21162
21199
|
|
|
21163
21200
|
doOpen(newVal) {
|
|
21164
|
-
if (
|
|
21165
|
-
|
|
21166
|
-
|
|
21167
|
-
|
|
21201
|
+
// if ( ////
|
|
21202
|
+
// newVal &&
|
|
21203
|
+
// !this.open &&
|
|
21204
|
+
// this.selectionFeedback === selectionFeedbackOptions[TOP_AFTER_REOPEN]
|
|
21205
|
+
// ) {
|
|
21206
|
+
// this.updateOptions();
|
|
21207
|
+
// }
|
|
21168
21208
|
this.open = newVal;
|
|
21169
21209
|
},
|
|
21170
21210
|
|
|
@@ -21200,8 +21240,7 @@ var script$5 = {
|
|
|
21200
21240
|
this.onItemClick(this.highlighted);
|
|
21201
21241
|
this.$refs.input.focus();
|
|
21202
21242
|
this.filter = "";
|
|
21203
|
-
this.doOpen(false);
|
|
21204
|
-
this.updateOptions();
|
|
21243
|
+
this.doOpen(false); // this.updateOptions(); ////
|
|
21205
21244
|
} else {
|
|
21206
21245
|
this.doOpen(true);
|
|
21207
21246
|
}
|
|
@@ -21263,11 +21302,10 @@ var script$5 = {
|
|
|
21263
21302
|
this.clearFilter();
|
|
21264
21303
|
});
|
|
21265
21304
|
}
|
|
21266
|
-
}
|
|
21305
|
+
} // if (this.selectionFeedback === selectionFeedbackOptions[TOP]) {
|
|
21306
|
+
// this.updateOptions(); ////
|
|
21307
|
+
// }
|
|
21267
21308
|
|
|
21268
|
-
if (this.selectionFeedback === selectionFeedbackOptions[TOP]) {
|
|
21269
|
-
this.updateOptions();
|
|
21270
|
-
}
|
|
21271
21309
|
|
|
21272
21310
|
this.$refs.button.focus();
|
|
21273
21311
|
this.$emit("change", this.dataValue);
|
|
@@ -21501,7 +21539,7 @@ var __vue_render__$e = function () {
|
|
|
21501
21539
|
"id": _vm.uid,
|
|
21502
21540
|
"role": "listbox"
|
|
21503
21541
|
}
|
|
21504
|
-
}, _vm._l(_vm.
|
|
21542
|
+
}, _vm._l(_vm.filteredOptions, function (item, index) {
|
|
21505
21543
|
var _obj;
|
|
21506
21544
|
|
|
21507
21545
|
return _c('div', {
|
|
@@ -21580,11 +21618,11 @@ var __vue_staticRenderFns__$e = [];
|
|
|
21580
21618
|
|
|
21581
21619
|
const __vue_inject_styles__$f = function (inject) {
|
|
21582
21620
|
if (!inject) return;
|
|
21583
|
-
inject("data-v-
|
|
21584
|
-
source: ".bx--multi-select--filterable .bx--tag.selected-item[data-v-
|
|
21621
|
+
inject("data-v-3f4d297b_0", {
|
|
21622
|
+
source: ".bx--multi-select--filterable .bx--tag.selected-item[data-v-3f4d297b]{margin-left:0;margin-bottom:.25rem}.margin-bottom-on-open[data-v-3f4d297b]{margin-bottom:14rem}.label-with-tooltip[data-v-3f4d297b]{display:flex;align-items:baseline}",
|
|
21585
21623
|
map: undefined,
|
|
21586
21624
|
media: undefined
|
|
21587
|
-
}), inject("data-v-
|
|
21625
|
+
}), inject("data-v-3f4d297b_1", {
|
|
21588
21626
|
source: ".selected-item button.bx--tag__close-icon{position:relative;right:1px}.ns-multi-select .bx--tooltip__label .bx--tooltip__trigger{margin-left:.25rem}",
|
|
21589
21627
|
map: undefined,
|
|
21590
21628
|
media: undefined
|
|
@@ -21593,7 +21631,7 @@ const __vue_inject_styles__$f = function (inject) {
|
|
|
21593
21631
|
/* scoped */
|
|
21594
21632
|
|
|
21595
21633
|
|
|
21596
|
-
const __vue_scope_id__$f = "data-v-
|
|
21634
|
+
const __vue_scope_id__$f = "data-v-3f4d297b";
|
|
21597
21635
|
/* module identifier */
|
|
21598
21636
|
|
|
21599
21637
|
const __vue_module_identifier__$f = undefined;
|