@instructure/emotion 8.10.1 → 8.10.3-snapshot.12
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 +4 -0
- package/LICENSE.md +27 -0
- package/es/withStyle.js +22 -6
- package/lib/withStyle.js +23 -6
- package/package.json +11 -10
- package/src/withStyle.tsx +26 -4
- package/types/withStyle.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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
|
+
## [8.10.2](https://github.com/instructure/instructure-ui/compare/v8.10.1...v8.10.2) (2021-10-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/emotion
|
|
9
|
+
|
|
6
10
|
## [8.10.1](https://github.com/instructure/instructure-ui/compare/v8.10.0...v8.10.1) (2021-10-01)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/emotion
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The MIT License (MIT)
|
|
3
|
+
category: Getting Started
|
|
4
|
+
order: 9
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# The MIT License (MIT)
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2015 Instructure, Inc.
|
|
10
|
+
|
|
11
|
+
**Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions.**
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
package/es/withStyle.js
CHANGED
|
@@ -26,12 +26,16 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
26
26
|
import React, { forwardRef, useState } from 'react';
|
|
27
27
|
import { isEqual } from 'lodash';
|
|
28
28
|
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
29
|
+
import { warn } from '@instructure/console';
|
|
29
30
|
import { decorator } from '@instructure/ui-decorator';
|
|
30
31
|
import { useTextDirectionContext } from '@instructure/ui-i18n';
|
|
31
32
|
import { bidirectionalPolyfill } from './styleUtils/bidirectionalPolyfill';
|
|
32
33
|
import { getComponentThemeOverride } from './getComponentThemeOverride';
|
|
33
34
|
import { useTheme } from './useTheme';
|
|
34
|
-
|
|
35
|
+
const defaultValues = {
|
|
36
|
+
styles: {},
|
|
37
|
+
makeStyles: () => {}
|
|
38
|
+
};
|
|
35
39
|
/**
|
|
36
40
|
* ---
|
|
37
41
|
* category: utilities/themes
|
|
@@ -100,13 +104,24 @@ import { useTheme } from './useTheme';
|
|
|
100
104
|
* @param {function} generateComponentTheme - The function that returns the component's theme variables object
|
|
101
105
|
* @returns {ReactElement} The decorated WithStyle Component
|
|
102
106
|
*/
|
|
107
|
+
|
|
103
108
|
const withStyle = decorator((ComposedComponent, generateStyle, generateComponentTheme) => {
|
|
104
109
|
const displayName = ComposedComponent.displayName || ComposedComponent.name;
|
|
105
110
|
const WithStyle = /*#__PURE__*/forwardRef((props, ref) => {
|
|
106
111
|
const theme = useTheme();
|
|
107
112
|
const dir = useTextDirectionContext();
|
|
113
|
+
|
|
114
|
+
if (props.styles) {
|
|
115
|
+
warn(false, `Manually passing the "styles" property is not allowed on the ${displayName} component. Using the default styles calculated by the @withStyle decorator instead.\n`, props.styles);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (props.makeStyles) {
|
|
119
|
+
warn(false, `Manually passing the "makeStyles" property is not allowed on the ${displayName} component. Styles are calculated by the @withStyle decorator.`);
|
|
120
|
+
}
|
|
121
|
+
|
|
108
122
|
const componentProps = { ...ComposedComponent.defaultProps,
|
|
109
|
-
...props
|
|
123
|
+
...props,
|
|
124
|
+
...defaultValues
|
|
110
125
|
};
|
|
111
126
|
const themeOverride = getComponentThemeOverride(theme, displayName, ComposedComponent.componentId, componentProps);
|
|
112
127
|
const componentTheme = typeof generateComponentTheme === 'function' ? { ...generateComponentTheme(theme),
|
|
@@ -127,10 +142,11 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
|
|
|
127
142
|
};
|
|
128
143
|
|
|
129
144
|
return /*#__PURE__*/React.createElement(ComposedComponent, Object.assign({
|
|
130
|
-
ref: ref
|
|
145
|
+
ref: ref
|
|
146
|
+
}, props, {
|
|
131
147
|
makeStyles: makeStyleHandler,
|
|
132
148
|
styles: styles
|
|
133
|
-
}
|
|
149
|
+
}));
|
|
134
150
|
});
|
|
135
151
|
hoistNonReactStatics(WithStyle, ComposedComponent); // we have to pass these on, because sometimes users
|
|
136
152
|
// access propTypes of the component in other components
|
|
@@ -145,8 +161,8 @@ const withStyle = decorator((ComposedComponent, generateStyle, generateComponent
|
|
|
145
161
|
// eslint-disable-next-line no-param-reassign
|
|
146
162
|
|
|
147
163
|
ComposedComponent.defaultProps = { ...ComposedComponent.defaultProps,
|
|
148
|
-
makeStyles:
|
|
149
|
-
styles:
|
|
164
|
+
makeStyles: defaultValues.makeStyles,
|
|
165
|
+
styles: defaultValues.styles
|
|
150
166
|
};
|
|
151
167
|
|
|
152
168
|
if (process.env.NODE_ENV !== 'production') {
|
package/lib/withStyle.js
CHANGED
|
@@ -17,6 +17,8 @@ var _lodash = require("lodash");
|
|
|
17
17
|
|
|
18
18
|
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
19
19
|
|
|
20
|
+
var _console = require("@instructure/console");
|
|
21
|
+
|
|
20
22
|
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
21
23
|
|
|
22
24
|
var _uiI18n = require("@instructure/ui-i18n");
|
|
@@ -50,7 +52,10 @@ var _useTheme = require("./useTheme");
|
|
|
50
52
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
51
53
|
* SOFTWARE.
|
|
52
54
|
*/
|
|
53
|
-
|
|
55
|
+
const defaultValues = {
|
|
56
|
+
styles: {},
|
|
57
|
+
makeStyles: () => {}
|
|
58
|
+
};
|
|
54
59
|
/**
|
|
55
60
|
* ---
|
|
56
61
|
* category: utilities/themes
|
|
@@ -119,13 +124,24 @@ var _useTheme = require("./useTheme");
|
|
|
119
124
|
* @param {function} generateComponentTheme - The function that returns the component's theme variables object
|
|
120
125
|
* @returns {ReactElement} The decorated WithStyle Component
|
|
121
126
|
*/
|
|
127
|
+
|
|
122
128
|
const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, generateComponentTheme) => {
|
|
123
129
|
const displayName = ComposedComponent.displayName || ComposedComponent.name;
|
|
124
130
|
const WithStyle = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
125
131
|
const theme = (0, _useTheme.useTheme)();
|
|
126
132
|
const dir = (0, _uiI18n.useTextDirectionContext)();
|
|
133
|
+
|
|
134
|
+
if (props.styles) {
|
|
135
|
+
(0, _console.warn)(false, `Manually passing the "styles" property is not allowed on the ${displayName} component. Using the default styles calculated by the @withStyle decorator instead.\n`, props.styles);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (props.makeStyles) {
|
|
139
|
+
(0, _console.warn)(false, `Manually passing the "makeStyles" property is not allowed on the ${displayName} component. Styles are calculated by the @withStyle decorator.`);
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
const componentProps = { ...ComposedComponent.defaultProps,
|
|
128
|
-
...props
|
|
143
|
+
...props,
|
|
144
|
+
...defaultValues
|
|
129
145
|
};
|
|
130
146
|
const themeOverride = (0, _getComponentThemeOverride.getComponentThemeOverride)(theme, displayName, ComposedComponent.componentId, componentProps);
|
|
131
147
|
const componentTheme = typeof generateComponentTheme === 'function' ? { ...generateComponentTheme(theme),
|
|
@@ -146,10 +162,11 @@ const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, g
|
|
|
146
162
|
};
|
|
147
163
|
|
|
148
164
|
return /*#__PURE__*/_react.default.createElement(ComposedComponent, Object.assign({
|
|
149
|
-
ref: ref
|
|
165
|
+
ref: ref
|
|
166
|
+
}, props, {
|
|
150
167
|
makeStyles: makeStyleHandler,
|
|
151
168
|
styles: styles
|
|
152
|
-
}
|
|
169
|
+
}));
|
|
153
170
|
});
|
|
154
171
|
(0, _hoistNonReactStatics.default)(WithStyle, ComposedComponent); // we have to pass these on, because sometimes users
|
|
155
172
|
// access propTypes of the component in other components
|
|
@@ -164,8 +181,8 @@ const withStyle = (0, _decorator.decorator)((ComposedComponent, generateStyle, g
|
|
|
164
181
|
// eslint-disable-next-line no-param-reassign
|
|
165
182
|
|
|
166
183
|
ComposedComponent.defaultProps = { ...ComposedComponent.defaultProps,
|
|
167
|
-
makeStyles:
|
|
168
|
-
styles:
|
|
184
|
+
makeStyles: defaultValues.makeStyles,
|
|
185
|
+
styles: defaultValues.styles
|
|
169
186
|
};
|
|
170
187
|
|
|
171
188
|
if (process.env.NODE_ENV !== 'production') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/emotion",
|
|
3
|
-
"version": "8.10.
|
|
3
|
+
"version": "8.10.3-snapshot.12+af470a237",
|
|
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.10.
|
|
30
|
-
"@instructure/shared-types": "8.10.
|
|
31
|
-
"@instructure/ui-decorator": "8.10.
|
|
32
|
-
"@instructure/ui-i18n": "8.10.
|
|
33
|
-
"@instructure/ui-themes": "8.10.
|
|
34
|
-
"@instructure/ui-utils": "8.10.
|
|
29
|
+
"@instructure/console": "8.10.3-snapshot.12+af470a237",
|
|
30
|
+
"@instructure/shared-types": "8.10.3-snapshot.12+af470a237",
|
|
31
|
+
"@instructure/ui-decorator": "8.10.3-snapshot.12+af470a237",
|
|
32
|
+
"@instructure/ui-i18n": "8.10.3-snapshot.12+af470a237",
|
|
33
|
+
"@instructure/ui-themes": "8.10.3-snapshot.12+af470a237",
|
|
34
|
+
"@instructure/ui-utils": "8.10.3-snapshot.12+af470a237",
|
|
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.10.
|
|
42
|
-
"@instructure/ui-test-utils": "8.10.
|
|
41
|
+
"@instructure/ui-babel-preset": "8.10.3-snapshot.12+af470a237",
|
|
42
|
+
"@instructure/ui-test-utils": "8.10.3-snapshot.12+af470a237",
|
|
43
43
|
"@types/lodash": "^4.14.171",
|
|
44
44
|
"cpy-cli": "^3.1.1"
|
|
45
45
|
},
|
|
@@ -49,5 +49,6 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"sideEffects": false
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"gitHead": "af470a2374463c265ed1304870b7890fc8bb09a4"
|
|
53
54
|
}
|
package/src/withStyle.tsx
CHANGED
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
import { isEqual } from 'lodash'
|
|
33
33
|
import hoistNonReactStatics from 'hoist-non-react-statics'
|
|
34
34
|
|
|
35
|
+
import { warn } from '@instructure/console'
|
|
35
36
|
import { decorator } from '@instructure/ui-decorator'
|
|
36
37
|
import { useTextDirectionContext } from '@instructure/ui-i18n'
|
|
37
38
|
import { bidirectionalPolyfill } from './styleUtils/bidirectionalPolyfill'
|
|
@@ -76,6 +77,11 @@ type WithStyleProps<
|
|
|
76
77
|
? WithStylePrivateProps<Style>
|
|
77
78
|
: WithStylePrivateProps<Style> & ThemeOverrideProp<Theme>
|
|
78
79
|
|
|
80
|
+
const defaultValues = {
|
|
81
|
+
styles: {},
|
|
82
|
+
makeStyles: () => {}
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
/**
|
|
80
86
|
* ---
|
|
81
87
|
* category: utilities/themes
|
|
@@ -161,9 +167,25 @@ const withStyle = decorator(
|
|
|
161
167
|
const theme = useTheme()
|
|
162
168
|
const dir = useTextDirectionContext()
|
|
163
169
|
|
|
170
|
+
if (props.styles) {
|
|
171
|
+
warn(
|
|
172
|
+
false,
|
|
173
|
+
`Manually passing the "styles" property is not allowed on the ${displayName} component. Using the default styles calculated by the @withStyle decorator instead.\n`,
|
|
174
|
+
props.styles
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (props.makeStyles) {
|
|
179
|
+
warn(
|
|
180
|
+
false,
|
|
181
|
+
`Manually passing the "makeStyles" property is not allowed on the ${displayName} component. Styles are calculated by the @withStyle decorator.`
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
164
185
|
const componentProps: Props = {
|
|
165
186
|
...ComposedComponent.defaultProps,
|
|
166
|
-
...props
|
|
187
|
+
...props,
|
|
188
|
+
...defaultValues
|
|
167
189
|
}
|
|
168
190
|
|
|
169
191
|
const themeOverride = getComponentThemeOverride(
|
|
@@ -205,9 +227,9 @@ const withStyle = decorator(
|
|
|
205
227
|
return (
|
|
206
228
|
<ComposedComponent
|
|
207
229
|
ref={ref}
|
|
230
|
+
{...props}
|
|
208
231
|
makeStyles={makeStyleHandler}
|
|
209
232
|
styles={styles}
|
|
210
|
-
{...props}
|
|
211
233
|
/>
|
|
212
234
|
)
|
|
213
235
|
})
|
|
@@ -230,8 +252,8 @@ const withStyle = decorator(
|
|
|
230
252
|
// eslint-disable-next-line no-param-reassign
|
|
231
253
|
ComposedComponent.defaultProps = {
|
|
232
254
|
...ComposedComponent.defaultProps,
|
|
233
|
-
makeStyles:
|
|
234
|
-
styles:
|
|
255
|
+
makeStyles: defaultValues.makeStyles,
|
|
256
|
+
styles: defaultValues.styles
|
|
235
257
|
}
|
|
236
258
|
|
|
237
259
|
if (process.env.NODE_ENV !== 'production') {
|
package/types/withStyle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withStyle.d.ts","sourceRoot":"","sources":["../src/withStyle.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAA+C,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"withStyle.d.ts","sourceRoot":"","sources":["../src/withStyle.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAA+C,MAAM,OAAO,CAAA;AAkBnE,OAAO,KAAK,EAAa,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,KAAK,EACV,cAAc,EAKf,MAAM,gBAAgB,CAAA;AASvB,aAAK,qBAAqB,CACxB,KAAK,SAAS,cAAc,GAAG,IAAI,GAAG,cAAc,IAClD,KAAK,SAAS,IAAI,GAElB,EAAE,GACF;IACE,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CAC3D,CAAA;AAEL,aAAK,iBAAiB,CAAC,KAAK,SAAS,cAAc,GAAG,IAAI,GAAG,cAAc,IAAI;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;CAC/B,CAAA;AAED,aAAK,cAAc,CACjB,KAAK,SAAS,cAAc,GAAG,IAAI,GAAG,cAAc,EACpD,KAAK,SAAS,cAAc,GAAG,IAAI,GAAG,cAAc,IAClD,KAAK,SAAS,IAAI,GAClB,qBAAqB,CAAC,KAAK,CAAC,GAC5B,qBAAqB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAO3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,QAAA,MAAM,SAAS,oFAgHd,CAAA;AAED,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA;AACpB,YAAY,EAAE,cAAc,EAAE,CAAA"}
|