react-outline 2.1.0 → 2.1.2
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/README.md +5 -53
- package/dist/reactOutline.js +1 -231
- package/dist/reactOutline.js.map +4 -4
- package/package.json +8 -10
- package/dist/Styles.js +0 -45
- package/dist/element.js +0 -141
- package/dist/main.js +0 -64
- package/dist/styleItem.js +0 -168
- package/dist/utils/buildCssString.js +0 -14
- package/dist/utils/genCss.js +0 -27
- package/dist/utils/genStyles.js +0 -23
- package/dist/utils/hasKids.js +0 -12
- package/dist/utils/index.js +0 -83
- package/dist/utils/makeid.js +0 -13
- package/dist/utils/object2css.js +0 -25
- package/dist/utils/pubsub.js +0 -40
- package/dist/utils/replaceColors.js +0 -16
- package/dist/utils/replacedStyleFn.js +0 -35
- package/dist/utils/sanitizeOutlineInput.js +0 -70
- package/dist/utils/separateCssStyle.js +0 -23
- package/dist/wrapStyles.js +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-outline",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "react styling framework to keep your makeup clean",
|
|
5
5
|
"main": "./dist/reactOutline.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -9,14 +9,13 @@
|
|
|
9
9
|
"index.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"test": "jest --no-cache ",
|
|
12
|
+
"build:dist": "npx esbuild source/main.js --bundle --minify --sourcemap --outfile=dist/reactOutline.js --format=cjs --platform=node --loader:.js=jsx --external:react --external:react-dom",
|
|
13
|
+
"pretest": "npm run build:dist",
|
|
14
|
+
"test": "jest --no-cache",
|
|
16
15
|
"test:go": "npm test -- --watch --coverage",
|
|
17
16
|
"test:update": "npm test -- --updateSnapshot",
|
|
18
|
-
"test:cover": "
|
|
19
|
-
"test:watch": "npm
|
|
17
|
+
"test:cover": "jest --no-cache --config jest.coverage.config.js --coverage",
|
|
18
|
+
"test:watch": "npm run build:dist && jest --no-cache --watch --runInBand",
|
|
20
19
|
"release": "bash scripts/_publish.sh"
|
|
21
20
|
},
|
|
22
21
|
"repository": {
|
|
@@ -57,8 +56,7 @@
|
|
|
57
56
|
"@faker-js/faker": "^8.3.0",
|
|
58
57
|
"@testing-library/jest-dom": "^6.1.0",
|
|
59
58
|
"@testing-library/react": "^14.1.0",
|
|
60
|
-
"
|
|
61
|
-
"esbuild": "^0.24.2",
|
|
59
|
+
"esbuild": "^0.27.2",
|
|
62
60
|
"jest": "^29.7.0",
|
|
63
61
|
"jest-environment-jsdom": "^29.7.0",
|
|
64
62
|
"raw-loader": "^4.0.2",
|
|
@@ -71,7 +69,7 @@
|
|
|
71
69
|
"moduleNameMapper": {
|
|
72
70
|
"\\.(css|jpg|png)$": "<rootDir>/empty-module.js",
|
|
73
71
|
"^raw-loader": "<rootDir>/empty-module.js",
|
|
74
|
-
"react-outline": "<rootDir>/
|
|
72
|
+
"react-outline": "<rootDir>/dist/reactOutline.js",
|
|
75
73
|
"^react-addons-css-transition-group$": "<rootDir>/empty-module.js"
|
|
76
74
|
},
|
|
77
75
|
"testPathIgnorePatterns": [
|
package/dist/Styles.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = Styles;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _utils = require("./utils");
|
|
10
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
-
// TODO: make Styles a "ref" and manual set the content
|
|
18
|
-
|
|
19
|
-
function StylesElem(props) {
|
|
20
|
-
var _useState = (0, _react.useState)(function () {
|
|
21
|
-
return (0, _utils.buildCssString)(_utils.pubsub.get(), props);
|
|
22
|
-
}),
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
cssString = _useState2[0],
|
|
25
|
-
setCssString = _useState2[1];
|
|
26
|
-
(0, _react.useEffect)(function () {
|
|
27
|
-
var updateCss = function updateCss() {
|
|
28
|
-
setCssString((0, _utils.buildCssString)(_utils.pubsub.get(), props));
|
|
29
|
-
};
|
|
30
|
-
_utils.pubsub.subscribe(updateCss);
|
|
31
|
-
|
|
32
|
-
// Cleanup subscription on unmount
|
|
33
|
-
return function () {
|
|
34
|
-
// Note: pubsub.subscribe doesn't return an unsubscribe function in the current implementation
|
|
35
|
-
// This is kept for future compatibility if unsubscribe is added
|
|
36
|
-
};
|
|
37
|
-
}, [props]);
|
|
38
|
-
return /*#__PURE__*/_react["default"].createElement("style", null, cssString);
|
|
39
|
-
}
|
|
40
|
-
function Styles(props) {
|
|
41
|
-
return /*#__PURE__*/_react["default"].createElement(StylesElem, props);
|
|
42
|
-
}
|
|
43
|
-
Styles.toString = function () {
|
|
44
|
-
return (0, _utils.buildCssString)(_utils.pubsub.get());
|
|
45
|
-
};
|
package/dist/element.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = _default;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _reactDom = require("react-dom");
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
-
function _default(_ref) {
|
|
26
|
-
var elemName = _ref.elemName,
|
|
27
|
-
css = _ref.css,
|
|
28
|
-
styleCSS = _ref.styleCSS,
|
|
29
|
-
inlineStyle = _ref.inlineStyle,
|
|
30
|
-
style = _ref.style,
|
|
31
|
-
styleName = _ref.styleName,
|
|
32
|
-
colors = _ref.colors,
|
|
33
|
-
randomClassName = _ref.randomClassName,
|
|
34
|
-
options = _ref.options,
|
|
35
|
-
replacedStyle = _ref.replacedStyle;
|
|
36
|
-
var C2 = /*#__PURE__*/function (_React$Component) {
|
|
37
|
-
function C2(props) {
|
|
38
|
-
var _this;
|
|
39
|
-
_classCallCheck(this, C2);
|
|
40
|
-
_this = _callSuper(this, C2, [props]);
|
|
41
|
-
_this.eventHandlers = {};
|
|
42
|
-
return _this;
|
|
43
|
-
}
|
|
44
|
-
_inherits(C2, _React$Component);
|
|
45
|
-
return _createClass(C2, [{
|
|
46
|
-
key: "createEventHandler",
|
|
47
|
-
value: function createEventHandler(listen, onDomEvent) {
|
|
48
|
-
var _this2 = this;
|
|
49
|
-
return function (event) {
|
|
50
|
-
return onDomEvent[listen](_this2.domElem, event);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "componentDidMount",
|
|
55
|
-
value: function componentDidMount() {
|
|
56
|
-
var onDomEvent = this.props.onDomEvent;
|
|
57
|
-
for (var listen in onDomEvent) {
|
|
58
|
-
this.eventHandlers[listen] = this.createEventHandler(listen, onDomEvent);
|
|
59
|
-
this.domElem.addEventListener(listen, this.eventHandlers[listen]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "componentWillUnmount",
|
|
64
|
-
value: function componentWillUnmount() {
|
|
65
|
-
for (var listen in this.eventHandlers) {
|
|
66
|
-
this.domElem.removeEventListener(listen, this.eventHandlers[listen]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "render",
|
|
71
|
-
value: function render() {
|
|
72
|
-
var _this3 = this;
|
|
73
|
-
var props = this.props;
|
|
74
|
-
if ("css" in props) {
|
|
75
|
-
var updatedCss = Object.assign({}, css);
|
|
76
|
-
for (var selectorRule in props.css) {
|
|
77
|
-
updatedCss[selectorRule] = Object.assign({}, css[selectorRule], "function" === typeof props.css[selectorRule] ? props.css[selectorRule]() : props.css[selectorRule]);
|
|
78
|
-
}
|
|
79
|
-
_utils.pubsub.publish(randomClassName, (0, _utils.genCss)({
|
|
80
|
-
randomClassName: randomClassName,
|
|
81
|
-
css: updatedCss,
|
|
82
|
-
styleCSS: styleCSS,
|
|
83
|
-
colors: colors,
|
|
84
|
-
style: style,
|
|
85
|
-
styleName: styleName
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
var elemProps = Object.assign({}, props);
|
|
89
|
-
var passedTrueProps = Object.keys(props).filter(function (name) {
|
|
90
|
-
return props[name] === true && styleCSS[styleName] && name in styleCSS[styleName];
|
|
91
|
-
});
|
|
92
|
-
// console.log("passedTrueProps",passedTrueProps)
|
|
93
|
-
if (0 < passedTrueProps.length) {
|
|
94
|
-
passedTrueProps = passedTrueProps.reduce(function (styleProps, name) {
|
|
95
|
-
// If elem is a HTML type = Removed it Unknown prop `...` on <...> tag. Remove this prop from the element.
|
|
96
|
-
if ("function" !== typeof elemName && "disabled" !== name) {
|
|
97
|
-
delete elemProps[name];
|
|
98
|
-
}
|
|
99
|
-
return Object.assign(styleProps, _defineProperty({}, name, true));
|
|
100
|
-
}, {});
|
|
101
|
-
} else {
|
|
102
|
-
passedTrueProps = null;
|
|
103
|
-
}
|
|
104
|
-
if (passedTrueProps || props.hasOwnProperty("style")) {
|
|
105
|
-
//if(props.style instanceof Object)
|
|
106
|
-
// passedTrueProps = Object.assign({},props.style,passedTrueProps);
|
|
107
|
-
if (randomClassName) elemProps.style = props.style;else elemProps.style = replacedStyle[styleName](props.style, passedTrueProps);
|
|
108
|
-
} else {
|
|
109
|
-
elemProps.style = inlineStyle || replacedStyle[styleName]();
|
|
110
|
-
}
|
|
111
|
-
//TODO: write a test for this
|
|
112
|
-
// For some reason in prod!
|
|
113
|
-
// a custom element in a perfect storm can have style undefined
|
|
114
|
-
//SEE: test - should generated an element with css selector
|
|
115
|
-
// thss is the same prod code.. BUT this is not catching this case :(
|
|
116
|
-
if (elemProps.style && Object.keys(elemProps.style).length === 0) {
|
|
117
|
-
delete elemProps.style;
|
|
118
|
-
}
|
|
119
|
-
if (options.named) {
|
|
120
|
-
elemProps.name = elemProps.name || styleName;
|
|
121
|
-
}
|
|
122
|
-
elemProps.className = elemProps.className || "";
|
|
123
|
-
if (elemProps.className && randomClassName) {
|
|
124
|
-
elemProps.className += " ";
|
|
125
|
-
}
|
|
126
|
-
elemProps.className += randomClassName || "";
|
|
127
|
-
if ("" === elemProps.className) delete elemProps.className;
|
|
128
|
-
if (props.onDomEvent) {
|
|
129
|
-
elemProps.ref = function (reatElem) {
|
|
130
|
-
return _this3.domElem = (0, _reactDom.findDOMNode)(reatElem);
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
return /*#__PURE__*/_react["default"].createElement(elemName || styleName, elemProps, elemProps && elemProps.children);
|
|
134
|
-
}
|
|
135
|
-
}]);
|
|
136
|
-
}(_react["default"].Component);
|
|
137
|
-
Object.defineProperty(C2, 'name', {
|
|
138
|
-
value: styleName
|
|
139
|
-
});
|
|
140
|
-
return C2;
|
|
141
|
-
}
|
package/dist/main.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Styles", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Styles["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
exports["default"] = void 0;
|
|
13
|
-
exports.setOptions = setOptions;
|
|
14
|
-
exports.testing = void 0;
|
|
15
|
-
exports.withOptions = withOptions;
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _utils = require("./utils");
|
|
18
|
-
var _wrapStyles = _interopRequireDefault(require("./wrapStyles"));
|
|
19
|
-
var _Styles = _interopRequireDefault(require("./Styles"));
|
|
20
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
21
|
-
var userSetOptions = {
|
|
22
|
-
named: true /* prefix:getVendorPrefix()*/
|
|
23
|
-
};
|
|
24
|
-
var wrapStyles = (0, _wrapStyles["default"])(userSetOptions);
|
|
25
|
-
|
|
26
|
-
//=====================================================
|
|
27
|
-
//============================= top Level - Wrap Styles
|
|
28
|
-
//=====================================================
|
|
29
|
-
|
|
30
|
-
function outline(_styles) {
|
|
31
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
32
|
-
return sanitizeOutline((0, _utils.sanitizeOutlineInput)(_styles, options), options);
|
|
33
|
-
}
|
|
34
|
-
function sanitizeOutline(_styles, options) {
|
|
35
|
-
var wrappedStyles = wrapStyles(_styles, options);
|
|
36
|
-
wrappedStyles.colors = wrappedStyles.colors || options && options.colors || userSetOptions && userSetOptions.colors;
|
|
37
|
-
return wrappedStyles;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//=====================================================
|
|
41
|
-
//============================================= Options
|
|
42
|
-
//=====================================================
|
|
43
|
-
|
|
44
|
-
function withOptions(options) {
|
|
45
|
-
if (!options) throw new Error("Bad options values for react-outline:" + JSON.stringify(options));
|
|
46
|
-
var tempOutlineFn = function tempOutlineFn(_styles, optionsOrLogic) {
|
|
47
|
-
return sanitizeOutline((0, _utils.sanitizeOutlineInput)(_styles, optionsOrLogic), options);
|
|
48
|
-
};
|
|
49
|
-
if (options.colors) {
|
|
50
|
-
tempOutlineFn.colors = options.colors;
|
|
51
|
-
}
|
|
52
|
-
return tempOutlineFn;
|
|
53
|
-
}
|
|
54
|
-
function setOptions(options) {
|
|
55
|
-
if (!options) throw new Error("Bad options values for react-outline:" + JSON.stringify(options));
|
|
56
|
-
if (options.colors) {
|
|
57
|
-
outline.colors = options.colors;
|
|
58
|
-
}
|
|
59
|
-
Object.assign(userSetOptions, options);
|
|
60
|
-
}
|
|
61
|
-
var testing = exports.testing = {
|
|
62
|
-
resetCSS: _utils.pubsub.clear
|
|
63
|
-
};
|
|
64
|
-
var _default = exports["default"] = outline;
|
package/dist/styleItem.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = _default;
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
var _element = _interopRequireDefault(require("./element"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
//=====================================================
|
|
11
|
-
//========================================== build Elem
|
|
12
|
-
//=====================================================
|
|
13
|
-
|
|
14
|
-
function buildElem(_ref) {
|
|
15
|
-
var elemName = _ref.elemName,
|
|
16
|
-
args = _ref.args,
|
|
17
|
-
styleCSS = _ref.styleCSS,
|
|
18
|
-
styleName = _ref.styleName,
|
|
19
|
-
options = _ref.options,
|
|
20
|
-
replacedStyle = _ref.replacedStyle,
|
|
21
|
-
colors = _ref.colors;
|
|
22
|
-
elemName = elemName[0] || args[1];
|
|
23
|
-
var inlineStyle = null; //replacedStyle[styleName]();
|
|
24
|
-
|
|
25
|
-
var baseStyle = styleCSS[styleName] && styleCSS[styleName].base || {};
|
|
26
|
-
for (var propN in styleCSS[styleName]) {
|
|
27
|
-
//if(specialCharacters.includes(propN[0]) || !!propN.match(new RegExp(`[${specialInnerCharacters}]`, "gi"))){
|
|
28
|
-
if (/^[a-zA-Z0-9-]+$/.test(propN) === false) {
|
|
29
|
-
baseStyle[propN] = styleCSS[styleName][propN];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//splict ":" and "@" from all over styles
|
|
33
|
-
var _separateCssStyle = (0, _utils.separateCssStyle)(baseStyle),
|
|
34
|
-
css = _separateCssStyle.css,
|
|
35
|
-
style = _separateCssStyle.style;
|
|
36
|
-
/*
|
|
37
|
-
const cssPropNames = Object.keys(styleCSS[styleName])
|
|
38
|
-
.filter(stylePropName => stylePropName[0] === "@" || stylePropName[0] === ":");
|
|
39
|
-
*/
|
|
40
|
-
var randomClassName = "";
|
|
41
|
-
|
|
42
|
-
//if(0 < cssPropNames.length){
|
|
43
|
-
if (css) {
|
|
44
|
-
randomClassName = "react-outline-";
|
|
45
|
-
if (!global.__TEST__) randomClassName += (0, _utils.makeid)();
|
|
46
|
-
_utils.pubsub.publish(randomClassName, (0, _utils.genCss)({
|
|
47
|
-
randomClassName: randomClassName,
|
|
48
|
-
css: css,
|
|
49
|
-
styleCSS: styleCSS,
|
|
50
|
-
colors: colors,
|
|
51
|
-
style: style,
|
|
52
|
-
styleName: styleName
|
|
53
|
-
}));
|
|
54
|
-
inlineStyle = {};
|
|
55
|
-
}
|
|
56
|
-
return (0, _element["default"])({
|
|
57
|
-
elemName: elemName,
|
|
58
|
-
css: css,
|
|
59
|
-
styleCSS: styleCSS,
|
|
60
|
-
inlineStyle: inlineStyle,
|
|
61
|
-
style: style,
|
|
62
|
-
styleName: styleName,
|
|
63
|
-
colors: colors,
|
|
64
|
-
randomClassName: randomClassName,
|
|
65
|
-
options: options,
|
|
66
|
-
replacedStyle: replacedStyle
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
//=====================================================
|
|
71
|
-
//===================================== build Style Obj
|
|
72
|
-
//=====================================================
|
|
73
|
-
|
|
74
|
-
function buildStyleObj(_ref2) {
|
|
75
|
-
var styleStuff = _ref2.styleStuff,
|
|
76
|
-
genStyles = _ref2.genStyles,
|
|
77
|
-
args = _ref2.args,
|
|
78
|
-
colors = _ref2.colors,
|
|
79
|
-
caching = _ref2.caching,
|
|
80
|
-
cached = _ref2.cached;
|
|
81
|
-
if (!caching) {
|
|
82
|
-
return genStyles(styleStuff, args, colors);
|
|
83
|
-
}
|
|
84
|
-
// quick test
|
|
85
|
-
if (cached.value && cached.source[0] === args[0] && cached.source[0] === args[1]) {
|
|
86
|
-
return cached.value;
|
|
87
|
-
}
|
|
88
|
-
// deep test
|
|
89
|
-
var key = "" + JSON.stringify(args[0]) + JSON.stringify(args[1]);
|
|
90
|
-
if (key === cached.key) {
|
|
91
|
-
return cached.value;
|
|
92
|
-
}
|
|
93
|
-
cached.key = key;
|
|
94
|
-
cached.source[0] = args[0];
|
|
95
|
-
cached.source[1] = args[1];
|
|
96
|
-
cached.value = genStyles(styleStuff, args, colors);
|
|
97
|
-
return cached.value;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//=====================================================
|
|
101
|
-
//========================================== style Item
|
|
102
|
-
//=====================================================
|
|
103
|
-
|
|
104
|
-
function _default(_ref3) {
|
|
105
|
-
var _styles = _ref3._styles,
|
|
106
|
-
replacedStyle = _ref3.replacedStyle,
|
|
107
|
-
styleCSS = _ref3.styleCSS,
|
|
108
|
-
colors = _ref3.colors,
|
|
109
|
-
options = _ref3.options,
|
|
110
|
-
caching = _ref3.caching,
|
|
111
|
-
wrapStyles = _ref3.wrapStyles;
|
|
112
|
-
//+++++++++++++++++++++++++++++++++++++ style function
|
|
113
|
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
114
|
-
return function (styleName) {
|
|
115
|
-
var styleFn = _styles[styleName] || function () {
|
|
116
|
-
return {};
|
|
117
|
-
};
|
|
118
|
-
var cached = {
|
|
119
|
-
key: null,
|
|
120
|
-
value: null,
|
|
121
|
-
source: []
|
|
122
|
-
};
|
|
123
|
-
replacedStyle[styleName] = function () {
|
|
124
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
125
|
-
args[_key] = arguments[_key];
|
|
126
|
-
}
|
|
127
|
-
var elemName = args[0];
|
|
128
|
-
|
|
129
|
-
//+++++++++++++++++++++++++++++++++++ build an element
|
|
130
|
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
131
|
-
|
|
132
|
-
if (Array.isArray(elemName) && elemName.hasOwnProperty("raw")) {
|
|
133
|
-
return buildElem({
|
|
134
|
-
elemName: elemName,
|
|
135
|
-
args: args,
|
|
136
|
-
styleCSS: styleCSS,
|
|
137
|
-
styleName: styleName,
|
|
138
|
-
options: options,
|
|
139
|
-
replacedStyle: replacedStyle,
|
|
140
|
-
colors: colors
|
|
141
|
-
});
|
|
142
|
-
} // elem gen
|
|
143
|
-
|
|
144
|
-
//++++++++++++++++++++++++++++++++++++++ generat style
|
|
145
|
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
146
|
-
|
|
147
|
-
var styleStuff = {
|
|
148
|
-
styleCSS: styleCSS[styleName],
|
|
149
|
-
styleFn: styleFn
|
|
150
|
-
};
|
|
151
|
-
return buildStyleObj({
|
|
152
|
-
styleStuff: styleStuff,
|
|
153
|
-
genStyles: _utils.genStyles,
|
|
154
|
-
args: args,
|
|
155
|
-
colors: colors,
|
|
156
|
-
caching: caching,
|
|
157
|
-
cached: cached
|
|
158
|
-
});
|
|
159
|
-
}; // END replacedStyle[styleName] = function(...args)
|
|
160
|
-
|
|
161
|
-
//+++++++++++++++++++++++++++++++++ step down the tree
|
|
162
|
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
163
|
-
|
|
164
|
-
if (0 < Object.keys(styleFn).length || (0, _utils.hasKids)(styleCSS[styleName])) {
|
|
165
|
-
Object.assign(replacedStyle[styleName], wrapStyles(styleFn, options, styleCSS[styleName]));
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = buildCssString;
|
|
7
|
-
function buildCssString(classesValues, props) {
|
|
8
|
-
var css = Object.keys(classesValues).map(function (className) {
|
|
9
|
-
return classesValues[className];
|
|
10
|
-
}).join(" ");
|
|
11
|
-
css += (props === null || props === void 0 ? void 0 : props.children) || "";
|
|
12
|
-
css = css.replace(/\n/g, ' ').replace(/\s+/g, ' ');
|
|
13
|
-
return css;
|
|
14
|
-
}
|
package/dist/utils/genCss.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = genCss;
|
|
7
|
-
var _object2css = _interopRequireDefault(require("./object2css"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function genCss(_ref) {
|
|
10
|
-
var randomClassName = _ref.randomClassName,
|
|
11
|
-
css = _ref.css,
|
|
12
|
-
styleCSS = _ref.styleCSS,
|
|
13
|
-
colors = _ref.colors,
|
|
14
|
-
style = _ref.style,
|
|
15
|
-
styleName = _ref.styleName;
|
|
16
|
-
var newStyle = style ? ".".concat(randomClassName, "{").concat((0, _object2css["default"])(colors, style), "}") : "";
|
|
17
|
-
newStyle = Object.keys(css).reduce(function (cssString, propName) {
|
|
18
|
-
var styleContent = (0, _object2css["default"])(colors, css[propName]
|
|
19
|
-
/* || styleCSS[styleName].base
|
|
20
|
-
&& styleCSS[styleName].base[propName]
|
|
21
|
-
|| styleCSS[styleName][propName]*/);
|
|
22
|
-
if (propName[0] === "@") return cssString + " ".concat(propName, "{ .").concat(randomClassName, "{ ").concat(styleContent, " } } ");else if (propName[0] === ":") return " .".concat(randomClassName).concat(propName, "{ ").concat(styleContent, " } ") + cssString;else return " .".concat(randomClassName, " ").concat(propName, "{ ").concat(styleContent, " } ") + cssString;
|
|
23
|
-
// else // skip unknown prop
|
|
24
|
-
// return cssString
|
|
25
|
-
}, newStyle);
|
|
26
|
-
return newStyle;
|
|
27
|
-
}
|
package/dist/utils/genStyles.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = genStyles;
|
|
7
|
-
var _inlineStylePrefixer = _interopRequireDefault(require("inline-style-prefixer"));
|
|
8
|
-
var _replacedStyleFn = _interopRequireDefault(require("./replacedStyleFn"));
|
|
9
|
-
var _replaceColors = _interopRequireDefault(require("./replaceColors"));
|
|
10
|
-
var _index = require("./index");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
var prefixer = new _inlineStylePrefixer["default"]();
|
|
13
|
-
function genStyles(styleStuff, args, colors) {
|
|
14
|
-
var userResult = (0, _replacedStyleFn["default"])(styleStuff, args);
|
|
15
|
-
var swapedColor = (0, _replaceColors["default"])(colors, userResult);
|
|
16
|
-
for (var name in swapedColor) {
|
|
17
|
-
//if(!specialCharacters.includes(name[0]))
|
|
18
|
-
swapedColor[name] = prefixer.prefix({
|
|
19
|
-
a: swapedColor[name]
|
|
20
|
-
}).a;
|
|
21
|
-
}
|
|
22
|
-
return swapedColor;
|
|
23
|
-
}
|
package/dist/utils/hasKids.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = hasKids;
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function hasKids(obj) {
|
|
9
|
-
for (var name in obj) {
|
|
10
|
-
if ("base" !== name && "object" === _typeof(obj[name])) return true;
|
|
11
|
-
}
|
|
12
|
-
}
|
package/dist/utils/index.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "buildCssString", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _buildCssString["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "genCss", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _genCss["default"];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "genStyles", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _genStyles["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "hasKids", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _hasKids["default"];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "makeid", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _makeid["default"];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "object2css", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _object2css["default"];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "pubsub", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _pubsub["default"];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "replaceColors", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function get() {
|
|
51
|
-
return _replaceColors["default"];
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(exports, "replacedStyleFn", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function get() {
|
|
57
|
-
return _replacedStyleFn["default"];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(exports, "sanitizeOutlineInput", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function get() {
|
|
63
|
-
return _sanitizeOutlineInput["default"];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "separateCssStyle", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: function get() {
|
|
69
|
-
return _separateCssStyle["default"];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
var _buildCssString = _interopRequireDefault(require("./buildCssString"));
|
|
73
|
-
var _genCss = _interopRequireDefault(require("./genCss"));
|
|
74
|
-
var _genStyles = _interopRequireDefault(require("./genStyles"));
|
|
75
|
-
var _hasKids = _interopRequireDefault(require("./hasKids"));
|
|
76
|
-
var _makeid = _interopRequireDefault(require("./makeid"));
|
|
77
|
-
var _object2css = _interopRequireDefault(require("./object2css"));
|
|
78
|
-
var _pubsub = _interopRequireDefault(require("./pubsub"));
|
|
79
|
-
var _replaceColors = _interopRequireDefault(require("./replaceColors"));
|
|
80
|
-
var _replacedStyleFn = _interopRequireDefault(require("./replacedStyleFn"));
|
|
81
|
-
var _sanitizeOutlineInput = _interopRequireDefault(require("./sanitizeOutlineInput"));
|
|
82
|
-
var _separateCssStyle = _interopRequireDefault(require("./separateCssStyle"));
|
|
83
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
package/dist/utils/makeid.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = makeid;
|
|
7
|
-
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
8
|
-
function makeid() {
|
|
9
|
-
var side = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
10
|
-
var text = "";
|
|
11
|
-
for (var i = 0; i < side; i++) text += possible.charAt(~~(Math.random() * possible.length));
|
|
12
|
-
return text;
|
|
13
|
-
}
|