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

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

const tslib_1 = require("tslib");
/* eslint-disable max-statements */


const makeMultiState_1 = tslib_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