@haiilo/catalyst 2.0.3 → 2.1.1

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 (77) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/p-53a1db22.js +3 -0
  4. package/dist/catalyst/p-53a1db22.js.map +1 -0
  5. package/dist/catalyst/p-5bfc70e3.entry.js +2 -0
  6. package/dist/catalyst/{p-270fd91d.entry.js.map → p-5bfc70e3.entry.js.map} +1 -1
  7. package/dist/catalyst/p-c0ccf7d1.entry.js +2 -0
  8. package/dist/catalyst/p-c0ccf7d1.entry.js.map +1 -0
  9. package/dist/cjs/cat-alert_22.cjs.entry.js +113 -22
  10. package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
  11. package/dist/cjs/cat-modal.cjs.entry.js +2 -2
  12. package/dist/cjs/cat-modal.cjs.entry.js.map +1 -1
  13. package/dist/cjs/catalyst.cjs.js +2 -2
  14. package/dist/cjs/{index-b2134f1b.js → index-e540e911.js} +1 -4
  15. package/dist/cjs/index-e540e911.js.map +1 -0
  16. package/dist/cjs/loader.cjs.js +2 -2
  17. package/dist/collection/components/cat-button/cat-button.js +50 -4
  18. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  19. package/dist/collection/components/cat-checkbox/cat-checkbox.js +50 -4
  20. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  21. package/dist/collection/components/cat-input/cat-input.js +50 -4
  22. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  23. package/dist/collection/components/cat-radio/cat-radio.js +50 -4
  24. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  25. package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
  26. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
  27. package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
  28. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  29. package/dist/collection/components/cat-textarea/cat-textarea.js +50 -4
  30. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  31. package/dist/collection/components/cat-toggle/cat-toggle.js +50 -4
  32. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  33. package/dist/collection/components/cat-tooltip/cat-tooltip.css +11 -0
  34. package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -6
  35. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  36. package/dist/components/cat-button2.js +19 -3
  37. package/dist/components/cat-button2.js.map +1 -1
  38. package/dist/components/cat-checkbox2.js +19 -3
  39. package/dist/components/cat-checkbox2.js.map +1 -1
  40. package/dist/components/cat-input.js +19 -3
  41. package/dist/components/cat-input.js.map +1 -1
  42. package/dist/components/cat-radio-group.js +1 -1
  43. package/dist/components/cat-radio-group.js.map +1 -1
  44. package/dist/components/cat-radio.js +19 -3
  45. package/dist/components/cat-radio.js.map +1 -1
  46. package/dist/components/cat-tabs.js +1 -1
  47. package/dist/components/cat-tabs.js.map +1 -1
  48. package/dist/components/cat-textarea.js +19 -3
  49. package/dist/components/cat-textarea.js.map +1 -1
  50. package/dist/components/cat-toggle.js +19 -3
  51. package/dist/components/cat-toggle.js.map +1 -1
  52. package/dist/components/cat-tooltip.js +14 -7
  53. package/dist/components/cat-tooltip.js.map +1 -1
  54. package/dist/esm/cat-alert_22.entry.js +113 -22
  55. package/dist/esm/cat-alert_22.entry.js.map +1 -1
  56. package/dist/esm/cat-modal.entry.js +2 -2
  57. package/dist/esm/cat-modal.entry.js.map +1 -1
  58. package/dist/esm/catalyst.js +2 -2
  59. package/dist/esm/{index-033048ed.js → index-c2a28ebb.js} +2 -4
  60. package/dist/esm/index-c2a28ebb.js.map +1 -0
  61. package/dist/esm/loader.js +2 -2
  62. package/dist/types/components/cat-button/cat-button.d.ts +12 -2
  63. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +12 -2
  64. package/dist/types/components/cat-input/cat-input.d.ts +12 -2
  65. package/dist/types/components/cat-radio/cat-radio.d.ts +12 -2
  66. package/dist/types/components/cat-textarea/cat-textarea.d.ts +12 -2
  67. package/dist/types/components/cat-toggle/cat-toggle.d.ts +12 -2
  68. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +3 -0
  69. package/dist/types/components.d.ts +78 -30
  70. package/package.json +2 -2
  71. package/dist/catalyst/p-270fd91d.entry.js +0 -2
  72. package/dist/catalyst/p-3a489c97.entry.js +0 -2
  73. package/dist/catalyst/p-3a489c97.entry.js.map +0 -1
  74. package/dist/catalyst/p-692e49d6.js +0 -3
  75. package/dist/catalyst/p-692e49d6.js.map +0 -1
  76. package/dist/cjs/index-b2134f1b.js.map +0 -1
  77. package/dist/esm/index-033048ed.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-b2134f1b.js');
