Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const tslib_1 = require("tslib");

const exotic_1 = require("exotic");

const utils_1 = require("@skava/utils");

const classnames_1 = tslib_1.__importDefault(require("classnames"));

function toClassList(props, state) {
  const className = classnames_1.default(props.className, {
    selected: props.isSelected,
    select: true,
    'input-error': state.isValidInput === false
  });
  return className;
}

exports.toClassList = toClassList;

function toOnChange(props) {
  return props.onDropDownStateChange || props.onChange || props.onChangeValue;
}

exports.toOnChange = toOnChange;

function toList(props) {
  // if elseif if
  if (exotic_1.isArray(props.list) === true) {
    return props.list;
  } else if (exotic_1.isArray(props.options) === true) {
    return props.options;
  } else {
    return exotic_1.EMPTY_ARRAY;
  }
}

exports.toList = toList;
const omitList = ['list', 'options', 'onDropDownStateChange', 'onChangeValue', 'onChange', 'className', 'isActive'];
Object.freeze(omitList);

function toAccessibleAttributes(props, state) {
  // aria-haspopup="listbox"
  // aria-activedescendant="exp_elem_Cm"
  // aria-expanded="true"
  // tabindex="-1"
  // @todo .attributes
  return '@@todo';
}

exports.toAccessibleAttributes = toAccessibleAttributes;

function toAttributes(props, state) {
  return {
    onChange: toOnChange(props),
    list: toList(props),
    className: toClassList(props, state),
    passthroughProps: utils_1.omit(props, omitList)
  };
}

exports.toAttributes = toAttributes;

function defaultRenderEmpty(props, state) {
  console.warn('SelectDropDown received no dropdowns');
  return '';
}

exports.defaultRenderEmpty = defaultRenderEmpty;

function toText(props, state) {
  const text = // @todo :: @james @sri label is not getting update onChange(), renderActiveItem prop
  props.label || props.value || props.children || ''; // try on props, then try on state

  if (!text && exotic_1.isObj(state) && arguments.length === 2) {
    return toText(state);
  } else {
    return String(text);
  }
}

exports.toText = toText;
exports.default = {
  toClassList,
  toOnChange,
  toList,
  toAccessibleAttributes,
  toAttributes,
  defaultRenderEmpty
}; //# sourceMappingURL=_deps.js.map