@websy/websy-designs 1.2.2 → 1.2.3
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/websy-designs-es6.debug.js +32 -11
- package/dist/websy-designs-es6.js +32 -10
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +54 -20
- package/dist/websy-designs.js +53 -18
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -864,6 +864,12 @@ class WebsyDropdown {
|
|
|
864
864
|
closeAfterSelection: true
|
|
865
865
|
}
|
|
866
866
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
867
|
+
if (this.options.items.length > 0) {
|
|
868
|
+
this.options.items = this.options.items.map((d, i) => {
|
|
869
|
+
d.index = i
|
|
870
|
+
return d
|
|
871
|
+
})
|
|
872
|
+
}
|
|
867
873
|
this.tooltipTimeoutFn = null
|
|
868
874
|
this._originalData = []
|
|
869
875
|
this.selectedItems = this.options.selectedItems || []
|
|
@@ -926,7 +932,12 @@ class WebsyDropdown {
|
|
|
926
932
|
this.selectedItems = d || []
|
|
927
933
|
}
|
|
928
934
|
set data (d) {
|
|
929
|
-
this.options.items = d || []
|
|
935
|
+
this.options.items = (d || []).map((d, i) => {
|
|
936
|
+
if (typeof d.index === 'undefined') {
|
|
937
|
+
d.index = i
|
|
938
|
+
}
|
|
939
|
+
return d
|
|
940
|
+
})
|
|
930
941
|
const el = document.getElementById(`${this.elementId}_items`)
|
|
931
942
|
if (el.childElementCount === 0) {
|
|
932
943
|
this.render()
|
|
@@ -1031,6 +1042,10 @@ class WebsyDropdown {
|
|
|
1031
1042
|
if (this.options.onCancelSearch) {
|
|
1032
1043
|
this.options.onCancelSearch(event.target.value)
|
|
1033
1044
|
}
|
|
1045
|
+
else {
|
|
1046
|
+
this.data = this._originalData
|
|
1047
|
+
this._originalData = []
|
|
1048
|
+
}
|
|
1034
1049
|
}
|
|
1035
1050
|
}
|
|
1036
1051
|
}
|
|
@@ -1133,12 +1148,12 @@ class WebsyDropdown {
|
|
|
1133
1148
|
// </div>
|
|
1134
1149
|
// </div>
|
|
1135
1150
|
// `
|
|
1136
|
-
// el.innerHTML = html
|
|
1151
|
+
// el.innerHTML = html
|
|
1137
1152
|
this.renderItems()
|
|
1138
1153
|
}
|
|
1139
1154
|
renderItems () {
|
|
1140
1155
|
let html = this.options.items.map((r, i) => `
|
|
1141
|
-
<li data-index='${
|
|
1156
|
+
<li data-index='${r.index}' class='websy-dropdown-item ${(r.classes || []).join(' ')} ${this.selectedItems.indexOf(r.index) !== -1 ? 'active' : ''}'>${r.label}</li>
|
|
1142
1157
|
`).join('')
|
|
1143
1158
|
const el = document.getElementById(`${this.elementId}_items`)
|
|
1144
1159
|
if (el) {
|
|
@@ -1159,7 +1174,8 @@ class WebsyDropdown {
|
|
|
1159
1174
|
const itemEls = el.querySelectorAll(`.websy-dropdown-item`)
|
|
1160
1175
|
for (let i = 0; i < itemEls.length; i++) {
|
|
1161
1176
|
itemEls[i].classList.remove('active')
|
|
1162
|
-
|
|
1177
|
+
let index = itemEls[i].getAttribute('data-index')
|
|
1178
|
+
if (this.selectedItems.indexOf(+index) !== -1) {
|
|
1163
1179
|
itemEls[i].classList.add('active')
|
|
1164
1180
|
}
|
|
1165
1181
|
}
|
|
@@ -1213,15 +1229,17 @@ class WebsyDropdown {
|
|
|
1213
1229
|
}
|
|
1214
1230
|
updateSelected (index) {
|
|
1215
1231
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1216
|
-
let pos = this.selectedItems.indexOf(index)
|
|
1217
|
-
if (pos !== -1) {
|
|
1218
|
-
this.selectedItems.splice(pos, 1)
|
|
1219
|
-
}
|
|
1232
|
+
let pos = this.selectedItems.indexOf(index)
|
|
1220
1233
|
if (this.options.multiSelect === false) {
|
|
1221
1234
|
this.selectedItems = [index]
|
|
1222
1235
|
}
|
|
1223
1236
|
else {
|
|
1224
|
-
|
|
1237
|
+
if (pos !== -1) {
|
|
1238
|
+
this.selectedItems.splice(pos, 1)
|
|
1239
|
+
}
|
|
1240
|
+
else {
|
|
1241
|
+
this.selectedItems.push(index)
|
|
1242
|
+
}
|
|
1225
1243
|
}
|
|
1226
1244
|
}
|
|
1227
1245
|
const item = this.options.items[index]
|
|
@@ -1684,11 +1702,11 @@ class WebsyNavigationMenu {
|
|
|
1684
1702
|
data-id='${currentBlock}'
|
|
1685
1703
|
data-menu-id='${this.elementId}_${currentBlock}_list'
|
|
1686
1704
|
data-popout-id='${level > 1 ? block : currentBlock}'
|
|
1687
|
-
data-text='${items[i].text}'
|
|
1705
|
+
data-text='${items[i].isLink !== true ? items[i].text : ''}'
|
|
1688
1706
|
style='padding-left: ${level * this.options.childIndentation}px'
|
|
1689
1707
|
${(items[i].attributes && items[i].attributes.join(' ')) || ''}
|
|
1690
1708
|
>
|
|
1691
|
-
`
|
|
1709
|
+
`
|
|
1692
1710
|
if (this.options.orientation === 'horizontal') {
|
|
1693
1711
|
html += items[i].text
|
|
1694
1712
|
}
|
|
@@ -1709,6 +1727,9 @@ class WebsyNavigationMenu {
|
|
|
1709
1727
|
html += `
|
|
1710
1728
|
|
|
1711
1729
|
`
|
|
1730
|
+
}
|
|
1731
|
+
if (items[i].isLink === true && items[i].href) {
|
|
1732
|
+
html += `<a href='${items[i].href}'>${items[i].text}</a>`
|
|
1712
1733
|
}
|
|
1713
1734
|
html += `
|
|
1714
1735
|
</div>
|
|
@@ -1026,6 +1026,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1026
1026
|
closeAfterSelection: true
|
|
1027
1027
|
};
|
|
1028
1028
|
this.options = _extends({}, DEFAULTS, options);
|
|
1029
|
+
|
|
1030
|
+
if (this.options.items.length > 0) {
|
|
1031
|
+
this.options.items = this.options.items.map(function (d, i) {
|
|
1032
|
+
d.index = i;
|
|
1033
|
+
return d;
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1029
1037
|
this.tooltipTimeoutFn = null;
|
|
1030
1038
|
this._originalData = [];
|
|
1031
1039
|
this.selectedItems = this.options.selectedItems || [];
|
|
@@ -1168,6 +1176,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1168
1176
|
} else {
|
|
1169
1177
|
if (this.options.onCancelSearch) {
|
|
1170
1178
|
this.options.onCancelSearch(event.target.value);
|
|
1179
|
+
} else {
|
|
1180
|
+
this.data = this._originalData;
|
|
1181
|
+
this._originalData = [];
|
|
1171
1182
|
}
|
|
1172
1183
|
}
|
|
1173
1184
|
}
|
|
@@ -1293,7 +1304,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1293
1304
|
// </div>
|
|
1294
1305
|
// </div>
|
|
1295
1306
|
// `
|
|
1296
|
-
// el.innerHTML = html
|
|
1307
|
+
// el.innerHTML = html
|
|
1297
1308
|
|
|
1298
1309
|
|
|
1299
1310
|
this.renderItems();
|
|
@@ -1304,7 +1315,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1304
1315
|
var _this7 = this;
|
|
1305
1316
|
|
|
1306
1317
|
var html = this.options.items.map(function (r, i) {
|
|
1307
|
-
return "\n <li data-index='".concat(
|
|
1318
|
+
return "\n <li data-index='".concat(r.index, "' class='websy-dropdown-item ").concat((r.classes || []).join(' '), " ").concat(_this7.selectedItems.indexOf(r.index) !== -1 ? 'active' : '', "'>").concat(r.label, "</li>\n ");
|
|
1308
1319
|
}).join('');
|
|
1309
1320
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1310
1321
|
|
|
@@ -1334,8 +1345,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1334
1345
|
|
|
1335
1346
|
for (var i = 0; i < itemEls.length; i++) {
|
|
1336
1347
|
itemEls[i].classList.remove('active');
|
|
1348
|
+
var index = itemEls[i].getAttribute('data-index');
|
|
1337
1349
|
|
|
1338
|
-
if (this.selectedItems.indexOf(
|
|
1350
|
+
if (this.selectedItems.indexOf(+index) !== -1) {
|
|
1339
1351
|
itemEls[i].classList.add('active');
|
|
1340
1352
|
}
|
|
1341
1353
|
}
|
|
@@ -1399,14 +1411,14 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1399
1411
|
if (typeof index !== 'undefined' && index !== null) {
|
|
1400
1412
|
var pos = this.selectedItems.indexOf(index);
|
|
1401
1413
|
|
|
1402
|
-
if (pos !== -1) {
|
|
1403
|
-
this.selectedItems.splice(pos, 1);
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
1414
|
if (this.options.multiSelect === false) {
|
|
1407
1415
|
this.selectedItems = [index];
|
|
1408
1416
|
} else {
|
|
1409
|
-
|
|
1417
|
+
if (pos !== -1) {
|
|
1418
|
+
this.selectedItems.splice(pos, 1);
|
|
1419
|
+
} else {
|
|
1420
|
+
this.selectedItems.push(index);
|
|
1421
|
+
}
|
|
1410
1422
|
}
|
|
1411
1423
|
}
|
|
1412
1424
|
|
|
@@ -1429,7 +1441,13 @@ var WebsyDropdown = /*#__PURE__*/function () {
|
|
|
1429
1441
|
}, {
|
|
1430
1442
|
key: "data",
|
|
1431
1443
|
set: function set(d) {
|
|
1432
|
-
this.options.items = d || []
|
|
1444
|
+
this.options.items = (d || []).map(function (d, i) {
|
|
1445
|
+
if (typeof d.index === 'undefined') {
|
|
1446
|
+
d.index = i;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
return d;
|
|
1450
|
+
});
|
|
1433
1451
|
var el = document.getElementById("".concat(this.elementId, "_items"));
|
|
1434
1452
|
|
|
1435
1453
|
if (el.childElementCount === 0) {
|
|
@@ -1944,7 +1962,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
1944
1962
|
items[i].classes = items[i].classes.join(' ');
|
|
1945
1963
|
}
|
|
1946
1964
|
|
|
1947
|
-
html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item ").concat(items[i].alwaysOpen === true ? 'always-open' : '', "'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes || '', " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(blockId, "' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.childIndentation, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' ') || '', "\n >\n ");
|
|
1965
|
+
html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item ").concat(items[i].alwaysOpen === true ? 'always-open' : '', "'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes || '', " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(blockId, "' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].isLink !== true ? items[i].text : '', "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.childIndentation, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' ') || '', "\n >\n ");
|
|
1948
1966
|
|
|
1949
1967
|
if (this.options.orientation === 'horizontal') {
|
|
1950
1968
|
html += items[i].text;
|
|
@@ -1964,6 +1982,10 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
|
|
|
1964
1982
|
html += "\n \n ";
|
|
1965
1983
|
}
|
|
1966
1984
|
|
|
1985
|
+
if (items[i].isLink === true && items[i].href) {
|
|
1986
|
+
html += "<a href='".concat(items[i].href, "'>").concat(items[i].text, "</a>");
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1967
1989
|
html += " \n\t\t\t\t</div>\n\t\t ";
|
|
1968
1990
|
|
|
1969
1991
|
if (items[i].items) {
|