@haiilo/catalyst 2.3.0 → 2.4.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 (77) 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-e5f9669a.entry.js +2 -0
  5. package/dist/catalyst/p-e5f9669a.entry.js.map +1 -0
  6. package/dist/catalyst/scss/core/_typography.scss +5 -4
  7. package/dist/cjs/{cat-alert_22.cjs.entry.js → cat-alert_23.cjs.entry.js} +71 -49
  8. package/dist/cjs/cat-alert_23.cjs.entry.js.map +1 -0
  9. package/dist/cjs/catalyst.cjs.js +1 -1
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/collection/collection-manifest.json +1 -0
  12. package/dist/collection/components/cat-alert/cat-alert.js +2 -3
  13. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
  14. package/dist/collection/components/cat-badge/cat-badge.js +6 -31
  15. package/dist/collection/components/cat-badge/cat-badge.js.map +1 -1
  16. package/dist/collection/components/cat-checkbox/cat-checkbox.js +21 -1
  17. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  18. package/dist/collection/components/cat-input/cat-input.js +24 -9
  19. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  20. package/dist/collection/components/cat-label/cat-label.css +16 -0
  21. package/dist/collection/components/cat-label/cat-label.js +96 -0
  22. package/dist/collection/components/cat-label/cat-label.js.map +1 -0
  23. package/dist/collection/components/cat-radio/cat-radio.js +22 -2
  24. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  25. package/dist/collection/components/cat-select/cat-select.js +24 -9
  26. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  27. package/dist/collection/components/cat-textarea/cat-textarea.js +24 -9
  28. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  29. package/dist/collection/components/cat-toggle/cat-toggle.js +21 -1
  30. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  31. package/dist/collection/scss/core/_typography.scss +5 -4
  32. package/dist/collection/utils/setDefault.js +0 -6
  33. package/dist/collection/utils/setDefault.js.map +1 -1
  34. package/dist/components/cat-alert.js +7 -3
  35. package/dist/components/cat-alert.js.map +1 -1
  36. package/dist/components/cat-badge.js +5 -25
  37. package/dist/components/cat-badge.js.map +1 -1
  38. package/dist/components/cat-checkbox2.js +5 -1
  39. package/dist/components/cat-checkbox2.js.map +1 -1
  40. package/dist/components/cat-dropdown2.js.map +1 -1
  41. package/dist/components/cat-input.js +5 -5
  42. package/dist/components/cat-input.js.map +1 -1
  43. package/dist/components/cat-label.d.ts +11 -0
  44. package/dist/components/cat-label.js +71 -0
  45. package/dist/components/cat-label.js.map +1 -0
  46. package/dist/components/cat-radio.js +6 -2
  47. package/dist/components/cat-radio.js.map +1 -1
  48. package/dist/components/cat-select2.js +5 -5
  49. package/dist/components/cat-select2.js.map +1 -1
  50. package/dist/components/cat-textarea.js +5 -5
  51. package/dist/components/cat-textarea.js.map +1 -1
  52. package/dist/components/cat-toggle.js +5 -1
  53. package/dist/components/cat-toggle.js.map +1 -1
  54. package/dist/components/index.d.ts +1 -0
  55. package/dist/components/index.js +1 -0
  56. package/dist/components/index.js.map +1 -1
  57. package/dist/esm/{cat-alert_22.entry.js → cat-alert_23.entry.js} +71 -50
  58. package/dist/esm/cat-alert_23.entry.js.map +1 -0
  59. package/dist/esm/catalyst.js +1 -1
  60. package/dist/esm/loader.js +1 -1
  61. package/dist/types/components/cat-badge/cat-badge.d.ts +0 -4
  62. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +6 -1
  63. package/dist/types/components/cat-input/cat-input.d.ts +7 -2
  64. package/dist/types/components/cat-label/cat-label.d.ts +17 -0
  65. package/dist/types/components/cat-radio/cat-radio.d.ts +6 -1
  66. package/dist/types/components/cat-select/cat-select.d.ts +7 -2
  67. package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
  68. package/dist/types/components/cat-toggle/cat-toggle.d.ts +6 -1
  69. package/dist/types/components.d.ts +80 -3
  70. package/dist/types/utils/setDefault.d.ts +0 -6
  71. package/package.json +2 -2
  72. package/dist/catalyst/p-757cf2e8.entry.js +0 -2
  73. package/dist/catalyst/p-757cf2e8.entry.js.map +0 -1
  74. package/dist/cjs/cat-alert_22.cjs.entry.js.map +0 -1
  75. package/dist/components/setDefault.js +0 -18
  76. package/dist/components/setDefault.js.map +0 -1
  77. package/dist/esm/cat-alert_22.entry.js.map +0 -1
