@haiilo/catalyst 1.0.2 → 1.1.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 (47) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/p-78b3fc17.entry.js +10 -0
  5. package/dist/catalyst/p-78b3fc17.entry.js.map +1 -0
  6. package/dist/catalyst/scss/utils/_sizing.mixins.scss +1 -1
  7. package/dist/cjs/cat-alert_23.cjs.entry.js +299 -120
  8. package/dist/cjs/cat-alert_23.cjs.entry.js.map +1 -1
  9. package/dist/cjs/catalyst.cjs.js +1 -1
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/collection/components/cat-alert/cat-alert.css +13 -19
  12. package/dist/collection/components/cat-alert/cat-alert.js +17 -18
  13. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
  14. package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -1
  15. package/dist/collection/components/cat-select/cat-select.css +1 -1
  16. package/dist/collection/components/cat-select/cat-select.js +290 -94
  17. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  18. package/dist/collection/components/cat-select-demo/cat-select-demo.js +43 -30
  19. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  20. package/dist/collection/components/cat-tooltip/cat-tooltip.css +26 -2
  21. package/dist/collection/components/cat-tooltip/cat-tooltip.js +51 -3
  22. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  23. package/dist/collection/index.js.map +1 -1
  24. package/dist/collection/scss/utils/_sizing.mixins.scss +1 -1
  25. package/dist/components/cat-alert.js +14 -12
  26. package/dist/components/cat-alert.js.map +1 -1
  27. package/dist/components/cat-checkbox2.js +1 -1
  28. package/dist/components/cat-checkbox2.js.map +1 -1
  29. package/dist/components/cat-select-demo.js +33 -22
  30. package/dist/components/cat-select-demo.js.map +1 -1
  31. package/dist/components/cat-select2.js +237 -81
  32. package/dist/components/cat-select2.js.map +1 -1
  33. package/dist/components/cat-tooltip.js +17 -3
  34. package/dist/components/cat-tooltip.js.map +1 -1
  35. package/dist/esm/cat-alert_23.entry.js +300 -121
  36. package/dist/esm/cat-alert_23.entry.js.map +1 -1
  37. package/dist/esm/catalyst.js +1 -1
  38. package/dist/esm/loader.js +1 -1
  39. package/dist/types/components/cat-alert/cat-alert.d.ts +3 -2
  40. package/dist/types/components/cat-select/cat-select.d.ts +32 -1
  41. package/dist/types/components/cat-select-demo/cat-select-demo.d.ts +3 -0
  42. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +8 -0
  43. package/dist/types/components.d.ts +37 -5
  44. package/dist/types/index.d.ts +1 -1
  45. package/package.json +2 -2
  46. package/dist/catalyst/p-a2ddc7fa.entry.js +0 -10
  47. package/dist/catalyst/p-a2ddc7fa.entry.js.map +0 -1
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-8ab22379.js');
6
6
  const catNotification = require('./cat-notification-bcb9fb86.js');
7
7
 
8
- const catAlertCss = ":host{display:block;border-radius:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}:host(:focus-visible){outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.alert{font:inherit;display:flex;gap:0.5rem;padding:1.25rem;border-radius:0.5rem}.content{align-self:center}::slotted(:last-child){margin-bottom:0 !important}.alert-primary{background-color:rgba(var(--cat-primary-bg, 32, 127, 138), 0.1)}.alert-primary cat-icon{color:#207f8a}.alert-secondary{background-color:rgba(105, 118, 135, 0.1)}.alert-secondary cat-icon{color:#697687}.alert-success{background-color:rgba(0, 132, 88, 0.1)}.alert-success cat-icon{color:#008458}.alert-warning{background-color:rgba(255, 206, 128, 0.1)}.alert-warning cat-icon{color:#ebb663}.alert-danger{background-color:rgba(217, 52, 13, 0.1)}.alert-danger cat-icon{color:#d9340d}";
8
+ const catAlertCss = ":host{display:flex;gap:0.5rem;padding:1.25rem;border-radius:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}:host(:focus-visible){outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.content{align-self:center}::slotted(:last-child){margin-bottom:0 !important}:host([color=primary]){background-color:rgba(var(--cat-primary-bg, 32, 127, 138), 0.1)}:host([color=primary]) cat-icon{color:#207f8a}:host([color=secondary]){background-color:rgba(105, 118, 135, 0.1)}:host([color=secondary]) cat-icon{color:#697687}:host([color=success]){background-color:rgba(0, 132, 88, 0.1)}:host([color=success]) cat-icon{color:#008458}:host([color=warning]){background-color:rgba(255, 206, 128, 0.1)}:host([color=warning]) cat-icon{color:#ebb663}:host([color=danger]){background-color:rgba(217, 52, 13, 0.1)}:host([color=danger]) cat-icon{color:#d9340d}";
9
9
 
