@instructure/emotion 10.26.1-snapshot-2 → 10.26.1

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 (38) hide show
  1. package/CHANGELOG.md +2 -23
  2. package/es/InstUISettingsProvider/index.js +15 -3
  3. package/es/getTheme.js +4 -2
  4. package/es/index.js +1 -1
  5. package/es/styleUtils/ThemeablePropTypes.js +74 -0
  6. package/es/styleUtils/index.js +1 -0
  7. package/es/useTheme.js +7 -1
  8. package/es/withStyle.js +7 -1
  9. package/lib/InstUISettingsProvider/index.js +16 -3
  10. package/lib/getTheme.js +4 -2
  11. package/lib/index.js +7 -0
  12. package/lib/styleUtils/ThemeablePropTypes.js +81 -0
  13. package/lib/styleUtils/index.js +7 -0
  14. package/lib/useTheme.js +7 -1
  15. package/lib/withStyle.js +7 -1
  16. package/package.json +15 -13
  17. package/src/InstUISettingsProvider/index.tsx +46 -11
  18. package/src/getTheme.ts +5 -2
  19. package/src/index.ts +1 -0
  20. package/src/styleUtils/ThemeablePropTypes.ts +121 -0
  21. package/src/styleUtils/index.ts +1 -0
  22. package/src/useTheme.ts +9 -1
  23. package/src/withStyle.tsx +6 -2
  24. package/tsconfig.build.json +3 -0
  25. package/tsconfig.build.tsbuildinfo +1 -1
  26. package/types/InstUISettingsProvider/index.d.ts +29 -3
  27. package/types/InstUISettingsProvider/index.d.ts.map +1 -1
  28. package/types/getTheme.d.ts.map +1 -1
  29. package/types/index.d.ts +1 -1
  30. package/types/index.d.ts.map +1 -1
  31. package/types/styleUtils/ThemeablePropTypes.d.ts +22 -0
  32. package/types/styleUtils/ThemeablePropTypes.d.ts.map +1 -0
  33. package/types/styleUtils/index.d.ts +1 -0
  34. package/types/styleUtils/index.d.ts.map +1 -1
  35. package/types/useTheme.d.ts +2 -1
  36. package/types/useTheme.d.ts.map +1 -1
  37. package/types/withStyle.d.ts +1 -1
  38. package/types/withStyle.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,30 +3,9 @@
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
- ## [10.26.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1-snapshot-2) (2025-10-06)
6
+ ## [10.26.1](https://github.com/instructure/instructure-ui/compare/v10.26.0...v10.26.1) (2025-10-06)
7
7
 