5
+ const index = require('./index-e540e911.js');
6
6
  const catIconRegistry = require('./cat-icon-registry-2a54df3d.js');
7
7
  const firstTabbable = require('./first-tabbable-7966cf1c.js');
8
8
 
@@ -384,14 +384,28 @@ const CatButton = class {
384
384
  }
385
385
  }
386
386
  /**
387
- * Sets focus on the button. Use this method instead of `button.focus()`.
387
+ * Programmatically move focus to the button. Use this method instead of
388
+ * `button.focus()`.
388
389
  *
389
390
  * @param options An optional object providing options to control aspects of
390
391
  * the focusing process.
391
392
  */
392
- async setFocus(options) {
393
+ async doFocus(options) {
393
394
  this.button.focus(options);
394
395
  }
396
+ /**
397
+ * Programmatically remove focus from the button. Use this method instead of
398
+ * `button.blur()`.
399
+ */
400
+ async doBlur() {
401
+ this.button.blur();
402
+ }
403
+ /**
404
+ * Programmatically simulate a click on the button.
405
+ */
406
+ async doClick() {
407
+ this.button.click();
408
+ }
395
409
  render() {
396
410
  var _a;
397
411
  if (this.url) {
@@ -550,14 +564,28 @@ const CatCheckbox = class {
550
564
  }
551
565
  }
552
566
  /**
553
- * Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.
567
+ * Programmatically move focus to the checkbox. Use this method instead of
568
+ * `input.focus()`.
554
569
  *
555
570
  * @param options An optional object providing options to control aspects of
556
571
  * the focusing process.
557
572
  */
558
- async setFocus(options) {
573
+ async doFocus(options) {
559
574
  this.input.focus(options);
560
575
  }
576
+ /**
577
+ * Programmatically remove focus from the checkbox. Use this method instead of
578
+ * `input.blur()`.
579
+ */
580
+ async doBlur() {
581
+ this.input.blur();
582
+ }
583
+ /**
584
+ * Programmatically simulate a click on the checkbox.
585
+ */
586
+ async doClick() {
587
+ this.input.click();
588
+ }
561
589
  render() {
562
590
  return (index.h(index.Host, null, index.h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft } }, index.h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value !== undefined ? String(this.value) : this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), index.h("span", { class: "box", "aria-hidden": "true", part: "checkbox" }, index.h("svg", { class: "check", viewBox: "0 0 12 10" }, index.h("polyline", { points: "1.5 6 4.5 9 10.5 1" })), index.h("svg", { class: "dash", viewBox: "0 0 12 10" }, index.h("polyline", { points: "1.5 5 10.5 5" }))), index.h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label)), this.hintSection));
563
591
  }
@@ -1948,14 +1976,28 @@ const CatInput = class {
1948
1976
  }
1949
1977
  }
1950
1978
  /**
1951
- * Sets focus on the input. Use this method instead of `input.focus()`.
1979
+ * Programmatically move focus to the input. Use this method instead of
1980
+ * `input.focus()`.
1952
1981
  *
1953
1982
  * @param options An optional object providing options to control aspects of
1954
1983
  * the focusing process.
1955
1984
  */
1956
- async setFocus(options) {
1985
+ async doFocus(options) {
1957
1986
  this.input.focus(options);
1958
1987
  }
1988
+ /**
1989
+ * Programmatically remove focus from the input. Use this method instead of
1990
+ * `input.blur()`.
1991
+ */
1992
+ async doBlur() {
1993
+ this.input.blur();
1994
+ }
1995
+ /**
1996
+ * Programmatically simulate a click on the input.
1997
+ */
1998
+ async doClick() {
1999
+ this.input.click();
2000
+ }
1959
2001
  /**
1960
2002
  * Clear the input.
1961
2003
  */
@@ -2129,14 +2171,28 @@ const CatRadio = class {
2129
2171
  }
2130
2172
  }
