@instructure/emotion 8.9.2-snapshot.7 → 8.9.2-snapshot.9

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 (53) hide show
  1. package/es/EmotionThemeProvider/index.js +3 -3
  2. package/es/EmotionTypes.js +1 -0
  3. package/es/getComponentThemeOverride.js +16 -4
  4. package/es/index.js +2 -2
  5. package/es/styleUtils/ThemeablePropTypes.js +5 -5
  6. package/es/styleUtils/bidirectionalPolyfill.js +8 -5
  7. package/es/useTheme.js +6 -3
  8. package/es/withStyle.js +8 -7
  9. package/lib/EmotionThemeProvider/index.js +4 -4
  10. package/lib/EmotionTypes.js +1 -0
  11. package/lib/getComponentThemeOverride.js +16 -5
  12. package/lib/index.js +51 -26
  13. package/lib/styleUtils/ThemeablePropTypes.js +5 -5
  14. package/lib/styleUtils/bidirectionalPolyfill.js +7 -5
  15. package/lib/useTheme.js +4 -2
  16. package/lib/withStyle.js +9 -8
  17. package/package.json +10 -10
  18. package/src/EmotionThemeProvider/index.tsx +11 -22
  19. package/src/EmotionTypes.ts +89 -0
  20. package/src/getComponentThemeOverride.ts +33 -11
  21. package/src/index.ts +23 -2
  22. package/src/styleUtils/ThemeablePropTypes.ts +36 -12
  23. package/src/styleUtils/ThemeablePropValues.ts +1 -1
  24. package/src/styleUtils/bidirectionalPolyfill.ts +29 -10
  25. package/src/styleUtils/getShorthandPropValue.ts +1 -0
  26. package/src/styleUtils/makeThemeVars.ts +5 -5
  27. package/src/styleUtils/mirrorShorthandCorners.ts +1 -0
  28. package/src/styleUtils/mirrorShorthandEdges.ts +1 -0
  29. package/src/useTheme.ts +7 -2
  30. package/src/withStyle.tsx +85 -17
  31. package/types/EmotionThemeProvider/index.d.ts +1 -15
  32. package/types/EmotionThemeProvider/index.d.ts.map +1 -1
  33. package/types/EmotionTypes.d.ts +29 -0
  34. package/types/EmotionTypes.d.ts.map +1 -0
  35. package/types/getComponentThemeOverride.d.ts +14 -2
  36. package/types/getComponentThemeOverride.d.ts.map +1 -1
  37. package/types/index.d.ts +5 -2
  38. package/types/index.d.ts.map +1 -1
  39. package/types/styleUtils/ThemeablePropTypes.d.ts +8 -6
  40. package/types/styleUtils/ThemeablePropTypes.d.ts.map +1 -1
  41. package/types/styleUtils/ThemeablePropValues.d.ts +1 -1
  42. package/types/styleUtils/ThemeablePropValues.d.ts.map +1 -1
  43. package/types/styleUtils/bidirectionalPolyfill.d.ts +5 -1
  44. package/types/styleUtils/bidirectionalPolyfill.d.ts.map +1 -1
  45. package/types/styleUtils/getShorthandPropValue.d.ts.map +1 -1
  46. package/types/styleUtils/makeThemeVars.d.ts +4 -5
  47. package/types/styleUtils/makeThemeVars.d.ts.map +1 -1
  48. package/types/styleUtils/mirrorShorthandCorners.d.ts.map +1 -1
  49. package/types/styleUtils/mirrorShorthandEdges.d.ts.map +1 -1
  50. package/types/useTheme.d.ts +4 -1
  51. package/types/useTheme.d.ts.map +1 -1
  52. package/types/withStyle.d.ts +11 -5
  53. package/types/withStyle.d.ts.map +1 -1
@@ -22,8 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import React from 'react';
25
- import { ThemeProvider } from '@emotion/react';
26
25
  import { merge, cloneDeep } from 'lodash';
26
+ import { ThemeProvider } from '@emotion/react';
27
27
 
