@haiilo/catalyst 3.0.2 → 4.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 (80) 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-8d6a31b9.entry.js +10 -0
  4. package/dist/catalyst/p-8d6a31b9.entry.js.map +1 -0
  5. package/dist/catalyst/p-919eea27.js +3 -0
  6. package/dist/catalyst/p-919eea27.js.map +1 -0
  7. package/dist/catalyst/p-ccfebe33.js.map +1 -1
  8. package/dist/cjs/cat-alert_24.cjs.entry.js +129 -28
  9. package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
  10. package/dist/cjs/cat-icon-registry-671af264.js.map +1 -1
  11. package/dist/cjs/catalyst.cjs.js +2 -2
  12. package/dist/cjs/{index-22e41d18.js → index-c4542095.js} +65 -4
  13. package/dist/cjs/index-c4542095.js.map +1 -0
  14. package/dist/cjs/loader.cjs.js +2 -2
  15. package/dist/collection/components/cat-button/cat-button.js +17 -2
  16. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  17. package/dist/collection/components/cat-checkbox/cat-checkbox.js +16 -1
  18. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  19. package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js +13 -0
  20. package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js.map +1 -0
  21. package/dist/collection/components/cat-form-hint/cat-form-hint.js +2 -1
  22. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -1
  23. package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
  24. package/dist/collection/components/cat-input/cat-input.css +244 -8
  25. package/dist/collection/components/cat-input/cat-input.js +101 -13
  26. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  27. package/dist/collection/components/cat-radio/cat-radio.js +16 -1
  28. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  29. package/dist/collection/components/cat-select/cat-select.css +252 -0
  30. package/dist/collection/components/cat-select/cat-select.js +95 -9
  31. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  32. package/dist/collection/components/cat-textarea/cat-textarea.css +261 -1
  33. package/dist/collection/components/cat-textarea/cat-textarea.js +102 -10
  34. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  35. package/dist/collection/components/cat-toggle/cat-toggle.js +16 -1
  36. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  37. package/dist/components/cat-button2.js +3 -2
  38. package/dist/components/cat-button2.js.map +1 -1
  39. package/dist/components/cat-checkbox2.js +2 -1
  40. package/dist/components/cat-checkbox2.js.map +1 -1
  41. package/dist/components/cat-form-hint-utils.js +17 -0
  42. package/dist/components/cat-form-hint-utils.js.map +1 -0
  43. package/dist/components/cat-form-hint.js +2 -1
  44. package/dist/components/cat-form-hint.js.map +1 -1
  45. package/dist/components/cat-i18n-registry.js.map +1 -1
  46. package/dist/components/cat-input.js +43 -9
  47. package/dist/components/cat-input.js.map +1 -1
  48. package/dist/components/cat-radio.js +2 -1
  49. package/dist/components/cat-radio.js.map +1 -1
  50. package/dist/components/cat-select2.js +40 -9
  51. package/dist/components/cat-select2.js.map +1 -1
  52. package/dist/components/cat-textarea.js +50 -7
  53. package/dist/components/cat-textarea.js.map +1 -1
  54. package/dist/components/cat-toggle.js +2 -1
  55. package/dist/components/cat-toggle.js.map +1 -1
  56. package/dist/esm/cat-alert_24.entry.js +129 -28
  57. package/dist/esm/cat-alert_24.entry.js.map +1 -1
  58. package/dist/esm/cat-icon-registry-d6b80490.js.map +1 -1
  59. package/dist/esm/catalyst.js +2 -2
  60. package/dist/esm/{index-7b85fb91.js → index-524906f7.js} +65 -4
  61. package/dist/esm/index-524906f7.js.map +1 -0
  62. package/dist/esm/loader.js +2 -2
  63. package/dist/types/components/cat-button/cat-button.d.ts +6 -0
  64. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +6 -0
  65. package/dist/types/components/cat-form-hint/cat-form-hint-utils.d.ts +4 -0
  66. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +1 -0
  67. package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +1 -1
  68. package/dist/types/components/cat-input/cat-input.d.ts +27 -1
  69. package/dist/types/components/cat-radio/cat-radio.d.ts +6 -0
  70. package/dist/types/components/cat-select/cat-select.d.ts +28 -2
  71. package/dist/types/components/cat-textarea/cat-textarea.d.ts +27 -1
  72. package/dist/types/components/cat-toggle/cat-toggle.d.ts +6 -0
  73. package/dist/types/components.d.ts +105 -0
  74. package/package.json +3 -2
  75. package/dist/catalyst/p-1c6eace6.js +0 -3
  76. package/dist/catalyst/p-1c6eace6.js.map +0 -1
  77. package/dist/catalyst/p-6865acc8.entry.js +0 -10
  78. package/dist/catalyst/p-6865acc8.entry.js.map +0 -1
  79. package/dist/cjs/index-22e41d18.js.map +0 -1
  80. package/dist/esm/index-7b85fb91.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { Component, Element, Event, h, Host, Method, Prop, State } from '@stencil/core';
