selectic 3.0.7 → 3.0.11

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.
@@ -35,13 +35,50 @@ function styleInject(css, ref) {
35
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";
36
36
  styleInject(css_248z);
37
37
 
38
- /* File Purpose:
39
- * It keeps and computes all states at a single place.
40
- * Every inner components of Selectic should communicate with this file to
41
- * change or to get states.
38
+ /**
39
+ * Clone the object and its inner properties.
40
+ * @param obj The object to be clone.
41
+ * @param refs internal reference to object to avoid cyclic references
42
+ * @returns a copy of obj
42
43
  */
43
- /* }}} */
44
- /* {{{ Helper */
44
+ function deepClone(origObject, ignoreAttributes = [], refs = new WeakMap()) {
45
+ const obj = vue.unref(origObject);
46
+ /* For circular references */
47
+ if (refs.has(obj)) {
48
+ return refs.get(obj);
49
+ }
50
+ if (typeof obj === 'object') {
51
+ if (obj === null) {
52
+ return obj;
53
+ }
54
+ if (Array.isArray(obj)) {
55
+ const ref = [];
56
+ refs.set(obj, ref);
57
+ obj.forEach((val, idx) => {
58
+ ref[idx] = deepClone(val, ignoreAttributes, refs);
59
+ });
60
+ return ref;
61
+ }
62
+ if (obj instanceof RegExp) {
63
+ const ref = new RegExp(obj.source, obj.flags);
64
+ refs.set(obj, ref);
65
+ return ref;
66
+ }
67
+ /* This should be an object */
68
+ const ref = {};
69
+ refs.set(obj, ref);
70
+ for (const [key, val] of Object.entries(obj)) {
71
+ if (ignoreAttributes.includes(key)) {
72
+ ref[key] = val;
73
+ continue;
74
+ }
75
+ ref[key] = deepClone(val, ignoreAttributes, refs);
76
+ }
77
+ return ref;
78
+ }
79
+ /* This should be a primitive */
80
+ return obj;
81
+ }
45
82
  /**
46
83
  * Escape search string to consider regexp special characters as they
47
84
  * are and not like special characters.
@@ -72,6 +109,12 @@ function assignObject(obj, ...sourceObjects) {
72
109
  }
73
110
  return result;
74
111
  }
112
+
113
+ /* File Purpose:
114
+ * It keeps and computes all states at a single place.
115
+ * Every inner components of Selectic should communicate with this file to
116
+ * change or to get states.
117
+ */
75
118
  /* }}} */
76
119
  /* {{{ Static */
77
120
  function changeTexts$1(texts) {
@@ -211,17 +254,17 @@ class SelecticStore {
211
254
  this.commit('isOpen', false);
212
255
  this.buildAllOptions(true);
213
256
  this.buildSelectedOptions();
214
- });
257
+ }, { deep: true });
215
258
  vue.watch(() => [this.listOptions, this.elementOptions], () => {
216
259
  /* TODO: transform allOptions as a computed properties and this
217
260
  * watcher become useless */
218
261
  this.buildAllOptions(true);
219
- });
262
+ }, { deep: true });
220
263
  vue.watch(() => this.props.value, () => {
221
264
  var _a;
222
265
  const value = (_a = this.props.value) !== null && _a !== void 0 ? _a : null;
223
266
  this.commit('internalValue', value);
224
- });
267
+ }, { deep: true });
225
268
  vue.watch(() => this.props.selectionIsExcluded, () => {
226
269
  this.commit('selectionIsExcluded', this.props.selectionIsExcluded);
227
270
  });
@@ -237,14 +280,14 @@ class SelecticStore {
237
280
  areAllSelected = this.state.filteredOptions.every((item) => !!(+item.selected ^ selectionIsExcluded));
238
281
  }
239
282
  this.state.status.areAllSelected = areAllSelected;
240
- });
283
+ }, { deep: true });
241
284
  vue.watch(() => this.state.internalValue, () => {
242
285
  this.buildSelectedOptions();
243
- });
286
+ }, { deep: true });
244
287
  vue.watch(() => this.state.allOptions, () => {
245
288
  this.checkAutoSelect();
246
289
  this.checkAutoDisabled();
247
- });
290
+ }, { deep: true });
248
291
  vue.watch(() => this.state.totalAllOptions, () => {
249
292
  this.checkHideFilter();
250
293
  });