@@ -7,15 +7,6 @@ function setAttributeDefault(host, attr, value) {
7
7
  host.hostElement.setAttribute(attr, String(value));
8
8
  }
9
9
  }
10
- function setPropertyDefault(host, prop) {
11
- setAttributeDefault(host, String(prop), host[prop]);
12
- }
13
- function setAttribute(host, attr, value) {
14
- host.hostElement.setAttribute(attr, String(value));
15
- }
16
- function setProperty(host, prop) {
17
- setAttribute(host, String(prop), host[prop]);
18
- }
19
10
 
20
11
  const catAlertCss = ":host{display:flex;gap:0.5rem;padding:1.25rem;border-radius:var(--cat-border-radius-l, 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, 0, 129, 148), 0.1)}:host([color=primary]) cat-icon{color:rgb(var(--cat-primary-text, 0, 129, 148))}:host([color=secondary]){background-color:rgba(var(--cat-secondary-bg, 105, 118, 135), 0.1)}:host([color=secondary]) cat-icon{color:#697687}:host([color=success]){background-color:rgba(var(--cat-success-bg-, 0, 132, 88), 0.1)}:host([color=success]) cat-icon{color:#008458}:host([color=warning]){background-color:rgba(var(--cat-warning-bg, 255, 206, 128), 0.1)}:host([color=warning]) cat-icon{color:#ebb663}:host([color=danger]){background-color:rgba(var(--cat-danger-bg, 217, 52, 13), 0.1)}:host([color=danger]) cat-icon{color:#d9340d}";
21
12
 