1
+ import { Component, Element, Event, h, Host, Method, Prop, State, Watch } from '@stencil/core';
2
2
  import log from 'loglevel';
3
- import { CatFormHint } from '../cat-form-hint/cat-form-hint';
3
+ import { buildHintSection } from '../cat-form-hint/cat-form-hint-utils';
4
4
  import { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';
5
5
  let nextUniqueId = 0;
6
6
  /**
@@ -58,11 +58,18 @@ export class CatInput {
58
58
  * Type of form control.
59
59
  */
60
60
  this.type = 'text';
61
+ /**
62
+ * Fine-grained control over when the errors are shown. Can be `false` to
63
+ * never show errors, `true` to show errors on blur, or a number to show
64
+ * errors on change with the given delay in milliseconds.
65
+ */
66
+ this.errorUpdate = 0;
61
67
  }
62
68
  get id() {
63
69
  return this.identifier || this._id;
64
70
  }
65
71
  componentWillRender() {
72
+ this.watchErrorsHandler(this.errors);
66
73
  this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
67
74
  if (!this.label && !this.hasSlottedLabel) {
68
75
  log.warn('[A11y] Missing ARIA label on input', this);
@@ -97,48 +104,69 @@ export class CatInput {
97
104
  async clear() {
98
105
  this.value = '';
99
106
  }
107
+ watchErrorsHandler(value) {
108
+ if (this.errorUpdate === false) {
109
+ this.errorMap = undefined;
110
+ }
111
+ else {
112
+ this.errorMapSrc = Array.isArray(value)
113
+ ? value.map(error => ({ [error]: undefined }))
114
+ : value === true
115
+ ? {}
116
+ : value || undefined;
117
+ }
118
+ }
100
119
  render() {
120
+ var _a;
101
121
  return (h(Host, null,
102
122
  (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
103
123
  h("span", { part: "label" },
104
124
  (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label,
105
- !this.required && this.requiredMarker.startsWith('optional') && (h("span", { class: "input-optional", "aria-hidden": "true" },
125
+ !this.required && this.requiredMarker.startsWith('optional') && (h("span", { class: "label-optional", "aria-hidden": "true" },
106
126
  "(",
107
127
  i18n.t('input.optional'),
108
128
  ")")),
109
- this.required && this.requiredMarker.startsWith('required') && (h("span", { class: "input-optional", "aria-hidden": "true" },
129
+ this.required && this.requiredMarker.startsWith('required') && (h("span", { class: "label-optional", "aria-hidden": "true" },
110
130
  "(",
111
131
  i18n.t('input.required'),
112
132
  ")"))))),
113
133
  h("div", { class: {
114
134
  'input-wrapper': true,
115
135
  'input-round': this.round,
116
- 'input-disabled': this.disabled
136
+ 'input-disabled': this.disabled,
137
+ 'input-invalid': this.invalid
117
138
  }, onClick: () => this.input.focus() },
118
139
  this.textPrefix && (h("span", { class: "text-prefix", part: "prefix" }, this.textPrefix)),
119
140
  this.icon && !this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-prefix", size: "l" }),
120
141
  h("div", { class: "input-inner-wrapper" },
121
- h("input", { ref: el => (this.input = el), id: this.id, class: {
142
+ h("input", Object.assign({}, this.nativeAttributes, { ref: el => (this.input = el), id: this.id, class: {
122
143
  'has-clearable': this.clearable && !this.disabled
123
- }, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
144
+ }, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": ((_a = this.hint) === null || _a === void 0 ? void 0 : _a.length) ? this.id + '-hint' : undefined })),
124
145
  this.clearable && !this.disabled && this.value && (h("cat-button", { class: "clearable", icon: "cross-circle-outlined", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this) }))),
125
- this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }),
146
+ !this.invalid && this.icon && this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" })),
147
+ this.invalid && (h("cat-icon", { icon: "alert-circle-outlined", class: "icon-suffix cat-text-danger", size: "l" })),
126
148
  this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))),
127
- this.hintSection));
149
+ buildHintSection(this.hostElement, this.id, this.hint, this.errorMap)));
128
150
  }
129
- get hintSection() {
130
- const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
131
- return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
151
+ get invalid() {
152
+ return !!this.errorMap;
132
153
  }
133
154
  onInput(event) {
134
155
  this.value = this.input.value;
135
156
  this.catChange.emit(event);
157
+ if (typeof this.errorUpdate === 'number') {
158
+ typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);
159
+ this.errorUpdateTimeoutId = window.setTimeout(() => (this.errorMap = this.errorMapSrc), this.errorUpdate);
160
+ }
136
161
  }
137
162
  onFocus(event) {
138
163
  this.catFocus.emit(event);
139
164
  }
140
165
  onBlur(event) {
141
166
  this.catBlur.emit(event);
167
+ if (this.errorUpdate !== false) {
168
+ this.errorMap = this.errorMapSrc;
169
+ }
142
170
  }
143
171
  static get is() { return "cat-input"; }
144
172
  static get encapsulation() { return "shadow"; }
@@ -554,10 +582,66 @@ export class CatInput {
554
582
  },
555
583
  "attribute": "value",
556
584
  "reflect": false
585
+ },
586
+ "errors": {
587
+ "type": "boolean",
588
+ "mutable": false,
589
+ "complexType": {
590
+ "original": "boolean | string[] | ErrorMap",
591
+ "resolved": "boolean | string[] | undefined | { [key: string]: any; }",
592
+ "references": {
593
+ "ErrorMap": {
594
+ "location": "import",
595
+ "path": "../cat-form-hint/cat-form-hint-utils"
596
+ }
597
+ }
598
+ },
599
+ "required": false,
600
+ "optional": true,
601
+ "docs": {
602
+ "tags": [],
603
+ "text": "The validation errors for this input. Will render a hint under the input\nwith the translated error message(s) `error.${key}`. If an object is\npassed, the keys will be used as error keys and the values translation\nparameters.\nIf the value is `true`, the input will be marked as invalid without any\nhints under the input."
604
+ },
605
+ "attribute": "errors",
606
+ "reflect": false
607
+ },
608
+ "errorUpdate": {
609
+ "type": "any",
610
+ "mutable": false,
611
+ "complexType": {
612
+ "original": "boolean | number",
613
+ "resolved": "boolean | number",
614
+ "references": {}
615
+ },
616
+ "required": false,
617
+ "optional": false,
618
+ "docs": {
619
+ "tags": [],
620
+ "text": "Fine-grained control over when the errors are shown. Can be `false` to\nnever show errors, `true` to show errors on blur, or a number to show\nerrors on change with the given delay in milliseconds."
621
+ },
622
+ "attribute": "error-update",
623
+ "reflect": false,
624
+ "defaultValue": "0"
625
+ },
626
+ "nativeAttributes": {
627
+ "type": "unknown",
628
+ "mutable": false,
629
+ "complexType": {
630
+ "original": "{ [key: string]: string }",
631
+ "resolved": "undefined | { [key: string]: string; }",
632
+ "references": {}
633
+ },
634
+ "required": false,
635
+ "optional": true,
636
+ "docs": {
637
+ "tags": [],
638
+ "text": "Attributes that will be added to the native HTML input element."
639
+ }
557
640
  }
558
641
  }; }
559
642
  static get states() { return {
560
- "hasSlottedLabel": {}
643
+ "hasSlottedLabel": {},
644
+ "errorMap": {}
561
645
  }; }
562
646
  static get events() { return [{
563
647
  "method": "catChange",
@@ -692,5 +776,9 @@ export class CatInput {
692
776
  }
693
777
  }; }
694
778
  static get elementRef() { return "hostElement"; }
779
+ static get watchers() { return [{
780
+ "propName": "errors",
781
+ "methodName": "watchErrorsHandler"
782
+ }]; }
695
783
  }
696
784
  //# sourceMappingURL=cat-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGxE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,QAAQ;EALrB;IAMmB,QAAG,GAAG,aAAa,YAAY,EAAE,EAAE,CAAC;IAS5C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,mBAAc,GAA2E,UAAU,CAAC;IAO5G;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAYzB;;OAEG;IAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\n\nlet nextUniqueId = 0;\n\n/**\n * Inputs are used to allow users to provide text input when the expected input\n * is short. As well as plain text, Input supports various types of text,\n * including passwords and numbers.\n *\n * @slot hint - Optional hint element to be displayed with the input.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n * @part prefix - The text prefix.\n * @part suffix - The text suffix.\n */\n@Component({\n tag: 'cat-input',\n styleUrl: 'cat-input.scss',\n shadow: true\n})\nexport class CatInput {\n private readonly _id = `cat-input-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for date, time and numeric values.\n */\n @Prop() max?: number | string;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for date, time and numeric values.\n */\n @Prop() min?: number | string;\n\n /**\n * A minimum length (number of characters) for textual values.\n */\n @Prop() minLength?: number;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Use round input edges.\n */\n @Prop() round = false;\n\n /**\n * Type of form control.\n */\n @Prop() type: InputType = 'text';\n\n /**\n * The value of the control.\n */\n @Prop({ mutable: true }) value?: string | number;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Programmatically simulate a click on the input.\n */\n @Method()\n async doClick(): Promise<void> {\n this.input.click();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && this.requiredMarker.startsWith('optional') && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker.startsWith('required') && (\n <span class=\"input-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n </span>\n </label>\n )}\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-disabled': this.disabled\n }}\n onClick={() => this.input.focus()}\n >\n {this.textPrefix && (\n <span class=\"text-prefix\" part=\"prefix\">\n {this.textPrefix}\n </span>\n )}\n {this.icon && !this.iconRight && <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\"></cat-icon>}\n <div class=\"input-inner-wrapper\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n max={this.max}\n maxlength={this.maxLength}\n min={this.min}\n minlength={this.minLength}\n name={this.name}\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n type={this.type}\n value={this.value}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n ></input>\n {this.clearable && !this.disabled && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"cross-circle-outlined\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {this.icon && this.iconRight && <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>}\n {this.textSuffix && (\n <span class=\"text-suffix\" part=\"suffix\">\n {this.textSuffix}\n </span>\n )}\n </div>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
1
+ {"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAY,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGxE,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,QAAQ;EALrB;IAMmB,QAAG,GAAG,aAAa,YAAY,EAAE,EAAE,CAAC;IAU5C,oBAAe,GAAG,KAAK,CAAC;IAIjC;;OAEG;IACK,mBAAc,GAA2E,UAAU,CAAC;IAO5G;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAYzB;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;IAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport log from 'loglevel';\nimport { buildHintSection, ErrorMap } from '../cat-form-hint/cat-form-hint-utils';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\n\nlet nextUniqueId = 0;\n\n/**\n * Inputs are used to allow users to provide text input when the expected input\n * is short. As well as plain text, Input supports various types of text,\n * including passwords and numbers.\n *\n * @slot hint - Optional hint element to be displayed with the input.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n * @part prefix - The text prefix.\n * @part suffix - The text suffix.\n */\n@Component({\n tag: 'cat-input',\n styleUrl: 'cat-input.scss',\n shadow: true\n})\nexport class CatInput {\n private readonly _id = `cat-input-${nextUniqueId++}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n private errorMapSrc?: ErrorMap;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() errorMap?: ErrorMap;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for date, time and numeric values.\n */\n @Prop() max?: number | string;\n\n /**\n * A maximum length (number of characters) for textual values.\n */\n @Prop() maxLength?: number;\n\n /**\n * A minimum value for date, time and numeric values.\n */\n @Prop() min?: number | string;\n\n /**\n * A minimum length (number of characters) for textual values.\n */\n @Prop() minLength?: number;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * Use round input edges.\n */\n @Prop() round = false;\n\n /**\n * Type of form control.\n */\n @Prop() type: InputType = 'text';\n\n /**\n * The value of the control.\n */\n @Prop({ mutable: true }) value?: string | number;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.watchErrorsHandler(this.errors);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on input', this);\n }\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Programmatically simulate a click on the input.\n */\n @Method()\n async doClick(): Promise<void> {\n this.input.click();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n }\n\n @Watch('errors')\n watchErrorsHandler(value?: boolean | string[] | ErrorMap) {\n if (this.errorUpdate === false) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(value)\n ? value.map(error => ({ [error]: undefined }))\n : value === true\n ? {}\n : value || undefined;\n }\n }\n\n render() {\n return (\n <Host>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} class={{ hidden: this.labelHidden }}>\n <span part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n {!this.required && this.requiredMarker.startsWith('optional') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.optional')})\n </span>\n )}\n {this.required && this.requiredMarker.startsWith('required') && (\n <span class=\"label-optional\" aria-hidden=\"true\">\n ({i18n.t('input.required')})\n </span>\n )}\n </span>\n </label>\n )}\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-disabled': this.disabled,\n 'input-invalid': this.invalid\n }}\n onClick={() => this.input.focus()}\n >\n {this.textPrefix && (\n <span class=\"text-prefix\" part=\"prefix\">\n {this.textPrefix}\n </span>\n )}\n {this.icon && !this.iconRight && <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\"></cat-icon>}\n <div class=\"input-inner-wrapper\">\n <input\n {...this.nativeAttributes}\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n max={this.max}\n maxlength={this.maxLength}\n min={this.min}\n minlength={this.minLength}\n name={this.name}\n placeholder={this.placeholder}\n readonly={this.readonly}\n required={this.required}\n type={this.type}\n value={this.value}\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n aria-invalid={this.invalid ? 'true' : undefined}\n aria-describedby={this.hint?.length ? this.id + '-hint' : undefined}\n ></input>\n {this.clearable && !this.disabled && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"cross-circle-outlined\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n ></cat-button>\n )}\n </div>\n {!this.invalid && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>\n )}\n {this.invalid && (\n <cat-icon icon=\"alert-circle-outlined\" class=\"icon-suffix cat-text-danger\" size=\"l\"></cat-icon>\n )}\n {this.textSuffix && (\n <span class=\"text-suffix\" part=\"suffix\">\n {this.textSuffix}\n </span>\n )}\n </div>\n {buildHintSection(this.hostElement, this.id, this.hint, this.errorMap)}\n </Host>\n );\n }\n\n private get invalid() {\n return !!this.errorMap;\n }\n\n private errorUpdateTimeoutId?: number;\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\n if (typeof this.errorUpdate === 'number') {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => (this.errorMap = this.errorMapSrc), this.errorUpdate);\n }\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n if (this.errorUpdate !== false) {\n this.errorMap = this.errorMapSrc;\n }\n }\n}\n"]}
@@ -75,7 +75,7 @@ export class CatRadio {
75
75
  return (h(Host, null,
76
76
  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' },
77
77
  h("span", { class: "radio" },
78
- 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) }),
78
+ h("input", Object.assign({}, this.nativeAttributes, { 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) })),
79
79
  h("span", { class: "circle" })),
