CyclicMaterials/molecule-input

View on GitHub
src/InputCharCounter/index.js

Summary

Maintainability
A
3 hrs
Test Coverage
import cuid from 'cuid';
import model from './model';
import props from './props';
import view from './view';
import {clone} from 'ramda';
import {predicateObjectOfObservable} from './../shared/predicate';

const COMPONENT_NAME = `molecule-InputCharCounter`;

function InputCharCounter(sources) {
  const props$ = predicateObjectOfObservable(props)(sources.props$);
  const id = cuid();
  const state$ = model({props$, componentName: COMPONENT_NAME});

  return {
    DOM: view({state$, id}),
    id,
    state$: state$.map((state) => clone(state)),
  };
}

export {COMPONENT_NAME};

export default InputCharCounter;