react-outline 1.7.3 → 2.1.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/README.md +151 -116
- package/dist/Styles.js +34 -35
- package/dist/element.js +69 -88
- package/dist/main.js +22 -35
- package/dist/reactOutline.js +241 -0
- package/dist/reactOutline.js.map +7 -0
- package/dist/styleItem.js +105 -91
- package/dist/utils/buildCssString.js +2 -2
- package/dist/utils/genCss.js +21 -32
- package/dist/utils/genStyles.js +13 -26
- package/dist/utils/hasKids.js +2 -4
- package/dist/utils/index.js +80 -66
- package/dist/utils/makeid.js +3 -6
- package/dist/utils/object2css.js +10 -22
- package/dist/utils/pubsub.js +10 -24
- package/dist/utils/replaceColors.js +3 -4
- package/dist/utils/replacedStyleFn.js +5 -10
- package/dist/utils/sanitizeOutlineInput.js +8 -24
- package/dist/utils/separateCssStyle.js +5 -8
- package/dist/wrapStyles.js +18 -14
- package/index.d.ts +149 -0
- package/package.json +38 -24
- package/.babelrc +0 -6
- package/.travis.yml +0 -7
- package/__snapshots__/cornerCases.test.js.snap +0 -139
- package/__snapshots__/example.test.js.snap +0 -408
- package/cornerCases.test.js +0 -367
- package/dist/utils/sanitizeStyleObj.js +0 -22
- package/empty-module.js +0 -1
- package/example/.babelrc +0 -4
- package/example/.storybook/config.js +0 -7
- package/example/.storybook/webpack.config.js +0 -14
- package/example/README.md +0 -11
- package/example/package.json +0 -55
- package/example/stories/Animate/basic.js +0 -73
- package/example/stories/Basics/CreatingAndApplyingAStyle.js +0 -12
- package/example/stories/Basics/Form.js +0 -24
- package/example/stories/Basics/ImpliedTags.js +0 -40
- package/example/stories/Basics/PassingStyleAndFuntion.js +0 -13
- package/example/stories/Basics/PassingStyleAndFuntionAsArray.js +0 -13
- package/example/stories/Basics/ReusingElements.js +0 -13
- package/example/stories/Basics/Share.js +0 -19
- package/example/stories/Basics/UsingTheTagCreater.js +0 -13
- package/example/stories/Basics/WrappingAnExistingElement.js +0 -19
- package/example/stories/Button.js +0 -27
- package/example/stories/CSSHelpers/CssSelector.js +0 -24
- package/example/stories/CSSHelpers/CssSource.js +0 -18
- package/example/stories/CSSHelpers/DynamicCssSelectors.js +0 -24
- package/example/stories/CSSHelpers/Hover.js +0 -20
- package/example/stories/CSSHelpers/MediaQuery.js +0 -22
- package/example/stories/CSSHelpers/VendorPrefix.js +0 -19
- package/example/stories/CombineStyles/CreatingAndApplyingAStyle.js +0 -16
- package/example/stories/CombineStyles/LogicFnWithGenerateElement.js +0 -16
- package/example/stories/CombineStyles/PassStyleObjToGenerateElement.js +0 -9
- package/example/stories/CombineStyles/UsingAPropFlag.js +0 -16
- package/example/stories/CombineStyles/UsingTheTagCreater.js +0 -16
- package/example/stories/Ref/byFn.js +0 -51
- package/example/stories/Ref/onEvent.js +0 -43
- package/example/stories/RuntimeFunctions/DynamicStyles.js +0 -32
- package/example/stories/RuntimeFunctions/FunctionWithOutStyle.js +0 -31
- package/example/stories/RuntimeFunctions/ModifyingStyles.js +0 -36
- package/example/stories/RuntimeFunctions/WithGeneratedElements.js +0 -38
- package/example/stories/Welcome.js +0 -90
- package/example/stories/index.js +0 -88
- package/example/stories/load.js +0 -229
- package/example.test.js +0 -16
- package/source/Styles.js +0 -23
- package/source/element.js +0 -100
- package/source/main.js +0 -56
- package/source/styleItem.js +0 -105
- package/source/utils/buildCssString.js +0 -6
- package/source/utils/genCss.js +0 -30
- package/source/utils/genStyles.js +0 -19
- package/source/utils/hasKids.js +0 -6
- package/source/utils/index.js +0 -27
- package/source/utils/makeid.js +0 -9
- package/source/utils/object2css.js +0 -20
- package/source/utils/pubsub.js +0 -22
- package/source/utils/replaceColors.js +0 -11
- package/source/utils/replacedStyleFn.js +0 -30
- package/source/utils/sanitizeOutlineInput.js +0 -72
- package/source/utils/sanitizeStyleObj.js +0 -13
- package/source/utils/separateCssStyle.js +0 -25
- package/source/wrapStyles.js +0 -30
package/dist/utils/pubsub.js
CHANGED
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
8
|
+
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; } }
|
|
9
|
+
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; }
|
|
7
10
|
var pubsub = new function () {
|
|
8
|
-
|
|
9
11
|
var vals = {};
|
|
10
12
|
var subscribers = [];
|
|
11
|
-
|
|
12
13
|
this.publish = function (key, value) {
|
|
13
|
-
|
|
14
14
|
vals[key] = value;
|
|
15
15
|
subscribers.forEach(function (subscriber) {
|
|
16
16
|
return subscriber(vals);
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
-
|
|
20
19
|
this.subscribe = function (subscriber) {
|
|
21
20
|
return subscribers.push(subscriber);
|
|
22
21
|
};
|
|
@@ -24,31 +23,18 @@ var pubsub = new function () {
|
|
|
24
23
|
return vals;
|
|
25
24
|
};
|
|
26
25
|
this.clear = function () {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
var _iteratorError = undefined;
|
|
30
|
-
|
|
26
|
+
var _iterator = _createForOfIteratorHelper(Object.getOwnPropertyNames(vals)),
|
|
27
|
+
_step;
|
|
31
28
|
try {
|
|
32
|
-
for (
|
|
29
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
30
|
var className = _step.value;
|
|
34
|
-
|
|
35
31
|
delete vals[className];
|
|
36
32
|
}
|
|
37
33
|
} catch (err) {
|
|
38
|
-
|
|
39
|
-
_iteratorError = err;
|
|
34
|
+
_iterator.e(err);
|
|
40
35
|
} finally {
|
|
41
|
-
|
|
42
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
43
|
-
_iterator.return();
|
|
44
|
-
}
|
|
45
|
-
} finally {
|
|
46
|
-
if (_didIteratorError) {
|
|
47
|
-
throw _iteratorError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
36
|
+
_iterator.f();
|
|
50
37
|
}
|
|
51
38
|
};
|
|
52
39
|
}();
|
|
53
|
-
|
|
54
|
-
exports.default = pubsub;
|
|
40
|
+
var _default = exports["default"] = pubsub;
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
exports["default"] = _default;
|
|
7
|
+
function _default(colors, style) {
|
|
9
8
|
if (!colors) return style;
|
|
10
9
|
var result = Object.assign({}, style);
|
|
11
10
|
for (var key in result) {
|
|
@@ -14,4 +13,4 @@ exports.default = function (colors, style) {
|
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
return result;
|
|
17
|
-
}
|
|
16
|
+
}
|
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.default = replacedStyleFn;
|
|
6
|
+
exports["default"] = replacedStyleFn;
|
|
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); }
|
|
10
8
|
function replacedStyleFn(_ref, args) {
|
|
11
9
|
var styleCSS = _ref.styleCSS,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
styleFn = _ref.styleFn;
|
|
15
11
|
var processedStyles = 1 === styleFn.length ? styleFn(args[0]) : styleFn(styleCSS, args[0]);
|
|
16
12
|
|
|
17
13
|
// const styleAsPropObj = 0===styleFn.length && "object" === typeof args[0] ? args[0] : {};
|
|
@@ -26,15 +22,14 @@ function replacedStyleFn(_ref, args) {
|
|
|
26
22
|
|
|
27
23
|
//const autoAddStyles = [], firstVal = args[1]// || args[0];
|
|
28
24
|
var autoAddStyles = [],
|
|
29
|
-
|
|
25
|
+
firstVal = args[1] || args[0];
|
|
30
26
|
//console.log(args)
|
|
31
|
-
if (!!firstVal && "object" ===
|
|
27
|
+
if (!!firstVal && "object" === _typeof(firstVal)) {
|
|
32
28
|
Object.keys(firstVal).forEach(function (cssName) {
|
|
33
29
|
if (true === firstVal[cssName] && styleCSS && cssName in styleCSS) autoAddStyles.push(styleCSS[cssName]);
|
|
34
30
|
// else // to bind style value to output obj
|
|
35
31
|
// autoAddStyles.push({cssName:firstVal[cssName]})
|
|
36
32
|
});
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
return Object.assign.apply(Object, [{}, styleBase].concat(autoAddStyles, [processedStyles]));
|
|
40
35
|
}
|
|
@@ -3,45 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.default = sanitizeOutlineInput;
|
|
6
|
+
exports["default"] = sanitizeOutlineInput;
|
|
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); }
|
|
10
8
|
//+++++++++++++++++++++++++++++ { base:{}, foo: ()=> }
|
|
11
9
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
12
10
|
function sanitizeOutlineInput(_styles) {
|
|
13
11
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if ("object" !== (typeof _styles === "undefined" ? "undefined" : _typeof(_styles))) {
|
|
12
|
+
if ("object" !== _typeof(_styles) || Array.isArray(_styles)) {
|
|
17
13
|
throw new Error("Bad style values: " + JSON.stringify(_styles));
|
|
18
14
|
}
|
|
19
|
-
|
|
20
|
-
//+++++++++++++++++++++++++++++++++++++++ [ base, fn ]
|
|
21
|
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
22
|
-
if (Array.isArray(_styles)) {
|
|
23
|
-
|
|
24
|
-
_styles = Object.assign({}, { base: _styles[0] }, _styles[1]);
|
|
25
|
-
} else if (!("base" in _styles)) {
|
|
26
|
-
|
|
15
|
+
if (!("base" in _styles)) {
|
|
27
16
|
var base = {},
|
|
28
|
-
|
|
17
|
+
fns = {};
|
|
29
18
|
|
|
30
19
|
//++++++++++++++ { table: {}, header:{} }, fn:{ ()=> }
|
|
31
20
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
32
21
|
|
|
33
22
|
var optionsIsFns = true;
|
|
34
|
-
|
|
35
23
|
for (var prop in options) {
|
|
36
24
|
if (options.hasOwnProperty(prop) && "function" !== typeof options[prop]) {
|
|
37
25
|
optionsIsFns = false;
|
|
38
26
|
}
|
|
39
27
|
}
|
|
40
|
-
|
|
41
28
|
if (optionsIsFns) {
|
|
42
29
|
Object.assign(fns, options);
|
|
43
30
|
}
|
|
44
|
-
|
|
45
31
|
for (var _prop in _styles) {
|
|
46
32
|
//+++++++++++++++++++++++++++ { table: {}, header:{} }
|
|
47
33
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
@@ -55,11 +41,12 @@ function sanitizeOutlineInput(_styles) {
|
|
|
55
41
|
throw new Error("Bad style value: " + JSON.stringify(_styles[_prop]));
|
|
56
42
|
}
|
|
57
43
|
}
|
|
58
|
-
_styles = Object.assign({}, {
|
|
44
|
+
_styles = Object.assign({}, {
|
|
45
|
+
base: base
|
|
46
|
+
}, fns);
|
|
59
47
|
}
|
|
60
48
|
|
|
61
49
|
// apply sharing
|
|
62
|
-
|
|
63
50
|
var _loop = function _loop(_prop2) {
|
|
64
51
|
if (0 < _prop2.indexOf(',')) {
|
|
65
52
|
_prop2.split(',').map(function (x) {
|
|
@@ -71,16 +58,13 @@ function sanitizeOutlineInput(_styles) {
|
|
|
71
58
|
// e.g. "foo , bar" (cross cutting style) is in style Object
|
|
72
59
|
// but "foo" & "bar" are functions
|
|
73
60
|
root[x] && root[x].base ? root[x].base : root[x]);
|
|
74
|
-
|
|
75
61
|
root[x] && root[x].base ? root[x].base = val : root[x] = val;
|
|
76
62
|
});
|
|
77
63
|
delete _styles.base[_prop2];
|
|
78
64
|
}
|
|
79
65
|
};
|
|
80
|
-
|
|
81
66
|
for (var _prop2 in _styles.base) {
|
|
82
67
|
_loop(_prop2);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
return _styles;
|
|
86
70
|
}
|
|
@@ -3,24 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
6
|
+
exports["default"] = separateCssStyle;
|
|
8
7
|
//import { specialCharacters } from './index'
|
|
9
8
|
|
|
10
9
|
function separateCssStyle(styles) {
|
|
11
|
-
|
|
12
10
|
var css = {};
|
|
13
11
|
var style = {};
|
|
14
|
-
|
|
15
12
|
for (var name in styles) {
|
|
16
13
|
//if(specialCharacters.includes(name[0]) )//|| !!name.match(new RegExp(`[${specialInnerCharacters}]`, "gi")))
|
|
17
14
|
//if (!/^\w+$/.test(name))
|
|
18
15
|
if (!/^[a-zA-Z0-9-]+$/.test(name)) css[name] = styles[name];else style[name] = styles[name];
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
if (0 === Object.keys(css).length) css = null;
|
|
22
|
-
|
|
23
18
|
if (0 === Object.keys(style).length) style = null;
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
return {
|
|
20
|
+
css: css,
|
|
21
|
+
style: style
|
|
22
|
+
};
|
|
26
23
|
}
|
package/dist/wrapStyles.js
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
exports["default"] = _default;
|
|
7
|
+
var _styleItem = _interopRequireDefault(require("./styleItem"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
//=====================================================
|
|
10
|
+
//========================================= wrap Styles
|
|
11
|
+
//=====================================================
|
|
12
|
+
|
|
13
|
+
function _default(userSetOptions) {
|
|
8
14
|
return function wrapStyles(_styles, options, styleCSS) {
|
|
9
|
-
|
|
10
15
|
options = Object.assign({}, userSetOptions, options);
|
|
11
16
|
// const radium = !!options.radium;
|
|
12
17
|
var caching = !!options.caching;
|
|
@@ -14,21 +19,20 @@ exports.default = function (userSetOptions) {
|
|
|
14
19
|
styleCSS = _styles.base || styleCSS;
|
|
15
20
|
var replacedStyle = {};
|
|
16
21
|
if (_styles.base) replacedStyle.base = styleCSS;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
var styleItemGen = (0, _styleItem["default"])({
|
|
23
|
+
_styles: _styles,
|
|
24
|
+
replacedStyle: replacedStyle,
|
|
25
|
+
styleCSS: styleCSS,
|
|
26
|
+
colors: colors,
|
|
27
|
+
options: options,
|
|
28
|
+
caching: caching,
|
|
29
|
+
wrapStyles: wrapStyles
|
|
30
|
+
});
|
|
20
31
|
Object.keys(_styles).concat(Object.keys(styleCSS)).filter(function (item, pos, a) {
|
|
21
32
|
return a.indexOf(item) === pos;
|
|
22
33
|
}).filter(function (styleName) {
|
|
23
34
|
return "base" !== styleName;
|
|
24
35
|
}).forEach(styleItemGen);
|
|
25
|
-
|
|
26
36
|
return replacedStyle;
|
|
27
37
|
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _styleItem = require("./styleItem");
|
|
31
|
-
|
|
32
|
-
var _styleItem2 = _interopRequireDefault(_styleItem);
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
// CSS style value types
|
|
4
|
+
type CSSValue = string | number;
|
|
5
|
+
type CSSProperties = React.CSSProperties;
|
|
6
|
+
|
|
7
|
+
// Color palette mapping
|
|
8
|
+
type ColorMap = Record<string, string>;
|
|
9
|
+
|
|
10
|
+
// Options for outline configuration
|
|
11
|
+
interface OutlineOptions {
|
|
12
|
+
/** Enable caching of styles (default: false) */
|
|
13
|
+
caching?: boolean;
|
|
14
|
+
/** Color palette mapping for color values */
|
|
15
|
+
colors?: ColorMap;
|
|
16
|
+
/** Add name attribute to DOM elements for debugging (default: true) */
|
|
17
|
+
named?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// CSS selector styles (for :hover, @media, etc.)
|
|
21
|
+
type CSSSelector = {
|
|
22
|
+
[selector: string]: CSSProperties;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Style definition with optional base and variant styles
|
|
26
|
+
type StyleDefinition = CSSProperties | {
|
|
27
|
+
base?: CSSProperties;
|
|
28
|
+
[variant: string]: CSSProperties | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Style input object - keys are style names
|
|
32
|
+
type StyleInput = {
|
|
33
|
+
[styleName: string]: StyleDefinition;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Logic function types
|
|
37
|
+
type StyleLogicFn<T = any> = (arg: T) => CSSProperties;
|
|
38
|
+
type StyleModifierFn<T = any> = (baseStyle: CSSProperties, arg: T) => CSSProperties;
|
|
39
|
+
|
|
40
|
+
// Logic functions object - keys are style names
|
|
41
|
+
type LogicInput = {
|
|
42
|
+
[styleName: string]: StyleLogicFn | StyleModifierFn;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Props for generated styled components
|
|
46
|
+
interface StyledComponentProps<T = any> extends React.HTMLAttributes<HTMLElement> {
|
|
47
|
+
/** Style overrides or variant flags */
|
|
48
|
+
style?: CSSProperties | Record<string, boolean> | T;
|
|
49
|
+
/** CSS selector overrides for dynamic styling */
|
|
50
|
+
css?: CSSSelector;
|
|
51
|
+
/** DOM event handlers with direct element access */
|
|
52
|
+
onDomEvent?: {
|
|
53
|
+
[eventName: string]: (element: Element, event: Event) => void;
|
|
54
|
+
};
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Generated styled component
|
|
59
|
+
type StyledComponent = React.ComponentClass<StyledComponentProps>;
|
|
60
|
+
|
|
61
|
+
// Style function that returns inline styles
|
|
62
|
+
interface StyleFunction {
|
|
63
|
+
/** Get the inline styles, optionally with variant flags */
|
|
64
|
+
(variants?: Record<string, boolean>): CSSProperties;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Tagged template literal function for creating styled components
|
|
68
|
+
interface TagCreator {
|
|
69
|
+
(strings: TemplateStringsArray, ...values: any[]): StyledComponent;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Combined style item - both a function and a tag creator
|
|
73
|
+
type StyleItem = StyleFunction & TagCreator & {
|
|
74
|
+
/** Color palette if configured */
|
|
75
|
+
colors?: ColorMap;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Processed styles object
|
|
79
|
+
type ProcessedStyles<T extends StyleInput> = {
|
|
80
|
+
[K in keyof T]: StyleItem;
|
|
81
|
+
} & {
|
|
82
|
+
/** Color palette if configured */
|
|
83
|
+
colors?: ColorMap;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Outline function signature
|
|
87
|
+
interface OutlineFunction {
|
|
88
|
+
/** Process style definitions into usable style functions */
|
|
89
|
+
<T extends StyleInput>(styles: T, logic?: LogicInput): ProcessedStyles<T>;
|
|
90
|
+
/** Color palette if configured via setOptions */
|
|
91
|
+
colors?: ColorMap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Outline function with options pre-configured
|
|
95
|
+
interface ConfiguredOutlineFunction extends OutlineFunction {
|
|
96
|
+
/** Color palette if configured via withOptions */
|
|
97
|
+
colors?: ColorMap;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Props for the Styles component
|
|
101
|
+
interface StylesProps {
|
|
102
|
+
/** Optional: filter which styles to include */
|
|
103
|
+
[key: string]: any;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Styles component for CSS output (media queries, hover states, etc.)
|
|
107
|
+
interface StylesComponent extends React.FC<StylesProps> {
|
|
108
|
+
/** Get CSS string for server-side rendering */
|
|
109
|
+
toString(): string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Testing utilities
|
|
113
|
+
interface TestingUtils {
|
|
114
|
+
/** Reset all generated CSS (useful in tests) */
|
|
115
|
+
resetCSS: () => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Main outline function
|
|
119
|
+
declare const outline: OutlineFunction;
|
|
120
|
+
|
|
121
|
+
// Create outline function with custom options
|
|
122
|
+
declare function withOptions(options: OutlineOptions): ConfiguredOutlineFunction;
|
|
123
|
+
|
|
124
|
+
// Set global default options
|
|
125
|
+
declare function setOptions(options: OutlineOptions): void;
|
|
126
|
+
|
|
127
|
+
// Styles component for CSS injection
|
|
128
|
+
declare const Styles: StylesComponent;
|
|
129
|
+
|
|
130
|
+
// Testing utilities
|
|
131
|
+
declare const testing: TestingUtils;
|
|
132
|
+
|
|
133
|
+
export default outline;
|
|
134
|
+
export { withOptions, setOptions, Styles, testing };
|
|
135
|
+
export type {
|
|
136
|
+
OutlineOptions,
|
|
137
|
+
StyleInput,
|
|
138
|
+
LogicInput,
|
|
139
|
+
StyleDefinition,
|
|
140
|
+
StyleFunction,
|
|
141
|
+
StyledComponent,
|
|
142
|
+
StyledComponentProps,
|
|
143
|
+
ProcessedStyles,
|
|
144
|
+
ColorMap,
|
|
145
|
+
CSSProperties,
|
|
146
|
+
CSSSelector,
|
|
147
|
+
StylesProps,
|
|
148
|
+
TestingUtils,
|
|
149
|
+
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-outline",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "react styling framework to keep your makeup clean",
|
|
5
|
-
"main": "./dist/
|
|
5
|
+
"main": "./dist/reactOutline.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"index.d.ts"
|
|
10
|
+
],
|
|
6
11
|
"scripts": {
|
|
12
|
+
"prepare": "cp .hooks/* .git/hooks/ 2>/dev/null && chmod +x .git/hooks/* || true",
|
|
7
13
|
"build": "babel --copy-files source --out-dir dist",
|
|
8
14
|
"build:watch": "babel --copy-files source --out-dir dist -s --source-maps inline -w",
|
|
9
15
|
"test": "jest --no-cache ",
|
|
10
16
|
"test:go": "npm test -- --watch --coverage",
|
|
11
17
|
"test:update": "npm test -- --updateSnapshot",
|
|
12
18
|
"test:cover": "npm test -- --coverage --no-cache",
|
|
13
|
-
"test:watch": "npm test -- --watch --runInBand"
|
|
19
|
+
"test:watch": "npm test -- --watch --runInBand",
|
|
20
|
+
"release": "bash scripts/_publish.sh"
|
|
14
21
|
},
|
|
15
22
|
"repository": {
|
|
16
23
|
"type": "git",
|
|
@@ -36,28 +43,31 @@
|
|
|
36
43
|
"dependencies": {
|
|
37
44
|
"add-px-to-style": "^1.0.0",
|
|
38
45
|
"hyphenate-style-name": "^1.0.2",
|
|
39
|
-
"inline-style-prefixer": "^3.0.6"
|
|
40
|
-
|
|
46
|
+
"inline-style-prefixer": "^3.0.6"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": ">=16.0.0 <20.0.0"
|
|
41
50
|
},
|
|
42
51
|
"devDependencies": {
|
|
43
|
-
"babel": "^
|
|
44
|
-
"babel
|
|
45
|
-
"babel
|
|
46
|
-
"babel-
|
|
47
|
-
"babel
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
52
|
+
"@babel/cli": "^7.23.0",
|
|
53
|
+
"@babel/core": "^7.23.0",
|
|
54
|
+
"@babel/plugin-proposal-decorators": "^7.23.0",
|
|
55
|
+
"@babel/preset-env": "^7.23.0",
|
|
56
|
+
"@babel/preset-react": "^7.23.0",
|
|
57
|
+
"@faker-js/faker": "^8.3.0",
|
|
58
|
+
"@testing-library/jest-dom": "^6.1.0",
|
|
59
|
+
"@testing-library/react": "^14.1.0",
|
|
60
|
+
"coveralls": "^3.1.1",
|
|
61
|
+
"esbuild": "^0.24.2",
|
|
62
|
+
"jest": "^29.7.0",
|
|
63
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
64
|
+
"raw-loader": "^4.0.2",
|
|
65
|
+
"react": "^18.2.0",
|
|
66
|
+
"react-dom": "^18.2.0",
|
|
67
|
+
"react-test-renderer": "^18.2.0"
|
|
56
68
|
},
|
|
57
69
|
"jest": {
|
|
58
|
-
"
|
|
59
|
-
"__TEST__": true
|
|
60
|
-
},
|
|
70
|
+
"testEnvironment": "jsdom",
|
|
61
71
|
"moduleNameMapper": {
|
|
62
72
|
"\\.(css|jpg|png)$": "<rootDir>/empty-module.js",
|
|
63
73
|
"^raw-loader": "<rootDir>/empty-module.js",
|
|
@@ -65,13 +75,17 @@
|
|
|
65
75
|
"^react-addons-css-transition-group$": "<rootDir>/empty-module.js"
|
|
66
76
|
},
|
|
67
77
|
"testPathIgnorePatterns": [
|
|
68
|
-
"/node_modules/"
|
|
78
|
+
"/node_modules/",
|
|
79
|
+
"example.test.js"
|
|
69
80
|
],
|
|
70
81
|
"coverageDirectory": "coverage",
|
|
71
82
|
"collectCoverageFrom": [
|
|
72
83
|
"source/**/*.js",
|
|
73
84
|
"!source/utils/index.js"
|
|
74
85
|
],
|
|
75
|
-
"verbose": true
|
|
86
|
+
"verbose": true,
|
|
87
|
+
"setupFilesAfterEnv": [
|
|
88
|
+
"<rootDir>/jest.setup.js"
|
|
89
|
+
]
|
|
76
90
|
}
|
|
77
|
-
}
|
|
91
|
+
}
|
package/.babelrc
DELETED
package/.travis.yml
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
node_js:
|
|
3
|
-
- "7.9.0"
|
|
4
|
-
# https://strongloop.com/strongblog/npm-modules-travis-coveralls/
|
|
5
|
-
script: npm run-script test:cover
|
|
6
|
-
# Send coverage data to Coveralls
|
|
7
|
-
after_success: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|