@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
@@ -1,7 +1,7 @@
1
- import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-df195301.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-df195301.js';
2
2
  import { l as loglevel, a as CatIconRegistry, C as CatI18nRegistry, N as NotificationsService } from './cat-notification-8bcf6fa2.js';
3
3
 
4
- 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}";
4
+ 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}";
5
5
 
6
6
  const CatAlert = class {
7
7
  constructor(hostRef) {
@@ -13,6 +13,13 @@ const CatAlert = class {
13
13
  ['warning', 'danger-filled'],
14
14
  ['danger', 'cross-circle-filled']
15
15
  ]);
16
+ this.mapRole = new Map([
17
+ ['primary', 'status'],
18
+ ['secondary', 'status'],
19
+ ['success', 'status'],
20
+ ['warning', 'alert'],
21
+ ['danger', 'alert']
22
+ ]);
16
23
  /**
17
24
  * The color palette of the alert.
18
25
  */
@@ -23,20 +30,15 @@ const CatAlert = class {
23
30
  this.noIcon = false;
24
31
  }
25
32
  render() {
26
- return (h(Host, { tabindex: "0", role: this.role }, h("div", { part: "alert", class: {
27
- alert: true,
28
- [`alert-${this.color}`]: Boolean(this.color)
29
- } }, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null)))));
33
+ return (h(Host, { tabindex: this.tabIndex, role: this.role }, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null))));
34
+ }
35
+ get tabIndex() {
36
+ return this.hostElement.getAttribute('tabindex') || '0';
30
37
  }
31
38
  get role() {
32
- switch (this.color) {
33
- case 'danger':
34
- case 'warning':
35
- return 'alert';
36
- default:
37
- return 'status';
38
- }
39
+ return this.hostElement.getAttribute('role') || this.mapRole.get(this.color) || null;
39
40
  }
41
+ get hostElement() { return getElement(this); }
40
42
  };
41
43
  CatAlert.style = catAlertCss;
42
44
 
@@ -483,7 +485,7 @@ const CatFormHint = props => {
483
485
  ]));
484
486
  };
485
487
 
486
- 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))}";
488
+ 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))}";
487
489
 
488
490
  let nextUniqueId$8 = 0;
489
491
  const CatCheckbox = class {
@@ -5219,7 +5221,7 @@ var autosizeInput = function (element, options) {
5219
5221
  }
5220
5222
  };
5221
5223
 
5222
- 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))}";
5224
+ 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))}";
5223
5225
 
