@haiilo/catalyst 13.2.0 → 13.3.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.
@@ -118,6 +118,9 @@ export class CatInput {
118
118
  async clear() {
119
119
  this.value = '';
120
120
  this.catChange.emit(this.value);
121
+ if (this.type === 'file') {
122
+ this.catChangeFiles.emit(null);
123
+ }
121
124
  }
122
125
  onErrorsChanged(newValue, _oldValue, update = true) {
123
126
  if (!coerceBoolean(this.errorUpdate)) {
@@ -134,24 +137,24 @@ export class CatInput {
134
137
  }
135
138
  render() {
136
139
  this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
137
- return (h("div", { key: '50c440a0998694c006b5a6cad4125bc395a159f1', class: {
140
+ return (h("div", { key: 'ffc4412a1f7c10431da8c4b6380fd8218298ac5a', class: {
138
141
  'input-field': true,
139
142
  'input-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false
140
- } }, h("div", { key: 'daa77827a09a7a06a5984498ad5537c1e7b07605', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: 'a39c7bd5557d03d0cb92713229da76fcf9c2e4f4', htmlFor: this.id, part: "label" }, h("span", { key: 'bddb726ce5a13891f316cd6961f2313103ffaa06', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '9d9b6db604192d7da651e84c786eaab140faa951', name: "label" })) || this.label, h("div", { key: 'f59ccad528690950b12a582df7bc3580e40f3a84', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: 'f8d8b6ddd9a3056986bfc9bc2cbc3196c3241891', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: '93034a970baf7e474934ba6b5327550678abd096', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")")), (this.maxLength || this.hasSlottedCounter) && (h("div", { key: '458caee7098e89168d779b776030e24be1c8fce0', class: "label-character-count", "aria-hidden": "true" }, this.hasSlottedCounter ? (h("slot", { name: "counter" })) : (`${this.value?.length ?? 0}/${this.maxLength}`)))))))), h("div", { key: 'c8583c36bf7cef298d1d0f50c942f43dbc8d9cab', class: { 'input-color': this.type === 'color', 'input-container': true } }, h("div", { key: '937aacc0c048c44ca710f3b14e71b436ac3d0039', class: "input-outer-wrapper" }, h("div", { key: '02d657ad1dad507dfcd63863a12da02c46ceeb20', class: {
143
+ } }, h("div", { key: '212806d23ea27c6bcfd8850ee3da759014ca78ad', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '78072a1cba66307777885eb284c8e1bdd58e16a1', htmlFor: this.id, part: "label" }, h("span", { key: '8418283fde42db3445d5ca9b10559684c8bcd7d7', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '6676d6381311ed2d171cb807598de2c408d017bf', name: "label" })) || this.label, h("div", { key: '5ae2d177c55c34663304c8d844e232fda8378067', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: '21f4e5a75faa4753f75a5a08de6cad4fdcf685fd', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: 'ea4c178c57d407e09bb8b10f14016c4987db4874', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")")), (this.maxLength || this.hasSlottedCounter) && (h("div", { key: '43e04d882ca31ad03a66fbc148594cbcdb9ee313', class: "label-character-count", "aria-hidden": "true" }, this.hasSlottedCounter ? (h("slot", { name: "counter" })) : (`${this.value?.length ?? 0}/${this.maxLength}`)))))))), h("div", { key: '06b53fdb4df82aeb736ae19d73b2a11d1c4e9af0', class: { 'input-color': this.type === 'color', 'input-container': true } }, h("div", { key: 'edb77ce73acff3cbcc0f4228a3c9ac95dbaca2d8', class: "input-outer-wrapper" }, h("div", { key: 'b39ccf857a38b31e2f15885f11c6d5f75f335aa3', class: {
141
144
  'input-wrapper': true,
142
145
  'input-round': this.round,
143
146
  'input-readonly': this.readonly,
144
147
  'input-disabled': this.disabled,
145
148
  'input-invalid': this.invalid
146
- }, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { key: 'fa5b35337dda6e3132f392133a914ae43e70c94e', class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { key: '4d06684dc073e4dcc2b1703fa56e7e386901a632', icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: 'e839a75201951e435a88fd6b740d1143d912c13b', class: {
149
+ }, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { key: 'f075bb5d4a81c2ccf35d7c50fd3ec65a6b9ab37e', class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { key: '12013d6b78cd440b99982c12aef4af31dcd91246', icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: '6d339cfe079f7926b4263b161ff08f4c6b9a4a43', class: {
147
150
  'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,
148
151
  'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value,
149
152
  'input-inner-wrapper': true,
150
153
  'type-color': this.type === 'color'
151
- } }, this.type === 'color' && h("span", { key: '1ba9f12990e0ec1ac114186d9784dbcc9dd57644', class: "color-value" }, this.value ?? '#000000'), h("input", { key: '6e089b3f68e7deb4912f16dd68a49f31821d0bfc', "data-test": this.testId, ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, class: {
154
+ } }, this.type === 'color' && h("span", { key: 'cf422632d44d234e7a9aef52572665a9a28ecc9d', class: "color-value" }, this.value ?? '#000000'), h("input", { key: 'ebc4a025956a028f1f73958486fa7e37dcd585a3', "data-test": this.testId, ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, class: {
152
155
  'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,
153
156
  'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value
154
- }, autocomplete: this.autoComplete, disabled: this.disabled, accept: this.type === 'file' ? this.accept : undefined, multiple: this.type === 'file' ? this.multiple : undefined, 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.isPasswordShown ? 'text' : 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": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: '5462cce12644d0ba36763e3a477c5953283fb884', class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'd45bc4743ba06802ddf4cfbbd413cad94611bcae', class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), this.loading && h("cat-spinner", { key: '63ab5d0a0dd36ef44ec8952dbeb09e336af3f231', size: "m", class: "icon-loading" }), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { key: '977d45f4d87510f41642566856fabc36db0727b9', icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && (h("cat-icon", { key: '4a71c080f96ab75de98624d553f159ec19155880', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), this.textSuffix && (h("span", { key: 'cdf4a92c9de5e483b914e7a1f33fab72db57ab0d', class: "text-suffix", part: "suffix" }, this.textSuffix))), h("slot", { key: 'c8e42694679b3d1f0fecbfcaba6fccc9ef18eff0', name: "addon" })), this.hasHint && (h(CatFormHint, { key: 'a5690f41eec951c3d88db93bf5c8527c53756945', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
157
+ }, autocomplete: this.autoComplete, disabled: this.disabled, accept: this.type === 'file' ? this.accept : undefined, multiple: this.type === 'file' ? this.multiple : undefined, 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.isPasswordShown ? 'text' : 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": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'c60b67e4b261a08d91180a92618fdfc692d239bf', class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'db6c218c74a241f626e5c2fdc767fa8f63d33a86', class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": i18n.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), this.loading && h("cat-spinner", { key: 'b2179d6109246c579189f0911faeb95168b96016', size: "m", class: "icon-loading" }), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { key: '52487c6ce3219d9b60f4af4f3360691bd7c34ace', icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && (h("cat-icon", { key: '18a27e11f4c4501d17758af16953ee2e23a1f0b9', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), this.textSuffix && (h("span", { key: '670348803c9828e4cf0587dd24de55273611f3a1', class: "text-suffix", part: "suffix" }, this.textSuffix))), h("slot", { key: '31969e55553baa41f18f60af3f81add74dafc6a7', name: "addon" })), this.hasHint && (h(CatFormHint, { key: '3a240f0af4686de4c2fc66c267e0e8c6b5f26157', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
155
158
  }
156
159
  get hasHint() {
157
160
  return !!this.hint || !!this.hasSlottedHint || this.invalid;
@@ -172,6 +175,9 @@ export class CatInput {
172
175
  this.value = formattedValue;
173
176
  this.internals.setFormValue(this.input.value);
174
177
  this.catChange.emit(this.value);
178
+ if (this.type === 'file') {
179
+ this.catChangeFiles.emit(this.input.files);
180
+ }
175
181
  this.showErrorsIfTimeout();
176
182
  }
177
183
  onFocus(event) {
@@ -998,6 +1004,26 @@ export class CatInput {
998
1004
  }
999
1005
  }
1000
1006
  }
1007
+ }, {
1008
+ "method": "catChangeFiles",
1009
+ "name": "catChangeFiles",
1010
+ "bubbles": true,
1011
+ "cancelable": true,
1012
+ "composed": true,
1013
+ "docs": {
1014
+ "tags": [],
1015
+ "text": "Emitted if the input type is \"file\" and files are selected."
1016
+ },
1017
+ "complexType": {
1018
+ "original": "FileList | null",
1019
+ "resolved": "FileList | null",
1020
+ "references": {
1021
+ "FileList": {
1022
+ "location": "global",
1023
+ "id": "global::FileList"
1024
+ }
1025
+ }
1026
+ }
1001
1027
  }];
1002
1028
  }
1003
1029
  static get methods() {
@@ -1 +1 @@
1
- {"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAY,M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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { AttachInternals, Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { coerceBoolean, coerceNumber } from '../../utils/coerce';\nimport { CatFormHint, ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\nimport { formatDate, formatTime } from 'cleave-zen';\n\nlet nextUniqueId = 0;\n\ntype TimeUnit = 'h' | 'm' | 's';\ntype TimeFormatType = '12' | '24';\ntype DateUnit = 'Y' | 'y' | 'm' | 'd';\n\nexport interface FormatTimeMaskOptions {\n timePattern?: TimeUnit[];\n timeFormat?: TimeFormatType;\n}\n\nexport interface FormatDateMaskOptions {\n delimiter?: string;\n datePattern?: DateUnit[];\n dateMin?: string;\n dateMax?: string;\n}\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 * @slot counter - Custom counter element to be displayed in the top right corner of the label.\n * @part label - The native label element.\n * @part input - The native input element.\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 formAssociated: true,\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatInput {\n private readonly _id = `cat-input-${nextUniqueId++}`;\n\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n private errorMapSrc?: ErrorMap | true;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n @State() hasSlottedCounter = false;\n\n @State() isPasswordShown = false;\n\n @State() errorMap?: ErrorMap | true;\n\n @AttachInternals() internals!: ElementInternals;\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 * Whether the label is on top or left.\n */\n @Prop() horizontal?: boolean;\n\n /**\n * If the horizontal value is not provided, this fallback value is used. Can be set by form-group.\n * @internal\n */\n @Prop() fallbackHorizontal?: boolean;\n\n /**\n * Defines the file types the file input should accept.\n */\n @Prop() accept?: string;\n\n /**\n * Whether the input should allow multiple files to be selected.\n */\n @Prop() multiple?: boolean;\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 should show a password toggle button for password inputs.\n */\n @Prop() togglePassword = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Displays the input in a loading state with a spinner.\n */\n @Prop() loading = 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 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 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;\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 change with the given delay in milliseconds or immediately on blur.\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 * A unique identifier for the underlying native element that is used for\n * testing purposes. The attribute is added as `data-test` attribute and acts\n * as a shorthand for `nativeAttributes={ 'data-test': 'test-Id' }`.\n */\n @Prop() testId?: string;\n\n /**\n * Activates cleave-zen time mask on input\n */\n @Prop() timeMaskOptions?: FormatTimeMaskOptions;\n\n /**\n * Activates cleave-zen date mask on input\n */\n @Prop() dateMaskOptions?: FormatDateMaskOptions;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\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 componentWillLoad(): void {\n this.onErrorsChanged(this.errors, undefined, false);\n }\n\n componentWillRender(): void {\n this.internals.setFormValue(this.value ?? null);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n this.hasSlottedCounter = !!this.hostElement.querySelector('[slot=\"counter\"]');\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 // hack to make datepicker inputs focusable. The datepicker hides the input\n // element and dynamically creates a sibling. We need to find the new input\n // element and focus it instead.\n const input = this.input.type === 'hidden' ? this.findSiblingInput(this.input.nextSibling) : this.input;\n 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 * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n this.catChange.emit(this.value);\n }\n\n @Watch('errors')\n onErrorsChanged(newValue?: boolean | string[] | ErrorMap, _oldValue?: unknown, update: boolean = true) {\n if (!coerceBoolean(this.errorUpdate)) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(newValue)\n ? (newValue as string[]).reduce((acc, err) => ({ ...acc, [err]: undefined }), {})\n : newValue || undefined;\n if (update) {\n this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();\n }\n }\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n return (\n <div\n class={{\n 'input-field': true,\n 'input-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false\n }}\n >\n <div class={{ 'label-container': true, hidden: this.labelHidden }}>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} part=\"label\">\n <span class=\"label-wrapper\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && (this.requiredMarker ?? 'optional').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 {(this.maxLength || this.hasSlottedCounter) && (\n <div class=\"label-character-count\" aria-hidden=\"true\">\n {this.hasSlottedCounter ? (\n <slot name=\"counter\"></slot>\n ) : (\n `${this.value?.length ?? 0}/${this.maxLength}`\n )}\n </div>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class={{ 'input-color': this.type === 'color', 'input-container': true }}>\n <div class=\"input-outer-wrapper\">\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-readonly': this.readonly,\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 && (\n <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\" onClick={() => this.doFocus()}></cat-icon>\n )}\n <div\n class={{\n 'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,\n 'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value,\n 'input-inner-wrapper': true,\n 'type-color': this.type === 'color'\n }}\n >\n {this.type === 'color' && <span class=\"color-value\">{this.value ?? '#000000'}</span>}\n <input\n data-test={this.testId}\n {...this.nativeAttributes}\n part=\"input\"\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,\n 'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n accept={this.type === 'file' ? this.accept : undefined}\n multiple={this.type === 'file' ? this.multiple : undefined}\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.isPasswordShown ? 'text' : 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.hasHint ? this.id + '-hint' : undefined}\n ></input>\n {this.clearable && !this.disabled && !this.readonly && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"$cat:input-close\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n data-dropdown-no-close\n ></cat-button>\n )}\n {this.togglePassword && !this.disabled && !this.readonly && this.value && (\n <cat-button\n class=\"toggle-password\"\n icon={this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show'}\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword')}\n onClick={this.doTogglePassword.bind(this)}\n ></cat-button>\n )}\n </div>\n {this.loading && <cat-spinner size=\"m\" class=\"icon-loading\"></cat-spinner>}\n {!this.invalid && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\" onClick={() => this.doFocus()}></cat-icon>\n )}\n {this.invalid && (\n <cat-icon icon=\"$cat:input-error\" 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 <slot name=\"addon\"></slot>\n </div>\n {this.hasHint && (\n <CatFormHint\n id={this.id}\n hint={this.hint}\n slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>}\n errorMap={this.errorMap}\n />\n )}\n </div>\n </div>\n );\n }\n\n private get hasHint() {\n return !!this.hint || !!this.hasSlottedHint || this.invalid;\n }\n\n private get invalid() {\n return this.errorMap === true || !!Object.keys(this.errorMap || {}).length;\n }\n\n private onInput() {\n let formattedValue = this.input.value;\n if (this.timeMaskOptions) {\n formattedValue = formatTime(this.input.value, this.timeMaskOptions);\n this.input.value = formattedValue;\n }\n if (this.dateMaskOptions) {\n formattedValue = formatDate(this.input.value, this.dateMaskOptions);\n this.input.value = formattedValue;\n }\n this.value = formattedValue;\n this.internals.setFormValue(this.input.value);\n this.catChange.emit(this.value);\n this.showErrorsIfTimeout();\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 (coerceBoolean(this.errorUpdate)) {\n this.showErrors();\n }\n }\n\n private doTogglePassword() {\n this.isPasswordShown = !this.isPasswordShown;\n }\n\n private showErrors() {\n this.errorMap = this.errorMapSrc;\n }\n\n private errorUpdateTimeoutId?: number;\n private showErrorsIfTimeout() {\n const errorUpdate = coerceNumber(this.errorUpdate, null);\n if (errorUpdate !== null) {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);\n return true;\n }\n return false;\n }\n\n private showErrorsIfNoFocus() {\n const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;\n if (!hasFocus) {\n this.showErrors();\n }\n }\n\n private findSiblingInput(node: Node | null): HTMLInputElement | undefined {\n if (node instanceof HTMLInputElement) {\n return node;\n } else if (node?.nextSibling) {\n return this.findSiblingInput(node.nextSibling);\n }\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"cat-input.js","sourceRoot":"","sources":["../../../src/components/cat-input/cat-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAY,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,IAAI,YAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { AttachInternals, Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { coerceBoolean, coerceNumber } from '../../utils/coerce';\nimport { CatFormHint, ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { InputType } from './input-type';\nimport { formatDate, formatTime } from 'cleave-zen';\n\nlet nextUniqueId = 0;\n\ntype TimeUnit = 'h' | 'm' | 's';\ntype TimeFormatType = '12' | '24';\ntype DateUnit = 'Y' | 'y' | 'm' | 'd';\n\nexport interface FormatTimeMaskOptions {\n timePattern?: TimeUnit[];\n timeFormat?: TimeFormatType;\n}\n\nexport interface FormatDateMaskOptions {\n delimiter?: string;\n datePattern?: DateUnit[];\n dateMin?: string;\n dateMax?: string;\n}\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 * @slot counter - Custom counter element to be displayed in the top right corner of the label.\n * @part label - The native label element.\n * @part input - The native input element.\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 formAssociated: true,\n shadow: {\n delegatesFocus: true\n }\n})\nexport class CatInput {\n private readonly _id = `cat-input-${nextUniqueId++}`;\n\n private get id() {\n return this.identifier || this._id;\n }\n\n private input!: HTMLInputElement;\n private errorMapSrc?: ErrorMap | true;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n @State() hasSlottedCounter = false;\n\n @State() isPasswordShown = false;\n\n @State() errorMap?: ErrorMap | true;\n\n @AttachInternals() internals!: ElementInternals;\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 * Whether the label is on top or left.\n */\n @Prop() horizontal?: boolean;\n\n /**\n * If the horizontal value is not provided, this fallback value is used. Can be set by form-group.\n * @internal\n */\n @Prop() fallbackHorizontal?: boolean;\n\n /**\n * Defines the file types the file input should accept.\n */\n @Prop() accept?: string;\n\n /**\n * Whether the input should allow multiple files to be selected.\n */\n @Prop() multiple?: boolean;\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 should show a password toggle button for password inputs.\n */\n @Prop() togglePassword = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Displays the input in a loading state with a spinner.\n */\n @Prop() loading = 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 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 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;\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 change with the given delay in milliseconds or immediately on blur.\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 * A unique identifier for the underlying native element that is used for\n * testing purposes. The attribute is added as `data-test` attribute and acts\n * as a shorthand for `nativeAttributes={ 'data-test': 'test-Id' }`.\n */\n @Prop() testId?: string;\n\n /**\n * Activates cleave-zen time mask on input\n */\n @Prop() timeMaskOptions?: FormatTimeMaskOptions;\n\n /**\n * Activates cleave-zen date mask on input\n */\n @Prop() dateMaskOptions?: FormatDateMaskOptions;\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\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 /**\n * Emitted if the input type is \"file\" and files are selected.\n */\n @Event() catChangeFiles!: EventEmitter<FileList | null>;\n\n componentWillLoad(): void {\n this.onErrorsChanged(this.errors, undefined, false);\n }\n\n componentWillRender(): void {\n this.internals.setFormValue(this.value ?? null);\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n this.hasSlottedCounter = !!this.hostElement.querySelector('[slot=\"counter\"]');\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 // hack to make datepicker inputs focusable. The datepicker hides the input\n // element and dynamically creates a sibling. We need to find the new input\n // element and focus it instead.\n const input = this.input.type === 'hidden' ? this.findSiblingInput(this.input.nextSibling) : this.input;\n 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 * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.value = '';\n this.catChange.emit(this.value);\n if (this.type === 'file') {\n this.catChangeFiles.emit(null);\n }\n }\n\n @Watch('errors')\n onErrorsChanged(newValue?: boolean | string[] | ErrorMap, _oldValue?: unknown, update: boolean = true) {\n if (!coerceBoolean(this.errorUpdate)) {\n this.errorMap = undefined;\n } else {\n this.errorMapSrc = Array.isArray(newValue)\n ? (newValue as string[]).reduce((acc, err) => ({ ...acc, [err]: undefined }), {})\n : newValue || undefined;\n if (update) {\n this.showErrorsIfTimeout() || this.showErrorsIfNoFocus();\n }\n }\n }\n\n render() {\n this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;\n return (\n <div\n class={{\n 'input-field': true,\n 'input-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false\n }}\n >\n <div class={{ 'label-container': true, hidden: this.labelHidden }}>\n {(this.hasSlottedLabel || this.label) && (\n <label htmlFor={this.id} part=\"label\">\n <span class=\"label-wrapper\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n <div class=\"label-metadata\">\n {!this.required && (this.requiredMarker ?? 'optional').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 {(this.maxLength || this.hasSlottedCounter) && (\n <div class=\"label-character-count\" aria-hidden=\"true\">\n {this.hasSlottedCounter ? (\n <slot name=\"counter\"></slot>\n ) : (\n `${this.value?.length ?? 0}/${this.maxLength}`\n )}\n </div>\n )}\n </div>\n </span>\n </label>\n )}\n </div>\n <div class={{ 'input-color': this.type === 'color', 'input-container': true }}>\n <div class=\"input-outer-wrapper\">\n <div\n class={{\n 'input-wrapper': true,\n 'input-round': this.round,\n 'input-readonly': this.readonly,\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 && (\n <cat-icon icon={this.icon} class=\"icon-prefix\" size=\"l\" onClick={() => this.doFocus()}></cat-icon>\n )}\n <div\n class={{\n 'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,\n 'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value,\n 'input-inner-wrapper': true,\n 'type-color': this.type === 'color'\n }}\n >\n {this.type === 'color' && <span class=\"color-value\">{this.value ?? '#000000'}</span>}\n <input\n data-test={this.testId}\n {...this.nativeAttributes}\n part=\"input\"\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n class={{\n 'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,\n 'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value\n }}\n autocomplete={this.autoComplete}\n disabled={this.disabled}\n accept={this.type === 'file' ? this.accept : undefined}\n multiple={this.type === 'file' ? this.multiple : undefined}\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.isPasswordShown ? 'text' : 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.hasHint ? this.id + '-hint' : undefined}\n ></input>\n {this.clearable && !this.disabled && !this.readonly && this.value && (\n <cat-button\n class=\"clearable\"\n icon=\"$cat:input-close\"\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t('input.clear')}\n onClick={this.clear.bind(this)}\n data-dropdown-no-close\n ></cat-button>\n )}\n {this.togglePassword && !this.disabled && !this.readonly && this.value && (\n <cat-button\n class=\"toggle-password\"\n icon={this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show'}\n icon-only=\"true\"\n size=\"s\"\n variant=\"text\"\n a11y-label={i18n.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword')}\n onClick={this.doTogglePassword.bind(this)}\n ></cat-button>\n )}\n </div>\n {this.loading && <cat-spinner size=\"m\" class=\"icon-loading\"></cat-spinner>}\n {!this.invalid && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\" onClick={() => this.doFocus()}></cat-icon>\n )}\n {this.invalid && (\n <cat-icon icon=\"$cat:input-error\" 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 <slot name=\"addon\"></slot>\n </div>\n {this.hasHint && (\n <CatFormHint\n id={this.id}\n hint={this.hint}\n slottedHint={this.hasSlottedHint && <slot name=\"hint\"></slot>}\n errorMap={this.errorMap}\n />\n )}\n </div>\n </div>\n );\n }\n\n private get hasHint() {\n return !!this.hint || !!this.hasSlottedHint || this.invalid;\n }\n\n private get invalid() {\n return this.errorMap === true || !!Object.keys(this.errorMap || {}).length;\n }\n\n private onInput() {\n let formattedValue = this.input.value;\n if (this.timeMaskOptions) {\n formattedValue = formatTime(this.input.value, this.timeMaskOptions);\n this.input.value = formattedValue;\n }\n if (this.dateMaskOptions) {\n formattedValue = formatDate(this.input.value, this.dateMaskOptions);\n this.input.value = formattedValue;\n }\n this.value = formattedValue;\n this.internals.setFormValue(this.input.value);\n this.catChange.emit(this.value);\n if (this.type === 'file') {\n this.catChangeFiles.emit(this.input.files);\n }\n this.showErrorsIfTimeout();\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 (coerceBoolean(this.errorUpdate)) {\n this.showErrors();\n }\n }\n\n private doTogglePassword() {\n this.isPasswordShown = !this.isPasswordShown;\n }\n\n private showErrors() {\n this.errorMap = this.errorMapSrc;\n }\n\n private errorUpdateTimeoutId?: number;\n private showErrorsIfTimeout() {\n const errorUpdate = coerceNumber(this.errorUpdate, null);\n if (errorUpdate !== null) {\n typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);\n this.errorUpdateTimeoutId = window.setTimeout(() => this.showErrors(), errorUpdate);\n return true;\n }\n return false;\n }\n\n private showErrorsIfNoFocus() {\n const hasFocus = document.activeElement === this.hostElement || document.activeElement === this.input;\n if (!hasFocus) {\n this.showErrors();\n }\n }\n\n private findSiblingInput(node: Node | null): HTMLInputElement | undefined {\n if (node instanceof HTMLInputElement) {\n return node;\n } else if (node?.nextSibling) {\n return this.findSiblingInput(node.nextSibling);\n }\n return undefined;\n }\n}\n"]}
@@ -19,6 +19,7 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
19
19
  this.catChange = createEvent(this, "catChange", 7);
20
20
  this.catFocus = createEvent(this, "catFocus", 7);
21
21
  this.catBlur = createEvent(this, "catBlur", 7);
22
+ this.catChangeFiles = createEvent(this, "catChangeFiles", 7);
22
23
  this.internals = this.attachInternals();
23
24
  this._id = `cat-input-${nextUniqueId++}`;
24
25
  this.hasSlottedLabel = false;
@@ -119,6 +120,9 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
119
120
  async clear() {
120
121
  this.value = '';
121
122
  this.catChange.emit(this.value);
123
+ if (this.type === 'file') {
124
+ this.catChangeFiles.emit(null);
125
+ }
122
126
  }
123
127
  onErrorsChanged(newValue, _oldValue, update = true) {
124
128
  if (!coerceBoolean(this.errorUpdate)) {
@@ -135,24 +139,24 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
135
139
  }
136
140
  render() {
137
141
  this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
138
- return (h("div", { key: '50c440a0998694c006b5a6cad4125bc395a159f1', class: {
142
+ return (h("div", { key: 'ffc4412a1f7c10431da8c4b6380fd8218298ac5a', class: {
139
143
  'input-field': true,
140
144
  'input-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false
141
- } }, h("div", { key: 'daa77827a09a7a06a5984498ad5537c1e7b07605', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: 'a39c7bd5557d03d0cb92713229da76fcf9c2e4f4', htmlFor: this.id, part: "label" }, h("span", { key: 'bddb726ce5a13891f316cd6961f2313103ffaa06', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '9d9b6db604192d7da651e84c786eaab140faa951', name: "label" })) || this.label, h("div", { key: 'f59ccad528690950b12a582df7bc3580e40f3a84', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: 'f8d8b6ddd9a3056986bfc9bc2cbc3196c3241891', class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: '93034a970baf7e474934ba6b5327550678abd096', class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.required'), ")")), (this.maxLength || this.hasSlottedCounter) && (h("div", { key: '458caee7098e89168d779b776030e24be1c8fce0', class: "label-character-count", "aria-hidden": "true" }, this.hasSlottedCounter ? (h("slot", { name: "counter" })) : (`${this.value?.length ?? 0}/${this.maxLength}`)))))))), h("div", { key: 'c8583c36bf7cef298d1d0f50c942f43dbc8d9cab', class: { 'input-color': this.type === 'color', 'input-container': true } }, h("div", { key: '937aacc0c048c44ca710f3b14e71b436ac3d0039', class: "input-outer-wrapper" }, h("div", { key: '02d657ad1dad507dfcd63863a12da02c46ceeb20', class: {
145
+ } }, h("div", { key: '212806d23ea27c6bcfd8850ee3da759014ca78ad', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '78072a1cba66307777885eb284c8e1bdd58e16a1', htmlFor: this.id, part: "label" }, h("span", { key: '8418283fde42db3445d5ca9b10559684c8bcd7d7', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: '6676d6381311ed2d171cb807598de2c408d017bf', name: "label" })) || this.label, h("div", { key: '5ae2d177c55c34663304c8d844e232fda8378067', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: '21f4e5a75faa4753f75a5a08de6cad4fdcf685fd', class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: 'ea4c178c57d407e09bb8b10f14016c4987db4874', class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.required'), ")")), (this.maxLength || this.hasSlottedCounter) && (h("div", { key: '43e04d882ca31ad03a66fbc148594cbcdb9ee313', class: "label-character-count", "aria-hidden": "true" }, this.hasSlottedCounter ? (h("slot", { name: "counter" })) : (`${this.value?.length ?? 0}/${this.maxLength}`)))))))), h("div", { key: '06b53fdb4df82aeb736ae19d73b2a11d1c4e9af0', class: { 'input-color': this.type === 'color', 'input-container': true } }, h("div", { key: 'edb77ce73acff3cbcc0f4228a3c9ac95dbaca2d8', class: "input-outer-wrapper" }, h("div", { key: 'b39ccf857a38b31e2f15885f11c6d5f75f335aa3', class: {
142
146
  'input-wrapper': true,
143
147
  'input-round': this.round,
144
148
  'input-readonly': this.readonly,
145
149
  'input-disabled': this.disabled,
146
150
  'input-invalid': this.invalid
147
- }, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { key: 'fa5b35337dda6e3132f392133a914ae43e70c94e', class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { key: '4d06684dc073e4dcc2b1703fa56e7e386901a632', icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: 'e839a75201951e435a88fd6b740d1143d912c13b', class: {
151
+ }, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { key: 'f075bb5d4a81c2ccf35d7c50fd3ec65a6b9ab37e', class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { key: '12013d6b78cd440b99982c12aef4af31dcd91246', icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: '6d339cfe079f7926b4263b161ff08f4c6b9a4a43', class: {
148
152
  'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,
149
153
  'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value,
150
154
  'input-inner-wrapper': true,
151
155
  'type-color': this.type === 'color'
152
- } }, this.type === 'color' && h("span", { key: '1ba9f12990e0ec1ac114186d9784dbcc9dd57644', class: "color-value" }, this.value ?? '#000000'), h("input", { key: '6e089b3f68e7deb4912f16dd68a49f31821d0bfc', "data-test": this.testId, ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, class: {
156
+ } }, this.type === 'color' && h("span", { key: 'cf422632d44d234e7a9aef52572665a9a28ecc9d', class: "color-value" }, this.value ?? '#000000'), h("input", { key: 'ebc4a025956a028f1f73958486fa7e37dcd585a3', "data-test": this.testId, ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, class: {
153
157
  'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,
154
158
  'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value
155
- }, autocomplete: this.autoComplete, disabled: this.disabled, accept: this.type === 'file' ? this.accept : undefined, multiple: this.type === 'file' ? this.multiple : undefined, 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.isPasswordShown ? 'text' : 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": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: '5462cce12644d0ba36763e3a477c5953283fb884', class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'd45bc4743ba06802ddf4cfbbd413cad94611bcae', class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), this.loading && h("cat-spinner", { key: '63ab5d0a0dd36ef44ec8952dbeb09e336af3f231', size: "m", class: "icon-loading" }), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { key: '977d45f4d87510f41642566856fabc36db0727b9', icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && (h("cat-icon", { key: '4a71c080f96ab75de98624d553f159ec19155880', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), this.textSuffix && (h("span", { key: 'cdf4a92c9de5e483b914e7a1f33fab72db57ab0d', class: "text-suffix", part: "suffix" }, this.textSuffix))), h("slot", { key: 'c8e42694679b3d1f0fecbfcaba6fccc9ef18eff0', name: "addon" })), this.hasHint && (h(CatFormHint, { key: 'a5690f41eec951c3d88db93bf5c8527c53756945', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
159
+ }, autocomplete: this.autoComplete, disabled: this.disabled, accept: this.type === 'file' ? this.accept : undefined, multiple: this.type === 'file' ? this.multiple : undefined, 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.isPasswordShown ? 'text' : 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": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'c60b67e4b261a08d91180a92618fdfc692d239bf', class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { key: 'db6c218c74a241f626e5c2fdc767fa8f63d33a86', class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), this.loading && h("cat-spinner", { key: 'b2179d6109246c579189f0911faeb95168b96016', size: "m", class: "icon-loading" }), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { key: '52487c6ce3219d9b60f4af4f3360691bd7c34ace', icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && (h("cat-icon", { key: '18a27e11f4c4501d17758af16953ee2e23a1f0b9', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), this.textSuffix && (h("span", { key: '670348803c9828e4cf0587dd24de55273611f3a1', class: "text-suffix", part: "suffix" }, this.textSuffix))), h("slot", { key: '31969e55553baa41f18f60af3f81add74dafc6a7', name: "addon" })), this.hasHint && (h(CatFormHint, { key: '3a240f0af4686de4c2fc66c267e0e8c6b5f26157', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
156
160
  }
157
161
  get hasHint() {
158
162
  return !!this.hint || !!this.hasSlottedHint || this.invalid;
@@ -173,6 +177,9 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
173
177
  this.value = formattedValue;
174
178
  this.internals.setFormValue(this.input.value);
175
179
  this.catChange.emit(this.value);
180
+ if (this.type === 'file') {
181
+ this.catChangeFiles.emit(this.input.files);
182
+ }
176
183
  this.showErrorsIfTimeout();
177
184
  }
178
185
  onFocus(event) {