10
10
  const CatAlert = class {
11
11
  constructor(hostRef) {
@@ -17,6 +17,13 @@ const CatAlert = class {
17
17
  ['warning', 'danger-filled'],
18
18
  ['danger', 'cross-circle-filled']
19
19
  ]);
20
+ this.mapRole = new Map([
21
+ ['primary', 'status'],
22
+ ['secondary', 'status'],
23
+ ['success', 'status'],
24
+ ['warning', 'alert'],
25
+ ['danger', 'alert']
26
+ ]);
20
27
  /**
21
28
  * The color palette of the alert.
22
29
  */
@@ -27,20 +34,15 @@ const CatAlert = class {
27
34
  this.noIcon = false;
28
35
  }
29
36
  render() {
30
- return (index.h(index.Host, { tabindex: "0", role: this.role }, index.h("div", { part: "alert", class: {
31
- alert: true,
32
- [`alert-${this.color}`]: Boolean(this.color)
33
- } }, !this.noIcon && index.h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), index.h("div", { class: "content" }, index.h("slot", null)))));
37
+ return (index.h(index.Host, { tabindex: this.tabIndex, role: this.role }, !this.noIcon && index.h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), index.h("div", { class: "content" }, index.h("slot", null))));
38
+ }
39
+ get tabIndex() {
40
+ return this.hostElement.getAttribute('tabindex') || '0';
34
41
  }
35
42
  get role() {
36
- switch (this.color) {
37
- case 'danger':
38
- case 'warning':
39
- return 'alert';
40
- default:
41
- return 'status';
42
- }
43
+ return this.hostElement.getAttribute('role') || this.mapRole.get(this.color) || null;
43
44
  }
45
+ get hostElement() { return index.getElement(this); }
44
46
  };
45
47
  CatAlert.style = catAlertCss;
46
48
 
@@ -487,7 +489,7 @@ const CatFormHint = props => {
487
489
  ]));
488
490
  };
489
491
 
490
- const catCheckboxCss = ".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;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;position:relative}.label-left{flex-direction:row-reverse}.label-left input{right:1px;left:unset}input{position:absolute;width:1.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit;left:1px;top:0.5px}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease;pointer-events:none}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:70%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}:host(.cat-error) .box{border:1px solid #d9340d}:host(.cat-error) :checked+.box,:host(.cat-error) :indeterminate+.box{background-color:#d9340d;border-color:#d9340d;stroke:white}.label{flex:1 1 auto;min-width:0}.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))}";
492
+ const catCheckboxCss = ".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;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;position:relative}.label-left{flex-direction:row-reverse}.label-left input{right:1px;left:unset}input{position:absolute;width:1.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit;left:1px;top:0.5px}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease;pointer-events:none}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:50%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}:host(.cat-error) .box{border:1px solid #d9340d}:host(.cat-error) :checked+.box,:host(.cat-error) :indeterminate+.box{background-color:#d9340d;border-color:#d9340d;stroke:white}.label{flex:1 1 auto;min-width:0}.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))}";
491
493
 
492
494
  let nextUniqueId$8 = 0;
493
495
  const CatCheckbox = class {
@@ -5223,7 +5225,7 @@ var autosizeInput = function (element, options) {
5223
5225
  }
5224
5226
  };
5225
5227
 