5224
5226
  const INIT_STATE = {
5225
5227
  term: '',
@@ -5281,6 +5283,10 @@ const CatSelect = class {
5281
5283
  * Whether the select should show a clear button.
5282
5284
  */
5283
5285
  this.clearable = false;
5286
+ /**
5287
+ * Whether the select should add new items.
5288
+ */
5289
+ this.tags = false;
5284
5290
  }
5285
5291
  onConnectorChange(connector) {
5286
5292
  this.reset(connector);
@@ -5300,11 +5306,25 @@ const CatSelect = class {
5300
5306
  this.hide();
5301
5307
  }
5302
5308
  const idsSelected = this.state.selection.map(item => item.item.id);
5303
- if (this.multiple) {
5304
- this.value = idsSelected;
5309
+ if (!this.tags) {
5310
+ if (this.multiple) {
5311
+ this.value = idsSelected;
5312
+ }
5313
+ else {
5314
+ this.value = idsSelected.length ? idsSelected[0] : '';
5315
+ }
5305
5316
  }
5306
5317
  else {
5307
- this.value = idsSelected.length ? idsSelected[0] : '';
5318
+ const ids = idsSelected.filter(id => !id.startsWith(`select-${this.id}-tag`));
5319
+ const tags = this.state.selection
5320
+ .filter(item => item.item.id.startsWith(`select-${this.id}-tag`))
5321
+ .map(item => item.render.label);
5322
+ if (this.multiple) {
5323
+ this.value = { ids, tags };
5324
+ }
5325
+ else {
5326
+ this.value = { id: ids.length ? ids[0] : '', tag: tags.length ? tags[0] : '' };
5327
+ }
5308
5328
  }
5309
5329
  this.catChange.emit();
5310
5330
  }
@@ -5325,7 +5345,12 @@ const CatSelect = class {
5325
5345
  }
5326
5346
  onBlur(event) {
5327
5347
  if (!this.multiple && this.state.activeOptionIndex >= 0) {
5328
- this.select(this.state.options[this.state.activeOptionIndex]);
5348
+ if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
5349
+ this.createTag(this.state.term);
5350
+ }
5351
+ else {
5352
+ this.select(this.state.options[this.state.activeOptionIndex]);
5353
+ }
5329
5354
  }
5330
5355
  this.hide();
5331
5356
  this.patchState({ activeSelectionIndex: -1 });
@@ -5337,8 +5362,19 @@ const CatSelect = class {
5337
5362
  if (['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
5338
5363
  this.onArrowKeyDown(event);
5339
5364
  }
5340
- else if (['Enter', ' '].includes(event.key)) {
5341
- if (isInputFocused && this.state.activeOptionIndex >= 0) {
5365
+ else if (['Enter', ' '].includes(event.key) && isInputFocused) {
5366
+ if (this.tags &&
5367
+ this.state.activeOptionIndex === 0 &&
5368
+ this.state.options[0].item.id === `select-${this.id}-option-tag`) {
5369
+ event.preventDefault();
5370
+ if (this.multiple) {
5371
+ this.toggleTag(this.state.options[0]);
5372
+ }
5373
+ else {
5374
+ this.createTag(this.state.options[0].render.label);
5375
+ }
5376
+ }
5377
+ else if (this.state.activeOptionIndex >= 0) {
5342
5378
  event.preventDefault();
5343
5379
  if (this.multiple) {
5344
5380
  this.toggle(this.state.options[this.state.activeOptionIndex]);
@@ -5347,6 +5383,9 @@ const CatSelect = class {
5347
5383
  this.select(this.state.options[this.state.activeOptionIndex]);
5348
5384
  }
5349
5385
  }
5386
+ else if (this.tags && event.key === 'Enter' && this.state.activeOptionIndex < 0) {
5387
+ this.createTag(this.state.term);
5388
+ }
5350
5389
  }
5351
5390
  else if (event.key === 'Escape') {
5352
5391
  this.hide();
@@ -5357,11 +5396,6 @@ const CatSelect = class {
5357
5396
  if (this.state.activeSelectionIndex >= 0) {
5358
5397
  this.deselect(this.state.selection[this.state.activeSelectionIndex].item.id);
5359
5398
  }
5360
- else if (this.state.selection.length) {
5361
- const selectionClone = [...this.state.selection];
5362
- selectionClone.pop();
5363
- this.patchState({ selection: selectionClone });
5364
- }
5365
5399
  }
5366
5400
  }
5367
5401
  else if (event.key === 'Tab') {
@@ -5370,7 +5404,12 @@ const CatSelect = class {
5370
5404
  this.patchState({ activeSelectionIndex: -1, activeOptionIndex: -1 });
5371
5405
  }
5372
5406
  else if (this.state.activeOptionIndex >= 0) {
5373
- this.select(this.state.options[this.state.activeOptionIndex]);
5407
+ if (this.tags && this.state.options[this.state.activeOptionIndex].item.id === `select-${this.id}-option-tag`) {
5408
+ this.createTag(this.state.term);
5409
+ }
5410
+ else {
5411
+ this.select(this.state.options[this.state.activeOptionIndex]);
5412
+ }
5374
5413
  }
5375
5414
  }
5376
5415
  else if (event.key.length === 1) {
@@ -5408,12 +5447,28 @@ const CatSelect = class {
5408
5447
  this.subscription = this.term$
5409
5448
  .asObservable()
5410
5449
  .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], []))))
5411
- .subscribe(items => this.patchState({
5412
- options: items === null || items === void 0 ? void 0 : items.map(item => ({
5450
+ .subscribe(items => {
5451
+ var _a;
5452
+ const options = items === null || items === void 0 ? void 0 : items.map(item => ({
5413
5453
  item,
5414
5454
  render: this.connectorSafe.render(item)
5415
- }))
5416
- }));
5455
+ }));
5456
+ if (this.tags &&
5457
+ this.state.term.trim().length &&
5458
+ !options.find(value1 => value1.render.label.toLowerCase() === this.state.term.toLowerCase())) {
5459
+ let label;
5460
+ if (this.isAlreadyCreated(this.state.term)) {
5461
+ label = (_a = this.state.selection.find(item => item.render.label.toLowerCase() === this.state.term.toLowerCase())) === null || _a === void 0 ? void 0 : _a.render.label;
5462
+ }
5463
+ options.unshift({
5464
+ item: { id: `select-${this.id}-option-tag` },
5465
+ render: { label: label ? label : this.state.term }
5466
+ });
5467
+ }
5468
+ this.patchState({
5469
+ options
5470
+ });
5471
+ });
5417
5472
  }
5418
5473
  render() {
5419
5474
  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("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) }, h("div", { class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (h("span", { class: {
@@ -5423,16 +5478,35 @@ const CatSelect = class {
5423
5478
  }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", null, item.render.label), !this.disabled && (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 ? (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, 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 && h("cat-spinner", null), (this.state.selection.length || this.state.term.length) &&
5424
5479
  !this.disabled &&
5425
5480
  !this.state.isResolving &&
5426
- this.clearable ? (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 && (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, h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, 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) => (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": this.isSelected(item.item.id) ? 'true' : 'false' }, this.multiple ? (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 => {
5427
- this.toggle(item);
5428
- e.stopPropagation();
5429
- } }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
5430
- 'select-option-inner': true,
5431
- 'select-option-single': true,
5432
- 'select-option-active': this.state.activeOptionIndex === i
5433
- }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description))))))), this.state.isLoading
5481
+ this.clearable ? (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 && (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, h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, 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
5434
5482
  ? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" }, h("cat-skeleton", { variant: "body", lines: 1 }), h("cat-skeleton", { variant: "body", lines: 1 }))))
5435
- : !this.state.options.length && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
5483
+ : !this.state.options.length &&
5484
+ !this.tags && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
5485
+ }
5486
+ get optionsList() {
5487
+ return this.state.options.map((item, i) => {
5488
+ const isTagOption = this.tags && item.item.id === `select-${this.id}-option-tag`;
5489
+ const getAriaSelected = () => {
5490
+ if (isTagOption) {
5491
+ return this.isAlreadyCreated(item.render.label) ? 'true' : 'false';
5492
+ }
5493
+ return this.isSelected(item.item.id) ? 'true' : 'false';
5494
+ };
5495
+ const getLabel = () => {
5496
+ if (isTagOption) {
5497
+ return item.render.label + this.tagTextHelp;
5498
+ }
5499
+ return item.render.label;
5500
+ };
5501
+ return (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": getAriaSelected() }, this.multiple ? (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 => {
5502
+ !isTagOption ? this.toggle(item) : this.toggleTag(item);
5503
+ e.stopPropagation();
5504
+ } }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
5505
+ 'select-option-inner': true,
5506
+ 'select-option-single': true,
5507
+ 'select-option-active': this.state.activeOptionIndex === i
5508
+ }, 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 ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, initials: '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))));
5509
+ });
5436
5510
  }
