@haiilo/catalyst 0.15.0 → 0.15.3

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 (34) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/index.cdn.js +17 -12
  4. package/dist/catalyst/{p-01da674e.entry.js → p-048192b1.entry.js} +5 -5
  5. package/dist/catalyst/p-048192b1.entry.js.map +1 -0
  6. package/dist/cjs/cat-alert_24.cjs.entry.js +79 -9
  7. package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
  8. package/dist/cjs/catalyst.cjs.js +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/components/cat-select-remote/cat-select-remote.css +21 -7
  11. package/dist/collection/components/cat-select-remote/cat-select-remote.js +59 -13
  12. package/dist/collection/components/cat-select-remote/cat-select-remote.js.map +1 -1
  13. package/dist/collection/components/cat-select-remote-test/cat-select-remote-test.js +69 -5
  14. package/dist/collection/components/cat-select-remote-test/cat-select-remote-test.js.map +1 -1
  15. package/dist/collection/index.cdn.js +17 -12
  16. package/dist/collection/index.js.map +1 -1
  17. package/dist/components/cat-avatar.js +1 -118
  18. package/dist/components/cat-avatar.js.map +1 -1
  19. package/dist/components/cat-avatar2.js +122 -0
  20. package/dist/components/cat-avatar2.js.map +1 -0
  21. package/dist/components/cat-select-remote-test.js +72 -4
  22. package/dist/components/cat-select-remote-test.js.map +1 -1
  23. package/dist/components/cat-select-remote2.js +21 -7
  24. package/dist/components/cat-select-remote2.js.map +1 -1
  25. package/dist/esm/cat-alert_24.entry.js +79 -9
  26. package/dist/esm/cat-alert_24.entry.js.map +1 -1
  27. package/dist/esm/catalyst.js +1 -1
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/types/components/cat-select-remote/cat-select-remote.d.ts +30 -3
  30. package/dist/types/components/cat-select-remote-test/cat-select-remote-test.d.ts +2 -0
  31. package/dist/types/components.d.ts +10 -2
  32. package/dist/types/index.d.ts +3 -0
  33. package/package.json +2 -2
  34. package/dist/catalyst/p-01da674e.entry.js.map +0 -1
@@ -12918,7 +12918,7 @@ var autosizeInput = function (element, options) {
12918
12918
  }
12919
12919
  };
12920
12920
 
12921
- const catSelectRemoteCss = ".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}:host{display:flex;flex-direction:column;gap:0.5rem;position:relative}: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:4px}.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))}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.select-wrapper-inner{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:4px;min-width:0}.select-input{font:inherit;background:none;border:none;outline:none;padding:6px 8px;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:4px;padding:4px 8px;background:#ebecf0;border-radius:0.125rem;white-space:nowrap;min-width:0}.pill>span{overflow:hidden;text-overflow:ellipsis}.pill>cat-button{margin-right:-4px}.select-btn{transition:transform 0.13s linear}.select-btn::part(button){outline:none}cat-spinner{padding:6px}.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-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))}";
12921
+ const catSelectRemoteCss = ".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}: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))}.select-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.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))}";
12922
12922
 
12923
12923
  const INIT_STATE = {
12924
12924
  term: '',
@@ -12937,6 +12937,7 @@ const CatSelectRemote = class {
12937
12937
  this.catOpen = createEvent(this, "catOpen", 7);
12938
12938
  this.catClose = createEvent(this, "catClose", 7);
12939
12939
  this.catChange = createEvent(this, "catChange", 7);
12940
+ this.catBlur = createEvent(this, "catBlur", 7);
12940
12941
  this.i18n = CatI18nRegistry.getInstance();
12941
12942
  this.id = `cat-input-${nextUniqueId$4++}`;
12942
12943
  this.term$ = new Subject();
@@ -12972,7 +12973,7 @@ const CatSelectRemote = class {
12972
12973
  */
12973
12974
  this.labelHidden = false;
12974
12975
  /**
12975
- * A value is required or must be check for the form to be submittable.
12976
+ * A value is required or must be checked for the form to be submittable.
12976
12977
  */
12977
12978
  this.required = false;
12978
12979
  /**
@@ -13021,12 +13022,13 @@ const CatSelectRemote = class {
13021
13022
  loglevel.error('[A11y] Missing ARIA label on select', this);
13022
13023
  }
13023
13024
  }
13024
- onBlur() {
13025
+ onBlur(event) {
13025
13026
  if (!this.multiple && this.state.activeOptionIndex >= 0) {
13026
13027
  this.select(this.state.options[this.state.activeOptionIndex]);
13027
13028
  }
13028
13029
  this.hide();
13029
13030
  this.patchState({ activeSelectionIndex: -1 });
13031
+ this.catBlur.emit(event);
13030
13032
  }
13031
13033
  onKeyDown(event) {
13032
13034
  var _a, _b, _c, _d, _e;
@@ -13092,6 +13094,11 @@ const CatSelectRemote = class {
13092
13094
  }
13093
13095
  }
13094
13096
  }
13097
+ /**
13098
+ * Connect the functions of the select
13099
+ *
13100
+ * @param connector - The {@link CatSelectRemoteConnector} of the select.
13101
+ */
13095
13102
  async connect(connector) {
13096
13103
  var _a;
13097
13104
  this.connector = connector;
@@ -13112,16 +13119,17 @@ const CatSelectRemote = class {
13112
13119
  pill: true,
13113
13120
  'select-no-open': true,
13114
13121
  'select-option-active': this.state.activeSelectionIndex === i
13115
- }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, 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 }))))))) : 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) &&
13122
+ }, 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) &&
13116
13123
  !this.disabled &&
