<commit_before>import * as React from "react";
import {
  SurveyQuestion,
  ISurveyCreator,
  SurveyElementErrors
} from "./reactquestion";
import { PageModel } from "../page";
import { SurveyModel } from "../survey";
import { QuestionRowModel, PanelModel } from "../panel";
import { QuestionBase } from "../questionbase";
import { SurveyElementBase } from "./reactquestionelement";

export class SurveyPage extends React.Component<any, any> {
  private page: PageModel;
  private survey: SurveyModel;
  private creator: ISurveyCreator;
  protected css: any;
  constructor(props: any) {
    super(props);
    this.page = props.page;
    this.survey = props.survey;
    this.creator = props.creator;
    this.css = props.css;
  }
  componentWillReceiveProps(nextProps: any) {
    this.page = nextProps.page;
    this.survey = nextProps.survey;
    this.creator = nextProps.creator;
    this.css = nextProps.css;
  }
  componentDidMount() {
    this.doAfterRender();
  }
  componentDidUpdate(prevProps, prevState) {
    this.doAfterRender();
  }
  private doAfterRender() {
    var el = this.refs["root"];
    if (el && this.survey) this.survey.afterRenderPage(el);
  }
  render(): JSX.Element {
    if (this.page == null || this.survey == null || this.creator == null)
      return null;
    var title = this.renderTitle();
    var description = this.renderDescription();
    var rows = [];
    var questionRows = this.page.rows;
    var self = this;
    for (var i = 0; i < questionRows.length; i++) {
      var row = questionRows[i];
      row.visibilityChangedCallback = function() {
        self.forceUpdate();
      };

      rows.push(this.createRow(questionRows[i], i));
    }
    return (
      <div ref="root" className={this.css.page.root}>
        {title}
        {description}
        {rows}
      </div>
    );
  }
  protected createRow(row: QuestionRowModel, index: number): JSX.Element {
    var rowName = "row" + (index + 1);
    return (
      <SurveyRow
        key={rowName}
        row={row}
        survey={this.survey}
        creator={this.creator}
        css={this.css}
      />
    );
  }
  protected renderTitle(): JSX.Element {
    if (!this.page.title || !this.survey.showPageTitles) return null;
    var text = SurveyElementBase.renderLocString(this.page.locTitle);
    return <h4 className={this.css.pageTitle}>{text}</h4>;
  }
  protected renderDescription(): JSX.Element {
    if (!this.page.description || !this.survey.showPageTitles) return null;
    var text = SurveyElementBase.renderLocString(this.page.locDescription);
    return <div className={this.css.pageDescription}>{text}</div>;
  }
}

