@haiilo/catalyst 0.10.8 → 0.11.0

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.
Files changed (38) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/{p-e5c5e21d.entry.js → p-aa382647.entry.js} +4 -4
  4. package/dist/catalyst/p-aa382647.entry.js.map +1 -0
  5. package/dist/catalyst/scss/index.scss +1 -1
  6. package/dist/cjs/cat-alert_21.cjs.entry.js +74 -92
  7. package/dist/cjs/cat-alert_21.cjs.entry.js.map +1 -1
  8. package/dist/cjs/catalyst.cjs.js +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/collection-manifest.json +1 -1
  11. package/dist/collection/components/cat-badge/cat-badge.css +15 -15
  12. package/dist/collection/components/cat-input/cat-input.js +1 -1
  13. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  14. package/dist/collection/components/cat-radio/cat-radio.css +1 -0
  15. package/dist/collection/components/cat-radio-group/cat-radio-group.js +5 -4
  16. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
  17. package/dist/collection/components/cat-select/cat-select.js +84 -205
  18. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  19. package/dist/collection/scss/index.scss +1 -1
  20. package/dist/components/cat-badge.js +1 -1
  21. package/dist/components/cat-badge.js.map +1 -1
  22. package/dist/components/cat-input.js.map +1 -1
  23. package/dist/components/cat-radio-group.js +0 -2
  24. package/dist/components/cat-radio-group.js.map +1 -1
  25. package/dist/components/cat-radio.js +1 -1
  26. package/dist/components/cat-radio.js.map +1 -1
  27. package/dist/components/cat-select.js +77 -97
  28. package/dist/components/cat-select.js.map +1 -1
  29. package/dist/esm/cat-alert_21.entry.js +74 -92
  30. package/dist/esm/cat-alert_21.entry.js.map +1 -1
  31. package/dist/esm/catalyst.js +1 -1
  32. package/dist/esm/loader.js +1 -1
  33. package/dist/types/components/cat-input/cat-input.d.ts +1 -1
  34. package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +9 -0
  35. package/dist/types/components/cat-select/cat-select.d.ts +13 -28
  36. package/dist/types/components.d.ts +30 -37
  37. package/package.json +2 -2
  38. package/dist/catalyst/p-e5c5e21d.entry.js.map +0 -1
@@ -116,7 +116,7 @@ const CatAvatar = class {
116
116
  };
117
117
  CatAvatar.style = catAvatarCss;
118
118
 
119
- const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.badge-round{border-radius:10rem}.badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.badge-xs{height:0.75rem;min-width:0.75rem;font-size:0.75rem;padding:0rem 0.25rem}.badge-s{height:1rem;min-width:1rem;font-size:0.75rem;padding:0.25rem 0.5rem}.badge-m{height:1.25rem;min-width:1.25rem;font-size:0.75rem;padding:0.5rem 0.75rem}.badge-l{height:1.5rem;min-width:1.5rem;font-size:0.875rem;padding:0.75rem 1rem}.badge-xl{height:1.75rem;min-width:1.75rem;font-size:0.9375rem;padding:1rem 1.25rem}.badge-pulse.badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.badge-pulse.badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
119
+ const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.badge-round{border-radius:10rem}.badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.badge-xs{height:1rem;min-width:0.75rem;font-size:12px;padding:0 0.25rem}.badge-s{height:1.5rem;min-width:1rem;font-size:12px;padding:0 0.5rem}.badge-m{height:2rem;min-width:1.25rem;font-size:13px;padding:0 0.75rem}.badge-l{height:2.5rem;min-width:1.5rem;font-size:15px;padding:0 1rem}.badge-xl{height:3rem;min-width:1.75rem;font-size:18px;padding:0 1rem}.badge-pulse.badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.badge-pulse.badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
120
120
 