5226
- const catSelectCss = ".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;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;position:relative;margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{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}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.select-wrapper{display:flex;align-items:flex-start;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear;padding:0.25rem}.select-wrapper:not(.select-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.select-wrapper:not(.select-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}:host(.cat-error) .select-wrapper{box-shadow:0 0 0 1px #d9340d}:host(.cat-error) .select-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d9340d}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));pointer-events:none}.select-wrapper-inner{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:0.25rem;min-width:0}.select-wrapper-inner>cat-avatar{padding-left:0.25rem}.select-wrapper-inner cat-avatar{--cat-avatar-size:1.25rem}.select-input{font:inherit;background:none;border:none;outline:none;padding:0.375rem 0.5rem;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.select-disabled .select-input{cursor:inherit}.select-pills{display:contents}.pill{display:inline-flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;background:#ebecf0;border-radius:0.125rem;white-space:nowrap;min-width:0}.pill>span{overflow:hidden;text-overflow:ellipsis}.pill>cat-button{margin-right:-0.25rem;margin-left:-0.25rem}.select-btn{transition:transform 0.13s linear}.select-btn::part(button){outline:none}cat-spinner{padding:0.375rem}.select-btn-open{transform:rotate(180deg)}.select-dropdown{position:absolute;right:0;background:white;display:none;overflow:auto;box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem;z-index:100}.select-options-wrapper{max-height:16rem;width:100%}.select-empty{margin:1rem 0;padding:0 1.25rem}.select-options{list-style-type:none;margin:0;padding:0.5rem 0}.select-options cat-checkbox,.select-options .select-option-single{margin:0;padding:0.5rem 1rem}.select-option-inner{display:flex;gap:0.5rem;--cat-avatar-size:1.25rem}.select-option-single{cursor:pointer}.select-input-transparent-caret{caret-color:transparent}.select-option-empty,.select-option-loading{padding:0.5rem 1rem}.select-option:hover{background-color:rgba(105, 118, 135, 0.05)}.select-option-active{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:-2px}.select-option-label{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}.select-option-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
5228
+ const catSelectCss = ".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;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host-context(.cat-error) .hint-section{color:#d9340d}:host{display:flex;flex-direction:column;gap:0.5rem;position:relative;margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{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}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.select-wrapper{display:flex;align-items:flex-start;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear;padding:0.25rem}.select-wrapper:not(.select-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.select-wrapper:not(.select-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}:host(.cat-error) .select-wrapper{box-shadow:0 0 0 1px #d9340d}:host(.cat-error) .select-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d9340d}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));pointer-events:none}.select-wrapper-inner{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:0.25rem;min-width:0}.select-wrapper-inner>cat-avatar{padding-left:0.25rem}.select-wrapper-inner cat-avatar{--cat-avatar-size:1.25rem}.select-input{font:inherit;background:none;border:none;outline:none;padding:0.375rem 0.5rem;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.select-disabled .select-input{cursor:inherit}.select-pills{display:contents}.pill{display:inline-flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;background:#f2f4f7;border-radius:0.125rem;white-space:nowrap;min-width:0}.pill>span{overflow:hidden;text-overflow:ellipsis}.pill>cat-button{margin-right:-0.25rem;margin-left:-0.25rem}.select-btn{transition:transform 0.13s linear}.select-btn::part(button){outline:none}cat-spinner{padding:0.375rem}.select-btn-open{transform:rotate(180deg)}.select-dropdown{position:absolute;right:0;background:white;display:none;overflow:auto;box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem;z-index:100}.select-options-wrapper{max-height:16rem;width:100%}.select-empty{margin:1rem 0;padding:0 1.25rem}.select-options{list-style-type:none;margin:0;padding:0.5rem 0}.select-options cat-checkbox,.select-options .select-option-single{margin:0;padding:0.5rem 1rem}.select-option-inner{display:flex;gap:0.5rem;--cat-avatar-size:1.25rem}.select-option-single{cursor:pointer}.select-input-transparent-caret{caret-color:transparent}.select-option-empty,.select-option-loading{padding:0.5rem 1rem}.select-option:hover{background-color:rgba(105, 118, 135, 0.05)}.select-option-active{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:-2px}.select-option-label{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}.select-option-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
5227
5229
 
