selectic 1.3.9 → 3.0.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.
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vtyx = require('vtyx');
6
+ var vue = require('vue');
6
7
 
7
8
  function styleInject(css, ref) {
8
9
  if ( ref === void 0 ) ref = {};
@@ -31,21 +32,16 @@ function styleInject(css, ref) {
31
32
  }
32
33
  }
33
34
 
34
- var css_248z = "/* {{{ Variables */\n\n:root {\n --selectic-font-size: 14px;\n --selectic-cursor-disabled: not-allowed;\n\n /* The main element */\n --selectic-color: #555555;\n --selectic-bg: #ffffff;\n\n /* The main element (when disabled) */\n --selectic-color-disabled: #787878;\n --selectic-bg-disabled: #eeeeee;\n\n /* The list */\n --selectic-panel-bg: #f0f0f0;\n --selectic-separator-bordercolor: #cccccc;\n /* --selectic-item-color: var(--selectic-color); /* Can be set in any CSS configuration */\n\n /* The current selected item */\n --selectic-selected-item-color: #428bca;\n\n /* When mouse is over items or by selecting with key arrows */\n --selectic-active-item-color: #ffffff;\n --selectic-active-item-bg: #66afe9;\n\n /* Selected values in main element */\n --selectic-value-bg: #f0f0f0;\n /* --selectic-more-items-bg: var(--selectic-info-bg); /* can be set in any CSS configuration */\n /* --selectic-more-items-color: var(--selectic-info-color); /* can be set in any CSS configuration */\n --selectic-more-items-bg-disabled: #cccccc;\n\n /* Information message */\n --selectic-info-bg: #5bc0de;\n --selectic-info-color: #ffffff;\n\n /* Error message */\n --selectic-error-bg: #b72c29;\n --selectic-error-color: #ffffff;\n\n /* XXX: Currently it is important to keep this size for a correct scroll\n * height estimation */\n --selectic-input-height: 30px;\n}\n\n/* }}} */\n/* {{{ Bootstrap equivalent style */\n\n.selectic .form-control {\n display: block;\n width: 100%;\n height: calc(var(--selectic-input-height) - 2px);\n font-size: var(--selectic-font-size);\n line-height: 1.42857143;\n color: var(--selectic-color);\n background-color: var(--selectic-bg);\n background-image: none;\n border: 1px solid var(--selectic-separator-bordercolor); /* should use a better variable */\n border-radius: 4px;\n box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;\n}\n.selectic .has-feedback {\n position: relative;\n}\n.selectic .has-feedback .form-control {\n padding-right: calc(var(--selectic-input-height) + 4px);\n}\n\n.selectic .form-control-feedback.fa,\n.selectic .form-control-feedback {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 2;\n display: block;\n width: calc(var(--selectic-input-height) + 4px);\n height: calc(var(--selectic-input-height) + 4px);\n line-height: var(--selectic-input-height);\n text-align: center;\n pointer-events: none;\n}\n\n.selectic .alert-info {\n background-color: var(--selectic-info-bg);\n color: var(--selectic-info-color);\n}\n\n.selectic .alert-danger {\n background-color: var(--selectic-error-bg);\n color: var(--selectic-error-color);\n}\n\n/* }}} */\n\n.selectic * {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.selectic.form-control {\n display: inline-block;\n padding: 0;\n cursor: pointer;\n border: unset;\n}\n\n.has-feedback .selectic__icon-container.form-control-feedback {\n right: 0;\n}\n\n/* The input which contains the selected value\n * XXX: This input should stay hidden behind other elements, but is \"visible\"\n * (in term of DOM point of view) in order to get and to trigger the `focus`\n * DOM event. */\n.selectic__input-value {\n position: fixed;\n opacity: 0;\n z-index: -1000;\n top: -100px;\n}\n\n/* XXX: .form-control has been added to this selector to improve priority and\n * override some rules of the original .form-control */\n.selectic-input.form-control {\n display: inline-flex;\n justify-content: space-between;\n overflow: hidden;\n width: 100%;\n min-height: var(--selectic-input-height);\n padding-top: 0;\n padding-bottom: 0;\n padding-left: 5px;\n line-height: calc(var(--selectic-input-height) - 4px);\n color: var(--selectic-color);\n}\n\n.selectic-input__reverse-icon {\n align-self: center;\n margin-right: 3px;\n cursor: default;\n}\n.selectic-input__clear-icon {\n align-self: center;\n margin-left: 3px;\n cursor: pointer;\n}\n.selectic-input__clear-icon:hover {\n color: var(--selectic-selected-item-color);\n}\n\n.selectic-input.focused {\n border-bottom-left-radius: 0px;\n border-bottom-right-radius: 0px;\n}\n\n.selectic-input.disabled {\n cursor: var(--selectic-cursor-disabled);\n background-color: var(--selectic-bg-disabled);\n}\n.selectic-input.disabled .more-items {\n\tbackground-color: var(--selectic-more-items-bg-disabled);\n}\n\n.selectic-input__selected-items {\n display: inline-flex;\n flex-wrap: nowrap;\n align-items: center;\n white-space: nowrap;\n}\n\n.selectic-input__selected-items__placeholder {\n font-style: italic;\n opacity: 0.7;\n white-space: nowrap;\n}\n\n.selectic-icon {\n color: var(--selectic-color);\n text-align: center;\n vertical-align: middle;\n}\n\n.selectic__extended-list {\n position: fixed;\n z-index: 2000;\n background-color: var(--selectic-bg, #ffffff);\n box-shadow: 2px 5px 12px 0px #888888;\n border-radius: 0 0 4px 4px;\n padding: 0;\n min-width: 200px;\n}\n.selectic__extended-list__list-items {\n max-height: calc(var(--selectic-input-height) * 10);\n overflow: auto;\n padding-left: 0;\n}\n\n.selectic-item {\n display: block;\n position: relative;\n box-sizing: border-box;\n padding: 2px 8px;\n color: var(--selectic-item-color, var(--selectic-color));\n min-height: calc(var(--selectic-input-height) - 3px);\n list-style-type: none;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.selectic-item_text {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.selectic-item:not(.selected) .selectic-item_icon {\n opacity: 0;\n}\n\n.selectic-item__active {\n background-color: var(--selectic-active-item-bg);\n color: var(--selectic-active-item-color);\n}\n.selectic-item__active:not(.selected) .selectic-item_icon {\n opacity: 0.2;\n}\n\n.selectic-item__disabled {\n color: var(--selectic-color-disabled);\n background-color: var(--selectic-bg-disabled);\n}\n\n.selectic-item__is-in-group {\n padding-left: 2em;\n}\n\n.selectic-item__is-group {\n font-weight: bold;\n cursor: default;\n}\n\n.selectic-item.selected {\n color: var(--selectic-selected-item-color);\n}\n.selectic-search-scope {\n color: #e0e0e0;\n left: auto;\n right: 10px;\n}\n\n.selectic__message {\n text-align: center;\n padding: 3px;\n}\n\n.selectic .filter-panel {\n padding: 3px;\n margin-left: 0px;\n margin-right: 0px;\n background-color: var(--selectic-panel-bg);\n border-bottom: 1px solid var(--selectic-separator-bordercolor);\n}\n\n.selectic .panelclosed {\n max-height: 0px;\n transition: max-height 0.3s ease-out;\n overflow: hidden;\n}\n\n.panelopened {\n max-height: 200px;\n transition: max-height 0.3s ease-in;\n overflow: hidden;\n}\n\n.selectic .filter-panel__input {\n padding-left: 0px;\n padding-right: 0px;\n padding-bottom: 10px;\n margin-bottom: 0px;\n}\n.selectic .filter-input {\n height: calc(var(--selectic-input-height) * 0.75);\n}\n\n.selectic .checkbox-filter {\n padding: 5px;\n text-align: center;\n}\n\n.selectic .curtain-handler {\n text-align: center;\n}\n\n.selectic .toggle-selectic {\n margin: 5px;\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.selectic .toggle-boolean-select-all-toggle {\n display: inline;\n margin-right: 15px;\n}\n\n.selectic .toggle-boolean-excluding-toggle {\n display: inline;\n margin-right: 15px;\n}\n\n.selectic .single-value {\n display: grid;\n grid-template: \"value icon\" 1fr / max-content max-content;\n\n padding: 2px;\n padding-left: 5px;\n margin-left: 0;\n margin-right: 5px;\n /* margin top/bottom are mainly to create a gutter in multilines */\n margin-top: 2px;\n margin-bottom: 2px;\n\n border-radius: 3px;\n background-color: var(--selectic-value-bg);\n max-height: calc(var(--selectic-input-height) - 10px);\n max-width: 100%;\n min-width: 30px;\n\n overflow: hidden;\n white-space: nowrap;\n line-height: initial;\n vertical-align: middle;\n}\n\n.selectic .more-items {\n display: inline-block;\n\n padding-left: 5px;\n padding-right: 5px;\n border-radius: 10px;\n\n background-color: var(--selectic-more-items-bg, var(--selectic-info-bg));\n color: var(--selectic-more-items-color, var(--selectic-info-color));\n cursor: help;\n}\n.selectic-input__selected-items__value {\n grid-area: value;\n align-self: center;\n justify-self: normal;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.selectic-input__selected-items__icon {\n grid-area: icon;\n align-self: center;\n justify-self: center;\n margin-left: 5px;\n}\n.selectic-input__selected-items__icon:hover {\n color: var(--selectic-selected-item-color);\n}\n\n.selectic__label-disabled {\n opacity: 0.5;\n transition: opacity 400ms;\n}\n\n/* XXX: override padding of bootstrap input-sm.\n * This padding introduce a line shift. */\n.selectic.input-sm {\n padding: 0;\n}\n\n/* {{{ overflow multiline */\n\n.selectic--overflow-multiline,\n.selectic--overflow-multiline.form-control,\n.selectic--overflow-multiline .form-control {\n height: unset;\n}\n\n.selectic--overflow-multiline .selectic-input {\n overflow: unset;\n}\n\n.selectic--overflow-multiline .selectic-input__selected-items {\n flex-wrap: wrap;\n}\n\n/* }}} */\n";
35
+ var css_248z = "/* {{{ Variables */\n\n:root {\n --selectic-font-size: 14px;\n --selectic-cursor-disabled: not-allowed;\n\n /* The main element */\n --selectic-color: #555555;\n --selectic-bg: #ffffff;\n\n /* The main element (when disabled) */\n --selectic-color-disabled: #787878;\n --selectic-bg-disabled: #eeeeee;\n\n /* The list */\n --selectic-panel-bg: #f0f0f0;\n --selectic-separator-bordercolor: #cccccc;\n /* --selectic-item-color: var(--selectic-color); /* Can be set in any CSS configuration */\n\n /* The current selected item */\n --selectic-selected-item-color: #428bca;\n\n /* When mouse is over items or by selecting with key arrows */\n --selectic-active-item-color: #ffffff;\n --selectic-active-item-bg: #66afe9;\n\n /* Selected values in main element */\n --selectic-value-bg: #f0f0f0;\n /* --selectic-more-items-bg: var(--selectic-info-bg); /* can be set in any CSS configuration */\n /* --selectic-more-items-color: var(--selectic-info-color); /* can be set in any CSS configuration */\n --selectic-more-items-bg-disabled: #cccccc;\n\n /* Information message */\n --selectic-info-bg: #5bc0de;\n --selectic-info-color: #ffffff;\n\n /* Error message */\n --selectic-error-bg: #b72c29;\n --selectic-error-color: #ffffff;\n\n /* XXX: Currently it is important to keep this size for a correct scroll\n * height estimation */\n --selectic-input-height: 30px;\n}\n\n/* }}} */\n/* {{{ Bootstrap equivalent style */\n\n.selectic .form-control {\n display: block;\n width: 100%;\n height: calc(var(--selectic-input-height) - 2px);\n font-size: var(--selectic-font-size);\n line-height: 1.42857143;\n color: var(--selectic-color);\n background-color: var(--selectic-bg);\n background-image: none;\n border: 1px solid var(--selectic-separator-bordercolor); /* should use a better variable */\n border-radius: 4px;\n box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;\n}\n.selectic .has-feedback {\n position: relative;\n}\n.selectic .has-feedback .form-control {\n padding-right: calc(var(--selectic-input-height) + 4px);\n}\n\n.selectic .form-control-feedback.fa,\n.selectic .form-control-feedback {\n position: absolute;\n top: 0;\n right: 0;\n z-index: 2;\n display: block;\n width: calc(var(--selectic-input-height) + 4px);\n height: calc(var(--selectic-input-height) + 4px);\n line-height: var(--selectic-input-height);\n text-align: center;\n pointer-events: none;\n}\n\n.selectic .alert-info {\n background-color: var(--selectic-info-bg);\n color: var(--selectic-info-color);\n}\n\n.selectic .alert-danger {\n background-color: var(--selectic-error-bg);\n color: var(--selectic-error-color);\n}\n\n/* }}} */\n\n.selectic * {\n -webkit-box-sizing: border-box;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.selectic.form-control {\n display: inline-block;\n padding: 0;\n cursor: pointer;\n border: unset;\n}\n\n.has-feedback .selectic__icon-container.form-control-feedback {\n right: 0;\n}\n\n/* The input which contains the selected value\n * XXX: This input should stay hidden behind other elements, but is \"visible\"\n * (in term of DOM point of view) in order to get and to trigger the `focus`\n * DOM event. */\n.selectic__input-value {\n position: fixed;\n opacity: 0;\n z-index: -1000;\n top: -100px;\n}\n\n/* XXX: .form-control has been added to this selector to improve priority and\n * override some rules of the original .form-control */\n.selectic-input.form-control {\n display: inline-flex;\n justify-content: space-between;\n overflow: hidden;\n width: 100%;\n min-height: var(--selectic-input-height);\n padding-top: 0;\n padding-bottom: 0;\n padding-left: 5px;\n line-height: calc(var(--selectic-input-height) - 4px);\n color: var(--selectic-color);\n}\n\n.selectic-input__reverse-icon {\n align-self: center;\n margin-right: 3px;\n cursor: default;\n}\n.selectic-input__clear-icon {\n align-self: center;\n margin-left: 3px;\n cursor: pointer;\n}\n.selectic-input__clear-icon:hover {\n color: var(--selectic-selected-item-color);\n}\n\n.selectic-input.focused {\n border-bottom-left-radius: 0px;\n border-bottom-right-radius: 0px;\n}\n\n.selectic-input.disabled {\n cursor: var(--selectic-cursor-disabled);\n background-color: var(--selectic-bg-disabled);\n}\n.selectic-input.disabled .more-items {\n\tbackground-color: var(--selectic-more-items-bg-disabled);\n}\n\n.selectic-input__selected-items {\n display: inline-flex;\n flex-wrap: nowrap;\n align-items: center;\n white-space: nowrap;\n}\n\n.selectic-input__selected-items__placeholder {\n font-style: italic;\n opacity: 0.7;\n white-space: nowrap;\n}\n\n.selectic-icon {\n color: var(--selectic-color);\n text-align: center;\n vertical-align: middle;\n}\n\n.selectic__extended-list {\n position: fixed;\n z-index: 2000;\n height: auto;\n background-color: var(--selectic-bg, #ffffff);\n box-shadow: 2px 5px 12px 0px #888888;\n border-radius: 0 0 4px 4px;\n padding: 0;\n min-width: 200px;\n}\n.selectic__extended-list__list-items {\n max-height: calc(var(--selectic-input-height) * 10);\n overflow: auto;\n padding-left: 0;\n}\n\n.selectic-item {\n display: block;\n position: relative;\n box-sizing: border-box;\n padding: 2px 8px;\n color: var(--selectic-item-color, var(--selectic-color));\n min-height: calc(var(--selectic-input-height) - 3px);\n list-style-type: none;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.selectic-item_text {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.selectic-item:not(.selected) .selectic-item_icon {\n opacity: 0;\n}\n\n.selectic-item_text {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.selectic-item__active {\n background-color: var(--selectic-active-item-bg);\n color: var(--selectic-active-item-color);\n}\n.selectic-item__active:not(.selected) .selectic-item_icon {\n opacity: 0.2;\n}\n\n.selectic-item__disabled {\n color: var(--selectic-color-disabled);\n background-color: var(--selectic-bg-disabled);\n}\n\n.selectic-item__is-in-group {\n padding-left: 2em;\n}\n\n.selectic-item__is-group {\n font-weight: bold;\n cursor: default;\n}\n\n.selectic-item.selected {\n color: var(--selectic-selected-item-color);\n}\n.selectic-search-scope {\n color: #e0e0e0;\n left: auto;\n right: 10px;\n}\n\n.selectic__message {\n text-align: center;\n padding: 3px;\n}\n\n.selectic .filter-panel {\n padding: 3px;\n margin-left: 0px;\n margin-right: 0px;\n background-color: var(--selectic-panel-bg);\n border-bottom: 1px solid var(--selectic-separator-bordercolor);\n}\n\n.selectic .panelclosed {\n max-height: 0px;\n transition: max-height 0.3s ease-out;\n overflow: hidden;\n}\n\n.panelopened {\n max-height: 200px;\n transition: max-height 0.3s ease-in;\n overflow: hidden;\n}\n\n.selectic .filter-panel__input {\n padding-left: 0px;\n padding-right: 0px;\n padding-bottom: 10px;\n margin-bottom: 0px;\n}\n.selectic .filter-input {\n height: calc(var(--selectic-input-height) * 0.75);\n}\n\n.selectic .checkbox-filter {\n padding: 5px;\n text-align: center;\n}\n\n.selectic .curtain-handler {\n text-align: center;\n}\n\n.selectic .toggle-selectic {\n margin: 5px;\n padding-left: 0px;\n padding-right: 0px;\n}\n\n.selectic .toggle-boolean-select-all-toggle {\n display: inline;\n margin-right: 15px;\n}\n\n.selectic .toggle-boolean-excluding-toggle {\n display: inline;\n margin-right: 15px;\n}\n\n.selectic .single-value {\n display: grid;\n grid-template: \"value icon\" 1fr / max-content max-content;\n\n padding: 2px;\n padding-left: 5px;\n margin-left: 0;\n margin-right: 5px;\n /* margin top/bottom are mainly to create a gutter in multilines */\n margin-top: 2px;\n margin-bottom: 2px;\n\n border-radius: 3px;\n background-color: var(--selectic-value-bg);\n max-height: calc(var(--selectic-input-height) - 10px);\n max-width: 100%;\n min-width: 30px;\n\n overflow: hidden;\n white-space: nowrap;\n line-height: initial;\n vertical-align: middle;\n}\n\n.selectic .more-items {\n display: inline-block;\n\n padding-left: 5px;\n padding-right: 5px;\n border-radius: 10px;\n\n background-color: var(--selectic-more-items-bg, var(--selectic-info-bg));\n color: var(--selectic-more-items-color, var(--selectic-info-color));\n cursor: help;\n}\n.selectic-input__selected-items__value {\n grid-area: value;\n align-self: center;\n justify-self: normal;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.selectic-input__selected-items__icon {\n grid-area: icon;\n align-self: center;\n justify-self: center;\n margin-left: 5px;\n}\n.selectic-input__selected-items__icon:hover {\n color: var(--selectic-selected-item-color);\n}\n\n.selectic__label-disabled {\n opacity: 0.5;\n transition: opacity 400ms;\n}\n\n/* XXX: override padding of bootstrap input-sm.\n * This padding introduce a line shift. */\n.selectic.input-sm {\n padding: 0;\n}\n\n/* {{{ overflow multiline */\n\n.selectic--overflow-multiline,\n.selectic--overflow-multiline.form-control,\n.selectic--overflow-multiline .form-control {\n height: unset;\n}\n\n.selectic--overflow-multiline .selectic-input {\n overflow: unset;\n}\n\n.selectic--overflow-multiline .selectic-input__selected-items {\n flex-wrap: wrap;\n}\n\n/* }}} */\n";
35
36
  styleInject(css_248z);
