@cloudflare/style-container 7.5.24 → 7.6.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 CHANGED
@@ -3,6 +3,42 @@
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
+ # [7.6.0](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@7.5.27...@cloudflare/style-container@7.6.0) (2022-01-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * **style-container:** A11Y-584 Add style filter function ([614c27d](http://stash.cfops.it:7999/fe/stratus/commits/614c27d))
12
+ * **style-container:** A11Y-584 Export styleRuleProps ([084e735](http://stash.cfops.it:7999/fe/stratus/commits/084e735))
13
+
14
+
15
+
16
+
17
+
18
+ ## [7.5.27](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@7.5.26...@cloudflare/style-container@7.5.27) (2021-12-28)
19
+
20
+ **Note:** Version bump only for package @cloudflare/style-container
21
+
22
+
23
+
24
+
25
+
26
+ ## [7.5.26](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@7.5.24...@cloudflare/style-container@7.5.26) (2021-12-21)
27
+
28
+ **Note:** Version bump only for package @cloudflare/style-container
29
+
30
+
31
+
32
+
33
+
34
+ ## [7.5.25](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@7.5.24...@cloudflare/style-container@7.5.25) (2021-12-21)
35
+
36
+ **Note:** Version bump only for package @cloudflare/style-container
37
+
38
+
39
+
40
+
41
+
6
42
  ## [7.5.24](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@7.5.23...@cloudflare/style-container@7.5.24) (2021-12-09)
7
43
 
8
44
  **Note:** Version bump only for package @cloudflare/style-container
@@ -25,7 +25,8 @@ declare const colorProps: readonly ["color", "backgroundColor", "borderColor", "
25
25
  declare const borderStyleProps: readonly ["borderStyle", "borderTopStyle", "borderBottomStyle", "borderLeftStyle", "borderRightStyle"];
26
26
  declare const borderWidthProps: readonly ["borderWidth", "borderTopWidth", "borderBottomWidth", "borderLeftWidth", "borderRightWidth"];
27
27
  declare const borderRadiusProps: readonly ["borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderbottomRightRadius"];
28
- declare const styleRuleProps: ("p" | "color" | "height" | "width" | "cursor" | "display" | "fontSize" | "fontWeight" | "textDecoration" | "textAlign" | "backgroundColor" | "borderColor" | "borderLeftColor" | "borderRightColor" | "borderTopColor" | "borderBottomColor" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "margin" | "marginTop" | "marginRight" | "marginLeft" | "padding" | "paddingTop" | "paddingRight" | "paddingLeft" | "borderRadius" | "verticalAlign" | "alignItems" | "alignSelf" | "borderBottomLeftRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftStyle" | "borderLeftWidth" | "borderRightStyle" | "borderRightWidth" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "boxSizing" | "justifyContent" | "marginBottom" | "paddingBottom" | "textTransform" | "borderStyle" | "borderWidth" | "m" | "ml" | "mr" | "mt" | "mb" | "mx" | "my" | "pl" | "pr" | "pt" | "pb" | "px" | "py" | "borderbottomRightRadius")[];
28
+ export declare const styleRuleProps: ("p" | "color" | "height" | "width" | "cursor" | "display" | "fontSize" | "fontWeight" | "textDecoration" | "textAlign" | "backgroundColor" | "borderColor" | "borderLeftColor" | "borderRightColor" | "borderTopColor" | "borderBottomColor" | "minWidth" | "minHeight" | "maxWidth" | "maxHeight" | "margin" | "marginTop" | "marginRight" | "marginLeft" | "padding" | "paddingTop" | "paddingRight" | "paddingLeft" | "borderRadius" | "verticalAlign" | "alignItems" | "alignSelf" | "borderBottomLeftRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderLeftStyle" | "borderLeftWidth" | "borderRightStyle" | "borderRightWidth" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "boxSizing" | "justifyContent" | "marginBottom" | "paddingBottom" | "textTransform" | "borderStyle" | "borderWidth" | "m" | "ml" | "mr" | "mt" | "mb" | "mx" | "my" | "pl" | "pr" | "pt" | "pb" | "px" | "py" | "borderbottomRightRadius")[];
29
+ export declare function filterStyleProps<Type extends {}>(props: Type): Type;
29
30
  declare type StyleRuleProp = typeof styleRuleProps[number];
30
31
  declare type ExpandedCSSProperty<P extends StyleRuleProp> = P extends ShorthandSpacingProp ? ShorthandToLonghandMap[P][0] : P;
31
32
  declare type CSSPropertyValue<P> = P extends keyof React.CSSProperties ? React.CSSProperties[P] : never;
package/dist/index.d.ts CHANGED
@@ -4,10 +4,10 @@ import applyStaticStyles from './applyStaticStyles';
4
4
  import applyTheme from './applyTheme';
5
5
  import createComponent from './createComponent';
6
6
  import createComponentStyles from './createComponentStyles';
7
- import createStyledComponent from './createStyledComponent';
7
+ import createStyledComponent, { filterStyleProps } from './createStyledComponent';
8
8
  import withRenderer from './withRenderer';
9
9
  import { isValidElementProp, filterValidElementProps } from './isValidElementProp';
10
10
  import { WithTheme } from './types';
11
11
  export * from './types';
12
12
  export declare const withTheme: WithTheme;
13
- export { createComponent, applyTheme, ThemeProvider, FelaTheme, connect, combineRules, createComponentStyles, withRenderer, applyStaticStyles, createStyledComponent, isValidElementProp, filterValidElementProps };
13
+ export { createComponent, applyTheme, ThemeProvider, FelaTheme, connect, combineRules, createComponentStyles, withRenderer, applyStaticStyles, createStyledComponent, isValidElementProp, filterValidElementProps, filterStyleProps };
@@ -35,7 +35,20 @@ const borderStyleProps = ['borderStyle', 'borderTopStyle', 'borderBottomStyle',
35
35
  const borderWidthProps = ['borderWidth', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth'];
36
36
  const borderRadiusProps = ['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderbottomRightRadius'];
37
37
  const additionalProps = ['fontSize', 'fontWeight', 'textAlign', 'display', 'width', 'verticalAlign', 'alignItems', 'alignSelf', 'justifyContent', 'textDecoration', 'textTransform', 'boxSizing', 'cursor'];
38
- const styleRuleProps = [...spacingProps, ...sizeProps, ...colorProps, ...borderStyleProps, ...borderWidthProps, ...borderRadiusProps, ...additionalProps];
38
+ export const styleRuleProps = [...spacingProps, ...sizeProps, ...colorProps, ...borderStyleProps, ...borderWidthProps, ...borderRadiusProps, ...additionalProps];
39
+ const stylesRulePropsSet = new Set(styleRuleProps); // Function to remove styling attributes from a Props object
40
+
41
+ export function filterStyleProps(props) {
42
+ let newProps;
43
+ const properties = Object.keys(props);
44
+ properties.forEach(property => {
45
+ if (stylesRulePropsSet.has(property)) {
46
+ newProps = newProps || _objectSpread({}, props);
47
+ delete newProps[property];
48
+ }
49
+ });
50
+ return newProps || props;
51
+ }
39
52
  // gotta broaden from Set<StyleRuleProp> to a ReadonlySet<string> so we can check
40
53
  // if arbitrary strings are in it via propsSet.has(maybeStyleRuleProp)
41
54
  const propsSet = new Set(styleRuleProps); // Function to construct the prop types object
package/es/index.js CHANGED
@@ -6,9 +6,9 @@ import applyStaticStyles from './applyStaticStyles';
6
6
  import applyTheme from './applyTheme';
7
7
  import createComponent from './createComponent';
8
8
  import createComponentStyles from './createComponentStyles';
9
- import createStyledComponent from './createStyledComponent';
9
+ import createStyledComponent, { filterStyleProps } from './createStyledComponent';
10
10
  import withRenderer from './withRenderer';
11
11
  import { isValidElementProp, filterValidElementProps } from './isValidElementProp';
12
12
  export * from './types';
13
13
  export const withTheme = _withTheme;
14
- export { createComponent, applyTheme, ThemeProvider, FelaTheme, connect, combineRules, createComponentStyles, withRenderer, applyStaticStyles, createStyledComponent, isValidElementProp, filterValidElementProps };
14
+ export { createComponent, applyTheme, ThemeProvider, FelaTheme, connect, combineRules, createComponentStyles, withRenderer, applyStaticStyles, createStyledComponent, isValidElementProp, filterValidElementProps, filterStyleProps };
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.borderRadiusProps = exports.borderWidthProps = exports.borderStyleProps = exports.sizeProps = exports.spacingProps = exports.colorProps = exports.default = void 0;
6
+ exports.filterStyleProps = filterStyleProps;
7
+ exports.borderRadiusProps = exports.borderWidthProps = exports.borderStyleProps = exports.sizeProps = exports.spacingProps = exports.colorProps = exports.default = exports.styleRuleProps = void 0;
7
8
 
8
9
  var _reactDisplayName = _interopRequireDefault(require("react-display-name"));
9
10
 
@@ -19,10 +20,10 @@ var _types = require("./types");
19
20
 
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
 
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
23
-
24
23
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
25
24
 
25
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
26
+
26
27
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
28
 
28
29
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -74,6 +75,21 @@ var additionalProps = ['fontSize', 'fontWeight', 'textAlign', 'display', 'width'
74
75
 
75
76
  var styleRuleProps = _toConsumableArray(spacingProps).concat(sizeProps, colorProps, borderStyleProps, borderWidthProps, borderRadiusProps, additionalProps);
76
77
 
78
+ exports.styleRuleProps = styleRuleProps;
79
+ var stylesRulePropsSet = new Set(styleRuleProps); // Function to remove styling attributes from a Props object
80
+
81
+ function filterStyleProps(props) {
82
+ var newProps;
83
+ var properties = Object.keys(props);
84
+ properties.forEach(function (property) {
85
+ if (stylesRulePropsSet.has(property)) {
86
+ newProps = newProps || _objectSpread({}, props);
87
+ delete newProps[property];
88
+ }
89
+ });
90
+ return newProps || props;
91
+ }
92
+
77
93
  // gotta broaden from Set<StyleRuleProp> to a ReadonlySet<string> so we can check
78
94
  // if arbitrary strings are in it via propsSet.has(maybeStyleRuleProp)
79
95
  var propsSet = new Set(styleRuleProps); // Function to construct the prop types object
package/lib/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -14,6 +16,7 @@ var _exportNames = {
14
16
  createComponent: true,
15
17
  createComponentStyles: true,
16
18
  createStyledComponent: true,
19
+ filterStyleProps: true,
17
20
  withRenderer: true,
18
21
  isValidElementProp: true,
19
22
  filterValidElementProps: true
@@ -72,6 +75,12 @@ Object.defineProperty(exports, "createStyledComponent", {
72
75
  return _createStyledComponent.default;
73
76
  }
74
77
  });
78
+ Object.defineProperty(exports, "filterStyleProps", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _createStyledComponent.filterStyleProps;
82
+ }
83
+ });
75
84
  Object.defineProperty(exports, "withRenderer", {
76
85
  enumerable: true,
77
86
  get: function get() {
@@ -104,7 +113,7 @@ var _createComponent = _interopRequireDefault(require("./createComponent"));
104
113
 
105
114
  var _createComponentStyles = _interopRequireDefault(require("./createComponentStyles"));
106
115
 
107
- var _createStyledComponent = _interopRequireDefault(require("./createStyledComponent"));
116
+ var _createStyledComponent = _interopRequireWildcard(require("./createStyledComponent"));
108
117
 
109
118
  var _withRenderer = _interopRequireDefault(require("./withRenderer"));
110
119
 
@@ -123,6 +132,10 @@ Object.keys(_types).forEach(function (key) {
123
132
  });
124
133
  });
125
134
 
135
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
136
+
137
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
138
+
126
139
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
127
140
 
128
141
  // eslint-disable-line behance/no-deprecated
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/style-container",
3
3
  "description": "Cloudflare Style Container",
4
- "version": "7.5.24",
4
+ "version": "7.6.0",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -12,8 +12,8 @@
12
12
  "access": "public"
13
13
  },
14
14
  "dependencies": {
15
- "@cloudflare/style-const": "^5.1.18",
16
- "@cloudflare/types": "^6.11.16",
15
+ "@cloudflare/style-const": "^5.2.0",
16
+ "@cloudflare/types": "^6.11.19",
17
17
  "fela": "^11.6.1",
18
18
  "fela-tools": "^11.6.1",
19
19
  "lodash": "^4.17.10",
@@ -34,5 +34,5 @@
34
34
  "test-coverage": "stratus test --coverage",
35
35
  "test-watch": "stratus test --watch"
36
36
  },
37
- "gitHead": "61e863a0ad6f04518b2f41a82d74411b777362a6"
37
+ "gitHead": "b7c207b9d1a4a78c3412f7ad4185e92ec36c4f5e"
38
38
  }