5228
5230
  const INIT_STATE = {
5229
5231
  term: '',
@@ -5285,6 +5287,10 @@ const CatSelect = class {
5285
5287
  * Whether the select should show a clear button.
5286
5288
  */
5287
5289
  this.clearable = false;
5290
+ /**
5291
+ * Whether the select should add new items.
5292
+ */
5293
+ this.tags = false;
5288
5294
  }
5289
5295
  onConnectorChange(connector) {
5290
5296
  this.reset(connector);
@@ -5304,11 +5310,25 @@ const CatSelect = class {
5304
5310
  this.hide();
5305
5311
  }
5306
5312
  const idsSelected = this.state.selection.map(item => item.item.id);
5307
- if (this.multiple) {
5308
- this.value = idsSelected;
5313
+ if (!this.tags) {
5314
+ if (this.multiple) {
5315
+ this.value = idsSelected;
5316
+ }
5317
+ else {
5318
+ this.value = idsSelected.length ? idsSelected[0] : '';
5319
+ }
5309
5320
  }
5310
5321
  else {
5311
- this.value = idsSelected.length ? idsSelected[0] : '';
5322
+ const ids = idsSelected.filter(id => !id.startsWith(`select-${this.id}-tag`));
5323
+ const tags = this.state.selection
5324
+ .filter(item => item.item.id.startsWith(`select-${this.id}-tag`))
5325
+ .map(item => item.render.label);
5326
+ if (this.multiple) {
5327
+ this.value = { ids, tags };
5328
+ }
5329
+ else {
5330
+ this.value = { id: ids.length ? ids[0] : '', tag: tags.length ? tags[0] : '' };
5331
+ }
5312
5332
  }
5313
5333
  this.catChange.emit();
5314
5334
  }
@@ -5329,7 +5349,12 @@ const CatSelect = class {
5329
5349
  }
5330
5350
  onBlur(event) {
5331
5351
  if (!this.multiple && this.state.activeOptionIndex >= 0) {
5332
- this.select(this.state.options[this.state.activeOptionIndex]);
5352
+ if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
5353
+ this.createTag(this.state.term);
5354
+ }
5355
+ else {
5356
+ this.select(this.state.options[this.state.activeOptionIndex]);
5357
+ }
5333
5358
  }
5334
5359
  this.hide();
5335
5360
  this.patchState({ activeSelectionIndex: -1 });
@@ -5341,8 +5366,19 @@ const CatSelect = class {
5341
5366
  if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
5342
5367
  this.onArrowKeyDown(event);
5343
5368
  }
5344
- else if (['Enter', ' '].includes(event.key)) {
5345
- if (isInputFocused && this.state.activeOptionIndex >= 0) {
5369
+ else if (['Enter', ' '].includes(event.key) && isInputFocused) {
5370
+ if (this.tags &&
5371
+ this.state.activeOptionIndex === 0 &&
5372
+ this.state.options[0].item.id === `select-${this.id}-option-tag`) {
5373
+ event.preventDefault();
5374
+ if (this.multiple) {
5375
+ this.toggleTag(this.state.options[0]);
5376
+ }
5377
+ else {
5378
+ this.createTag(this.state.options[0].render.label);
5379
+ }
5380
+ }
5381
+ else if (this.state.activeOptionIndex >= 0) {
5346
5382
  event.preventDefault();
5347
5383
  if (this.multiple) {
5348
5384
  this.toggle(this.state.options[this.state.activeOptionIndex]);
@@ -5351,6 +5387,9 @@ const CatSelect = class {
5351
5387
  this.select(this.state.options[this.state.activeOptionIndex]);
5352
5388
  }
5353
5389
  }
5390
+ else if (this.tags && event.key === 'Enter' && this.state.activeOptionIndex < 0) {
5391
+ this.createTag(this.state.term);
5392
+ }
5354
5393
  }
5355
5394
  else if (event.key === 'Escape') {
5356
5395
  this.hide();
@@ -5361,11 +5400,6 @@ const CatSelect = class {
5361
5400
  if (this.state.activeSelectionIndex >= 0) {
5362
5401
  this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
5363
5402
  }
5364
- else if (this.state.selection.length) {
5365
- const selectionClone = [...this.state.selection];
5366
- selectionClone.pop();
5367
- this.patchState({ selection: selectionClone });
5368
- }
5369
5403
  }
5370
5404
  }
5371
5405
  else if (event.key === 'Tab') {
@@ -5374,7 +5408,12 @@ const CatSelect = class {
5374
5408
  this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
5375
5409
  }
5376
5410
  else if (this.state.activeOptionIndex >= 0) {
5377
- this.select(this.state.options[this.state.activeOptionIndex]);
5411
+ if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
5412
+ this.createTag(this.state.term);
5413
+ }
5414
+ else {
5415
+ this.select(this.state.options[this.state.activeOptionIndex]);
5416
+ }
5378
5417
  }
5379
5418
  }
5380
5419
  else if (event.key.length === 1) {
@@ -5412,12 +5451,28 @@ const CatSelect = class {
5412
5451
  this.subscription = this.term$
5413
5452
  .asObservable()
5414
5453
  .pipe(debounce(term => (term ? timer(this.debounce) : of(0))), distinctUntilChanged(), tap(() => (number$ = this.more$.pipe(filter(() => !this.state.isLoading), scan(n => n + 1, 0), startWith(0)))), tap(() => this.patchState({ options: [] })), switchMap(term => number$.pipe(tap(() => this.patchState({ isLoading: true })), switchMap(number => this.connectorSafe.retrieve(term, number)), tap(page => this.patchState({ isLoading: false, totalElements: page.totalElements })), takeWhile(page => !page.last, true), scan((items, page) => [...items, ...page.content], []))))
5415
- .subscribe(items => this.patchState({
5416
- options: items === null || items === void 0 ? void 0 : items.map(item => ({
5454
+ .subscribe(items => {
5455
+ var _a;
5456
+ const options = items === null || items === void 0 ? void 0 : items.map(item => ({
5417
5457
  item,
5418
5458
  render: this.connectorSafe.render(item)
5419
- }))
5420
- }));
5459
+ }));
5460
+ if (this.tags &&
5461
+ this.state.term.trim().length &&
5462
+ !options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
5463
+ let label;
5464
+ if (this.isAlreadyCreated(this.state.term)) {
5465
+ label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
5466
+ }
5467
+ options.unshift({
5468
+ item: { id: `select-${this.id}-option-tag` },
5469
+ render: { label: label ? label : this.state.term }
5470
+ });
5471
+ }
5472
+ this.patchState({
5473
+ options
5474
+ });
5475
+ });
5421
5476
  }
5422
5477
  render() {
5423
5478
  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("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, index.h("div", { class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (index.h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (index.h("span", { class: {
@@ -5427,16 +5482,35 @@ const CatSelect = class {
5427
5482
  }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", null, item.render.label), !this.disabled && (index.h("cat-button", { size: "xs", variant: "text", icon: "16-cross", iconOnly: true, a11yLabel: this.i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (index.h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, initials: '' })) : null, index.h("input", { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, onInput: () => this.onInput(), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })), this.state.isResolving && index.h("cat-spinner", null), (this.state.selection.length || this.state.term.length) &&
5428
5483
  !this.disabled &&
5429
5484
  !this.state.isResolving &&
5430
- this.clearable ? (index.h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: this.i18n.t('input.clear'), onClick: () => this.clear() })) : null, !this.state.isResolving && (index.h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? this.i18n.t('select.close') : this.i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))), this.hintSection, index.h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (index.h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, index.h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.state.options.map((item, i) => (index.h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": this.isSelected(item.item.id) ? 'true' : 'false' }, this.multiple ? (index.h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: this.isSelected(item.item.id), tabIndex: -1, labelLeft: true, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onCatChange: e => {
5431
- this.toggle(item);
5432
- e.stopPropagation();
5433
- } }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
5434
- 'select-option-inner': true,
5435
- 'select-option-single': true,
5436
- 'select-option-active': this.state.activeOptionIndex === i
5437
- }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description))))))), this.state.isLoading
5485
+ this.clearable ? (index.h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: this.i18n.t('input.clear'), onClick: () => this.clear() })) : null, !this.state.isResolving && (index.h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? this.i18n.t('select.close') : this.i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))), this.hintSection, index.h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (index.h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, index.h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isLoading
5438
5486
  ? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (index.h("li", { class: "select-option-loading" }, index.h("cat-skeleton", { variant: "body", lines: 1 }), index.h("cat-skeleton", { variant: "body", lines: 1 }))))
