@patternfly/react-styles 2.3.6 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/esm/build/util.js +1 -1
- package/dist/js/StyleSheet.d.ts +5 -2
- package/dist/js/build/util.js +1 -1
- package/dist/umd/StyleSheet.js +98 -0
- package/dist/umd/build/babel/index.js +31 -0
- package/dist/umd/build/babel/plugin.js +167 -0
- package/dist/umd/build/jest/snapshot-serializer/cssPropertyOverrides.js +71 -0
- package/dist/umd/build/jest/snapshot-serializer/cssUtils.js +161 -0
- package/dist/umd/build/jest/snapshot-serializer/index.js +37 -0
- package/dist/umd/build/jest/snapshot-serializer/reactUtils.js +51 -0
- package/dist/umd/build/jest/snapshot-serializer/serializer.js +52 -0
- package/dist/umd/build/jest/transform.js +35 -0
- package/dist/umd/build/loader/index.js +23 -0
- package/dist/umd/build/util.js +94 -0
- package/dist/umd/index.js +61 -0
- package/dist/umd/server.js +24 -0
- package/dist/umd/utils.js +83 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,50 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# 2.4.0 (2019-03-18)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **Dropdown:** fix d.ts file to make props optional ([#1593](https://github.com/patternfly/patternfly-react/issues/1593)) ([a2c6645](https://github.com/patternfly/patternfly-react/commit/a2c6645)), closes [#1584](https://github.com/patternfly/patternfly-react/issues/1584)
|
12
|
+
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* **umd:** add umd for styles, tokens, and icons ([#1599](https://github.com/patternfly/patternfly-react/issues/1599)) ([4ca1a5c](https://github.com/patternfly/patternfly-react/commit/4ca1a5c))
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## 2.3.9 (2019-03-14)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @patternfly/react-styles
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
## 2.3.8 (2019-03-13)
|
31
|
+
|
32
|
+
**Note:** Version bump only for package @patternfly/react-styles
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
## 2.3.7 (2019-03-11)
|
39
|
+
|
40
|
+
|
41
|
+
### Bug Fixes
|
42
|
+
|
43
|
+
* **build:** Support running the test suite under Windows ([#1255](https://github.com/patternfly/patternfly-react/issues/1255)) [ci skip] ([851756e](https://github.com/patternfly/patternfly-react/commit/851756e))
|
44
|
+
* **tsconfig:** avatar tsx change ([#1535](https://github.com/patternfly/patternfly-react/issues/1535)) ([8107f5c](https://github.com/patternfly/patternfly-react/commit/8107f5c))
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
6
50
|
## 2.3.6 (2019-03-08)
|
7
51
|
|
8
52
|
**Note:** Version bump only for package @patternfly/react-styles
|
package/dist/esm/build/util.js
CHANGED
@@ -38,7 +38,7 @@ export function writeCSSJSFile(rootPath, originalPath, destinationPath, contents
|
|
38
38
|
|
39
39
|
export function getRelativeImportPath(from, to) {
|
40
40
|
var parsedTo = path.parse(to);
|
41
|
-
var newImportPath = path.normalize(path.join(relative(from, parsedTo.dir), parsedTo.base)
|
41
|
+
var newImportPath = path.normalize(path.join(relative(from, parsedTo.dir), parsedTo.base));
|
42
42
|
return newImportPath.startsWith('.') ? newImportPath : './' + newImportPath;
|
43
43
|
}
|
44
44
|
|
package/dist/js/StyleSheet.d.ts
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
import { StyleDeclarationStatic } from './utils';
|
2
|
-
import {
|
2
|
+
import { Interpolation } from 'emotion';
|
3
|
+
import { ClassNameArg } from 'create-emotion';
|
4
|
+
|
5
|
+
type emotionCss = (...classNames: Array<ClassNameArg | StyleDeclarationStatic>) => string;
|
3
6
|
|
4
7
|
export interface StyleSheetStatic {
|
5
8
|
parse(cssString: string): StyleSheetValueStatic;
|
@@ -15,4 +18,4 @@ export type StyleSheetValueStatic = {
|
|
15
18
|
|
16
19
|
export const StyleSheet: StyleSheetStatic;
|
17
20
|
|
18
|
-
export const css:
|
21
|
+
export const css: emotionCss;
|
package/dist/js/build/util.js
CHANGED
@@ -63,7 +63,7 @@ function writeCSSJSFile(rootPath, originalPath, destinationPath, contents) {
|
|
63
63
|
|
64
64
|
function getRelativeImportPath(from, to) {
|
65
65
|
var parsedTo = _path2.default.parse(to);
|
66
|
-
var newImportPath = _path2.default.normalize(_path2.default.join((0, _relative2.default)(from, parsedTo.dir), parsedTo.base)
|
66
|
+
var newImportPath = _path2.default.normalize(_path2.default.join((0, _relative2.default)(from, parsedTo.dir), parsedTo.base));
|
67
67
|
return newImportPath.startsWith('.') ? newImportPath : './' + newImportPath;
|
68
68
|
}
|
69
69
|
|
@@ -0,0 +1,98 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'emotion', './utils'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('emotion'), require('./utils'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.emotion, global.utils);
|
11
|
+
global.StyleSheet = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _emotion, _utils) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.StyleSheet = undefined;
|
20
|
+
exports.css = css;
|
21
|
+
var _extends = Object.assign || function (target) {
|
22
|
+
for (var i = 1; i < arguments.length; i++) {
|
23
|
+
var source = arguments[i];for (var key in source) {
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
25
|
+
target[key] = source[key];
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}return target;
|
29
|
+
};
|
30
|
+
|
31
|
+
function _defineProperty(obj, key, value) {
|
32
|
+
if (key in obj) {
|
33
|
+
Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
|
34
|
+
} else {
|
35
|
+
obj[key] = value;
|
36
|
+
}return obj;
|
37
|
+
}
|
38
|
+
|
39
|
+
var StyleSheet = exports.StyleSheet = {
|
40
|
+
create: function create(styleObj) {
|
41
|
+
var keys = Object.keys(styleObj);
|
42
|
+
if (keys.length > 0) {
|
43
|
+
return keys.reduce(function (prev, key) {
|
44
|
+
return _extends({}, prev, _defineProperty({}, key, (0, _emotion.css)(styleObj[key])));
|
45
|
+
}, {});
|
46
|
+
}
|
47
|
+
return (0, _emotion.css)(styleObj);
|
48
|
+
},
|
49
|
+
parse: function parse(input) {
|
50
|
+
var classes = (0, _utils.getCSSClasses)(input);
|
51
|
+
if (!classes) {
|
52
|
+
return {};
|
53
|
+
}
|
54
|
+
|
55
|
+
return classes.reduce(function (map, className) {
|
56
|
+
var key = (0, _utils.formatClassName)(className);
|
57
|
+
if (map[key]) {
|
58
|
+
return map;
|
59
|
+
}
|
60
|
+
|
61
|
+
var value = (0, _utils.createStyleDeclaration)(className, input);
|
62
|
+
|
63
|
+
if ((0, _utils.isModifier)(className)) {
|
64
|
+
map.modifiers[key] = value;
|
65
|
+
} else {
|
66
|
+
map[key] = value;
|
67
|
+
}
|
68
|
+
|
69
|
+
return map;
|
70
|
+
}, {
|
71
|
+
modifiers: {},
|
72
|
+
inject: function inject() {
|
73
|
+
return (0, _emotion.injectGlobal)(input);
|
74
|
+
},
|
75
|
+
raw: input
|
76
|
+
});
|
77
|
+
}
|
78
|
+
};
|
79
|
+
|
80
|
+
function css() {
|
81
|
+
var filteredStyles = [];
|
82
|
+
|
83
|
+
for (var _len = arguments.length, styles = Array(_len), _key = 0; _key < _len; _key++) {
|
84
|
+
styles[_key] = arguments[_key];
|
85
|
+
}
|
86
|
+
|
87
|
+
styles.forEach(function (style) {
|
88
|
+
if ((0, _utils.isValidStyleDeclaration)(style)) {
|
89
|
+
style.__inject();
|
90
|
+
filteredStyles.push((0, _utils.getClassName)(style));
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
filteredStyles.push(style);
|
94
|
+
});
|
95
|
+
|
96
|
+
return _emotion.cx.apply(undefined, filteredStyles);
|
97
|
+
}
|
98
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', './plugin'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('./plugin'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.plugin);
|
11
|
+
global.index = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _plugin) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, 'default', {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _interopRequireDefault(_plugin).default;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
|
26
|
+
function _interopRequireDefault(obj) {
|
27
|
+
return obj && obj.__esModule ? obj : {
|
28
|
+
default: obj
|
29
|
+
};
|
30
|
+
}
|
31
|
+
});
|
@@ -0,0 +1,167 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', '@babel/helper-plugin-utils', 'path', 'resolve-from', '../util', '../../StyleSheet'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('@babel/helper-plugin-utils'), require('path'), require('resolve-from'), require('../util'), require('../../StyleSheet'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.helperPluginUtils, global.path, global.resolveFrom, global.util, global.StyleSheet);
|
11
|
+
global.plugin = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _helperPluginUtils, _path, _resolveFrom, _util, _StyleSheet) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
|
20
|
+
var _resolveFrom2 = _interopRequireDefault(_resolveFrom);
|
21
|
+
|
22
|
+
function _interopRequireDefault(obj) {
|
23
|
+
return obj && obj.__esModule ? obj : {
|
24
|
+
default: obj
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
var _extends = Object.assign || function (target) {
|
29
|
+
for (var i = 1; i < arguments.length; i++) {
|
30
|
+
var source = arguments[i];for (var key in source) {
|
31
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
32
|
+
target[key] = source[key];
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}return target;
|
36
|
+
};
|
37
|
+
|
38
|
+
/* eslint-disable no-case-declarations */
|
39
|
+
|
40
|
+
|
41
|
+
var defaultOptions = {
|
42
|
+
extensions: ['.css'],
|
43
|
+
srcDir: './src',
|
44
|
+
useModules: false
|
45
|
+
};
|
46
|
+
|
47
|
+
exports.default = (0, _helperPluginUtils.declare)(function (_ref) {
|
48
|
+
var t = _ref.types;
|
49
|
+
|
50
|
+
var outputFiles = new Set();
|
51
|
+
|
52
|
+
function getVariableName(path) {
|
53
|
+
if (path.node.specifiers && path.node.specifiers[0] && path.node.specifiers[0].local) {
|
54
|
+
return path.node.specifiers[0].local.name;
|
55
|
+
}
|
56
|
+
return null;
|
57
|
+
}
|
58
|
+
|
59
|
+
function getLastImportIndex(path) {
|
60
|
+
var lastImportIndex = 0;
|
61
|
+
path.container.forEach(function (p, i) {
|
62
|
+
if (t.isImportDeclaration(p)) {
|
63
|
+
lastImportIndex = i;
|
64
|
+
}
|
65
|
+
});
|
66
|
+
return lastImportIndex;
|
67
|
+
}
|
68
|
+
|
69
|
+
function getPackageImportIndex(path) {
|
70
|
+
return path.container.findIndex(function (p) {
|
71
|
+
return t.isImportDeclaration(p) && p.source.value === _util.packageName;
|
72
|
+
});
|
73
|
+
}
|
74
|
+
|
75
|
+
function createStyleSheetImport(path) {
|
76
|
+
return t.importDeclaration([t.importSpecifier(t.identifier('__PF__' + _util.styleSheetToken), t.identifier(_util.styleSheetToken))], t.stringLiteral(_util.packageName));
|
77
|
+
}
|
78
|
+
|
79
|
+
function validateReferences(referencePaths, styleObject) {
|
80
|
+
var nestedProperties = {
|
81
|
+
modifier: 'modifiers'
|
82
|
+
};
|
83
|
+
referencePaths.forEach(function (rp) {
|
84
|
+
if (!t.isMemberExpression(rp.parentPath.node)) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
var propName = rp.parentPath.node.property.name;
|
88
|
+
if (Object.values(nestedProperties).includes(propName)) {
|
89
|
+
var nestedNode = rp.parentPath.parentPath.node;
|
90
|
+
if (!t.isMemberExpression(nestedNode)) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
var nestedPropertyName = nestedNode.property.name;
|
94
|
+
if (!styleObject[propName][nestedPropertyName]) {
|
95
|
+
throw rp.buildCodeFrameError(nestedPropertyName + ' is not a valid ' + (propName === nestedProperties.modifier ? 'modifier' : 'property'));
|
96
|
+
}
|
97
|
+
} else if (!styleObject[propName]) {
|
98
|
+
throw rp.buildCodeFrameError(propName + ' does not exist');
|
99
|
+
}
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
return {
|
104
|
+
visitor: {
|
105
|
+
ImportDeclaration: function ImportDeclaration(path, _ref2) {
|
106
|
+
var file = _ref2.file,
|
107
|
+
_ref2$opts = _ref2.opts,
|
108
|
+
opts = _ref2$opts === undefined ? {} : _ref2$opts;
|
109
|
+
|
110
|
+
var options = _extends({}, defaultOptions, opts);
|
111
|
+
var value = path.node.source.value;
|
112
|
+
|
113
|
+
var ext = (0, _path.extname)(value);
|
114
|
+
if (options.extensions.includes(ext) && getVariableName(path)) {
|
115
|
+
var rootPath = file.opts.sourceRoot || process.cwd();
|
116
|
+
var scriptDirectory = (0, _path.dirname)((0, _path.resolve)(file.opts.filename));
|
117
|
+
var cssfilePath = (0, _resolveFrom2.default)(scriptDirectory, value);
|
118
|
+
var cssString = (0, _util.getCSS)(cssfilePath);
|
119
|
+
var varName = getVariableName(path);
|
120
|
+
var bindings = path.scope.bindings;
|
121
|
+
|
122
|
+
var styleObject = _StyleSheet.StyleSheet.parse(cssString);
|
123
|
+
|
124
|
+
validateReferences(bindings[varName].referencePaths, styleObject);
|
125
|
+
|
126
|
+
if (!options.outDir) {
|
127
|
+
var lastImportIndex = getLastImportIndex(path);
|
128
|
+
var pfStylesImportIndex = getPackageImportIndex(path);
|
129
|
+
|
130
|
+
if (pfStylesImportIndex === -1) {
|
131
|
+
path.getSibling(lastImportIndex).insertAfter(createStyleSheetImport());
|
132
|
+
lastImportIndex++;
|
133
|
+
pfStylesImportIndex = lastImportIndex;
|
134
|
+
}
|
135
|
+
|
136
|
+
var pfStylesImportPath = path.getSibling(pfStylesImportIndex);
|
137
|
+
var styleSheetSpecifier = pfStylesImportPath.node.specifiers.find(function (s) {
|
138
|
+
return t.isImportSpecifier(s) && s.imported.name === _util.styleSheetToken;
|
139
|
+
});
|
140
|
+
if (!styleSheetSpecifier) {
|
141
|
+
styleSheetSpecifier = t.importSpecifier(t.identifier('__PF__' + _util.styleSheetToken), t.identifier(_util.styleSheetToken));
|
142
|
+
pfStylesImportPath.node.specifiers.push(styleSheetSpecifier);
|
143
|
+
}
|
144
|
+
var varDeclaration = t.variableDeclaration('const', [t.variableDeclarator(t.identifier(varName), t.callExpression(t.memberExpression(t.identifier(styleSheetSpecifier.local.name), t.identifier('parse')), [t.stringLiteral(cssString)]))]);
|
145
|
+
path.getSibling(lastImportIndex).insertAfter(varDeclaration);
|
146
|
+
path.remove();
|
147
|
+
} else {
|
148
|
+
var srcDir = options.srcDir,
|
149
|
+
outDir = options.outDir;
|
150
|
+
|
151
|
+
var cssOutputPath = (0, _util.getCSSOutputPath)(outDir, rootPath, cssfilePath);
|
152
|
+
|
153
|
+
var scriptOutputPath = (0, _path.resolve)(file.opts.filename).replace((0, _path.resolve)(srcDir), outDir);
|
154
|
+
|
155
|
+
if (!outputFiles.has(cssOutputPath)) {
|
156
|
+
(0, _util.writeCSSJSFile)(rootPath, cssfilePath, cssOutputPath, (0, _util.cssToJS)(cssString, options.useModules));
|
157
|
+
outputFiles.add(cssOutputPath);
|
158
|
+
}
|
159
|
+
|
160
|
+
path.node.source.value = (0, _util.getRelativeImportPath)(scriptOutputPath, cssOutputPath);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
};
|
166
|
+
});
|
167
|
+
});
|
@@ -0,0 +1,71 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'cssstyle', 'camel-case'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('cssstyle'), require('camel-case'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.cssstyle, global.camelCase);
|
11
|
+
global.cssPropertyOverrides = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _cssstyle, _camelCase) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.addOverrides = addOverrides;
|
20
|
+
|
21
|
+
var _camelCase2 = _interopRequireDefault(_camelCase);
|
22
|
+
|
23
|
+
function _interopRequireDefault(obj) {
|
24
|
+
return obj && obj.__esModule ? obj : {
|
25
|
+
default: obj
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
var _extends = Object.assign || function (target) {
|
30
|
+
for (var i = 1; i < arguments.length; i++) {
|
31
|
+
var source = arguments[i];for (var key in source) {
|
32
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
33
|
+
target[key] = source[key];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}return target;
|
37
|
+
};
|
38
|
+
|
39
|
+
function _defineProperty(obj, key, value) {
|
40
|
+
if (key in obj) {
|
41
|
+
Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
|
42
|
+
} else {
|
43
|
+
obj[key] = value;
|
44
|
+
}return obj;
|
45
|
+
}
|
46
|
+
|
47
|
+
var properties = ['grid', 'grid-area', 'grid-auto-columns', 'grid-auto-flow', 'grid-auto-rows', 'grid-column', 'grid-column-end', 'grid-column-gap', 'grid-column-start', 'grid-gap', 'grid-row', 'grid-row-end', 'grid-row-gap', 'grid-row-start', 'grid-template', 'grid-template-areas', 'grid-template-columns', 'grid-template-rows'];
|
48
|
+
|
49
|
+
function createOverride(key) {
|
50
|
+
return {
|
51
|
+
set: function set(v) {
|
52
|
+
this._setProperty(key, v);
|
53
|
+
},
|
54
|
+
get: function get() {
|
55
|
+
return this.getPropertyValue(key);
|
56
|
+
},
|
57
|
+
|
58
|
+
enumerable: true,
|
59
|
+
configurable: true
|
60
|
+
};
|
61
|
+
}
|
62
|
+
|
63
|
+
function addOverrides() {
|
64
|
+
var overrides = properties.reduce(function (acc, property) {
|
65
|
+
var _extends2;
|
66
|
+
|
67
|
+
return _extends({}, acc, (_extends2 = {}, _defineProperty(_extends2, property, createOverride(property)), _defineProperty(_extends2, (0, _camelCase2.default)(property), createOverride(property)), _extends2));
|
68
|
+
}, {});
|
69
|
+
Object.defineProperties(_cssstyle.CSSStyleDeclaration.prototype, overrides);
|
70
|
+
}
|
71
|
+
});
|
@@ -0,0 +1,161 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'css', 'jsdom'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('css'), require('jsdom'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.css, global.jsdom);
|
11
|
+
global.cssUtils = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _css, _jsdom) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.getStyles = exports.getSelectors = undefined;
|
20
|
+
|
21
|
+
var css = _interopRequireWildcard(_css);
|
22
|
+
|
23
|
+
var jsdom = _interopRequireWildcard(_jsdom);
|
24
|
+
|
25
|
+
function _interopRequireWildcard(obj) {
|
26
|
+
if (obj && obj.__esModule) {
|
27
|
+
return obj;
|
28
|
+
} else {
|
29
|
+
var newObj = {};
|
30
|
+
|
31
|
+
if (obj != null) {
|
32
|
+
for (var key in obj) {
|
33
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
newObj.default = obj;
|
38
|
+
return newObj;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
function _toConsumableArray(arr) {
|
43
|
+
if (Array.isArray(arr)) {
|
44
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
45
|
+
arr2[i] = arr[i];
|
46
|
+
}return arr2;
|
47
|
+
} else {
|
48
|
+
return Array.from(arr);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
var JSDOM = jsdom.JSDOM;
|
53
|
+
|
54
|
+
function getSelectors(nodes) {
|
55
|
+
return nodes.reduce(function (selectors, node) {
|
56
|
+
var props = typeof node.props === 'function' ? node.props() : node.props;
|
57
|
+
return [].concat(_toConsumableArray(selectors), [getSelectorsFromProps(props)]);
|
58
|
+
}, []);
|
59
|
+
}
|
60
|
+
|
61
|
+
function getSelectorsFromProps() {
|
62
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
63
|
+
|
64
|
+
var className = props.className || props.class;
|
65
|
+
if (className) {
|
66
|
+
return className.toString().split(' ').map(function (cn) {
|
67
|
+
return '.' + cn;
|
68
|
+
});
|
69
|
+
}
|
70
|
+
return [];
|
71
|
+
}
|
72
|
+
|
73
|
+
function componentToHex(c) {
|
74
|
+
var hex = c.toString(16);
|
75
|
+
return hex.length === 1 ? '0' + hex : hex;
|
76
|
+
}
|
77
|
+
|
78
|
+
function rgbToHex(r, g, b) {
|
79
|
+
return '#' + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
80
|
+
}
|
81
|
+
|
82
|
+
function getComputedStyles(classNames, cssStr) {
|
83
|
+
var dom = new JSDOM('<!DOCTYPE html>\n <head><style>' + cssStr + '</style></head>\n <body><div class="' + classNames + '"></div>\n </body>');
|
84
|
+
var cs = dom.window.getComputedStyle(dom.window.document.body.children[0]);
|
85
|
+
var values = {};
|
86
|
+
for (var i = 0; i < cs.length; i++) {
|
87
|
+
var key = cs[i];
|
88
|
+
var value = cs.getPropertyValue(key).replace(/rgb\(([\d|,|\s]+)\)/g, function (full, match) {
|
89
|
+
return rgbToHex.apply(undefined, _toConsumableArray(match.split(',').map(function (n) {
|
90
|
+
return parseInt(n, 10);
|
91
|
+
})));
|
92
|
+
});
|
93
|
+
values[key] = value;
|
94
|
+
}
|
95
|
+
return values;
|
96
|
+
}
|
97
|
+
|
98
|
+
function getStylesAST(bufferedStyles) {
|
99
|
+
var globalCSS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
100
|
+
|
101
|
+
var ast = css.parse(globalCSS + '\n' + bufferedStyles);
|
102
|
+
var vars = {};
|
103
|
+
var getVarValue = function getVarValue(value) {
|
104
|
+
return value.replace(/var\(([\w|-]*)\)/g, function (full, match) {
|
105
|
+
return vars[match];
|
106
|
+
});
|
107
|
+
};
|
108
|
+
ast.stylesheet.rules = ast.stylesheet.rules.map(function (rule) {
|
109
|
+
if (rule.type === 'rule') {
|
110
|
+
rule.declarations = rule.declarations.map(function (decl) {
|
111
|
+
if (decl.type === 'declaration') {
|
112
|
+
var property = decl.property,
|
113
|
+
value = decl.value;
|
114
|
+
|
115
|
+
if (property.startsWith('--')) {
|
116
|
+
vars[property] = getVarValue(value);
|
117
|
+
}
|
118
|
+
decl.value = getVarValue(value);
|
119
|
+
}
|
120
|
+
return decl;
|
121
|
+
});
|
122
|
+
}
|
123
|
+
return rule;
|
124
|
+
});
|
125
|
+
return ast;
|
126
|
+
}
|
127
|
+
|
128
|
+
function formatComputedStyles(nodeSelectors, computedStyles) {
|
129
|
+
var selector = nodeSelectors.join('');
|
130
|
+
var cssString = selector + ' {\n ' + Object.keys(computedStyles).map(function (k) {
|
131
|
+
return k + ': ' + computedStyles[k] + ';';
|
132
|
+
}).join('\n') + '\n }';
|
133
|
+
return css.stringify(css.parse(cssString));
|
134
|
+
}
|
135
|
+
|
136
|
+
function getStyles(nodeSelectors, insertedStyles, globalCSS) {
|
137
|
+
if (!nodeSelectors.length) {
|
138
|
+
return '';
|
139
|
+
}
|
140
|
+
var ast = getStylesAST(insertedStyles, globalCSS);
|
141
|
+
return nodeSelectors.reduce(function (acc, sel) {
|
142
|
+
if (!sel.length) {
|
143
|
+
return acc;
|
144
|
+
}
|
145
|
+
|
146
|
+
var re = new RegExp('(' + sel.join('|') + ')', 'g');
|
147
|
+
if (!re.test(insertedStyles)) {
|
148
|
+
return acc;
|
149
|
+
}
|
150
|
+
|
151
|
+
var computedStyles = getComputedStyles(sel.map(function (s) {
|
152
|
+
return s.replace('.', '');
|
153
|
+
}).join(' '), css.stringify(ast));
|
154
|
+
|
155
|
+
return [].concat(_toConsumableArray(acc), [formatComputedStyles(sel, computedStyles)]);
|
156
|
+
}, []).join('\n');
|
157
|
+
}
|
158
|
+
|
159
|
+
exports.getSelectors = getSelectors;
|
160
|
+
exports.getStyles = getStyles;
|
161
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', './serializer'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('./serializer'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.serializer);
|
11
|
+
global.index = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _serializer) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, 'default', {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _interopRequireDefault(_serializer).default;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
Object.defineProperty(exports, 'createSerializer', {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _serializer.createSerializer;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
function _interopRequireDefault(obj) {
|
33
|
+
return obj && obj.__esModule ? obj : {
|
34
|
+
default: obj
|
35
|
+
};
|
36
|
+
}
|
37
|
+
});
|
@@ -0,0 +1,51 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports);
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports);
|
11
|
+
global.reactUtils = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
|
20
|
+
var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
21
|
+
return typeof obj;
|
22
|
+
} : function (obj) {
|
23
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
24
|
+
};
|
25
|
+
|
26
|
+
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
|
27
|
+
return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
28
|
+
} : function (obj) {
|
29
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
|
30
|
+
};
|
31
|
+
|
32
|
+
function getNodes(node) {
|
33
|
+
var nodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
34
|
+
|
35
|
+
if (node.children) {
|
36
|
+
var children = typeof node.children === 'function' ? node.children() : node.children;
|
37
|
+
|
38
|
+
children.forEach(function (child) {
|
39
|
+
return getNodes(child, nodes);
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object') {
|
44
|
+
nodes.push(node);
|
45
|
+
}
|
46
|
+
|
47
|
+
return nodes;
|
48
|
+
}
|
49
|
+
|
50
|
+
exports.getNodes = getNodes;
|
51
|
+
});
|
@@ -0,0 +1,52 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', './cssUtils', './reactUtils', '../../../utils', './cssPropertyOverrides'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('./cssUtils'), require('./reactUtils'), require('../../../utils'), require('./cssPropertyOverrides'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.cssUtils, global.reactUtils, global.utils, global.cssPropertyOverrides);
|
11
|
+
global.serializer = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _cssUtils, _reactUtils, _utils, _cssPropertyOverrides) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.createSerializer = createSerializer;
|
20
|
+
function createSerializer() {
|
21
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
22
|
+
_ref$globalCSS = _ref.globalCSS,
|
23
|
+
globalCSS = _ref$globalCSS === undefined ? '' : _ref$globalCSS;
|
24
|
+
|
25
|
+
(0, _cssPropertyOverrides.addOverrides)();
|
26
|
+
function test(val) {
|
27
|
+
return val && !val.withStyles && val.$$typeof === Symbol.for('react.test.json');
|
28
|
+
}
|
29
|
+
|
30
|
+
function print(val, printer) {
|
31
|
+
var nodes = (0, _reactUtils.getNodes)(val);
|
32
|
+
nodes.forEach(function (node) {
|
33
|
+
node.withStyles = true;
|
34
|
+
});
|
35
|
+
|
36
|
+
var selectors = (0, _cssUtils.getSelectors)(nodes);
|
37
|
+
var styles = (0, _cssUtils.getStyles)(selectors, (0, _utils.getInsertedStyles)().join(''), globalCSS);
|
38
|
+
var code = printer(val);
|
39
|
+
if (styles) {
|
40
|
+
return styles + '\n\n' + code;
|
41
|
+
}
|
42
|
+
return code;
|
43
|
+
}
|
44
|
+
|
45
|
+
return {
|
46
|
+
test: test,
|
47
|
+
print: print
|
48
|
+
};
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.default = createSerializer();
|
52
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'fbjs-scripts/jest/createCacheKeyFunction', '../util'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('fbjs-scripts/jest/createCacheKeyFunction'), require('../util'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.createCacheKeyFunction, global.util);
|
11
|
+
global.transform = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _createCacheKeyFunction, _util) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.getCacheKey = undefined;
|
20
|
+
exports.process = process;
|
21
|
+
|
22
|
+
var _createCacheKeyFunction2 = _interopRequireDefault(_createCacheKeyFunction);
|
23
|
+
|
24
|
+
function _interopRequireDefault(obj) {
|
25
|
+
return obj && obj.__esModule ? obj : {
|
26
|
+
default: obj
|
27
|
+
};
|
28
|
+
}
|
29
|
+
|
30
|
+
function process(src) {
|
31
|
+
return (0, _util.cssToJS)((0, _util.minifyCSS)(src), false);
|
32
|
+
}
|
33
|
+
|
34
|
+
var getCacheKey = exports.getCacheKey = (0, _createCacheKeyFunction2.default)([]);
|
35
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', '../util'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('../util'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.util);
|
11
|
+
global.index = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _util) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.default = pfStyleLoader;
|
20
|
+
function pfStyleLoader(source) {
|
21
|
+
return (0, _util.cssToJS)(source, false);
|
22
|
+
}
|
23
|
+
});
|
@@ -0,0 +1,94 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'path', 'fs', 'css', 'fs-extra', 'relative'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('path'), require('fs'), require('css'), require('fs-extra'), require('relative'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.path, global.fs, global.css, global.fsExtra, global.relative);
|
11
|
+
global.util = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _path, _fs, _css, _fsExtra, _relative) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.styleSheetToken = exports.packageName = undefined;
|
20
|
+
exports.cssToJS = cssToJS;
|
21
|
+
exports.getCSS = getCSS;
|
22
|
+
exports.minifyCSS = minifyCSS;
|
23
|
+
exports.writeCSSJSFile = writeCSSJSFile;
|
24
|
+
exports.getRelativeImportPath = getRelativeImportPath;
|
25
|
+
exports.getCSSOutputPath = getCSSOutputPath;
|
26
|
+
|
27
|
+
var _path2 = _interopRequireDefault(_path);
|
28
|
+
|
29
|
+
var _css2 = _interopRequireDefault(_css);
|
30
|
+
|
31
|
+
var _relative2 = _interopRequireDefault(_relative);
|
32
|
+
|
33
|
+
function _interopRequireDefault(obj) {
|
34
|
+
return obj && obj.__esModule ? obj : {
|
35
|
+
default: obj
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
var packageName = exports.packageName = '@patternfly/react-styles';
|
40
|
+
var styleSheetToken = exports.styleSheetToken = 'StyleSheet';
|
41
|
+
|
42
|
+
function cssToJS(cssString) {
|
43
|
+
var useModules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
44
|
+
|
45
|
+
if (useModules) {
|
46
|
+
return 'import { ' + styleSheetToken + ' } from \'' + packageName + '\';\nexport default ' + styleSheetToken + '.parse(`' + cssString + '`);\n';
|
47
|
+
}
|
48
|
+
|
49
|
+
return 'const { ' + styleSheetToken + ' } = require(\'' + packageName + '\');\nmodule.exports = ' + styleSheetToken + '.parse(`' + cssString + '`);\n';
|
50
|
+
}
|
51
|
+
|
52
|
+
function getCSS(pathToCSSFile) {
|
53
|
+
var rawCss = (0, _fs.readFileSync)(pathToCSSFile, 'utf8').replace('@charset "UTF-8";', '');
|
54
|
+
return minifyCSS(rawCss);
|
55
|
+
}
|
56
|
+
|
57
|
+
function minifyCSS(cssString) {
|
58
|
+
return _css2.default.stringify(_css2.default.parse(cssString.replace('@charset "UTF-8";', '')), {
|
59
|
+
compress: true
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
function writeCSSJSFile(rootPath, originalPath, destinationPath, contents) {
|
64
|
+
(0, _fsExtra.outputFileSync)(destinationPath, contents);
|
65
|
+
var removeRE = new RegExp(rootPath + '/?');
|
66
|
+
var inFormatted = originalPath.replace(removeRE, '');
|
67
|
+
var outFormatted = destinationPath.replace(removeRE, '');
|
68
|
+
console.log(inFormatted + ' -> ' + outFormatted); // eslint-disable-line
|
69
|
+
}
|
70
|
+
|
71
|
+
function getRelativeImportPath(from, to) {
|
72
|
+
var parsedTo = _path2.default.parse(to);
|
73
|
+
var newImportPath = _path2.default.normalize(_path2.default.join((0, _relative2.default)(from, parsedTo.dir), parsedTo.base));
|
74
|
+
return newImportPath.startsWith('.') ? newImportPath : './' + newImportPath;
|
75
|
+
}
|
76
|
+
|
77
|
+
function getCSSOutputPath(outDir, rootPath, pathToCSSFile) {
|
78
|
+
return _path2.default.join(_path2.default.resolve(rootPath, outDir), getFormattedCSSOutputPath(pathToCSSFile));
|
79
|
+
}
|
80
|
+
|
81
|
+
function getFormattedCSSOutputPath(pathToCSSFile) {
|
82
|
+
var _path$parse = _path2.default.parse(pathToCSSFile),
|
83
|
+
dir = _path$parse.dir,
|
84
|
+
name = _path$parse.name;
|
85
|
+
|
86
|
+
var formattedDir = dir;
|
87
|
+
var nodeText = 'node_modules';
|
88
|
+
var nodeIndex = formattedDir.lastIndexOf(nodeText);
|
89
|
+
if (nodeIndex !== -1) {
|
90
|
+
formattedDir = formattedDir.substring(nodeIndex + nodeText.length);
|
91
|
+
}
|
92
|
+
return _path2.default.join(formattedDir, name + '.css.js');
|
93
|
+
}
|
94
|
+
});
|
@@ -0,0 +1,61 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', './StyleSheet', './utils'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('./StyleSheet'), require('./utils'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.StyleSheet, global.utils);
|
11
|
+
global.index = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _StyleSheet, _utils) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, 'StyleSheet', {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _StyleSheet.StyleSheet;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
Object.defineProperty(exports, 'css', {
|
26
|
+
enumerable: true,
|
27
|
+
get: function () {
|
28
|
+
return _StyleSheet.css;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
Object.defineProperty(exports, 'isValidStyleDeclaration', {
|
32
|
+
enumerable: true,
|
33
|
+
get: function () {
|
34
|
+
return _utils.isValidStyleDeclaration;
|
35
|
+
}
|
36
|
+
});
|
37
|
+
Object.defineProperty(exports, 'getModifier', {
|
38
|
+
enumerable: true,
|
39
|
+
get: function () {
|
40
|
+
return _utils.getModifier;
|
41
|
+
}
|
42
|
+
});
|
43
|
+
Object.defineProperty(exports, 'isModifier', {
|
44
|
+
enumerable: true,
|
45
|
+
get: function () {
|
46
|
+
return _utils.isModifier;
|
47
|
+
}
|
48
|
+
});
|
49
|
+
Object.defineProperty(exports, 'getInsertedStyles', {
|
50
|
+
enumerable: true,
|
51
|
+
get: function () {
|
52
|
+
return _utils.getInsertedStyles;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
Object.defineProperty(exports, 'getClassName', {
|
56
|
+
enumerable: true,
|
57
|
+
get: function () {
|
58
|
+
return _utils.getClassName;
|
59
|
+
}
|
60
|
+
});
|
61
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'emotion-server'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('emotion-server'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.emotionServer);
|
11
|
+
global.server = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _emotionServer) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.renderStatic = renderStatic;
|
20
|
+
function renderStatic(renderFn) {
|
21
|
+
var html = (0, _emotionServer.renderStylesToString)(renderFn());
|
22
|
+
return { html: html };
|
23
|
+
}
|
24
|
+
});
|
@@ -0,0 +1,83 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(['exports', 'camel-case', 'emotion'], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require('camel-case'), require('emotion'));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.camelCase, global.emotion);
|
11
|
+
global.utils = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function (exports, _camelCase, _emotion) {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
exports.isValidStyleDeclaration = isValidStyleDeclaration;
|
20
|
+
exports.createStyleDeclaration = createStyleDeclaration;
|
21
|
+
exports.isModifier = isModifier;
|
22
|
+
exports.getModifier = getModifier;
|
23
|
+
exports.formatClassName = formatClassName;
|
24
|
+
exports.getCSSClasses = getCSSClasses;
|
25
|
+
exports.getClassName = getClassName;
|
26
|
+
exports.getInsertedStyles = getInsertedStyles;
|
27
|
+
|
28
|
+
var _camelCase2 = _interopRequireDefault(_camelCase);
|
29
|
+
|
30
|
+
function _interopRequireDefault(obj) {
|
31
|
+
return obj && obj.__esModule ? obj : {
|
32
|
+
default: obj
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
function isValidStyleDeclaration(styleObj) {
|
37
|
+
return Boolean(styleObj) && typeof styleObj.__className === 'string' && typeof styleObj.__inject === 'function';
|
38
|
+
}
|
39
|
+
|
40
|
+
function createStyleDeclaration(className, rawCss) {
|
41
|
+
return {
|
42
|
+
__className: className.replace('.', '').trim(),
|
43
|
+
__inject: function __inject() {
|
44
|
+
(0, _emotion.injectGlobal)(rawCss);
|
45
|
+
}
|
46
|
+
};
|
47
|
+
}
|
48
|
+
|
49
|
+
function isModifier(className) {
|
50
|
+
return Boolean(className && className.startsWith) && className.startsWith('.pf-m-');
|
51
|
+
}
|
52
|
+
|
53
|
+
function getModifier(styleObj, modifier, defaultModifier) {
|
54
|
+
if (!styleObj) {
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
|
58
|
+
var modifiers = styleObj.modifiers || styleObj;
|
59
|
+
return modifiers[modifier] || modifiers[(0, _camelCase2.default)(modifier)] || defaultModifier;
|
60
|
+
}
|
61
|
+
|
62
|
+
function formatClassName(className) {
|
63
|
+
return (0, _camelCase2.default)(className.replace(/pf-((c|l|m|u|is|has)-)?/g, ''));
|
64
|
+
}
|
65
|
+
|
66
|
+
function getCSSClasses(cssString) {
|
67
|
+
return cssString.match(/(\.)(?!\d)([^\s\.,{\[>+~#:)]*)(?![^{]*})/g); //eslint-disable-line
|
68
|
+
}
|
69
|
+
|
70
|
+
function getClassName() {
|
71
|
+
var styleObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
72
|
+
|
73
|
+
if (typeof styleObj === 'string') {
|
74
|
+
return styleObj;
|
75
|
+
}
|
76
|
+
|
77
|
+
return isValidStyleDeclaration(styleObj) ? styleObj.__className : '';
|
78
|
+
}
|
79
|
+
|
80
|
+
function getInsertedStyles() {
|
81
|
+
return Object.values(_emotion.caches.inserted);
|
82
|
+
}
|
83
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@patternfly/react-styles",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.0",
|
4
4
|
"main": "dist/js/index.js",
|
5
5
|
"module": "dist/esm/index.js",
|
6
6
|
"types": "dist/js/index.d.ts",
|
@@ -11,6 +11,14 @@
|
|
11
11
|
"access": "public",
|
12
12
|
"tag": "prerelease"
|
13
13
|
},
|
14
|
+
"scripts": {
|
15
|
+
"build": "yarn build:babel && node ./scripts/copyTS.js",
|
16
|
+
"build:babel": "concurrently 'yarn build:babel:cjs' 'yarn build:babel:esm' && yarn build:babel:umd",
|
17
|
+
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
|
18
|
+
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
|
19
|
+
"build:babel:umd": "cross-env BABEL_ENV=production:umd babel dist/esm --out-dir dist/umd --plugins transform-es2015-modules-umd",
|
20
|
+
"clean": "rimraf dist"
|
21
|
+
},
|
14
22
|
"dependencies": {
|
15
23
|
"@babel/helper-plugin-utils": "^7.0.0-beta.48",
|
16
24
|
"camel-case": "^3.0.0",
|
@@ -26,17 +34,10 @@
|
|
26
34
|
"resolve-from": "^4.0.0"
|
27
35
|
},
|
28
36
|
"devDependencies": {
|
37
|
+
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
|
29
38
|
"glob": "^7.1.2",
|
30
39
|
"rimraf": "^2.6.2"
|
31
40
|
},
|
32
41
|
"license": "MIT",
|
33
|
-
"
|
34
|
-
"build": "yarn build:babel && yarn build:ts",
|
35
|
-
"build:babel": "concurrently \"yarn build:babel:cjs\" \"yarn build:babel:esm\"",
|
36
|
-
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
|
37
|
-
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
|
38
|
-
"build:ts": "node ./scripts/copyTS.js",
|
39
|
-
"clean": "rimraf dist"
|
40
|
-
},
|
41
|
-
"gitHead": "b0789cefa147a96765ccdaf558211a17f2b9071c"
|
42
|
+
"gitHead": "a9751cf3e68321937adfc456d48952abfbe338ba"
|
42
43
|
}
|