diff --git a/packages/devextreme-angular/src/ui/validator/index.ts b/packages/devextreme-angular/src/ui/validator/index.ts index e2a7c2a6f7db..2ea1d490c228 100644 --- a/packages/devextreme-angular/src/ui/validator/index.ts +++ b/packages/devextreme-angular/src/ui/validator/index.ts @@ -26,7 +26,7 @@ import { import * as CommonTypes from 'devextreme/common'; -import { EventInfo } from 'devextreme/common/core/events'; +import { DisposingEvent, InitializedEvent, OptionChangedEvent, ValidatedEvent } from 'devextreme/ui/validator'; import DxValidator from 'devextreme/ui/validator'; @@ -179,27 +179,27 @@ export class DxValidatorComponent extends DxComponentExtension implements OnDest /** - * [descr:DOMComponentOptions.onDisposing] + * [descr:dxValidatorOptions.onDisposing] */ - @Output() onDisposing: EventEmitter>; + @Output() onDisposing: EventEmitter; /** - * [descr:ComponentOptions.onInitialized] + * [descr:dxValidatorOptions.onInitialized] */ - @Output() onInitialized: EventEmitter; + @Output() onInitialized: EventEmitter; /** - * [descr:DOMComponentOptions.onOptionChanged] + * [descr:dxValidatorOptions.onOptionChanged] */ - @Output() onOptionChanged: EventEmitter; + @Output() onOptionChanged: EventEmitter; /** @@ -207,7 +207,7 @@ export class DxValidatorComponent extends DxComponentExtension implements OnDest */ - @Output() onValidated: EventEmitter; + @Output() onValidated: EventEmitter; /** diff --git a/packages/devextreme-react/src/validator.ts b/packages/devextreme-react/src/validator.ts index 89da2743ea1f..979753c579e7 100644 --- a/packages/devextreme-react/src/validator.ts +++ b/packages/devextreme-react/src/validator.ts @@ -9,9 +9,20 @@ import { ExtensionComponent as BaseComponent } from "./core/extension-component" import { IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component"; import NestedOption from "./core/nested-option"; +import type { DisposingEvent, InitializedEvent, ValidatedEvent } from "devextreme/ui/validator"; import type { ValidationRuleType, ComparisonOperator } from "devextreme/common"; -type IValidatorOptions = React.PropsWithChildren +type ReplaceFieldTypes = { + [P in keyof TSource]: P extends keyof TReplacement ? TReplacement[P] : TSource[P]; +} + +type IValidatorOptionsNarrowedEvents = { + onDisposing?: ((e: DisposingEvent) => void); + onInitialized?: ((e: InitializedEvent) => void); + onValidated?: ((validatedInfo: ValidatedEvent) => void); +} + +type IValidatorOptions = React.PropsWithChildren & IHtmlOptions> interface ValidatorRef { instance: () => dxValidator; diff --git a/packages/devextreme-vue/src/validator.ts b/packages/devextreme-vue/src/validator.ts index 5b5dc4c0686b..7b6661d2620b 100644 --- a/packages/devextreme-vue/src/validator.ts +++ b/packages/devextreme-vue/src/validator.ts @@ -2,15 +2,13 @@ import { PropType } from "vue"; import { defineComponent } from "vue"; import { prepareExtensionComponentConfig } from "./core/index"; import Validator, { Properties } from "devextreme/ui/validator"; -import DOMComponent from "devextreme/core/dom_component"; import { - EventInfo, -} from "devextreme/common/core/events"; + DisposingEvent, + InitializedEvent, + OptionChangedEvent, + ValidatedEvent, +} from "devextreme/ui/validator"; import { - Component, -} from "devextreme/core/component"; -import { - ValidationStatus, ValidationRuleType, ComparisonOperator, } from "devextreme/common"; @@ -41,10 +39,10 @@ const componentConfig = { elementAttr: Object as PropType>, height: [Function, Number, String] as PropType<((() => number | string)) | number | string>, name: String, - onDisposing: Function as PropType<((e: EventInfo) => void)>, - onInitialized: Function as PropType<((e: { component: Component, element: any }) => void)>, - onOptionChanged: Function as PropType<((e: { component: DOMComponent, element: any, fullName: string, model: any, name: string, previousValue: any, value: any }) => void)>, - onValidated: Function as PropType<((validatedInfo: { brokenRule: CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule, brokenRules: Array, isValid: boolean, name: string, status: ValidationStatus, validationRules: Array, value: Record }) => void)>, + onDisposing: Function as PropType<((e: DisposingEvent) => void)>, + onInitialized: Function as PropType<((e: InitializedEvent) => void)>, + onOptionChanged: Function as PropType<((e: OptionChangedEvent) => void)>, + onValidated: Function as PropType<((validatedInfo: ValidatedEvent) => void)>, validationGroup: String, validationRules: Array as PropType>, width: [Function, Number, String] as PropType<((() => number | string)) | number | string> diff --git a/packages/devextreme/js/ui/validator.d.ts b/packages/devextreme/js/ui/validator.d.ts index 8cc8a58c6628..8a7cb405e715 100644 --- a/packages/devextreme/js/ui/validator.d.ts +++ b/packages/devextreme/js/ui/validator.d.ts @@ -22,23 +22,52 @@ export { ValidationStatus, }; -/** @public */ +/** + * @docid _ui_validator_DisposingEvent + * @public + * @type object + * @inherits EventInfo + */ export type DisposingEvent = EventInfo; -/** @public */ +/** + * @docid _ui_validator_InitializedEvent + * @public + * @type object + * @inherits InitializedEventInfo + */ export type InitializedEvent = InitializedEventInfo; -/** @public */ +/** + * @docid _ui_validator_OptionChangedEvent + * @public + * @type object + * @inherits EventInfo,ChangedOptionInfo + */ export type OptionChangedEvent = EventInfo & ChangedOptionInfo; -/** @public */ +/** + * @docid _ui_validator_ValidatedEvent + * @public + * @type object + */ export type ValidatedEvent = { + /** @docid _ui_validator_ValidatedEvent.name */ name?: string; + /** @docid _ui_validator_ValidatedEvent.isValid */ isValid?: boolean; + /** + * @docid _ui_validator_ValidatedEvent.value + * @type object + */ value?: any; + /** @docid _ui_validator_ValidatedEvent.validationRules */ validationRules?: Array; + /** @docid _ui_validator_ValidatedEvent.brokenRule */ brokenRule?: ValidationRule; - brokenRules?: ValidationRule; + /** @docid _ui_validator_ValidatedEvent.brokenRules */ + brokenRules?: Array; + /** @docid _ui_validator_ValidatedEvent.status */ status?: ValidationStatus; }; @@ -85,12 +114,7 @@ export interface dxValidatorOptions extends DOMComponentOptions { name?: string; /** * @docid - * @type_function_param1 validatedInfo:Object - * @type_function_param1_field value:Object - * @type_function_param1_field validationRules:Array - * @type_function_param1_field brokenRule:RequiredRule|NumericRule|RangeRule|StringLengthRule|CustomRule|CompareRule|PatternRule|EmailRule|AsyncRule - * @type_function_param1_field brokenRules:Array - * @type_function_param1_field status:Enums.ValidationStatus + * @type_function_param1 validatedInfo:{ui/validator:ValidatedEvent} * @action * @public */ @@ -198,3 +222,31 @@ export type Properties = dxValidatorOptions; /** @deprecated use Properties instead */ export type Options = dxValidatorOptions; + +///#DEBUG +// eslint-disable-next-line import/first +import { CheckedEvents } from '../core'; + +type EventsIntegrityCheckingHelper = CheckedEvents, 'onValidated'>; + +/** +* @hidden +*/ +type Events = { +/** + * @docid dxValidatorOptions.onDisposing + * @type_function_param1 e:{ui/validator:DisposingEvent} + */ +onDisposing?: ((e: DisposingEvent) => void); +/** + * @docid dxValidatorOptions.onInitialized + * @type_function_param1 e:{ui/validator:InitializedEvent} + */ +onInitialized?: ((e: InitializedEvent) => void); +/** + * @docid dxValidatorOptions.onOptionChanged + * @type_function_param1 e:{ui/validator:OptionChangedEvent} + */ +onOptionChanged?: ((e: OptionChangedEvent) => void); +}; +///#ENDDEBUG diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index 08cde15f679e..3c9672dc6390 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -30749,21 +30749,54 @@ declare module DevExpress.ui { validate(): DevExpress.ui.dxValidator.ValidationResult; } module dxValidator { + /** + * [descr:_ui_validator_DisposingEvent] + */ export type DisposingEvent = DevExpress.common.core.events.EventInfo; + /** + * [descr:_ui_validator_InitializedEvent] + */ export type InitializedEvent = DevExpress.common.core.events.InitializedEventInfo; + /** + * [descr:_ui_validator_OptionChangedEvent] + */ export type OptionChangedEvent = DevExpress.common.core.events.EventInfo & DevExpress.common.core.events.ChangedOptionInfo; export type Properties = dxValidatorOptions; + /** + * [descr:_ui_validator_ValidatedEvent] + */ export type ValidatedEvent = { + /** + * [descr:_ui_validator_ValidatedEvent.name] + */ name?: string; + /** + * [descr:_ui_validator_ValidatedEvent.isValid] + */ isValid?: boolean; + /** + * [descr:_ui_validator_ValidatedEvent.value] + */ value?: any; + /** + * [descr:_ui_validator_ValidatedEvent.validationRules] + */ validationRules?: Array; + /** + * [descr:_ui_validator_ValidatedEvent.brokenRule] + */ brokenRule?: DevExpress.common.ValidationRule; - brokenRules?: DevExpress.common.ValidationRule; + /** + * [descr:_ui_validator_ValidatedEvent.brokenRules] + */ + brokenRules?: Array; + /** + * [descr:_ui_validator_ValidatedEvent.status] + */ status?: DevExpress.common.ValidationStatus; }; export type ValidationResult = dxValidatorResult;