@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
@@ -12922,7 +12922,7 @@ var autosizeInput = function (element, options) {
12922
12922
  }
12923
12923
  };
12924
12924
 
12925
- 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))}";
12925
+ 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))}";
12926
12926
 
12927
12927
  const INIT_STATE = {
12928
12928
  term: '',
@@ -12941,6 +12941,7 @@ const CatSelectRemote = class {
12941
12941
  this.catOpen = index.createEvent(this, "catOpen", 7);
12942
12942
  this.catClose = index.createEvent(this, "catClose", 7);
12943
12943
  this.catChange = index.createEvent(this, "catChange", 7);
12944
+ this.catBlur = index.createEvent(this, "catBlur", 7);
12944
12945
  this.i18n = catNotification.CatI18nRegistry.getInstance();
12945
12946
  this.id = `cat-input-${nextUniqueId$4++}`;
12946
12947
  this.term$ = new Subject();
@@ -12976,7 +12977,7 @@ const CatSelectRemote = class {
12976
12977
  */
12977
12978
  this.labelHidden = false;
12978
12979
  /**
12979
- * A value is required or must be check for the form to be submittable.
12980
+ * A value is required or must be checked for the form to be submittable.
12980
12981
  */
12981
12982
  this.required = false;
12982
12983
  /**
@@ -13025,12 +13026,13 @@ const CatSelectRemote = class {
13025
13026
  catNotification.loglevel.error('[A11y] Missing ARIA label on select', this);
13026
13027
  }
13027
13028
  }
13028
- onBlur() {
13029
+ onBlur(event) {
13029
13030
  if (!this.multiple && this.state.activeOptionIndex >= 0) {
13030
13031
  this.select(this.state.options[this.state.activeOptionIndex]);
13031
13032
  }
13032
13033
  this.hide();
13033
13034
  this.patchState({ activeSelectionIndex: -1 });
13035
+ this.catBlur.emit(event);
13034
13036
  }
13035
13037
  onKeyDown(event) {
13036
13038
  var _a, _b, _c, _d, _e;
@@ -13096,6 +13098,11 @@ const CatSelectRemote = class {
13096
13098
  }
13097
13099
  }
13098
13100
  }
13101
+ /**
13102
+ * Connect the functions of the select
13103
+ *
13104
+ * @param connector - The {@link CatSelectRemoteConnector} of the select.
13105
+ */
13099
13106
  async connect(connector) {
13100
13107
  var _a;
13101
13108
  this.connector = connector;
@@ -13116,16 +13123,17 @@ const CatSelectRemote = class {
13116
13123
  pill: true,
13117
13124
  'select-no-open': true,
13118
13125
  'select-option-active': this.state.activeSelectionIndex === i
13119
- }, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, 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 }))))))) : 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) &&
13126
+ }, 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) &&
13120
13127
  !this.disabled &&
13121
13128
  !this.state.isResolving &&
13122
13129
  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('select.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 => {
13123
13130
  this.toggle(item);
13124
13131
  e.stopPropagation();
13125
- } }, index.h("span", { slot: "label", class: "select-option" }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description)))) : (index.h("div", { class: {
13132
+ } }, 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: {
13133
+ 'select-option-inner': true,
13126
13134
  'select-option-single': true,
13127
13135
  'select-option-active': this.state.activeOptionIndex === i
13128
- }, onFocus: () => { var _a; return (_a = this.input) === null || _a === void 0 ? void 0 : _a.focus(); }, onClick: () => this.select(item), tabIndex: -1 }, index.h("span", { class: "select-option-label" }, item.render.label), index.h("span", { class: "select-option-description" }, item.render.description)))))), this.state.isLoading
13136
+ }, 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
13129
13137
  ? Array.from(Array(CatSelectRemote.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 }))))
13130
13138
  : !this.state.options.length && index.h("li", { class: "select-option-empty" }, this.i18n.t('select.empty'))))))));
13131
13139
  }
@@ -13337,7 +13345,7 @@ const CatSelectRemoteTest = class {
13337
13345
  index.registerInstance(this, hostRef);
13338
13346
  }
