@haiilo/catalyst 4.0.0 → 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.
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-8d6a31b9.entry.js +10 -0
- package/dist/catalyst/p-8d6a31b9.entry.js.map +1 -0
- package/dist/catalyst/p-ccfebe33.js.map +1 -1
- package/dist/cjs/cat-alert_24.cjs.entry.js +121 -33
- package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
- package/dist/cjs/cat-icon-registry-671af264.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +16 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js +13 -0
- package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js.map +1 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +1 -1
- package/dist/collection/components/cat-input/cat-input.js +64 -57
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js +16 -1
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.css +252 -0
- package/dist/collection/components/cat-select/cat-select.js +95 -9
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +261 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +102 -10
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +16 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/components/cat-checkbox2.js +2 -1
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-form-hint-utils.js +17 -0
- package/dist/components/cat-form-hint-utils.js.map +1 -0
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-input.js +39 -21
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-radio.js +2 -1
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-select2.js +40 -9
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-textarea.js +50 -7
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +2 -1
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/esm/cat-alert_24.entry.js +121 -33
- package/dist/esm/cat-alert_24.entry.js.map +1 -1
- package/dist/esm/cat-icon-registry-d6b80490.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +6 -0
- package/dist/types/components/cat-form-hint/cat-form-hint-utils.d.ts +4 -0
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +1 -1
- package/dist/types/components/cat-input/cat-input.d.ts +17 -11
- package/dist/types/components/cat-radio/cat-radio.d.ts +6 -0
- package/dist/types/components/cat-select/cat-select.d.ts +28 -2
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +27 -1
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +6 -0
- package/dist/types/components.d.ts +85 -20
- package/package.json +2 -2
- package/dist/catalyst/p-0a46696e.entry.js +0 -10
- package/dist/catalyst/p-0a46696e.entry.js.map +0 -1
|
@@ -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;AA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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 * Flag that indicates if the input is invalid.\n */\n @Prop({ mutable: true }) invalid = false;\n\n /**\n * Validation errors. Will render a hint under the input with the translated error message `error.${key}`.\n */\n @Prop({ mutable: true }) errors?: { [key: string]: unknown };\n\n /**\n * Disable validation for the input. No error messages or error colors will be shown.\n */\n @Prop() disableValidation = 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 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 'input-invalid': this.invalid && !this.disableValidation\n }}\n onClick={() => this.input.focus()}\n >\n {this.textPrefix && (\n <span class=\"text-prefix\" part=\"prefix\">\n {this.textPrefix}\n {this.invalid}\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' : 'false'}\n aria-describedby={this.id + '-hint'}\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.disableValidation) && this.icon && this.iconRight && (\n <cat-icon icon={this.icon} class=\"icon-suffix\" size=\"l\"></cat-icon>\n )}\n {this.invalid && !this.disableValidation && (\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 <div id={this.id + '-hint'}>{this.hintSection}</div>\n </Host>\n );\n }\n\n private get hintSection() {\n if (this.errors && !this.disableValidation) {\n return Object.keys(this.errors).map(error => (\n <CatFormHint hint={i18n.t(`error.${error}`)} class=\"cat-text-danger\" />\n ));\n }\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;IAO1B;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IA0C5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,UAAK,GAAG,KAAK,CAAC;IAEtB;;OAEG;IACK,SAAI,GAAc,MAAM,CAAC;IAiBjC;;;;OAIG;IACK,gBAAW,GAAqB,CAAC,CAAC;GAkM3C;EAjVC,IAAY,EAAE;IACZ,OAAO,IAAI,CAAC,UAAU,IAAI,I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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,OA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C,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
|
}
|
|
@@ -3,7 +3,7 @@ import { Component, Element, Event, h, Host, Listen, Method, Prop, State, Watch
|
|
|
3
3
|
import autosizeInput from 'autosize-input';
|
|
4
4
|
import log from 'loglevel';
|
|
5
5
|
import { catchError, debounce, distinctUntilChanged, filter, first, of, scan, startWith, Subject, switchMap, takeWhile, tap, timer } from 'rxjs';
|
|
6
|
-
import {
|
|
6
|
+
import { buildHintSection } from '../cat-form-hint/cat-form-hint-utils';
|
|
7
7
|
import { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';
|
|
8
8
|
const INIT_STATE = {
|
|
9
9
|
term: '',
|
|
@@ -73,6 +73,12 @@ export class CatSelect {
|
|
|
73
73
|
* Whether the select should add new items.
|
|
74
74
|
*/
|
|
75
75
|
this.tags = false;
|
|
76
|
+
/**
|
|
77
|
+
* Fine-grained control over when the errors are shown. Can be `false` to
|
|
78
|
+
* never show errors, `true` to show errors on blur, or a number to show
|
|
79
|
+
* errors on change with the given delay in milliseconds.
|
|
80
|
+
*/
|
|
81
|
+
this.errorUpdate = 0;
|
|
76
82
|
}
|
|
77
83
|
get id() {
|
|
78
84
|
return this.identifier || this._id;
|
|
@@ -84,6 +90,18 @@ export class CatSelect {
|
|
|
84
90
|
onValueChange() {
|
|
85
91
|
!this.valueChangedBySelection ? this.resolve() : (this.valueChangedBySelection = false);
|
|
86
92
|
}
|
|
93
|
+
watchErrorsHandler(value) {
|
|
94
|
+
if (this.errorUpdate === false) {
|
|
95
|
+
this.errorMap = undefined;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.errorMapSrc = Array.isArray(value)
|
|
99
|
+
? value.map(error => ({ [error]: undefined }))
|
|
100
|
+
: value === true
|
|
101
|
+
? {}
|
|
102
|
+
: value || undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
87
105
|
onStateChange(newState, oldState) {
|
|
88
106
|
var _a;
|
|
89
107
|
const changed = (key) => newState[key] !== oldState[key];
|
|
@@ -124,6 +142,10 @@ export class CatSelect {
|
|
|
124
142
|
this.value = newValue;
|
|
125
143
|
}
|
|
126
144
|
this.catChange.emit();
|
|
145
|
+
if (typeof this.errorUpdate === 'number') {
|
|
146
|
+
typeof this.errorUpdateTimeoutId === 'number' && window.clearTimeout(this.errorUpdateTimeoutId);
|
|
147
|
+
this.errorUpdateTimeoutId = window.setTimeout(() => (this.errorMap = this.errorMapSrc), this.errorUpdate);
|
|
148
|
+
}
|
|
127
149
|
}
|
|
128
150
|
}
|
|
129
151
|
componentDidLoad() {
|
|
@@ -135,6 +157,7 @@ export class CatSelect {
|
|
|
135
157
|
}
|
|
136
158
|
}
|
|
137
159
|
componentWillRender() {
|
|
160
|
+
this.watchErrorsHandler(this.errors);
|
|
138
161
|
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
139
162
|
if (!this.label && !this.hasSlottedLabel) {
|
|
140
163
|
log.warn('[A11y] Missing ARIA label on select', this);
|
|
@@ -152,6 +175,9 @@ export class CatSelect {
|
|
|
152
175
|
this.hide();
|
|
153
176
|
this.patchState({ activeSelectionIndex: -1 });
|
|
154
177
|
this.catBlur.emit(event);
|
|
178
|
+
if (this.errorUpdate !== false) {
|
|
179
|
+
this.errorMap = this.errorMapSrc;
|
|
180
|
+
}
|
|
155
181
|
}
|
|
156
182
|
onKeyDown(event) {
|
|
157
183
|
var _a, _b, _c, _d, _e;
|
|
@@ -270,6 +296,7 @@ export class CatSelect {
|
|
|
270
296
|
});
|
|
271
297
|
}
|
|
272
298
|
render() {
|
|
299
|
+
var _a;
|
|
273
300
|
return (h(Host, null,
|
|
274
301
|
(this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } },
|
|
275
302
|
h("span", { part: "label" },
|
|
@@ -282,7 +309,7 @@ export class CatSelect {
|
|
|
282
309
|
"(",
|
|
283
310
|
i18n.t('input.required'),
|
|
284
311
|
")"))))),
|
|
285
|
-
h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) },
|
|
312
|
+
h("div", { class: { 'select-wrapper': true, 'select-disabled': this.disabled, 'select-invalid': this.invalid }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) },
|
|
286
313
|
h("div", { class: "select-wrapper-inner" },
|
|
287
314
|
this.multiple && this.state.selection.length ? (h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => {
|
|
288
315
|
var _a;
|
|
@@ -295,14 +322,15 @@ export class CatSelect {
|
|
|
295
322
|
h("span", null, item.render.label),
|
|
296
323
|
!this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "16-cross", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1 }))));
|
|
297
324
|
}))) : this.state.selection.length && this.state.selection[0].render.avatar ? (h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, initials: '' })) : null,
|
|
298
|
-
h("input", { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, onInput: () => this.onInput(), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })),
|
|
325
|
+
h("input", Object.assign({}, this.nativeAttributes, { class: "select-input", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": ((_a = this.hint) === null || _a === void 0 ? void 0 : _a.length) ? this.id + '-hint' : undefined, onInput: () => this.onInput(), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving }))),
|
|
299
326
|
this.state.isResolving && h("cat-spinner", null),
|
|
327
|
+
this.invalid && (h("cat-icon", { icon: "alert-circle-outlined", class: "icon-suffix cat-text-danger", size: "l" })),
|
|
300
328
|
(this.state.selection.length || this.state.term.length) &&
|
|
301
329
|
!this.disabled &&
|
|
302
330
|
!this.state.isResolving &&
|
|
303
331
|
this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "cross-circle-outlined", variant: "text", size: "s", a11yLabel: i18n.t('input.clear'), onClick: () => this.clear() })) : null,
|
|
304
332
|
!this.state.isResolving && (h("cat-button", { iconOnly: true, icon: "chevron-down-outlined", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? i18n.t('select.close') : i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving }))),
|
|
305
|
-
this.
|
|
333
|
+
buildHintSection(this.hostElement, this.id, this.hint, this.errorMap),
|
|
306
334
|
h("div", { class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() },
|
|
307
335
|
h("ul", { class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` },
|
|
308
336
|
this.optionsList,
|
|
@@ -313,6 +341,9 @@ export class CatSelect {
|
|
|
313
341
|
: !this.state.options.length &&
|
|
314
342
|
!this.tags && (h("li", { class: "select-option-empty" }, this.noItems ? this.noItems : i18n.t('select.empty')))))))));
|
|
315
343
|
}
|
|
344
|
+
get invalid() {
|
|
345
|
+
return !!this.errorMap;
|
|
346
|
+
}
|
|
316
347
|
get optionsList() {
|
|
317
348
|
return this.state.options.map((item, i) => {
|
|
318
349
|
var _a, _b;
|
|
@@ -343,10 +374,6 @@ export class CatSelect {
|
|
|
343
374
|
h("span", { class: "select-option-description" }, item.render.description))))));
|
|
344
375
|
});
|
|
345
376
|
}
|
|
346
|
-
get hintSection() {
|
|
347
|
-
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
348
|
-
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
349
|
-
}
|
|
350
377
|
get connectorSafe() {
|
|
351
378
|
if (this.connector) {
|
|
352
379
|
return this.connector;
|
|
@@ -950,12 +977,68 @@ export class CatSelect {
|
|
|
950
977
|
},
|
|
951
978
|
"attribute": "no-items",
|
|
952
979
|
"reflect": false
|
|
980
|
+
},
|
|
981
|
+
"errors": {
|
|
982
|
+
"type": "boolean",
|
|
983
|
+
"mutable": false,
|
|
984
|
+
"complexType": {
|
|
985
|
+
"original": "boolean | string[] | ErrorMap",
|
|
986
|
+
"resolved": "boolean | string[] | undefined | { [key: string]: any; }",
|
|
987
|
+
"references": {
|
|
988
|
+
"ErrorMap": {
|
|
989
|
+
"location": "import",
|
|
990
|
+
"path": "../cat-form-hint/cat-form-hint-utils"
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
"required": false,
|
|
995
|
+
"optional": true,
|
|
996
|
+
"docs": {
|
|
997
|
+
"tags": [],
|
|
998
|
+
"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."
|
|
999
|
+
},
|
|
1000
|
+
"attribute": "errors",
|
|
1001
|
+
"reflect": false
|
|
1002
|
+
},
|
|
1003
|
+
"errorUpdate": {
|
|
1004
|
+
"type": "any",
|
|
1005
|
+
"mutable": false,
|
|
1006
|
+
"complexType": {
|
|
1007
|
+
"original": "boolean | number",
|
|
1008
|
+
"resolved": "boolean | number",
|
|
1009
|
+
"references": {}
|
|
1010
|
+
},
|
|
1011
|
+
"required": false,
|
|
1012
|
+
"optional": false,
|
|
1013
|
+
"docs": {
|
|
1014
|
+
"tags": [],
|
|
1015
|
+
"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."
|
|
1016
|
+
},
|
|
1017
|
+
"attribute": "error-update",
|
|
1018
|
+
"reflect": false,
|
|
1019
|
+
"defaultValue": "0"
|
|
1020
|
+
},
|
|
1021
|
+
"nativeAttributes": {
|
|
1022
|
+
"type": "unknown",
|
|
1023
|
+
"mutable": false,
|
|
1024
|
+
"complexType": {
|
|
1025
|
+
"original": "{ [key: string]: string }",
|
|
1026
|
+
"resolved": "undefined | { [key: string]: string; }",
|
|
1027
|
+
"references": {}
|
|
1028
|
+
},
|
|
1029
|
+
"required": false,
|
|
1030
|
+
"optional": true,
|
|
1031
|
+
"docs": {
|
|
1032
|
+
"tags": [],
|
|
1033
|
+
"text": "Attributes that will be added to the native HTML input element."
|
|
1034
|
+
}
|
|
953
1035
|
}
|
|
954
1036
|
}; }
|
|
955
1037
|
static get states() { return {
|
|
956
1038
|
"connector": {},
|
|
957
1039
|
"state": {},
|
|
958
|
-
"hasSlottedLabel": {}
|
|
1040
|
+
"hasSlottedLabel": {},
|
|
1041
|
+
"errorMap": {}
|
|
959
1042
|
}; }
|
|
960
1043
|
static get events() { return [{
|
|
961
1044
|
"method": "catOpen",
|
|
@@ -1074,6 +1157,9 @@ export class CatSelect {
|
|
|
1074
1157
|
}, {
|
|
1075
1158
|
"propName": "value",
|
|
1076
1159
|
"methodName": "onValueChange"
|
|
1160
|
+
}, {
|
|
1161
|
+
"propName": "errors",
|
|
1162
|
+
"methodName": "watchErrorsHandler"
|
|
1077
1163
|
}, {
|
|
1078
1164
|
"propName": "state",
|
|
1079
1165
|
"methodName": "onStateChange"
|