@@ -253,10 +296,10 @@ class SelecticStore {
253
296
  this.setAutomaticClose();
254
297
  this.commit('isOpen', false);
255
298
  };
256
- const value = this.props.value;
299
+ const value = deepClone(this.props.value);
257
300
  /* set initial value for non reactive attribute */
258
301
  this.cacheRequest = new Map();
259
- const stateParam = Object.assign({}, this.props.params);
302
+ const stateParam = deepClone(this.props.params);
260
303
  if (stateParam.optionBehavior) {
261
304
  this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
262
305
  delete stateParam.optionBehavior;
@@ -646,7 +689,7 @@ class SelecticStore {
646
689
  }
647
690
  /* This method is for the computed property listOptions */
648
691
  getListOptions() {
649
- const options = this.props.options;
692
+ const options = deepClone(this.props.options, ['data']);
650
693
  const listOptions = [];
651
694
  if (!Array.isArray(options)) {
652
695
  return listOptions;
@@ -683,7 +726,7 @@ class SelecticStore {
683
726
  }
684
727
  /* This method is for the computed property elementOptions */
685
728
  getElementOptions() {
686
- const options = this.props.childOptions;
729
+ const options = deepClone(this.props.childOptions, ['data']);
687
730
  const childOptions = [];
688
731
  if (!Array.isArray(options) || options.length === 0) {
689
732
  return childOptions;
@@ -1393,7 +1436,7 @@ __decorate$4([
1393
1436
  vtyx.Prop({ default: '' })
1394
1437
  ], MainInput.prototype, "id", void 0);
1395
1438
  __decorate$4([
1396
- vtyx.Watch('store.state.internalValue')
1439
+ vtyx.Watch('store.state.internalValue', { deep: true })
1397
1440
  ], MainInput.prototype, "onInternalChange", null);
1398
1441
  MainInput = __decorate$4([
1399
1442
  vtyx.Component
@@ -1497,7 +1540,7 @@ let FilterPanel = class FilterPanel extends vtyx.Vue {
1497
1540
  document.addEventListener('keypress', this.onKeyPressed);
1498
1541
  this.getFocus();
1499
1542
  }
1500
- destroyed() {
1543
+ unmounted() {
1501
1544
  document.removeEventListener('keypress', this.onKeyPressed);
1502
1545
  }
1503
1546
  /* }}} */
@@ -1757,7 +1800,7 @@ __decorate$2([
1757
1800
  vtyx.Watch('store.state.offsetItem')
1758
1801
  ], List.prototype, "onOffsetChange", null);
1759
1802
  __decorate$2([
1760
- vtyx.Watch('filteredOptions')
1803
+ vtyx.Watch('filteredOptions', { deep: true })
1761
1804
  ], List.prototype, "onFilteredOptionsChange", null);
1762
1805
  __decorate$2([
1763
1806
  vtyx.Watch('groupId')
@@ -1928,7 +1971,7 @@ let ExtendedList = class ExtendedList extends vtyx.Vue {
1928
1971
  document.body.addEventListener('keydown', this.onKeyDown);
1929
1972
  this.computeListSize();
1930
1973
  }
1931
- destroyed() {
1974
+ unmounted() {
1932
1975
  document.body.removeEventListener('keydown', this.onKeyDown);
1933
1976
  /* force the element to be removed from DOM */
1934
1977
  if (this.$el.parentNode) {
@@ -1973,7 +2016,7 @@ __decorate$1([
1973
2016
  vtyx.Prop({ default: 300 })
1974
2017
  ], ExtendedList.prototype, "width", void 0);
1975
2018
  __decorate$1([
1976
- vtyx.Watch('store.state.filteredOptions')
2019
+ vtyx.Watch('store.state.filteredOptions', { deep: true })
1977
2020
  ], ExtendedList.prototype, "onFilteredOptionsChange", null);
1978
2021
  __decorate$1([
1979
2022
  vtyx.Watch('store.state.hideFilter')
@@ -2221,7 +2264,7 @@ let Selectic = class Selectic extends vtyx.Vue {
2221
2264
  this.store.props.selectionIsExcluded = this.selectionIsExcluded;
2222
2265
  }
2223
2266
  onOptionsChange() {
2224
- this.store.props.options = Array.from(this.options);
2267
+ this.store.props.options = deepClone(this.options);
2225
2268
  }
2226
2269
  onTextsChange() {
2227
2270
  const texts = this.texts;
@@ -2462,7 +2505,7 @@ let Selectic = class Selectic extends vtyx.Vue {
2462
2505
  // }
2463
2506
  // this.store.childOptions = options;
2464
2507
  }
2465
- beforeDestroy() {
2508
+ beforeUnmount() {
2466
2509
  this.removeListeners();
2467
2510
  }
2468
2511
  /* }}} */
@@ -2538,22 +2581,22 @@ __decorate([
2538
2581
  vtyx.Prop()
2539
2582
  ], Selectic.prototype, "_getMethods", void 0);
2540
2583
  __decorate([
2541
- vtyx.Watch('value')
2584
+ vtyx.Watch('value', { deep: true })
2542
2585
  ], Selectic.prototype, "onValueChange", null);
2543
2586
  __decorate([
2544
2587
  vtyx.Watch('selectionIsExcluded')
2545
2588
  ], Selectic.prototype, "onExcludedChange", null);
2546
2589
  __decorate([
2547
- vtyx.Watch('options')
2590
+ vtyx.Watch('options', { deep: true })
2548
2591
  ], Selectic.prototype, "onOptionsChange", null);
2549
2592
  __decorate([
2550
- vtyx.Watch('texts')
2593
+ vtyx.Watch('texts', { deep: true })
2551
2594
  ], Selectic.prototype, "onTextsChange", null);
2552
2595
  __decorate([
2553
2596
  vtyx.Watch('disabled')
2554
2597
  ], Selectic.prototype, "onDisabledChange", null);
2555
2598
  __decorate([
2556
- vtyx.Watch('groups')
2599
+ vtyx.Watch('groups', { deep: true })
2557
2600
  ], Selectic.prototype, "onGroupsChanged", null);
2558
2601
  __decorate([
2559
2602
  vtyx.Watch('placeholder')
@@ -2565,7 +2608,7 @@ __decorate([
2565
2608
  vtyx.Watch('isFocused')
2566
2609
  ], Selectic.prototype, "onFocusChanged", null);
2567
2610
  __decorate([
2568
- vtyx.Watch('store.state.internalValue')
2611
+ vtyx.Watch('store.state.internalValue', { deep: true })
2569
2612
  ], Selectic.prototype, "onInternalValueChange", null);
2570
2613
  __decorate([
2571
2614
  vtyx.Emit('input'),
@@ -1,5 +1,5 @@
1
1
  import { Prop, Watch, Component, Vue, h, Emit } from 'vtyx';
2
- import { reactive, computed, unref, watch } from 'vue';
2
+ import { unref, reactive, computed, watch } from 'vue';
3
3
 
4
4
  function styleInject(css, ref) {
5
5
  if ( ref === void 0 ) ref = {};
@@ -31,13 +31,50 @@ function styleInject(css, ref) {
31
31
  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";
32
32
  styleInject(css_248z);
33
33
 
34
- /* File Purpose:
35
- * It keeps and computes all states at a single place.
36
- * Every inner components of Selectic should communicate with this file to
37
- * change or to get states.
34
+ /**
35
+ * Clone the object and its inner properties.
36
+ * @param obj The object to be clone.
37
+ * @param refs internal reference to object to avoid cyclic references
38
+ * @returns a copy of obj
38
39
  */
39
- /* }}} */
40
- /* {{{ Helper */
40
+ function deepClone(origObject, ignoreAttributes = [], refs = new WeakMap()) {
41
+ const obj = unref(origObject);
42
+ /* For circular references */
43
+ if (refs.has(obj)) {
44
+ return refs.get(obj);
45
+ }
46
+ if (typeof obj === 'object') {
47
+ if (obj === null) {
48
+ return obj;
49
+ }
50
+ if (Array.isArray(obj)) {
51
+ const ref = [];
52
+ refs.set(obj, ref);
53
+ obj.forEach((val, idx) => {
54
+ ref[idx] = deepClone(val, ignoreAttributes, refs);
55
+ });
56
+ return ref;
57
+ }
58
+ if (obj instanceof RegExp) {
59
+ const ref = new RegExp(obj.source, obj.flags);
60
+ refs.set(obj, ref);
61
+ return ref;
62
+ }
63
+ /* This should be an object */
64
+ const ref = {};
65
+ refs.set(obj, ref);
66
+ for (const [key, val] of Object.entries(obj)) {
67
+ if (ignoreAttributes.includes(key)) {
68
+ ref[key] = val;
69
+ continue;
70
+ }
71
+ ref[key] = deepClone(val, ignoreAttributes, refs);
72
+ }
73
+ return ref;
74
+ }
75
+ /* This should be a primitive */
76
+ return obj;
77
+ }
41
78
  /**
42
79
  * Escape search string to consider regexp special characters as they
43
80
  * are and not like special characters.
@@ -68,6 +105,12 @@ function assignObject(obj, ...sourceObjects) {
68
105
  }
69
106
  return result;
70
107
  }
108
+
109
+ /* File Purpose:
110
+ * It keeps and computes all states at a single place.
111
+ * Every inner components of Selectic should communicate with this file to
112
+ * change or to get states.
113
+ */
71
114
  /* }}} */
72
115
  /* {{{ Static */
73
116
  function changeTexts$1(texts) {
@@ -207,17 +250,17 @@ class SelecticStore {
207
250
  this.commit('isOpen', false);
208
251
  this.buildAllOptions(true);
209
252
  this.buildSelectedOptions();
210
- });
253
+ }, { deep: true });
211
254
  watch(() => [this.listOptions, this.elementOptions], () => {
212
255
  /* TODO: transform allOptions as a computed properties and this
213
256
  * watcher become useless */
214
257
  this.buildAllOptions(true);
215
- });
258
+ }, { deep: true });
216
259
  watch(() => this.props.value, () => {
217
260
  var _a;
218
261
  const value = (_a = this.props.value) !== null && _a !== void 0 ? _a : null;
219
262
  this.commit('internalValue', value);
220
- });
263
+ }, { deep: true });
221
264
  watch(() => this.props.selectionIsExcluded, () => {
222
265
  this.commit('selectionIsExcluded', this.props.selectionIsExcluded);
223
266
  });
@@ -233,14 +276,14 @@ class SelecticStore {
233
276
  areAllSelected = this.state.filteredOptions.every((item) => !!(+item.selected ^ selectionIsExcluded));
234
277
  }
235
278
  this.state.status.areAllSelected = areAllSelected;
236
- });
279
+ }, { deep: true });
237
280
  watch(() => this.state.internalValue, () => {
238
281
  this.buildSelectedOptions();
239
- });
282
+ }, { deep: true });
240
283
  watch(() => this.state.allOptions, () => {
241
284
  this.checkAutoSelect();
242
285
  this.checkAutoDisabled();
243
- });
286
+ }, { deep: true });
244
287
  watch(() => this.state.totalAllOptions, () => {
245
288
  this.checkHideFilter();
246
289
  });
@@ -249,10 +292,10 @@ class SelecticStore {
249
292
  this.setAutomaticClose();
250
293
  this.commit('isOpen', false);
251
294
  };
252
- const value = this.props.value;
295
+ const value = deepClone(this.props.value);
253
296
  /* set initial value for non reactive attribute */
254
297
  this.cacheRequest = new Map();
255
- const stateParam = Object.assign({}, this.props.params);
298
+ const stateParam = deepClone(this.props.params);
256
299
  if (stateParam.optionBehavior) {
257
300
  this.buildOptionBehavior(stateParam.optionBehavior, stateParam);
258
301
  delete stateParam.optionBehavior;
@@ -642,7 +685,7 @@ class SelecticStore {
642
685
  }
643
686
  /* This method is for the computed property listOptions */
644
687
  getListOptions() {
645
- const options = this.props.options;
688
+ const options = deepClone(this.props.options, ['data']);
646
689
  const listOptions = [];
647
690
  if (!Array.isArray(options)) {
648
691
  return listOptions;
@@ -679,7 +722,7 @@ class SelecticStore {
679
722
  }
680
723
  /* This method is for the computed property elementOptions */
681
724
  getElementOptions() {
682
- const options = this.props.childOptions;
725
+ const options = deepClone(this.props.childOptions, ['data']);
683
726
  const childOptions = [];
684
727
  if (!Array.isArray(options) || options.length === 0) {
685
728
  return childOptions;
@@ -1389,7 +1432,7 @@ __decorate$4([
1389
1432
  Prop({ default: '' })
1390
1433
  ], MainInput.prototype, "id", void 0);
1391
1434
  __decorate$4([
1392
- Watch('store.state.internalValue')
1435
+ Watch('store.state.internalValue', { deep: true })
1393
1436
  ], MainInput.prototype, "onInternalChange", null);
1394
1437
  MainInput = __decorate$4([
1395
1438
  Component
@@ -1493,7 +1536,7 @@ let FilterPanel = class FilterPanel extends Vue {
1493
1536
  document.addEventListener('keypress', this.onKeyPressed);
1494
1537
  this.getFocus();
1495
1538
  }
1496
- destroyed() {
1539
+ unmounted() {
1497
1540
  document.removeEventListener('keypress', this.onKeyPressed);
1498
1541
  }
1499
1542
  /* }}} */
@@ -1753,7 +1796,7 @@ __decorate$2([
1753
1796
  Watch('store.state.offsetItem')
1754
1797
  ], List.prototype, "onOffsetChange", null);
1755
1798
  __decorate$2([
1756
- Watch('filteredOptions')
1799
+ Watch('filteredOptions', { deep: true })
1757
1800
  ], List.prototype, "onFilteredOptionsChange", null);
1758
1801
  __decorate$2([
1759
1802
  Watch('groupId')
@@ -1924,7 +1967,7 @@ let ExtendedList = class ExtendedList extends Vue {
1924
1967
  document.body.addEventListener('keydown', this.onKeyDown);
1925
1968
  this.computeListSize();
1926
1969
  }
1927
- destroyed() {
1970
+ unmounted() {
1928
1971
  document.body.removeEventListener('keydown', this.onKeyDown);
1929
1972
  /* force the element to be removed from DOM */
1930
1973
  if (this.$el.parentNode) {
@@ -1969,7 +2012,7 @@ __decorate$1([
1969
2012
  Prop({ default: 300 })
1970
2013
  ], ExtendedList.prototype, "width", void 0);
1971
2014
  __decorate$1([
1972
- Watch('store.state.filteredOptions')
2015
+ Watch('store.state.filteredOptions', { deep: true })
1973
2016
  ], ExtendedList.prototype, "onFilteredOptionsChange", null);
1974
2017
  __decorate$1([
1975
2018
  Watch('store.state.hideFilter')
@@ -2217,7 +2260,7 @@ let Selectic = class Selectic extends Vue {
2217
2260
  this.store.props.selectionIsExcluded = this.selectionIsExcluded;
2218
2261
  }
2219
2262
  onOptionsChange() {
2220
- this.store.props.options = Array.from(this.options);
2263
+ this.store.props.options = deepClone(this.options);
2221
2264
  }
2222
2265
  onTextsChange() {
2223
2266
  const texts = this.texts;
@@ -2458,7 +2501,7 @@ let Selectic = class Selectic extends Vue {
2458
2501
  // }
2459
2502
  // this.store.childOptions = options;
2460
2503
  }
2461
- beforeDestroy() {
2504
+ beforeUnmount() {
2462
2505
  this.removeListeners();
2463
2506
  }
2464
2507
  /* }}} */
@@ -2534,22 +2577,22 @@ __decorate([
2534
2577
  Prop()
2535
2578
  ], Selectic.prototype, "_getMethods", void 0);
2536
2579
  __decorate([
2537
- Watch('value')
2580
+ Watch('value', { deep: true })
2538
2581
  ], Selectic.prototype, "onValueChange", null);
2539
2582
  __decorate([
2540
2583
  Watch('selectionIsExcluded')
2541
2584
  ], Selectic.prototype, "onExcludedChange", null);
2542
2585
  __decorate([
2543
- Watch('options')
2586
+ Watch('options', { deep: true })
2544
2587
  ], Selectic.prototype, "onOptionsChange", null);
2545
2588
  __decorate([
2546
- Watch('texts')
2589
+ Watch('texts', { deep: true })
2547
2590
  ], Selectic.prototype, "onTextsChange", null);
2548
2591
  __decorate([
2549
2592
  Watch('disabled')
2550
2593
  ], Selectic.prototype, "onDisabledChange", null);
2551
2594
  __decorate([
2552
- Watch('groups')
2595
+ Watch('groups', { deep: true })
2553
2596
  ], Selectic.prototype, "onGroupsChanged", null);
2554
2597
  __decorate([
2555
2598
  Watch('placeholder')
@@ -2561,7 +2604,7 @@ __decorate([
2561
2604
  Watch('isFocused')
2562
2605
  ], Selectic.prototype, "onFocusChanged", null);
2563
2606
  __decorate([
2564
- Watch('store.state.internalValue')
2607
+ Watch('store.state.internalValue', { deep: true })
2565
2608
  ], Selectic.prototype, "onInternalValueChange", null);
2566
2609
  __decorate([
2567
2610
  Emit('input'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selectic",
3
- "version": "3.0.7",
3
+ "version": "3.0.11",
4
4
  "description": "Smart Select for VueJS 3.x",
5
5
  "main": "dist/selectic.common.js",
6
6
  "module": "dist/selectic.esm.js",
package/rollup.config.js CHANGED
@@ -30,5 +30,12 @@ export default [{
30
30
  'vtyx',
31
31
  ],
32
32
  context: 'this',
33
+ }, {
34
+ input: 'lib/tools.js',
35
+ output: [{
36
+ file: 'test/dist/tools.js',
37
+ exports: 'named',
38
+ format: 'cjs',
39
+ }],
40
+ context: 'this',
33
41
  }];
34
-
@@ -192,7 +192,7 @@ export default class ExtendedList extends Vue<Props> {
192
192
  /* }}} */
193
193
  /* {{{ watch */
194
194
 
195
- @Watch('store.state.filteredOptions')
195
+ @Watch('store.state.filteredOptions', { deep: true })
196
196
  public onFilteredOptionsChange() {
197
197
  this.$nextTick(this.computeListSize);
198
198
  }
@@ -228,7 +228,7 @@ export default class ExtendedList extends Vue<Props> {
228
228
  this.computeListSize();
229
229
  }
230
230
 
231
- public destroyed() {
231
+ public unmounted() {
232
232
  document.body.removeEventListener('keydown', this.onKeyDown);
233
233
 
234
234
  /* force the element to be removed from DOM */
package/src/Filter.tsx CHANGED
@@ -133,7 +133,7 @@ export default class FilterPanel extends Vue<Props> {
133
133
  this.getFocus();
134
134
  }
135
135
 
136
- public destroyed() {
136
+ public unmounted() {
137
137
  document.removeEventListener('keypress', this.onKeyPressed);
138
138
  }
139
139
 
package/src/List.tsx CHANGED
@@ -220,7 +220,7 @@ export default class List extends Vue<Props> {
220
220
  this.checkOffset();
221
221
  }
222
222
 
223
- @Watch('filteredOptions')
223
+ @Watch('filteredOptions', { deep: true })
224
224
  public onFilteredOptionsChange() {
225
225
  this.checkOffset();
226
226
  }
package/src/MainInput.tsx CHANGED
@@ -264,7 +264,7 @@ export default class MainInput extends Vue<Props> {
264
264
  /* }}} */
265
265
  /* {{{ watch */
266
266
 
267
- @Watch('store.state.internalValue')
267
+ @Watch('store.state.internalValue', { deep: true })
268
268
  public onInternalChange() {
269
269
  this.nbHiddenItems = 0;
270
270
  }