123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- // // 假设 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后续处理
|