var _excluded = ["children"];
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
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