Repository URL to install this package:
|
Version:
1.2.6 ▾
|
@skava/modules
/
___dist
/
view-container
/
styles
/
styled-components
/
src
/
models
/
InlineStyle.js
|
|---|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.resetStyleCache = void 0;
var _index = require("../../../../../chain-able/index.js");
var _flatten = _interopRequireDefault(require("../utils/flatten"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @todo - improve parsing of ssr here for optimize when needed
*/
/* eslint-disable import/no-unresolved */
// import transformDeclPairs from 'css-to-react-native'
//
// import hashStr from '../vendor/glamor/hash'
let generated = {};
const resetStyleCache = () => {
generated = {};
};
/*
InlineStyle takes arbitrary CSS and generates a flat object
*/
exports.resetStyleCache = resetStyleCache;
var _default = styleSheet => {
let InlineStyle = class InlineStyle {
constructor(rules) {
this.rules = void 0;
this.rules = rules;
}
generateStyleObject(executionContext) {
const flatCSS = (0, _flatten.default)(this.rules, executionContext).join('');
const hash = (0, _index.fliphash)(flatCSS); // console.log({ flatCSS })
console.log('FIX_SSR_REMOVE_POSTCSS');
return '';
if (!generated[hash]) {
generated[hash] = flatCSS; // const root = parse(flatCSS)
// const declPairs = []
// root.each(node => {
// if (node.type === 'decl') {
// declPairs.push([node.prop, node.value])
// } else if (
// node.type !== 'comment' &&
// process.env.NODE_ENV !== 'production'
// ) {
// /* eslint-disable no-console */
// console.warn(
// `Node of type ${node.type} not supported as an inline style`
// )
// }
// })
// RN currently does not support differing values for the corner radii of Image
// components (but does for View). It is almost impossible to tell whether we'll have
// support, so we'll just disable multiple values here.
// https://github.com/styled-components/css-to-react-native/issues/11
// const styleObject = transformDeclPairs(declPairs, [
// 'borderRadius',
// 'borderWidth',
// 'borderColor',
// 'borderStyle',
// ])
// const styles = styleSheet.create({
// generated: styleObject,
// })
// generated[hash] = styles.generated
// generated[hash] = declPairs
}
return generated[hash];
}
};
return InlineStyle;
};
exports.default = _default;