8
-
9
- ### Features
10
-
11
- * **many:** instUI v11 release ([36f5438](https://github.com/instructure/instructure-ui/commit/36f54382669186227ba24798bbf7201ef2f5cd4c))
12
-
13
-
14
- ### BREAKING CHANGES
15
-
16
- * **many:** InstUI v11 contains the following breaking changes:
17
- - React 16 and 17 are no longer supported
18
- - remove `PropTypes` from all packages
19
- - remove `CodeEditor` component
20
- - remove `@instui/theme-registry` package
21
- - remove `@testable`, `@experimental`, `@hack` decorators
22
- - InstUISettingsProvider's `as` prop is removed
23
- - `canvas.use()`, `canvasHighContrast.use()` functions are removed
24
- - `canvasThemeLocal`, `canvasHighContrastThemeLocal` are removed
25
- - `variables` field on theme objects are removed
26
- - remove deprecated props from Table: Row's `isStacked`, Body's
27
- `isStacked`, `hover`, and `headers`
28
- - `Table`'s `caption` prop is now required
29
- - `ui-dom-utils`'s `getComputedStyle` can now return `undefined`
8
+ **Note:** Version bump only for package @instructure/emotion
30
9
 
31
10
 
32
11
 
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  import { useContext } from 'react';
26
+ import PropTypes from 'prop-types';
26
27
  import { ThemeProvider } from '@emotion/react';
27
28
  import { TextDirectionContext } from '@instructure/ui-i18n';
28
29
  import { DeterministicIdContextProvider } from '@instructure/ui-react-utils';
@@ -38,7 +39,8 @@ function InstUISettingsProvider({
38
39
  children,
39
40
  theme = {},
40
41
  dir,
41
- instanceCounterMap
42
+ instanceCounterMap,
43
+ as
42
44
  }) {
43
45
  const finalDir = dir || useContext(TextDirectionContext);
44
46
  if (process.env.NODE_ENV !== 'production' && finalDir === 'auto') {}
@@ -53,12 +55,22 @@ function InstUISettingsProvider({
53
55
  })
54
56
  });
55
57
  if (dir) {
56
- providers = _jsx("span", {
58
+ const Element = as || 'span';
59
+ providers = _jsx(Element, {
57
60
  dir: finalDir,
58
61
  children: providers
59
62
  });
60
- }
63
+ } else if (as && process.env.NODE_ENV !== 'production') {}
61
64
  return providers;
62
65
  }
66
+ InstUISettingsProvider.propTypes = {
67
+ /* eslint-disable react/require-default-props */
68
+ children: PropTypes.node,
69
+ theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
70
+ dir: PropTypes.oneOf(['ltr', 'rtl']),
71
+ instanceCounterMap: PropTypes.instanceOf(Map),
72
+ as: PropTypes.string
73
+ /* eslint-enable react/require-default-props */
74
+ };
63
75
  export default InstUISettingsProvider;
64
76
  export { InstUISettingsProvider };
package/es/getTheme.js CHANGED
@@ -22,6 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import canvas from '@instructure/ui-themes';
25
+ import { ThemeRegistry } from '@instructure/theme-registry';
25
26
  import { isBaseTheme, mergeDeep } from '@instructure/ui-utils';
26
27
  /**
27
28
  * ---
@@ -44,8 +45,9 @@ const getTheme = themeOrOverride => (ancestorTheme = {}) => {
44
45
  // we need to clone the ancestor theme not to override it
45
46
  let currentTheme;
46
47
  if (Object.keys(ancestorTheme).length === 0) {
47
- if (process.env.NODE_ENV !== 'production') {}
48
- currentTheme = canvas;
48
+ const globalTheme = ThemeRegistry.getCurrentTheme();
49
+ if (process.env.NODE_ENV !== 'production' && !globalTheme) {}
50
+ currentTheme = globalTheme || canvas;
49
51
  } else {
50
52
  currentTheme = ancestorTheme;
51
53
  }
package/es/index.js CHANGED
@@ -26,5 +26,5 @@
26
26
  export * from '@emotion/react';
27
27
  export { InstUISettingsProvider } from './InstUISettingsProvider';
28
28
  export { withStyle } from './withStyle';
29
- export { ThemeablePropValues, makeThemeVars, getShorthandPropValue, mirrorShorthandCorners, mirrorShorthandEdges, mapSpacingToShorthand } from './styleUtils';
29
+ export { ThemeablePropValues, ThemeablePropTypes, makeThemeVars, getShorthandPropValue, mirrorShorthandCorners, mirrorShorthandEdges, mapSpacingToShorthand } from './styleUtils';
30
30
  export { useStyle } from './useStyle';
@@ -0,0 +1,74 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import PropTypes from 'prop-types';
26
+ import { ThemeablePropValues } from './ThemeablePropValues';
27
+ const SHADOW_TYPES = ThemeablePropValues.SHADOW_TYPES,
28
+ STACKING_TYPES = ThemeablePropValues.STACKING_TYPES,
29
+ BORDER_WIDTHS = ThemeablePropValues.BORDER_WIDTHS,
30
+ BORDER_RADII = ThemeablePropValues.BORDER_RADII,
31
+ BACKGROUNDS = ThemeablePropValues.BACKGROUNDS,
32
+ SIZES = ThemeablePropValues.SIZES;
33
+
34
+ /**
35
+ * ---
36
+ * category: utilities/themes
37
+ * ---
38
+ * Custom prop types for themeable React components.
39
+ * @module ThemeablePropTypes
40
+ */
41
+ const ThemeablePropTypes = {
42
+ shadow: PropTypes.oneOf(Object.values(SHADOW_TYPES)),
43
+ stacking: PropTypes.oneOf(Object.values(STACKING_TYPES)),
44
+ borderWidth: shorthandPropType(Object.values(BORDER_WIDTHS)),
45
+ borderRadius: shorthandPropType(Object.values(BORDER_RADII)),
46
+ background: PropTypes.oneOf(Object.values(BACKGROUNDS)),
47
+ size: PropTypes.oneOf(Object.values(SIZES))
48
+ };
49
+ function shorthandPropType(validValues) {
50
+ return function (props, propName, componentName, location) {
51
+ const propValue = props[propName];
52
+ if (typeof propValue === 'undefined') {
53
+ return null;
54
+ }
55
+ if (typeof propValue !== 'string') {
56
+ return new Error(`Invalid ${location} \`${propName}\` of type \`${typeof propValue}\` supplied to \`${componentName}\`, expected ` + `a string.`);
57
+ }
58
+ const propValues = propValue.split(' ');
59
+ const valuesLength = propValues.length;
60
+ if (valuesLength > 0 && valuesLength < 5) {
61
+ for (let i = 0; i < valuesLength; i++) {
62
+ const valueIndex = validValues.indexOf(propValues[i]);
63
+ if (valueIndex === -1) {
64
+ return new Error(`Invalid ${location} \`${propName}\` \`${propValues[i]}\` supplied to \`${componentName}\`, expected ` + `a one of \`${validValues.join(', ')}\`.`);
65
+ }
66
+ }
67
+ } else {
68
+ return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `between one and four of the following valid values: \`${validValues.join(', ')}\`.`);
69
+ }
70
+ return null;
71
+ };
72
+ }
73
+ export default ThemeablePropTypes;
74
+ export { ThemeablePropTypes, shorthandPropType };
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  export { ThemeablePropValues } from './ThemeablePropValues';
26
+ export { ThemeablePropTypes } from './ThemeablePropTypes';
26
27
  export { makeThemeVars } from './makeThemeVars';
