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/modules / ___dist / view-container / styles / styled-components / src / utils / extractCompsFromCSS.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
// @flow
const SC_COMPONENT_ID = /^[^\S\n]*?\/\* sc-component-id:\s*(\S+)\s+\*\//gm;

var _default = maybeCSS => {
  const css = `${maybeCSS || ''}`;
  const existingComponents = [];
  css.replace(SC_COMPONENT_ID, (match, componentId, matchIndex) => {
    existingComponents.push({
      componentId,
      matchIndex
    });
    return match;
  }); // @todo
  // return existingComponents.map((existing, i) => {
  //   const { componentId, matchIndex } = existing

  return existingComponents.map(({
    componentId,
    matchIndex
  }, i) => {
    const nextComp = existingComponents[i + 1];
    const cssFromDOM = nextComp ? css.slice(matchIndex, nextComp.matchIndex) : css.slice(matchIndex);
    return {
      componentId,
      cssFromDOM
    };
  });
};

exports.default = _default;