80
80
  h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
81
81
  this.hintSection));
@@ -278,6 +278,21 @@ export class CatRadio {
278
278
  "attribute": "label-left",
279
279
  "reflect": false,
280
280
  "defaultValue": "false"
281
+ },
282
+ "nativeAttributes": {
283
+ "type": "unknown",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "{ [key: string]: string }",
287
+ "resolved": "undefined | { [key: string]: string; }",
288
+ "references": {}
289
+ },
290
+ "required": false,
291
+ "optional": true,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": "Attributes that will be added to the native HTML input element."
295
+ }
281
296
  }
282
297
  }; }
283
298
  static get states() { return {
@@ -1 +1 @@
1
- {"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;GAOG;AAMH,MAAM,OAAO,QAAQ;EALrB;IAMmB,QAAG,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC;IAS5C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACsB,YAAO,GAAG,KAAK,CAAC;IAEzC;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAOzB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAO5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAYzB;;OAEG;IACK,cAAS,GAAG,KAAK,CAAC;GA4G3B;EAtKC,IAAY,EAAE;IACZ,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC;EACrC,CAAC;EAyED,mBAAmB;IACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;MACxC,GAAG,CAAC,IAAI,CAAC,oCAAoC,EAAE,IAAI,CAAC,CAAC;KACtD;EACH,CAAC;EAED;;;;;;KAMG;EAEH,KAAK,CAAC,OAAO,CAAC,OAAsB;IAClC,IAAI,CAA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["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Radio Buttons are graphical interface elements that allow user to choose\n * only one of a predefined set of mutually exclusive options.\n *\n * @slot hint - Optional hint element to be displayed with the radio.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-radio',\n styleUrl: 'cat-radio.scss',\n shadow: true\n})\nexport class CatRadio {\n private readonly _id = `cat-radio-${++nextUniqueId}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label of the radio that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the radio component.\n */\n @Prop() name?: string;\n\n /**\n * Whether the radio is required.\n */\n @Prop() required = false;\n\n /**\n * The value of the radio component.\n */\n @Prop() value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Whether the label should appear to the left of the radio component.\n */\n @Prop() labelLeft = false;\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the radio received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the radio loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Programmatically move focus to the radio button. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the radio button. Use this method\n * instead of `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Programmatically simulate a click on the radio button.\n */\n @Method()\n async doClick(): Promise<void> {\n this.input.click();\n }\n\n render() {\n return (\n <Host>\n <label\n htmlFor={this.id}\n class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n >\n <span class=\"radio\">\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.identifier || this.id}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onChange.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"circle\"></span>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange(event: Event) {\n this.checked = true;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
1
+ {"version":3,"file":"cat-radio.js","sourceRoot":"","sources":["../../../src/components/cat-radio/cat-radio.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,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CAAC,WAAW,CACZ,CACR,CAAC;EACJ,CAAC;EAED,IAAY,WAAW;IACrB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzE,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAC/B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,CACF,CAAC;EACJ,CAAC;EAEO,QAAQ,CAAC,KAAY;IAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC7B,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Radio Buttons are graphical interface elements that allow user to choose\n * only one of a predefined set of mutually exclusive options.\n *\n * @slot hint - Optional hint element to be displayed with the radio.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-radio',\n styleUrl: 'cat-radio.scss',\n shadow: true\n})\nexport class CatRadio {\n private readonly _id = `cat-radio-${++nextUniqueId}`;\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Whether this radio is checked.\n */\n @Prop({ mutable: true }) checked = false;\n\n /**\n * Whether this radio is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label of the radio that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the radio component.\n */\n @Prop() name?: string;\n\n /**\n * Whether the radio is required.\n */\n @Prop() required = false;\n\n /**\n * The value of the radio component.\n */\n @Prop() value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the radio.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Whether the label should appear to the left of the radio component.\n */\n @Prop() labelLeft = false;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * Emitted when the radio is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the radio received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the radio loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.warn('[A11y] Missing ARIA label on radio', this);\n }\n }\n\n /**\n * Programmatically move focus to the radio button. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n /**\n * Programmatically remove focus from the radio button. Use this method\n * instead of `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input.blur();\n }\n\n /**\n * Programmatically simulate a click on the radio button.\n */\n @Method()\n async doClick(): Promise<void> {\n this.input.click();\n }\n\n render() {\n return (\n <Host>\n <label\n htmlFor={this.id}\n class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled, 'label-left': this.labelLeft }}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n >\n <span class=\"radio\">\n <input\n {...this.nativeAttributes}\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.identifier || this.id}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n onInput={this.onChange.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"circle\"></span>\n </span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onChange(event: Event) {\n this.checked = true;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
@@ -17,6 +17,240 @@
17
17
  margin: 0 !important;
18
18
  }
19
19
 
20
+ .cat-bg-primary {
21
+ background-color: rgb(var(--cat-primary-bg, 0, 129, 148)) !important;
22
+ color: rgb(var(--cat-primary-fill, 255, 255, 255)) !important;
23
+ }
24
+
25
+ .cat-bg-primary-hover {
26
+ transition: background-color 0.13s, color 0.13s;
27
+ }
28
+ .cat-bg-primary-hover:hover {
29
+ background-color: rgb(var(--cat-primary-bg-hover, 1, 115, 132)) !important;
30
+ color: rgb(var(--cat-primary-fill-hover, 255, 255, 255)) !important;
31
+ }
32
+
33
+ .cat-text-primary,
34
+ .cat-link-primary {
35
+ color: rgb(var(--cat-primary-text, 0, 129, 148)) !important;
36
+ }
37
+
38
+ .cat-link-primary,
39
+ .cat-text-primary-hover {
40
+ transition: color 0.13s;
41
+ }
42
+ .cat-link-primary:hover,
43
+ .cat-text-primary-hover:hover {
44
+ color: rgb(var(--cat-primary-text-hover, 1, 115, 132)) !important;
45
+ }
46
+ .cat-link-primary:active,
47
+ .cat-text-primary-hover:active {
48
+ color: rgb(var(--cat-primary-text-active, 2, 99, 113)) !important;
49
+ }
50
+
51
+ .cat-bg-primaryInverted {
52
+ background-color: #93b4f2 !important;
53
+ color: black !important;
54
+ }
55
+
56
+ .cat-bg-primaryInverted-hover {
57
+ transition: background-color 0.13s, color 0.13s;
58
+ }
59
+ .cat-bg-primaryInverted-hover:hover {
60
+ background-color: #93b4f2 !important;
61
+ color: black !important;
62
+ }
63
+
64
+ .cat-text-primaryInverted,
65
+ .cat-link-primaryInverted {
66
+ color: #93b4f2 !important;
67
+ }
68
+
69
+ .cat-link-primaryInverted,
70
+ .cat-text-primaryInverted-hover {
71
+ transition: color 0.13s;
72
+ }
73
+ .cat-link-primaryInverted:hover,
74
+ .cat-text-primaryInverted-hover:hover {
75
+ color: #93b4f2 !important;
76
+ }
77
+ .cat-link-primaryInverted:active,
78
+ .cat-text-primaryInverted-hover:active {
79
+ color: #93b4f2 !important;
80
+ }
81
+
82
+ .cat-bg-secondary {
83
+ background-color: rgb(var(--cat-secondary-bg, 105, 118, 135)) !important;
84
+ color: rgb(var(--cat-secondary-fill, 255, 255, 255)) !important;
85
+ }
86
+
87
+ .cat-bg-secondary-hover {
88
+ transition: background-color 0.13s, color 0.13s;
89
+ }
90
+ .cat-bg-secondary-hover:hover {
91
+ background-color: rgb(var(--cat-secondary-bg-hover, 105, 118, 135)) !important;
92
+ color: rgb(var(--cat-secondary-fill-hover, 255, 255, 255)) !important;
93
+ }
94
+
95
+ .cat-text-secondary,
96
+ .cat-link-secondary {
97
+ color: rgb(var(--cat-secondary-text, 0, 0, 0)) !important;
98
+ }
99
+
100
+ .cat-link-secondary,
101
+ .cat-text-secondary-hover {
102
+ transition: color 0.13s;
103
+ }
104
+ .cat-link-secondary:hover,
105
+ .cat-text-secondary-hover:hover {
106
+ color: rgb(var(--cat-secondary-text-hover, 0, 0, 0)) !important;
107
+ }
108
+ .cat-link-secondary:active,
109
+ .cat-text-secondary-hover:active {
110
+ color: rgb(var(--cat-secondary-text-active, 0, 0, 0)) !important;
111
+ }
112
+
113
+ .cat-bg-secondaryInverted {
114
+ background-color: #697687 !important;
115
+ color: black !important;
116
+ }
117
+
118
+ .cat-bg-secondaryInverted-hover {
119
+ transition: background-color 0.13s, color 0.13s;
120
+ }
121
+ .cat-bg-secondaryInverted-hover:hover {
122
+ background-color: #697687 !important;
123
+ color: black !important;
124
+ }
125
+
126
+ .cat-text-secondaryInverted,
127
+ .cat-link-secondaryInverted {
128
+ color: white !important;
129
+ }
130
+
131
+ .cat-link-secondaryInverted,
132
+ .cat-text-secondaryInverted-hover {
133
+ transition: color 0.13s;
134
+ }
135
+ .cat-link-secondaryInverted:hover,
136
+ .cat-text-secondaryInverted-hover:hover {
137
+ color: white !important;
138
+ }
139
+ .cat-link-secondaryInverted:active,
140
+ .cat-text-secondaryInverted-hover:active {
141
+ color: white !important;
142
+ }
143
+
144
+ .cat-bg-success {
145
+ background-color: rgb(var(--cat-success-bg-, 0, 132, 88)) !important;
146
+ color: rgb(var(--cat-success-fill, 255, 255, 255)) !important;
147
+ }
148
+
149
+ .cat-bg-success-hover {
150
+ transition: background-color 0.13s, color 0.13s;
151
+ }
152
+ .cat-bg-success-hover:hover {
153
+ background-color: rgb(var(--cat-success-bg-hover, 0, 117, 78)) !important;
154
+ color: rgb(var(--cat-success-fill-hover, 255, 255, 255)) !important;
155
+ }
156
+
157
+ .cat-text-success,
158
+ .cat-link-success {
159
+ color: rgb(var(--cat-success-text, 0, 132, 88)) !important;
160
+ }
161
+
162
+ .cat-link-success,
163
+ .cat-text-success-hover {
164
+ transition: color 0.13s;
165
+ }
166
+ .cat-link-success:hover,
167
+ .cat-text-success-hover:hover {
168
+ color: rgb(var(--cat-success-text-hover, 0, 117, 78)) !important;
169
+ }
170
+ .cat-link-success:active,
171
+ .cat-text-success-hover:active {
172
+ color: rgb(var(--cat-success-text-active, 0, 105, 70)) !important;
173
+ }
174
+
175
+ .cat-bg-warning {
176
+ background-color: rgb(var(--cat-warning-bg, 255, 206, 128)) !important;
177
+ color: rgb(var(--cat-warning-fill, 0, 0, 0)) !important;
178
+ }
179
+
180
+ .cat-bg-warning-hover {
181
+ transition: background-color 0.13s, color 0.13s;
182
+ }
183
+ .cat-bg-warning-hover:hover {
184
+ background-color: rgb(var(--cat-warning-bg-hover, 255, 214, 148)) !important;
185
+ color: rgb(var(--cat-warning-fill-hover, 0, 0, 0)) !important;
186
+ }
187
+
188
+ .cat-text-warning,
189
+ .cat-link-warning {
190
+ color: rgb(var(--cat-warning-text, 159, 97, 0)) !important;
191
+ }
192
+
193
+ .cat-link-warning,
194
+ .cat-text-warning-hover {
195
+ transition: color 0.13s;
196
+ }
197
+ .cat-link-warning:hover,
198
+ .cat-text-warning-hover:hover {
199
+ color: rgb(var(--cat-warning-text-hover, 159, 97, 0)) !important;
200
+ }
201
+ .cat-link-warning:active,
202
+ .cat-text-warning-hover:active {
203
+ color: rgb(var(--cat-warning-text-active, 159, 97, 0)) !important;
204
+ }
205
+
206
+ .cat-bg-danger {
207
+ background-color: rgb(var(--cat-danger-bg, 217, 52, 13)) !important;
208
+ color: rgb(var(--cat-danger-fill, 255, 255, 255)) !important;
209
+ }
210
+
211
+ .cat-bg-danger-hover {
212
+ transition: background-color 0.13s, color 0.13s;
213
+ }
214
+ .cat-bg-danger-hover:hover {
215
+ background-color: rgb(var(--cat-danger-bg-hover, 194, 46, 11)) !important;
216
+ color: rgb(var(--cat-danger-fill-hover, 255, 255, 255)) !important;
217
+ }
218
+
219
+ .cat-text-danger,
220
+ .cat-link-danger {
221
+ color: rgb(var(--cat-danger-text, 217, 52, 13)) !important;
222
+ }
223
+
224
+ .cat-link-danger,
225
+ .cat-text-danger-hover {
226
+ transition: color 0.13s;
227
+ }
228
+ .cat-link-danger:hover,
229
+ .cat-text-danger-hover:hover {
230
+ color: rgb(var(--cat-danger-text-hover, 194, 46, 11)) !important;
231
+ }
232
+ .cat-link-danger:active,
233
+ .cat-text-danger-hover:active {
234
+ color: rgb(var(--cat-danger-text-active, 174, 42, 10)) !important;
235
+ }
236
+
237
+ .cat-active {
238
+ color: rgb(var(--cat-primary-text, 0, 129, 148)) !important;
239
+ }
240
+
241
+ .cat-muted {
242
+ color: rgb(var(--cat-font-color-muted, 105, 118, 135)) !important;
243
+ }
244
+
245
+ .cat-text-reset {
246
+ color: inherit !important;
247
+ }
248
+
249
+ .cat-link-reset {
250
+ color: inherit !important;
251
+ text-decoration: inherit !important;
252
+ }
253
+
20
254
  :host {
21
255
  display: flex;
22
256
  flex-direction: column;
@@ -61,13 +295,27 @@ label.hidden {
61
295
  box-shadow: 0 0 0 1px rgb(var(--cat-border-color-dark, 215, 219, 224));
62
296
  transition: box-shadow 0.13s linear;
63
297
  padding: 0.25rem;
298
+ /* stylelint-disable property-no-vendor-prefix */
299
+ /* stylelint-enable property-no-vendor-prefix */
64
300
  }
65
301
  .select-wrapper:not(.select-disabled):hover {
66
302
  box-shadow: 0 0 0 2px rgb(var(--cat-border-color-dark, 215, 219, 224));
67
303
  }
304
+ .select-wrapper:not(.select-disabled):hover.select-invalid {
305
+ box-shadow: 0 0 0 2px rgba(var(--cat-danger-bg, 217, 52, 13), 0.2);
306
+ }
68
307
  .select-wrapper:not(.select-disabled):focus-within {
69
308
  outline: 2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));
70
309
  }
310
+ .select-wrapper:not(.select-disabled):focus-within.select-invalid {
311
+ outline: 2px solid rgba(var(--cat-danger-bg, 217, 52, 13), 0.2);
312
+ }
313
+ .select-wrapper.select-invalid {
314
+ box-shadow: 0 0 0 1px rgba(var(--cat-danger-bg, 217, 52, 13), 0.2);
315
+ }
316
+ .select-wrapper:has(input:-webkit-autofill), .select-wrapper:has(input:-webkit-autofill):hover, .select-wrapper:has(input:-webkit-autofill):focus {
317
+ background-color: #e8f0fe;
318
+ }
71
319
 
72
320
  :host(.cat-error) .select-wrapper {
73
321
  box-shadow: 0 0 0 1px rgb(var(--cat-danger-bg, 217, 52, 13));
@@ -150,6 +398,10 @@ cat-spinner {
150
398
  padding: 0.375rem;
151
399
  }
152
400
 
401
+ .icon-suffix {
402
+ padding: 0.25rem;
403
+ }
404
+
153
405
  .select-btn-open {
154
406
  transform: rotate(180deg);
155
407
  }