2131
2173
  /**
2132
- * Sets focus on the radio. Use this method instead of `radio.focus()`.
2174
+ * Programmatically move focus to the radio button. Use this method instead of
2175
+ * `input.focus()`.
2133
2176
  *
2134
2177
  * @param options An optional object providing options to control aspects of
2135
2178
  * the focusing process.
2136
2179
  */
2137
- async setFocus(options) {
2180
+ async doFocus(options) {
2138
2181
  this.input.focus(options);
2139
2182
  }
2183
+ /**
2184
+ * Programmatically remove focus from the radio button. Use this method
2185
+ * instead of `input.blur()`.
2186
+ */
2187
+ async doBlur() {
2188
+ this.input.blur();
2189
+ }
2190
+ /**
2191
+ * Programmatically simulate a click on the radio button.
2192
+ */
2193
+ async doClick() {
2194
+ this.input.click();
2195
+ }
2140
2196
  render() {
2141
2197
  return (index.h(index.Host, null, index.h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }, role: "radio", "aria-checked": this.checked ? 'true' : 'false' }, index.h("span", { class: "radio" }, index.h("input", { ref: el => (this.input = el), id: this.id, type: "radio", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onChange.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), index.h("span", { class: "circle" })), index.h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label)), this.hintSection));
2142
2198
  }
@@ -2207,7 +2263,7 @@ const CatRadioGroup = class {
2207
2263
  const activeIdx = this.catRadioGroup.findIndex(catRadio => catRadio === activeElement);
2208
2264
  const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;
2209
2265
  const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
2210
- targetElements[targetIdx].setFocus();
2266
+ targetElements[targetIdx].doFocus();
2211
2267
  (_b = (_a = targetElements[targetIdx].shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.click();
2212
2268
  this.updateTabIndex();
2213
2269
  event.preventDefault();
@@ -6179,7 +6235,7 @@ const CatTabs = class {
6179
6235
  const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
6180
6236
  const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;
6181
6237
  const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
6182
- targetElements[targetIdx].setFocus();
6238
+ targetElements[targetIdx].doFocus();
6183
6239
  event.preventDefault();
6184
6240
  }
6185
6241
  }
@@ -6262,14 +6318,28 @@ const CatTextarea = class {
6262
6318
  d(this.textarea);
6263
6319
  }
6264
6320
  /**
6265
- * Sets focus on the textarea. Use this method instead of `textarea.focus()`.
6321
+ * Programmatically move focus to the textarea. Use this method instead of
6322
+ * `textarea.focus()`.
6266
6323
  *
6267
6324
  * @param options An optional object providing options to control aspects of
6268
6325
  * the focusing process.
6269
6326
  */
6270
- async setFocus(options) {
6327
+ async doFocus(options) {
6271
6328
  this.textarea.focus(options);
6272
6329
  }
6330
+ /**
6331
+ * Programmatically remove focus from the textarea. Use this method instead of
6332
+ * `textarea.blur()`.
6333
+ */
6334
+ async doBlur() {
6335
+ this.textarea.blur();
6336
+ }
6337
+ /**
6338
+ * Programmatically simulate a click on the textarea.
6339
+ */
6340
+ async doClick() {
6341
+ this.textarea.click();
6342
+ }
6273
6343
  render() {
6274
6344
  return (index.h(index.Host, null, (this.hasSlottedLabel || this.label) && (index.h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, index.h("span", { part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label, !this.required && (index.h("span", { class: "input-optional", "aria-hidden": "true" }, "(Optional)"))))), index.h("textarea", { ref: el => (this.textarea = el), id: this.id, disabled: this.disabled, maxlength: this.maxLength, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, rows: this.rows, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), this.hintSection));
6275
6345
  }
@@ -6334,14 +6404,28 @@ const CatToggle = class {
6334
6404
  }
6335
6405
  }
6336
6406
  /**
6337
- * Sets focus on the toggle. Use this method instead of `toggle.focus()`.
6407
+ * Programmatically move focus to the toggle. Use this method instead of
6408
+ * `input.focus()`.
6338
6409
  *
6339
6410
  * @param options An optional object providing options to control aspects of
6340
6411
  * the focusing process.
6341
6412
  */
6342
- async setFocus(options) {
6413
+ async doFocus(options) {
6343
6414
  this.input.focus(options);
6344
6415
  }
6416
+ /**
6417
+ * Programmatically remove focus from the toggle. Use this method instead of
6418
+ * `input.blur()`.
6419
+ */
6420
+ async doBlur() {
6421
+ this.input.blur();
6422
+ }
6423
+ /**
6424
+ * Programmatically simulate a click on the toggle.
6425
+ */
6426
+ async doClick() {
6427
+ this.input.click();
6428
+ }
6345
6429
  render() {
6346
6430
  return (index.h(index.Host, null, index.h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft } }, index.h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value !== undefined ? String(this.value) : this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), index.h("span", { class: "toggle", part: "toggle" }), index.h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && index.h("slot", { name: "label" })) || this.label)), this.hintSection));