36
37
 
37
38
  /* File Purpose:
38
39
  * It keeps and computes all states at a single place.
39
- * Every inner components of Selectic should comunicate with this file to
40
+ * Every inner components of Selectic should communicate with this file to
40
41
  * change or to get states.
41
42
  */
42
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
43
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
44
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
45
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
46
- return c > 3 && r && Object.defineProperty(target, key, r), r;
47
- };
48
43
  /* }}} */
44
+ /* {{{ Helper */
49
45
  /**
50
46
  * Escape search string to consider regexp special characters as they
51
47
  * are and not like special characters.
@@ -62,6 +58,26 @@ function convertToRegExp(name, flag = 'i') {
62
58
  .replace(/\*/g, '.*');
63
59
  return new RegExp(pattern, flag);
64
60
  }
61
+ /** Does the same as Object.assign but does not replace if value is undefined */
62
+ function assignObject(obj, ...sourceObjects) {
63
+ const result = obj;
64
+ for (const source of sourceObjects) {
65
+ for (const key of Object.keys(source)) {
66
+ const value = source[key];
67
+ if (value === undefined) {
68
+ continue;
69
+ }
70
+ result[key] = value;
71
+ }
72
+ }
73
+ return result;
74
+ }
75
+ /* }}} */
76
+ /* {{{ Static */
77
+ function changeTexts$1(texts) {
78
+ messages = Object.assign(messages, texts);
79
+ }
80
+ /* }}} */
65
81
  let messages = {
66
82
  noFetchMethod: 'Fetch callback is missing: it is not possible to retrieve data.',
67
83
  searchPlaceholder: 'Search',
@@ -81,20 +97,12 @@ let messages = {
81
97
  unknownPropertyValue: 'property "%s" has incorrect values.',
82
98
  };
83
99
  let closePreviousSelectic;
84
- /* {{{ Static */
85
- function changeTexts(texts) {
86
- messages = Object.assign(messages, texts);
87
- }
88
100
  /* }}} */
89
- let SelecticStore = class SelecticStore extends vtyx.Vue {
90
- constructor() {
91
- /* {{{ props */
92
- super(...arguments);
93
- /* }}} */
101
+ let uid = 0;
102
+ class SelecticStore {
103
+ constructor(props = {}) {
94
104
  /* {{{ data */
95
- /* Number of items displayed in a page (before scrolling) */
96
- this.itemsPerPage = 10;
97
- this.state = {
105
+ this.state = vue.reactive({
98
106
  multiple: false,
99
107
  disabled: false,
100
108
  placeholder: '',
@@ -129,44 +137,150 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
129
137
  areAllSelected: false,
130
138
  hasChanged: false,
131
139
  },
140
+ });
141
+ /* Do not need reactivity */
142
+ this.requestId = 0;
143
+ this._uid = ++uid;
144
+ /* {{{ Props */
145
+ const defaultProps = {
146
+ value: null,
147
+ selectionIsExcluded: false,
148
+ disabled: false,
149
+ options: null,
150
+ childOptions: [],
151
+ groups: [],
152
+ texts: null,
153
+ params: {},
154
+ fetchCallback: null,
155
+ getItemsCallback: null,
156
+ keepOpenWithOtherSelectic: false,
132
157
  };
133
- this.labels = Object.assign({}, messages);
134
- /* used to avoid checking and updating table while doing batch stuff */
135
- this.doNotUpdate = false;
136
- this.cacheItem = new Map();
137
- this.activeOrder = 'D';
138
- this.dynOffset = 0;
158
+ const propsVal = assignObject(defaultProps, props);
159
+ this.props = vue.reactive(propsVal);
139
160
  /* }}} */
140
- }
141
- /* }}} */
142
- /* {{{ computed */
143
- /* Number of item to pre-display */
144
- get marginSize() {
145
- return this.state.pageSize / 2;
146
- }
147
- get isPartial() {
148
- const state = this.state;
149
- let isPartial = typeof this.fetchCallback === 'function';
150
- if (isPartial && state.optionBehaviorOperation === 'force' && this.activeOrder !== 'D') {
151
- isPartial = false;
161
+ /* {{{ data */
162
+ this.data = vue.reactive({
163
+ labels: Object.assign({}, messages),
164
+ itemsPerPage: 10,
165
+ doNotUpdate: false,
166
+ cacheItem: new Map(),
167
+ activeOrder: 'D',
168
+ dynOffset: 0,
169
+ });
170
+ /* }}} */
171
+ /* {{{ computed */
172
+ this.marginSize = vue.computed(() => {
173
+ return this.state.pageSize / 2;
174
+ });
175
+ this.isPartial = vue.computed(() => {
176
+ const state = this.state;
177
+ let isPartial = typeof this.props.fetchCallback === 'function';
178
+ if (isPartial &&
179
+ state.optionBehaviorOperation === 'force' &&
180
+ this.data.activeOrder !== 'D') {
181
+ isPartial = false;
182
+ }
183
+ return isPartial;
184
+ });
185
+ this.hasAllItems = vue.computed(() => {
186
+ const state = this.state;
187
+ const nbItems = state.totalFilteredOptions + state.groups.size;
188
+ return this.state.filteredOptions.length >= nbItems;
189
+ });
190
+ this.hasFetchedAllItems = vue.computed(() => {
191
+ var _a;
192
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
193
+ if (!isPartial) {
194
+ return true;
195
+ }
196
+ const state = this.state;
197
+ return state.dynOptions.length === state.totalDynOptions;
198
+ });
199
+ this.listOptions = vue.computed(() => {
200
+ return this.getListOptions();
201
+ });
202
+ this.elementOptions = vue.computed(() => {
203
+ return this.getElementOptions();
204
+ });
205
+ /* }}} */
206
+ /* {{{ watch */
207
+ vue.watch(() => [this.props.options, this.props.childOptions], () => {
208
+ this.data.cacheItem.clear();
209
+ this.commit('isOpen', false);
210
+ this.buildAllOptions(true);
211
+ this.buildSelectedOptions();
212
+ });
213
+ vue.watch(() => [this.listOptions, this.elementOptions], () => {
214
+ /* TODO: transform allOptions as a computed properties and this
215
+ * watcher become useless */
216
+ this.buildAllOptions(true);
217
+ });
218
+ vue.watch(() => this.props.value, () => {
219
+ var _a;
220
+ const value = (_a = this.props.value) !== null && _a !== void 0 ? _a : null;
221
+ this.commit('internalValue', value);
222
+ });
223
+ vue.watch(() => this.props.selectionIsExcluded, () => {
224
+ this.commit('selectionIsExcluded', this.props.selectionIsExcluded);
225
+ });
226
+ vue.watch(() => this.props.disabled, () => {
227
+ this.commit('disabled', this.props.disabled);
228
+ });
229
+ vue.watch(() => this.state.filteredOptions, () => {
230
+ var _a;
231
+ let areAllSelected = false;
232
+ const hasAllItems = (_a = this.hasAllItems.value) !== null && _a !== void 0 ? _a : this.hasAllItems;
233
+ if (hasAllItems) {
234
+ const selectionIsExcluded = +this.state.selectionIsExcluded;
235
+ /* eslint-disable-next-line no-bitwise */
236
+ areAllSelected = this.state.filteredOptions.every((item) => !!(+item.selected ^ selectionIsExcluded));
237
+ }
238
+ this.state.status.areAllSelected = areAllSelected;
239
+ });
240
+ vue.watch(() => this.state.internalValue, () => {
241
+ this.buildSelectedOptions();
242
+ });
243
+ vue.watch(() => this.state.allOptions, () => {
244
+ this.checkAutoSelect();
245
+ this.checkAutoDisabled();
246
+ });
247
+ vue.watch(() => this.state.totalAllOptions, () => {
248
+ this.checkHideFilter();
249
+ });
250
+ /* }}} */
251
+ this.closeSelectic = () => {
252
+ this.commit('isOpen', false);
253
+ };
254
+ const value = this.props.value;
255
+ /* set initial value for non reactive attribute */
256
+ this.cacheRequest = new Map();
257
+ const stateParam = Object.assign({}, this.props.params);
258
+ if (stateParam.optionBehavior) {
259
+ this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
260
+ delete stateParam.optionBehavior;
152
261
  }
153
- return isPartial;
154
- }
155
- get hasAllItems() {
156
- const nbItems = this.state.totalFilteredOptions + this.state.groups.size;
157
- return this.state.filteredOptions.length >= nbItems;
158
- }
159
- get hasFetchedAllItems() {
160
- const state = this.state;
161
- if (!this.isPartial) {
162
- return true;
262
+ if (stateParam.hideFilter === 'auto') {
263
+ delete stateParam.hideFilter;
264
+ }
265
+ /* Update state */
266
+ assignObject(this.state, stateParam);
267
+ /* XXX: should be done in 2 lines, in order to set the multiple state
268
+ * and ensure convertValue run with correct state */
269
+ assignObject(this.state, {
270
+ internalValue: this.convertTypeValue(value),
271
+ selectionIsExcluded: props.selectionIsExcluded,
272
+ disabled: props.disabled,
273
+ });
274
+ this.checkHideFilter();
275
+ if (this.props.texts) {
276
+ this.changeTexts(this.props.texts);
163
277
  }
164
- return state.dynOptions.length === state.totalDynOptions;
165
- }
166
- get closeSelectic() {
167
- return () => this.commit('isOpen', false);
278
+ this.addGroups(this.props.groups);
279
+ this.assertValueType();
280
+ this.buildAllOptions();
281
+ this.buildSelectedOptions();
282
+ this.checkAutoDisabled();
168
283
  }
169
- /* }}} */
170
284
  /* {{{ methods */
171
285
  /* {{{ public methods */
172
286
  commit(name, value) {
@@ -204,7 +318,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
204
318
  if (typeof closePreviousSelectic === 'function') {
205
319
  closePreviousSelectic();
206
320
  }
207
- if (!this.keepOpenWithOtherSelectic) {
321
+ if (!this.props.keepOpenWithOtherSelectic) {
208
322
  closePreviousSelectic = this.closeSelectic;
209
323
  }
210
324
  }
@@ -231,7 +345,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
231
345
  getItem(id) {
232
346
  let item;
233
347
  if (this.hasItemInStore(id)) {
234
- item = this.cacheItem.get(id);
348
+ item = this.data.cacheItem.get(id);
235
349
  }
236
350
  else {
237
351
  this.getItems([id]);
@@ -244,7 +358,8 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
244
358
  }
245
359
  async getItems(ids) {
246
360
  const itemsToFetch = ids.filter((id) => !this.hasItemInStore(id));
247
- if (itemsToFetch.length && typeof this.getItemsCallback === 'function') {
361
+ const getItemsCallback = this.props.getItemsCallback;
362
+ if (itemsToFetch.length && typeof getItemsCallback === 'function') {
248
363
  const cacheRequest = this.cacheRequest;
249
364
  const requestId = itemsToFetch.toString();
250
365
  let promise;
@@ -252,26 +367,29 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
252
367
  promise = cacheRequest.get(requestId);
253
368
  }
254
369
  else {
255
- promise = this.getItemsCallback(itemsToFetch);
370
+ promise = getItemsCallback(itemsToFetch);
256
371
  cacheRequest.set(requestId, promise);
257
372
  promise.then(() => {
258
373
  cacheRequest.delete(requestId);
259
374
  });
260
375
  }
261
376
  const items = await promise;
377
+ const cacheItem = this.data.cacheItem;
262
378
  for (const item of items) {
263
379
  if (item) {
264
- this.cacheItem.set(item.id, item);
380
+ cacheItem.set(item.id, item);
265
381
  }
266
382
  }
267
383
  }
268
384
  return this.buildSelectedItems(ids);
269
385
  }
270
386
  selectItem(id, selected, keepOpen = false) {
387
+ var _a;
271
388
  const state = this.state;
272
389
  let hasChanged = false;
390
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
273
391
  /* Check that item is not disabled */
274
- if (!this.isPartial) {
392
+ if (!isPartial) {
275
393
  const item = state.allOptions.find((opt) => opt.id === id);
276
394
  if (item && item.disabled) {
277
395
  return;
@@ -330,16 +448,19 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
330
448
  }
331
449
  }
332
450
  toggleSelectAll() {
451
+ var _a;
333
452
  if (!this.state.multiple) {
334
453
  return;
335
454
  }
336
- if (!this.hasAllItems) {
455
+ const hasAllItems = (_a = this.hasAllItems.value) !== null && _a !== void 0 ? _a : this.hasAllItems;
456
+ if (!hasAllItems) {
457
+ const labels = this.data.labels;
337
458
  if (this.state.searchText) {
338
- this.state.status.errorMessage = this.labels.cannotSelectAllSearchedItems;
459
+ this.state.status.errorMessage = labels.cannotSelectAllSearchedItems;
339
460
  return;
340
461
  }
341
462
  if (!this.state.allowRevert) {
342
- this.state.status.errorMessage = this.labels.cannotSelectAllRevertItems;
463
+ this.state.status.errorMessage = labels.cannotSelectAllRevertItems;
343
464
  return;
344
465
  }
345
466
  const value = this.state.internalValue;
@@ -352,9 +473,9 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
352
473
  }
353
474
  const selectAll = !this.state.status.areAllSelected;
354
475
  this.state.status.areAllSelected = selectAll;
355
- this.doNotUpdate = true;
476
+ this.data.doNotUpdate = true;
356
477
  this.state.filteredOptions.forEach((item) => this.selectItem(item.id, selectAll));
357
- this.doNotUpdate = false;
478
+ this.data.doNotUpdate = false;
358
479
  this.updateFilteredOptions();
359
480
  }
360
481
  resetChange() {
@@ -364,8 +485,10 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
364
485
  this.state.status.errorMessage = '';
365
486
  }
366
487
  clearCache(forceReset = false) {
367
- const total = this.isPartial ? Infinity : 0;
368
- this.cacheItem.clear();
488
+ var _a;
489
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
490
+ const total = isPartial ? Infinity : 0;
491
+ this.data.cacheItem.clear();
369
492
  this.state.allOptions = [];
370
493
  this.state.totalAllOptions = total;
371
494
  this.state.totalDynOptions = total;
@@ -392,7 +515,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
392
515
  this.buildFilteredOptions();
393
516
  }
394
517
  changeTexts(texts) {
395
- this.labels = Object.assign({}, this.labels, texts);
518
+ this.data.labels = Object.assign({}, this.data.labels, texts);
396
519
  }
397
520
  /* }}} */
398
521
  /* {{{ private methods */
@@ -403,27 +526,53 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
403
526
  return !!this.getValue(id);
404
527
  }
405
528
  getValue(id) {
529
+ var _a, _b;
406
530
  function findId(option) {
407
531
  return option.id === id;
408
532
  }
409
533
  return this.state.filteredOptions.find(findId) ||
410
534
  this.state.dynOptions.find(findId) ||
411
- this.getListOptions().find(findId) ||
412
- this.getElementOptions().find(findId);
535
+ ((_a = this.listOptions.value) !== null && _a !== void 0 ? _a : this.listOptions).find(findId) ||
536
+ ((_b = this.elementOptions.value) !== null && _b !== void 0 ? _b : this.elementOptions).find(findId);
413
537
  }
414
- assertCorrectValue(forceStrict = false) {
538
+ convertTypeValue(oldValue) {
539
+ const state = this.state;
540
+ const isMultiple = state.multiple;
541
+ let newValue = oldValue;
542
+ if (isMultiple) {
543
+ if (!Array.isArray(oldValue)) {
544
+ newValue = oldValue === null ? [] : [oldValue];
545
+ }
546
+ }
547
+ else {
548
+ if (Array.isArray(oldValue)) {
549
+ const value = oldValue[0];
550
+ newValue = typeof value === 'undefined' ? null : value;
551
+ }
552
+ }
553
+ return newValue;
554
+ }
555
+ assertValueType() {
415
556
  const state = this.state;
416
557
  const internalValue = state.internalValue;
558
+ const newValue = this.convertTypeValue(internalValue);
559
+ if (newValue !== internalValue) {
560
+ state.internalValue = newValue;
561
+ }
562
+ }
563
+ assertCorrectValue(applyStrict = false) {
564
+ var _a, _b;
565
+ const state = this.state;
566
+ this.assertValueType();
567
+ const internalValue = state.internalValue;
417
568
  const selectionIsExcluded = state.selectionIsExcluded;
418
569
  const isMultiple = state.multiple;
419
570
  const checkStrict = state.strictValue;
420
571
  let newValue = internalValue;
421
- const isPartial = this.isPartial;
572
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
422
573
  if (isMultiple) {
423
- if (!Array.isArray(internalValue)) {
424
- newValue = internalValue === null ? [] : [internalValue];
425
- }
426
- if (selectionIsExcluded && this.hasFetchedAllItems) {
574
+ const hasFetchedAllItems = (_b = this.hasFetchedAllItems.value) !== null && _b !== void 0 ? _b : this.hasFetchedAllItems;
575
+ if (selectionIsExcluded && hasFetchedAllItems) {
427
576
  newValue = state.allOptions.reduce((values, option) => {
428
577
  const id = option.id;
429
578
  if (!internalValue.includes(id)) {
@@ -435,10 +584,6 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
435
584
  }
436
585
  }
437
586
  else {
438
- if (Array.isArray(internalValue)) {
439
- const value = internalValue[0];
440
- newValue = typeof value === 'undefined' ? null : value;
441
- }
442
587
  state.selectionIsExcluded = false;
443
588
  }
444
589
  if (checkStrict) {
@@ -448,16 +593,18 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
448
593
  filteredValue = newValue
449
594
  .filter((value) => this.hasItemInStore(value));
450
595
  isDifferent = filteredValue.length !== newValue.length;
451
- if (isDifferent && isPartial && !forceStrict) {
452
- this.getItems(newValue).then(() => this.assertCorrectValue(true));
596
+ if (isDifferent && isPartial && !applyStrict) {
597
+ this.getItems(newValue)
598
+ .then(() => this.assertCorrectValue(true));
453
599
  return;
454
600
  }
455
601
  }
456
- else if (!this.hasItemInStore(newValue)) {
602
+ else if (newValue !== null && !this.hasItemInStore(newValue)) {
457
603
  filteredValue = null;
458
604
  isDifferent = true;
459
- if (isPartial && !forceStrict) {
460
- this.getItems([newValue]).then(() => this.assertCorrectValue(true));
605
+ if (isPartial && !applyStrict) {
606
+ this.getItems([newValue])
607
+ .then(() => this.assertCorrectValue(true));
461
608
  return;
462
609
  }
463
610
  }
@@ -471,8 +618,9 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
471
618
  }
472
619
  }
473
620
  updateFilteredOptions() {
474
- if (!this.doNotUpdate) {
621
+ if (!this.data.doNotUpdate) {
475
622
  this.state.filteredOptions = this.buildItems(this.state.filteredOptions);
623
+ this.buildSelectedOptions();
476
624
  }
477
625
  }
478
626
  addGroups(groups) {
@@ -480,13 +628,14 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
480
628
  this.state.groups.set(group.id, group.text);
481
629
  });
482
630
  }
483
- /* XXX: This is not a computed property to avoid consuming more memory */
631
+ /* This method is for the computed property listOptions */
484
632
  getListOptions() {
485
- const options = this.options;
633
+ const options = this.props.options;
486
634
  const listOptions = [];
487
635
  if (!Array.isArray(options)) {
488
636
  return listOptions;
489
637
  }
638
+ const state = this.state;
490
639
  options.forEach((option) => {
491
640
  /* manage simple string */
492
641
  if (typeof option === 'string') {
@@ -499,13 +648,13 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
499
648
  const group = option.group;
500
649
  const subOptions = option.options;
501
650
  /* check for groups */
502
- if (group && !this.state.groups.has(group)) {
503
- this.state.groups.set(group, String(group));
651
+ if (group && !state.groups.has(group)) {
652
+ state.groups.set(group, String(group));
504
653
  }
505
654
  /* check for sub options */
506
655
  if (subOptions) {
507
656
  const groupId = option.id;
508
- this.state.groups.set(groupId, option.text);
657
+ state.groups.set(groupId, option.text);
509
658
  subOptions.forEach((subOpt) => {
510
659
  subOpt.group = groupId;
511
660
  });
@@ -516,24 +665,25 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
516
665
  });
517
666
  return listOptions;
518
667
  }
519
- /* XXX: This is not a computed property to avoid consuming more memory */
668
+ /* This method is for the computed property elementOptions */
520
669
  getElementOptions() {
521
- const options = this.childOptions;
670
+ const options = this.props.childOptions;
522
671
  const childOptions = [];
523
- if (!Array.isArray(options)) {
672
+ if (!Array.isArray(options) || options.length === 0) {
524
673
  return childOptions;
525
674
  }
675
+ const state = this.state;
526
676
  options.forEach((option) => {
527
677
  const group = option.group;
528
678
  const subOptions = option.options;
529
679
  /* check for groups */
530
- if (group && !this.state.groups.has(group)) {
531
- this.state.groups.set(group, String(group));
680
+ if (group && !state.groups.has(group)) {
681
+ state.groups.set(group, String(group));
532
682
  }
533
683
  /* check for sub options */
534
684
  if (subOptions) {
535
685
  const groupId = option.id;
536
- this.state.groups.set(groupId, option.text);
686
+ state.groups.set(groupId, option.text);
537
687
  const sOpts = subOptions.map((subOpt) => {
538
688
  return Object.assign({}, subOpt, {
539
689
  group: groupId,
@@ -547,11 +697,13 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
547
697
  return childOptions;
548
698
  }
549
699
  buildAllOptions(keepFetched = false) {
700
+ var _a, _b, _c;
550
701
  const allOptions = [];
551
702
  let listOptions = [];
552
703
  let elementOptions = [];
553
704
  const optionBehaviorOrder = this.state.optionBehaviorOrder;
554
705
  let length = Infinity;
706
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
555
707
  const arrayFromOrder = (orderValue) => {
556
708
  switch (orderValue) {
557
709
  case 'O': return listOptions;
@@ -569,7 +721,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
569
721
  return 0;
570
722
  };
571
723
  if (!keepFetched) {
572
- if (this.isPartial) {
724
+ if (isPartial) {
573
725
  this.state.totalAllOptions = Infinity;
574
726
  this.state.totalDynOptions = Infinity;
575
727
  }
@@ -577,14 +729,14 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
577
729
  this.state.totalDynOptions = 0;
578
730
  }
579
731
  }
580
- listOptions = this.getListOptions();
581
- elementOptions = this.getElementOptions();
732
+ listOptions = (_b = this.listOptions.value) !== null && _b !== void 0 ? _b : this.listOptions;
733
+ elementOptions = (_c = this.elementOptions.value) !== null && _c !== void 0 ? _c : this.elementOptions;
582
734
  if (this.state.optionBehaviorOperation === 'force') {
583
735
  const orderValue = optionBehaviorOrder.find((value) => lengthFromOrder(value) > 0);
584
736
  allOptions.push(...arrayFromOrder(orderValue));
585
737
  length = lengthFromOrder(orderValue);
586
- this.activeOrder = orderValue;
587
- this.dynOffset = 0;
738
+ this.data.activeOrder = orderValue;
739
+ this.data.dynOffset = 0;
588
740
  }
589
741
  else {
590
742
  /* sort */
@@ -593,7 +745,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
593
745
  const list = arrayFromOrder(orderValue);
594
746
  const lngth = lengthFromOrder(orderValue);
595
747
  if (orderValue === 'D') {
596
- this.dynOffset = offset;
748
+ this.data.dynOffset = offset;
597
749
  }
598
750
  else {
599
751
  offset += lngth;
@@ -604,7 +756,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
604
756
  break;
605
757
  }
606
758
  }
607
- this.activeOrder = 'D';
759
+ this.data.activeOrder = 'D';
608
760
  length = optionBehaviorOrder.reduce((total, orderValue) => total + lengthFromOrder(orderValue), 0);
609
761
  }
610
762
  this.state.allOptions = allOptions;
@@ -612,15 +764,19 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
612
764
  this.state.totalAllOptions = length;
613
765
  }
614
766
  else {
615
- if (!this.isPartial) {
767
+ if (!isPartial) {
616
768
  this.state.totalAllOptions = allOptions.length;
617
769
  }
618
770
  }
619
771
  this.state.filteredOptions = [];
620
772
  this.state.totalFilteredOptions = Infinity;
621
- this.buildFilteredOptions();
773
+ this.buildFilteredOptions().then(() => {
774
+ /* XXX: To recompute for strict mode and auto-select */
775
+ this.assertCorrectValue();
776
+ });
622
777
  }
623
778
  async buildFilteredOptions() {
779
+ var _a, _b, _c, _d;
624
780
  if (!this.state.isOpen) {
625
781
  /* Do not try to fetch anything while the select is not open */
626
782
  return;
@@ -630,12 +786,14 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
630
786
  const totalAllOptions = this.state.totalAllOptions;
631
787
  const allOptionsLength = allOptions.length;
632
788
  let filteredOptionsLength = this.state.filteredOptions.length;
633
- if (this.hasAllItems) {
789
+ const hasAllItems = (_a = this.hasAllItems.value) !== null && _a !== void 0 ? _a : this.hasAllItems;
790
+ if (hasAllItems) {
634
791
  /* Everything has already been fetched and stored in filteredOptions */
635
792
  return;
636
793
  }
794
+ const hasFetchedAllItems = (_b = this.hasFetchedAllItems.value) !== null && _b !== void 0 ? _b : this.hasFetchedAllItems;
637
795
  /* Check if all options have been fetched */
638
- if (this.hasFetchedAllItems) {
796
+ if (hasFetchedAllItems) {
639
797
  if (!search) {
640
798
  this.state.filteredOptions = this.buildGroupItems(allOptions);
641
799
  this.state.totalFilteredOptions = this.state.filteredOptions.length;
@@ -648,7 +806,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
648
806
  }
649
807
  /* When we only have partial options */
650
808
  const offsetItem = this.state.offsetItem;
651
- const marginSize = this.marginSize;
809
+ const marginSize = (_c = this.marginSize.value) !== null && _c !== void 0 ? _c : this.marginSize;
652
810
  const endIndex = offsetItem + marginSize;
653
811
  if (endIndex <= filteredOptionsLength) {
654
812
  return;
@@ -656,7 +814,8 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
656
814
  if (!search && endIndex <= allOptionsLength) {
657
815
  this.state.filteredOptions = this.buildGroupItems(allOptions);
658
816
  this.state.totalFilteredOptions = totalAllOptions + this.state.groups.size;
659
- if (this.isPartial && this.state.totalDynOptions === Infinity) {
817
+ const isPartial = (_d = this.isPartial.value) !== null && _d !== void 0 ? _d : this.isPartial;
818
+ if (isPartial && this.state.totalDynOptions === Infinity) {
660
819
  this.fetchData();
661
820
  }
662
821
  return;
@@ -664,7 +823,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
664
823
  if (filteredOptionsLength === 0 && this.state.optionBehaviorOperation === 'sort') {
665
824
  this.addStaticFilteredOptions();
666
825
  filteredOptionsLength = this.state.filteredOptions.length;
667
- this.dynOffset = filteredOptionsLength;
826
+ this.data.dynOffset = filteredOptionsLength;
668
827
  if (endIndex <= filteredOptionsLength) {
669
828
  return;
670
829
  }
@@ -673,21 +832,22 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
673
832
  }
674
833
  async buildSelectedOptions() {
675
834
  const internalValue = this.state.internalValue;
676
- if (this.state.multiple) {
835
+ const state = this.state;
836
+ if (state.multiple) {
677
837
  /* display partial information about selected items */
678
- this.state.selectedOptions = this.buildSelectedItems(internalValue);
838
+ state.selectedOptions = this.buildSelectedItems(internalValue);
679
839
  const items = await this.getItems(internalValue).catch(() => []);
680
- if (internalValue !== this.state.internalValue) {
840
+ if (internalValue !== state.internalValue) {
681
841
  /* Values have been deprecated */
682
842
  return;
683
843
  }
684
844
  if (items.length !== internalValue.length) {
685
- if (!this.state.strictValue) {
686
- const updatedItems = this.state.selectedOptions.map((option) => {
845
+ if (!state.strictValue) {
846
+ const updatedItems = state.selectedOptions.map((option) => {
687
847
  const foundItem = items.find((item) => item.id === option.id);
688
848
  return foundItem || option;
689
849
  });
690
- this.state.selectedOptions = updatedItems;
850
+ state.selectedOptions = updatedItems;
691
851
  }
692
852
  else {
693
853
  const itemIds = items.map((item) => item.id);
@@ -696,54 +856,58 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
696
856
  return;
697
857
  }
698
858
  /* display full information about selected items */
699
- this.state.selectedOptions = items;
859
+ state.selectedOptions = items;
700
860
  }
701
861
  else if (internalValue === null) {
702
- this.state.selectedOptions = null;
862
+ state.selectedOptions = null;
703
863
  }
704
864
  else {
705
865
  /* display partial information about selected items */
706
- this.state.selectedOptions = this.buildSelectedItems([internalValue])[0];
866
+ state.selectedOptions = this.buildSelectedItems([internalValue])[0];
707
867
  const items = await this.getItems([internalValue]).catch(() => []);
708
- if (internalValue !== this.state.internalValue) {
868
+ if (internalValue !== state.internalValue) {
709
869
  /* Values have been deprecated */
710
870
  return;
711
871
  }
712
872
  if (!items.length) {
713
- if (this.state.strictValue) {
873
+ if (state.strictValue) {
714
874
  this.commit('internalValue', null);
715
875
  }
716
876
  return;
717
877
  }
718
878
  /* display full information about selected items */
719
- this.state.selectedOptions = items[0];
879
+ state.selectedOptions = items[0];
720
880
  }
721
881
  }
722
882
  async fetchData() {
883
+ var _a;
723
884
  const state = this.state;
724
- if (!this.fetchCallback) {
725
- state.status.errorMessage = this.labels.noFetchMethod;
885
+ const labels = this.data.labels;
886
+ const fetchCallback = this.props.fetchCallback;
887
+ if (!fetchCallback) {
888
+ state.status.errorMessage = labels.noFetchMethod;
726
889
  return;
727
890
  }
728
891
  const search = state.searchText;
729
892
  const filteredOptionsLength = state.filteredOptions.length;
730
893
  const offsetItem = state.offsetItem;
731
894
  const pageSize = state.pageSize;
732
- const marginSize = this.marginSize;
895
+ const marginSize = (_a = this.marginSize.value) !== null && _a !== void 0 ? _a : this.marginSize;
733
896
  const endIndex = offsetItem + marginSize;
897
+ const dynOffset = this.data.dynOffset;
734
898
  /* Run the query */
735
899
  this.state.status.searching = true;
736
900
  /* Manage cases where offsetItem is not equal to the last item received */
737
- const offset = filteredOptionsLength - this.nbGroups(state.filteredOptions) - this.dynOffset;
901
+ const offset = filteredOptionsLength - this.nbGroups(state.filteredOptions) - dynOffset;
738
902
  const nbItems = endIndex - offset;
739
903
  const limit = Math.ceil(nbItems / pageSize) * pageSize;
740
904
  try {
741
905
  const requestId = ++this.requestId;
742
- const { total: rTotal, result } = await this.fetchCallback(search, offset, limit);
906
+ const { total: rTotal, result } = await fetchCallback(search, offset, limit);
743
907
  let total = rTotal;
744
908
  /* Assert result is correctly formatted */
745
909
  if (!Array.isArray(result)) {
746
- throw new Error(this.labels.wrongFormattedData);
910
+ throw new Error(labels.wrongFormattedData);
747
911
  }
748
912
  /* Handle case where total is not returned */
749
913
  if (typeof total !== 'number') {
@@ -757,7 +921,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
757
921
  /* update cache */
758
922
  state.totalDynOptions = total;
759
923
  state.dynOptions.splice(offset, limit, ...result);
760
- this.$nextTick(() => this.buildAllOptions(true));
924
+ setTimeout(() => this.buildAllOptions(true), 0);
761
925
  }
762
926
  /* Check request is not obsolete */
763
927
  if (requestId !== this.requestId) {
@@ -770,13 +934,13 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
770
934
  const previousItem = state.filteredOptions[filteredOptionsLength - 1];
771
935
  const options = this.buildGroupItems(result, previousItem);
772
936
  const nbGroups1 = this.nbGroups(options);
773
- state.filteredOptions.splice(offset + this.dynOffset, limit + nbGroups1, ...options);
937
+ state.filteredOptions.splice(offset + dynOffset, limit + nbGroups1, ...options);
774
938
  }
775
939
  let nbGroups = state.groups.size;
776
940
  if (offset + limit >= total) {
777
941
  nbGroups = this.nbGroups(state.filteredOptions);
778
942
  }
779
- state.totalFilteredOptions = total + nbGroups + this.dynOffset;
943
+ state.totalFilteredOptions = total + nbGroups + dynOffset;
780
944
  if (search && state.totalFilteredOptions <= state.filteredOptions.length) {
781
945
  this.addStaticFilteredOptions(true);
782
946
  }
@@ -800,6 +964,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
800
964
  return this.buildGroupItems(options.filter((option) => rgx.test(option.text)));
801
965
  }
802
966
  addStaticFilteredOptions(fromDynamic = false) {
967
+ var _a, _b;
803
968
  const search = this.state.searchText;
804
969
  let continueLoop = fromDynamic;
805
970
  if (this.state.optionBehaviorOperation !== 'sort') {
@@ -819,10 +984,10 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
819
984
  }
820
985
  switch (order) {
821
986
  case 'O':
822
- options = this.filterOptions(this.getListOptions(), search);
987
+ options = this.filterOptions((_a = this.listOptions.value) !== null && _a !== void 0 ? _a : this.listOptions, search);
823
988
  break;
824
989
  case 'E':
825
- options = this.filterOptions(this.getElementOptions(), search);
990
+ options = this.filterOptions((_b = this.elementOptions.value) !== null && _b !== void 0 ? _b : this.elementOptions, search);
826
991
  break;
827
992
  }
828
993
  this.state.filteredOptions.push(...options);
@@ -831,7 +996,8 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
831
996
  }
832
997
  buildSelectedItems(ids) {
833
998
  return this.buildItems(ids.map((id) => {
834
- const item = this.cacheItem.get(id);
999
+ const cacheItem = this.data.cacheItem;
1000
+ const item = cacheItem.get(id);
835
1001
  return item || {
836
1002
  id,
837
1003
  text: String(id),
@@ -839,11 +1005,12 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
839
1005
  }));
840
1006
  }
841
1007
  hasItemInStore(id) {
842
- let item = this.cacheItem.get(id);
1008
+ const cacheItem = this.data.cacheItem;
1009
+ let item = cacheItem.get(id);
843
1010
  if (!item) {
844
1011
  item = this.getValue(id);
845
1012
  if (item) {
846
- this.cacheItem.set(item.id, item);
1013
+ cacheItem.set(item.id, item);
847
1014
  }
848
1015
  }
849
1016
  return !!item;
@@ -860,7 +1027,7 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
860
1027
  disabled: false,
861
1028
  isGroup: false,
862
1029
  }, option, {
863
- // tslint:disable-next-line:no-bitwise
1030
+ /* eslint-disable-next-line no-bitwise */
864
1031
  selected: !!(+selected.includes(id) ^ selectionIsExcluded),
865
1032
  });
866
1033
  });
@@ -892,7 +1059,8 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
892
1059
  isValid = isValid && ['sort', 'force'].includes(operation);
893
1060
  isValid = isValid && /^[ODE]+$/.test(order);
894
1061
  if (!isValid) {
895
- this.state.status.errorMessage = this.labels.unknownPropertyValue.replace(/%s/, 'optionBehavior');
1062
+ const labels = this.data.labels;
1063
+ this.state.status.errorMessage = labels.unknownPropertyValue.replace(/%s/, 'optionBehavior');
896
1064
  operation = 'sort';
897
1065
  orderArray = ['O', 'D', 'E'];
898
1066
  }
@@ -919,14 +1087,18 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
919
1087
  for (const option of options) {
920
1088
  if (!option.disabled) {
921
1089
  this.selectItem(option.id, true, true);
1090
+ this.checkAutoDisabled();
922
1091
  return;
923
1092
  }
924
1093
  }
925
1094
  }
926
1095
  checkAutoDisabled() {
1096
+ var _a, _b;
927
1097
  const state = this.state;
928
- const doNotCheck = this.disabled || this.isPartial || !state.autoDisabled;
929
- if (doNotCheck || !this.hasFetchedAllItems) {
1098
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
1099
+ const doNotCheck = isPartial || this.props.disabled || !state.autoDisabled;
1100
+ const hasFetchedAllItems = (_b = this.hasFetchedAllItems.value) !== null && _b !== void 0 ? _b : this.hasFetchedAllItems;
1101
+ if (doNotCheck || !hasFetchedAllItems) {
930
1102
  return;
931
1103
  }
932
1104
  const enabledOptions = state.allOptions.filter((opt) => !opt.disabled);
@@ -946,174 +1118,33 @@ let SelecticStore = class SelecticStore extends vtyx.Vue {
946
1118
  }
947
1119
  }
948
1120
  checkHideFilter() {
949
- if (this.params && this.params.hideFilter !== 'auto') {
1121
+ var _a;
1122
+ const params = this.props.params;
1123
+ if (params && params.hideFilter !== 'auto') {
950
1124
  return;
951
1125
  }
952
1126
  const state = this.state;
953
- if (state.multiple || this.isPartial) {
1127
+ const isPartial = (_a = this.isPartial.value) !== null && _a !== void 0 ? _a : this.isPartial;
1128
+ if (state.multiple || isPartial) {
954
1129
  state.hideFilter = false;
955
1130
  }
956
1131
  else {
957
- state.hideFilter = state.totalAllOptions <= this.itemsPerPage;
1132
+ state.hideFilter = state.totalAllOptions <= this.data.itemsPerPage;
958
1133
  }
959
1134
  }
960
- /* }}} */
961
- /* }}} */
962
- /* {{{ watch */
963
- onOptionsChange(options = [], oldOptions = []) {
964
- if (JSON.stringify(options) === JSON.stringify(oldOptions)) {
965
- /* There is no real difference, only a change of reference */
966
- return;
967
- }
968
- this.cacheItem.clear();
969
- this.commit('isOpen', false);
970
- this.buildAllOptions(true);
971
- this.assertCorrectValue();
972
- this.buildSelectedOptions();
973
- }
974
- onChildOptionsChange(childOptions = [], oldChildOptions = []) {
975
- if (JSON.stringify(childOptions) === JSON.stringify(oldChildOptions)) {
976
- /* There is no real difference, only a change of reference */
977
- return;
978
- }
979
- this.cacheItem.clear();
980
- this.commit('isOpen', false);
981
- this.buildAllOptions(true);
982
- this.assertCorrectValue();
983
- this.buildSelectedOptions();
984
- }
985
- onValueChange() {
986
- const value = typeof this.value === 'undefined' ? null : this.value;
987
- this.commit('internalValue', value);
988
- }
989
- onSelectionExcludedChange() {
990
- this.commit('selectionIsExcluded', this.selectionIsExcluded);
991
- }
992
- onDisabledChange() {
993
- this.commit('disabled', this.disabled);
994
- }
995
- onFilteredChange() {
996
- let areAllSelected = false;
997
- if (this.hasAllItems) {
998
- const selectionIsExcluded = +this.state.selectionIsExcluded;
999
- // tslint:disable-next-line:no-bitwise
1000
- areAllSelected = this.state.filteredOptions.every((item) => !!(+item.selected ^ selectionIsExcluded));
1001
- }
1002
- this.state.status.areAllSelected = areAllSelected;
1003
- }
1004
- onInternalValueChange() {
1005
- this.buildSelectedOptions();
1006
- }
1007
- onAllOptionChange() {
1008
- this.checkAutoSelect();
1009
- this.checkAutoDisabled();
1010
- }
1011
- onTotalAllOptionsChange() {
1012
- this.checkHideFilter();
1013
- }
1014
- /* }}} */
1015
- /* {{{ life cycles methods */
1016
- created() {
1017
- const value = typeof this.value === 'undefined' ? null : this.value;
1018
- /* set initial value for non reactive attribute */
1019
- this.requestId = 0;
1020
- this.cacheRequest = new Map();
1021
- const stateParam = Object.assign({}, this.params);
1022
- if (stateParam.optionBehavior) {
1023
- this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
1024
- delete stateParam.optionBehavior;
1025
- }
1026
- this.state = Object.assign(this.state, stateParam, {
1027
- internalValue: value,
1028
- selectionIsExcluded: this.selectionIsExcluded,
1029
- disabled: this.disabled,
1030
- });
1031
- this.checkHideFilter();
1032
- if (this.texts) {
1033
- this.changeTexts(this.texts);
1034
- }
1035
- this.addGroups(this.groups);
1036
- this.buildAllOptions();
1037
- this.assertCorrectValue();
1038
- this.buildSelectedOptions();
1039
- }
1040
- };
1041
- __decorate([
1042
- vtyx.Prop()
1043
- ], SelecticStore.prototype, "value", void 0);
1044
- __decorate([
1045
- vtyx.Prop({ default: false })
1046
- ], SelecticStore.prototype, "selectionIsExcluded", void 0);
1047
- __decorate([
1048
- vtyx.Prop({ default: false })
1049
- ], SelecticStore.prototype, "disabled", void 0);
1050
- __decorate([
1051
- vtyx.Prop()
1052
- ], SelecticStore.prototype, "options", void 0);
1053
- __decorate([
1054
- vtyx.Prop()
1055
- ], SelecticStore.prototype, "childOptions", void 0);
1056
- __decorate([
1057
- vtyx.Prop({ default: () => [] })
1058
- ], SelecticStore.prototype, "groups", void 0);
1059
- __decorate([
1060
- vtyx.Prop()
1061
- ], SelecticStore.prototype, "texts", void 0);
1062
- __decorate([
1063
- vtyx.Prop()
1064
- ], SelecticStore.prototype, "params", void 0);
1065
- __decorate([
1066
- vtyx.Prop()
1067
- ], SelecticStore.prototype, "fetchCallback", void 0);
1068
- __decorate([
1069
- vtyx.Prop()
1070
- ], SelecticStore.prototype, "getItemsCallback", void 0);
1071
- __decorate([
1072
- vtyx.Prop({ default: false })
1073
- ], SelecticStore.prototype, "keepOpenWithOtherSelectic", void 0);
1074
- __decorate([
1075
- vtyx.Watch('options')
1076
- ], SelecticStore.prototype, "onOptionsChange", null);
1077
- __decorate([
1078
- vtyx.Watch('childOptions')
1079
- ], SelecticStore.prototype, "onChildOptionsChange", null);
1080
- __decorate([
1081
- vtyx.Watch('value')
1082
- ], SelecticStore.prototype, "onValueChange", null);
1083
- __decorate([
1084
- vtyx.Watch('selectionIsExcluded')
1085
- ], SelecticStore.prototype, "onSelectionExcludedChange", null);
1086
- __decorate([
1087
- vtyx.Watch('disabled')
1088
- ], SelecticStore.prototype, "onDisabledChange", null);
1089
- __decorate([
1090
- vtyx.Watch('state.filteredOptions')
1091
- ], SelecticStore.prototype, "onFilteredChange", null);
1092
- __decorate([
1093
- vtyx.Watch('state.internalValue')
1094
- ], SelecticStore.prototype, "onInternalValueChange", null);
1095
- __decorate([
1096
- vtyx.Watch('state.allOptions')
1097
- ], SelecticStore.prototype, "onAllOptionChange", null);
1098
- __decorate([
1099
- vtyx.Watch('state.totalAllOptions')
1100
- ], SelecticStore.prototype, "onTotalAllOptionsChange", null);
1101
- SelecticStore = __decorate([
1102
- vtyx.Component
1103
- ], SelecticStore);
1104
- var Store = SelecticStore;
1135
+ }
1105
1136
 
1106
1137
  /* File Purpose:
1107
1138
  * It displays the core element which is always visible (where selection is
1108
1139
  * displayed) and handles all interaction with it.
1109
1140
  */
1110
- var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
1141
+ var __decorate$4 = (this && this.__decorate) || function (decorators, target, key, desc) {
1111
1142
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1112
1143
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1113
1144
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1114
1145
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1115
1146
  };
1116
- let Selectic = class Selectic extends vtyx.Vue {
1147
+ let MainInput = class MainInput extends vtyx.Vue {
1117
1148
  constructor() {
1118
1149
  super(...arguments);
1119
1150
  /* }}} */
@@ -1159,7 +1190,7 @@ let Selectic = class Selectic extends vtyx.Vue {
1159
1190
  get clearedLabel() {
1160
1191
  const isMultiple = this.store.state.multiple;
1161
1192
  const labelKey = isMultiple ? 'clearSelections' : 'clearSelection';
1162
- return this.store.labels[labelKey];
1193
+ return this.store.data.labels[labelKey];
1163
1194
  }
1164
1195
  get singleSelectedItem() {
1165
1196
  const state = this.store.state;
@@ -1185,7 +1216,7 @@ let Selectic = class Selectic extends vtyx.Vue {
1185
1216
  }
1186
1217
  get reverseSelectionLabel() {
1187
1218
  const labelKey = 'reverseSelection';
1188
- return this.store.labels[labelKey];
1219
+ return this.store.data.labels[labelKey];
1189
1220
  }
1190
1221
  get formatItem() {
1191
1222
  const formatSelection = this.store.state.formatSelection;
@@ -1222,8 +1253,9 @@ let Selectic = class Selectic extends vtyx.Vue {
1222
1253
  if (!store.state.multiple || nbHiddenItems === 0) {
1223
1254
  return '';
1224
1255
  }
1225
- const text = nbHiddenItems === 1 ? store.labels.moreSelectedItem
1226
- : store.labels.moreSelectedItems;
1256
+ const labels = store.data.labels;
1257
+ const text = nbHiddenItems === 1 ? labels.moreSelectedItem
1258
+ : labels.moreSelectedItems;
1227
1259
  return text.replace(/%d/, nbHiddenItems.toString());
1228
1260
  }
1229
1261
  get moreSelectedTitle() {
@@ -1305,59 +1337,58 @@ let Selectic = class Selectic extends vtyx.Vue {
1305
1337
  }
1306
1338
  /* }}} */
1307
1339
  render() {
1308
- const h = this.renderWrapper();
1309
- return (h("div", { class: "has-feedback", on: {
1340
+ return (vtyx.h("div", { class: "has-feedback", on: {
1310
1341
  'click.prevent.stop': () => this.toggleFocus(),
1311
1342
  } },
1312
- h("div", { id: this.selecticId, class: ['selectic-input form-control',
1343
+ vtyx.h("div", { id: this.selecticId, class: ['selectic-input form-control',
1313
1344
  {
1314
1345
  focused: this.store.state.isOpen,
1315
1346
  disabled: this.store.state.disabled,
1316
1347
  }] },
1317
- this.hasValue && !this.store.state.multiple && (h("span", { class: "selectic-item_text", style: this.singleStyle, title: this.singleSelectedItem || '' }, this.singleSelectedItem)),
1318
- this.displayPlaceholder && (h("span", { class: [
1348
+ this.hasValue && !this.store.state.multiple && (vtyx.h("span", { class: "selectic-item_text", style: this.singleStyle, title: this.singleSelectedItem || '' }, this.singleSelectedItem)),
1349
+ this.displayPlaceholder && (vtyx.h("span", { class: [
1319
1350
  'selectic-input__selected-items__placeholder',
1320
1351
  'selectic-item_text',
1321
1352
  ], title: this.store.state.placeholder }, this.store.state.placeholder)),
1322
- this.store.state.multiple && (h("div", { class: "selectic-input__selected-items", ref: "selectedItems" },
1323
- this.isSelectionReversed && (h("span", { class: "fa fa-strikethrough selectic-input__reverse-icon", title: this.reverseSelectionLabel })),
1324
- this.showSelectedOptions.map((item) => (h("div", { class: "single-value", style: item.style, title: item.text, on: {
1353
+ this.store.state.multiple && (vtyx.h("div", { class: "selectic-input__selected-items", ref: "selectedItems" },
1354
+ this.isSelectionReversed && (vtyx.h("span", { class: "fa fa-strikethrough selectic-input__reverse-icon", title: this.reverseSelectionLabel })),
1355
+ this.showSelectedOptions.map((item) => (vtyx.h("div", { class: "single-value", style: item.style, title: item.text, on: {
1325
1356
  click: () => this.$emit('item:click', item.id),
1326
1357
  } },
1327
- h("span", { class: "selectic-input__selected-items__value" }, item.text),
1328
- !this.isDisabled && (h("span", { class: "fa fa-times selectic-input__selected-items__icon", on: {
1358
+ vtyx.h("span", { class: "selectic-input__selected-items__value" }, item.text),
1359
+ !this.isDisabled && (vtyx.h("span", { class: "fa fa-times selectic-input__selected-items__icon", on: {
1329
1360
  'click.prevent.stop': () => this.selectItem(item.id),
1330
1361
  } }))))),
1331
- this.moreSelectedNb && (h("div", { class: "single-value more-items", title: this.moreSelectedTitle }, this.moreSelectedNb)))),
1332
- this.showClearAll && (h("span", { class: "fa fa-times selectic-input__clear-icon", title: this.clearedLabel, on: { 'click.prevent.stop': this.clearSelection } }))),
1333
- h("div", { class: [
1362
+ this.moreSelectedNb && (vtyx.h("div", { class: "single-value more-items", title: this.moreSelectedTitle }, this.moreSelectedNb)))),
1363
+ this.showClearAll && (vtyx.h("span", { class: "fa fa-times selectic-input__clear-icon", title: this.clearedLabel, on: { 'click.prevent.stop': this.clearSelection } }))),
1364
+ vtyx.h("div", { class: [
1334
1365
  'selectic__icon-container',
1335
1366
  'form-control-feedback',
1336
1367
  { focused: this.store.state.isOpen }
1337
1368
  ], on: {
1338
1369
  'click.prevent.stop': () => this.toggleFocus(),
1339
1370
  } },
1340
- h("span", { class: "fa fa-caret-down selectic-icon" }))));
1371
+ vtyx.h("span", { class: "fa fa-caret-down selectic-icon" }))));
1341
1372
  }
1342
1373
  };
1343
- __decorate$1([
1374
+ __decorate$4([
1344
1375
  vtyx.Prop()
1345
- ], Selectic.prototype, "store", void 0);
1346
- __decorate$1([
1376
+ ], MainInput.prototype, "store", void 0);
1377
+ __decorate$4([
1347
1378
  vtyx.Prop({ default: '' })
1348
- ], Selectic.prototype, "id", void 0);
1349
- __decorate$1([
1379
+ ], MainInput.prototype, "id", void 0);
1380
+ __decorate$4([
1350
1381
  vtyx.Watch('store.state.internalValue')
1351
- ], Selectic.prototype, "onInternalChange", null);
1352
- Selectic = __decorate$1([
1382
+ ], MainInput.prototype, "onInternalChange", null);
1383
+ MainInput = __decorate$4([
1353
1384
  vtyx.Component
1354
- ], Selectic);
1355
- var MainInput = Selectic;
1385
+ ], MainInput);
1386
+ var MainInput$1 = MainInput;
1356
1387
 
1357
1388
  /* File Purpose:
1358
1389
  * It manages all controls which can filter the data.
1359
1390
  */
1360
- var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) {
1391
+ var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) {
1361
1392
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1362
1393
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1363
1394
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -1373,7 +1404,7 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1373
1404
  /* }}} */
1374
1405
  /* {{{ computed */
1375
1406
  get searchPlaceholder() {
1376
- return this.store.labels.searchPlaceholder;
1407
+ return this.store.data.labels.searchPlaceholder;
1377
1408
  }
1378
1409
  get selectionIsExcluded() {
1379
1410
  return this.store.state.selectionIsExcluded;
@@ -1383,12 +1414,12 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1383
1414
  const state = store.state;
1384
1415
  const isMultiple = state.multiple;
1385
1416
  const hasItems = state.filteredOptions.length === 0;
1386
- const canNotSelect = !!state.searchText && !store.hasAllItems;
1417
+ const canNotSelect = !!state.searchText && !store.hasAllItems.value;
1387
1418
  return !isMultiple || hasItems || canNotSelect;
1388
1419
  }
1389
1420
  get disableRevert() {
1390
1421
  const store = this.store;
1391
- return !store.state.multiple || !store.hasFetchedAllItems;
1422
+ return !store.state.multiple || !store.hasFetchedAllItems.value;
1392
1423
  }
1393
1424
  get enableRevert() {
1394
1425
  const state = this.store.state;
@@ -1408,11 +1439,11 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1408
1439
  return;
1409
1440
  }
1410
1441
  this.closed = false;
1411
- el.value += key;
1412
- this.store.commit('searchText', el.value);
1413
- setTimeout(() => {
1414
- el.focus();
1415
- }, 0);
1442
+ if (el) {
1443
+ el.value += key;
1444
+ this.store.commit('searchText', el.value);
1445
+ }
1446
+ this.getFocus();
1416
1447
  }
1417
1448
  }
1418
1449
  onInput(evt) {
@@ -1429,8 +1460,9 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1429
1460
  this.closed = !this.closed;
1430
1461
  }
1431
1462
  getFocus() {
1432
- if (!this.closed) {
1433
- setTimeout(() => this.$refs.filterInput.focus(), 0);
1463
+ const el = this.$refs.filterInput;
1464
+ if (!this.closed && el) {
1465
+ setTimeout(() => el.focus(), 0);
1434
1466
  }
1435
1467
  }
1436
1468
  /* }}} */
@@ -1450,51 +1482,50 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1450
1482
  }
1451
1483
  /* }}} */
1452
1484
  render() {
1453
- const h = this.renderWrapper();
1454
- return (h("div", { class: "filter-panel" },
1455
- h("div", { class: {
1485
+ return (vtyx.h("div", { class: "filter-panel" },
1486
+ vtyx.h("div", { class: {
1456
1487
  panelclosed: this.closed,
1457
1488
  panelopened: !this.closed,
1458
1489
  } },
1459
- h("div", { class: "filter-panel__input form-group has-feedback" },
1460
- h("input", { type: "text", class: "form-control filter-input", placeholder: this.searchPlaceholder, value: this.store.state.searchText, on: {
1490
+ vtyx.h("div", { class: "filter-panel__input form-group has-feedback" },
1491
+ vtyx.h("input", { type: "text", class: "form-control filter-input", placeholder: this.searchPlaceholder, value: this.store.state.searchText, on: {
1461
1492
  'input.stop.prevent': this.onInput,
1462
1493
  }, ref: "filterInput" }),
1463
- h("span", { class: "fa fa-search selectic-search-scope\n form-control-feedback" })),
1464
- this.store.state.multiple && (h("div", { class: "toggle-selectic" },
1465
- h("label", { class: ['control-label', {
1494
+ vtyx.h("span", { class: "fa fa-search selectic-search-scope\n form-control-feedback" })),
1495
+ this.store.state.multiple && (vtyx.h("div", { class: "toggle-selectic" },
1496
+ vtyx.h("label", { class: ['control-label', {
1466
1497
  'selectic__label-disabled': this.disableSelectAll,
1467
1498
  }] },
1468
- h("input", { type: "checkbox", checked: this.store.state.status.areAllSelected, disabled: this.disableSelectAll, on: {
1499
+ vtyx.h("input", { type: "checkbox", checked: this.store.state.status.areAllSelected, disabled: this.disableSelectAll, on: {
1469
1500
  change: this.onSelectAll,
1470
1501
  } }),
1471
- this.store.labels.selectAll))),
1472
- this.enableRevert && (h("div", { class: ['toggle-selectic', {
1502
+ this.store.data.labels.selectAll))),
1503
+ this.enableRevert && (vtyx.h("div", { class: ['toggle-selectic', {
1473
1504
  'selectic__label-disabled': this.disableRevert,
1474
1505
  }] },
1475
- h("label", { class: "control-label" },
1476
- h("input", { type: "checkbox", checked: this.selectionIsExcluded, disabled: this.disableRevert, on: {
1506
+ vtyx.h("label", { class: "control-label" },
1507
+ vtyx.h("input", { type: "checkbox", checked: this.selectionIsExcluded, disabled: this.disableRevert, on: {
1477
1508
  change: this.onExclude,
1478
1509
  } }),
1479
- this.store.labels.excludeResult)))),
1480
- h("div", { class: "curtain-handler", on: {
1510
+ this.store.data.labels.excludeResult)))),
1511
+ vtyx.h("div", { class: "curtain-handler", on: {
1481
1512
  'click.prevent.stop': this.togglePanel,
1482
1513
  } },
1483
- h("span", { class: "fa fa-search" }),
1484
- h("span", { class: {
1514
+ vtyx.h("span", { class: "fa fa-search" }),
1515
+ vtyx.h("span", { class: {
1485
1516
  'fa': true,
1486
1517
  'fa-caret-down': this.closed,
1487
1518
  'fa-caret-up': !this.closed,
1488
1519
  } }))));
1489
1520
  }
1490
1521
  };
1491
- __decorate$2([
1522
+ __decorate$3([
1492
1523
  vtyx.Prop()
1493
1524
  ], FilterPanel.prototype, "store", void 0);
1494
- __decorate$2([
1525
+ __decorate$3([
1495
1526
  vtyx.Watch('closed')
1496
1527
  ], FilterPanel.prototype, "onClosed", null);
1497
- FilterPanel = __decorate$2([
1528
+ FilterPanel = __decorate$3([
1498
1529
  vtyx.Component
1499
1530
  ], FilterPanel);
1500
1531
  var Filter = FilterPanel;
@@ -1503,7 +1534,7 @@ var Filter = FilterPanel;
1503
1534
  * It displays each item in an efficient way (optimizes DOM consumption).
1504
1535
  * It handles interactions with these items.
1505
1536
  */
1506
- var __decorate$3 = (this && this.__decorate) || function (decorators, target, key, desc) {
1537
+ var __decorate$2 = (this && this.__decorate) || function (decorators, target, key, desc) {
1507
1538
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1508
1539
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1509
1540
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -1527,7 +1558,9 @@ let List = class List extends vtyx.Vue {
1527
1558
  return this.store.state.multiple;
1528
1559
  }
1529
1560
  get itemsMargin() {
1530
- return this.store.marginSize;
1561
+ var _a;
1562
+ /* XXX: I don't really know when we should use value or not... */
1563
+ return (_a = this.store.marginSize.value) !== null && _a !== void 0 ? _a : this.store.marginSize;
1531
1564
  }
1532
1565
  get shortOptions() {
1533
1566
  const endIndex = this.endIndex;
@@ -1559,7 +1592,7 @@ let List = class List extends vtyx.Vue {
1559
1592
  }
1560
1593
  get startIndex() {
1561
1594
  const endIndex = this.endIndex;
1562
- const idx = endIndex - this.store.itemsPerPage - 3 * this.itemsMargin;
1595
+ const idx = endIndex - this.store.data.itemsPerPage - 3 * this.itemsMargin;
1563
1596
  return Math.max(0, idx);
1564
1597
  }
1565
1598
  get leftItems() {
@@ -1603,7 +1636,8 @@ let List = class List extends vtyx.Vue {
1603
1636
  const scrollTop = this.$refs.elList.scrollTop;
1604
1637
  const topIndex = Math.floor(scrollTop / this.itemHeight);
1605
1638
  const total = this.totalItems;
1606
- const bottomIndex = Math.min(topIndex + this.store.itemsPerPage, total);
1639
+ const itemsPerPage = this.store.data.itemsPerPage;
1640
+ const bottomIndex = Math.min(topIndex + itemsPerPage, total);
1607
1641
  this.debounce(() => this.store.commit('offsetItem', bottomIndex));
1608
1642
  this.computeGroupId(topIndex);
1609
1643
  }
@@ -1671,12 +1705,11 @@ let List = class List extends vtyx.Vue {
1671
1705
  }
1672
1706
  /* }}} */
1673
1707
  render() {
1674
- const h = this.renderWrapper();
1675
- return (h("ul", { on: {
1708
+ return (vtyx.h("ul", { on: {
1676
1709
  scroll: this.checkOffset,
1677
1710
  }, ref: "elList" },
1678
- !!this.topOffset && (h("li", { class: "selectic-item", style: `height:${this.topOffset}px;` })),
1679
- this.shortOptions.map((option, idx) => (h("li", { on: {
1711
+ !!this.topOffset && (vtyx.h("li", { class: "selectic-item", style: `height:${this.topOffset}px;` })),
1712
+ this.shortOptions.map((option, idx) => (vtyx.h("li", { on: {
1680
1713
  'click.prevent.stop': () => this.click(option),
1681
1714
  'mouseover': () => this.onMouseOver(idx),
1682
1715
  }, class: ['selectic-item', option.className || '', {
@@ -1686,28 +1719,28 @@ let List = class List extends vtyx.Vue {
1686
1719
  'selectic-item__is-in-group': !!option.group,
1687
1720
  'selectic-item__is-group': option.isGroup,
1688
1721
  }], style: option.style, title: option.title, key: 'selectic-item-' + (idx + this.startIndex) },
1689
- this.isMultiple && (h("span", { class: "fa fa-fw fa-check selectic-item_icon" })),
1690
- option.icon && (h("span", { class: option.icon })),
1722
+ this.isMultiple && (vtyx.h("span", { class: "fa fa-fw fa-check selectic-item_icon" })),
1723
+ option.icon && (vtyx.h("span", { class: option.icon })),
1691
1724
  option.text))),
1692
- !!this.bottomOffset && (h("li", { class: "selectic-item", style: `height:${this.bottomOffset}px;` }))));
1725
+ !!this.bottomOffset && (vtyx.h("li", { class: "selectic-item", style: `height:${this.bottomOffset}px;` }))));
1693
1726
  }
1694
1727
  };
1695
- __decorate$3([
1728
+ __decorate$2([
1696
1729
  vtyx.Prop()
1697
1730
  ], List.prototype, "store", void 0);
1698
- __decorate$3([
1731
+ __decorate$2([
1699
1732
  vtyx.Watch('store.state.activeItemIdx')
1700
1733
  ], List.prototype, "onIndexChange", null);
1701
- __decorate$3([
1734
+ __decorate$2([
1702
1735
  vtyx.Watch('store.state.offsetItem')
1703
1736
  ], List.prototype, "onOffsetChange", null);
1704
- __decorate$3([
1737
+ __decorate$2([
1705
1738
  vtyx.Watch('filteredOptions')
1706
1739
  ], List.prototype, "onFilteredOptionsChange", null);
1707
- __decorate$3([
1740
+ __decorate$2([
1708
1741
  vtyx.Watch('groupId')
1709
1742
  ], List.prototype, "onGroupIdChange", null);
1710
- List = __decorate$3([
1743
+ List = __decorate$2([
1711
1744
  vtyx.Component
1712
1745
  ], List);
1713
1746
  var List$1 = List;
@@ -1716,7 +1749,7 @@ var List$1 = List;
1716
1749
  * It manages the panel which is displayed when Selectic is open.
1717
1750
  * Content of inner elements are related to dedicated files.
1718
1751
  */
1719
- var __decorate$4 = (this && this.__decorate) || function (decorators, target, key, desc) {
1752
+ var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
1720
1753
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1721
1754
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1722
1755
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -1735,7 +1768,7 @@ let ExtendedList = class ExtendedList extends vtyx.Vue {
1735
1768
  /* }}} */
1736
1769
  /* {{{ computed */
1737
1770
  get searchingLabel() {
1738
- return this.store.labels.searching;
1771
+ return this.store.data.labels.searching;
1739
1772
  }
1740
1773
  get searching() {
1741
1774
  return this.store.state.status.searching;
@@ -1750,9 +1783,9 @@ let ExtendedList = class ExtendedList extends vtyx.Vue {
1750
1783
  const store = this.store;
1751
1784
  if (store.state.filteredOptions.length === 0) {
1752
1785
  if (store.state.searchText) {
1753
- return store.labels.noResult;
1786
+ return store.data.labels.noResult;
1754
1787
  }
1755
- return store.labels.noData;
1788
+ return store.data.labels.noData;
1756
1789
  }
1757
1790
  return '';
1758
1791
  }
@@ -1849,10 +1882,10 @@ let ExtendedList = class ExtendedList extends vtyx.Vue {
1849
1882
  /* }}} */
1850
1883
  /* {{{ watch */
1851
1884
  onFilteredOptionsChange() {
1852
- vtyx.Vue.nextTick(this.computeListSize, this);
1885
+ this.$nextTick(this.computeListSize);
1853
1886
  }
1854
1887
  onHideFilterChange() {
1855
- vtyx.Vue.nextTick(this.computeListSize, this);
1888
+ this.$nextTick(this.computeListSize);
1856
1889
  }
1857
1890
  /* }}} */
1858
1891
  /* {{{ methods */
@@ -1882,47 +1915,48 @@ let ExtendedList = class ExtendedList extends vtyx.Vue {
1882
1915
  }
1883
1916
  /* }}} */
1884
1917
  render() {
1885
- const h = this.renderWrapper();
1886
1918
  const store = this.store;
1887
1919
  const state = store.state;
1888
- return (h("div", { style: this.positionStyle, class: "selectic selectic__extended-list" },
1889
- !state.hideFilter && (h(Filter, { store: this.store })),
1890
- state.groups.size > 0 && state.totalFilteredOptions > store.itemsPerPage && (h("span", { class: "selectic-item selectic-item--header selectic-item__is-group" }, this.topGroup)),
1891
- h(List$1, { store: store, class: "selectic__extended-list__list-items", on: {
1920
+ const isGroup = state.groups.size > 0 &&
1921
+ state.totalFilteredOptions > store.data.itemsPerPage;
1922
+ return (vtyx.h("div", { style: this.positionStyle, class: "selectic selectic__extended-list" },
1923
+ !state.hideFilter && (vtyx.h(Filter, { store: this.store })),
1924
+ isGroup && (vtyx.h("span", { class: "selectic-item selectic-item--header selectic-item__is-group" }, this.topGroup)),
1925
+ vtyx.h(List$1, { store: store, class: "selectic__extended-list__list-items", on: {
1892
1926
  groupId: this.getGroup,
1893
1927
  } }),
1894
- this.infoMessage && (h("div", { class: "selectic__message alert-info" }, this.infoMessage)),
1895
- this.searching && (h("div", { class: "selectic__message" },
1896
- h("span", { class: "fa fa-spinner fa-spin" }),
1928
+ this.infoMessage && (vtyx.h("div", { class: "selectic__message alert-info" }, this.infoMessage)),
1929
+ this.searching && (vtyx.h("div", { class: "selectic__message" },
1930
+ vtyx.h("span", { class: "fa fa-spinner fa-spin" }),
1897
1931
  this.searchingLabel)),
1898
- this.errorMessage && (h("div", { class: "selectic__message alert-danger", on: { click: () => store.resetErrorMessage() } }, this.errorMessage))));
1932
+ this.errorMessage && (vtyx.h("div", { class: "selectic__message alert-danger", on: { click: () => store.resetErrorMessage() } }, this.errorMessage))));
1899
1933
  }
1900
1934
  };
1901
- __decorate$4([
1935
+ __decorate$1([
1902
1936
  vtyx.Prop()
1903
1937
  ], ExtendedList.prototype, "store", void 0);
1904
- __decorate$4([
1938
+ __decorate$1([
1905
1939
  vtyx.Prop({ default: 0 })
1906
1940
  ], ExtendedList.prototype, "elementLeft", void 0);
1907
- __decorate$4([
1941
+ __decorate$1([
1908
1942
  vtyx.Prop({ default: 0 })
1909
1943
  ], ExtendedList.prototype, "elementRight", void 0);
1910
- __decorate$4([
1944
+ __decorate$1([
1911
1945
  vtyx.Prop({ default: 0 })
1912
1946
  ], ExtendedList.prototype, "elementTop", void 0);
1913
- __decorate$4([
1947
+ __decorate$1([
1914
1948
  vtyx.Prop({ default: 0 })
1915
1949
  ], ExtendedList.prototype, "elementBottom", void 0);
1916
- __decorate$4([
1950
+ __decorate$1([
1917
1951
  vtyx.Prop({ default: 300 })
1918
1952
  ], ExtendedList.prototype, "width", void 0);
1919
- __decorate$4([
1953
+ __decorate$1([
1920
1954
  vtyx.Watch('store.state.filteredOptions')
1921
1955
  ], ExtendedList.prototype, "onFilteredOptionsChange", null);
1922
- __decorate$4([
1956
+ __decorate$1([
1923
1957
  vtyx.Watch('store.state.hideFilter')
1924
1958
  ], ExtendedList.prototype, "onHideFilterChange", null);
1925
- ExtendedList = __decorate$4([
1959
+ ExtendedList = __decorate$1([
1926
1960
  vtyx.Component
1927
1961
  ], ExtendedList);
1928
1962
  var ExtendedList$1 = ExtendedList;
@@ -1933,16 +1967,16 @@ var ExtendedList$1 = ExtendedList;
1933
1967
  * these items dynamically which allow to build very long list without loading
1934
1968
  * all data.
1935
1969
  */
1936
- var __decorate$5 = (this && this.__decorate) || function (decorators, target, key, desc) {
1970
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
1937
1971
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1938
1972
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1939
1973
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1940
1974
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1941
1975
  };
1942
- function changeTexts$1(texts) {
1943
- changeTexts(texts);
1976
+ function changeTexts(texts) {
1977
+ changeTexts$1(texts);
1944
1978
  }
1945
- let Selectic$1 = class Selectic extends vtyx.Vue {
1979
+ let Selectic = class Selectic extends vtyx.Vue {
1946
1980
  constructor() {
1947
1981
  super(...arguments);
1948
1982
  /* }}} */
@@ -1952,15 +1986,16 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
1952
1986
  this.elementLeft = 0;
1953
1987
  this.elementRight = 0;
1954
1988
  this.width = 0;
1989
+ this.hasBeenRendered = false;
1955
1990
  this.store = {};
1956
1991
  }
1957
1992
  /* }}} */
1958
1993
  /* {{{ computed */
1959
1994
  get isFocused() {
1960
- if (!this.store || !this.store.state) {
1995
+ if (!this.hasBeenRendered) {
1961
1996
  return false;
1962
1997
  }
1963
- return this.store.state.isOpen;
1998
+ return !!this.store.state.isOpen;
1964
1999
  }
1965
2000
  get scrollListener() {
1966
2001
  return this.computeOffset.bind(this, true);
@@ -2068,15 +2103,15 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
2068
2103
  }
2069
2104
  computeOffset(doNotAddListener = false) {
2070
2105
  const mainInput = this.$refs.mainInput;
2071
- if (!mainInput || !mainInput.$el) {
2106
+ const mainEl = mainInput === null || mainInput === void 0 ? void 0 : mainInput.$el;
2107
+ if (!mainEl) {
2072
2108
  /* This method has been called too soon (before render function) */
2073
2109
  return;
2074
2110
  }
2075
- const mainEl = mainInput.$el;
2076
2111
  const _elementsListeners = this._elementsListeners;
2077
2112
  /* add listeners */
2078
2113
  if (!doNotAddListener) {
2079
- let el = mainInput.$el;
2114
+ let el = mainEl;
2080
2115
  while (el) {
2081
2116
  el.addEventListener('scroll', this.scrollListener, { passive: true });
2082
2117
  _elementsListeners.push(el);
@@ -2150,10 +2185,10 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
2150
2185
  }
2151
2186
  }
2152
2187
  onExcludedChange() {
2153
- this.store.selectionIsExcluded = this.selectionIsExcluded;
2188
+ this.store.props.selectionIsExcluded = this.selectionIsExcluded;
2154
2189
  }
2155
2190
  onOptionsChange() {
2156
- this.store.options = this.options;
2191
+ this.store.props.options = Array.from(this.options);
2157
2192
  }
2158
2193
  onTextsChange() {
2159
2194
  const texts = this.texts;
@@ -2162,7 +2197,7 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
2162
2197
  }
2163
2198
  }
2164
2199
  onDisabledChange() {
2165
- this.store.disabled = this.disabled;
2200
+ this.store.props.disabled = this.disabled;
2166
2201
  }
2167
2202
  onGroupsChanged() {
2168
2203
  this.store.changeGroups(this.groups);
@@ -2181,7 +2216,8 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
2181
2216
  const oldValue = this._oldValue;
2182
2217
  const value = this.getValue();
2183
2218
  const areSimilar = this.compareValues(oldValue, value);
2184
- /* should not trigger when initializing internalValue, but should do if it changes the inital value */
2219
+ /* should not trigger when initializing internalValue, but should do
2220
+ * if it changes the initial value */
2185
2221
  const canTrigger = (oldValue !== undefined || !this.hasGivenValue) && !areSimilar;
2186
2222
  if (canTrigger) {
2187
2223
  const selectionIsExcluded = this.store.state.selectionIsExcluded;
@@ -2210,243 +2246,269 @@ let Selectic$1 = class Selectic extends vtyx.Vue {
2210
2246
  this.store.commit('isOpen', false);
2211
2247
  }, 0);
2212
2248
  }
2213
- extractFromNode(node, text = '') {
2214
- var _a, _b, _c, _d, _e, _f, _g;
2215
- function styleToString(staticStyle) {
2216
- if (!staticStyle) {
2217
- return;
2218
- }
2219
- let styles = [];
2220
- for (const [key, value] of Object.entries(staticStyle)) {
2221
- styles.push(`${key}: ${value}`);
2222
- }
2223
- return styles.join(';');
2224
- }
2225
- const domProps = (_a = node.data) === null || _a === void 0 ? void 0 : _a.domProps;
2226
- const attrs = (_b = node.data) === null || _b === void 0 ? void 0 : _b.attrs;
2227
- const id = (_e = (_d = (_c = domProps === null || domProps === void 0 ? void 0 : domProps.value) !== null && _c !== void 0 ? _c : attrs === null || attrs === void 0 ? void 0 : attrs.value) !== null && _d !== void 0 ? _d : attrs === null || attrs === void 0 ? void 0 : attrs.id) !== null && _e !== void 0 ? _e : text;
2228
- const className = (_f = node.data) === null || _f === void 0 ? void 0 : _f.staticClass;
2229
- const style = styleToString((_g = node.data) === null || _g === void 0 ? void 0 : _g.staticStyle);
2230
- const optVal = {
2231
- id,
2232
- text,
2233
- className,
2234
- style,
2235
- };
2236
- if (attrs) {
2237
- for (const [key, val] of Object.entries(attrs)) {
2238
- switch (key) {
2239
- case 'title':
2240
- optVal.title = val;
2241
- break;
2242
- case 'disabled':
2243
- if (val === false) {
2244
- optVal.disabled = false;
2245
- }
2246
- else {
2247
- optVal.disabled = true;
2248
- }
2249
- break;
2250
- case 'group':
2251
- optVal.group = val;
2252
- break;
2253
- case 'icon':
2254
- optVal.icon = val;
2255
- break;
2256
- case 'data':
2257
- optVal.data = val;
2258
- break;
2259
- default:
2260
- if (key.startsWith('data')) {
2261
- if (typeof optVal.data !== 'object') {
2262
- optVal.data = {};
2263
- }
2264
- optVal.data[key.slice(5)] = val;
2265
- }
2266
- }
2267
- }
2268
- }
2269
- return optVal;
2270
- }
2271
- extractOptionFromNode(node) {
2272
- const children = node.children;
2273
- const text = (children && children[0].text || '').trim();
2274
- return this.extractFromNode(node, text);
2275
- }
2276
- extractOptgroupFromNode(node) {
2277
- var _a;
2278
- const attrs = (_a = node.data) === null || _a === void 0 ? void 0 : _a.attrs;
2279
- const children = node.children || [];
2280
- const text = (attrs === null || attrs === void 0 ? void 0 : attrs.label) || '';
2281
- const options = [];
2282
- for (const child of children) {
2283
- if (child.tag === 'option') {
2284
- options.push(this.extractOptionFromNode(child));
2285
- }
2286
- }
2287
- const opt = this.extractFromNode(node, text);
2288
- opt.options = options;
2289
- return opt;
2290
- }
2249
+ emit(event, ...args) {
2250
+ this.$emit(event, ...args);
2251
+ if (typeof this._on === 'function') {
2252
+ this._on(event, ...args);
2253
+ }
2254
+ }
2255
+ // private extractFromNode(node: Vue.VNode, text = ''): OptionValue {
2256
+ // function styleToString(staticStyle?: {[key: string]: string}): string | undefined {
2257
+ // if (!staticStyle) {
2258
+ // return;
2259
+ // }
2260
+ // let styles = [];
2261
+ // for (const [key, value] of Object.entries(staticStyle)) {
2262
+ // styles.push(`${key}: ${value}`);
2263
+ // }
2264
+ // return styles.join(';');
2265
+ // }
2266
+ // const domProps = node.data?.domProps;
2267
+ // const attrs = node.data?.attrs;
2268
+ // const id = domProps?.value ?? attrs?.value ?? attrs?.id ?? text;
2269
+ // const className = node.data?.staticClass;
2270
+ // const style = styleToString(node.data?.staticStyle);
2271
+ // const optVal: OptionValue = {
2272
+ // id,
2273
+ // text,
2274
+ // className,
2275
+ // style,
2276
+ // };
2277
+ // if (attrs) {
2278
+ // for (const [key, val] of Object.entries(attrs)) {
2279
+ // switch(key) {
2280
+ // case 'title':
2281
+ // optVal.title = val;
2282
+ // break;
2283
+ // case 'disabled':
2284
+ // if (val === false) {
2285
+ // optVal.disabled = false;
2286
+ // } else {
2287
+ // optVal.disabled = true;
2288
+ // }
2289
+ // break;
2290
+ // case 'group':
2291
+ // optVal.group = val;
2292
+ // break;
2293
+ // case 'icon':
2294
+ // optVal.icon = val;
2295
+ // break;
2296
+ // case 'data':
2297
+ // optVal.data = val;
2298
+ // break;
2299
+ // default:
2300
+ // if (key.startsWith('data')) {
2301
+ // if (typeof optVal.data !== 'object') {
2302
+ // optVal.data = {};
2303
+ // }
2304
+ // optVal.data[key.slice(5)] = val;
2305
+ // }
2306
+ // }
2307
+ // }
2308
+ // }
2309
+ // return optVal;
2310
+ // }
2311
+ // private extractOptionFromNode(node: Vue.VNode): OptionValue {
2312
+ // const children = node.children;
2313
+ // const text = (children && children[0].text || '').trim();
2314
+ // return this.extractFromNode(node, text);
2315
+ // }
2316
+ // private extractOptgroupFromNode(node: Vue.VNode): OptionValue {
2317
+ // const attrs = node.data?.attrs;
2318
+ // const children = node.children || [];
2319
+ // const text = attrs?.label || '';
2320
+ // const options: OptionValue[] = [];
2321
+ // for (const child of children) {
2322
+ // if (child.tag === 'option') {
2323
+ // options.push(this.extractOptionFromNode(child));
2324
+ // }
2325
+ // }
2326
+ // const opt = this.extractFromNode(node, text);
2327
+ // opt.options = options;
2328
+ // return opt;
2329
+ // }
2291
2330
  /* }}} */
2292
2331
  /* {{{ Life cycle */
2293
2332
  created() {
2333
+ var _a, _b;
2294
2334
  this._elementsListeners = [];
2295
- this.store = new Store({ propsData: {
2296
- options: this.options,
2297
- value: this.value,
2298
- selectionIsExcluded: this.selectionIsExcluded,
2299
- disabled: this.disabled,
2300
- texts: this.texts,
2301
- groups: this.groups,
2302
- keepOpenWithOtherSelectic: !!this.params.keepOpenWithOtherSelectic,
2303
- params: {
2304
- multiple: this.multiple,
2305
- pageSize: this.params.pageSize || 100,
2306
- hideFilter: this.params.hideFilter !== undefined
2307
- ? this.params.hideFilter : 'auto',
2308
- allowRevert: this.params.allowRevert,
2309
- allowClearSelection: this.params.allowClearSelection || false,
2310
- autoSelect: this.params.autoSelect === undefined
2311
- ? !this.multiple && !this.params.fetchCallback
2312
- : this.params.autoSelect,
2313
- autoDisabled: typeof this.params.autoDisabled === 'boolean'
2314
- ? this.params.autoDisabled : true,
2315
- strictValue: this.params.strictValue || false,
2316
- selectionOverflow: this.params.selectionOverflow || 'collapsed',
2317
- placeholder: this.placeholder,
2318
- formatOption: this.params.formatOption,
2319
- formatSelection: this.params.formatSelection,
2320
- listPosition: this.params.listPosition || 'auto',
2321
- optionBehavior: this.params.optionBehavior,
2322
- isOpen: !!this.open,
2323
- },
2324
- fetchCallback: this.params.fetchCallback,
2325
- getItemsCallback: this.params.getItemsCallback,
2326
- } });
2335
+ this.store = new SelecticStore({
2336
+ options: this.options,
2337
+ value: this.value,
2338
+ selectionIsExcluded: this.selectionIsExcluded,
2339
+ disabled: this.disabled,
2340
+ texts: this.texts,
2341
+ groups: this.groups,
2342
+ keepOpenWithOtherSelectic: !!this.params.keepOpenWithOtherSelectic,
2343
+ params: {
2344
+ multiple: ((_a = this.multiple) !== null && _a !== void 0 ? _a : false) !== false,
2345
+ pageSize: this.params.pageSize || 100,
2346
+ hideFilter: this.params.hideFilter !== undefined
2347
+ ? this.params.hideFilter : 'auto',
2348
+ allowRevert: this.params.allowRevert,
2349
+ allowClearSelection: this.params.allowClearSelection || false,
2350
+ autoSelect: this.params.autoSelect === undefined
2351
+ ? !this.multiple && !this.params.fetchCallback
2352
+ : this.params.autoSelect,
2353
+ autoDisabled: typeof this.params.autoDisabled === 'boolean'
2354
+ ? this.params.autoDisabled : true,
2355
+ strictValue: this.params.strictValue || false,
2356
+ selectionOverflow: this.params.selectionOverflow || 'collapsed',
2357
+ placeholder: this.placeholder,
2358
+ formatOption: this.params.formatOption,
2359
+ formatSelection: this.params.formatSelection,
2360
+ listPosition: this.params.listPosition || 'auto',
2361
+ optionBehavior: this.params.optionBehavior,
2362
+ isOpen: ((_b = this.open) !== null && _b !== void 0 ? _b : false) !== false,
2363
+ },
2364
+ fetchCallback: this.params.fetchCallback,
2365
+ getItemsCallback: this.params.getItemsCallback,
2366
+ });
2367
+ if (typeof this._getMethods === 'function') {
2368
+ this._getMethods({
2369
+ clearCache: this.clearCache.bind(this),
2370
+ changeTexts: this.changeTexts.bind(this),
2371
+ getValue: this.getValue.bind(this),
2372
+ getSelectedItems: this.getSelectedItems.bind(this),
2373
+ isEmpty: this.isEmpty.bind(this),
2374
+ toggleOpen: this.toggleOpen.bind(this),
2375
+ });
2376
+ }
2327
2377
  }
2328
2378
  mounted() {
2329
- setTimeout(() => this.computeOffset(), 0);
2379
+ setTimeout(() => {
2380
+ this.hasBeenRendered = true;
2381
+ this.computeOffset();
2382
+ }, 100);
2330
2383
  }
2331
2384
  beforeUpdate() {
2332
- const elements = this.$slots.default;
2333
- if (!elements) {
2334
- this.store.childOptions = [];
2335
- return;
2336
- }
2337
- const options = [];
2338
- for (const node of elements) {
2339
- if (node.tag === 'option') {
2340
- const prop = this.extractOptionFromNode(node);
2341
- options.push(prop);
2342
- }
2343
- else if (node.tag === 'optgroup') {
2344
- const prop = this.extractOptgroupFromNode(node);
2345
- options.push(prop);
2346
- }
2347
- }
2348
- this.store.childOptions = options;
2385
+ // const elements = this.$slots.default;
2386
+ // if (!elements) {
2387
+ // this.store.childOptions = [];
2388
+ // return;
2389
+ // }
2390
+ // const options = [];
2391
+ // for (const node of elements) {
2392
+ // if (node.tag === 'option') {
2393
+ // const prop = this.extractOptionFromNode(node);
2394
+ // options.push(prop);
2395
+ // } else
2396
+ // if (node.tag === 'optgroup') {
2397
+ // const prop = this.extractOptgroupFromNode(node);
2398
+ // options.push(prop);
2399
+ // }
2400
+ // }
2401
+ // this.store.childOptions = options;
2349
2402
  }
2350
2403
  beforeDestroy() {
2351
2404
  this.removeListeners();
2352
2405
  }
2353
2406
  /* }}} */
2354
2407
  render() {
2355
- const h = this.renderWrapper();
2356
2408
  const id = this.id || undefined;
2357
- return (h("div", { class: this.selecticClass, title: this.title, "data-selectic": "true", on: {
2358
- 'click.prevent.stop': () => this.store.commit('isOpen', true),
2409
+ const store = this.store;
2410
+ if (!store.state) {
2411
+ return; /* component is not ready yet */
2412
+ }
2413
+ return (vtyx.h("div", { class: this.selecticClass, title: this.title, "data-selectic": "true", on: {
2414
+ 'click.prevent.stop': () => store.commit('isOpen', true),
2359
2415
  } },
2360
- h("input", { type: "text", id: id, value: this.inputValue, class: "selectic__input-value", on: {
2361
- focus: () => this.store.commit('isOpen', true),
2416
+ vtyx.h("input", { type: "text", id: id, value: this.inputValue, class: "selectic__input-value", on: {
2417
+ focus: () => store.commit('isOpen', true),
2362
2418
  blur: this.checkFocus,
2363
2419
  } }),
2364
- h(MainInput, { store: this.store, id: id, on: {
2365
- 'item:click': (id) => this.$emit('item:click', id, this),
2420
+ vtyx.h(MainInput$1, { store: store, id: id, on: {
2421
+ 'item:click': (id) => this.emit('item:click', id, this),
2366
2422
  }, ref: "mainInput" }),
2367
- this.isFocused && (h(ExtendedList$1, { store: this.store, elementBottom: this.elementBottom, elementTop: this.elementTop, elementLeft: this.elementLeft, elementRight: this.elementRight, width: this.width, ref: "extendedList" }))));
2423
+ this.isFocused && (vtyx.h(ExtendedList$1, { class: this.className, store: store, elementBottom: this.elementBottom, elementTop: this.elementTop, elementLeft: this.elementLeft, elementRight: this.elementRight, width: this.width, ref: "extendedList" }))));
2368
2424
  }
2369
2425
  };
2370
- __decorate$5([
2426
+ __decorate([
2371
2427
  vtyx.Prop()
2372
- ], Selectic$1.prototype, "value", void 0);
2373
- __decorate$5([
2428
+ ], Selectic.prototype, "value", void 0);
2429
+ __decorate([
2374
2430
  vtyx.Prop({ default: false })
2375
- ], Selectic$1.prototype, "selectionIsExcluded", void 0);
2376
- __decorate$5([
2431
+ ], Selectic.prototype, "selectionIsExcluded", void 0);
2432
+ __decorate([
2377
2433
  vtyx.Prop({ default: () => [] })
2378
- ], Selectic$1.prototype, "options", void 0);
2379
- __decorate$5([
2434
+ ], Selectic.prototype, "options", void 0);
2435
+ __decorate([
2380
2436
  vtyx.Prop({ default: () => [] })
2381
- ], Selectic$1.prototype, "groups", void 0);
2382
- __decorate$5([
2437
+ ], Selectic.prototype, "groups", void 0);
2438
+ __decorate([
2383
2439
  vtyx.Prop({ default: false })
2384
- ], Selectic$1.prototype, "multiple", void 0);
2385
- __decorate$5([
2440
+ ], Selectic.prototype, "multiple", void 0);
2441
+ __decorate([
2386
2442
  vtyx.Prop({ default: false })
2387
- ], Selectic$1.prototype, "disabled", void 0);
2388
- __decorate$5([
2443
+ ], Selectic.prototype, "disabled", void 0);
2444
+ __decorate([
2389
2445
  vtyx.Prop({ default: '' })
2390
- ], Selectic$1.prototype, "placeholder", void 0);
2391
- __decorate$5([
2446
+ ], Selectic.prototype, "placeholder", void 0);
2447
+ __decorate([
2392
2448
  vtyx.Prop({ default: '' })
2393
- ], Selectic$1.prototype, "id", void 0);
2394
- __decorate$5([
2449
+ ], Selectic.prototype, "id", void 0);
2450
+ __decorate([
2395
2451
  vtyx.Prop({ default: '' })
2396
- ], Selectic$1.prototype, "className", void 0);
2397
- __decorate$5([
2452
+ ], Selectic.prototype, "className", void 0);
2453
+ __decorate([
2398
2454
  vtyx.Prop()
2399
- ], Selectic$1.prototype, "title", void 0);
2400
- __decorate$5([
2455
+ ], Selectic.prototype, "title", void 0);
2456
+ __decorate([
2401
2457
  vtyx.Prop()
2402
- ], Selectic$1.prototype, "texts", void 0);
2403
- __decorate$5([
2458
+ ], Selectic.prototype, "texts", void 0);
2459
+ __decorate([
2404
2460
  vtyx.Prop({ default: false })
2405
- ], Selectic$1.prototype, "noCache", void 0);
2406
- __decorate$5([
2461
+ ], Selectic.prototype, "noCache", void 0);
2462
+ __decorate([
2407
2463
  vtyx.Prop()
2408
- ], Selectic$1.prototype, "open", void 0);
2409
- __decorate$5([
2464
+ ], Selectic.prototype, "open", void 0);
2465
+ __decorate([
2410
2466
  vtyx.Prop({ default: () => ({
2411
2467
  allowClearSelection: false,
2412
2468
  strictValue: false,
2413
2469
  selectionOverflow: 'collapsed',
2414
2470
  }) })
2415
- ], Selectic$1.prototype, "params", void 0);
2416
- __decorate$5([
2471
+ ], Selectic.prototype, "params", void 0);
2472
+ __decorate([
2473
+ vtyx.Prop()
2474
+ ], Selectic.prototype, "_on", void 0);
2475
+ __decorate([
2476
+ vtyx.Prop()
2477
+ ], Selectic.prototype, "_getMethods", void 0);
2478
+ __decorate([
2417
2479
  vtyx.Watch('value')
2418
- ], Selectic$1.prototype, "onValueChange", null);
2419
- __decorate$5([
2480
+ ], Selectic.prototype, "onValueChange", null);
2481
+ __decorate([
2420
2482
  vtyx.Watch('selectionIsExcluded')
2421
- ], Selectic$1.prototype, "onExcludedChange", null);
2422
- __decorate$5([
2483
+ ], Selectic.prototype, "onExcludedChange", null);
2484
+ __decorate([
2423
2485
  vtyx.Watch('options')
2424
- ], Selectic$1.prototype, "onOptionsChange", null);
2425
- __decorate$5([
2486
+ ], Selectic.prototype, "onOptionsChange", null);
2487
+ __decorate([
2426
2488
  vtyx.Watch('texts')
2427
- ], Selectic$1.prototype, "onTextsChange", null);
2428
- __decorate$5([
2489
+ ], Selectic.prototype, "onTextsChange", null);
2490
+ __decorate([
2429
2491
  vtyx.Watch('disabled')
2430
- ], Selectic$1.prototype, "onDisabledChange", null);
2431
- __decorate$5([
2492
+ ], Selectic.prototype, "onDisabledChange", null);
2493
+ __decorate([
2432
2494
  vtyx.Watch('groups')
2433
- ], Selectic$1.prototype, "onGroupsChanged", null);
2434
- __decorate$5([
2495
+ ], Selectic.prototype, "onGroupsChanged", null);
2496
+ __decorate([
2435
2497
  vtyx.Watch('placeholder')
2436
- ], Selectic$1.prototype, "onPlaceholderChanged", null);
2437
- __decorate$5([
2498
+ ], Selectic.prototype, "onPlaceholderChanged", null);
2499
+ __decorate([
2438
2500
  vtyx.Watch('open')
2439
- ], Selectic$1.prototype, "onOpenChanged", null);
2440
- __decorate$5([
2501
+ ], Selectic.prototype, "onOpenChanged", null);
2502
+ __decorate([
2441
2503
  vtyx.Watch('isFocused')
2442
- ], Selectic$1.prototype, "onFocusChanged", null);
2443
- __decorate$5([
2504
+ ], Selectic.prototype, "onFocusChanged", null);
2505
+ __decorate([
2444
2506
  vtyx.Watch('store.state.internalValue')
2445
- ], Selectic$1.prototype, "onInternalValueChange", null);
2446
- Selectic$1 = __decorate$5([
2507
+ ], Selectic.prototype, "onInternalValueChange", null);
2508
+ Selectic = __decorate([
2447
2509
  vtyx.Component
2448
- ], Selectic$1);
2449
- var Selectic$2 = Selectic$1;
2510
+ ], Selectic);
2511
+ var Selectic$1 = Selectic;
2450
2512
 
2451
- exports.changeTexts = changeTexts$1;
2452
- exports.default = Selectic$2;
2513
+ exports.changeTexts = changeTexts;
2514
+ exports['default'] = Selectic$1;