27
28
  export { getShorthandPropValue } from './getShorthandPropValue';
28
29
  export { mirrorShorthandCorners } from './mirrorShorthandCorners';
package/es/useTheme.js CHANGED
@@ -25,18 +25,24 @@
25
25
  import { useTheme as useEmotionTheme } from '@emotion/react';
26
26
  import canvas from '@instructure/ui-themes';
27
27
  import { isEmpty } from '@instructure/ui-utils';
28
+ import { ThemeRegistry } from '@instructure/theme-registry';
28
29
  /**
29
30
  * ---
30
31
  * private: true
31
32
  * ---
32
33
  * A hook that will return the currently applied theme object from the nearest Context.
33
- * If there is no theme provided to the Context, it will return the default `canvas` theme.
34
+ * If there is no Context, then it tries to get the current theme from the global ThemeRegistry.
35
+ * If there is no theme provided to the Context and ThemeRegistry it will return the default `canvas` theme.
34
36
  * @returns The theme object
35
37
  */
36
38
  const useTheme = () => {
37
39
  // This reads the theme from Emotion's ThemeContext
38
40
  let theme = useEmotionTheme();
39
41
  if (isEmpty(theme)) {
42
+ const globalTheme = ThemeRegistry.getCurrentTheme();
43
+ if (globalTheme) {
44
+ return globalTheme;
45
+ }
40
46
  if (process.env.NODE_ENV !== 'production') {}
41
47
  theme = canvas;
42
48
  }
package/es/withStyle.js CHANGED
@@ -69,7 +69,7 @@ const defaultValues = {
69
69
  * [InstUISettingsProvider](#InstUISettingsProvider) component, and/or set
70
70
  * explicitly via its `themeOverride` prop.
71
71
  *
72
- * InstUISettingsProvider provides a theme object (e.g. the [canvas theme](/#canvas)).
72
+ * InstUISettingsProvider provides a theme object with global theme variables (e.g. the [canvas theme](/#canvas)).
73
73
  * These variables are mapped to the component's own variables in `theme.js` (see [theming](#theming-basics) for more info).
74
74
  *
75
75
  * With the `themeOverride` prop you can directly set/override the component theme variables declared in theme.js. It accepts an object or a function. The function has the component's theme and the currently active main theme as its parameter.
@@ -164,7 +164,13 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
164
164
  // added so it can be tested with ReactTestUtils
165
165
  // more info: https://github.com/facebook/react/issues/13455
166
166
  WithStyle.originalType = ComposedComponent.originalType || ComposedComponent;
167
+
168
+ // we have to pass these on, because sometimes users
169
+ // access propTypes of the component in other components
170
+ // eslint-disable-next-line react/forbid-foreign-prop-types
171
+ WithStyle.propTypes = ComposedComponent.propTypes;
167
172
  WithStyle.defaultProps = ComposedComponent.defaultProps;
173
+
168
174
  // These static fields exist on InstUI components
169
175
  WithStyle.allowedProps = ComposedComponent.allowedProps;
170
176
 
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.InstUISettingsProvider = InstUISettingsProvider;
7
8
  exports.default = void 0;
8
9
  var _react = require("react");
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
11
  var _react2 = require("@emotion/react");
10
12
  var _TextDirectionContext = require("@instructure/ui-i18n/lib/TextDirectionContext.js");
11
13
  var _DeterministicIdContextProvider = require("@instructure/ui-react-utils/lib/DeterministicIdContext/DeterministicIdContextProvider.js");
@@ -45,7 +47,8 @@ function InstUISettingsProvider({
45
47
  children,
46
48
  theme = {},
47
49
  dir,
48
- instanceCounterMap
50
+ instanceCounterMap,
51
+ as
49
52
  }) {
50
53
  const finalDir = dir || (0, _react.useContext)(_TextDirectionContext.TextDirectionContext);
51
54
  if (process.env.NODE_ENV !== 'production' && finalDir === 'auto') {}
@@ -60,11 +63,21 @@ function InstUISettingsProvider({
60
63
  })
61
64
  });
62
65
  if (dir) {
63
- providers = (0, _jsxRuntime.jsx)("span", {
66
+ const Element = as || 'span';
67
+ providers = (0, _jsxRuntime.jsx)(Element, {
64
68
  dir: finalDir,
65
69
  children: providers
66
70
  });
67
- }
71
+ } else if (as && process.env.NODE_ENV !== 'production') {}
68
72
  return providers;
69
73
  }
74
+ InstUISettingsProvider.propTypes = {
75
+ /* eslint-disable react/require-default-props */
76
+ children: _propTypes.default.node,
77
+ theme: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.func]),
78
+ dir: _propTypes.default.oneOf(['ltr', 'rtl']),
79
+ instanceCounterMap: _propTypes.default.instanceOf(Map),
80
+ as: _propTypes.default.string
81
+ /* eslint-enable react/require-default-props */
82
+ };
70
83
  var _default = exports.default = InstUISettingsProvider;
package/lib/getTheme.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getTheme = exports.default = void 0;
8
8
  var _uiThemes = _interopRequireDefault(require("@instructure/ui-themes"));
9
+ var _themeRegistry = require("@instructure/theme-registry");
9
10
  var _isBaseTheme = require("@instructure/ui-utils/lib/isBaseTheme.js");
10
11
  var _mergeDeep = require("@instructure/ui-utils/lib/mergeDeep.js");
11
12
  /*
@@ -53,8 +54,9 @@ const getTheme = themeOrOverride => (ancestorTheme = {}) => {
53
54
  // we need to clone the ancestor theme not to override it
54
55
  let currentTheme;
55
56
  if (Object.keys(ancestorTheme).length === 0) {
56
- if (process.env.NODE_ENV !== 'production') {}
57
- currentTheme = _uiThemes.default;
57
+ const globalTheme = _themeRegistry.ThemeRegistry.getCurrentTheme();
58
+ if (process.env.NODE_ENV !== 'production' && !globalTheme) {}
59
+ currentTheme = globalTheme || _uiThemes.default;
58
60
  } else {
59
61
  currentTheme = ancestorTheme;
60
62
  }
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ var _exportNames = {
7
7
  InstUISettingsProvider: true,
8
8
  withStyle: true,
9
9
  ThemeablePropValues: true,
10
+ ThemeablePropTypes: true,
10
11
  makeThemeVars: true,
11
12
  getShorthandPropValue: true,
12
13
  mirrorShorthandCorners: true,
@@ -20,6 +21,12 @@ Object.defineProperty(exports, "InstUISettingsProvider", {
20
21
  return _InstUISettingsProvider.InstUISettingsProvider;
21
22
  }
22
23
  });
24
+ Object.defineProperty(exports, "ThemeablePropTypes", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _styleUtils.ThemeablePropTypes;
28
+ }
29
+ });
23
30
  Object.defineProperty(exports, "ThemeablePropValues", {
24
31
  enumerable: true,
25
32
  get: function () {
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.ThemeablePropTypes = void 0;
8
+ exports.shorthandPropType = shorthandPropType;
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _ThemeablePropValues = require("./ThemeablePropValues");
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+
35
+ const SHADOW_TYPES = _ThemeablePropValues.ThemeablePropValues.SHADOW_TYPES,
36
+ STACKING_TYPES = _ThemeablePropValues.ThemeablePropValues.STACKING_TYPES,
37
+ BORDER_WIDTHS = _ThemeablePropValues.ThemeablePropValues.BORDER_WIDTHS,
38
+ BORDER_RADII = _ThemeablePropValues.ThemeablePropValues.BORDER_RADII,
39
+ BACKGROUNDS = _ThemeablePropValues.ThemeablePropValues.BACKGROUNDS,
40
+ SIZES = _ThemeablePropValues.ThemeablePropValues.SIZES;
41
+
42
+ /**
43
+ * ---
44
+ * category: utilities/themes
45
+ * ---
46
+ * Custom prop types for themeable React components.
47
+ * @module ThemeablePropTypes
48
+ */
49
+ const ThemeablePropTypes = exports.ThemeablePropTypes = {
50
+ shadow: _propTypes.default.oneOf(Object.values(SHADOW_TYPES)),
51
+ stacking: _propTypes.default.oneOf(Object.values(STACKING_TYPES)),
52
+ borderWidth: shorthandPropType(Object.values(BORDER_WIDTHS)),
53
+ borderRadius: shorthandPropType(Object.values(BORDER_RADII)),
54
+ background: _propTypes.default.oneOf(Object.values(BACKGROUNDS)),
55
+ size: _propTypes.default.oneOf(Object.values(SIZES))
56
+ };
57
+ function shorthandPropType(validValues) {
58
+ return function (props, propName, componentName, location) {
59
+ const propValue = props[propName];
60
+ if (typeof propValue === 'undefined') {
61
+ return null;
62
+ }
63
+ if (typeof propValue !== 'string') {
64
+ return new Error(`Invalid ${location} \`${propName}\` of type \`${typeof propValue}\` supplied to \`${componentName}\`, expected ` + `a string.`);
65
+ }
66
+ const propValues = propValue.split(' ');
67
+ const valuesLength = propValues.length;
68
+ if (valuesLength > 0 && valuesLength < 5) {
69
+ for (let i = 0; i < valuesLength; i++) {
70
+ const valueIndex = validValues.indexOf(propValues[i]);
71
+ if (valueIndex === -1) {
72
+ return new Error(`Invalid ${location} \`${propName}\` \`${propValues[i]}\` supplied to \`${componentName}\`, expected ` + `a one of \`${validValues.join(', ')}\`.`);
73
+ }
74
+ }
75
+ } else {
76
+ return new Error(`Invalid ${location} \`${propName}\` \`${propValue}\` supplied to \`${componentName}\`, expected ` + `between one and four of the following valid values: \`${validValues.join(', ')}\`.`);
77
+ }
78
+ return null;
79
+ };
80
+ }
81
+ var _default = exports.default = ThemeablePropTypes;
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "ThemeablePropTypes", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ThemeablePropTypes.ThemeablePropTypes;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "ThemeablePropValues", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -40,6 +46,7 @@ Object.defineProperty(exports, "mirrorShorthandEdges", {
40
46
  }
41
47
  });
42
48
  var _ThemeablePropValues = require("./ThemeablePropValues");
49
+ var _ThemeablePropTypes = require("./ThemeablePropTypes");
43
50
  var _makeThemeVars = require("./makeThemeVars");
44
51
  var _getShorthandPropValue = require("./getShorthandPropValue");
45
52
  var _mirrorShorthandCorners = require("./mirrorShorthandCorners");
package/lib/useTheme.js CHANGED
@@ -8,6 +8,7 @@ exports.useTheme = exports.default = void 0;
8
8
  var _react = require("@emotion/react");
9
9
  var _uiThemes = _interopRequireDefault(require("@instructure/ui-themes"));
10
10
  var _isEmpty = require("@instructure/ui-utils/lib/isEmpty.js");
11
+ var _themeRegistry = require("@instructure/theme-registry");
11
12
  /*
12
13
  * The MIT License (MIT)
13
14
  *
@@ -37,13 +38,18 @@ var _isEmpty = require("@instructure/ui-utils/lib/isEmpty.js");
37
38
  * private: true
38
39
  * ---
39
40
  * A hook that will return the currently applied theme object from the nearest Context.
40
- * If there is no theme provided to the Context, it will return the default `canvas` theme.
41
+ * If there is no Context, then it tries to get the current theme from the global ThemeRegistry.
42
+ * If there is no theme provided to the Context and ThemeRegistry it will return the default `canvas` theme.
41
43
  * @returns The theme object
42
44
  */
43
45
  const useTheme = () => {
44
46
  // This reads the theme from Emotion's ThemeContext
45
47
  let theme = (0, _react.useTheme)();
46
48
  if ((0, _isEmpty.isEmpty)(theme)) {
49
+ const globalTheme = _themeRegistry.ThemeRegistry.getCurrentTheme();
50
+ if (globalTheme) {
51
+ return globalTheme;
52
+ }
47
53
  if (process.env.NODE_ENV !== 'production') {}
48
54
  theme = _uiThemes.default;
49
55
  }
package/lib/withStyle.js CHANGED
@@ -76,7 +76,7 @@ const defaultValues = {
76
76
  * [InstUISettingsProvider](#InstUISettingsProvider) component, and/or set
77
77
  * explicitly via its `themeOverride` prop.
78
78
  *
79
- * InstUISettingsProvider provides a theme object (e.g. the [canvas theme](/#canvas)).
79
+ * InstUISettingsProvider provides a theme object with global theme variables (e.g. the [canvas theme](/#canvas)).
80
80
  * These variables are mapped to the component's own variables in `theme.js` (see [theming](#theming-basics) for more info).
81
81
  *
82
82
  * With the `themeOverride` prop you can directly set/override the component theme variables declared in theme.js. It accepts an object or a function. The function has the component's theme and the currently active main theme as its parameter.
@@ -171,7 +171,13 @@ const withStyle = exports.withStyle = (0, _decorator.decorator)((ComposedCompone
171
171
  // added so it can be tested with ReactTestUtils
172
172
  // more info: https://github.com/facebook/react/issues/13455
173
173
  WithStyle.originalType = ComposedComponent.originalType || ComposedComponent;
174
+
175
+ // we have to pass these on, because sometimes users
176
+ // access propTypes of the component in other components
177
+ // eslint-disable-next-line react/forbid-foreign-prop-types
178
+ WithStyle.propTypes = ComposedComponent.propTypes;
174
179
  WithStyle.defaultProps = ComposedComponent.defaultProps;
180
+
175
181
  // These static fields exist on InstUI components
176
182
  WithStyle.allowedProps = ComposedComponent.allowedProps;
177
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/emotion",
3
- "version": "10.26.1-snapshot-2",
3
+ "version": "10.26.1",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -25,25 +25,27 @@
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.27.6",
27
27
  "@emotion/react": "^11",
28
- "@instructure/console": "10.26.1-snapshot-2",
29
- "@instructure/shared-types": "10.26.1-snapshot-2",
30
- "@instructure/ui-decorator": "10.26.1-snapshot-2",
31
- "@instructure/ui-i18n": "10.26.1-snapshot-2",
32
- "@instructure/ui-react-utils": "10.26.1-snapshot-2",
33
- "@instructure/ui-themes": "10.26.1-snapshot-2",
34
- "@instructure/ui-utils": "10.26.1-snapshot-2",
35
- "hoist-non-react-statics": "^3.3.2"
28
+ "@instructure/console": "10.26.1",
29
+ "@instructure/shared-types": "10.26.1",
30
+ "@instructure/theme-registry": "10.26.1",
31
+ "@instructure/ui-decorator": "10.26.1",
32
+ "@instructure/ui-i18n": "10.26.1",
33
+ "@instructure/ui-react-utils": "10.26.1",
34
+ "@instructure/ui-themes": "10.26.1",
35
+ "@instructure/ui-utils": "10.26.1",
36
+ "hoist-non-react-statics": "^3.3.2",
37
+ "prop-types": "^15.8.1"
36
38
  },
37
39
  "devDependencies": {
38
- "@instructure/ui-babel-preset": "10.26.1-snapshot-2",
40
+ "@instructure/ui-babel-preset": "10.26.1",
39
41
  "@testing-library/jest-dom": "^6.6.3",
40
- "@testing-library/react": "15.0.7",
42
+ "@testing-library/react": "^16.0.1",
41
43
  "@testing-library/user-event": "^14.6.1",
42
- "react-dom": "18.3.1",
44
+ "react-dom": "^18.3.1",
43
45
  "vitest": "^3.2.2"
44
46
  },
45
47
  "peerDependencies": {
46
- "react": ">=18 <=19"
48
+ "react": ">=16.14 <=18"
47
49
  },
48
50
  "publishConfig": {
49
51
  "access": "public"
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  import { useContext } from 'react'
26
+ import PropTypes from 'prop-types'
26
27
  import { ThemeProvider } from '@emotion/react'
27
28
 
28
29
  import { TextDirectionContext } from '@instructure/ui-i18n'
@@ -32,6 +33,7 @@ import { getTheme } from '../getTheme'
32
33
 
33
34
  import type { ThemeOrOverride } from '../EmotionTypes'
34
35
  import type { DeterministicIdProviderValue } from '@instructure/ui-react-utils'
36
+ import type { AsElementType } from '@instructure/shared-types'
35
37
 
36
38
  type InstUIProviderProps = {
37
39
  children?: React.ReactNode
@@ -49,15 +51,32 @@ type InstUIProviderProps = {
49
51
  * specific InstUI components. (generally this is used for deterministic id generation for [SSR](/#server-side-rendering))
50
52
  */
51
53
  instanceCounterMap?: DeterministicIdProviderValue
52
-
53
- /**
54
- * The text direction to use in the descendants. If not provided, it uses the following in this priority order:
55
- * - The value given in a parent `TextDirectionContext`
56
- * - The `dir` prop of `document.documentElement` or its `direction` CSS prop
57
- * - The default `ltr`
58
- */
59
- dir?: 'ltr' | 'rtl'
60
- }
54
+ } & (
55
+ | {
56
+ /**
57
+ * The text direction to use in the descendants. If not provided, it uses the following in this priority order:
58
+ * - The value given in a parent `TextDirectionContext`
59
+ * - The `dir` prop of `document.documentElement` or its `direction` CSS prop
60
+ * - The default `ltr`
61
+ */
62
+ dir: 'ltr' | 'rtl'
63
+ /**
64
+ * @deprecated This prop will be removed in InstUI v11
65
+ *
66
+ * The element type to render as
67
+ */
68
+ as?: AsElementType
69
+ }
70
+ | {
71
+ dir?: never
72
+ /**
73
+ * @deprecated This prop will be removed in InstUI v11
74
+ *
75
+ * The element type to render as
76
+ */
77
+ as?: never
78
+ }
79
+ )
61
80
 
62
81
  /**
63
82
  * ---
@@ -69,7 +88,8 @@ function InstUISettingsProvider({
69
88
  children,
70
89
  theme = {},
71
90
  dir,
72
- instanceCounterMap
91
+ instanceCounterMap,
92
+ as
73
93
  }: InstUIProviderProps) {
74
94
  const finalDir = dir || useContext(TextDirectionContext)
75
95
 
@@ -90,11 +110,26 @@ function InstUISettingsProvider({
90
110
  )
91
111
 
92
112
  if (dir) {
93
- providers = <span dir={finalDir}>{providers}</span>
113
+ const Element = as || 'span'
114
+ providers = <Element dir={finalDir}>{providers}</Element>
115
+ } else if (as && process.env.NODE_ENV !== 'production') {
116
+ console.warn(
117
+ "The 'as' property should be used in conjunction with the 'dir' property!"
118
+ )
94
119
  }
95
120
 
96
121
  return providers
97
122
  }
98
123
 
124
+ InstUISettingsProvider.propTypes = {
125
+ /* eslint-disable react/require-default-props */
126
+ children: PropTypes.node,
127
+ theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
128
+ dir: PropTypes.oneOf(['ltr', 'rtl']),
129
+ instanceCounterMap: PropTypes.instanceOf(Map),
130
+ as: PropTypes.string
131
+ /* eslint-enable react/require-default-props */
132
+ }
133
+
99
134
  export default InstUISettingsProvider
100
135
  export { InstUISettingsProvider }
package/src/getTheme.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import canvas from '@instructure/ui-themes'
25
+ import { ThemeRegistry } from '@instructure/theme-registry'
25
26
  import { isBaseTheme, mergeDeep } from '@instructure/ui-utils'
26
27
 
27
28
  import type { BaseTheme } from '@instructure/shared-types'
@@ -54,12 +55,14 @@ const getTheme =
54
55
  // we need to clone the ancestor theme not to override it
55
56
  let currentTheme
56
57
  if (Object.keys(ancestorTheme).length === 0) {
57
- if (process.env.NODE_ENV !== 'production') {
58
+ const globalTheme = ThemeRegistry.getCurrentTheme()
59
+
60
+ if (process.env.NODE_ENV !== 'production' && !globalTheme) {
58
61
  console.warn(
59
62
  'No theme provided for [InstUISettingsProvider], using default `canvas` theme.'
60
63
  )
61
64
  }
62
- currentTheme = canvas
65
+ currentTheme = globalTheme || canvas
63
66
  } else {
64
67
  currentTheme = ancestorTheme
65
68
  }
package/src/index.ts CHANGED
@@ -29,6 +29,7 @@ export { InstUISettingsProvider } from './InstUISettingsProvider'
29
29
  export { withStyle } from './withStyle'
30
30
  export {
31
31
  ThemeablePropValues,
32
+ ThemeablePropTypes,
32
33
  makeThemeVars,
33
34
  getShorthandPropValue,
34
35
  mirrorShorthandCorners,