5437
5511
  get hintSection() {
5438
5512
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
@@ -5445,21 +5519,27 @@ const CatSelect = class {
5445
5519
  throw new Error('CatSelectConnector not set');
5446
5520
  }
5447
5521
  resolve() {
5448
- var _a;
5449
5522
  this.patchState({ isResolving: true });
5450
- let ids;
5451
- if (this.multiple) {
5452
- ids = this.value;
5453
- }
5454
- else {
5455
- ids = [this.value];
5456
- }
5457
- const data$ = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
5458
- data$.pipe(catchError(() => of([]))).subscribe(items => this.patchState({
5459
- isResolving: false,
5460
- selection: items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })),
5461
- term: !this.multiple && items.length ? this.connectorSafe.render(items[0]).label : ''
5462
- }));
5523
+ const ids = this.initIds();
5524
+ let tags;
5525
+ if (this.tags) {
5526
+ tags = this.initTags();
5527
+ }
5528
+ const data$ = ids.length ? this.connectorSafe.resolve(ids).pipe(first()) : of([]);
5529
+ data$.pipe(catchError(() => of([]))).subscribe(items => {
5530
+ const selection = items.length ? items === null || items === void 0 ? void 0 : items.map(item => ({ item, render: this.connectorSafe.render(item) })) : [];
5531
+ if (this.tags) {
5532
+ tags === null || tags === void 0 ? void 0 : tags.forEach((tag, index) => {
5533
+ const item = { id: `select-${this.id}-tag-${index}`, name: tag };
5534
+ selection.push({ item, render: { label: item.name } });
5535
+ });
5536
+ }
5537
+ this.patchState({
5538
+ isResolving: false,
5539
+ selection,
5540
+ term: !this.multiple && selection.length ? selection[0].render.label : ''
5541
+ });
5542
+ });
5463
5543
  }
