@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
@@ -68,7 +68,7 @@ section {
68
68
  padding: 2rem 0;
69
69
 
70
70
  &:not(:last-of-type) {
71
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
71
+ border-bottom: 1px solid rgba(0, 0, 0, 10%);
72
72
  }
73
73
 
74
74
  > h2:not(:first-child),
@@ -120,7 +120,7 @@ const CatAvatar = class {
120
120
  };
121
121
  CatAvatar.style = catAvatarCss;
122
122
 
123
- 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)}}";
123
+ 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)}}";
124
124
 
125
125
  const CatBadge = class {
126
126
  constructor(hostRef) {
@@ -3069,7 +3069,7 @@ const CatModal = class {
3069
3069
  };
3070
3070
  CatModal.style = catModalCss;
3071
3071
 
3072
- 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}";
3072
+ 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}";
3073
3073
 
3074
3074
  let nextUniqueId$4 = 0;
3075
3075
  const CatRadio = class {
@@ -3188,7 +3188,6 @@ const CatRadioGroup = class {
3188
3188
  this.onValueChanged(this.value);
3189
3189
  this.onDisabledChanged(this.disabled);
3190
3190
  this.onLabelLeftChanged(this.labelLeft);
3191
- //this.updateTabIndex();
3192
3191
  }
3193
3192
  onKeydown(event) {
3194
3193
  var _a, _b;
@@ -3207,7 +3206,6 @@ const CatRadioGroup = class {
3207
3206
  onInput(event) {
3208
3207
  const catRadioElement = this.catRadioGroup.find(value => value === event.target);
3209
3208
  this.value = catRadioElement === null || catRadioElement === void 0 ? void 0 : catRadioElement.value;
3210
- //this.updateTabIndex();
3211
3209
  this.catChange.emit();
3212
3210
  }
3213
3211
  render() {
@@ -12067,6 +12065,7 @@ const CatSelect = class {
12067
12065
  this.catScrolledBottom = index.createEvent(this, "catScrolledBottom", 7);
12068
12066
  this.i18n = catNotification.CatI18nRegistry.getInstance();
12069
12067
  this.id = `cat-select-${nextUniqueId$3++}`;
12068
+ this.resetItemsOnNextValueChange = true;
12070
12069
  this.hasSlottedLabel = false;
12071
12070
  /**
12072
12071
  * The label for the select.
@@ -12083,7 +12082,7 @@ const CatSelect = class {
12083
12082
  /**
12084
12083
  * The available options for the input.
12085
12084
  */
12086
- this.choices = [];
12085
+ this.items = [];
12087
12086
  /**
12088
12087
  * Disable the select.
12089
12088
  */
@@ -12105,17 +12104,39 @@ const CatSelect = class {
12105
12104
  /**
12106
12105
  * Enable search for the select.
12107
12106
  */
12108
- this.noSearch = false;
12109
- }
12110
- setChoicesHandler(choices) {
12111
- if (!(choices === null || choices === void 0 ? void 0 : choices.length))
12112
- return;
12113
- this.setChoices(choices, 'value', 'label', true);
12107
+ this.search = false;
12108
+ }
12109
+ setChoicesHandler(items) {
12110
+ var _a, _b, _c, _d;
12111
+ const isSelected = (item) => { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.includes(item.value); };
12112
+ const choices = items.map(item => (Object.assign(Object.assign({}, item), { selected: isSelected(item) })));
12113
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, 'value', 'label', true);
12114
+ const vItems = ((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue()) || [];
12115
+ const vItemsArray = (Array.isArray(vItems) ? vItems : [vItems]);
12116
+ const vItemValues = [...this.value];
12117
+ // remove duplicate items
12118
+ (_c = this.choice) === null || _c === void 0 ? void 0 : _c.unhighlightAll();
12119
+ vItemsArray.forEach(vItem => {
12120
+ var _a;
12121
+ const index = vItemValues.indexOf(vItem.value);
12122
+ if (index > -1) {
12123
+ vItemValues.splice(index, 1);
12124
+ }
12125
+ else {
12126
+ vItem.choiceId = -1; // disconnect item from choice
12127
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.highlightItem(vItem, false);
12128
+ }
12129
+ });
12130
+ (_d = this.choice) === null || _d === void 0 ? void 0 : _d.removeHighlightedItems(false);
12114
12131
  }
12115
12132
  setValueHandler(value) {
12116
- if (this.multiple)
12117
- return;
12118
- this.setValue(value || []);
12133
+ var _a, _b;
12134
+ if (this.resetItemsOnNextValueChange) {
12135
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
12136
+ }
12137
+ this.resetItemsOnNextValueChange = true;
12138
+ (_b = this.choice) === null || _b === void 0 ? void 0 : _b.setChoiceByValue(value);
12139
+ this.multiple && this.updateRemoveItemButtonVisibility();
12119
12140
  }
12120
12141
  componentWillRender() {
12121
12142
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
@@ -12124,88 +12145,48 @@ const CatSelect = class {
12124
12145
  }
12125
12146
  }
12126
12147
  componentDidLoad() {
12127
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
12148
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12128
12149
  this.init();
12129
12150
  const attachedInternals = (_b = (_a = this.hostElement).attachInternals) === null || _b === void 0 ? void 0 : _b.call(_a);
12130
12151
  if (attachedInternals) {
12131
- this.choiceInner = ((_c = attachedInternals.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.choices__inner')) || undefined;
12132
- this.choiceDropdown =
12133
- ((_e = (_d = attachedInternals.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.choices__list--dropdown')) === null || _e === void 0 ? void 0 : _e.firstElementChild) || undefined;
12134
- }
12135
- (_f = this.choiceInner) === null || _f === void 0 ? void 0 : _f.addEventListener('click', this.showDropdownHandler.bind(this));
12136
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.addEventListener('addItem', this.onChange.bind(this));
12137
- (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('removeItem', this.onChange.bind(this));
12138
- (_j = this.selectElement) === null || _j === void 0 ? void 0 : _j.addEventListener('search', this.onSearch.bind(this));
12139
- (_k = this.choiceDropdown) === null || _k === void 0 ? void 0 : _k.addEventListener('scroll', this.onScrolledBottom.bind(this));
12152
+ const root = attachedInternals.shadowRoot;
12153
+ this.choiceInner = (root === null || root === void 0 ? void 0 : root.querySelector('.choices__inner')) || undefined;
12154
+ this.choiceDropdown = ((_c = root === null || root === void 0 ? void 0 : root.querySelector('.choices__list--dropdown')) === null || _c === void 0 ? void 0 : _c.firstElementChild) || undefined;
12155
+ }
12156
+ (_d = this.choiceInner) === null || _d === void 0 ? void 0 : _d.addEventListener('click', this.showDropdownHandler.bind(this));
12157
+ (_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.addEventListener('change', this.onChange.bind(this));
12158
+ (_f = this.selectElement) === null || _f === void 0 ? void 0 : _f.addEventListener('search', this.onSearch.bind(this));
12159
+ (_g = this.choiceDropdown) === null || _g === void 0 ? void 0 : _g.addEventListener('scroll', this.onScrolledBottom.bind(this));
12140
12160
  if (this.multiple) {
12141
- (_l = this.selectElement) === null || _l === void 0 ? void 0 : _l.addEventListener('choice', this.onChoice.bind(this));
12161
+ (_h = this.selectElement) === null || _h === void 0 ? void 0 : _h.addEventListener('choice', this.onChoice.bind(this));
12142
12162
  this.createRemoveItemButton();
12143
12163
  }
12144
12164
  }
12145
12165
  disconnectedCallback() {
12146
- var _a, _b, _c, _d, _e, _f, _g, _h;
12166
+ var _a, _b, _c, _d, _e, _f;
12147
12167
  (_a = this.choice) === null || _a === void 0 ? void 0 : _a.destroy();
12148
12168
  this.choice = undefined;
12149
12169
  (_b = this.choiceInner) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.showDropdownHandler.bind(this));
12150
- (_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('addItem', this.onChange.bind(this));
12151
- (_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('removeItem', this.onChange.bind(this));
12152
- (_e = this.selectElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('search', this.onSearch.bind(this));
12153
- (_f = this.choiceDropdown) === null || _f === void 0 ? void 0 : _f.removeEventListener('scroll', this.onScrolledBottom.bind(this));
12170
+ (_c = this.selectElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('change', this.onChange.bind(this));
12171
+ (_d = this.selectElement) === null || _d === void 0 ? void 0 : _d.removeEventListener('search', this.onSearch.bind(this));
12172
+ (_e = this.choiceDropdown) === null || _e === void 0 ? void 0 : _e.removeEventListener('scroll', this.onScrolledBottom.bind(this));
12154
12173
  if (this.multiple) {
12155
- (_g = this.selectElement) === null || _g === void 0 ? void 0 : _g.removeEventListener('choice', this.onChoice.bind(this));
12156
- (_h = this.removeElement) === null || _h === void 0 ? void 0 : _h.removeEventListener('click', this.onRemoveItemButtonClick.bind(this));
12174
+ (_f = this.removeElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('choice', this.onChoice.bind(this));
12157
12175
  }
12158
12176
  }
12159
- /**
12160
- * Set value of input based on an array of objects or strings. This behaves
12161
- * exactly the same as passing items via the items option but can be called
12162
- * after initialisation.
12163
- */
12164
- async setValue(args) {
12165
- var _a;
12166
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setValue(args);
12167
- return this;
12168
- }
12169
- /**
12170
- * Set choices of select input via an array of objects (or function that
12171
- * returns array of object or promise of it), a value field name and a label
12172
- * field name.
12173
- */
12174
- async setChoices(choices, value, label, replaceChoices) {
12175
- var _a;
12176
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.setChoices(choices, value, label, replaceChoices);
12177
- return this;
12178
- }
12179
- /**
12180
- * Clear all choices from select.
12181
- */
12182
- async clearChoices() {
12183
- var _a;
12184
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearChoices();
12185
- return this;
12186
- }
12187
- /**
12188
- * Clear input of any user inputted text.
12189
- */
12190
- async clearInput() {
12191
- var _a;
12192
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.clearInput();
12193
- return this;
12194
- }
12195
12177
  render() {
12196
12178
  return (index.h(index.Host, null, (this.hasSlottedLabel || this.label) && (index.h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, index.h("span", { part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label, !this.required && (index.h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.t('input.optional'), ")"))))), index.h("select", { id: this.id, ref: el => (this.selectElement = el), multiple: this.multiple, disabled: this.disabled }), this.hintSection));
12197
12179
  }
12198
12180
  init() {
12199
- const value = this.value || [];
12181
+ const component = this; // eslint-disable-line @typescript-eslint/no-this-alias
12200
12182
  const removeItemText = (value) => this.i18n.t('select.removeItem', { value });
12201
12183
  const config = {
12202
12184
  allowHTML: true,
12203
- items: Array.isArray(value) ? value : [value],
12204
12185
  removeItemButton: true,
12205
12186
  duplicateItemsAllowed: false,
12206
12187
  delimiter: '',
12207
12188
  paste: false,
12208
- searchEnabled: !this.noSearch,
12189
+ searchEnabled: this.search,
12209
12190
  searchChoices: false,
12210
12191
  position: this.position,
12211
12192
  resetScrollPosition: false,
@@ -12220,7 +12201,12 @@ const CatSelect = class {
12220
12201
  addItemText: (value) => this.i18n.t('select.addItem', { value }),
12221
12202
  maxItemText: (maxItemCount) => this.i18n.t('select.maxItem', { maxItemCount }),
12222
12203
  uniqueItemText: this.i18n.t('select.uniqueItem'),
12223
- customAddItemText: this.i18n.t('select.customAddItem')
12204
+ customAddItemText: this.i18n.t('select.customAddItem'),
12205
+ callbackOnInit: function () {
12206
+ const choice = this;
12207
+ choice.setChoices(component.items, 'value', 'label', true);
12208
+ choice.setChoiceByValue(component.value);
12209
+ }
12224
12210
  };
12225
12211
  const configSingle = {
12226
12212
  callbackOnCreateTemplates: (strToEl) => {
@@ -12286,18 +12272,24 @@ const CatSelect = class {
12286
12272
  const settings = this.multiple
12287
12273
  ? Object.assign(Object.assign({}, config), configMultiple) : Object.assign(Object.assign({}, config), configSingle);
12288
12274
  this.choice = new Choices(this.selectElement, settings);
12289
- this.choice.setChoices(this.choices);
12290
12275
  }
12291
12276
  get hintSection() {
12292
12277
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
12293
12278
  return ((this.hint || hasSlottedHint) && (index.h(catFormHint.CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && index.h("slot", { name: "hint" }) })));
12294
12279
  }
12295
12280
  onChange() {
12296
- var _a, _b;
12297
- this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue();
12298
- this.catChange.emit((_b = this.choice) === null || _b === void 0 ? void 0 : _b.getValue());
12299
- if (this.multiple) {
12300
- this.updateRemoveItemButtonVisibility();
12281
+ var _a;
12282
+ this.resetItemsOnNextValueChange = false;
12283
+ this.value = (_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue(true);
12284
+ this.catChange.emit(this.value);
12285
+ }
12286
+ onChoice(event) {
12287
+ var _a;
12288
+ const customEvent = event;
12289
+ const coice = customEvent.detail.choice;
12290
+ if (coice.selected) {
12291
+ (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItemsByValue(coice.value);
12292
+ this.onChange();
12301
12293
  }
12302
12294
  }
12303
12295
  onSearch(event) {
@@ -12312,20 +12304,9 @@ const CatSelect = class {
12312
12304
  this.catScrolledBottom.emit();
12313
12305
  }
12314
12306
  }
12315
- onChoice(event) {
12316
- var _a, _b;
12317
- const customEvent = event;
12318
- const items = Array.from((_a = this.choice) === null || _a === void 0 ? void 0 : _a.getValue());
12319
- const item = items.find(value => value.choiceId === customEvent.detail.choice.id);
12320
- if (item) {
12321
- (_b = this.choice) === null || _b === void 0 ? void 0 : _b._removeItem(item);
12322
- }
12323
- }
12324
12307
  showDropdownHandler() {
12325
12308
  var _a;
12326
- if (!this.disabled) {
12327
- (_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown();
12328
- }
12309
+ !this.disabled && ((_a = this.choice) === null || _a === void 0 ? void 0 : _a.showDropdown());
12329
12310
  }
12330
12311
  createRemoveItemButton() {
12331
12312
  var _a;
@@ -12343,7 +12324,7 @@ const CatSelect = class {
12343
12324
  if (items.length) {
12344
12325
  (_b = this.removeElement) === null || _b === void 0 ? void 0 : _b.removeAttribute('hidden');
12345
12326
  }
12346
- else if (!items.length) {
12327
+ else {
12347
12328
  (_c = this.removeElement) === null || _c === void 0 ? void 0 : _c.setAttribute('hidden', 'true');
12348
12329
  }
12349
12330
  }
@@ -12351,10 +12332,11 @@ const CatSelect = class {
12351
12332
  var _a;
12352
12333
  event.stopPropagation();
12353
12334
  (_a = this.choice) === null || _a === void 0 ? void 0 : _a.removeActiveItems(-1);
12335
+ this.updateRemoveItemButtonVisibility();
12354
12336
  }
12355
12337
  get hostElement() { return index.getElement(this); }
12356
12338
  static get watchers() { return {
12357
- "choices": ["setChoicesHandler"],
12339
+ "items": ["setChoicesHandler"],
12358
12340
  "value": ["setValueHandler"]
12359
12341
  }; }
12360
12342
  };