5439
- : !this.state.options.length && index.h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
5487
+ : !this.state.options.length &&
5488
+ !this.tags && index.h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
5489
+ }
5490
+ get optionsList() {
5491
+ return this.state.options.map((item, i) => {
5492
+ const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
5493
+ const getAriaSelected = () => {
5494
+ if (isTagOption) {
5495
+ return this.isAlreadyCreated(item.render.label) ? 'true' : 'false';
5496
+ }
5497
+ return this.isSelected(item.item.id) ? 'true' : 'false';
5498
+ };
5499
+ const getLabel = () => {
5500
+ if (isTagOption) {
5501
+ return item.render.label + this.tagTextHelp;
5502
+ }
5503
+ return item.render.label;
5504
+ };
5505
+ return (index.h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": getAriaSelected() }, this.multiple ? (index.h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: !isTagOption ? this.isSelected(item.item.id) : this.isAlreadyCreated(item.render.label), tabIndex: -1, labelLeft: true, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onCatChange: e => {
5506
+ !isTagOption ? this.toggle(item) : this.toggleTag(item);
5507
+ e.stopPropagation();
5508
+ } }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
5509
+ 'select-option-inner': true,
5510
+ 'select-option-single': true,
5511
+ 'select-option-active': this.state.activeOptionIndex === i
5512
+ }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => (isTagOption ? this.createTag(item.render.label) : this.select(item)), tabIndex: -1 }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))));
5513
+ });
5440
5514
  }
5441
5515
  get hintSection() {
5442
5516
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
@@ -5449,21 +5523,27 @@ const CatSelect = class {
5449
5523
  throw new Error('CatSelectConnector not set');
5450
5524
  }
5451
5525
  resolve() {
5452
- var _a;
5453
5526
  this.patchState({ isResolving: true });
5454
- let ids;
5455
- if (this.multiple) {
5456
- ids = this.value;
5457
- }
5458
- else {
5459
- ids = [this.value];
5460
- }
5461
- const data$ = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
5462
- data$.pipe(catchError(() => of([]))).subscribe(items => this.patchState({
5463
- isResolving: false,
5464
- selection: items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })),
5465
- term: !this.multiple && items.length ? this.connectorSafe.render(items[0]).label : ''
5466
- }));
5527
+ const ids = this.initIds();
5528
+ let tags;
5529
+ if (this.tags) {
5530
+ tags = this.initTags();
5531
+ }
5532
+ const data$ = ids.length ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
5533
+ data$.pipe(catchError(() => of([]))).subscribe(items => {
5534
+ const selection = items.length ? items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })) : [];
5535
+ if (this.tags) {
5536
+ tags === null || tags === void 0 ? void 0 : tags.forEach((tag, index) => {
5537
+ const item = { id: `select-${this.id}-tag-${index}`, name: tag };
5538
+ selection.push({ item, render: { label: item.name } });
5539
+ });
5540
+ }
5541
+ this.patchState({
5542
+ isResolving: false,
5543
+ selection,
5544
+ term: !this.multiple && selection.length ? selection[0].render.label : ''
5545
+ });
5546
+ });
5467
5547
  }