13339
13347
  componentDidLoad() {
13340
- var _a, _b;
13348
+ var _a, _b, _c, _d;
13341
13349
  (_a = this.multipleSelect) === null || _a === void 0 ? void 0 : _a.connect({
13342
13350
  resolve: (ids) => {
13343
13351
  console.info(`Resolving data... (${ids.join(', ')})`);
@@ -13368,7 +13376,41 @@ const CatSelectRemoteTest = class {
13368
13376
  description: user.desc
13369
13377
  })
13370
13378
  });
13371
- (_b = this.singleSelect) === null || _b === void 0 ? void 0 : _b.connect({
13379
+ (_b = this.multipleSelectAvatar) === null || _b === void 0 ? void 0 : _b.connect({
13380
+ resolve: (ids) => {
13381
+ console.info(`Resolving data... (${ids.join(', ')})`);
13382
+ return of(ids.map(id => ({
13383
+ id,
13384
+ firstName: 'John',
13385
+ lastName: `Doe (${id})`,
13386
+ desc: 'resolved'
13387
+ }))).pipe(delay(500));
13388
+ },
13389
+ retrieve: (term, page) => {
13390
+ console.info(`Retrieving data... ("${term}", ${page})`);
13391
+ return term === 'no'
13392
+ ? of({ last: true, content: [], totalElements: 0 })
13393
+ : of({
13394
+ last: false,
13395
+ totalElements: 10000,
13396
+ content: Array.from({ length: 10 }, (_, i) => ({
13397
+ id: '' + (i + page * 10),
13398
+ firstName: 'John',
13399
+ lastName: `Doe (${i + page * 10})`,
13400
+ desc: `"${term}": page ${page}`
13401
+ }))
13402
+ }).pipe(delay(500));
13403
+ },
13404
+ render: (user) => ({
13405
+ label: `${user.firstName} ${user.lastName}`,
13406
+ description: user.desc,
13407
+ avatar: {
13408
+ src: `https://picsum.photos/id/${Math.floor(Math.random() * 100)}/200`,
13409
+ round: true
13410
+ }
13411
+ })
13412
+ });
13413
+ (_c = this.singleSelect) === null || _c === void 0 ? void 0 : _c.connect({
13372
13414
  resolve: (ids) => {
13373
13415
  console.info(`Resolving data... (${ids.join(', ')})`);
13374
13416
  return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
@@ -13392,9 +13434,37 @@ const CatSelectRemoteTest = class {
13392
13434
  description: country.capital || 'No capital'
13393
13435
  })
13394
13436
  });
13437
+ (_d = this.singleSelectAvatar) === null || _d === void 0 ? void 0 : _d.connect({
13438
+ resolve: (ids) => {
13439
+ console.info(`Resolving data... (${ids.join(', ')})`);
13440
+ return of(ids.map(id => countries.find(value => value.id === id))).pipe(delay(500));
13441
+ },
13442
+ retrieve: (term, page) => {
13443
+ console.info(`Retrieving data... ("${term}", ${page})`);
13444
+ const filter = countries.filter(value => {
13445
+ var _a;
13446
+ return value.country.toLowerCase().indexOf(term.toLowerCase()) === 0 ||
13447
+ ((_a = value.capital) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(term.toLowerCase())) === 0;
13448
+ });
13449
+ const slice = filter.slice(page * 10, page * 10 + 10);
13450
+ return of({
13451
+ last: slice.length < 10,
13452
+ totalElements: filter.length,
13453
+ content: slice
13454
+ }).pipe(delay(500));
13455
+ },
13456
+ render: (country) => ({
13457
+ label: country.country,
13458
+ description: country.capital || 'No capital',
13459
+ avatar: {
13460
+ src: `https://picsum.photos/id/${Math.floor(Math.random() * 100)}/200`,
13461
+ round: true
13462
+ }
13463
+ })
13464
+ });
13395
13465
  }
13396
13466
  render() {
13397
- return (index.h(index.Host, { style: { display: 'flex', gap: '0.5rem', flexDirection: 'column' } }, index.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 }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.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 })));
13467
+ return (index.h(index.Host, { style: { display: 'flex', flexDirection: 'column' } }, index.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 }, index.h("span", { slot: "hint" }, "Searching for \"no\" -", '>', " no options are returned!")), index.h("cat-select-remote", { label: "Multiple with img", ref: el => (this.multipleSelectAvatar = el), value: ['1'], placeholder: "Hello World", multiple: true, clearable: true }), index.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 }), index.h("cat-select-remote", { label: "Single with img", ref: el => (this.singleSelectAvatar = el), value: '1', placeholder: "Search for a country or capital", clearable: true })));
13398
13468
  }
13399
13469
  };
13400
13470
  const countries = [