@@ -48,7 +39,6 @@ const CatAlert = class {
48
39
  connectedCallback() {
49
40
  setAttributeDefault(this, 'tabindex', 0);
50
41
  setAttributeDefault(this, 'role', this.mapRole.get(this.color));
51
- setPropertyDefault(this, 'color');
52
42
  }
53
43
  render() {
54
44
  return (h(Host, null, !this.noIcon && h("cat-icon", { size: "l", icon: this.icon ? this.icon : this.mapIcon.get(this.color) }), h("div", { class: "content" }, h("slot", null))));
@@ -168,29 +158,10 @@ const CatBadge = class {
168
158
  */
169
159
  this.pulse = false;
170
160
  }
171
- connectedCallback() {
172
- setPropertyDefault(this, 'variant');
173
- setPropertyDefault(this, 'color');
174
- setPropertyDefault(this, 'size');
175
- }
176
161
  render() {
177
162
  return h("slot", null);
178
163
  }
179
- onColorChanged() {
180
- setProperty(this, 'color');
181
- }
182
- onSizeChanged() {
183
- setProperty(this, 'size');
184
- }
185
- onVariantChanged() {
186
- setProperty(this, 'variant');
187
- }
188
164
  get hostElement() { return getElement(this); }
189
- static get watchers() { return {
190
- "color": ["onColorChanged"],
191
- "size": ["onSizeChanged"],
192
- "variant": ["onVariantChanged"]
193
- }; }
194
165
  };
195
166
  CatBadge.style = catBadgeCss;
196
167
 
@@ -537,7 +508,7 @@ const CatCheckbox = class {
537
508
  this.catChange = createEvent(this, "catChange", 7);
538
509
  this.catFocus = createEvent(this, "catFocus", 7);
539
510
  this.catBlur = createEvent(this, "catBlur", 7);
540
- this.id = `cat-checkbox-${nextUniqueId$8++}`;
511
+ this._id = `cat-checkbox-${nextUniqueId$8++}`;
541
512
  this.hasSlottedLabel = false;
542
513
  /**
543
514
  * Checked state of the checkbox
@@ -568,6 +539,9 @@ const CatCheckbox = class {
568
539
  */
569
540
  this.labelLeft = false;
570
541
  }
542
+ get id() {
543
+ return this.identifier || this._id;
544
+ }
571
545
  componentDidLoad() {
572
546
  if (this.input && this.indeterminate) {
573
547
  this.input.indeterminate = true;
@@ -1942,7 +1916,7 @@ const CatInput = class {
1942
1916
  this.catChange = createEvent(this, "catChange", 7);
1943
1917
  this.catFocus = createEvent(this, "catFocus", 7);
1944
1918
  this.catBlur = createEvent(this, "catBlur", 7);
1945
- this.id = `cat-input-${nextUniqueId$6++}`;
1919
+ this._id = `cat-input-${nextUniqueId$6++}`;
1946
1920
  this.hasSlottedLabel = false;
1947
1921
  /**
1948
1922
  * Whether the input should show a clear button.
@@ -1964,10 +1938,6 @@ const CatInput = class {
1964
1938
  * Visually hide the label, but still show it to assistive technologies like screen readers.
1965
1939
  */
1966
1940
  this.labelHidden = false;
1967
- /**
1968
- * The name of the form control. Submitted with the form as part of a name/value pair.
1969
- */
1970
- this.name = '';
1971
1941
  /**
1972
1942
  * The value is not editable.
1973
1943
  */
@@ -1985,6 +1955,9 @@ const CatInput = class {
1985
1955
  */
1986
1956
  this.type = 'text';
1987
1957
  }
1958
+ get id() {
1959
+ return this.identifier || this._id;
1960
+ }
1988
1961
  componentWillRender() {
1989
1962
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
1990
1963
  if (!this.label && !this.hasSlottedLabel) {
@@ -2047,6 +2020,50 @@ const CatInput = class {
2047
2020
  };
2048
2021
  CatInput.style = catInputCss;
2049
2022
 
2023
+ const catLabelCss = ":host{display:block}.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))}";
2024
+
2025
+ const CatLabel = class {
2026
+ constructor(hostRef) {
2027
+ registerInstance(this, hostRef);
2028
+ /**
2029
+ * A value is required or must be check for the form to be submittable.
2030
+ */
2031
+ this.required = false;
2032
+ }
2033
+ onClick() {
2034
+ var _a;
2035
+ if (this.for) {
2036
+ // focus target that is possibly hidden inside a shadow root
2037
+ (_a = (document.getElementById(this.for) || this.findShadowTarget(this.for))) === null || _a === void 0 ? void 0 : _a.focus();
2038
+ }
2039
+ }
2040
+ render() {
2041
+ return (h(Host, null, h("label", { htmlFor: this.for, onClick: this.onClick.bind(this) }, h("slot", null), !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.optional'), ")")))));
2042
+ }
2043
+ findShadowTarget(id) {
2044
+ var _a;
2045
+ for (let i = 0; i < CatLabel.SHADOW_TARGETS.length; i++) {
2046
+ const elems = document.getElementsByTagName(CatLabel.SHADOW_TARGETS[i]);
2047
+ for (let i = 0; i < elems.length; i++) {
2048
+ const target = (_a = elems[i].shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById(id);
2049
+ if (target) {
2050
+ return target;
2051
+ }
2052
+ }
2053
+ }
2054
+ return null;
2055
+ }
2056
+ };
2057
+ CatLabel.SHADOW_TARGETS = [
2058
+ 'CAT-INPUT',
2059
+ 'CAT-TEXTAREA',
2060
+ 'CAT-CHECKBOX',
2061
+ 'CAT-TOGGLE',
2062
+ 'CAT-RADIO',
2063
+ 'CAT-SELECT'
2064
+ ];
2065
+ CatLabel.style = catLabelCss;
2066
+
2050
2067
  const catPaginationCss = ":host{display:inline-block}:host([hidden]){display:none}ol{display:flex;flex-wrap:wrap;list-style:none;margin:0;padding:0}li{display:inline-flex;justify-content:center}li.dots{-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([variant=outlined]) ol{gap:0.75rem}.cat-pagination-xs li.dots,.cat-pagination-xs li.text{height:1.5rem;line-height:1.5rem;font-size:0.875rem}.cat-pagination-xs li.dots{width:1.5rem}:host([variant=outlined]) .cat-pagination-xs{gap:0.375rem}.cat-pagination-s li.dots,.cat-pagination-s li.text{height:2rem;line-height:2rem;font-size:0.9375rem}.cat-pagination-s li.dots{width:2rem}:host([variant=outlined]) .cat-pagination-s{gap:0.5rem}.cat-pagination-m li.dots,.cat-pagination-m li.text{height:2.5rem;line-height:2.5rem;font-size:0.9375rem}.cat-pagination-m li.dots{width:2.5rem}:host([variant=outlined]) .cat-pagination-m{gap:0.625rem}.cat-pagination-l li.dots,.cat-pagination-l li.text{height:3rem;line-height:3rem;font-size:0.9375rem}.cat-pagination-l li.dots{width:3rem}:host([variant=outlined]) .cat-pagination-l{gap:0.75rem}.cat-pagination-xl li.dots,.cat-pagination-xl li.text{height:3.5rem;line-height:3.5rem;font-size:1.125rem}.cat-pagination-xl li.dots{width:3.5rem}:host([variant=outlined]) .cat-pagination-xl{gap:0.875rem}";
2051
2068
 
2052
2069
  const CatPagination = class {
@@ -2153,7 +2170,7 @@ const CatRadio = class {
2153
2170
  this.catChange = createEvent(this, "catChange", 7);
2154
2171
  this.catFocus = createEvent(this, "catFocus", 7);
2155
2172
  this.catBlur = createEvent(this, "catBlur", 7);
2156
- this.id = `cat-radio-${++nextUniqueId$5}`;
2173
+ this._id = `cat-radio-${++nextUniqueId$5}`;
2157
2174
  this.hasSlottedLabel = false;
2158
2175
  /**
2159
2176
  * Whether this radio is checked.
@@ -2180,6 +2197,9 @@ const CatRadio = class {
2180
2197
  */
2181
2198
  this.labelLeft = false;
2182
2199
  }
2200
+ get id() {
2201
+ return this.identifier || this._id;
2202
+ }
2183
2203
  componentWillRender() {
2184
2204
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
2185
2205
  if (!this.label && !this.hasSlottedLabel) {
@@ -2210,7 +2230,7 @@ const CatRadio = class {
2210
2230
  this.input.click();
2211
2231
  }
2212
2232
  render() {
2213
- return (h(Host, null, 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' }, h("span", { class: "radio" }, 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) }), h("span", { class: "circle" })), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
2233
+ return (h(Host, null, 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' }, h("span", { class: "radio" }, h("input", { ref: el => (this.input = el), id: this.identifier || 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) }), h("span", { class: "circle" })), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
2214
2234
  }
2215
2235
  get hintSection() {
2216
2236
  const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
@@ -4182,7 +4202,7 @@ const CatSelect = class {
4182
4202
  this.catClose = createEvent(this, "catClose", 7);
4183
4203
  this.catChange = createEvent(this, "catChange", 7);
4184
4204
  this.catBlur = createEvent(this, "catBlur", 7);
4185
- this.id = `cat-input-${nextUniqueId$4++}`;
4205
+ this._id = `cat-input-${nextUniqueId$4++}`;
4186
4206
  this.term$ = new Subject();
4187
4207
  this.more$ = new Subject();
4188
4208
  this.state = INIT_STATE;
@@ -4207,10 +4227,6 @@ const CatSelect = class {
4207
4227
  * The label for the select.
4208
4228
  */
4209
4229
  this.label = '';
4210
- /**
4211
- * The name of the form control. Submitted with the form as part of a name/value pair.
4212
- */
4213
- this.name = '';
4214
4230
  /**
4215
4231
  * Visually hide the label, but still show it to assistive technologies like screen readers.
4216
4232
  */
@@ -4228,6 +4244,9 @@ const CatSelect = class {
4228
4244
  */
4229
4245
  this.tags = false;
4230
4246
  }
4247
+ get id() {
4248
+ return this.identifier || this._id;
4249
+ }
4231
4250
  onConnectorChange(connector) {
4232
4251
  this.reset(connector);
4233
4252
  this.resolve();
@@ -6293,7 +6312,7 @@ const CatTextarea = class {
6293
6312
  this.catChange = createEvent(this, "catChange", 7);
6294
6313
  this.catFocus = createEvent(this, "catFocus", 7);
6295
6314
  this.catBlur = createEvent(this, "catBlur", 7);
6296
- this.id = `cat-textarea-${nextUniqueId$2++}`;
6315
+ this._id = `cat-textarea-${nextUniqueId$2++}`;
6297
6316
  this.hasSlottedLabel = false;
6298
6317
  /**
6299
6318
  * Whether the textarea is disabled.
@@ -6307,10 +6326,6 @@ const CatTextarea = class {
6307
6326
  * Visually hide the label, but still show it to assistive technologies like screen readers.
6308
6327
  */
6309
6328
  this.labelHidden = false;
6310
- /**
6311
- * The name of the form control. Submitted with the form as part of a name/value pair.
6312
- */
6313
- this.name = '';
6314
6329
  /**
6315
6330
  * The value is not editable.
6316
6331
  */
@@ -6324,6 +6339,9 @@ const CatTextarea = class {
6324
6339
  */
6325
6340
  this.rows = 3;
6326
6341
  }
6342
+ get id() {
6343
+ return this.identifier || this._id;
6344
+ }
6327
6345
  componentWillRender() {
6328
6346
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
6329
6347
  if (!this.label && !this.hasSlottedLabel) {
@@ -6386,7 +6404,7 @@ const CatToggle = class {
6386
6404
  this.catChange = createEvent(this, "catChange", 7);
6387
6405
  this.catFocus = createEvent(this, "catFocus", 7);
6388
6406
  this.catBlur = createEvent(this, "catBlur", 7);
6389
- this.id = `cat-toggle-${nextUniqueId$1++}`;
6407
+ this._id = `cat-toggle-${nextUniqueId$1++}`;
6390
6408
  this.hasSlottedLabel = false;
6391
6409
  /**
6392
6410
  * Checked state of the toggle.
@@ -6413,6 +6431,9 @@ const CatToggle = class {
6413
6431
  */
6414
6432
  this.labelLeft = false;
6415
6433
  }
6434
+ get id() {
6435
+ return this.identifier || this._id;
6436
+ }
6416
6437
  componentWillRender() {
6417
6438
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
6418
6439
  if (!this.label && !this.hasSlottedLabel) {
@@ -6613,6 +6634,6 @@ const CatTooltip = class {
6613
6634
  CatTooltip.OFFSET = 4;
6614
6635
  CatTooltip.style = catTooltipCss;
6615
6636
 
6616
- export { CatAlert as cat_alert, CatAvatar as cat_avatar, CatBadge as cat_badge, CatButton as cat_button, CatCard as cat_card, CatCheckbox as cat_checkbox, CatDropdown as cat_dropdown, CatIcon as cat_icon, CatInput as cat_input, CatPagination as cat_pagination, CatRadio as cat_radio, CatRadioGroup as cat_radio_group, CatScrollable as cat_scrollable, CatSelect as cat_select, CatSelectTest as cat_select_demo, CatSkeleton as cat_skeleton, CatSpinner as cat_spinner, CatTab as cat_tab, CatTabs as cat_tabs, CatTextarea as cat_textarea, CatToggle as cat_toggle, CatTooltip as cat_tooltip };
6637
+ export { CatAlert as cat_alert, CatAvatar as cat_avatar, CatBadge as cat_badge, CatButton as cat_button, CatCard as cat_card, CatCheckbox as cat_checkbox, CatDropdown as cat_dropdown, CatIcon as cat_icon, CatInput as cat_input, CatLabel as cat_label, CatPagination as cat_pagination, CatRadio as cat_radio, CatRadioGroup as cat_radio_group, CatScrollable as cat_scrollable, CatSelect as cat_select, CatSelectTest as cat_select_demo, CatSkeleton as cat_skeleton, CatSpinner as cat_spinner, CatTab as cat_tab, CatTabs as cat_tabs, CatTextarea as cat_textarea, CatToggle as cat_toggle, CatTooltip as cat_tooltip };
6617
6638
 
6618
- //# sourceMappingURL=cat-alert_22.entry.js.map
6639
+ //# sourceMappingURL=cat-alert_23.entry.js.map