6347
6431
  }
@@ -6368,13 +6452,14 @@ CatToggle.style = catToggleCss;
6368
6452
 
6369
6453
  const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
6370
6454
 
6371
- const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;background-color:rgb(var(--cat-bg-tooltip, 0, 0, 0));border-radius:var(--cat-border-radius-m, 0.25rem);color:rgb(var(--cat-font-color-tooltip, 255, 255, 255));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}";
6455
+ const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;background-color:rgb(var(--cat-bg-tooltip, 0, 0, 0));border-radius:var(--cat-border-radius-m, 0.25rem);color:rgb(var(--cat-font-color-tooltip, 255, 255, 255));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-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}.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}";
6372
6456
 
6373
6457
  let nextUniqueId = 0;
6374
6458
  const CatTooltip = class {
6375
6459
  constructor(hostRef) {
6376
6460
  index.registerInstance(this, hostRef);
6377
6461
  this.id = `cat-tooltip-${nextUniqueId++}`;
6462
+ this.hidden = false;
6378
6463
  /**
6379
6464
  * The content of the tooltip.
6380
6465
  */
@@ -6433,6 +6518,9 @@ const CatTooltip = class {
6433
6518
  (_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('mouseleave', this.hideListener.bind(this));
6434
6519
  }
6435
6520
  }
6521
+ componentWillRender() {
6522
+ this.hidden = !this.content || this.disabled;
6523
+ }
6436
6524
  disconnectedCallback() {
6437
6525
  var _a, _b, _c, _d, _e, _f;
6438
6526
  if (isTouchDevice) {
@@ -6448,11 +6536,12 @@ const CatTooltip = class {
6448
6536
  }
6449
6537
  }
6450
6538
  render() {
6451
- return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), this.content && !this.disabled && (index.h("div", { ref: el => (this.tooltip = el), id: this.id, class: {
6539
+ return (index.h(index.Host, null, index.h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, index.h("slot", null)), index.h("div", { ref: el => (this.tooltip = el), id: this.id, "aria-hidden": this.hidden, class: {
6452
6540
  tooltip: true,
6541
+ 'tooltip-hidden': this.hidden,
6453
6542
  'tooltip-round': this.round,
6454
6543
  [`tooltip-${this.size}`]: Boolean(this.size)
6455
- } }, this.content))));
6544
+ } }, this.content)));
6456
6545
  }
6457
6546
  get isTabbable() {
6458
6547
  return firstTabbable.firstTabbable(this.trigger);
@@ -6475,8 +6564,7 @@ const CatTooltip = class {
6475
6564
  showListener() {
6476
6565
  window.clearTimeout(this.hideTimeout);
6477
6566
  this.showTimeout = window.setTimeout(() => {
6478
- var _a;
6479
- (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
6567
+ this.showTooltip();
6480
6568
  }, this.showDelay);
6481
6569
  }
6482
6570
  hideListener() {
@@ -6489,8 +6577,7 @@ const CatTooltip = class {
6489
6577
  touchStartListener(event) {
6490
6578
  event.stopPropagation();
6491
6579
  this.touchTimeout = window.setTimeout(() => {
6492
- var _a;
6493
- (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
6580
+ this.showTooltip();
6494
6581
  }, this.longTouchDuration);
6495
6582
  }
6496
6583
  touchEndListener() {
@@ -6502,6 +6589,10 @@ const CatTooltip = class {
6502
6589
  var _a;
6503
6590
  (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
6504
6591
  }
6592
+ showTooltip() {
6593
+ var _a;
6594
+ !this.hidden && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show'));
6595
+ }
6505
6596
  };
6506
6597
  CatTooltip.OFFSET = 4;
6507
6598
  CatTooltip.style = catTooltipCss;