var _excluded = ["children"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import { isEmpty } from 'ramda';
import { useBuffer } from './Buffer';

/* TYPES */

/**
 * @deprecatedSince 9
 * @deprecated Never officially documented/supported
 */

/**
 * @deprecatedSince 9
 * @deprecated Never officially documented/supported
 */

/**
 * @deprecatedSince 9
 * @deprecated Never officially documented/supported
 */

/* HOOK */
/**
 * @deprecatedSince 9.7.0
 * @deprecated A wrapper around useBuffer (deprecated) that would also call onChange. A trivial hook for storing a string. Write your own or use a hook utility lib.
 * 
 * **Source:**
 * ```
export function useTextEntry({
  initialValue = '',
  onChange = () => {},
}) {
  const { value, update, clear, reset } = useBuffer({ initialValue })

  return {
    clear: () => {
      onChange({ target: { value: '' } })
      clear()
    },
    empty: Ramda.isEmpty(value),
    onChange: (event) => {
      onChange(event)
      update(event.target.value)
    },
    reset: () => {
      onChange({ target: { value } })
      reset()
    },
    value,
  }
}
```
 */
export function useTextEntry(_ref) {
  var _ref$initialValue = _ref.initialValue,
    initialValue = _ref$initialValue === void 0 ? '' : _ref$initialValue,
    _ref$onChange = _ref.onChange,
    _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
  var _useBuffer = useBuffer({
      initialValue: initialValue
    }),
    value = _useBuffer.value,
    update = _useBuffer.update,
    _clear = _useBuffer.clear,
    _reset = _useBuffer.reset;
  return {
    clear: function clear() {
      _onChange({
        target: {
          value: ''
        }
      });
      _clear();
    },
    empty: isEmpty(value),
    onChange: function onChange(event) {
      _onChange(event);
      update(event.target.value);
    },
    reset: function reset() {
      _onChange({
        target: {
          value: value
        }
      });
      _reset();
    },
    value: value
  };
}

/* RENDER PROP */
/**
 * @deprecatedSince 9.7.0
 * @deprecated
 */
export function TextEntry(_ref2) {
  var children = _ref2.children,
    props = _objectWithoutProperties(_ref2, _excluded);
  var textEntry = useTextEntry(props);
  return typeof children === 'function' ? children(textEntry) : children;
}
//# sourceMappingURL=TextEntry.js.map