react-outline 1.7.2 → 2.0.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.
Files changed (84) hide show
  1. package/README.md +151 -116
  2. package/dist/Styles.js +34 -35
  3. package/dist/element.js +69 -88
  4. package/dist/main.js +22 -35
  5. package/dist/reactOutline.js +241 -0
  6. package/dist/reactOutline.js.map +7 -0
  7. package/dist/styleItem.js +105 -91
  8. package/dist/utils/buildCssString.js +2 -2
  9. package/dist/utils/genCss.js +21 -32
  10. package/dist/utils/genStyles.js +13 -26
  11. package/dist/utils/hasKids.js +2 -4
  12. package/dist/utils/index.js +81 -61
  13. package/dist/utils/makeid.js +3 -6
  14. package/dist/utils/object2css.js +10 -22
  15. package/dist/utils/pubsub.js +10 -24
  16. package/dist/utils/replaceColors.js +3 -4
  17. package/dist/utils/replacedStyleFn.js +5 -10
  18. package/dist/utils/sanitizeOutlineInput.js +8 -24
  19. package/dist/utils/separateCssStyle.js +5 -8
  20. package/dist/wrapStyles.js +18 -14
  21. package/package.json +36 -24
  22. package/.babelrc +0 -6
  23. package/.npmignore +0 -30
  24. package/.travis.yml +0 -7
  25. package/__snapshots__/cornerCases.test.js.snap +0 -139
  26. package/__snapshots__/example.test.js.snap +0 -408
  27. package/cornerCases.test.js +0 -367
  28. package/dist/utils/sanitizeStyleObj.js +0 -22
  29. package/empty-module.js +0 -1
  30. package/example/.babelrc +0 -4
  31. package/example/.storybook/config.js +0 -7
  32. package/example/.storybook/webpack.config.js +0 -14
  33. package/example/README.md +0 -11
  34. package/example/package.json +0 -55
  35. package/example/stories/Animate/basic.js +0 -73
  36. package/example/stories/Basics/CreatingAndApplyingAStyle.js +0 -12
  37. package/example/stories/Basics/Form.js +0 -24
  38. package/example/stories/Basics/ImpliedTags.js +0 -40
  39. package/example/stories/Basics/PassingStyleAndFuntion.js +0 -13
  40. package/example/stories/Basics/PassingStyleAndFuntionAsArray.js +0 -13
  41. package/example/stories/Basics/ReusingElements.js +0 -13
  42. package/example/stories/Basics/Share.js +0 -19
  43. package/example/stories/Basics/UsingTheTagCreater.js +0 -13
  44. package/example/stories/Basics/WrappingAnExistingElement.js +0 -19
  45. package/example/stories/Button.js +0 -27
  46. package/example/stories/CSSHelpers/CssSelector.js +0 -24
  47. package/example/stories/CSSHelpers/CssSource.js +0 -18
  48. package/example/stories/CSSHelpers/DynamicCssSelectors.js +0 -24
  49. package/example/stories/CSSHelpers/Hover.js +0 -20
  50. package/example/stories/CSSHelpers/MediaQuery.js +0 -22
  51. package/example/stories/CSSHelpers/VendorPrefix.js +0 -19
  52. package/example/stories/CombineStyles/CreatingAndApplyingAStyle.js +0 -16
  53. package/example/stories/CombineStyles/LogicFnWithGenerateElement.js +0 -16
  54. package/example/stories/CombineStyles/PassStyleObjToGenerateElement.js +0 -9
  55. package/example/stories/CombineStyles/UsingAPropFlag.js +0 -16
  56. package/example/stories/CombineStyles/UsingTheTagCreater.js +0 -16
  57. package/example/stories/Ref/byFn.js +0 -51
  58. package/example/stories/Ref/onEvent.js +0 -43
  59. package/example/stories/RuntimeFunctions/DynamicStyles.js +0 -32
  60. package/example/stories/RuntimeFunctions/FunctionWithOutStyle.js +0 -31
  61. package/example/stories/RuntimeFunctions/ModifyingStyles.js +0 -36
  62. package/example/stories/RuntimeFunctions/WithGeneratedElements.js +0 -38
  63. package/example/stories/Welcome.js +0 -90
  64. package/example/stories/index.js +0 -88
  65. package/example/stories/load.js +0 -229
  66. package/example.test.js +0 -16
  67. package/source/Styles.js +0 -23
  68. package/source/element.js +0 -100
  69. package/source/main.js +0 -56
  70. package/source/styleItem.js +0 -105
  71. package/source/utils/buildCssString.js +0 -6
  72. package/source/utils/genCss.js +0 -30
  73. package/source/utils/genStyles.js +0 -19
  74. package/source/utils/hasKids.js +0 -6
  75. package/source/utils/index.js +0 -33
  76. package/source/utils/makeid.js +0 -9
  77. package/source/utils/object2css.js +0 -20
  78. package/source/utils/pubsub.js +0 -22
  79. package/source/utils/replaceColors.js +0 -11
  80. package/source/utils/replacedStyleFn.js +0 -30
  81. package/source/utils/sanitizeOutlineInput.js +0 -72
  82. package/source/utils/sanitizeStyleObj.js +0 -13
  83. package/source/utils/separateCssStyle.js +0 -25
  84. package/source/wrapStyles.js +0 -30
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- exports.default = function (colors, style) {
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
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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
- styleFn = _ref.styleFn;
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
- firstVal = args[1] || args[0];
25
+ firstVal = args[1] || args[0];
30
26
  //console.log(args)
31
- if (!!firstVal && "object" === (typeof firstVal === "undefined" ? "undefined" : _typeof(firstVal))) {
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
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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
- fns = {};
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({}, { base: base }, fns);
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.default = separateCssStyle;
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
- return { css: css, style: style };
19
+ return {
20
+ css: css,
21
+ style: style
22
+ };
26
23
  }
@@ -3,10 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- exports.default = function (userSetOptions) {
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
- var styleItemGen = (0, _styleItem2.default)({ _styles: _styles, replacedStyle: replacedStyle, styleCSS: styleCSS, colors: colors, options: options, caching: caching, wrapStyles: wrapStyles });
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/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "react-outline",
3
- "version": "1.7.2",
3
+ "version": "2.0.0",
4
4
  "description": "react styling framework to keep your makeup clean",
5
- "main": "./dist/main.js",
5
+ "main": "./dist/reactOutline.js",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "scripts": {
10
+ "prepare": "cp .hooks/* .git/hooks/ 2>/dev/null && chmod +x .git/hooks/* || true",
7
11
  "build": "babel --copy-files source --out-dir dist",
8
12
  "build:watch": "babel --copy-files source --out-dir dist -s --source-maps inline -w",
9
13
  "test": "jest --no-cache ",
10
14
  "test:go": "npm test -- --watch --coverage",
11
15
  "test:update": "npm test -- --updateSnapshot",
12
16
  "test:cover": "npm test -- --coverage --no-cache",
13
- "test:watch": "npm test -- --watch --runInBand"
17
+ "test:watch": "npm test -- --watch --runInBand",
18
+ "release": "bash scripts/_publish.sh"
14
19
  },
15
20
  "repository": {
16
21
  "type": "git",
@@ -36,28 +41,31 @@
36
41
  "dependencies": {
37
42
  "add-px-to-style": "^1.0.0",
38
43
  "hyphenate-style-name": "^1.0.2",
39
- "inline-style-prefixer": "^3.0.6",
40
- "react": "^15.6.1"
44
+ "inline-style-prefixer": "^3.0.6"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=16.0.0 <20.0.0"
41
48
  },
42
49
  "devDependencies": {
43
- "babel": "^6.23.0",
44
- "babel-cli": "^6.24.1",
45
- "babel-plugin-transform-decorators-legacy": "^1.3.4",
46
- "babel-plugin-transform-object-rest-spread": "^6.23.0",
47
- "babel-preset-es2015": "^6.24.1",
48
- "babel-preset-react": "^6.24.1",
49
- "coveralls": "^2.13.1",
50
- "enzyme": "^2.9.1",
51
- "faker": "^4.1.0",
52
- "jest": "^20.0.4",
53
- "raw-loader": "^0.5.1",
54
- "react-dom": "^15.6.1",
55
- "react-test-renderer": "^15.6.1"
50
+ "@babel/cli": "^7.23.0",
51
+ "@babel/core": "^7.23.0",
52
+ "@babel/plugin-proposal-decorators": "^7.23.0",
53
+ "@babel/preset-env": "^7.23.0",
54
+ "@babel/preset-react": "^7.23.0",
55
+ "@faker-js/faker": "^8.3.0",
56
+ "@testing-library/jest-dom": "^6.1.0",
57
+ "@testing-library/react": "^14.1.0",
58
+ "coveralls": "^3.1.1",
59
+ "esbuild": "^0.24.2",
60
+ "jest": "^29.7.0",
61
+ "jest-environment-jsdom": "^29.7.0",
62
+ "raw-loader": "^4.0.2",
63
+ "react": "^18.2.0",
64
+ "react-dom": "^18.2.0",
65
+ "react-test-renderer": "^18.2.0"
56
66
  },
57
67
  "jest": {
58
- "globals": {
59
- "__TEST__": true
60
- },
68
+ "testEnvironment": "jsdom",
61
69
  "moduleNameMapper": {
62
70
  "\\.(css|jpg|png)$": "<rootDir>/empty-module.js",
63
71
  "^raw-loader": "<rootDir>/empty-module.js",
@@ -65,13 +73,17 @@
65
73
  "^react-addons-css-transition-group$": "<rootDir>/empty-module.js"
66
74
  },
67
75
  "testPathIgnorePatterns": [
68
- "/node_modules/"
76
+ "/node_modules/",
77
+ "example.test.js"
69
78
  ],
70
79
  "coverageDirectory": "coverage",
71
80
  "collectCoverageFrom": [
72
81
  "source/**/*.js",
73
82
  "!source/utils/index.js"
74
83
  ],
75
- "verbose": true
84
+ "verbose": true,
85
+ "setupFilesAfterEnv": [
86
+ "<rootDir>/jest.setup.js"
87
+ ]
76
88
  }
77
- }
89
+ }
package/.babelrc DELETED
@@ -1,6 +0,0 @@
1
-
2
- {
3
- "presets": ["react", "es2015" ],
4
- "plugins": ["transform-decorators-legacy"]
5
-
6
- }
package/.npmignore DELETED
@@ -1,30 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
-
5
- # System Files
6
- .DS_Store
7
- ._.DS_Store
8
- Thumbs.db
9
-
10
- # Dependency directory
11
- node_modules
12
- example/node_modules
13
- example/storybook-static
14
- example/dist
15
-
16
- # Linter
17
- linters/
18
-
19
- # testing
20
- /coverage
21
-
22
- # compiled output
23
- /build
24
- /Release
25
- /dll
26
- .tmp
27
- documentation/*.html
28
-
29
- # misc
30
- .env
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"
@@ -1,139 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`CSS selectors should allow for color replacment 1`] = `
4
- <div>
5
- <style>
6
- .react-outline- .abc{ font-size:20px; } .react-outline-{color:squanchy; }
7
- </style>
8
- <div
9
- className="react-outline-"
10
- name="div"
11
- />
12
- </div>
13
- `;
14
-
15
- exports[`CSS selectors should allow you to select a nested element 1`] = `
16
- <div>
17
- <style>
18
- .react-outline- .abc{ font-size:20px; } .react-outline-{color:red; }
19
- </style>
20
- <div
21
- className="react-outline-"
22
- name="div"
23
- />
24
- </div>
25
- `;
26
-
27
- exports[`CSS selectors should work with user defined callNames 1`] = `
28
- <div>
29
- <div
30
- className="a react-outline-"
31
- name="a"
32
- />
33
- <div
34
- className="react-outline-"
35
- name="a"
36
- />
37
- <div
38
- className="b"
39
- name="b"
40
- />
41
- <div
42
- name="b"
43
- />
44
- </div>
45
- `;
46
-
47
- exports[`In production mode should allow cross cutting style to map to only functions 1`] = `
48
- <span
49
- name="foo"
50
- style={
51
- Object {
52
- "background": "gray",
53
- "fontSize": "20px",
54
- }
55
- }
56
- />
57
- `;
58
-
59
- exports[`In production mode should allow cross cutting style to map to only functions 2`] = `
60
- <span
61
- name="bar"
62
- style={
63
- Object {
64
- "background": "black",
65
- "fontSize": "20px",
66
- }
67
- }
68
- />
69
- `;
70
-
71
- exports[`In production mode should be able to destructur assignments on generated element 1`] = `
72
- <div
73
- name="cats"
74
- style={
75
- Object {
76
- "color": "pink",
77
- }
78
- }
79
- />
80
- `;
81
-
82
- exports[`In production mode should be able to destructur assignments on generated element 2`] = `
83
- <div
84
- name="cats"
85
- style={
86
- Object {
87
- "color": "blue",
88
- }
89
- }
90
- />
91
- `;
92
-
93
- exports[`In production mode should be able to pass an value to style logic 1`] = `
94
- <div
95
- name="dogs"
96
- style={
97
- Object {
98
- "color": "white",
99
- }
100
- }
101
- />
102
- `;
103
-
104
- exports[`In production mode should be able to pass an value to style logic 2`] = `
105
- <div
106
- name="dogs"
107
- style={
108
- Object {
109
- "color": "black",
110
- }
111
- }
112
- />
113
- `;
114
-
115
- exports[`In production mode should be able to pass true value 1`] = `
116
- <input
117
- disabled={true}
118
- name="input"
119
- style={
120
- Object {
121
- "background": "gray",
122
- "color": "red",
123
- "fontSize": "20px",
124
- }
125
- }
126
- />
127
- `;
128
-
129
- exports[`In production mode should generated an element with a logic fn that can take undefined 1`] = `
130
- <span
131
- name="foo"
132
- style={
133
- Object {
134
- "background": "gray",
135
- "fontSize": "20px",
136
- }
137
- }
138
- />
139
- `;