28
28
  /**
29
29
  * ---
@@ -90,7 +90,7 @@ function EmotionThemeProvider({
90
90
 
91
91
 
92
92
  const getTheme = themeOrOverride => (ancestorTheme = {}) => {
93
- var _themeOrOverride$them;
93
+ var _themeOverrides;
94
94
 
95
95
  if (isBaseTheme(themeOrOverride)) {
96
96
  return themeOrOverride;
@@ -100,7 +100,7 @@ const getTheme = themeOrOverride => (ancestorTheme = {}) => {
100
100
  const currentTheme = cloneDeep(ancestorTheme);
101
101
  const themeName = currentTheme.key; // we pick the overrides for the current theme from the override object
102
102
 
103
- const currentThemeOverrides = (themeOrOverride === null || themeOrOverride === void 0 ? void 0 : (_themeOrOverride$them = themeOrOverride.themeOverrides) === null || _themeOrOverride$them === void 0 ? void 0 : _themeOrOverride$them[themeName]) || {};
103
+ const currentThemeOverrides = (themeOrOverride === null || themeOrOverride === void 0 ? void 0 : (_themeOverrides = themeOrOverride.themeOverrides) === null || _themeOverrides === void 0 ? void 0 : _themeOverrides[themeName]) || {};
104
104
  return merge({}, currentTheme, merge({}, themeOrOverride, currentThemeOverrides));
105
105
  }; // themeable themes have a 'key' property (= name of the theme),
106
106
  // so without it it's just an overrides objects
@@ -0,0 +1 @@
1
+ export {};
@@ -30,15 +30,27 @@
30
30
  * based on every possible override there is.
31
31
 
32
32
  * @param {object} theme - Theme object
33
- * @param {*} componentName - Name of the component
33
+ * @param {*} displayName - Name of the component
34
+ * @param {*} componentId - componentId of the component
34
35
  * @param {*} props - The component's props object
35
36
  * @returns {object} The calculated theme override object
36
37
  */
37
- export const getComponentThemeOverride = (theme, componentName, props) => {
38
+ const getComponentThemeOverride = (theme, displayName, componentId, props) => {
38
39
  var _props$themeOverride;
39
40
 
40
- const componentOverride = (theme === null || theme === void 0 ? void 0 : theme.componentOverrides) && (theme.componentOverrides[componentName[0]] || theme.componentOverrides[componentName[1]]);
41
+ let componentOverride = {};
42
+ const overrides = theme.componentOverrides;
43
+ const name = displayName;
44
+ const id = componentId;
45
+
46
+ if (overrides) {
47
+ componentOverride = name && overrides[name] || id && overrides[id] || {};
48
+ }
49
+
41
50
  return { ...componentOverride,
42
51
  ...((_props$themeOverride = props === null || props === void 0 ? void 0 : props.themeOverride) !== null && _props$themeOverride !== void 0 ? _props$themeOverride : {})
43
52
  };
44
- };
53
+ };
54
+
55
+ export default getComponentThemeOverride;
56
+ export { getComponentThemeOverride };
package/es/index.js CHANGED
@@ -24,5 +24,5 @@
24
24
  /// <reference types="@emotion/react/types/css-prop" />
25
25
  export * from '@emotion/react';
26
26
  export { EmotionThemeProvider } from './EmotionThemeProvider';
27
- export * from './styleUtils';
28
- export * from './withStyle';
27
+ export { withStyle } from './withStyle';
28
+ export { ThemeablePropValues, ThemeablePropTypes, makeThemeVars, getShorthandPropValue, mirrorShorthandCorners, mirrorShorthandEdges } from './styleUtils';
@@ -53,13 +53,11 @@ function shorthandPropType(validValues) {
53
53
  const propValue = props[propName];
54
54
 
55
55
  if (typeof propValue === 'undefined') {
56
- return;
56
+ return null;
57
57
  }
58
58
 
59
- const propValueType = typeof propValue;
60
-
61
- if (propValueType !== 'string') {
62
- return new Error(`Invalid ${location} \`${propName}\` of type \`${propValueType}\` supplied to \`${componentName}\`, expected ` + `a string.`);
59
+ if (typeof propValue !== 'string') {
60
+ return new Error(`Invalid ${location} \`${propName}\` of type \`${typeof propValue}\` supplied to \`${componentName}\`, expected ` + `a string.`);
63
61
  }
64
62
 
65
63
  const propValues = propValue.split(' ');
@@ -76,6 +74,8 @@ function shorthandPropType(validValues) {
76
74
  } else {
77
75
  return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `between one and four of the following valid values: \`${validValues.join(', ')}\`.`);
78
76
  }
77
+
78
+ return null;
79
79
  };
