Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: hideError validation #5660

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/components/src/components/@deprecated/input/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Generic } from '@a11y-ui/core';

import { InputTypeOnDefault } from '../../../types/input/types';
import { AdjustHeightPropType, validateAdjustHeight } from '../../../types/props/adjust-height';
import { HideErrorPropType, validateHideError } from '../../../types/props/hide-error';
import { validateHideLabel } from '../../../types/props/hide-label';
import { LabelWithExpertSlotPropType, validateLabelWithExpertSlot } from '../../../types/props/label';
import { a11yHint, a11yHintDisabled, devHint } from '../../../utils/a11y.tipps';
Expand Down Expand Up @@ -44,6 +45,18 @@ export class InputController extends ControlledInputController implements Watche
watchString(this.component, '_error', value);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateHideLabel(value?: boolean): void {
validateHideLabel(this.component, value, {
hooks: {
Expand Down Expand Up @@ -106,6 +119,7 @@ export class InputController extends ControlledInputController implements Watche
this.validateAdjustHeight(this.component._adjustHeight);
this.validateError(this.component._error);
this.validateDisabled(this.component._disabled);
this.validateHideError(this.component._hideError);
this.validateHideLabel(this.component._hideLabel);
this.validateHint(this.component._hint);
this.validateId(this.component._id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type OptionalProps = PropLabelWithExpertSlot & {
adjustHeight: boolean;
disabled: boolean;
error: string;
hideError: boolean;
hideLabel: boolean;
hint: string;
id: string;
Expand Down
17 changes: 1 addition & 16 deletions packages/components/src/components/input-checkbox/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { Generic } from '@a11y-ui/core';

import { Stringified } from '../../types/common';
import { CheckedPropType, validateChecked } from '../../types/props/checked';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { IndeterminatePropType, validateIndeterminate } from '../../types/props/indeterminate';
import { StencilUnknown } from '../../types/unknown';
import { a11yHint } from '../../utils/a11y.tipps';
import { setState, watchValidator } from '../../utils/prop.validators';
import { isString } from '../../utils/validator';
import { InputCheckboxRadioController } from '../input-radio/controller';
import { InputCheckboxIconsProp, InputCheckboxIconsState, InputCheckboxVariant, inputCheckboxVariantOptions, Props, Watches } from './types';
import { InputCheckboxIconsProp, InputCheckboxIconsState, InputCheckboxVariant, Props, Watches, inputCheckboxVariantOptions } from './types';

export class InputCheckboxController extends InputCheckboxRadioController implements Watches {
protected readonly component: Generic.Element.Component & Props;
Expand All @@ -32,18 +30,6 @@ export class InputCheckboxController extends InputCheckboxRadioController implem
this.setFormAssociatedCheckboxValue(this.component.state._value as StencilUnknown);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateIcons(value?: Stringified<InputCheckboxIconsProp>): void {
watchValidator(
this.component,
Expand Down Expand Up @@ -88,7 +74,6 @@ export class InputCheckboxController extends InputCheckboxRadioController implem
public componentWillLoad(): void {
super.componentWillLoad();
this.validateChecked(this.component._checked);
this.validateHideError(this.component._hideError);
this.validateIcons(this.component._icons);
this.validateIndeterminate(this.component._indeterminate);
this.validateValue(this.component._value);
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-color/controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Generic } from '@a11y-ui/core';

import { InputTypeOnOff, inputTypeOnOffOptions } from '../../types/input/types';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { SuggestionsPropType, validateSuggestions } from '../../types/props/suggestions';
import { a11yHint } from '../../utils/a11y.tipps';
import { watchString, watchValidator } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand Down Expand Up @@ -35,22 +33,9 @@ export class InputColorController extends InputIconController implements Watches
this.setFormAssociatedValue(this.component.state._value as string);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public componentWillLoad(): void {
super.componentWillLoad();
this.validateAutoComplete(this.component._autoComplete);
this.validateHideError(this.component._hideError);
this.validateSuggestions(this.component._suggestions);
this.validateValue(this.component._value);
}
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-date/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { Generic } from '@a11y-ui/core';
import { InputDateType, inputDateTypeOptions } from '../../types/input/control/number';
import { Iso8601 } from '../../types/input/iso8601';
import { InputTypeOnDefault, InputTypeOnOff } from '../../types/input/types';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { ReadOnlyPropType, validateReadOnly } from '../../types/props/read-only';
import { SuggestionsPropType, validateSuggestions } from '../../types/props/suggestions';
import { a11yHint } from '../../utils/a11y.tipps';
import { setState, watchBoolean, watchNumber, watchValidator } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand Down Expand Up @@ -38,18 +36,6 @@ export class InputDateController extends InputIconController implements Watches
);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateSuggestions(value?: SuggestionsPropType): void {
validateSuggestions(this.component, value);
}
Expand Down Expand Up @@ -213,7 +199,6 @@ export class InputDateController extends InputIconController implements Watches
this.validateAutoComplete(this.component._autoComplete);
this.validateMax(this.component._max);
this.validateMin(this.component._min);
this.validateHideError(this.component._hideError);
this.validateLabel(this.component._label);
this.validateSuggestions(this.component._suggestions);
this.validateOn(this.component._on);
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-email/controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Generic } from '@a11y-ui/core';

import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { MultiplePropType, validateMultiple } from '../../types/props/multiple';
import { a11yHint } from '../../utils/a11y.tipps';
import { InputTextEmailController } from '../input-text/controller';
import { Props, Watches } from './types';

Expand All @@ -14,25 +12,12 @@ export class InputEmailController extends InputTextEmailController implements Wa
this.component = component;
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateMultiple(value?: MultiplePropType): void {
validateMultiple(this.component, value);
}

public componentWillLoad(): void {
super.componentWillLoad();
this.validateHideError(this.component._hideError);
this.validateMultiple(this.component._multiple);
}
}
15 changes: 0 additions & 15 deletions packages/components/src/components/input-file/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Generic } from '@a11y-ui/core';

import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { a11yHint } from '../../utils/a11y.tipps';
import { watchBoolean, watchString } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand All @@ -18,18 +16,6 @@ export class InputFileController extends InputIconController implements Watches
watchString(this.component, '_accept', value);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateMultiple(value?: boolean): void {
watchBoolean(this.component, '_multiple', value);
}
Expand All @@ -46,7 +32,6 @@ export class InputFileController extends InputIconController implements Watches
public componentWillLoad(): void {
super.componentWillLoad();
this.validateAccept(this.component._accept);
this.validateHideError(this.component._hideError);
this.validateMultiple(this.component._multiple);
this.validateRequired(this.component._required);
this.validateValue(this.component._value);
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-number/controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Generic } from '@a11y-ui/core';
import { Iso8601 } from '../../types/input/iso8601';
import { InputTypeOnOff } from '../../types/input/types';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { SuggestionsPropType, validateSuggestions } from '../../types/props/suggestions';
import { a11yHint } from '../../utils/a11y.tipps';
import { watchBoolean, watchNumber, watchString, watchValidator } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand Down Expand Up @@ -33,18 +31,6 @@ export class InputNumberController extends InputIconController implements Watche
);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateSuggestions(value?: SuggestionsPropType): void {
validateSuggestions(this.component, value);
}
Expand Down Expand Up @@ -131,7 +117,6 @@ export class InputNumberController extends InputIconController implements Watche
public componentWillLoad(): void {
super.componentWillLoad();
this.validateAutoComplete(this.component._autoComplete);
this.validateHideError(this.component._hideError);
this.validateMax(this.component._max);
this.validateMin(this.component._min);
this.validateSuggestions(this.component._suggestions);
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-password/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Generic } from '@a11y-ui/core';

import { InputTypeOnOff } from '../../types/input/types';
import { validateHasCounter } from '../../types/props/has-counter';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { a11yHint } from '../../utils/a11y.tipps';
import { watchBoolean, watchNumber, watchString, watchValidator } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand Down Expand Up @@ -31,18 +29,6 @@ export class InputPasswordController extends InputIconController implements Watc
validateHasCounter(this.component, value);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateMaxLength(value?: number): void {
watchNumber(this.component, '_maxLength', value, {
min: 0,
Expand Down Expand Up @@ -74,7 +60,6 @@ export class InputPasswordController extends InputIconController implements Watc
super.componentWillLoad();
this.validateAutoComplete(this.component._autoComplete);
this.validateHasCounter(this.component._hasCounter);
this.validateHideError(this.component._hideError);
this.validateMaxLength(this.component._maxLength);
this.validatePattern(this.component._pattern);
this.validatePlaceholder(this.component._placeholder);
Expand Down
15 changes: 0 additions & 15 deletions packages/components/src/components/input-radio/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { Generic } from '@a11y-ui/core';
import { Stringified } from '../../types/common';
import { Optgroup, Option, SelectOption } from '../../types/input/types';
import { Orientation, orientationOptions } from '../../types/orientation';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { PropLabelWithExpertSlot } from '../../types/props/label';
import { OptionsPropType, validateOptions } from '../../types/props/options';
import { validateRequired } from '../../types/props/required';
import { StencilUnknown } from '../../types/unknown';
import { W3CInputValue } from '../../types/w3c';
import { a11yHint } from '../../utils/a11y.tipps';
import { mapString2Unknown, setState, watchValidator } from '../../utils/prop.validators';
import { STATE_CHANGE_EVENT } from '../../utils/validator';
import { InputController } from '../@deprecated/input/controller';
Expand Down Expand Up @@ -43,18 +41,6 @@ export class InputCheckboxRadioController extends InputController implements Inp
this.component = component;
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateRequired(value?: boolean): void {
validateRequired(this.component, value);
}
Expand Down Expand Up @@ -143,7 +129,6 @@ export class InputRadioController extends InputCheckboxRadioController implement

this.validateOrientation(this.component._orientation);
this.validateOptions(this.component._options);
this.validateHideError(this.component._hideError);
this.validateValue(this.component._value);
}
}
15 changes: 0 additions & 15 deletions packages/components/src/components/input-range/controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Generic } from '@a11y-ui/core';
import { InputTypeOnOff } from '../../types/input/types';
import { HideErrorPropType, validateHideError } from '../../types/props/hide-error';
import { SuggestionsPropType, validateSuggestions } from '../../types/props/suggestions';
import { a11yHint } from '../../utils/a11y.tipps';
import { watchNumber, watchValidator } from '../../utils/prop.validators';
import { InputIconController } from '../@deprecated/input/controller-icon';
import { Props, Watches } from './types';
Expand All @@ -25,18 +23,6 @@ export class InputRangeController extends InputIconController implements Watches
);
}

public validateHideError(value?: HideErrorPropType): void {
validateHideError(this.component, value, {
hooks: {
afterPatch: () => {
if (this.component.state._hideError) {
a11yHint('Property hide-error for inputs: Only use when the error message is shown outside of the input component.');
}
},
},
});
}

public validateMax(value?: number): void {
watchNumber(this.component, '_max', value);
}
Expand All @@ -61,7 +47,6 @@ export class InputRangeController extends InputIconController implements Watches
public componentWillLoad(): void {
super.componentWillLoad();
this.validateAutoComplete(this.component._autoComplete);
this.validateHideError(this.component._hideError);
this.validateMax(this.component._max);
this.validateMin(this.component._min);
this.validateStep(this.component._step);
Expand Down
Loading
Loading