121
121
  const CatBadge = class {
122
122
  constructor(hostRef) {
@@ -3065,7 +3065,7 @@ const CatModal = class {
3065
3065
  };
3066
3066
  CatModal.style = catModalCss;
3067
3067
 
3068
- const catRadioCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;cursor:pointer}.label-left{flex-direction:row-reverse}.radio{display:flex;position:relative}.circle{position:absolute;width:0.75rem;height:0.75rem;background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-radius:10rem;top:calc(50% - 0.375rem);left:calc(50% - 0.375rem);visibility:hidden}input{margin:0;width:1.25rem;height:1.25rem;appearance:none;background-color:white;border:1px solid #d7dbe0;border-radius:10rem;cursor:inherit}input:checked{border-color:rgb(var(--cat-primary-bg, 32, 127, 138))}input:checked+.circle{visibility:visible}input:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.is-disabled input{background-color:#f8f8fb}.is-disabled input:checked{border-color:#d7dbe0}.is-disabled .circle{background-color:#d7dbe0}";
3068
+ const catRadioCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;cursor:pointer}.label-left{flex-direction:row-reverse}.radio{display:flex;position:relative;align-self:flex-start}.circle{position:absolute;width:0.75rem;height:0.75rem;background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-radius:10rem;top:calc(50% - 0.375rem);left:calc(50% - 0.375rem);visibility:hidden}input{margin:0;width:1.25rem;height:1.25rem;appearance:none;background-color:white;border:1px solid #d7dbe0;border-radius:10rem;cursor:inherit}input:checked{border-color:rgb(var(--cat-primary-bg, 32, 127, 138))}input:checked+.circle{visibility:visible}input:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.is-disabled input{background-color:#f8f8fb}.is-disabled input:checked{border-color:#d7dbe0}.is-disabled .circle{background-color:#d7dbe0}";
3069
3069
 
3070
3070
  let nextUniqueId$4 = 0;
3071
3071
  const CatRadio = class {
@@ -3184,7 +3184,6 @@ const CatRadioGroup = class {
3184
3184
  this.onValueChanged(this.value);
3185
3185
  this.onDisabledChanged(this.disabled);
3186
3186
  this.onLabelLeftChanged(this.labelLeft);
3187
- //this.updateTabIndex();
3188
3187
  }
3189
3188
  onKeydown(event) {
3190
3189
  var _a, _b;
@@ -3203,7 +3202,6 @@ const CatRadioGroup = class {
3203
3202
  onInput(event) {
3204
3203
  const catRadioElement = this.catRadioGroup.find(value => value === event.target);
3205
3204
  this.value = catRadioElement === null || catRadioElement === void 0 ? void 0 : catRadioElement.value;
3206
- //this.updateTabIndex();
3207
3205
  this.catChange.emit();
3208
3206
  }
3209
3207
  render() {
@@ -12063,6 +12061,7 @@ const CatSelect = class {
12063
12061
  this.catScrolledBottom = createEvent(this, "catScrolledBottom", 7);
12064
12062
  this.i18n = CatI18nRegistry.getInstance();
12065
12063
  this.id = `cat-select-${nextUniqueId$3++}`;
12064
+ this.resetItemsOnNextValueChange = true;
12066
12065
  this.hasSlottedLabel = false;
12067
12066
  /**
12068
12067
  * The label for the select.
@@ -12079,7 +12078,7 @@ const CatSelect = class {
12079
12078
  /**
12080
12079
  * The available options for the input.
12081
12080
  */
12082
- this.choices = [];
12081
+ this.items = [];
12083
12082
  /**
12084
12083
  * Disable the select.
12085
12084
  */
@@ -12101,17 +12100,39 @@ const CatSelect = class {
12101
12100
  /**
12102
12101
  * Enable search for the select.
12103
12102
  */
12104
- this.noSearch = false;
12105
- }
12106
- setChoicesHandler(choices) {
12107
- if (!(choices === null || choices === void 0 ? void 0 : choices.length))
12108
- return;
12109
- this.setChoices(choices, 'value', 'label', true);
12103
+ this.search = false;
12104
+ }
12105
+ setChoicesHandler(items) {
12106
+ var _a, _b, _c, _d;
12107
+ const isSelected = (item) => { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.includes(item.value); };
12108
+ const choices = items.map(item => (Object.assign(Object.assign({}, item), { selected: isSelected(item) })));
12109
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, 'value', 'label', true);
12110
+ const vItems = ((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue()) || [];
12111
+ const vItemsArray = (Array.isArray(vItems) ? vItems : [vItems]);
12112
+ const vItemValues = [...this.value];
12113
+ // remove duplicate items
12114
+ (_c = this.choice) === null || _c === void 0 ? void 0 : _c.unhighlightAll();
12115
+ vItemsArray.forEach(vItem => {
12116
+ var _a;
12117
+ const index = vItemValues.indexOf(vItem.value);
12118
+ if (index > -1) {
12119
+ vItemValues.splice(index, 1);
12120
+ }
12121
+ else {
12122
+ vItem.choiceId = -1; // disconnect item from choice
12123
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.highlightItem(vItem, false);
12124
+ }
12125
+ });
12126
+ (_d = this.choice) === null || _d === void 0 ? void 0 : _d.removeHighlightedItems(false);
12110
12127
  }
12111
12128
  setValueHandler(value) {
12112
- if (this.multiple)
12113
- return;
12114
- this.setValue(value || []);
12129
+ var _a, _b;
12130
+ if (this.resetItemsOnNextValueChange) {
12131
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
12132
+ }
12133
+ this.resetItemsOnNextValueChange = true;
12134
+ (_b = this.choice) === null || _b === void 0 ? void 0 : _b.setChoiceByValue(value);
12135
+ this.multiple && this.updateRemoveItemButtonVisibility();
12115
12136
  }
12116
12137
  componentWillRender() {
12117
12138
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
@@ -12120,88 +12141,48 @@ const CatSelect = class {
12120
12141
  }
12121
12142
  }
12122
12143
  componentDidLoad() {
12123
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12144
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12124
12145
  this.init();
12125
12146
  const attachedInternals = (_b = (_a = this.hostElement).attachInternals) === null || _b === void 0 ? void 0 : _b.call(_a);
12126
12147
  if (attachedInternals) {
12127
- this.choiceInner = ((_c = attachedInternals.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.choices__inner')) || undefined;
12128
- this.choiceDropdown =
12129
- ((_e = (_d = attachedInternals.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.choices__list--dropdown')) === null || _e === void 0 ? void 0 : _e.firstElementChild) || undefined;
12130
- }
12131
- (_f = this.choiceInner) === null || _f === void 0 ? void 0 : _f.addEventListener('click', this.showDropdownHandler.bind(this));
12132
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.addEventListener('addItem', this.onChange.bind(this));
12133
- (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('removeItem', this.onChange.bind(this));
12134
- (_j = this.selectElement) === null || _j === void 0 ? void 0 : _j.addEventListener('search', this.onSearch.bind(this));
12135
- (_k = this.choiceDropdown) === null || _k === void 0 ? void 0 : _k.addEventListener('scroll', this.onScrolledBottom.bind(this));
12148
+ const root = attachedInternals.shadowRoot;
12149
+ this.choiceInner = (root === null || root === void 0 ? void 0 : root.querySelector('.choices__inner')) || undefined;
12150
+ this.choiceDropdown = ((_c = root === null || root === void 0 ? void 0 : root.querySelector('.choices__list--dropdown')) === null || _c === void 0 ? void 0 : _c.firstElementChild) || undefined;
12151
+ }
12152
+ (_d = this.choiceInner) === null || _d === void 0 ? void 0 : _d.addEventListener('click', this.showDropdownHandler.bind(this));
12153
+ (_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.addEventListener('change', this.onChange.bind(this));
12154
+ (_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.addEventListener('search', this.onSearch.bind(this));
12155
+ (_g = this.choiceDropdown) === null || _g === void 0 ? void 0 : _g.addEventListener('scroll', this.onScrolledBottom.bind(this));
12136
12156
  if (this.multiple) {
12137
- (_l = this.selectElement) === null || _l === void 0 ? void 0 : _l.addEventListener('choice', this.onChoice.bind(this));
12157
+ (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('choice', this.onChoice.bind(this));
12138
12158
  this.createRemoveItemButton();
12139
12159
  }
12140
12160
  }
12141
12161
  disconnectedCallback() {
12142
- var _a, _b, _c, _d, _e, _f, _g, _h;
12162
+ var _a, _b, _c, _d, _e, _f;
12143
12163
  (_a = this.choice) === null || _a === void 0 ? void 0 : _a.destroy();
12144
12164
  this.choice = undefined;
12145
12165
  (_b = this.choiceInner) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.showDropdownHandler.bind(this));
12146
- (_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('addItem', this.onChange.bind(this));
12147
- (_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('removeItem', this.onChange.bind(this));
12148
- (_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('search', this.onSearch.bind(this));
12149
- (_f = this.choiceDropdown) === null || _f === void 0 ? void 0 : _f.removeEventListener('scroll', this.onScrolledBottom.bind(this));
12166
+ (_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('change', this.onChange.bind(this));
12167
+ (_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('search', this.onSearch.bind(this));
12168
+ (_e = this.choiceDropdown) === null || _e === void 0 ? void 0 : _e.removeEventListener('scroll', this.onScrolledBottom.bind(this));
12150
12169
  if (this.multiple) {
12151
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.removeEventListener('choice', this.onChoice.bind(this));
12152
- (_h = this.removeElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('click', this.onRemoveItemButtonClick.bind(this));
12170
+ (_f = this.removeElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('choice', this.onChoice.bind(this));
12153
12171
  }
12154
12172
  }
12155
- /**
12156
- * Set value of input based on an array of objects or strings. This behaves
12157
- * exactly the same as passing items via the items option but can be called
12158
- * after initialisation.
12159
- */
12160
- async setValue(args) {
12161
- var _a;
12162
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setValue(args);
12163
- return this;
12164
- }
12165
- /**
12166
- * Set choices of select input via an array of objects (or function that
12167
- * returns array of object or promise of it), a value field name and a label
12168
- * field name.
12169
- */
12170
- async setChoices(choices, value, label, replaceChoices) {
12171
- var _a;
12172
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, value, label, replaceChoices);
12173
- return this;
12174
- }
12175
- /**
12176
- * Clear all choices from select.
12177
- */
12178
- async clearChoices() {
12179
- var _a;
12180
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearChoices();
12181
- return this;
12182
- }
12183
- /**
12184
- * Clear input of any user inputted text.
12185
- */
12186
- async clearInput() {
12187
- var _a;
12188
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearInput();
12189
- return this;
12190
- }
12191
12173
  render() {
12192
12174
  return (h(Host, null, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.t('input.optional'), ")"))))), h("select", { id: this.id, ref: el => (this.selectElement = el), multiple: this.multiple, disabled: this.disabled }), this.hintSection));
12193
12175
  }
12194
12176
  init() {
12195
- const value = this.value || [];
12177
+ const component = this; // eslint-disable-line @typescript-eslint/no-this-alias
12196
12178
  const removeItemText = (value) => this.i18n.t('select.removeItem', { value });
12197
12179
  const config = {
12198
12180
  allowHTML: true,
12199
- items: Array.isArray(value) ? value : [value],
12200
12181
  removeItemButton: true,
12201
12182
  duplicateItemsAllowed: false,
12202
12183
  delimiter: '',
12203
12184
  paste: false,
12204
- searchEnabled: !this.noSearch,
12185
+ searchEnabled: this.search,
12205
12186
  searchChoices: false,
12206
12187
  position: this.position,
12207
12188
  resetScrollPosition: false,
@@ -12216,7 +12197,12 @@ const CatSelect = class {
12216
12197
  addItemText: (value) => this.i18n.t('select.addItem', { value }),
12217
12198
  maxItemText: (maxItemCount) => this.i18n.t('select.maxItem', { maxItemCount }),
12218
12199
  uniqueItemText: this.i18n.t('select.uniqueItem'),
12219
- customAddItemText: this.i18n.t('select.customAddItem')
12200
+ customAddItemText: this.i18n.t('select.customAddItem'),
12201
+ callbackOnInit: function () {
12202
+ const choice = this;
12203
+ choice.setChoices(component.items, 'value', 'label', true);
12204
+ choice.setChoiceByValue(component.value);
12205
+ }
12220
12206
  };
12221
12207
  const configSingle = {
12222
12208
  callbackOnCreateTemplates: (strToEl) => {
@@ -12282,18 +12268,24 @@ const CatSelect = class {
12282
12268
  const settings = this.multiple
12283
12269
  ? Object.assign(Object.assign({}, config), configMultiple) : Object.assign(Object.assign({}, config), configSingle);
12284
12270
  this.choice = new Choices(this.selectElement, settings);
12285
- this.choice.setChoices(this.choices);
12286
12271
  }
12287
12272
  get hintSection() {
12288
12273
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
12289
12274
  return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
12290
12275
  }
12291
12276
  onChange() {
12292
- var _a, _b;
12293
- this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue();
12294
- this.catChange.emit((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue());
12295
- if (this.multiple) {
12296
- this.updateRemoveItemButtonVisibility();
12277
+ var _a;
12278
+ this.resetItemsOnNextValueChange = false;
12279
+ this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue(true);
12280
+ this.catChange.emit(this.value);
12281
+ }
12282
+ onChoice(event) {
12283
+ var _a;
12284
+ const customEvent = event;
12285
+ const coice = customEvent.detail.choice;
12286
+ if (coice.selected) {
12287
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItemsByValue(coice.value);
12288
+ this.onChange();
12297
12289
  }
12298
12290
  }
12299
12291
  onSearch(event) {
@@ -12308,20 +12300,9 @@ const CatSelect = class {
12308
12300
  this.catScrolledBottom.emit();
12309
12301
  }
12310
12302
  }
12311
- onChoice(event) {
12312
- var _a, _b;
12313
- const customEvent = event;
12314
- const items = Array.from((_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue());
12315
- const item = items.find(value => value.choiceId === customEvent.detail.choice.id);
12316
- if (item) {
12317
- (_b = this.choice) === null || _b === void 0 ? void 0 : _b._removeItem(item);
12318
- }
12319
- }
12320
12303
  showDropdownHandler() {
12321
12304
  var _a;
12322
- if (!this.disabled) {
12323
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown();
12324
- }
12305
+ !this.disabled && ((_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown());
12325
12306
  }
12326
12307
  createRemoveItemButton() {
12327
12308
  var _a;
@@ -12339,7 +12320,7 @@ const CatSelect = class {
12339
12320
  if (items.length) {
12340
12321
  (_b = this.removeElement) === null || _b === void 0 ? void 0 : _b.removeAttribute('hidden');
12341
12322
  }
12342
- else if (!items.length) {
12323
+ else {
12343
12324
  (_c = this.removeElement) === null || _c === void 0 ? void 0 : _c.setAttribute('hidden', 'true');
12344
12325
  }
12345
12326
  }
@@ -12347,10 +12328,11 @@ const CatSelect = class {
12347
12328
  var _a;
12348
12329
  event.stopPropagation();
12349
12330
  (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
12331
+ this.updateRemoveItemButtonVisibility();
12350
12332
  }
12351
12333
  get hostElement() { return getElement(this); }
12352
12334
  static get watchers() { return {
12353
- "choices": ["setChoicesHandler"],
12335
+ "items": ["setChoicesHandler"],
12354
12336
  "value": ["setValueHandler"]
12355
12337
  }; }
12356
12338
  };