Repository: DevExpress/devextreme-react
Pull request #534 (2021-04-13 10:21:50)

Change independent events filter
Change independent events filter
Eslint fixes


Patch:
diff --git a/packages/devextreme-react-generator/src/generator.ts b/packages/devextreme-react-generator/src/generator.ts
index 24ad2c7..4cf565f 100644
--- a/packages/devextreme-react-generator/src/generator.ts
+++ b/packages/devextreme-react-generator/src/generator.ts
@@ -138,7 +138,7 @@ export function collectIndependentEvents(options: IProp[]): IProp[] {
     if (option.types.filter((type) => type.type === 'Function').length === 1
         && (!option.firedEvents || option.firedEvents.length === 0)
         && option.name.substr(0, 2) === 'on'
-        && option.name !== 'onOptionChanged'
+        && !option.name.endsWith('Changed')
     ) {
       acc.push(option);
     }
diff --git a/packages/sandbox/drawer-example.tsx b/packages/sandbox/drawer-example.tsx
index 71dfe27..7ab732b 100644
--- a/packages/sandbox/drawer-example.tsx
+++ b/packages/sandbox/drawer-example.tsx
@@ -31,6 +31,26 @@ class App extends React.Component<any, {
     this.onMenuClick = this.onMenuClick.bind(this);
   }
 
+  onOpenedStateModeChanged({ value }) {
+    this.setState({ openedStateMode: value });
+  }
+
+  onRevealModeChanged({ value }) {
+    this.setState({ revealMode: value });
+  }
+
+  onPositionChanged({ value }) {
+    this.setState({ position: value });
+  }
+
+  onOutsideClick() {
+    this.setState({ opened: false });
+  }
+
+  onMenuClick() {
+    this.setState((prevState) => ({ opened: !prevState }));
+  }
+
   render() {
     const {
       opened, openedStateMode, position, revealMode,
@@ -103,26 +123,6 @@ class App extends React.Component<any, {
       </Example>
     );
   }
-
-  onOpenedStateModeChanged({ value }) {
-    this.setState({ openedStateMode: value });
-  }
-
-  onRevealModeChanged({ value }) {
-    this.setState({ revealMode: value });
-  }
-
-  onPositionChanged({ value }) {
-    this.setState({ position: value });
-  }
-
-  onOutsideClick() {
-    this.setState({ opened: false });
-  }
-
-  onMenuClick() {
-    this.setState((prevState) => ({ opened: !prevState }));
-  }
 }
 
 export default App;
diff --git a/packages/sandbox/popup-example.tsx b/packages/sandbox/popup-example.tsx
index a7fc1ee..312bfdb 100644
--- a/packages/sandbox/popup-example.tsx
+++ b/packages/sandbox/popup-example.tsx
@@ -21,16 +21,16 @@ export default class extends React.Component<any, { visible: boolean; text: stri
     this.handleTextUpdate = this.handleTextUpdate.bind(this);
   }
 
-  private toggle(visible: boolean) {
-    const { text } = this.state;
+  private handleTextUpdate(e: unknown) {
     this.setState({
-      visible: visible || !validateText(text),
+      text: e.value,
     });
   }
 
-  private handleTextUpdate(e: any) {
+  private toggle(visible: boolean) {
+    const { text } = this.state;
     this.setState({
-      text: e.value,
+      visible: visible || !validateText(text),
     });
   }
 
diff --git a/packages/sandbox/scroll-view-example.tsx b/packages/sandbox/scroll-view-example.tsx
index 485fe7c..d0a7659 100644
--- a/packages/sandbox/scroll-view-example.tsx
+++ b/packages/sandbox/scroll-view-example.tsx
@@ -17,15 +17,15 @@ export default class extends React.Component<any, { text: string }> {
     this.handleTextChange = this.handleTextChange.bind(this);
   }
 
-  private clearText() {
+  private handleTextChange(e: unknown) {
     this.setState({
-      text: '',
+      text: e.value,
     });
   }
 
-  private handleTextChange(e: any) {
+  private clearText() {
     this.setState({
-      text: e.value,
+      text: '',
     });
   }
 
diff --git a/packages/sandbox/text-box-example.tsx b/packages/sandbox/text-box-example.tsx
index eb57fe4..187a7f9 100644
--- a/packages/sandbox/text-box-example.tsx
+++ b/packages/sandbox/text-box-example.tsx
@@ -21,6 +21,12 @@ export default class extends React.Component<any, { text: string; uncontrolledTe
     this.setFocusToTextBox = this.setFocusToTextBox.bind(this);
   }
 
+  private handleChange(e: unknown) {
+    this.setState({
+      text: `#${(e.value as string).toUpperCase().replace('A', '_')}`,
+    });
+  }
+
   private setFocusToTextBox() {
     this.textBox.focus();
   }
@@ -31,12 +37,6 @@ export default class extends React.Component<any, { text: string; uncontrolledTe
     });
   }
 
-  private handleChange(e: any) {
-    this.setState({
-      text: `#${(e.value as string).toUpperCase().replace('A', '_')}`,
-    });
-  }
-
   public render(): React.ReactNode {
     const { text } = this.state;
     return (


Test patch:
diff --git a/packages/devextreme-react-generator/src/generator.test.ts b/packages/devextreme-react-generator/src/generator.test.ts
index 1a68576..cd4dd2e 100644
--- a/packages/devextreme-react-generator/src/generator.test.ts
+++ b/packages/devextreme-react-generator/src/generator.test.ts
@@ -26,7 +26,8 @@ describe('collectIndependentEvents', () => {
         ],
         props: [],
         firedEvents: ['func1'],
-      }, {
+      },
+      {
         name: 'onOption',
         isSubscribable: false,
         types: [
@@ -38,7 +39,8 @@ describe('collectIndependentEvents', () => {
         ],
         props: [],
         firedEvents: [],
-      }, {
+      },
+      {
         name: 'option3',
         isSubscribable: true,
         types: [
@@ -55,7 +57,8 @@ describe('collectIndependentEvents', () => {
         ],
         props: [],
         firedEvents: [],
-      }, {
+      },
+      {
         name: 'onOption4',
         isSubscribable: true,
         types: [
@@ -72,7 +75,8 @@ describe('collectIndependentEvents', () => {
         ],
         props: [],
         firedEvents: ['func1'],
-      }, {
+      },
+      {
         name: 'option5',
         isSubscribable: true,
         types: [
@@ -91,7 +95,7 @@ describe('collectIndependentEvents', () => {
         firedEvents: [],
       },
       {
-        name: 'onOptionChanged',
+        name: 'onSomeOptionChanged',
         isSubscribable: true,
         types: [
           {
@@ -103,10 +107,42 @@ describe('collectIndependentEvents', () => {
         props: [],
         firedEvents: [],
       },
+      {
+        name: 'onSomeOptionChange',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
+      {
+        name: 'onSomeOptionChanged',
+        isSubscribable: true,
+        types: [
+          {
+            type: 'Function',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+          {
+            type: 'Number',
+            acceptableValues: [],
+            isCustomType: true,
+          },
+        ],
+        props: [],
+        firedEvents: [],
+      },
     ];
     const independentEvents = collectIndependentEvents(options);
-    expect(independentEvents.length).toBe(1);
+    expect(independentEvents.length).toBe(2);
     expect(independentEvents[0]).toEqual(options[1]);
+    expect(independentEvents[1]).toEqual(options[6]);
   });
 });