80
80
  }
81
81
 
@@ -21,8 +21,9 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { consoleLog as log } from '@instructure/console';
25
24
  import { isObject } from 'lodash';
25
+ import { consoleLog as log } from '@instructure/console';
26
+
26
27
  /**
27
28
  * ---
28
29
  * category: utilities/themes
@@ -35,7 +36,6 @@ import { isObject } from 'lodash';
35
36
  * @param {string} dir - "ltr" of "rtl" direction
36
37
  * @returns {{}} styles object with Bi-directional properties polyfilled
37
38
  */
38
-
39
39
  const DEBUG = false;
40
40
  const SUPPORT_PROPS = ['float', 'clear', 'textAlign', 'paddingInlineStart', 'paddingInlineEnd', 'borderInlineStart', 'borderInlineEnd', 'borderInlineStartColor', 'borderInlineEndColor', 'borderInlineStartStyle', 'borderInlineEndStyle', 'borderInlineStartWidth', 'borderInlineEndWidth', 'borderInlineStartTop', 'borderInlineEndTop', 'borderTopInlineStartRadius', 'borderTopInlineEndRadius', 'borderBottomInlineStartRadius', 'borderBottomInlineEndRadius', 'marginInlineStart', 'marginInlineEnd', 'offsetInlineStart', 'offsetInlineEnd', 'insetInlineStart', 'insetInlineEnd'];
41
41
 
@@ -157,7 +157,7 @@ const processStyleProps = (propsObj, dir) => isObject(propsObj) ? Object.entries
157
157
  };
158
158
  }
159
159
 