5464
5544
  show() {
5465
5545
  var _a;
@@ -5484,7 +5564,6 @@ const CatSelect = class {
5484
5564
  return this.state.selection.findIndex(s => s.item.id === id) >= 0;
5485
5565
  }
5486
5566
  select(item) {
5487
- var _a;
5488
5567
  if (!this.isSelected(item.item.id)) {
5489
5568
  let newSelection;
5490
5569
  if (this.multiple) {
@@ -5495,11 +5574,13 @@ const CatSelect = class {
5495
5574
  this.search(item.render.label);
5496
5575
  }
5497
5576
  this.patchState({ selection: newSelection });
5577
+ if (this.multiple && this.state.term.trim() && this.input) {
5578
+ this.patchState({ term: '', activeOptionIndex: -1 });
5579
+ this.term$.next('');
5580
+ this.input.value = '';
5581
+ }
5498
5582
  }
5499
- if (!this.multiple) {
5500
- this.hide();
5501
- (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
5502
- }
5583
+ this.setTransparentCaret();
5503
5584
  }
5504
5585
  deselect(id) {
5505
5586
  if (this.isSelected(id)) {
@@ -5546,7 +5627,12 @@ const CatSelect = class {
5546
5627
  }
5547
5628
  onInput() {
5548
5629
  var _a;
5549
- this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || '');
5630
+ this.search(((_a = this.input) === null || _a === void 0 ? void 0 : _a.value.trim()) || '');
5631
+ if (!this.multiple && this.state.selection.length) {
5632
+ const selectionClone = [...this.state.selection];
5633
+ selectionClone.pop();
5634
+ this.patchState({ selection: selectionClone });
5635
+ }
5550
5636
  this.show();
5551
5637
  }
5552
5638
  update() {
@@ -5584,52 +5670,122 @@ const CatSelect = class {
5584
5670
  var _a, _b;
5585
5671
  let preventDefault = false;
5586
5672
  (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
5587
- if (event.key === 'ArrowDown') {
5588
- preventDefault = true;
5589
- this.state.isOpen
5590
- ? this.patchState({
5591
- activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
5592
- activeSelectionIndex: -1
5593
- })
5594
- : this.show();
5595
- }
5596
- else if (event.key === 'ArrowUp') {
5597
- preventDefault = true;
5598
- this.state.activeOptionIndex >= 0
5599
- ? this.patchState({
5600
- activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
5601
- activeSelectionIndex: -1
5602
- })
5603
- : this.hide();
5604
- }
5605
- else if (event.key === 'ArrowLeft') {
5606
- if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
5673
+ switch (event.key) {
5674
+ case 'ArrowDown':
5607
5675
  preventDefault = true;
5608
- let index;
5609
- this.state.activeSelectionIndex > 0
5610
- ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
5611
- : (index = this.state.selection.length - 1);
5612
- this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5613
- }
5614
- }
5615
- else if (event.key === 'ArrowRight') {
5616
- if (this.state.activeSelectionIndex >= 0) {
5676
+ this.state.isOpen
5677
+ ? this.patchState({
5678
+ activeOptionIndex: Math.min(this.state.activeOptionIndex + 1, this.state.options.length - 1),
5679
+ activeSelectionIndex: -1
5680
+ })
5681
+ : this.show();
5682
+ break;
5683
+ case 'ArrowUp':
5617
5684
  preventDefault = true;
5618
- let index = -1;
5619
- if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
5620
- index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
5685
+ this.state.activeOptionIndex >= 0
5686
+ ? this.patchState({
5687
+ activeOptionIndex: Math.max(this.state.activeOptionIndex - 1, -1),
5688
+ activeSelectionIndex: -1
5689
+ })
5690
+ : this.hide();
5691
+ break;
5692
+ case 'ArrowLeft':
5693
+ if (((_b = this.input) === null || _b === void 0 ? void 0 : _b.selectionStart) === 0) {
5694
+ preventDefault = true;
5695
+ let index;
5696
+ this.state.activeSelectionIndex > 0
5697
+ ? (index = Math.max(this.state.activeSelectionIndex - 1, -1))
5698
+ : (index = this.state.selection.length - 1);
5699
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5621
5700
  }
5622
- else if (!this.state.term) {
5623
- index = 0;
5701
+ break;
5702
+ case 'ArrowRight':
5703
+ if (this.state.activeSelectionIndex >= 0) {
5704
+ preventDefault = true;
5705
+ let index = -1;
5706
+ if (this.state.activeSelectionIndex < this.state.selection.length - 1) {
5707
+ index = Math.min(this.state.activeSelectionIndex + 1, this.state.selection.length - 1);
5708
+ }
5709
+ else if (!this.state.term) {
5710
+ index = 0;
5711
+ }
5712
+ this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5624
5713
  }
5625
- this.patchState({ activeSelectionIndex: index, activeOptionIndex: -1 });
5626
- }
5627
5714
  }
5628
5715
  if (preventDefault) {
5629
5716
  event.preventDefault();
5630
5717
  event.stopPropagation();
5631
5718
  }
5632
5719
  }
5720
+ get tagTextHelp() {
5721
+ return this.tagHint && !this.isAlreadyCreated(this.state.term) ? ' (' + this.tagHint + ')' : '';
5722
+ }
5723
+ isAlreadyCreated(term) {
5724
+ return this.state.selection.findIndex(item => item.render.label.toLowerCase() === term.toLowerCase()) >= 0;
5725
+ }
5726
+ createTag(term) {
5727
+ if (term.trim().length && !this.isAlreadyCreated(term)) {
5728
+ const value = this.value;
5729
+ const tags = value === null || value === void 0 ? void 0 : value.tags;
5730
+ const tag = { id: `select-${this.id}-tag-${tags ? tags.length : 0}`, name: term };
5731
+ this.select({ item: tag, render: { label: tag.name } });
5732
+ }
5733
+ this.setTransparentCaret();
5734
+ }
5735
+ initIds() {
5736
+ let ids = [];
5737
+ if (this.value) {
5738
+ if (!this.tags) {
5739
+ if (this.multiple) {
5740
+ ids = this.value;
5741
+ }
5742
+ else {
5743
+ ids = [this.value];
5744
+ }
5745
+ }
5746
+ else {
5747
+ if (this.multiple) {
5748
+ const value = this.value;
5749
+ ids = value.ids ? value.ids : [];
5750
+ }
5751
+ else {
5752
+ const value = this.value;
5753
+ ids = value.id ? [value.id] : [];
5754
+ }
5755
+ }
5756
+ }
5757
+ return ids;
5758
+ }
5759
+ initTags() {
5760
+ let tags = [];
5761
+ if (this.value) {
5762
+ if (this.multiple) {
5763
+ const value = this.value;
5764
+ tags = value.tags ? value.tags : [];
5765
+ }
5766
+ else {
5767
+ const value = this.value;
5768
+ tags = value.tag ? [value.tag] : [];
5769
+ }
5770
+ }
5771
+ return tags;
5772
+ }
5773
+ toggleTag(item) {
5774
+ this.isAlreadyCreated(item.render.label) ? this.removeTag(item.render.label) : this.createTag(item.render.label);
5775
+ }
5776
+ removeTag(label) {
5777
+ if (this.isAlreadyCreated(label)) {
5778
+ const item = this.state.selection.find(item => item.render.label.toLowerCase() === label.toLowerCase());
5779
+ item && this.deselect(item.item.id);
5780
+ }
5781
+ }
5782
+ setTransparentCaret() {
5783
+ var _a;
5784
+ if (!this.multiple) {
5785
+ this.hide();
5786
+ (_a = this.input) === null || _a === void 0 ? void 0 : _a.classList.add('select-input-transparent-caret');
5787
+ }
5788
+ }
5633
5789
  get hostElement() { return getElement(this); }
5634
5790
  static get watchers() { return {
5635
5791
  "connector": ["onConnectorChange"],
@@ -5645,7 +5801,7 @@ const CatSelectTest = class {
5645
5801
  registerInstance(this, hostRef);
5646
5802
  }
5647
5803
  componentDidLoad() {
5648
- var _a, _b, _c, _d;
5804
+ var _a, _b, _c, _d, _e, _f;
5649
5805
  (_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
5650
5806
  resolve: (ids) => {
5651
5807
  console.info(`Resolving data... (${ids.join(', ')})`);
@@ -5710,31 +5866,45 @@ const CatSelectTest = class {
5710
5866
  }
5711
5867
  })
5712
5868
  });
5713
- (_c = this.singleSelect) === null || _c === void 0 ? void 0 : _c.connect({
5869
+ (_c = this.multipleSelectTagging) === null || _c === void 0 ? void 0 : _c.connect(this.countryConnector);
5870
+ (_d = this.singleSelect) === null || _d === void 0 ? void 0 : _d.connect({
5714
5871
  resolve: (ids) => {
5715
5872
  console.info(`Resolving data... (${ids.join(', ')})`);
5716
- return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
5873
+ return of(ids.map(id => ({
5874
+ id,
5875
+ firstName: 'John',
5876
+ lastName: `Doe (${id})`,
5877
+ desc: 'resolved'
5878
+ }))).pipe(delay(500));
5717
5879
  },
5718
5880
  retrieve: (term, page) => {
5719
5881
  console.info(`Retrieving data... ("${term}", ${page})`);
5720
- const filter = countries.filter(value => {
5721
- var _a;
5722
- return value.country.toLowerCase().indexOf(term.toLowerCase()) === 0 ||
5723
- ((_a = value.capital) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(term.toLowerCase())) === 0;
5724
- });
5725
- const slice = filter.slice(page * 10, page * 10 + 10);
5726
- return of({
5727
- last: slice.length < 10,
5728
- totalElements: filter.length,
5729
- content: slice
5730
- }).pipe(delay(500));
5882
+ return term === 'no'
5883
+ ? of({ last: true, content: [], totalElements: 0 })
5884
+ : of({
5885
+ last: false,
5886
+ totalElements: 10000,
5887
+ content: Array.from({ length: 10 }, (_, i) => ({
5888
+ id: '' + (i + page * 10),
5889
+ firstName: 'John',
5890
+ lastName: `Doe (${i + page * 10})`,
5891
+ desc: `"${term}": page ${page}`
5892
+ }))
5893
+ }).pipe(delay(500));
5731
5894
  },
5732
- render: (country) => ({
5733
- label: country.country,
5734
- description: country.capital || 'No capital'
5895
+ render: (user) => ({
5896
+ label: `${user.firstName} ${user.lastName}`,
5897
+ description: user.desc
5735
5898
  })
5736
5899
  });
5737
- (_d = this.singleSelectAvatar) === null || _d === void 0 ? void 0 : _d.connect({
5900
+ (_e = this.singleSelectAvatar) === null || _e === void 0 ? void 0 : _e.connect(this.countryConnector);
5901
+ (_f = this.singleSelectTagging) === null || _f === void 0 ? void 0 : _f.connect(this.countryConnector);
5902
+ }
5903
+ render() {
5904
+ return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, 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 }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), 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 }), 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 }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true }), 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 })));
5905
+ }
5906
+ get countryConnector() {
5907
+ return {
5738
5908
  resolve: (ids) => {
5739
5909
  console.info(`Resolving data... (${ids.join(', ')})`);
5740
5910
  return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
@@ -5761,10 +5931,7 @@ const CatSelectTest = class {
5761
5931
  round: true
5762
5932
  }
5763
5933
  })
5764
- });
5765
- }
5766
- render() {
5767
- return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, 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 }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), 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 }), h("cat-select", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
5934
+ };
5768
5935
  }
