// // 假设 FieldPolicyCollection 和 TipAdorner 等类型的定义 // interface FieldPolicy { // Run(d: any, message: string): void; // } // interface FieldPolicyCollection { // [index: number]: FieldPolicy; // } // // 定义焦点管理器实例接口 // interface FocusManagerInstance { // IsFocusContinue: boolean; // } // // 焦点管理器类 // class FocusManager { // // 模拟获取焦点管理器实例 // static GetManagerInstance(d: any): FocusManagerInstance | null { // return { IsFocusContinue: true }; // } // // 模拟添加焦点丢失事件处理程序 // static AddPreviewLostFocusHandler(d: any, handler: (sender: any, args: any) => void) { // if (d.addEventListener) { // d.addEventListener('blur', handler); // } // } // // 模拟移除焦点丢失事件处理程序 // static RemovePreviewLostFocusHandler(d: any, handler: (sender: any, args: any) => void) { // if (d.removeEventListener) { // d.removeEventListener('blur', handler); // } // } // } // // 焦点管理器扩展类 // class FocusManagerExt { // // 定义静态属性 // static AssertNotEmptyProperty = Symbol('AssertNotEmpty'); // static RegexValidationProperty = Symbol('RegexValidation'); // static RegexValidateErrorInfoProperty = Symbol('RegexValidateErrorInfo'); // static ValidationFieldProperty = Symbol('ValidationField'); // static FieldEmptyPoliciesProperty = Symbol('FieldEmptyPolicies'); // static RegexValidateErrorPoliciesProperty = Symbol('RegexValidateErrorPolicies'); // static IsFocusAdornerProperty = Symbol('IsFocusAdorner'); // // Getter 和 Setter 方法 // static GetAssertNotEmpty(d: any): boolean { // return d[this.AssertNotEmptyProperty] || false; // } // static SetAssertNotEmpty(d: any, value: boolean) { // d[this.AssertNotEmptyProperty] = value; // this.OnAssertNotEmptyChanged(d, value); // } // static GetRegexValidation(d: any): string { // return d[this.RegexValidationProperty] || ''; // } // static SetRegexValidation(d: any, value: string) { // d[this.RegexValidationProperty] = value; // this.OnRegexValidationChanged(d, value); // } // static GetRegexValidateErrorInfo(d: any): string { // return d[this.RegexValidateErrorInfoProperty] || ''; // } // static SetRegexValidateErrorInfo(d: any, value: string) { // d[this.RegexValidateErrorInfoProperty] = value; // } // static GetValidationField(d: any): string { // return d[this.ValidationFieldProperty] || ''; // } // static SetValidationField(d: any, value: string) { // d[this.ValidationFieldProperty] = value; // } // static GetFieldEmptyPolicies(d: any): FieldPolicyCollection | null { // return d[this.FieldEmptyPoliciesProperty] || null; // } // static SetFieldEmptyPolicies(d: any, value: FieldPolicyCollection) { // d[this.FieldEmptyPoliciesProperty] = value; // } // static GetRegexValidateErrorPolicies(d: any): FieldPolicyCollection | null { // return d[this.RegexValidateErrorPoliciesProperty] || null; // } // static SetRegexValidateErrorPolicies(d: any, value: FieldPolicyCollection) { // d[this.RegexValidateErrorPoliciesProperty] = value; // } // static GetIsFocusAdorner(d: any): boolean { // return d[this.IsFocusAdornerProperty] || false; // } // static SetIsFocusAdorner(d: any, value: boolean) { // d[this.IsFocusAdornerProperty] = value; // } // // 属性变化处理方法 // private static OnAssertNotEmptyChanged(d: any, newValue: boolean) { // if (newValue) { // FocusManager.AddPreviewLostFocusHandler(d, this.handler); // } else { // FocusManager.RemovePreviewLostFocusHandler(d, this.handler); // } // } // private static handler = (sender: any, args: any) => { // const d = sender; // const focus = FocusManager.GetManagerInstance(d); // if (!focus) return; // const propertyName = this.GetValidationField(d); // if (!propertyName) return; // const propertyInfo = d[propertyName]; // if (propertyInfo) { // const strValue = String(propertyInfo); // if (strValue.trim() !== '') return; // } // const fieldEmptyPolicies = this.GetFieldEmptyPolicies(d); // if (fieldEmptyPolicies) { // for (const policy of fieldEmptyPolicies) { // policy.Run(d, '该输入要素不能为空'); // } // } // focus.IsFocusContinue = false; // args.preventDefault(); // }; // private static OnRegexValidationChanged(dp: any, newRegexValidation: string) { // const handler = (sender: any, args: any) => { // const d = sender; // const focus = FocusManager.GetManagerInstance(d); // if (!focus) return; // const propertyName = this.GetValidationField(d); // if (!propertyName) return; // const propertyInfo = d[propertyName]; // if (!propertyInfo) return; // const strValue = String(propertyInfo); // if (!this.GetAssertNotEmpty(d) && strValue === '') return; // const reg = this.GetRegexValidation(d); // if (!reg) return; // const regex = new RegExp(reg); // if (regex.test(strValue)) return; // const fieldPolicies = this.GetFieldEmptyPolicies(d); // let regexValidateErrorInfo = this.GetRegexValidateErrorInfo(d); // if (!regexValidateErrorInfo) { // regexValidateErrorInfo = `输入场要求输入值满足正则表达式:${reg},输入值:${strValue}不满足此要求!`; // } // if (fieldPolicies) { // for (const policy of fieldPolicies) { // policy.Run(d, regexValidateErrorInfo); // } // } // focus.IsFocusContinue = false; // args.preventDefault(); // }; // if (newRegexValidation) { // FocusManager.AddPreviewLostFocusHandler(dp, handler); // } else { // FocusManager.RemovePreviewLostFocusHandler(dp, handler); // } // } // } // export default FocusManagerExt; //焦点控制TODO后续处理