5468
5548
  show() {
5469
5549
  var _a;
@@ -5488,7 +5568,6 @@ const CatSelect = class {
5488
5568
  return this.state.selection.findIndex(s => s.item.id === id) >= 0;
5489
5569
  }
5490
5570
  select(item) {
5491
- var _a;
5492
5571
  if (!this.isSelected(item.item.id)) {
5493
5572
  let newSelection;
5494
5573
  if (this.multiple) {
@@ -5499,11 +5578,13 @@ const CatSelect = class {
5499
5578
  this.search(item.render.label);
5500
5579
  }
5501
5580
  this.patchState({ selection: newSelection });
5581
+ if (this.multiple && this.state.term.trim() && this.input) {
5582
+ this.patchState({ term: '', activeOptionIndex: -1 });
5583
+ this.term$.next('');
5584
+ this.input.value = '';
5585
+ }
5502
5586
  }
5503
- if (!this.multiple) {
5504
- this.hide();
5505
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
5506
- }
5587
+ this.setTransparentCaret();
5507
5588
  }
5508
5589
  deselect(id) {
5509
5590
  if (this.isSelected(id)) {
@@ -5550,7 +5631,12 @@ const CatSelect = class {
5550
5631
  }
5551
5632
  onInput() {
5552
5633
  var _a;
5553
- this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
5634
+ this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
5635
+ if (!this.multiple && this.state.selection.length) {
5636
+ const selectionClone = [...this.state.selection];
5637
+ selectionClone.pop();
5638
+ this.patchState({ selection: selectionClone });
5639
+ }
5554
5640
  this.show();
5555
5641
  }
5556
5642
  update() {
@@ -5588,52 +5674,122 @@ const CatSelect = class {
5588
5674
  var _a, _b;
5589
5675
  let preventDefault = false;
5590
5676
  (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
5591
- if (event.key === 'ArrowDown') {
5592
- preventDefault = true;
5593
- this.state.isOpen
5594
- ? this.patchState({
5595
- activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
5596
- activeSelectionIndex: -1
5597
- })
5598
- : this.show();
5599
- }
5600
- else if (event.key === 'ArrowUp') {
5601
- preventDefault = true;
5602
- this.state.activeOptionIndex >= 0
5603
- ? this.patchState({
5604
- activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
5605
- activeSelectionIndex: -1
5606
- })
5607
- : this.hide();
5608
- }
5609
- else if (event.key === 'ArrowLeft') {
5610
- if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
5677
+ switch (event.key) {
5678
+ case 'ArrowDown':
5611
5679
  preventDefault = true;
5612
- let index;
5613
- this.state.activeSelectionIndex > 0
5614
- ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
5615
- : (index = this.state.selection.length - 1);
5616
- this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5617
- }
5618
- }
5619
- else if (event.key === 'ArrowRight') {
5620
- if (this.state.activeSelectionIndex >= 0) {
5680
+ this.state.isOpen
5681
+ ? this.patchState({
5682
+ activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
5683
+ activeSelectionIndex: -1
5684
+ })
5685
+ : this.show();
5686
+ break;
5687
+ case 'ArrowUp':
5621
5688
  preventDefault = true;
5622
- let index = -1;
5623
- if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
5624
- index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
5689
+ this.state.activeOptionIndex >= 0
5690
+ ? this.patchState({
5691
+ activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
5692
+ activeSelectionIndex: -1
5693
+ })
5694
+ : this.hide();
5695
+ break;
5696
+ case 'ArrowLeft':
5697
+ if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
5698
+ preventDefault = true;
5699
+ let index;
5700
+ this.state.activeSelectionIndex > 0
5701
+ ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
5702
+ : (index = this.state.selection.length - 1);
5703
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5625
5704
  }
5626
- else if (!this.state.term) {
5627
- index = 0;
5705
+ break;
5706
+ case 'ArrowRight':
5707
+ if (this.state.activeSelectionIndex >= 0) {
5708
+ preventDefault = true;
5709
+ let index = -1;
5710
+ if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
5711
+ index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
5712
+ }
5713
+ else if (!this.state.term) {
5714
+ index = 0;
5715
+ }
5716
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5628
5717
  }
5629
- this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5630
- }
5631
5718
  }
5632
5719
  if (preventDefault) {
5633
5720
  event.preventDefault();
5634
5721
  event.stopPropagation();
5635
5722
  }
5636
5723
  }
5724
+ get tagTextHelp() {
5725
+ return this.tagHint && !this.isAlreadyCreated(this.state.term) ? ' (' + this.tagHint + ')' : '';
5726
+ }
5727
+ isAlreadyCreated(term) {
5728
+ return this.state.selection.findIndex(item => item.render.label.toLowerCase() === term.toLowerCase()) >= 0;
5729
+ }
5730
+ createTag(term) {
5731
+ if (term.trim().length && !this.isAlreadyCreated(term)) {
5732
+ const value = this.value;
5733
+ const tags = value === null || value === void 0 ? void 0 : value.tags;
5734
+ const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
5735
+ this.select({ item: tag, render: { label: tag.name } });
5736
+ }
5737
+ this.setTransparentCaret();
5738
+ }
5739
+ initIds() {
5740
+ let ids = [];
5741
+ if (this.value) {
5742
+ if (!this.tags) {
5743
+ if (this.multiple) {
5744
+ ids = this.value;
5745
+ }
5746
+ else {
5747
+ ids = [this.value];
5748
+ }
5749
+ }
5750
+ else {
5751
+ if (this.multiple) {
5752
+ const value = this.value;
5753
+ ids = value.ids ? value.ids : [];
5754
+ }
5755
+ else {
5756
+ const value = this.value;
5757
+ ids = value.id ? [value.id] : [];
5758
+ }
5759
+ }
5760
+ }
5761
+ return ids;
5762
+ }
5763
+ initTags() {
5764
+ let tags = [];
5765
+ if (this.value) {
5766
+ if (this.multiple) {
5767
+ const value = this.value;
5768
+ tags = value.tags ? value.tags : [];
5769
+ }
5770
+ else {
5771
+ const value = this.value;
5772
+ tags = value.tag ? [value.tag] : [];
5773
+ }
5774
+ }
5775
+ return tags;
5776
+ }
5777
+ toggleTag(item) {
5778
+ this.isAlreadyCreated(item.render.label) ? this.removeTag(item.render.label) : this.createTag(item.render.label);
5779
+ }
5780
+ removeTag(label) {
5781
+ if (this.isAlreadyCreated(label)) {
5782
+ const item = this.state.selection.find(item => item.render.label.toLowerCase() === label.toLowerCase());
5783
+ item && this.deselect(item.item.id);
5784
+ }
5785
+ }
5786
+ setTransparentCaret() {
5787
+ var _a;
5788
+ if (!this.multiple) {
5789
+ this.hide();
5790
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
5791
+ }
5792
+ }
5637
5793
  get hostElement() { return index.getElement(this); }
5638
5794
  static get watchers() { return {
5639
5795
  "connector": ["onConnectorChange"],
@@ -5649,7 +5805,7 @@ const CatSelectTest = class {
5649
5805
  index.registerInstance(this, hostRef);
5650
5806
  }
5651
5807
  componentDidLoad() {
5652
- var _a, _b, _c, _d;
5808
+ var _a, _b, _c, _d, _e, _f;
5653
5809
  (_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
5654
5810
  resolve: (ids) => {
5655
5811
  console.info(`Resolving data... (${ids.join(', ')})`);
@@ -5714,31 +5870,45 @@ const CatSelectTest = class {
5714
5870
  }
5715
5871
  })
5716
5872
  });
5717
- (_c = this.singleSelect) === null || _c === void 0 ? void 0 : _c.connect({
5873
+ (_c = this.multipleSelectTagging) === null || _c === void 0 ? void 0 : _c.connect(this.countryConnector);
5874
+ (_d = this.singleSelect) === null || _d === void 0 ? void 0 : _d.connect({
5718
5875
  resolve: (ids) => {
5719
5876
  console.info(`Resolving data... (${ids.join(', ')})`);
5720
- return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
5877
+ return of(ids.map(id => ({
5878
+ id,
5879
+ firstName: 'John',
5880
+ lastName: `Doe (${id})`,
5881
+ desc: 'resolved'
5882
+ }))).pipe(delay(500));
5721
5883
  },
5722
5884
  retrieve: (term, page) => {
5723
5885
  console.info(`Retrieving data... ("${term}", ${page})`);
5724
- const filter = countries.filter(value => {
5725
- var _a;
5726
- return value.country.toLowerCase().indexOf(term.toLowerCase()) === 0 ||
5727
- ((_a = value.capital) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(term.toLowerCase())) === 0;
5728
- });
5729
- const slice = filter.slice(page * 10, page * 10 + 10);
5730
- return of({
5731
- last: slice.length < 10,
5732
- totalElements: filter.length,
5733
- content: slice
5734
- }).pipe(delay(500));
5886
+ return term === 'no'
5887
+ ? of({ last: true, content: [], totalElements: 0 })
5888
+ : of({
5889
+ last: false,
5890
+ totalElements: 10000,
5891
+ content: Array.from({ length: 10 }, (_, i) => ({
5892
+ id: '' + (i + page * 10),
5893
+ firstName: 'John',
5894
+ lastName: `Doe (${i + page * 10})`,
5895
+ desc: `"${term}": page ${page}`
5896
+ }))
5897
+ }).pipe(delay(500));
5735
5898
  },
5736
- render: (country) => ({
5737
- label: country.country,
5738
- description: country.capital || 'No capital'
5899
+ render: (user) => ({
5900
+ label: `${user.firstName} ${user.lastName}`,
5901
+ description: user.desc
5739
5902
  })
5740
5903
  });
5741
- (_d = this.singleSelectAvatar) === null || _d === void 0 ? void 0 : _d.connect({
5904
+ (_e = this.singleSelectAvatar) === null || _e === void 0 ? void 0 : _e.connect(this.countryConnector);
5905
+ (_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
5906
+ }
5907
+ render() {
5908
+ return (index.h(index.Host, { style: { display: 'flex', flexDirection: 'column' } }, index.h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), index.h("cat-select", { label: "Multiple with tagging support", hint: "This is a hint!", ref: el => (this.multipleSelectTagging = el), value: { ids: ['1'], tags: ['Test'] }, placeholder: "Select country", onCatChange: () => { var _a; return console.log((_a = this.multipleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, multiple: true, tags: true, clearable: true }), index.h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), placeholder: "Search for a country or capital", onCatBlur: e => console.log('Single blur', e), clearable: true }), index.h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true }), index.h("cat-select", { label: "Single with tagging support", ref: el => (this.singleSelectTagging = el), value: { id: '1', tag: '' }, placeholder: "Search for a country or capital", onCatChange: () => { var _a; return console.log('Single', (_a = this.singleSelectTagging) === null || _a === void 0 ? void 0 : _a.value); }, tagHint: "new country", tags: true, clearable: true })));
5909
+ }
5910
+ get countryConnector() {
5911
+ return {
5742
5912
  resolve: (ids) => {
5743
5913
  console.info(`Resolving data... (${ids.join(', ')})`);
5744
5914
  return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
@@ -5765,10 +5935,7 @@ const CatSelectTest = class {
5765
5935
  round: true
5766
5936
  }
5767
5937
  })
5768
- });
5769
- }
5770
- render() {
5771
- return (index.h(index.Host, { style: { display: 'flex', flexDirection: 'column' } }, index.h("cat-select", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: e => console.log('Multiple', e), onCatBlur: e => console.log('Multiple blur', e), multiple: true, clearable: true }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), index.h("cat-select", { label: "Single Select", hint: "This is a hint!", ref: el => (this.singleSelect = el), value: '1', placeholder: "Search for a country or capital", onCatChange: e => console.log('Single', e), onCatBlur: e => console.log('Single blur', e), clearable: true }), index.h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
5938
+ };
5772
5939
  }
5773
5940
  };
5774
5941
  const countries = [
@@ -7384,7 +7551,7 @@ CatToggle.style = catToggleCss;
7384
7551
 
7385
7552
  const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
7386
7553
 
7387
- const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;padding:0.75rem;background-color:black;border-radius:0.25rem;color:white;transition:opacity 0.25s linear, visibility 0.25s linear;visibility:hidden;opacity:0;box-shadow:rgba(0, 0, 0, 0.08) 0 1px 8px 0;z-index:200;max-width:16rem}.tooltip-show{opacity:1;visibility:visible}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
7554
+ const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;background-color:black;border-radius:0.25rem;color:white;transition:opacity 0.25s linear, visibility 0.25s linear;visibility:hidden;opacity:0;box-shadow:rgba(0, 0, 0, 0.08) 0 1px 8px 0;z-index:200;max-width:20rem}.tooltip-show{opacity:1;visibility:visible}.tooltip-round{border-radius:10rem}.tooltip-s{padding:0.375rem 0.5rem}.tooltip-s.tooltip-round{padding:0.375rem 0.75rem}.tooltip-m{padding:0.75rem}.tooltip-m.tooltip-round{padding:0.75rem 1rem}.tooltip-l{padding:1rem}.tooltip-l.tooltip-round{padding:1rem 1.5rem}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
7388
7555
 
7389
7556
  let nextUniqueId = 0;
7390
7557
  const CatTooltip = class {
@@ -7404,10 +7571,18 @@ const CatTooltip = class {
7404
7571
  * The placement of the tooltip.
7405
7572
  */
7406
7573
  this.placement = 'top';
7574
+ /**
7575
+ * Use round tooltip edges.
7576
+ */
7577
+ this.round = false;
7578
+ /**
7579
+ * The size of the tooltip.
7580
+ */
7581
+ this.size = 'm';
7407
7582
  /**
7408
7583
  * The delay time for showing tooltip in ms.
7409
7584
  */
7410
- this.showDelay = 500;
7585
+ this.showDelay = 250;
7411
7586
  /**
7412
7587
  * The delay time for hiding tooltip in ms.
7413
7588
  */
@@ -7456,7 +7631,11 @@ const CatTooltip = class {
7456
7631
  }
7457
7632
  }
7458
7633
  render() {
7459
- return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
7634
+ return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class: {
7635
+ tooltip: true,
7636
+ 'tooltip-round': this.round,
7637
+ [`tooltip-${this.size}`]: Boolean(this.size)
7638
+ } }, this.content))));
7460
7639
  }
7461
7640
  get isTabbable() {
7462
7641
  return firstTabbable(this.trigger);