5769
5936
  };
5770
5937
  const countries = [
@@ -7380,7 +7547,7 @@ CatToggle.style = catToggleCss;
7380
7547
 
7381
7548
  const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
7382
7549
 
7383
- 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}";
7550
+ 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}";
7384
7551
 
7385
7552
  let nextUniqueId = 0;
7386
7553
  const CatTooltip = class {
@@ -7400,10 +7567,18 @@ const CatTooltip = class {
7400
7567
  * The placement of the tooltip.
7401
7568
  */
7402
7569
  this.placement = 'top';
7570
+ /**
7571
+ * Use round tooltip edges.
7572
+ */
7573
+ this.round = false;
7574
+ /**
7575
+ * The size of the tooltip.
7576
+ */
7577
+ this.size = 'm';
7403
7578
  /**
7404
7579
  * The delay time for showing tooltip in ms.
7405
7580
  */
7406
- this.showDelay = 500;
7581
+ this.showDelay = 250;
7407
7582
  /**
7408
7583
  * The delay time for hiding tooltip in ms.
7409
7584
  */
@@ -7452,7 +7627,11 @@ const CatTooltip = class {
7452
7627
  }
7453
7628
  }
7454
7629
  render() {
7455
- return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
7630
+ return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: {
7631
+ tooltip: true,
7632
+ 'tooltip-round': this.round,
7633
+ [`tooltip-${this.size}`]: Boolean(this.size)
7634
+ } }, this.content))));
7456
7635
  }
7457
7636
  get isTabbable() {
7458
7637
  return firstTabbable(this.trigger);