selectic 3.0.8 → 3.0.9

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,42 @@ 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(obj, refs = new WeakMap()) {
45
+ /* For circular references */
46
+ if (refs.has(obj)) {
47
+ return refs.get(obj);
48
+ }
49
+ if (typeof obj === 'object') {
50
+ if (Array.isArray(obj)) {
51
+ const ref = [];
52
+ refs.set(obj, ref);
53
+ obj.forEach((val, idx) => {
54
+ ref[idx] = deepClone(val, 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
+ ref[key] = deepClone(val, refs);
68
+ }
69
+ return ref;
70
+ }
71
+ /* This should be a primitive */
72
+ return obj;
73
+ }
45
74
  /**
46
75
  * Escape search string to consider regexp special characters as they
47
76
  * are and not like special characters.
@@ -72,6 +101,12 @@ function assignObject(obj, ...sourceObjects) {
72
101
  }
73
102
  return result;
74
103
  }
104
+
105
+ /* File Purpose:
106
+ * It keeps and computes all states at a single place.
107
+ * Every inner components of Selectic should communicate with this file to
108
+ * change or to get states.
109
+ */
75
110
  /* }}} */
76
111
  /* {{{ Static */
77
112
  function changeTexts$1(texts) {
@@ -2221,7 +2256,7 @@ let Selectic = class Selectic extends vtyx.Vue {
2221
2256
  this.store.props.selectionIsExcluded = this.selectionIsExcluded;
2222
2257
  }
2223
2258
  onOptionsChange() {
2224
- this.store.props.options = Array.from(this.options);
2259
+ this.store.props.options = deepClone(this.options);
2225
2260
  }
2226
2261
  onTextsChange() {
2227
2262
  const texts = this.texts;
@@ -31,13 +31,42 @@ 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(obj, refs = new WeakMap()) {
41
+ /* For circular references */
42
+ if (refs.has(obj)) {
43
+ return refs.get(obj);
44
+ }
45
+ if (typeof obj === 'object') {
46
+ if (Array.isArray(obj)) {
47
+ const ref = [];
48
+ refs.set(obj, ref);
49
+ obj.forEach((val, idx) => {
50
+ ref[idx] = deepClone(val, refs);
51
+ });
52
+ return ref;
53
+ }
54
+ if (obj instanceof RegExp) {
55
+ const ref = new RegExp(obj.source, obj.flags);
56
+ refs.set(obj, ref);
57
+ return ref;
58
+ }
59
+ /* This should be an object */
60
+ const ref = {};
61
+ refs.set(obj, ref);
62
+ for (const [key, val] of Object.entries(obj)) {
63
+ ref[key] = deepClone(val, refs);
64
+ }
65
+ return ref;
66
+ }
67
+ /* This should be a primitive */
68
+ return obj;
69
+ }
41
70
  /**
42
71
  * Escape search string to consider regexp special characters as they
43
72
  * are and not like special characters.
@@ -68,6 +97,12 @@ function assignObject(obj, ...sourceObjects) {
68
97
  }
69
98
  return result;
70
99
  }
100
+
101
+ /* File Purpose:
102
+ * It keeps and computes all states at a single place.
103
+ * Every inner components of Selectic should communicate with this file to
104
+ * change or to get states.
105
+ */
71
106
  /* }}} */
72
107
  /* {{{ Static */
73
108
  function changeTexts$1(texts) {
@@ -2217,7 +2252,7 @@ let Selectic = class Selectic extends Vue {
2217
2252
  this.store.props.selectionIsExcluded = this.selectionIsExcluded;
2218
2253
  }
2219
2254
  onOptionsChange() {
2220
- this.store.props.options = Array.from(this.options);
2255
+ this.store.props.options = deepClone(this.options);
2221
2256
  }
2222
2257
  onTextsChange() {
2223
2258
  const texts = this.texts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selectic",
3
- "version": "3.0.8",
3
+ "version": "3.0.9",
4
4
  "description": "Smart Select for VueJS 3.x",
5
5
  "main": "dist/selectic.common.js",
6
6
  "module": "dist/selectic.esm.js",
package/src/Store.tsx CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { reactive, watch, unref, computed, ComputedRef } from 'vue';
8
+ import { convertToRegExp, assignObject } from './tools';
8
9
 
9
10
  /* {{{ Types definitions */
10
11
 
@@ -336,42 +337,6 @@ interface Messages {
336
337
 
337
338
  export type PartialMessages = { [K in keyof Messages]?: Messages[K] };
338
339
 
339
- /* }}} */
340
- /* {{{ Helper */
341
-
342
- /**
343
- * Escape search string to consider regexp special characters as they
344
- * are and not like special characters.
345
- * Consider * characters as a wildcards characters (meanings 0 or
346
- * more characters) and convert them to .* (the wildcard characters
347
- * in Regexp)
348
- *
349
- * @param {String} name the original string to convert
350
- * @param {String} [flag] mode to apply for regExp
351
- * @return {String} the string ready to use for RegExp format
352
- */
353
- function convertToRegExp(name: string, flag = 'i'): RegExp {
354
- const pattern = name.replace(/[\\^$.+?(){}[\]|]/g, '\\$&')
355
- .replace(/\*/g, '.*');
356
-
357
- return new RegExp(pattern, flag);
358
- }
359
-
360
- /** Does the same as Object.assign but does not replace if value is undefined */
361
- function assignObject<T>(obj: Partial<T>, ...sourceObjects: Array<Partial<T>>): T {
362
- const result = obj;
363
- for (const source of sourceObjects) {
364
- for (const key of Object.keys(source)) {
365
- const value = source[key as keyof T];
366
- if (value === undefined) {
367
- continue;
368
- }
369
- result[key as keyof T] = value;
370
- }
371
- }
372
- return result as T;
373
- }
374
-
375
340
  /* }}} */
376
341
  /* {{{ Static */
377
342
 
package/src/index.tsx CHANGED
@@ -21,6 +21,8 @@
21
21
  import {Vue, Component, Emit, Prop, Watch, h} from 'vtyx';
22
22
  import './css/selectic.css';
23
23
 
24
+ import { deepClone } from './tools';
25
+
24
26
  import Store, {
25
27
  changeTexts as storeChangeTexts,
26
28
  OptionProp,
@@ -558,7 +560,7 @@ export default class Selectic extends Vue<Props> {
558
560
 
559
561
  @Watch('options', { deep: true })
560
562
  public onOptionsChange() {
561
- this.store.props.options = Array.from(this.options);
563
+ this.store.props.options = deepClone(this.options);
562
564
  }
563
565
 
564
566
  @Watch('texts', { deep: true })
package/src/tools.ts ADDED
@@ -0,0 +1,75 @@
1
+
2
+ /**
3
+ * Clone the object and its inner properties.
4
+ * @param obj The object to be clone.
5
+ * @param refs internal reference to object to avoid cyclic references
6
+ * @returns a copy of obj
7
+ */
8
+ export function deepClone<T = any>(obj: T, refs: WeakMap<any, any> = new WeakMap()): T {
9
+ /* For circular references */
10
+ if (refs.has(obj)) {
11
+ return refs.get(obj);
12
+ }
13
+
14
+ if (typeof obj === 'object') {
15
+ if (Array.isArray(obj)) {
16
+ const ref: any[] = [];
17
+ refs.set(obj, ref);
18
+ obj.forEach((val, idx) => {
19
+ ref[idx] = deepClone(val, refs);
20
+ });
21
+ return ref as unknown as T;
22
+ }
23
+
24
+ if (obj instanceof RegExp) {
25
+ const ref = new RegExp(obj.source, obj.flags);
26
+ refs.set(obj, ref);
27
+ return ref as unknown as T;
28
+ }
29
+
30
+ /* This should be an object */
31
+ const ref: any = {};
32
+ refs.set(obj, ref);
33
+ for (const [key, val] of Object.entries(obj)) {
34
+ ref[key] = deepClone(val, refs);
35
+ }
36
+ return ref as unknown as T;
37
+ }
38
+
39
+ /* This should be a primitive */
40
+ return obj;
41
+ }
42
+
43
+
44
+ /**
45
+ * Escape search string to consider regexp special characters as they
46
+ * are and not like special characters.
47
+ * Consider * characters as a wildcards characters (meanings 0 or
48
+ * more characters) and convert them to .* (the wildcard characters
49
+ * in Regexp)
50
+ *
51
+ * @param {String} name the original string to convert
52
+ * @param {String} [flag] mode to apply for regExp
53
+ * @return {String} the string ready to use for RegExp format
54
+ */
55
+ export function convertToRegExp(name: string, flag = 'i'): RegExp {
56
+ const pattern = name.replace(/[\\^$.+?(){}[\]|]/g, '\\$&')
57
+ .replace(/\*/g, '.*');
58
+
59
+ return new RegExp(pattern, flag);
60
+ }
61
+
62
+ /** Does the same as Object.assign but does not replace if value is undefined */
63
+ export function assignObject<T>(obj: Partial<T>, ...sourceObjects: Array<Partial<T>>): T {
64
+ const result = obj;
65
+ for (const source of sourceObjects) {
66
+ for (const key of Object.keys(source)) {
67
+ const value = source[key as keyof T];
68
+ if (value === undefined) {
69
+ continue;
70
+ }
71
+ result[key as keyof T] = value;
72
+ }
73
+ }
74
+ return result as T;
75
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Clone the object and its inner properties.
3
+ * @param obj The object to be clone.
4
+ * @param refs internal reference to object to avoid cyclic references
5
+ * @returns a copy of obj
6
+ */
7
+ export declare function deepClone<T = any>(obj: T, refs?: WeakMap<any, any>): T;
8
+ /**
9
+ * Escape search string to consider regexp special characters as they
10
+ * are and not like special characters.
11
+ * Consider * characters as a wildcards characters (meanings 0 or
12
+ * more characters) and convert them to .* (the wildcard characters
13
+ * in Regexp)
14
+ *
15
+ * @param {String} name the original string to convert
16
+ * @param {String} [flag] mode to apply for regExp
17
+ * @return {String} the string ready to use for RegExp format
18
+ */
19
+ export declare function convertToRegExp(name: string, flag?: string): RegExp;
20
+ /** Does the same as Object.assign but does not replace if value is undefined */
21
+ export declare function assignObject<T>(obj: Partial<T>, ...sourceObjects: Array<Partial<T>>): T;