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    
@skava/ui / src / components / molecules / ProductOptions / state / fromSelectionToAttributes.js
Size: Mime:
"use strict";

var __importDefault = this && this.__importDefault || function (mod) {
  return mod && mod.__esModule ? mod : {
    "default": mod
  };
};

Object.defineProperty(exports, "__esModule", {
  value: true
});
/* eslint-disable max-statements */

const makeMultiState_1 = __importDefault(require("./makeMultiState"));

const fromSelectionToAttributes = (props, name) => {
  let {
    /**
     * @todo @fixme - does not need to be like this!!!
     * @description defaults
     */
    list = [],
    type
  } = props;
  /**
   * @fixme - should be done in data  later
   */

  if (type === 'fit' || type === 'style1') {
    type = 'style';
  }

  const state = makeMultiState_1.default(name); // selectableOptions.fit

  const selectedForType = list[type];
  const shouldBeSelected = selectedForType === name; // selectedForType.includes(name)

  const shouldBeDisabled = false;

  if (shouldBeSelected) {
    state.select();
  } else if (shouldBeDisabled) {
    state.disable();
  }
  /**
   * @todo this logic is very confusing
   * @todo @deepak #help
   */


  return state;
};

exports.fromSelectionToAttributes = fromSelectionToAttributes;
exports.default = fromSelectionToAttributes; //# sourceMappingURL=fromSelectionToAttributes.js.map