export class SurveyPanel extends React.Component<any, any> {
  private panel: PanelModel;
  private survey: SurveyModel;
  private creator: ISurveyCreator;
  protected css: any;
  constructor(props: any) {
    super(props);
    this.panel = props.panel;
    this.survey = props.survey;
    this.creator = props.creator;
    this.css = props.css;
    this.state = { modelChanged: 0 };
  }
  componentWillReceiveProps(nextProps: any) {
    this.panel = nextProps.panel;
    this.survey = nextProps.survey;
    this.creator = nextProps.creator;
    this.css = nextProps.css;
  }
  componentDidMount() {
    let self = this;
    this.doAfterRender();
    this.panel.registerFunctionOnPropertiesValueChanged(
      ["isVisible", "renderWidth", "innerIndent", "rightIndent"],
      function() {
        self.setState({ modelChanged: self.state.modelChanged + 1 });
      },
      "react"
    );
  }
  componentDidUpdate(prevProps, prevState) {
    this.doAfterRender();
  }
  private doAfterRender() {
    let el = this.refs["root"];
    if (el && this.survey) {
      this.survey.afterRenderPanel(this.panel, el);
    }
  }
  componentWillUnmount() {
    if (this.panel) {
      this.panel.unRegisterFunctionOnPropertiesValueChanged(
        ["isVisible", "renderWidth", "innerIndent", "rightIndent"],
        "react"
      );
    }
  }
  render(): JSX.Element {
    if (this.panel == null || this.survey == null || this.creator == null)
      return null;<commit_msg>fix the bug: panel should expand on showing errors in questions in it, for versions: angular, jquery, react: https://github.com/surveyjs/surveyjs/issues/823<commit_after>import * as React from "react";
import {
  SurveyQuestion,
  ISurveyCreator,
  SurveyElementErrors
} from "./reactquestion";
import { PageModel } from "../page";
import { SurveyModel } from "../survey";
import { QuestionRowModel, PanelModel } from "../panel";
import { QuestionBase } from "../questionbase";
import { SurveyElementBase } from "./reactquestionelement";

export class SurveyPage extends React.Component<any, any> {
  private page: PageModel;
  private survey: SurveyModel;
  private creator: ISurveyCreator;
  protected css: any;
  constructor(props: any) {
    super(props);
    this.page = props.page;
    this.survey = props.survey;
    this.creator = props.creator;
    this.css = props.css;
  }
  componentWillReceiveProps(nextProps: any) {
    this.page = nextProps.page;
    this.survey = nextProps.survey;
    this.creator = nextProps.creator;
    this.css = nextProps.css;
  }
  componentDidMount() {
    this.doAfterRender();
  }
  componentDidUpdate(prevProps, prevState) {
    this.doAfterRender();
  }
  private doAfterRender() {
    var el = this.refs["root"];
    if (el && this.survey) this.survey.afterRenderPage(el);
  }
  render(): JSX.Element {
    if (this.page == null || this.survey == null || this.creator == null)
      return null;
    var title = this.renderTitle();
    var description = this.renderDescription();
    var rows = [];
    var questionRows = this.page.rows;
    var self = this;
    for (var i = 0; i < questionRows.length; i++) {
      var row = questionRows[i];
      row.visibilityChangedCallback = function() {
        self.forceUpdate();
      };

      rows.push(this.createRow(questionRows[i], i));
    }
    return (
      <div ref="root" className={this.css.page.root}>
        {title}
        {description}
        {rows}
      </div>
    );
  }
  protected createRow(row: QuestionRowModel, index: number): JSX.Element {
    var rowName = "row" + (index + 1);
    return (
      <SurveyRow
        key={rowName}
        row={row}
        survey={this.survey}
        creator={this.creator}
        css={this.css}
      />
    );
  }
  protected renderTitle(): JSX.Element {
    if (!this.page.title || !this.survey.showPageTitles) return null;
    var text = SurveyElementBase.renderLocString(this.page.locTitle);
    return <h4 className={this.css.pageTitle}>{text}</h4>;
  }
  protected renderDescription(): JSX.Element {
    if (!this.page.description || !this.survey.showPageTitles) return null;
    var text = SurveyElementBase.renderLocString(this.page.locDescription);
    return <div className={this.css.pageDescription}>{text}</div>;
  }
}

export class SurveyPanel extends React.Component<any, any> {
  private panel: PanelModel;
  private survey: SurveyModel;
  private creator: ISurveyCreator;
  protected css: any;
  constructor(props: any) {
    super(props);
    this.panel = props.panel;
    this.survey = props.survey;
    this.creator = props.creator;
    this.css = props.css;
    this.state = { modelChanged: 0 };
  }
  componentWillReceiveProps(nextProps: any) {
    this.panel = nextProps.panel;
    this.survey = nextProps.survey;
    this.creator = nextProps.creator;
    this.css = nextProps.css;
  }
  componentDidMount() {
    let self = this;
    this.doAfterRender();
    this.panel.registerFunctionOnPropertiesValueChanged(
      ["isVisible", "renderWidth", "innerIndent", "rightIndent", "state"],
      function() {
        self.setState({ modelChanged: self.state.modelChanged + 1 });
      },
      "react"
    );
  }
  componentDidUpdate(prevProps, prevState) {
    this.doAfterRender();
  }
  private doAfterRender() {
    let el = this.refs["root"];
    if (el && this.survey) {
      this.survey.afterRenderPanel(this.panel, el);
    }
  }
  componentWillUnmount() {
    if (this.panel) {
      this.panel.unRegisterFunctionOnPropertiesValueChanged(
        ["isVisible", "renderWidth", "innerIndent", "rightIndent", "state"],
        "react"
      );
    }
  }
  render(): JSX.Element {
    if (this.panel == null || this.survey == null || this.creator == null)
      return null;
{'fraction_non_alphanumeric': 0.13750149718529164, 'fraction_numerical': 0.0017966223499820337, 'mean_word_length': 3.105211406096362, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5796484', 'n_tokens_mistral': 2636, 'n_tokens_neox': 2622, 'n_words': 559}