13117
13124
  !this.state.isResolving &&
13118
13125
  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('select.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 => {
13119
13126
  this.toggle(item);
13120
13127
  e.stopPropagation();
13121
- } }, h("span", { slot: "label", class: "select-option" }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description)))) : (h("div", { class: {
13128
+ } }, 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: {
13129
+ 'select-option-inner': true,
13122
13130
  'select-option-single': true,
13123
13131
  'select-option-active': this.state.activeOptionIndex === i
13124
- }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, h("span", { class: "select-option-label" }, item.render.label), h("span", { class: "select-option-description" }, item.render.description)))))), this.state.isLoading
13132
+ }, 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
13125
13133
  ? Array.from(Array(CatSelectRemote.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" }, h("cat-skeleton", { variant: "body", lines: 1 }), h("cat-skeleton", { variant: "body", lines: 1 }))))
13126
13134
  : !this.state.options.length && h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
13127
13135
  }
@@ -13333,7 +13341,7 @@ const CatSelectRemoteTest = class {
13333
13341
  registerInstance(this, hostRef);
13334
13342
  }
13335
13343
  componentDidLoad() {
13336
- var _a, _b;
13344
+ var _a, _b, _c, _d;
13337
13345
  (_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
13338
13346
  resolve: (ids) => {
13339
13347
  console.info(`Resolving data... (${ids.join(', ')})`);
@@ -13364,7 +13372,41 @@ const CatSelectRemoteTest = class {
13364
13372
  description: user.desc
13365
13373
  })
13366
13374
  });
13367
- (_b = this.singleSelect) === null || _b === void 0 ? void 0 : _b.connect({
13375
+ (_b = this.multipleSelectAvatar) === null || _b === void 0 ? void 0 : _b.connect({
13376
+ resolve: (ids) => {
13377
+ console.info(`Resolving data... (${ids.join(', ')})`);
13378
+ return of(ids.map(id => ({
13379
+ id,
13380
+ firstName: 'John',
13381
+ lastName: `Doe (${id})`,
13382
+ desc: 'resolved'
13383
+ }))).pipe(delay(500));
13384
+ },
13385
+ retrieve: (term, page) => {
13386
+ console.info(`Retrieving data... ("${term}", ${page})`);
13387
+ return term === 'no'
13388
+ ? of({ last: true, content: [], totalElements: 0 })
13389
+ : of({
13390
+ last: false,
13391
+ totalElements: 10000,
13392
+ content: Array.from({ length: 10 }, (_, i) => ({
13393
+ id: '' + (i + page * 10),
13394
+ firstName: 'John',
13395
+ lastName: `Doe (${i + page * 10})`,
13396
+ desc: `"${term}": page ${page}`
13397
+ }))
13398
+ }).pipe(delay(500));
13399
+ },
13400
+ render: (user) => ({
13401
+ label: `${user.firstName} ${user.lastName}`,
13402
+ description: user.desc,
13403
+ avatar: {
13404
+ src: `https://picsum.photos/id/${Math.floor(Math.random() * 100)}/200`,
13405
+ round: true
13406
+ }
13407
+ })
13408
+ });
13409
+ (_c = this.singleSelect) === null || _c === void 0 ? void 0 : _c.connect({
13368
13410
  resolve: (ids) => {
13369
13411
  console.info(`Resolving data... (${ids.join(', ')})`);
13370
13412
  return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
@@ -13388,9 +13430,37 @@ const CatSelectRemoteTest = class {
13388
13430
  description: country.capital || 'No capital'
13389
13431
  })
13390
13432
  });
13433
+ (_d = this.singleSelectAvatar) === null || _d === void 0 ? void 0 : _d.connect({
13434
+ resolve: (ids) => {
13435
+ console.info(`Resolving data... (${ids.join(', ')})`);
13436
+ return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
13437
+ },
13438
+ retrieve: (term, page) => {
13439
+ console.info(`Retrieving data... ("${term}", ${page})`);
13440
+ const filter = countries.filter(value => {
13441
+ var _a;
13442
+ return value.country.toLowerCase().indexOf(term.toLowerCase()) === 0 ||
13443
+ ((_a = value.capital) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(term.toLowerCase())) === 0;
13444
+ });
13445
+ const slice = filter.slice(page * 10, page * 10 + 10);
13446
+ return of({
13447
+ last: slice.length < 10,
13448
+ totalElements: filter.length,
13449
+ content: slice
13450
+ }).pipe(delay(500));
13451
+ },
13452
+ render: (country) => ({
13453
+ label: country.country,
13454
+ description: country.capital || 'No capital',
13455
+ avatar: {
13456
+ src: `https://picsum.photos/id/${Math.floor(Math.random() * 100)}/200`,
13457
+ round: true
13458
+ }
13459
+ })
13460
+ });
13391
13461
  }
13392
13462
  render() {
13393
- return (h(Host, { style: { display: 'flex', gap: '0.5rem', flexDirection: 'column' } }, h("cat-select-remote", { label: "Multiple Select", hint: "This is a hint!", ref: el => (this.multipleSelect = el), value: ['1'], placeholder: "Hello World", onCatChange: e => console.log('Multiple', e), multiple: true, clearable: true }, h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), h("cat-select-remote", { 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), clearable: true })));
13463
+ return (h(Host, { style: { display: 'flex', flexDirection: 'column' } }, h("cat-select-remote", { 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-remote", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), h("cat-select-remote", { 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-remote", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
13394
13464
  }
13395
13465
  };
13396
13466
  const countries = [