@ldmjs/ui 1.0.68 → 1.0.70

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/index.js CHANGED
@@ -4805,11 +4805,11 @@ let SelectListBoxComponent = class SelectListBoxComponent extends (0,external_vu
4805
4805
  onCheckItem(checked, item) {
4806
4806
  if (Array.isArray(this.selected)) {
4807
4807
  const id = this.itemIdentity(item);
4808
- if (this.checkedItems.includes(id)) {
4809
- this.selected = this.selected.filter(el => this.itemIdentity(el) !== id);
4808
+ if (checked.includes(id)) {
4809
+ this.selected.push({ ...item });
4810
4810
  }
4811
4811
  else {
4812
- this.selected.push({ ...item });
4812
+ this.selected = this.selected.filter(el => this.itemIdentity(el) !== id);
4813
4813
  }
4814
4814
  this.onInput();
4815
4815
  }
@@ -6872,6 +6872,39 @@ function ld_dialogvue_type_template_id_7187923d_ts_true_render(_ctx, _cache, $pr
6872
6872
 
6873
6873
  // EXTERNAL MODULE: external "@ldmjs/core"
6874
6874
  var core_ = __webpack_require__(934);
6875
+ ;// ./src/ld-dialog/dialog.listeners.ts
6876
+ class DialogListeners {
6877
+ constructor() {
6878
+ this.listeners = new Map();
6879
+ this.modals = [];
6880
+ }
6881
+ set(modal, handler) {
6882
+ this.modals.push(modal);
6883
+ this.listeners.set(modal, handler);
6884
+ window.addEventListener('keydown', handler);
6885
+ }
6886
+ remove(modal) {
6887
+ const index = this.modals.findIndex(item => item.id === modal.id);
6888
+ if (index > -1) {
6889
+ this.modals.splice(index, 1);
6890
+ }
6891
+ if (this.listeners.has(this.modals[index])) {
6892
+ const handler = this.listeners.get(this.modals[index]);
6893
+ window.removeEventListener('keydown', handler);
6894
+ this.listeners.delete(this.modals[index]);
6895
+ }
6896
+ }
6897
+ isLast(modal) {
6898
+ if (!this.last) {
6899
+ return false;
6900
+ }
6901
+ return modal.id === this.last.id;
6902
+ }
6903
+ get last() {
6904
+ return this.modals[this.modals.length - 1];
6905
+ }
6906
+ }
6907
+
6875
6908
  ;// ./src/utils/awaiting.ts
6876
6909
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
6877
6910
  async function awaiting(callback) {
@@ -7989,14 +8022,15 @@ var ld_dialogvue_type_script_lang_ts_external_metadata = (undefined && undefined
7989
8022
 
7990
8023
 
7991
8024
 
8025
+
7992
8026
  let DialogComponent = class DialogComponent extends (0,external_vue_class_component_.mixins)(ViewportMixin) {
7993
8027
  constructor() {
7994
8028
  super(...arguments);
7995
8029
  this.minimized = [];
7996
8030
  this.dialogManager = new DialogManager();
8031
+ this.dialogListeners = new DialogListeners();
7997
8032
  this.modals = [];
7998
8033
  this.modalResult = null;
7999
- this.listeners = new Map();
8000
8034
  this.resizingModalId = null;
8001
8035
  }
8002
8036
  emitFocus(value) {
@@ -8035,8 +8069,15 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8035
8069
  return;
8036
8070
  }
8037
8071
  }
8072
+ if (!modalInfo.hostObject) {
8073
+ modalInfo.hostObject = {
8074
+ contentType: null,
8075
+ id: this.$utils.uidGen(4, '0-9'),
8076
+ kind: null,
8077
+ };
8078
+ }
8038
8079
  const modal = {
8039
- id: Number(modalInfo.hostObject?.id) || this.$utils.uidGen(4, '0-9'),
8080
+ id: Number(modalInfo.hostObject.id),
8040
8081
  component: modalInfo.component,
8041
8082
  componentProps: modalInfo.componentProps,
8042
8083
  hostObject: modalInfo.hostObject,
@@ -8111,17 +8152,18 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8111
8152
  const el = document.querySelector(`.${this.uniqKey(modal)}`);
8112
8153
  if (el) {
8113
8154
  clearInterval(checkDialogExist);
8114
- this.listenerMap.set(modal, (e) => {
8115
- if (!this.listenerMap.isLast(modal)) {
8155
+ const listenerHandler = (e) => {
8156
+ if (!this.dialogListeners.isLast(modal)) {
8116
8157
  return;
8117
8158
  }
8118
- if (e.key === 'Enter' && this.isConfirmDialog(modal)) {
8159
+ if (e.key === 'Enter') {
8119
8160
  this.handleOk(modal);
8120
8161
  }
8121
- if (e.key === 'Escape' && this.isConfirmDialog(modal)) {
8162
+ if (e.key === 'Escape') {
8122
8163
  this.handleCancel(modal);
8123
8164
  }
8124
- });
8165
+ };
8166
+ this.dialogListeners.set(modal, listenerHandler.bind(this));
8125
8167
  modal.el = el;
8126
8168
  if (this.isConfirmDialog(modal)) {
8127
8169
  const btnOk = modal.el.querySelector('#modalOk');
@@ -8189,6 +8231,13 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8189
8231
  }
8190
8232
  }
8191
8233
  async handleOk(modal, settedResult) {
8234
+ modal = this.findModal(modal.hostObject);
8235
+ if (!modal) {
8236
+ return;
8237
+ }
8238
+ if (modal.okDisabled) {
8239
+ return;
8240
+ }
8192
8241
  let removeModal = true;
8193
8242
  try {
8194
8243
  switch (modal.type) {
@@ -8247,11 +8296,15 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8247
8296
  finally {
8248
8297
  if (removeModal) {
8249
8298
  this.remove(modal);
8250
- this.listenerMap.remove(modal);
8299
+ this.dialogListeners.remove(modal);
8251
8300
  }
8252
8301
  }
8253
8302
  }
8254
8303
  async handleCancel(modal, fromCloseButton = false) {
8304
+ modal = this.findModal(modal.hostObject);
8305
+ if (!modal) {
8306
+ return;
8307
+ }
8255
8308
  try {
8256
8309
  if ([ModalType.CreateEdit, ModalType.Info].includes(modal.type)) {
8257
8310
  if (modal.componentInstance && modal.componentInstance.onClose) {
@@ -8293,7 +8346,7 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8293
8346
  finally {
8294
8347
  if (!modal.show) {
8295
8348
  this.remove(modal);
8296
- this.listenerMap.remove(modal);
8349
+ this.dialogListeners.remove(modal);
8297
8350
  core_.eventBus.$emit('modal-cancel' + this.id);
8298
8351
  }
8299
8352
  }
@@ -8323,6 +8376,7 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8323
8376
  this.modalResult = result;
8324
8377
  if (result) {
8325
8378
  if (modal.selectAsOk || this.isCreateEditDialog(modal)) {
8379
+ modal.okDisabled = false;
8326
8380
  return this.handleOk(modal, result);
8327
8381
  }
8328
8382
  if (Array.isArray(result)) {
@@ -8497,29 +8551,6 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8497
8551
  }
8498
8552
  });
8499
8553
  }
8500
- get listenerMap() {
8501
- let lastId = null;
8502
- function set(modal, handler) {
8503
- handler = handler.bind(this);
8504
- lastId = modal.id;
8505
- this.listeners.set(modal, handler);
8506
- window.addEventListener('keydown', handler);
8507
- }
8508
- function remove(modal) {
8509
- const m = this.modals.find(item => item.id === modal.id);
8510
- const handler = this.listeners.get(m);
8511
- window.removeEventListener('keydown', handler);
8512
- this.listeners.delete(m);
8513
- }
8514
- function isLast(modal) {
8515
- return modal.id === lastId;
8516
- }
8517
- return {
8518
- set: set.bind(this),
8519
- remove: remove.bind(this),
8520
- isLast,
8521
- };
8522
- }
8523
8554
  };
8524
8555
  ld_dialogvue_type_script_lang_ts_external_decorate([
8525
8556
  (0,external_vue_property_decorator_.Prop)({ type: String, default: '' }),
@@ -12262,10 +12293,10 @@ let ld_select_list_boxvue_type_script_lang_ts_external_SelectListBoxComponent =
12262
12293
  if (Array.isArray(this.selected)) {
12263
12294
  const id = this.itemIdentity(item);
12264
12295
  if (checked.includes(id)) {
12265
- this.selected = this.selected.filter(el => this.itemIdentity(el) !== id);
12296
+ this.selected.push({ ...item });
12266
12297
  }
12267
12298
  else {
12268
- this.selected.push({ ...item });
12299
+ this.selected = this.selected.filter(el => this.itemIdentity(el) !== id);
12269
12300
  }
12270
12301
  this.onInput();
12271
12302
  }
@@ -19709,10 +19740,9 @@ let DatepickerComponent = class DatepickerComponent extends (0,external_vue_clas
19709
19740
  if (!this.date && !this.currentMinDate) {
19710
19741
  this.currentMinDate = new Date(newVal);
19711
19742
  }
19712
- if (this.date && datetime.compare(this.date, newVal) > 0) {
19713
- const d = new Date(this.date);
19714
- d.setMonth(d.getMonth() - 1);
19715
- this.currentMinDate = new Date(d);
19743
+ if (this.date &&
19744
+ datetime.compare(new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), 0, 0, 0, 0), new Date(newVal.getFullYear(), newVal.getMonth(), newVal.getDate(), 0, 0, 0, 0)) > -1) {
19745
+ this.currentMinDate = new Date(newVal);
19716
19746
  }
19717
19747
  }
19718
19748
  async onCurrentMinDateChanged(newVal) {
@@ -19729,10 +19759,9 @@ let DatepickerComponent = class DatepickerComponent extends (0,external_vue_clas
19729
19759
  if (!this.date && !this.currentMaxDate) {
19730
19760
  this.currentMaxDate = new Date(newVal);
19731
19761
  }
19732
- if (this.date && datetime.compare(this.date, newVal) < 0) {
19733
- const d = new Date(this.date);
19734
- d.setMonth(d.getMonth() + 1);
19735
- this.currentMaxDate = new Date(d);
19762
+ if (this.date &&
19763
+ datetime.compare(new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), 0, 0, 0, 0), new Date(newVal.getFullYear(), newVal.getMonth(), newVal.getDate(), 0, 0, 0, 0)) < 1) {
19764
+ this.currentMaxDate = new Date(newVal);
19736
19765
  }
19737
19766
  }
19738
19767
  async onCurrentMaxDateChanged(newVal) {
@@ -19777,7 +19806,7 @@ let DatepickerComponent = class DatepickerComponent extends (0,external_vue_clas
19777
19806
  Y: {
19778
19807
  mask: IMask.MaskedRange,
19779
19808
  from: 1900,
19780
- to: 2999,
19809
+ to: 9999,
19781
19810
  },
19782
19811
  },
19783
19812
  format: date => this.formatDate(date),
@@ -1 +1 @@
1
- (function webpackUniversalModuleDefinition(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define(["vue"],t):"object"===typeof exports?exports["ldmui"]=t(require("vue")):e["ldmui"]=t(e["vue"])})(self,(e=>(()=>{"use strict";var t={6262:(e,t)=>{t.A=(e,t)=>{const i=e.__vccOpts||e;for(const[e,s]of t)i[e]=s;return i}},2380:t=>{t.exports=e}},i={};function __webpack_require__(e){var s=i[e];if(void 0!==s)return s.exports;var l=i[e]={exports:{}};return t[e](l,l.exports,__webpack_require__),l.exports}(()=>{__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}})(),(()=>{__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{__webpack_require__.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var s={};__webpack_require__.r(s),__webpack_require__.d(s,{default:()=>N});var l=__webpack_require__(2380);const o=["tabindex","aria-owns"],n={ref:"tags",class:"multiselect__tags"},r={class:"multiselect__tags-wrap"},a=["textContent"],h=["onKeypress","onMousedown"],p={class:"multiselect__tag"},c=["textContent"],u={class:"multiselect__spinner"},d=["name","id","placeholder","value","disabled","tabindex","aria-controls"],m=["id"],g={key:0},f={class:"multiselect__option"},b=["id","role"],y=["onClick","onMouseenter","data-select","data-selected","data-deselect"],w=["data-select","data-deselect","onMouseenter","onMousedown"],V={class:"multiselect__option"},_={class:"multiselect__option"};function render(e,t,i,s,v,S){return(0,l.openBlock)(),(0,l.createElementBlock)("div",{tabindex:e.searchable?-1:i.tabindex,class:(0,l.normalizeClass)([[e.uid?"multiselect"+e.uid:"",{"multiselect--active":e.isOpen,"multiselect--disabled":i.disabled,"multiselect--above":S.isAbove,"multiselect--has-options-group":S.hasOptionGroup,"multiselect--list-empty":e.isOpen&&!S.showNoResultsSlot&&!S.showNoOptionsSlot&&0===e.filteredOptions.length}],"multiselect"]),onFocus:t[12]||(t[12]=t=>e.activate()),onBlur:t[13]||(t[13]=t=>!e.searchable&&e.deactivate()),onKeydown:[t[14]||(t[14]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerForward()),["self","prevent"]),["down"])),t[15]||(t[15]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerBackward()),["self","prevent"]),["up"]))],onKeypress:t[16]||(t[16]=(0,l.withKeys)((0,l.withModifiers)((t=>e.addPointerElement(t)),["stop","self"]),["enter","tab"])),onKeyup:t[17]||(t[17]=(0,l.withKeys)((t=>e.deactivate()),["esc"])),role:"combobox","aria-owns":"listbox-"+e.id},[(0,l.renderSlot)(e.$slots,"caret",{toggle:e.toggle},(()=>[(0,l.createElementVNode)("div",{onMousedown:t[0]||(t[0]=(0,l.withModifiers)((t=>e.toggle()),["prevent","stop"])),class:"multiselect__select"},null,32)])),t[32]||(t[32]=(0,l.createTextVNode)()),(0,l.renderSlot)(e.$slots,"clear",{search:e.search}),t[33]||(t[33]=(0,l.createTextVNode)()),(0,l.createElementVNode)("div",n,[(0,l.renderSlot)(e.$slots,"selection",{search:e.search,remove:e.removeElement,values:S.visibleValues,isOpen:e.isOpen},(()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",r,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(S.visibleValues,((i,s)=>(0,l.renderSlot)(e.$slots,"tag",{option:i,search:e.search,remove:e.removeElement},(()=>[((0,l.openBlock)(),(0,l.createElementBlock)("span",{class:"multiselect__tag",key:s},[(0,l.createElementVNode)("span",{textContent:(0,l.toDisplayString)(e.getOptionLabel(i))},null,8,a),t[18]||(t[18]=(0,l.createTextVNode)()),(0,l.createElementVNode)("i",{tabindex:"1",onKeypress:(0,l.withKeys)((0,l.withModifiers)((t=>e.removeElement(i)),["prevent"]),["enter"]),onMousedown:(0,l.withModifiers)((t=>e.removeElement(i)),["prevent"]),class:"multiselect__tag-icon"},null,40,h)]))])))),256)),t[19]||(t[19]=(0,l.createTextVNode)()),e.internalValue&&e.internalValue.length>i.limit?(0,l.renderSlot)(e.$slots,"tag-overflow",{key:0,limit:i.limit,count:e.internalValue.length},(()=>[(0,l.createElementVNode)("span",p,[(0,l.createElementVNode)("strong",{class:"multiselect__strong",textContent:(0,l.toDisplayString)(i.limitText(e.internalValue.length-i.limit))},null,8,c)])])):(0,l.createCommentVNode)("",!0)],512),[[l.vShow,S.visibleValues.length>0]])])),t[20]||(t[20]=(0,l.createTextVNode)()),(0,l.createVNode)(l.Transition,{name:"multiselect__loading"},{default:(0,l.withCtx)((()=>[(0,l.renderSlot)(e.$slots,"loading",{},(()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",u,null,512),[[l.vShow,i.loading]])]))])),_:3}),t[21]||(t[21]=(0,l.createTextVNode)()),e.searchable?((0,l.openBlock)(),(0,l.createElementBlock)("input",{key:0,ref:"search",name:i.name,id:e.id,type:"text",autocomplete:"off",spellcheck:"false",placeholder:e.placeholder,style:(0,l.normalizeStyle)(S.inputStyle),value:e.search,disabled:i.disabled,tabindex:i.tabindex,class:"multiselect__input","aria-controls":"listbox-"+e.id,onInput:t[1]||(t[1]=t=>e.updateSearch(t.target.value)),onFocus:t[2]||(t[2]=(0,l.withModifiers)((t=>e.activate()),["prevent"])),onKeyup:t[3]||(t[3]=(0,l.withKeys)((t=>e.deactivate()),["esc"])),onKeydown:[t[4]||(t[4]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerForward()),["prevent"]),["down"])),t[5]||(t[5]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerBackward()),["prevent"]),["up"])),t[7]||(t[7]=(0,l.withKeys)((0,l.withModifiers)((t=>e.removeLastElement()),["stop"]),["delete"]))],onKeypress:t[6]||(t[6]=(0,l.withKeys)((0,l.withModifiers)((t=>e.addPointerElement(t)),["prevent","stop","self"]),["enter"]))},null,44,d)):(0,l.createCommentVNode)("",!0),t[22]||(t[22]=(0,l.createTextVNode)()),S.isSingleLabelVisible?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:1,class:"multiselect__single",onMousedown:t[8]||(t[8]=(0,l.withModifiers)(((...t)=>e.toggle&&e.toggle(...t)),["prevent"]))},[(0,l.renderSlot)(e.$slots,"singleLabel",{option:S.singleValue},(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.currentOptionLabel),1)]))],32)):(0,l.createCommentVNode)("",!0),t[23]||(t[23]=(0,l.createTextVNode)()),S.isPlaceholderVisible?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:2,class:"multiselect__placeholder",onMousedown:t[9]||(t[9]=(0,l.withModifiers)(((...t)=>e.toggle&&e.toggle(...t)),["prevent"]))},[(0,l.renderSlot)(e.$slots,"placeholder",{},(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.placeholder),1)]))],32)):(0,l.createCommentVNode)("",!0)],512),t[34]||(t[34]=(0,l.createTextVNode)()),(0,l.createVNode)(l.Transition,{name:"multiselect"},{default:(0,l.withCtx)((()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",{class:"multiselect__content-wrapper",onFocus:t[10]||(t[10]=(...t)=>e.activate&&e.activate(...t)),tabindex:"-1",onMousedown:t[11]||(t[11]=(0,l.withModifiers)((()=>{}),["prevent"])),style:(0,l.normalizeStyle)({maxHeight:e.optimizedHeight+"px"}),ref:"list"},[(0,l.createElementVNode)("ul",{class:"multiselect__content",style:(0,l.normalizeStyle)(S.contentStyle),role:"listbox",id:"listbox-"+e.id},[(0,l.renderSlot)(e.$slots,"beforeList"),t[27]||(t[27]=(0,l.createTextVNode)()),e.multiple&&e.max===e.internalValue.length?((0,l.openBlock)(),(0,l.createElementBlock)("li",g,[(0,l.createElementVNode)("span",f,[(0,l.renderSlot)(e.$slots,"maxElements",{},(()=>[(0,l.createTextVNode)("Maximum of "+(0,l.toDisplayString)(e.max)+" options selected. First remove a selected option to select another.",1)]))])])):(0,l.createCommentVNode)("",!0),t[28]||(t[28]=(0,l.createTextVNode)()),!e.max||e.internalValue.length<e.max?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:1},(0,l.renderList)(e.filteredOptions,((i,s)=>((0,l.openBlock)(),(0,l.createElementBlock)("li",{class:"multiselect__element",key:s,id:e.id+"-"+s,role:i&&(i.$isLabel||i.$isDisabled)?null:"option"},[i&&(i.$isLabel||i.$isDisabled)?(0,l.createCommentVNode)("",!0):((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:0,class:(0,l.normalizeClass)([e.optionHighlight(s,i),"multiselect__option"]),onClick:(0,l.withModifiers)((t=>e.select(i)),["stop"]),onMouseenter:(0,l.withModifiers)((t=>e.pointerSet(s)),["self"]),"data-select":i&&i.isTag?e.tagPlaceholder:S.selectLabelText,"data-selected":S.selectedLabelText,"data-deselect":S.deselectLabelText},[(0,l.renderSlot)(e.$slots,"option",{option:i,search:e.search,index:s},(()=>[(0,l.createElementVNode)("span",null,(0,l.toDisplayString)(e.getOptionLabel(i)),1)]))],42,y)),t[24]||(t[24]=(0,l.createTextVNode)()),i&&(i.$isLabel||i.$isDisabled)?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:1,"data-select":e.groupSelect&&S.selectGroupLabelText,"data-deselect":e.groupSelect&&S.deselectGroupLabelText,class:(0,l.normalizeClass)([e.groupHighlight(s,i),"multiselect__option"]),onMouseenter:(0,l.withModifiers)((t=>e.groupSelect&&e.pointerSet(s)),["self"]),onMousedown:(0,l.withModifiers)((t=>e.selectGroup(i)),["prevent"])},[(0,l.renderSlot)(e.$slots,"option",{option:i,search:e.search,index:s},(()=>[(0,l.createElementVNode)("span",null,(0,l.toDisplayString)(e.getOptionLabel(i)),1)]))],42,w)):(0,l.createCommentVNode)("",!0)],8,b)))),128)):(0,l.createCommentVNode)("",!0),t[29]||(t[29]=(0,l.createTextVNode)()),(0,l.withDirectives)((0,l.createElementVNode)("li",null,[(0,l.createElementVNode)("span",V,[(0,l.renderSlot)(e.$slots,"noResult",{search:e.search},(()=>[t[25]||(t[25]=(0,l.createTextVNode)("No elements found. Consider changing the search query."))]))])],512),[[l.vShow,S.showNoResultsSlot]]),t[30]||(t[30]=(0,l.createTextVNode)()),(0,l.withDirectives)((0,l.createElementVNode)("li",null,[(0,l.createElementVNode)("span",_,[(0,l.renderSlot)(e.$slots,"noOptions",{},(()=>[t[26]||(t[26]=(0,l.createTextVNode)("List is empty."))]))])],512),[[l.vShow,S.showNoOptionsSlot]]),t[31]||(t[31]=(0,l.createTextVNode)()),(0,l.renderSlot)(e.$slots,"afterList")],12,m)],36),[[l.vShow,e.isOpen]])])),_:3})],42,o)}function isEmpty(e){return 0!==e&&(!(!Array.isArray(e)||0!==e.length)||!e)}function not(e){return(...t)=>!e(...t)}function includes(e,t){void 0===e&&(e="undefined"),null===e&&(e="null"),!1===e&&(e="false");const i=e.toString().toLowerCase();return-1!==i.indexOf(t.trim())}function filterOptions(e,t,i,s){return t?e.filter((e=>includes(s(e,i),t))).sort(((e,t)=>s(e,i).length-s(t,i).length)):e}function stripGroups(e){return e.filter((e=>!e.$isLabel))}function flattenOptions(e,t){return i=>i.reduce(((i,s)=>s[e]&&s[e].length?(i.push({$groupLabel:s[t],$isLabel:!0}),i.concat(s[e])):i),[])}function filterGroups(e,t,i,s,l){return o=>o.map((o=>{if(!o[i])return console.warn("Options passed to vue-multiselect do not contain groups, despite the config."),[];const n=filterOptions(o[i],e,t,l);return n.length?{[s]:o[s],[i]:n}:[]}))}const flow=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),v={data(){return{search:"",isOpen:!1,preferredOpenDirection:"below",optimizedHeight:this.maxHeight}},props:{uid:{type:String,default:""},internalSearch:{type:Boolean,default:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},trackBy:{type:String},label:{type:String},searchable:{type:Boolean,default:!0},clearOnSelect:{type:Boolean,default:!0},hideSelected:{type:Boolean,default:!1},placeholder:{type:String,default:"Select option"},allowEmpty:{type:Boolean,default:!0},resetAfter:{type:Boolean,default:!1},closeOnSelect:{type:Boolean,default:!0},customLabel:{type:Function,default(e,t){return isEmpty(e)?"":t?e[t]:e}},taggable:{type:Boolean,default:!1},tagPlaceholder:{type:String,default:"Press enter to create a tag"},tagPosition:{type:String,default:"top"},max:{type:[Number,Boolean],default:!1},id:{default:null},optionsLimit:{type:Number,default:1e3},groupValues:{type:String},groupLabel:{type:String},groupSelect:{type:Boolean,default:!1},blockKeys:{type:Array,default(){return[]}},preserveSearch:{type:Boolean,default:!1},preselectFirst:{type:Boolean,default:!1},preventAutofocus:{type:Boolean,default:!1}},mounted(){!this.multiple&&this.max&&console.warn("[Vue-Multiselect warn]: Max prop should not be used when prop Multiple equals false."),this.preselectFirst&&!this.internalValue.length&&this.options.length&&this.select(this.filteredOptions[0])},computed:{internalValue(){return this.modelValue||0===this.modelValue?Array.isArray(this.modelValue)?this.modelValue:[this.modelValue]:[]},filteredOptions(){const e=this.search||"",t=e.toLowerCase().trim();let i=this.options.concat();return i=this.internalSearch?this.groupValues?this.filterAndFlat(i,t,this.label):filterOptions(i,t,this.label,this.customLabel):this.groupValues?flattenOptions(this.groupValues,this.groupLabel)(i):i,i=this.hideSelected?i.filter(not(this.isSelected)):i,this.taggable&&t.length&&!this.isExistingOption(t)&&("bottom"===this.tagPosition?i.push({isTag:!0,label:e}):i.unshift({isTag:!0,label:e})),i.slice(0,this.optionsLimit)},valueKeys(){return this.trackBy?this.internalValue.map((e=>e[this.trackBy])):this.internalValue},optionKeys(){const e=this.groupValues?this.flatAndStrip(this.options):this.options;return e.map((e=>this.customLabel(e,this.label).toString().toLowerCase()))},currentOptionLabel(){return this.multiple?this.searchable?"":this.placeholder:this.internalValue.length?this.getOptionLabel(this.internalValue[0]):this.searchable?"":this.placeholder}},watch:{internalValue:{handler(){this.resetAfter&&this.internalValue.length&&(this.search="",this.$emit("update:modelValue",this.multiple?[]:null))},deep:!0},search(){this.$emit("search-change",this.search)}},emits:["open","search-change","close","select","update:modelValue","remove","tag"],methods:{getValue(){return this.multiple?this.internalValue:0===this.internalValue.length?null:this.internalValue[0]},filterAndFlat(e,t,i){return flow(filterGroups(t,i,this.groupValues,this.groupLabel,this.customLabel),flattenOptions(this.groupValues,this.groupLabel))(e)},flatAndStrip(e){return flow(flattenOptions(this.groupValues,this.groupLabel),stripGroups)(e)},updateSearch(e){this.search=e},isExistingOption(e){return!!this.options&&this.optionKeys.indexOf(e)>-1},isSelected(e){const t=this.trackBy?e[this.trackBy]:e;return this.valueKeys.indexOf(t)>-1},isOptionDisabled(e){return!!e.$isDisabled},getOptionLabel(e){if(isEmpty(e))return"";if(e.isTag)return e.label;if(e.$isLabel)return e.$groupLabel;const t=this.customLabel(e,this.label);return isEmpty(t)?"":t},select(e,t){e.$isLabel&&this.groupSelect?this.selectGroup(e):-1!==this.blockKeys.indexOf(t)||this.disabled||e.$isDisabled||e.$isLabel||this.max&&this.multiple&&this.internalValue.length===this.max||("Tab"!==t||this.pointerDirty)&&(e.isTag?(this.$emit("tag",e.label,this.id),this.search="",this.closeOnSelect&&!this.multiple&&this.deactivate()):(this.multiple?this.$emit("update:modelValue",this.internalValue.concat([e])):this.$emit("update:modelValue",e),this.$emit("select",e,this.id),this.clearOnSelect&&(this.search="")),this.closeOnSelect&&this.deactivate())},selectGroup(e){const t=this.options.find((t=>t[this.groupLabel]===e.$groupLabel));if(t){if(this.wholeGroupSelected(t)){this.$emit("remove",t[this.groupValues],this.id);const e=this.internalValue.filter((e=>-1===t[this.groupValues].indexOf(e)));this.$emit("update:modelValue",e)}else{let e=t[this.groupValues].filter((e=>!(this.isOptionDisabled(e)||this.isSelected(e))));this.max&&e.splice(this.max-this.internalValue.length),this.$emit("select",e,this.id),this.$emit("update:modelValue",this.internalValue.concat(e))}this.closeOnSelect&&this.deactivate()}},wholeGroupSelected(e){return e[this.groupValues].every((e=>this.isSelected(e)||this.isOptionDisabled(e)))},wholeGroupDisabled(e){return e[this.groupValues].every(this.isOptionDisabled)},removeElement(e,t=!0){if(this.disabled)return;if(e.$isDisabled)return;if(!this.allowEmpty&&this.internalValue.length<=1)return void this.deactivate();const i="object"===typeof e?this.valueKeys.indexOf(e[this.trackBy]):this.valueKeys.indexOf(e);if(this.multiple){const e=this.internalValue.slice(0,i).concat(this.internalValue.slice(i+1));this.$emit("update:modelValue",e)}else this.$emit("update:modelValue",null);this.$emit("remove",e,this.id),this.closeOnSelect&&t&&this.deactivate()},removeLastElement(){-1===this.blockKeys.indexOf("Delete")&&0===this.search.length&&Array.isArray(this.internalValue)&&this.internalValue.length&&this.removeElement(this.internalValue[this.internalValue.length-1],!1)},activate(){if(this.isOpen||this.disabled)return;this.adjustPosition(),this.groupValues&&0===this.pointer&&this.filteredOptions.length&&(this.pointer=1),this.isOpen=!0,this.searchable?(this.preserveSearch||(this.search=""),this.preventAutofocus||this.$nextTick((()=>this.$refs.search&&this.$refs.search.focus()))):this.preventAutofocus||"undefined"!==typeof this.$el&&this.$el.focus(),this.$emit("open",this.id);const onMouseDown=e=>{if(e?.target){const t=this.uid?"multiselect"+this.uid:"multiselect",i=e.target.closest("."+t);Boolean(i)||(this.deactivate(),document.removeEventListener("mousedown",onMouseDown))}};setTimeout((()=>{document.addEventListener("mousedown",onMouseDown)}),300)},deactivate(){this.isOpen&&(this.isOpen=!1,this.searchable?this.$refs.search&&this.$refs.search.blur():this.$el&&this.$el.blur(),this.preserveSearch||(this.search=""),this.$emit("close",this.getValue(),this.id))},toggle(){this.isOpen?this.deactivate():this.activate()},adjustPosition(){if("undefined"===typeof window)return;const e=this.$el.getBoundingClientRect().top,t=window.innerHeight-this.$el.getBoundingClientRect().bottom,i=t>this.maxHeight;i||t>e||"below"===this.openDirection||"bottom"===this.openDirection?(this.preferredOpenDirection="below",this.optimizedHeight=Math.min(t-40,this.maxHeight)):(this.preferredOpenDirection="above",this.optimizedHeight=Math.min(e-40,this.maxHeight))}}},S={data(){return{pointer:0,pointerDirty:!1}},props:{showPointer:{type:Boolean,default:!0},optionHeight:{type:Number,default:40}},computed:{pointerPosition(){return this.pointer*this.optionHeight},visibleElements(){return this.optimizedHeight/this.optionHeight}},watch:{filteredOptions(){this.pointerAdjust()},isOpen(){this.pointerDirty=!1},pointer(){this.$refs.search&&this.$refs.search.setAttribute("aria-activedescendant",this.id+"-"+this.pointer.toString())}},methods:{optionHighlight(e,t){return{"multiselect__option--highlight":e===this.pointer&&this.showPointer,"multiselect__option--selected":this.isSelected(t)}},groupHighlight(e,t){if(!this.groupSelect)return["multiselect__option--disabled",{"multiselect__option--group":t.$isLabel}];const i=this.options.find((e=>e[this.groupLabel]===t.$groupLabel));return i&&!this.wholeGroupDisabled(i)?["multiselect__option--group",{"multiselect__option--highlight":e===this.pointer&&this.showPointer},{"multiselect__option--group-selected":this.wholeGroupSelected(i)}]:"multiselect__option--disabled"},addPointerElement({key:e}="Enter"){this.filteredOptions.length>0&&this.select(this.filteredOptions[this.pointer],e),this.pointerReset()},pointerForward(){this.pointer<this.filteredOptions.length-1&&(this.pointer++,this.$refs.list.scrollTop<=this.pointerPosition-(this.visibleElements-1)*this.optionHeight&&(this.$refs.list.scrollTop=this.pointerPosition-(this.visibleElements-1)*this.optionHeight),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()),this.pointerDirty=!0},pointerBackward(){this.pointer>0?(this.pointer--,this.$refs.list.scrollTop>=this.pointerPosition&&(this.$refs.list.scrollTop=this.pointerPosition),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerBackward()):this.filteredOptions[this.pointer]&&this.filteredOptions[0].$isLabel&&!this.groupSelect&&this.pointerForward(),this.pointerDirty=!0},pointerReset(){this.closeOnSelect&&(this.pointer=0,this.$refs.list&&(this.$refs.list.scrollTop=0))},pointerAdjust(){this.pointer>=this.filteredOptions.length-1&&(this.pointer=this.filteredOptions.length?this.filteredOptions.length-1:0),this.filteredOptions.length>0&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()},pointerSet(e){this.pointer=e,this.pointerDirty=!0}}},x={name:"vue-multiselect",mixins:[v,S],compatConfig:{MODE:3,ATTR_ENUMERATED_COERCION:!1},props:{name:{type:String,default:""},modelValue:{type:null,default(){return[]}},selectLabel:{type:String,default:"Press enter to select"},selectGroupLabel:{type:String,default:"Press enter to select group"},selectedLabel:{type:String,default:"Selected"},deselectLabel:{type:String,default:"Press enter to remove"},deselectGroupLabel:{type:String,default:"Press enter to deselect group"},showLabels:{type:Boolean,default:!0},limit:{type:Number,default:99999},maxHeight:{type:Number,default:300},limitText:{type:Function,default:e=>`and ${e} more`},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},openDirection:{type:String,default:""},showNoOptions:{type:Boolean,default:!0},showNoResults:{type:Boolean,default:!0},tabindex:{type:Number,default:0}},computed:{hasOptionGroup(){return this.groupValues&&this.groupLabel&&this.groupSelect},isSingleLabelVisible(){return!1},isPlaceholderVisible(){return!this.internalValue.length&&(!this.searchable||!this.isOpen)},visibleValues(){return this.internalValue.slice(0,this.limit)},singleValue(){return this.internalValue[0]},deselectLabelText(){return this.showLabels?this.deselectLabel:""},deselectGroupLabelText(){return this.showLabels?this.deselectGroupLabel:""},selectLabelText(){return this.showLabels?this.selectLabel:""},selectGroupLabelText(){return this.showLabels?this.selectGroupLabel:""},selectedLabelText(){return this.showLabels?this.selectedLabel:""},inputStyle(){return this.searchable||this.multiple&&this.modelValue&&this.modelValue.length?this.isOpen?{width:"100%"}:{width:"0",position:"absolute",padding:"0"}:""},contentStyle(){return this.options.length?{display:"inline-block"}:{display:"block"}},isAbove(){return"above"===this.openDirection||"top"===this.openDirection||"below"!==this.openDirection&&"bottom"!==this.openDirection&&"above"===this.preferredOpenDirection},showSearchInput(){return this.searchable&&(!this.hasSingleSelectedSlot||!this.visibleSingleValue&&0!==this.visibleSingleValue||this.isOpen)},showNoResultsSlot(){return this.showNoResults&&0===this.filteredOptions.length&&this.search&&!this.loading},showNoOptionsSlot(){return this.showNoOptions&&(0===this.options.length||!0===this.hasOptionGroup&&0===this.filteredOptions.length)&&!this.search&&!this.loading}}};var O=__webpack_require__(6262);const L=(0,O.A)(x,[["render",render]]),$=L,N=$;return s})()));
1
+ (function webpackUniversalModuleDefinition(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define(["vue"],t):"object"===typeof exports?exports["ldmui"]=t(require("vue")):e["ldmui"]=t(e["vue"])})(self,(e=>(()=>{"use strict";var t={6262:(e,t)=>{t.A=(e,t)=>{const i=e.__vccOpts||e;for(const[e,s]of t)i[e]=s;return i}},2380:t=>{t.exports=e}},i={};function __webpack_require__(e){var s=i[e];if(void 0!==s)return s.exports;var l=i[e]={exports:{}};return t[e](l,l.exports,__webpack_require__),l.exports}(()=>{__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}})(),(()=>{__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{__webpack_require__.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var s={};__webpack_require__.r(s),__webpack_require__.d(s,{default:()=>N});var l=__webpack_require__(2380);const o=["tabindex","aria-owns"],n={ref:"tags",class:"multiselect__tags"},r={class:"multiselect__tags-wrap"},a=["textContent"],h=["onKeypress","onMousedown"],p={class:"multiselect__tag"},c=["textContent"],u={class:"multiselect__spinner"},d=["name","id","placeholder","value","disabled","tabindex","aria-controls"],m=["id"],g={key:0},f={class:"multiselect__option"},b=["id","role"],y=["onClick","onMouseenter","data-select","data-selected","data-deselect"],w=["data-select","data-deselect","onMouseenter","onMousedown"],V={class:"multiselect__option"},v={class:"multiselect__option"};function render(e,t,i,s,_,S){return(0,l.openBlock)(),(0,l.createElementBlock)("div",{tabindex:e.searchable?-1:i.tabindex,class:(0,l.normalizeClass)([[e.uid?"multiselect"+e.uid:"",{"multiselect--active":e.isOpen,"multiselect--disabled":i.disabled,"multiselect--above":S.isAbove,"multiselect--has-options-group":S.hasOptionGroup,"multiselect--list-empty":e.isOpen&&!S.showNoResultsSlot&&!S.showNoOptionsSlot&&0===e.filteredOptions.length}],"multiselect"]),onFocus:t[12]||(t[12]=t=>e.activate()),onBlur:t[13]||(t[13]=t=>!e.searchable&&e.deactivate()),onKeydown:[t[14]||(t[14]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerForward()),["self","prevent"]),["down"])),t[15]||(t[15]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerBackward()),["self","prevent"]),["up"]))],onKeypress:t[16]||(t[16]=(0,l.withKeys)((0,l.withModifiers)((t=>e.addPointerElement(t)),["stop","self"]),["enter","tab"])),onKeyup:t[17]||(t[17]=(0,l.withKeys)((t=>e.deactivate()),["esc"])),role:"combobox","aria-owns":"listbox-"+e.id},[(0,l.renderSlot)(e.$slots,"caret",{toggle:e.toggle},(()=>[(0,l.createElementVNode)("div",{onMousedown:t[0]||(t[0]=(0,l.withModifiers)((t=>e.toggle()),["prevent","stop"])),class:"multiselect__select"},null,32)])),t[32]||(t[32]=(0,l.createTextVNode)()),(0,l.renderSlot)(e.$slots,"clear",{search:e.search}),t[33]||(t[33]=(0,l.createTextVNode)()),(0,l.createElementVNode)("div",n,[(0,l.renderSlot)(e.$slots,"selection",{search:e.search,remove:e.removeElement,values:S.visibleValues,isOpen:e.isOpen},(()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",r,[((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,null,(0,l.renderList)(S.visibleValues,((i,s)=>(0,l.renderSlot)(e.$slots,"tag",{option:i,search:e.search,remove:e.removeElement},(()=>[((0,l.openBlock)(),(0,l.createElementBlock)("span",{class:"multiselect__tag",key:s},[(0,l.createElementVNode)("span",{textContent:(0,l.toDisplayString)(e.getOptionLabel(i))},null,8,a),t[18]||(t[18]=(0,l.createTextVNode)()),(0,l.createElementVNode)("i",{tabindex:"1",onKeypress:(0,l.withKeys)((0,l.withModifiers)((t=>e.removeElement(i)),["prevent"]),["enter"]),onMousedown:(0,l.withModifiers)((t=>e.removeElement(i)),["prevent"]),class:"multiselect__tag-icon"},null,40,h)]))])))),256)),t[19]||(t[19]=(0,l.createTextVNode)()),e.internalValue&&e.internalValue.length>i.limit?(0,l.renderSlot)(e.$slots,"tag-overflow",{key:0,limit:i.limit,count:e.internalValue.length},(()=>[(0,l.createElementVNode)("span",p,[(0,l.createElementVNode)("strong",{class:"multiselect__strong",textContent:(0,l.toDisplayString)(i.limitText(e.internalValue.length-i.limit))},null,8,c)])])):(0,l.createCommentVNode)("",!0)],512),[[l.vShow,S.visibleValues.length>0]])])),t[20]||(t[20]=(0,l.createTextVNode)()),(0,l.createVNode)(l.Transition,{name:"multiselect__loading"},{default:(0,l.withCtx)((()=>[(0,l.renderSlot)(e.$slots,"loading",{},(()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",u,null,512),[[l.vShow,i.loading]])]))])),_:3}),t[21]||(t[21]=(0,l.createTextVNode)()),e.searchable?((0,l.openBlock)(),(0,l.createElementBlock)("input",{key:0,ref:"search",name:i.name,id:e.id,type:"text",autocomplete:"off",spellcheck:"false",placeholder:e.placeholder,style:(0,l.normalizeStyle)(S.inputStyle),value:e.search,disabled:i.disabled,tabindex:i.tabindex,class:"multiselect__input","aria-controls":"listbox-"+e.id,onInput:t[1]||(t[1]=t=>e.updateSearch(t.target.value)),onFocus:t[2]||(t[2]=(0,l.withModifiers)((t=>e.activate()),["prevent"])),onKeyup:t[3]||(t[3]=(0,l.withKeys)((t=>e.deactivate()),["esc"])),onKeydown:[t[4]||(t[4]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerForward()),["prevent"]),["down"])),t[5]||(t[5]=(0,l.withKeys)((0,l.withModifiers)((t=>e.pointerBackward()),["prevent"]),["up"])),t[7]||(t[7]=(0,l.withKeys)((0,l.withModifiers)((t=>e.removeLastElement()),["stop"]),["delete"]))],onKeypress:t[6]||(t[6]=(0,l.withKeys)((0,l.withModifiers)((t=>e.addPointerElement(t)),["prevent","stop","self"]),["enter"]))},null,44,d)):(0,l.createCommentVNode)("",!0),t[22]||(t[22]=(0,l.createTextVNode)()),S.isSingleLabelVisible?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:1,class:"multiselect__single",onMousedown:t[8]||(t[8]=(0,l.withModifiers)(((...t)=>e.toggle&&e.toggle(...t)),["prevent"]))},[(0,l.renderSlot)(e.$slots,"singleLabel",{option:S.singleValue},(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.currentOptionLabel),1)]))],32)):(0,l.createCommentVNode)("",!0),t[23]||(t[23]=(0,l.createTextVNode)()),S.isPlaceholderVisible?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:2,class:"multiselect__placeholder",onMousedown:t[9]||(t[9]=(0,l.withModifiers)(((...t)=>e.toggle&&e.toggle(...t)),["prevent"]))},[(0,l.renderSlot)(e.$slots,"placeholder",{},(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(e.placeholder),1)]))],32)):(0,l.createCommentVNode)("",!0)],512),t[34]||(t[34]=(0,l.createTextVNode)()),(0,l.createVNode)(l.Transition,{name:"multiselect"},{default:(0,l.withCtx)((()=>[(0,l.withDirectives)((0,l.createElementVNode)("div",{class:"multiselect__content-wrapper",onFocus:t[10]||(t[10]=(...t)=>e.activate&&e.activate(...t)),tabindex:"-1",onMousedown:t[11]||(t[11]=(0,l.withModifiers)((()=>{}),["prevent"])),style:(0,l.normalizeStyle)({maxHeight:e.optimizedHeight+"px"}),ref:"list"},[(0,l.createElementVNode)("ul",{class:"multiselect__content",style:(0,l.normalizeStyle)(S.contentStyle),role:"listbox",id:"listbox-"+e.id},[(0,l.renderSlot)(e.$slots,"beforeList"),t[27]||(t[27]=(0,l.createTextVNode)()),e.multiple&&e.max===e.internalValue.length?((0,l.openBlock)(),(0,l.createElementBlock)("li",g,[(0,l.createElementVNode)("span",f,[(0,l.renderSlot)(e.$slots,"maxElements",{},(()=>[(0,l.createTextVNode)("Maximum of "+(0,l.toDisplayString)(e.max)+" options selected. First remove a selected option to select another.",1)]))])])):(0,l.createCommentVNode)("",!0),t[28]||(t[28]=(0,l.createTextVNode)()),!e.max||e.internalValue.length<e.max?((0,l.openBlock)(!0),(0,l.createElementBlock)(l.Fragment,{key:1},(0,l.renderList)(e.filteredOptions,((i,s)=>((0,l.openBlock)(),(0,l.createElementBlock)("li",{class:"multiselect__element",key:s,id:e.id+"-"+s,role:i&&(i.$isLabel||i.$isDisabled)?null:"option"},[i&&(i.$isLabel||i.$isDisabled)?(0,l.createCommentVNode)("",!0):((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:0,class:(0,l.normalizeClass)([e.optionHighlight(s,i),"multiselect__option"]),onClick:(0,l.withModifiers)((t=>e.select(i)),["stop"]),onMouseenter:(0,l.withModifiers)((t=>e.pointerSet(s)),["self"]),"data-select":i&&i.isTag?e.tagPlaceholder:S.selectLabelText,"data-selected":S.selectedLabelText,"data-deselect":S.deselectLabelText},[(0,l.renderSlot)(e.$slots,"option",{option:i,search:e.search,index:s},(()=>[(0,l.createElementVNode)("span",null,(0,l.toDisplayString)(e.getOptionLabel(i)),1)]))],42,y)),t[24]||(t[24]=(0,l.createTextVNode)()),i&&(i.$isLabel||i.$isDisabled)?((0,l.openBlock)(),(0,l.createElementBlock)("span",{key:1,"data-select":e.groupSelect&&S.selectGroupLabelText,"data-deselect":e.groupSelect&&S.deselectGroupLabelText,class:(0,l.normalizeClass)([e.groupHighlight(s,i),"multiselect__option"]),onMouseenter:(0,l.withModifiers)((t=>e.groupSelect&&e.pointerSet(s)),["self"]),onMousedown:(0,l.withModifiers)((t=>e.selectGroup(i)),["prevent"])},[(0,l.renderSlot)(e.$slots,"option",{option:i,search:e.search,index:s},(()=>[(0,l.createElementVNode)("span",null,(0,l.toDisplayString)(e.getOptionLabel(i)),1)]))],42,w)):(0,l.createCommentVNode)("",!0)],8,b)))),128)):(0,l.createCommentVNode)("",!0),t[29]||(t[29]=(0,l.createTextVNode)()),(0,l.withDirectives)((0,l.createElementVNode)("li",null,[(0,l.createElementVNode)("span",V,[(0,l.renderSlot)(e.$slots,"noResult",{search:e.search},(()=>[t[25]||(t[25]=(0,l.createTextVNode)("No elements found. Consider changing the search query."))]))])],512),[[l.vShow,S.showNoResultsSlot]]),t[30]||(t[30]=(0,l.createTextVNode)()),(0,l.withDirectives)((0,l.createElementVNode)("li",null,[(0,l.createElementVNode)("span",v,[(0,l.renderSlot)(e.$slots,"noOptions",{},(()=>[t[26]||(t[26]=(0,l.createTextVNode)("List is empty."))]))])],512),[[l.vShow,S.showNoOptionsSlot]]),t[31]||(t[31]=(0,l.createTextVNode)()),(0,l.renderSlot)(e.$slots,"afterList")],12,m)],36),[[l.vShow,e.isOpen]])])),_:3})],42,o)}function isEmpty(e){return 0!==e&&(!(!Array.isArray(e)||0!==e.length)||!e)}function not(e){return(...t)=>!e(...t)}function includes(e,t){void 0===e&&(e="undefined"),null===e&&(e="null"),!1===e&&(e="false");const i=e.toString().toLowerCase();return-1!==i.indexOf(t.trim())}function filterOptions(e,t,i,s){return t?e.filter((e=>includes(s(e,i),t))).sort(((e,t)=>s(e,i).length-s(t,i).length)):e}function stripGroups(e){return e.filter((e=>!e.$isLabel))}function flattenOptions(e,t){return i=>i.reduce(((i,s)=>s[e]&&s[e].length?(i.push({$groupLabel:s[t],$isLabel:!0}),i.concat(s[e])):i),[])}function filterGroups(e,t,i,s,l){return o=>o.map((o=>{if(!o[i])return console.warn("Options passed to vue-multiselect do not contain groups, despite the config."),[];const n=filterOptions(o[i],e,t,l);return n.length?{[s]:o[s],[i]:n}:[]}))}const flow=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),_={data(){return{search:"",isOpen:!1,preferredOpenDirection:"below",optimizedHeight:this.maxHeight}},props:{uid:{type:String,default:""},internalSearch:{type:Boolean,default:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},trackBy:{type:String},label:{type:String},searchable:{type:Boolean,default:!0},clearOnSelect:{type:Boolean,default:!0},hideSelected:{type:Boolean,default:!1},placeholder:{type:String,default:"Select option"},allowEmpty:{type:Boolean,default:!0},resetAfter:{type:Boolean,default:!1},closeOnSelect:{type:Boolean,default:!0},customLabel:{type:Function,default(e,t){return isEmpty(e)?"":t?e[t]:e}},taggable:{type:Boolean,default:!1},tagPlaceholder:{type:String,default:"Press enter to create a tag"},tagPosition:{type:String,default:"top"},max:{type:[Number,Boolean],default:!1},id:{default:null},optionsLimit:{type:Number,default:1e3},groupValues:{type:String},groupLabel:{type:String},groupSelect:{type:Boolean,default:!1},blockKeys:{type:Array,default(){return[]}},preserveSearch:{type:Boolean,default:!1},preselectFirst:{type:Boolean,default:!1},preventAutofocus:{type:Boolean,default:!1}},mounted(){!this.multiple&&this.max&&console.warn("[Vue-Multiselect warn]: Max prop should not be used when prop Multiple equals false."),this.preselectFirst&&!this.internalValue.length&&this.options.length&&this.select(this.filteredOptions[0])},computed:{internalValue(){return this.modelValue||0===this.modelValue?Array.isArray(this.modelValue)?this.modelValue:[this.modelValue]:[]},filteredOptions(){const e=this.search||"",t=e.toLowerCase().trim();let i=this.options.concat();return i=this.internalSearch?this.groupValues?this.filterAndFlat(i,t,this.label):filterOptions(i,t,this.label,this.customLabel):this.groupValues?flattenOptions(this.groupValues,this.groupLabel)(i):i,i=this.hideSelected?i.filter(not(this.isSelected)):i,this.taggable&&t.length&&!this.isExistingOption(t)&&("bottom"===this.tagPosition?i.push({isTag:!0,label:e}):i.unshift({isTag:!0,label:e})),i.slice(0,this.optionsLimit)},valueKeys(){return this.trackBy?this.internalValue.map((e=>e[this.trackBy])):this.internalValue},optionKeys(){const e=this.groupValues?this.flatAndStrip(this.options):this.options;return e.map((e=>this.customLabel(e,this.label).toString().toLowerCase()))},currentOptionLabel(){return this.multiple?this.searchable?"":this.placeholder:this.internalValue.length?this.getOptionLabel(this.internalValue[0]):this.searchable?"":this.placeholder}},watch:{internalValue:{handler(){this.resetAfter&&this.internalValue.length&&(this.search="",this.$emit("update:modelValue",this.multiple?[]:null))},deep:!0},search(){this.$emit("search-change",this.search)}},emits:["open","search-change","close","select","update:modelValue","remove","tag"],methods:{getValue(){return this.multiple?this.internalValue:0===this.internalValue.length?null:this.internalValue[0]},filterAndFlat(e,t,i){return flow(filterGroups(t,i,this.groupValues,this.groupLabel,this.customLabel),flattenOptions(this.groupValues,this.groupLabel))(e)},flatAndStrip(e){return flow(flattenOptions(this.groupValues,this.groupLabel),stripGroups)(e)},updateSearch(e){this.search=e},isExistingOption(e){return!!this.options&&this.optionKeys.indexOf(e)>-1},isSelected(e){const t=this.trackBy?e[this.trackBy]:e;return this.valueKeys.indexOf(t)>-1},isOptionDisabled(e){return!!e.$isDisabled},getOptionLabel(e){if(isEmpty(e))return"";if(e.isTag)return e.label;if(e.$isLabel)return e.$groupLabel;const t=this.customLabel(e,this.label);return isEmpty(t)?"":t},select(e,t){if(e.$isLabel&&this.groupSelect)this.selectGroup(e);else if(!(-1!==this.blockKeys.indexOf(t)||this.disabled||e.$isDisabled||e.$isLabel)&&(!this.max||!this.multiple||this.internalValue.length!==this.max)&&("Tab"!==t||this.pointerDirty)){if(e.isTag)this.$emit("tag",e.label,this.id),this.search="",this.closeOnSelect&&!this.multiple&&this.deactivate();else{const i=this.isSelected(e);if(i)return void("Tab"!==t&&this.removeElement(e));this.multiple?this.$emit("update:modelValue",this.internalValue.concat([e])):this.$emit("update:modelValue",e),this.$emit("select",e,this.id),this.clearOnSelect&&(this.search="")}this.closeOnSelect&&this.deactivate()}},selectGroup(e){const t=this.options.find((t=>t[this.groupLabel]===e.$groupLabel));if(t){if(this.wholeGroupSelected(t)){this.$emit("remove",t[this.groupValues],this.id);const e=this.internalValue.filter((e=>-1===t[this.groupValues].indexOf(e)));this.$emit("update:modelValue",e)}else{let e=t[this.groupValues].filter((e=>!(this.isOptionDisabled(e)||this.isSelected(e))));this.max&&e.splice(this.max-this.internalValue.length),this.$emit("select",e,this.id),this.$emit("update:modelValue",this.internalValue.concat(e))}this.closeOnSelect&&this.deactivate()}},wholeGroupSelected(e){return e[this.groupValues].every((e=>this.isSelected(e)||this.isOptionDisabled(e)))},wholeGroupDisabled(e){return e[this.groupValues].every(this.isOptionDisabled)},removeElement(e,t=!0){if(this.disabled)return;if(e.$isDisabled)return;if(!this.allowEmpty&&this.internalValue.length<=1)return void this.deactivate();const i="object"===typeof e?this.valueKeys.indexOf(e[this.trackBy]):this.valueKeys.indexOf(e);if(this.multiple){const e=this.internalValue.slice(0,i).concat(this.internalValue.slice(i+1));this.$emit("update:modelValue",e)}else this.$emit("update:modelValue",null);this.$emit("remove",e,this.id),this.closeOnSelect&&t&&this.deactivate()},removeLastElement(){-1===this.blockKeys.indexOf("Delete")&&0===this.search.length&&Array.isArray(this.internalValue)&&this.internalValue.length&&this.removeElement(this.internalValue[this.internalValue.length-1],!1)},activate(){if(this.isOpen||this.disabled)return;this.adjustPosition(),this.groupValues&&0===this.pointer&&this.filteredOptions.length&&(this.pointer=1),this.isOpen=!0,this.searchable?(this.preserveSearch||(this.search=""),this.preventAutofocus||this.$nextTick((()=>this.$refs.search&&this.$refs.search.focus()))):this.preventAutofocus||"undefined"!==typeof this.$el&&this.$el.focus(),this.$emit("open",this.id);const onMouseDown=e=>{if(e?.target){const t=this.uid?"multiselect"+this.uid:"multiselect",i=e.target.closest("."+t);Boolean(i)||(this.deactivate(),document.removeEventListener("mousedown",onMouseDown))}};setTimeout((()=>{document.addEventListener("mousedown",onMouseDown)}),300)},deactivate(){this.isOpen&&(this.isOpen=!1,this.searchable?this.$refs.search&&this.$refs.search.blur():this.$el&&this.$el.blur(),this.preserveSearch||(this.search=""),this.$emit("close",this.getValue(),this.id))},toggle(){this.isOpen?this.deactivate():this.activate()},adjustPosition(){if("undefined"===typeof window)return;const e=this.$el.getBoundingClientRect().top,t=window.innerHeight-this.$el.getBoundingClientRect().bottom,i=t>this.maxHeight;i||t>e||"below"===this.openDirection||"bottom"===this.openDirection?(this.preferredOpenDirection="below",this.optimizedHeight=Math.min(t-40,this.maxHeight)):(this.preferredOpenDirection="above",this.optimizedHeight=Math.min(e-40,this.maxHeight))}}},S={data(){return{pointer:0,pointerDirty:!1}},props:{showPointer:{type:Boolean,default:!0},optionHeight:{type:Number,default:40}},computed:{pointerPosition(){return this.pointer*this.optionHeight},visibleElements(){return this.optimizedHeight/this.optionHeight}},watch:{filteredOptions(){this.pointerAdjust()},isOpen(){this.pointerDirty=!1},pointer(){this.$refs.search&&this.$refs.search.setAttribute("aria-activedescendant",this.id+"-"+this.pointer.toString())}},methods:{optionHighlight(e,t){return{"multiselect__option--highlight":e===this.pointer&&this.showPointer,"multiselect__option--selected":this.isSelected(t)}},groupHighlight(e,t){if(!this.groupSelect)return["multiselect__option--disabled",{"multiselect__option--group":t.$isLabel}];const i=this.options.find((e=>e[this.groupLabel]===t.$groupLabel));return i&&!this.wholeGroupDisabled(i)?["multiselect__option--group",{"multiselect__option--highlight":e===this.pointer&&this.showPointer},{"multiselect__option--group-selected":this.wholeGroupSelected(i)}]:"multiselect__option--disabled"},addPointerElement({key:e}="Enter"){this.filteredOptions.length>0&&this.select(this.filteredOptions[this.pointer],e),this.pointerReset()},pointerForward(){this.pointer<this.filteredOptions.length-1&&(this.pointer++,this.$refs.list.scrollTop<=this.pointerPosition-(this.visibleElements-1)*this.optionHeight&&(this.$refs.list.scrollTop=this.pointerPosition-(this.visibleElements-1)*this.optionHeight),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()),this.pointerDirty=!0},pointerBackward(){this.pointer>0?(this.pointer--,this.$refs.list.scrollTop>=this.pointerPosition&&(this.$refs.list.scrollTop=this.pointerPosition),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerBackward()):this.filteredOptions[this.pointer]&&this.filteredOptions[0].$isLabel&&!this.groupSelect&&this.pointerForward(),this.pointerDirty=!0},pointerReset(){this.closeOnSelect&&(this.pointer=0,this.$refs.list&&(this.$refs.list.scrollTop=0))},pointerAdjust(){this.pointer>=this.filteredOptions.length-1&&(this.pointer=this.filteredOptions.length?this.filteredOptions.length-1:0),this.filteredOptions.length>0&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()},pointerSet(e){this.pointer=e,this.pointerDirty=!0}}},x={name:"vue-multiselect",mixins:[_,S],compatConfig:{MODE:3,ATTR_ENUMERATED_COERCION:!1},props:{name:{type:String,default:""},modelValue:{type:null,default(){return[]}},selectLabel:{type:String,default:"Press enter to select"},selectGroupLabel:{type:String,default:"Press enter to select group"},selectedLabel:{type:String,default:"Selected"},deselectLabel:{type:String,default:"Press enter to remove"},deselectGroupLabel:{type:String,default:"Press enter to deselect group"},showLabels:{type:Boolean,default:!0},limit:{type:Number,default:99999},maxHeight:{type:Number,default:300},limitText:{type:Function,default:e=>`and ${e} more`},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},openDirection:{type:String,default:""},showNoOptions:{type:Boolean,default:!0},showNoResults:{type:Boolean,default:!0},tabindex:{type:Number,default:0}},computed:{hasOptionGroup(){return this.groupValues&&this.groupLabel&&this.groupSelect},isSingleLabelVisible(){return!1},isPlaceholderVisible(){return!this.internalValue.length&&(!this.searchable||!this.isOpen)},visibleValues(){return this.internalValue.slice(0,this.limit)},singleValue(){return this.internalValue[0]},deselectLabelText(){return this.showLabels?this.deselectLabel:""},deselectGroupLabelText(){return this.showLabels?this.deselectGroupLabel:""},selectLabelText(){return this.showLabels?this.selectLabel:""},selectGroupLabelText(){return this.showLabels?this.selectGroupLabel:""},selectedLabelText(){return this.showLabels?this.selectedLabel:""},inputStyle(){return this.searchable||this.multiple&&this.modelValue&&this.modelValue.length?this.isOpen?{width:"100%"}:{width:"0",position:"absolute",padding:"0"}:""},contentStyle(){return this.options.length?{display:"inline-block"}:{display:"block"}},isAbove(){return"above"===this.openDirection||"top"===this.openDirection||"below"!==this.openDirection&&"bottom"!==this.openDirection&&"above"===this.preferredOpenDirection},showSearchInput(){return this.searchable&&(!this.hasSingleSelectedSlot||!this.visibleSingleValue&&0!==this.visibleSingleValue||this.isOpen)},showNoResultsSlot(){return this.showNoResults&&0===this.filteredOptions.length&&this.search&&!this.loading},showNoOptionsSlot(){return this.showNoOptions&&(0===this.options.length||!0===this.hasOptionGroup&&0===this.filteredOptions.length)&&!this.search&&!this.loading}}};var O=__webpack_require__(6262);const L=(0,O.A)(x,[["render",render]]),$=L,N=$;return s})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldmjs/ui",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
4
4
  "description": "ldm ui",
5
5
  "main": "dist/index.js",
6
6
  "engines": {