160
- if (isSupportedProps(originalProp) && originalValue !== 'undefined') {
160
+ if (isSupportedProps(originalProp) && typeof originalValue !== 'undefined') {
161
161
  const _processProps = processProps({
162
162
  originalProp,
163
163
  originalValue
@@ -175,6 +175,9 @@ const processStyleProps = (propsObj, dir) => isObject(propsObj) ? Object.entries
175
175
  };
176
176
  }, {}) : propsObj;
177
177
 
178
- export const bidirectionalPolyfill = (styles, dir) => Object.entries(styles).reduce((accumulator, [style, props]) => ({ ...accumulator,
178
+ const bidirectionalPolyfill = (styles, dir) => Object.entries(styles).reduce((accumulator, [style, props]) => ({ ...accumulator,
179
179
  [style]: processStyleProps(props, dir)
180
- }), {});
180
+ }), {});
181
+
182
+ export default bidirectionalPolyfill;
183
+ export { bidirectionalPolyfill };
package/es/useTheme.js CHANGED
@@ -24,6 +24,7 @@
24
24
  import { useTheme as useEmotionTheme } from '@emotion/react';
25
25
  import { canvas } from '@instructure/ui-themes';
26
26
  import { isEmpty } from '@instructure/ui-utils';
27
+
27
28
  /**
28
29
  * ---
29
30
  * private: true
@@ -32,8 +33,7 @@ import { isEmpty } from '@instructure/ui-utils';
32
33
  * If there is no theme provided to the Context it will return the default `canvas` theme.
33
34
  * @returns {object} the theme object
34
35
  */
35
-
36
- export const useTheme = () => {
36
+ const useTheme = () => {
37
37
  let theme = useEmotionTheme(); // TODO type theme properly, then this cast might not be needed.
38
38
 
39
39
  if (isEmpty(theme)) {
@@ -43,4 +43,7 @@ export const useTheme = () => {
43
43
  }
44
44
 
45
45
  return theme;
46
- };
46
+ };
47
+
48
+ export default useTheme;
49
+ export { useTheme };
package/es/withStyle.js CHANGED
@@ -24,9 +24,9 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
24
24
  * SOFTWARE.
25
25
  */
26
26
  import React, { forwardRef, useState } from 'react';
27
- import { decorator } from '@instructure/ui-decorator';
28
27
  import { isEqual } from 'lodash';
29
28
  import hoistNonReactStatics from 'hoist-non-react-statics';
29
+ import { decorator } from '@instructure/ui-decorator';
30
30
  import { useTextDirectionContext } from '@instructure/ui-i18n';
31
31
  import { bidirectionalPolyfill } from './styleUtils/bidirectionalPolyfill';
32
32
  import { getComponentThemeOverride } from './getComponentThemeOverride';
@@ -108,7 +108,7 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
108
108
  const componentProps = { ...ComposedComponent.defaultProps,
109
109
  ...props
110
110
  };
111
- const themeOverride = getComponentThemeOverride(theme, [displayName, ComposedComponent.componentId], componentProps);
111
+ const themeOverride = getComponentThemeOverride(theme, displayName, ComposedComponent.componentId, componentProps);
112
112
  const componentTheme = typeof generateComponentTheme === 'function' ? { ...generateComponentTheme(theme),
113
113
  ...themeOverride
114
114
  } : {};
@@ -118,8 +118,8 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
118
118
  styles = _useState2[0],
119
119
  setStyles = _useState2[1];
120
120
 
121
- const makeStyleHandler = (...extraArgs) => {
122
- const calculatedStyles = bidirectionalPolyfill(generateStyle(componentTheme, componentProps, ...extraArgs), dir);
121
+ const makeStyleHandler = extraArgs => {
122
+ const calculatedStyles = bidirectionalPolyfill(generateStyle(componentTheme, componentProps, extraArgs), dir);
123
123
 
124
124
  if (!isEqual(calculatedStyles, styles)) {
125
125
  setStyles(calculatedStyles);
@@ -137,9 +137,10 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
137
137
  // eslint-disable-next-line react/forbid-foreign-prop-types
138
138
 
139
139
  WithStyle.propTypes = ComposedComponent.propTypes;
140
- WithStyle.defaultProps = ComposedComponent.defaultProps;
141
- WithStyle.allowedProps = ComposedComponent.allowedProps // we are exposing the theme generator for the docs generation
142
- ;
140
+ WithStyle.defaultProps = ComposedComponent.defaultProps; // These static fields exist on InstUI components
141
+
142
+ WithStyle.allowedProps = ComposedComponent.allowedProps; // we are exposing the theme generator for the docs generation
143
+
143
144
  WithStyle.generateComponentTheme = generateComponentTheme; // we have to add defaults to makeStyles and styles added by this decorator
144
145
  // eslint-disable-next-line no-param-reassign
145
146
 
@@ -10,10 +10,10 @@ exports.default = void 0;
10
10
 
11
11
  var _react = _interopRequireDefault(require("react"));
12
12
 
13
- var _react2 = require("@emotion/react");
14
-
15
13
  var _lodash = require("lodash");
16
14
 
15
+ var _react2 = require("@emotion/react");
16
+
17
17
  /*
18
18
  * The MIT License (MIT)
19
19
  *
@@ -103,7 +103,7 @@ function EmotionThemeProvider({
103
103
 
104
104
 
105
105
  const getTheme = themeOrOverride => (ancestorTheme = {}) => {
106
- var _themeOrOverride$them;
106
+ var _themeOverrides;
107
107
 
108
108
  if (isBaseTheme(themeOrOverride)) {
109
109
  return themeOrOverride;
@@ -113,7 +113,7 @@ const getTheme = themeOrOverride => (ancestorTheme = {}) => {
113
113
  const currentTheme = (0, _lodash.cloneDeep)(ancestorTheme);
114
114
  const themeName = currentTheme.key; // we pick the overrides for the current theme from the override object
115
115
 
116
- const currentThemeOverrides = (themeOrOverride === null || themeOrOverride === void 0 ? void 0 : (_themeOrOverride$them = themeOrOverride.themeOverrides) === null || _themeOrOverride$them === void 0 ? void 0 : _themeOrOverride$them[themeName]) || {};
116
+ const currentThemeOverrides = (themeOrOverride === null || themeOrOverride === void 0 ? void 0 : (_themeOverrides = themeOrOverride.themeOverrides) === null || _themeOverrides === void 0 ? void 0 : _themeOverrides[themeName]) || {};
117
117
  return (0, _lodash.merge)({}, currentTheme, (0, _lodash.merge)({}, themeOrOverride, currentThemeOverrides));
118
118
  }; // themeable themes have a 'key' property (= name of the theme),
119
119
  // so without it it's just an overrides objects
@@ -0,0 +1 @@
1
+ "use strict";
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getComponentThemeOverride = void 0;
6
+ exports.getComponentThemeOverride = exports.default = void 0;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -37,17 +37,28 @@ exports.getComponentThemeOverride = void 0;
37
37
  * based on every possible override there is.
38
38
 
39
39
  * @param {object} theme - Theme object
40
- * @param {*} componentName - Name of the component
40
+ * @param {*} displayName - Name of the component
41
+ * @param {*} componentId - componentId of the component
41
42
  * @param {*} props - The component's props object
42
43
  * @returns {object} The calculated theme override object
43
44
  */
44
- const getComponentThemeOverride = (theme, componentName, props) => {
45
+ const getComponentThemeOverride = (theme, displayName, componentId, props) => {
45
46
  var _props$themeOverride;
46
47
 
47
- const componentOverride = (theme === null || theme === void 0 ? void 0 : theme.componentOverrides) && (theme.componentOverrides[componentName[0]] || theme.componentOverrides[componentName[1]]);
48
+ let componentOverride = {};
49
+ const overrides = theme.componentOverrides;
50
+ const name = displayName;
51
+ const id = componentId;
52
+
53
+ if (overrides) {
54
+ componentOverride = name && overrides[name] || id && overrides[id] || {};
55
+ }
56
+
48
57
  return { ...componentOverride,
49
58
  ...((_props$themeOverride = props === null || props === void 0 ? void 0 : props.themeOverride) !== null && _props$themeOverride !== void 0 ? _props$themeOverride : {})
50
59
  };
51
60
  };
52
61
 
53
- exports.getComponentThemeOverride = getComponentThemeOverride;
62
+ exports.getComponentThemeOverride = getComponentThemeOverride;
63
+ var _default = getComponentThemeOverride;
64
+ exports.default = _default;
package/lib/index.js CHANGED
@@ -4,7 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- EmotionThemeProvider: true
7
+ EmotionThemeProvider: true,
8
+ withStyle: true,
9
+ ThemeablePropValues: true,
10
+ ThemeablePropTypes: true,
11
+ makeThemeVars: true,
12
+ getShorthandPropValue: true,
13
+ mirrorShorthandCorners: true,
14
+ mirrorShorthandEdges: true
8
15
  };
9
16
  Object.defineProperty(exports, "EmotionThemeProvider", {
10
17
  enumerable: true,
@@ -12,6 +19,48 @@ Object.defineProperty(exports, "EmotionThemeProvider", {
12
19
  return _EmotionThemeProvider.EmotionThemeProvider;
13
20
  }
14
21
  });
22
+ Object.defineProperty(exports, "withStyle", {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _withStyle.withStyle;
26
+ }
27
+ });
28
+ Object.defineProperty(exports, "ThemeablePropValues", {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _styleUtils.ThemeablePropValues;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, "ThemeablePropTypes", {
35
+ enumerable: true,
36
+ get: function () {
37
+ return _styleUtils.ThemeablePropTypes;
38
+ }
39
+ });
40
+ Object.defineProperty(exports, "makeThemeVars", {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _styleUtils.makeThemeVars;
44
+ }
45
+ });
46
+ Object.defineProperty(exports, "getShorthandPropValue", {
47
+ enumerable: true,
48
+ get: function () {
49
+ return _styleUtils.getShorthandPropValue;
50
+ }
51
+ });
52
+ Object.defineProperty(exports, "mirrorShorthandCorners", {
53
+ enumerable: true,
54
+ get: function () {
55
+ return _styleUtils.mirrorShorthandCorners;
56
+ }
57
+ });
58
+ Object.defineProperty(exports, "mirrorShorthandEdges", {
59
+ enumerable: true,
60
+ get: function () {
61
+ return _styleUtils.mirrorShorthandEdges;
62
+ }
63
+ });
15
64
 
16
65
  var _react = require("@emotion/react");
17
66
 
@@ -29,30 +78,6 @@ Object.keys(_react).forEach(function (key) {
29
78
 
30
79
  var _EmotionThemeProvider = require("./EmotionThemeProvider");
31
80
 
32
- var _styleUtils = require("./styleUtils");
33
-
34
- Object.keys(_styleUtils).forEach(function (key) {
35
- if (key === "default" || key === "__esModule") return;
36
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
37
- if (key in exports && exports[key] === _styleUtils[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function () {
41
- return _styleUtils[key];
42
- }
43
- });
44
- });
45
-
46
81
  var _withStyle = require("./withStyle");
47
82
 
48
- Object.keys(_withStyle).forEach(function (key) {
49
- if (key === "default" || key === "__esModule") return;
50
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
51
- if (key in exports && exports[key] === _withStyle[key]) return;
52
- Object.defineProperty(exports, key, {
53
- enumerable: true,
54
- get: function () {
55
- return _withStyle[key];
56
- }
57
- });
58
- });
83
+ var _styleUtils = require("./styleUtils");
@@ -66,13 +66,11 @@ function shorthandPropType(validValues) {
66
66
  const propValue = props[propName];
67
67
 
68
68
  if (typeof propValue === 'undefined') {
69
- return;
69
+ return null;
70
70
  }
71
71
 
72
- const propValueType = typeof propValue;
73
-
74
- if (propValueType !== 'string') {
75
- return new Error(`Invalid ${location} \`${propName}\` of type \`${propValueType}\` supplied to \`${componentName}\`, expected ` + `a string.`);
72
+ if (typeof propValue !== 'string') {
73
+ return new Error(`Invalid ${location} \`${propName}\` of type \`${typeof propValue}\` supplied to \`${componentName}\`, expected ` + `a string.`);
76
74
  }
77
75
 
78
76
  const propValues = propValue.split(' ');
@@ -89,6 +87,8 @@ function shorthandPropType(validValues) {
89
87
  } else {
90
88
  return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `between one and four of the following valid values: \`${validValues.join(', ')}\`.`);
91
89
  }
90
+
91
+ return null;
92
92
  };
93
93
  }
94
94
 
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.bidirectionalPolyfill = void 0;
7
-
8
- var _console = require("@instructure/console");
6
+ exports.bidirectionalPolyfill = exports.default = void 0;
9
7
 
10
8
  var _lodash = require("lodash");
11
9
 
10
+ var _console = require("@instructure/console");
11
+
12
12
  /*
13
13
  * The MIT License (MIT)
14
14
  *
@@ -166,7 +166,7 @@ const processStyleProps = (propsObj, dir) => (0, _lodash.isObject)(propsObj) ? O
166
166
  };
167
167
  }
168
168
 
169
- if (isSupportedProps(originalProp) && originalValue !== 'undefined') {
169
+ if (isSupportedProps(originalProp) && typeof originalValue !== 'undefined') {
170
170
  const _processProps = processProps({
171
171
  originalProp,
172
172
  originalValue
@@ -188,4 +188,6 @@ const bidirectionalPolyfill = (styles, dir) => Object.entries(styles).reduce((ac
188
188
  [style]: processStyleProps(props, dir)
189
189
  }), {});
190
190
 
191
- exports.bidirectionalPolyfill = bidirectionalPolyfill;
191
+ exports.bidirectionalPolyfill = bidirectionalPolyfill;
192
+ var _default = bidirectionalPolyfill;
193
+ exports.default = _default;
package/lib/useTheme.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useTheme = void 0;
6
+ exports.useTheme = exports.default = void 0;
7
7
 
8
8
  var _react = require("@emotion/react");
9
9
 
@@ -55,4 +55,6 @@ const useTheme = () => {
55
55
  return theme;
56
56
  };
57
57
 
58
- exports.useTheme = useTheme;
58
+ exports.useTheme = useTheme;
59
+ var _default = useTheme;
60
+ exports.default = _default;
package/lib/withStyle.js CHANGED
@@ -13,12 +13,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
13
13
 
14
14
  var _react = _interopRequireWildcard(require("react"));
15
15
 
16
- var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
17
-
18
16
  var _lodash = require("lodash");
19
17
 
20
18
  var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
21
19
 
20
+ var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
21
+
22
22
  var _uiI18n = require("@instructure/ui-i18n");
23
23
 
24
24
  var _bidirectionalPolyfill = require("./styleUtils/bidirectionalPolyfill");
@@ -127,7 +127,7 @@ const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, g
127
127
  const componentProps = { ...ComposedComponent.defaultProps,
128
128
  ...props
129
129
  };
130
- const themeOverride = (0, _getComponentThemeOverride.getComponentThemeOverride)(theme, [displayName, ComposedComponent.componentId], componentProps);
130
+ const themeOverride = (0, _getComponentThemeOverride.getComponentThemeOverride)(theme, displayName, ComposedComponent.componentId, componentProps);
131
131
  const componentTheme = typeof generateComponentTheme === 'function' ? { ...generateComponentTheme(theme),
132
132
  ...themeOverride
133
133
  } : {};
@@ -137,8 +137,8 @@ const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, g
137
137
  styles = _useState2[0],
138
138
  setStyles = _useState2[1];
139
139
 
140
- const makeStyleHandler = (...extraArgs) => {
141
- const calculatedStyles = (0, _bidirectionalPolyfill.bidirectionalPolyfill)(generateStyle(componentTheme, componentProps, ...extraArgs), dir);
140
+ const makeStyleHandler = extraArgs => {
141
+ const calculatedStyles = (0, _bidirectionalPolyfill.bidirectionalPolyfill)(generateStyle(componentTheme, componentProps, extraArgs), dir);
142
142
 
143
143
  if (!(0, _lodash.isEqual)(calculatedStyles, styles)) {
144
144
  setStyles(calculatedStyles);
@@ -156,9 +156,10 @@ const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, g
156
156
  // eslint-disable-next-line react/forbid-foreign-prop-types
157
157
 
158
158
  WithStyle.propTypes = ComposedComponent.propTypes;
159
- WithStyle.defaultProps = ComposedComponent.defaultProps;
160
- WithStyle.allowedProps = ComposedComponent.allowedProps // we are exposing the theme generator for the docs generation
161
- ;
159
+ WithStyle.defaultProps = ComposedComponent.defaultProps; // These static fields exist on InstUI components
160
+
161
+ WithStyle.allowedProps = ComposedComponent.allowedProps; // we are exposing the theme generator for the docs generation
162
+
162
163
  WithStyle.generateComponentTheme = generateComponentTheme; // we have to add defaults to makeStyles and styles added by this decorator
163
164
  // eslint-disable-next-line no-param-reassign
164
165
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/emotion",
3
- "version": "8.9.2-snapshot.7+1a56581cd",
3
+ "version": "8.9.2-snapshot.9+e92f12dda",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -26,20 +26,20 @@
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
28
  "@emotion/react": "^11.4.1",
29
- "@instructure/console": "8.9.2-snapshot.7+1a56581cd",
30
- "@instructure/shared-types": "8.9.2-snapshot.7+1a56581cd",
31
- "@instructure/ui-decorator": "8.9.2-snapshot.7+1a56581cd",
32
- "@instructure/ui-i18n": "8.9.2-snapshot.7+1a56581cd",
33
- "@instructure/ui-themes": "8.9.2-snapshot.7+1a56581cd",
34
- "@instructure/ui-utils": "8.9.2-snapshot.7+1a56581cd",
29
+ "@instructure/console": "8.9.2-snapshot.9+e92f12dda",
30
+ "@instructure/shared-types": "8.9.2-snapshot.9+e92f12dda",
31
+ "@instructure/ui-decorator": "8.9.2-snapshot.9+e92f12dda",
32
+ "@instructure/ui-i18n": "8.9.2-snapshot.9+e92f12dda",
33
+ "@instructure/ui-themes": "8.9.2-snapshot.9+e92f12dda",
34
+ "@instructure/ui-utils": "8.9.2-snapshot.9+e92f12dda",
35
35
  "emotion-theming": "^10.0.27",
36
36
  "hoist-non-react-statics": "^3.3.2",
37
37
  "lodash": "^4",
38
38
  "prop-types": "^15"
39
39
  },
40
40
  "devDependencies": {
41
- "@instructure/ui-babel-preset": "8.9.2-snapshot.7+1a56581cd",
42
- "@instructure/ui-test-utils": "8.9.2-snapshot.7+1a56581cd",
41
+ "@instructure/ui-babel-preset": "8.9.2-snapshot.9+e92f12dda",
42
+ "@instructure/ui-test-utils": "8.9.2-snapshot.9+e92f12dda",
43
43
  "@types/lodash": "^4.14.171",
44
44
  "cpy-cli": "^3.1.1"
45
45
  },
@@ -50,5 +50,5 @@
50
50
  "access": "public"
51
51
  },
52
52
  "sideEffects": false,
53
- "gitHead": "1a56581cde6bd3b4f9fe5cd11ae420bd1222fe15"
53
+ "gitHead": "e92f12dda2e003c834e8728072d6ab60e4212c89"
54
54
  }
@@ -21,31 +21,19 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
+
24
25
  import React from 'react'
25
- import { ThemeProvider } from '@emotion/react'
26
26
  import { merge, cloneDeep } from 'lodash'
27
- import {
28
- ComponentThemeMap,
29
- DeepPartial,
30
- BaseTheme
31
- } from '@instructure/shared-types'
32
-
33
- type PartialTheme = DeepPartial<Omit<BaseTheme, 'key'>>
34
- type ComponentOverride =
35
- | DeepPartial<ComponentThemeMap>
36
- // this is needed for user defined components which we can't possibly type
37
- | { [otherComponent: string]: Record<string, unknown> }
38
27
 
39
- type ThemeOverride =
40
- | PartialTheme
41
- | { [key: string]: PartialTheme | { componentOverrides?: ComponentOverride } }
28
+ import { ThemeProvider } from '@emotion/react'
42
29
 
43
- type Overrides = {
44
- themeOverrides?: ThemeOverride
45
- componentOverrides?: ComponentOverride
46
- }
30
+ import type { BaseTheme } from '@instructure/shared-types'
31
+ import type {
32
+ Overrides,
33
+ ThemeOrOverride,
34
+ SpecificThemeOverride
35
+ } from '../EmotionTypes'
47
36
 
48
- type ThemeOrOverride = BaseTheme | PartialTheme | Overrides
49
37
  type ThemeProviderProps = {
50
38
  theme: ThemeOrOverride
51
39
  }
@@ -125,8 +113,9 @@ const getTheme = (themeOrOverride: ThemeOrOverride) => (
125
113
 
126
114
  // we pick the overrides for the current theme from the override object
127
115
  const currentThemeOverrides =
128
- //@ts-expect-error TODO: fix this code, this way it is really hard to type
129
- themeOrOverride?.themeOverrides?.[themeName] || {}
116
+ ((themeOrOverride as Overrides)?.themeOverrides as SpecificThemeOverride)?.[
117
+ themeName
118
+ ] || {}
130
119
 
131
120
  return merge(
132
121
  {},