UNPKG

elliptical-string

Version:

Lacona Phrase for strings - a loose wrapper for <freetext />

49 lines (39 loc) 1.11 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.String = undefined; var _elliptical = require('elliptical'); var defaultProps = { label: 'string', limit: 1, trimmed: true }; /** @jsx createElement */ function describe(_ref) { var props = _ref.props; return (0, _elliptical.createElement)( 'placeholder', { label: props.label, arguments: props.phraseArguments || (props.phraseArguments ? [props.phraseArgument] : [props.label]) }, (0, _elliptical.createElement)('freetext', { greedy: props.greedy, consumeAll: props.consumeAll, splitOn: props.splitOn, trimmed: props.trimmed, filter: function filter(input) { return _filter(input, props); }, limit: props.limit }) ); } function _filter(input, props) { if (props.trimmed && (/^\s/.test(input) || /\s$/.test(input))) { return false; } if (props.filter) { return props.filter(input); } return true; } var String = exports.String = { defaultProps: defaultProps, describe: describe, id: 'elliptical-string:String' };