<commit_before>import R from 'ramda';
import React from 'react';
import Widgets from './inspectorWidgets';
import {
  ENTITY,
  PROPERTY_TYPE,
  PROPERTY_KIND,
  PROPERTY_MODE,
  PIN_DIRECTION,
} from 'xod-core/project/constants';

const widgetAccordance = {
  [ENTITY.NODE]: {
    [PROPERTY_TYPE.BOOL]: Widgets.BoolWidget,
    [PROPERTY_TYPE.NUMBER]: Widgets.NumberWidget,
    [PROPERTY_TYPE.STRING]: Widgets.StringWidget,
    [PROPERTY_TYPE.PULSE]: Widgets.NumberWidget,
    // [PROPERTY_TYPE.IO_LABEL]: Widgets.IOLabelWidget, // @TODO: use special field widget
  },
};

const labelProp = {
  kind: PROPERTY_KIND.PROP,
  mode: PROPERTY_MODE.PROP,
  key: 'label',
  label: 'Label',
  type: 'string',
  value: '',
};
const pinProp = {
  kind: PROPERTY_KIND.PROP,
  mode: PROPERTY_MODE.PROP,
  key: 'pin',
  label: 'Pin',
  type: 'string',
  value: '',
};

const getProp = (obj, node, key) => R.pipe(
  R.pathOr('', ['properties', key]),
  R.assoc('value', R.__, {}), // eslint-disable-line
  R.merge(obj)
)(node);

class Inspector extends React.Component {
  constructor(props) {
    super(props);

    this.createWidgets(props);
  }

  componentWillUpdate(nextProps) {
    this.createWidgets(nextProps);
  }

  getProperties(nodeType, node) {
    const props = [
      getProp(labelProp, node, 'label'),
    ];

    if (nodeType.category === 'hardware') {
      props.push(
        getProp(pinProp, node, 'pin')
      );
    }

    return props;
  }

  getPins(nodeType, node) {<commit_msg>fix(props): returned a customizable props in the nodes/meta<commit_after>import R from 'ramda';
import React from 'react';
import Widgets from './inspectorWidgets';
import {
  ENTITY,
  PROPERTY_TYPE,
  PROPERTY_KIND,
  PROPERTY_MODE,
  PIN_DIRECTION,
} from 'xod-core/project/constants';

const widgetAccordance = {
  [ENTITY.NODE]: {
    [PROPERTY_TYPE.BOOL]: Widgets.BoolWidget,
    [PROPERTY_TYPE.NUMBER]: Widgets.NumberWidget,
    [PROPERTY_TYPE.STRING]: Widgets.StringWidget,
    [PROPERTY_TYPE.PULSE]: Widgets.NumberWidget,
    // [PROPERTY_TYPE.IO_LABEL]: Widgets.IOLabelWidget, // @TODO: use special field widget
  },
};

const defaultProp = {
  kind: PROPERTY_KIND.PROP,
  mode: PROPERTY_MODE.PROP,
  type: 'string',
  value: '',
};

const labelProp = {
  kind: PROPERTY_KIND.PROP,
  mode: PROPERTY_MODE.PROP,
  key: 'label',
  label: 'Label',
  type: 'string',
  value: '',
};

const getProp = (obj, node, key) => R.pipe(
  R.pathOr('', ['properties', key]),
  R.assoc('value', R.__, {}), // eslint-disable-line
  R.merge(obj)
)(node);

class Inspector extends React.Component {
  constructor(props) {
    super(props);

    this.createWidgets(props);
  }

  componentWillUpdate(nextProps) {
    this.createWidgets(nextProps);
  }

  getProperties(nodeType, node) {
    const props = [
      getProp(labelProp, node, 'label'),
    ];

    if (nodeType.properties) {
      R.pipe(
        (c) => { console.log('NT', c); return c; },
        R.values,
        R.map(R.merge(defaultProp)),
        (c) => { console.log('NT', c); return c; },
        R.forEach(prop => props.push(prop))
      )(nodeType.properties);
    }

    return props;
  }

  getPins(nodeType, node) {
{'fraction_non_alphanumeric': 0.15668348045397226, 'fraction_numerical': 0.0, 'mean_word_length': 3.4943342776203967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, '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': '1207693', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1139, 'n_words': 224}