@instructure/ui-view 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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,14 @@
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
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-view
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-view
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug', 'borderColor'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-view",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A component for basic styles including spacing, sizing, borders, display, positioning, and focus states.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -15,22 +15,22 @@
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
- "@instructure/console": "11.6.0",
19
- "@instructure/emotion": "11.6.0",
20
- "@instructure/shared-types": "11.6.0",
21
- "@instructure/ui-dom-utils": "11.6.0",
22
- "@instructure/ui-color-utils": "11.6.0",
23
- "@instructure/ui-position": "11.6.0",
24
- "@instructure/ui-i18n": "11.6.0",
25
- "@instructure/ui-react-utils": "11.6.0"
18
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
19
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-i18n": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-position": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@testing-library/jest-dom": "^6.6.3",
29
29
  "@testing-library/react": "15.0.7",
30
30
  "vitest": "^3.2.2",
31
- "@instructure/ui-babel-preset": "11.6.0",
32
- "@instructure/ui-axe-check": "11.6.0",
33
- "@instructure/ui-themes": "11.6.0"
31
+ "@instructure/ui-axe-check": "11.6.1-pr-snapshot-1779894247159",
32
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
33
+ "@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=18 <=19"
@@ -43,10 +43,8 @@
43
43
  ".": {
44
44
  "types": "./types/index.d.ts",
45
45
  "import": "./es/index.js",
46
- "require": "./lib/index.js",
47
46
  "default": "./es/index.js"
48
47
  },
49
- "./lib/*": "./lib/*",
50
48
  "./es/*": "./es/*",
51
49
  "./types/*": "./types/*",
52
50
  "./package.json": "./package.json",
@@ -56,7 +54,7 @@
56
54
  "lint": "ui-scripts lint",
57
55
  "lint:fix": "ui-scripts lint --fix",
58
56
  "clean": "ui-scripts clean",
59
- "build": "ui-scripts build --modules es,cjs",
57
+ "build": "ui-scripts build",
60
58
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
61
59
  "build:types": "tsc -p tsconfig.build.json",
62
60
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,131 +0,0 @@
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.ContextView = void 0;
8
- var _react = require("react");
9
- var _emotion = require("@instructure/emotion");
10
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
11
- var _View = require("../View");
12
- var _styles = _interopRequireDefault(require("./styles"));
13
- var _theme = _interopRequireDefault(require("./theme"));
14
- var _props = require("./props");
15
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
- var _dec, _class, _ContextView;
17
- /*
18
- * The MIT License (MIT)
19
- *
20
- * Copyright (c) 2015 - present Instructure, Inc.
21
- *
22
- * Permission is hereby granted, free of charge, to any person obtaining a copy
23
- * of this software and associated documentation files (the "Software"), to deal
24
- * in the Software without restriction, including without limitation the rights
25
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
- * copies of the Software, and to permit persons to whom the Software is
27
- * furnished to do so, subject to the following conditions:
28
- *
29
- * The above copyright notice and this permission notice shall be included in all
30
- * copies or substantial portions of the Software.
31
- *
32
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
- * SOFTWARE.
39
- */
40
- /**
41
- ---
42
- category: components
43
- ---
44
- **/
45
- let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_ContextView = class ContextView extends _react.Component {
46
- constructor(...args) {
47
- super(...args);
48
- this.ref = null;
49
- this.handleRef = el => {
50
- const elementRef = this.props.elementRef;
51
- this.ref = el;
52
- if (typeof elementRef === 'function') {
53
- elementRef(el);
54
- }
55
- };
56
- }
57
- componentDidMount() {
58
- var _this$props$makeStyle, _this$props;
59
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
60
- }
61
- componentDidUpdate() {
62
- var _this$props$makeStyle2, _this$props2;
63
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
64
- }
65
- render() {
66
- const _this$props3 = this.props,
67
- as = _this$props3.as,
68
- background = _this$props3.background,
69
- children = _this$props3.children,
70
- debug = _this$props3.debug,
71
- height = _this$props3.height,
72
- width = _this$props3.width,
73
- maxHeight = _this$props3.maxHeight,
74
- maxWidth = _this$props3.maxWidth,
75
- minHeight = _this$props3.minHeight,
76
- minWidth = _this$props3.minWidth,
77
- margin = _this$props3.margin,
78
- padding = _this$props3.padding,
79
- shadow = _this$props3.shadow,
80
- stacking = _this$props3.stacking,
81
- style = _this$props3.style,
82
- textAlign = _this$props3.textAlign,
83
- styles = _this$props3.styles,
84
- borderColor = _this$props3.borderColor;
85
- return (0, _jsxRuntime.jsx)(_View.View, {
86
- ...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
87
- css: styles === null || styles === void 0 ? void 0 : styles.contextView,
88
- style: style,
89
- borderWidth: "none",
90
- display: "inline-block",
91
- as: as,
92
- withVisualDebug: debug,
93
- elementRef: this.handleRef,
94
- margin: margin,
95
- stacking: stacking,
96
- children: (0, _jsxRuntime.jsxs)(_View.View, {
97
- css: styles === null || styles === void 0 ? void 0 : styles.contextView__content,
98
- display: "block",
99
- borderRadius: "medium",
100
- borderWidth: "small",
101
- borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
102
- background: background === 'default' ? 'primary' : 'primary-inverse',
103
- withVisualDebug: debug,
104
- height: height,
105
- width: width,
106
- maxHeight: maxHeight,
107
- maxWidth: maxWidth,
108
- minHeight: minHeight,
109
- minWidth: minWidth,
110
- padding: padding,
111
- shadow: shadow,
112
- textAlign: textAlign,
113
- children: [(0, _jsxRuntime.jsx)("span", {
114
- css: styles === null || styles === void 0 ? void 0 : styles.contextView__arrow
115
- }), children]
116
- })
117
- });
118
- }
119
- }, _ContextView.displayName = "ContextView", _ContextView.componentId = 'ContextView', _ContextView.allowedProps = _props.allowedProps, _ContextView.defaultProps = {
120
- as: 'span',
121
- elementRef: () => {},
122
- debug: false,
123
- width: 'auto',
124
- height: 'auto',
125
- children: null,
126
- textAlign: 'start',
127
- background: 'default',
128
- shadow: 'resting',
129
- placement: 'center end'
130
- }, _ContextView)) || _class);
131
- var _default = exports.default = ContextView;
@@ -1,262 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _mirrorPlacement = require("@instructure/ui-position/lib/mirrorPlacement.js");
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- const endPlacements = ['end center', 'end top', 'end bottom', 'end stretch', 'center end', 'end'];
33
- const startPlacements = ['start center', 'start top', 'start bottom', 'start stretch', 'center start', 'start'];
34
- const bottomPlacements = ['bottom', 'bottom end', 'bottom start', 'bottom stretch', 'bottom center'];
35
- const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center'];
36
- const getPlacementStyle = (placement, theme) => {
37
- if (endPlacements.includes(placement)) {
38
- return {
39
- paddingInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
40
- paddingInlineEnd: '0'
41
- };
42
- }
43
- if (startPlacements.includes(placement)) {
44
- return {
45
- paddingInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
46
- paddingInlineStart: '0'
47
- };
48
- }
49
- if (bottomPlacements.includes(placement)) {
50
- return {
51
- paddingTop: theme === null || theme === void 0 ? void 0 : theme.arrowSize
52
- };
53
- }
54
- if (topPlacements.includes(placement)) {
55
- return {
56
- paddingBottom: theme === null || theme === void 0 ? void 0 : theme.arrowSize
57
- };
58
- }
59
- return {
60
- position: 'absolute',
61
- left: '-999em'
62
- };
63
- };
64
- const getArrowCorrections = (placement, theme) => {
65
- const center = ['top', 'bottom', 'top center', 'bottom center', 'top stretch', 'bottom stretch'];
66
- const start = ['top start', 'bottom start'];
67
- const end = ['top end', 'bottom end'];
68
- const top = ['start top', 'end top'];
69
- const bottom = ['start bottom', 'end bottom'];
70
- if (center.includes(placement)) {
71
- return {
72
- insetInlineStart: '50%'
73
- };
74
- }
75
- if (start.includes(placement)) {
76
- return {
77
- insetInlineStart: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
78
- insetInlineEnd: 'auto'
79
- };
80
- }
81
- if (end.includes(placement)) {
82
- return {
83
- insetInlineStart: `calc(100% - (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
84
- insetInlineEnd: 'auto'
85
- };
86
- }
87
- if (top.includes(placement)) {
88
- return {
89
- top: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
90
- };
91
- }
92
- if (bottom.includes(placement)) {
93
- return {
94
- top: `calc(100% - (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
95
- };
96
- }
97
- return {};
98
- };
99
- const getArrowPlacementVariant = (placement, background, theme, props) => {
100
- const transformedPlacement = (0, _mirrorPlacement.mirrorPlacement)(placement, ' ');
101
- const isInversed = background === 'inverse';
102
- const borderColor = props.borderColor;
103
- if (endPlacements.includes(transformedPlacement)) {
104
- return {
105
- main: {
106
- top: '50%',
107
- insetInlineStart: '100%',
108
- insetInlineEnd: 'auto',
109
- marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
110
- borderInlineEndWidth: '0',
111
- borderInlineEndColor: 'transparent',
112
- borderInlineStartColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
113
- borderTopColor: 'transparent',
114
- borderBottomColor: 'transparent',
115
- borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
116
- },
117
- __after: {
118
- insetInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
119
- insetInlineStart: 'auto',
120
- marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
121
- borderInlineEndWidth: '0',
122
- borderInlineEndColor: 'transparent',
123
- borderTopColor: 'transparent',
124
- borderBottomColor: 'transparent',
125
- borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
126
- borderInlineStartColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
127
- }
128
- };
129
- }
130
- if (startPlacements.includes(transformedPlacement)) {
131
- return {
132
- main: {
133
- top: '50%',
134
- insetInlineEnd: '100%',
135
- insetInlineStart: 'auto',
136
- marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
137
- borderInlineStartWidth: '0',
138
- borderInlineStartColor: 'transparent',
139
- borderInlineEndColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
140
- borderTopColor: 'transparent',
141
- borderBottomColor: 'transparent',
142
- borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
143
- },
144
- __after: {
145
- insetInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
146
- insetInlineEnd: 'auto',
147
- marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
148
- borderInlineStartWidth: '0',
149
- borderInlineStartColor: 'transparent',
150
- borderTopColor: 'transparent',
151
- borderBottomColor: 'transparent',
152
- borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
153
- borderInlineEndColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
154
- }
155
- };
156
- }
157
- if (bottomPlacements.includes(transformedPlacement)) {
158
- return {
159
- main: {
160
- top: '100%',
161
- marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
162
- marginInlineEnd: '0',
163
- borderBottomWidth: '0',
164
- borderBottomColor: 'transparent',
165
- borderInlineStartColor: 'transparent',
166
- borderInlineEndColor: 'transparent'
167
- },
168
- __after: {
169
- bottom: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
170
- marginInlineStart: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
171
- marginInlineEnd: '0',
172
- borderBottomWidth: '0',
173
- borderBottomColor: 'transparent',
174
- borderInlineStartColor: 'transparent',
175
- borderInlineEndColor: 'transparent',
176
- borderTopColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
177
- }
178
- };
179
- }
180
- return {
181
- main: {
182
- bottom: '100%',
183
- marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
184
- marginInlineEnd: '0',
185
- borderTopWidth: '0',
186
- borderTopColor: 'transparent',
187
- borderInlineStartColor: 'transparent',
188
- borderInlineEndColor: 'transparent'
189
- },
190
- __after: {
191
- top: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
192
- marginInlineStart: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
193
- marginInlineEnd: '0',
194
- borderTopWidth: '0',
195
- borderTopColor: 'transparent',
196
- borderInlineStartColor: 'transparent',
197
- borderInlineEndColor: 'transparent',
198
- borderBottomColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
199
- }
200
- };
201
- };
202
-
203
- /**
204
- * ---
205
- * private: true
206
- * ---
207
- * Generates the style object from the theme and provided additional information
208
- * @param {Object} componentTheme The theme variable object.
209
- * @param {Object} props the props of the component, the style is applied to
210
- * @param {Object} state the state of the component, the style is applied to
211
- * @return {Object} The final style object, which will be used in the component
212
- */
213
- const generateStyle = (componentTheme, props) => {
214
- const placement = props.placement,
215
- background = props.background,
216
- borderColor = props.borderColor;
217
- const arrowBaseStyles = {
218
- content: '""',
219
- height: '0',
220
- width: '0',
221
- position: 'absolute',
222
- display: 'block',
223
- boxSizing: 'border-box',
224
- pointerEvents: 'none',
225
- borderStyle: 'solid'
226
- };
227
- const arrowBackGroundVariants = {
228
- default: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColor,
229
- inverse: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColorInverse
230
- };
231
- const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
232
- return {
233
- contextView: {
234
- label: 'contextView',
235
- boxSizing: 'border-box',
236
- minHeight: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} * 2)`,
237
- ...getPlacementStyle(placement, componentTheme)
238
- },
239
- contextView__content: {
240
- label: 'contextView__content',
241
- position: 'relative'
242
- },
243
- contextView__arrow: {
244
- label: 'contextView__arrow',
245
- ...arrowBaseStyles,
246
- display: 'block',
247
- borderWidth: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} + ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderWidth})`,
248
- borderColor: borderColor || arrowBackGroundVariants[background],
249
- ...arrowPlacementVariant.main,
250
- ...getArrowCorrections(placement, componentTheme),
251
- '&::after': {
252
- borderWidth: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize,
253
- borderColor: arrowBackGroundVariants[background],
254
- ...arrowPlacementVariant.__after,
255
- ...arrowBaseStyles
256
- }
257
- },
258
- arrowSize: componentTheme.arrowSize,
259
- arrowBorderWidth: componentTheme.arrowBorderWidth
260
- };
261
- };
262
- var _default = exports.default = generateStyle;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- var _theme$borders, _theme$colors, _theme$colors$contras, _theme$colors2, _theme$colors2$contra, _theme$colors3, _theme$colors3$contra;
38
- const componentVariables = {
39
- arrowSize: '0.5rem',
40
- arrowBorderWidth: theme === null || theme === void 0 ? void 0 : (_theme$borders = theme.borders) === null || _theme$borders === void 0 ? void 0 : _theme$borders.widthSmall,
41
- arrowBackgroundColor: theme === null || theme === void 0 ? void 0 : (_theme$colors = theme.colors) === null || _theme$colors === void 0 ? void 0 : (_theme$colors$contras = _theme$colors.contrasts) === null || _theme$colors$contras === void 0 ? void 0 : _theme$colors$contras.white1010,
42
- arrowBorderColor: theme === null || theme === void 0 ? void 0 : (_theme$colors2 = theme.colors) === null || _theme$colors2 === void 0 ? void 0 : (_theme$colors2$contra = _theme$colors2.contrasts) === null || _theme$colors2$contra === void 0 ? void 0 : _theme$colors2$contra.grey1424,
43
- arrowBackgroundColorInverse: theme === null || theme === void 0 ? void 0 : (_theme$colors3 = theme.colors) === null || _theme$colors3 === void 0 ? void 0 : (_theme$colors3$contra = _theme$colors3.contrasts) === null || _theme$colors3$contra === void 0 ? void 0 : _theme$colors3$contra.grey125125,
44
- arrowBorderColorInverse: 'transparent'
45
- };
46
- return {
47
- ...componentVariables
48
- };
49
- };
50
- var _default = exports.default = generateComponentTheme;
package/lib/View/index.js DELETED
@@ -1,176 +0,0 @@
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.View = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = require("react");
10
- var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
11
- var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
12
- var _console = require("@instructure/console");
13
- var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
14
- var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
15
- var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
16
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
17
- var _emotion = require("@instructure/emotion");
18
- var _styles = _interopRequireDefault(require("./styles"));
19
- var _theme = _interopRequireDefault(require("./theme"));
20
- var _props = require("./props");
21
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
- const _excluded = ["children", "textAlign", "background", "display", "withVisualDebug", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "overflowX", "overflowY", "stacking", "shadow", "position", "focusPosition", "focusColor", "shouldAnimateFocus", "borderColor", "className", "overscrollBehavior", "styles", "makeStyles"];
23
- var _dec, _dec2, _class, _View;
24
- /*
25
- * The MIT License (MIT)
26
- *
27
- * Copyright (c) 2015 - present Instructure, Inc.
28
- *
29
- * Permission is hereby granted, free of charge, to any person obtaining a copy
30
- * of this software and associated documentation files (the "Software"), to deal
31
- * in the Software without restriction, including without limitation the rights
32
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
- * copies of the Software, and to permit persons to whom the Software is
34
- * furnished to do so, subject to the following conditions:
35
- *
36
- * The above copyright notice and this permission notice shall be included in all
37
- * copies or substantial portions of the Software.
38
- *
39
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
- * SOFTWARE.
46
- */
47
- /**
48
- ---
49
- category: components
50
- ---
51
- @module View
52
- **/
53
- let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_View = class View extends _react.Component {
54
- get _element() {
55
- return this.ref;
56
- }
57
- constructor(props) {
58
- super(props);
59
- this.spanMarginVerified = void 0;
60
- this.ref = null;
61
- this.handleElementRef = el => {
62
- if (typeof this.props.elementRef === 'function') {
63
- this.props.elementRef(el);
64
- }
65
- this.ref = el;
66
- };
67
- this.spanMarginVerified = false;
68
- }
69
- componentDidMount() {
70
- var _this$props$makeStyle, _this$props;
71
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
72
- }
73
- componentDidUpdate() {
74
- var _this$props$makeStyle2, _this$props2;
75
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
76
-
77
- // Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
78
- if (process.env.NODE_ENV === 'development' && !this.spanMarginVerified) {
79
- // We have to verify margins in the first 'componentDidUpdate',
80
- // because that is when all styles are calculated,
81
- // but we only want to check once, using a flag
82
- this.spanMarginVerified = true;
83
- (0, _console.logError)(!function verifySpanMargin(element, margin, _getCSSStyleDeclarati) {
84
- if (!element) {
85
- return;
86
- }
87
- const display = (_getCSSStyleDeclarati = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : _getCSSStyleDeclarati.display;
88
- if (display !== 'inline') {
89
- return;
90
- }
91
- const marginValues = margin ? margin.split(' ') : null;
92
- let verticalMargin = false;
93
-
94
- // either top or bottom margin are set
95
- if (margin) {
96
- if (marginValues && marginValues[0] && marginValues[0] !== 'none' && marginValues[0] !== '0') {
97
- verticalMargin = true;
98
- }
99
- if (marginValues && marginValues[2] && marginValues[2] !== 'none' && marginValues[2] !== '0') {
100
- verticalMargin = true;
101
- }
102
- }
103
- return verticalMargin;
104
- }(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
105
- }
106
- }
107
- render() {
108
- const _this$props3 = this.props,
109
- children = _this$props3.children,
110
- textAlign = _this$props3.textAlign,
111
- background = _this$props3.background,
112
- display = _this$props3.display,
113
- withVisualDebug = _this$props3.withVisualDebug,
114
- width = _this$props3.width,
115
- height = _this$props3.height,
116
- minWidth = _this$props3.minWidth,
117
- minHeight = _this$props3.minHeight,
118
- maxWidth = _this$props3.maxWidth,
119
- maxHeight = _this$props3.maxHeight,
120
- overflowX = _this$props3.overflowX,
121
- overflowY = _this$props3.overflowY,
122
- stacking = _this$props3.stacking,
123
- shadow = _this$props3.shadow,
124
- position = _this$props3.position,
125
- focusPosition = _this$props3.focusPosition,
126
- focusColor = _this$props3.focusColor,
127
- shouldAnimateFocus = _this$props3.shouldAnimateFocus,
128
- borderColor = _this$props3.borderColor,
129
- className = _this$props3.className,
130
- overscrollBehavior = _this$props3.overscrollBehavior,
131
- styles = _this$props3.styles,
132
- makeStyles = _this$props3.makeStyles,
133
- props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
134
- const ElementType = (0, _getElementType.getElementType)(View, this.props);
135
- return (0, _jsxRuntime.jsx)(ElementType, {
136
- ...(0, _passthroughProps.passthroughProps)(props),
137
- className: className,
138
- css: [styles === null || styles === void 0 ? void 0 : styles.view, styles === null || styles === void 0 ? void 0 : styles.inlineStyles],
139
- ref: this.handleElementRef,
140
- children: children
141
- });
142
- }
143
- }, _View.displayName = "View", _View.componentId = 'View', _View.allowedProps = _props.allowedProps, _View.defaultProps = {
144
- display: 'auto',
145
- overflowX: 'visible',
146
- overflowY: 'visible',
147
- withVisualDebug: false,
148
- borderColor: 'primary',
149
- position: 'static',
150
- focusPosition: 'offset',
151
- focusColor: 'info',
152
- shouldAnimateFocus: true,
153
- overscrollBehavior: 'auto'
154
- }, _View.omitViewProps = (props, Component) => {
155
- // We don't want the theming and styling props to pass
156
- // (these are added and handled by the `@withStyle` decorator)
157
- const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
158
- let shouldLogError = true;
159
- try {
160
- shouldLogError = process.env.NODE_ENV !== 'production';
161
- } catch (e) {
162
- if (e instanceof ReferenceError) {
163
- // if process is not available a ReferenceError is thrown
164
- shouldLogError = false;
165
- } else {
166
- throw e;
167
- }
168
- }
169
- if (shouldLogError) {
170
- Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
171
- (0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
172
- });
173
- }
174
- return (0, _omitProps.omitProps)(props, propsToOmit);
175
- }, _View)) || _class) || _class);
176
- var _default = exports.default = View;
package/lib/View/props.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- // This variable will be attached as static property on the `View` component
32
- // so we don't rely on the `PropTypes` validators for our internal logic.
33
- // This means on prod builds the consuming applications can safely delete propTypes.
34
- const allowedProps = exports.allowedProps = ['as', 'background', 'borderColor', 'borderRadius', 'borderWidth', 'children', 'cursor', 'dir', 'display', 'elementRef', 'focusColor', 'focusPosition', 'height', 'insetBlockEnd', 'insetBlockStart', 'insetInlineEnd', 'insetInlineStart', 'margin', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'overflowX', 'overflowY', 'overscrollBehavior', 'padding', 'position', 'shadow', 'shouldAnimateFocus', 'stacking', 'textAlign', 'width', 'withFocusOutline', 'withVisualDebug', 'focusRingBorderRadius', 'focusWithin'];
@@ -1,417 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _uiI18n = require("@instructure/ui-i18n");
8
- var _emotion = require("@instructure/emotion");
9
- var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
10
- var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
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 getBorderStyle = ({
36
- borderRadius,
37
- borderWidth,
38
- dir,
39
- theme
40
- }) => {
41
- const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
42
- return {
43
- borderRadius: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandCorners)(borderRadius) : borderRadius, 'borderRadius', true),
44
- borderWidth: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(borderWidth) : borderWidth, 'borderWidth')
45
- };
46
- };
47
- const getSpacingStyle = ({
48
- margin,
49
- padding,
50
- dir,
51
- theme
52
- }) => {
53
- const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
54
- return {
55
- margin: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(margin) : margin, 'margin'),
56
- padding: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(padding) : padding, 'padding')
57
- };
58
- };
59
- const getOffsetStyle = ({
60
- insetBlockStart,
61
- insetBlockEnd,
62
- insetInlineStart,
63
- insetInlineEnd,
64
- dir
65
- }) => {
66
- const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
67
- const blockStart = {
68
- top: insetBlockStart,
69
- insetBlockStart
70
- };
71
- const blockEnd = {
72
- bottom: insetBlockEnd,
73
- insetBlockEnd
74
- };
75
- const horizontalOffsets = {
76
- left: isRtlDirection ? insetInlineEnd : insetInlineStart,
77
- right: isRtlDirection ? insetInlineStart : insetInlineEnd
78
- };
79
- return {
80
- ...blockStart,
81
- ...blockEnd,
82
- ...horizontalOffsets
83
- };
84
- };
85
- const getStyleProps = ({
86
- cursor,
87
- style
88
- }) => {
89
- const whitelisted = (0, _pickProps.pickProps)(style || {}, {}, [
90
- // Position/calculateElementPosition:
91
- 'top', 'left', 'position', 'display', 'transform', 'overflow', 'minWidth', 'minHeight',
92
- // Img:
93
- 'filter',
94
- // Flex.Item:
95
- 'flexBasis',
96
- // Avatar:
97
- 'backgroundImage',
98
- // Popover:
99
- 'pointerEvents']);
100
- if (cursor) {
101
- whitelisted.cursor = cursor;
102
- }
103
- return whitelisted;
104
- };
105
- const withBorder = props => {
106
- const borderWidth = props.borderWidth;
107
- return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
108
- };
109
- const getFocusStyles = (props, componentTheme) => {
110
- const focusColor = props.focusColor,
111
- focusPosition = props.focusPosition,
112
- shouldAnimateFocus = props.shouldAnimateFocus,
113
- withFocusOutline = props.withFocusOutline,
114
- focusWithin = props.focusWithin;
115
- const focusPos = focusPosition == 'offset' || focusPosition == 'inset' ? focusPosition : 'offset';
116
- const focusPositionVariants = {
117
- offset: {
118
- outlineOffset: `calc(${componentTheme.focusOutlineOffset} - ${componentTheme.focusOutlineWidth})`
119
- },
120
- inset: {
121
- outlineOffset: `calc(${componentTheme.focusOutlineInset} - ${componentTheme.focusOutlineWidth})`
122
- }
123
- };
124
- const focusColorVariants = {
125
- info: componentTheme.focusColorInfo,
126
- inverse: componentTheme.focusColorInverse,
127
- success: componentTheme.focusColorSuccess,
128
- danger: componentTheme.focusColorDanger
129
- };
130
- const visibleFocusStyle = {
131
- ...focusPositionVariants[focusPos],
132
- outlineColor: focusColorVariants[focusColor]
133
- };
134
- const outlineStyle = {
135
- outlineOffset: '-0.8rem',
136
- // value when not in focus, its invisible
137
- outlineColor: (0, _alpha.alpha)(focusColorVariants[focusColor], 0),
138
- outlineStyle: componentTheme.focusOutlineStyle,
139
- outlineWidth: componentTheme.focusOutlineWidth,
140
- ...(withFocusOutline && visibleFocusStyle)
141
- };
142
- return {
143
- ...(shouldAnimateFocus && {
144
- transition: 'outline-color 0.2s, outline-offset 0.25s'
145
- }),
146
- ...outlineStyle,
147
- '&:hover, &:active': {
148
- // apply the same style so it's not overridden by some global style
149
- ...outlineStyle
150
- },
151
- ...(typeof withFocusOutline === 'undefined' && {
152
- // user focuses the element
153
- '&:focus': visibleFocusStyle
154
- }),
155
- ...(focusWithin && {
156
- '&:focus-within': visibleFocusStyle
157
- })
158
- };
159
- };
160
-
161
- /**
162
- * Generates the style object from the theme and provided additional information
163
- * @param {Object} componentTheme The theme variable object.
164
- * @param {Object} props the props of the component, the style is applied to
165
- * @return {Object} The final style object, which will be used in the component
166
- */
167
- const generateStyle = (componentTheme, props) => {
168
- const borderRadius = props.borderRadius,
169
- borderWidth = props.borderWidth,
170
- margin = props.margin,
171
- padding = props.padding,
172
- position = props.position,
173
- display = props.display,
174
- textAlign = props.textAlign,
175
- borderColor = props.borderColor,
176
- background = props.background,
177
- stacking = props.stacking,
178
- shadow = props.shadow,
179
- overflowY = props.overflowY,
180
- overflowX = props.overflowX,
181
- overscrollBehavior = props.overscrollBehavior,
182
- insetBlockEnd = props.insetBlockEnd,
183
- insetBlockStart = props.insetBlockStart,
184
- insetInlineEnd = props.insetInlineEnd,
185
- insetInlineStart = props.insetInlineStart,
186
- width = props.width,
187
- height = props.height,
188
- minWidth = props.minWidth,
189
- minHeight = props.minHeight,
190
- maxWidth = props.maxWidth,
191
- maxHeight = props.maxHeight,
192
- withVisualDebug = props.withVisualDebug,
193
- dir = props.dir;
194
- const borderStyle = getBorderStyle({
195
- theme: componentTheme,
196
- borderRadius,
197
- borderWidth,
198
- dir
199
- });
200
- const spacingStyle = getSpacingStyle({
201
- margin,
202
- padding,
203
- theme: componentTheme,
204
- dir
205
- });
206
- const offsetStyle = getOffsetStyle({
207
- dir,
208
- insetBlockEnd,
209
- insetBlockStart,
210
- insetInlineEnd,
211
- insetInlineStart
212
- });
213
- const displayVariants = {
214
- inline: {
215
- label: 'view--inline',
216
- display: 'inline'
217
- },
218
- block: {
219
- label: 'view--block',
220
- display: 'block'
221
- },
222
- 'inline-block': {
223
- label: 'view--inlineBlock',
224
- display: 'inline-block',
225
- verticalAlign: 'middle'
226
- },
227
- flex: {
228
- label: 'view--flex',
229
- display: 'flex'
230
- },
231
- 'inline-flex': {
232
- label: 'view--inlineFlex',
233
- display: 'inline-flex',
234
- verticalAlign: 'middle'
235
- },
236
- contents: {
237
- label: 'view--contents',
238
- display: 'contents'
239
- },
240
- inherit: {
241
- label: 'view--inherit',
242
- display: 'inherit'
243
- },
244
- initial: {
245
- label: 'view--initial',
246
- display: 'initial'
247
- },
248
- revert: {
249
- label: 'view--revert',
250
- display: 'revert'
251
- },
252
- 'revert-layer': {
253
- label: 'view--revertLayer',
254
- display: 'revert-layer'
255
- },
256
- unset: {
257
- label: 'view--unset',
258
- display: 'unset'
259
- },
260
- auto: {}
261
- };
262
- const textAlignVariants = {
263
- start: {
264
- textAlign: 'start'
265
- },
266
- center: {
267
- textAlign: 'center'
268
- },
269
- end: {
270
- textAlign: 'end'
271
- }
272
- };
273
- const borderColorVariants = {
274
- transparent: {
275
- borderColor: componentTheme.borderColorTransparent
276
- },
277
- primary: {
278
- borderColor: componentTheme.borderColorPrimary
279
- },
280
- secondary: {
281
- borderColor: componentTheme.borderColorSecondary
282
- },
283
- brand: {
284
- borderColor: componentTheme.borderColorBrand
285
- },
286
- info: {
287
- borderColor: componentTheme.borderColorInfo
288
- },
289
- success: {
290
- borderColor: componentTheme.borderColorSuccess
291
- },
292
- warning: {
293
- borderColor: componentTheme.borderColorWarning
294
- },
295
- alert: {
296
- borderColor: componentTheme.borderColorAlert
297
- },
298
- danger: {
299
- borderColor: componentTheme.borderColorDanger
300
- }
301
- };
302
- const backgroundColorVariants = {
303
- transparent: {
304
- color: componentTheme.color,
305
- background: 'none'
306
- },
307
- primary: {
308
- color: componentTheme.color,
309
- background: componentTheme.backgroundPrimary
310
- },
311
- secondary: {
312
- color: componentTheme.color,
313
- background: componentTheme.backgroundSecondary
314
- },
315
- ['primary-inverse']: {
316
- color: componentTheme.colorPrimaryInverse,
317
- background: componentTheme.backgroundPrimaryInverse
318
- },
319
- brand: {
320
- color: componentTheme.colorPrimaryInverse,
321
- background: componentTheme.backgroundBrand
322
- },
323
- info: {
324
- color: componentTheme.colorPrimaryInverse,
325
- background: componentTheme.backgroundInfo
326
- },
327
- alert: {
328
- color: componentTheme.colorPrimaryInverse,
329
- background: componentTheme.backgroundAlert
330
- },
331
- success: {
332
- color: componentTheme.colorPrimaryInverse,
333
- background: componentTheme.backgroundSuccess
334
- },
335
- danger: {
336
- color: componentTheme.colorPrimaryInverse,
337
- background: componentTheme.backgroundDanger
338
- },
339
- warning: {
340
- color: componentTheme.colorPrimaryInverse,
341
- background: componentTheme.backgroundWarning
342
- }
343
- };
344
- const stackingVariants = {
345
- topmost: {
346
- zIndex: componentTheme.stackingTopmost
347
- },
348
- above: {
349
- zIndex: componentTheme.stackingAbove
350
- },
351
- resting: {},
352
- below: {
353
- zIndex: componentTheme.stackingBelow
354
- },
355
- deepest: {
356
- zIndex: componentTheme.stackingDeepest
357
- }
358
- };
359
- const shadowVariants = {
360
- topmost: {
361
- boxShadow: componentTheme.shadowTopmost
362
- },
363
- resting: {
364
- boxShadow: componentTheme.shadowResting
365
- },
366
- above: {
367
- boxShadow: componentTheme.shadowAbove
368
- },
369
- none: {}
370
- };
371
- const focusStyles = getFocusStyles(props, componentTheme);
372
- return {
373
- view: {
374
- label: 'view',
375
- boxSizing: 'border-box',
376
- fontFamily: componentTheme.fontFamily,
377
- maxWidth: '100%',
378
- overflow: 'visible',
379
- ...displayVariants[display],
380
- ...(background && backgroundColorVariants[background]),
381
- ...(stacking && stackingVariants[stacking]),
382
- ...(shadow && shadowVariants[shadow]),
383
- ...(textAlign && textAlignVariants[textAlign]),
384
- overflowX: overflowX && overflowX !== 'visible' ? overflowX : '',
385
- overflowY: overflowY && overflowY !== 'visible' ? overflowY : '',
386
- position: position !== 'static' ? position : '',
387
- overscrollBehavior: overscrollBehavior ? overscrollBehavior : 'auto',
388
- ...(withVisualDebug ? {
389
- boxShadow: `0 0 0 1px ${componentTheme.debugOutlineColor}`
390
- } : {}),
391
- ...(withBorder(props) ? {
392
- borderStyle: componentTheme.borderStyle,
393
- ...(borderColorVariants[borderColor] || {
394
- borderColor: borderColor
395
- })
396
- } : {}),
397
- ...borderStyle
398
- },
399
- inlineStyles: {
400
- //every '&' symbol will add another class to the rule, so it will be stronger
401
- //making an accidental override less likely
402
- '&&&&&&&&&&': {
403
- ...spacingStyle,
404
- ...offsetStyle,
405
- ...focusStyles,
406
- width,
407
- height,
408
- minWidth,
409
- minHeight,
410
- maxWidth,
411
- maxHeight,
412
- ...getStyleProps(props)
413
- }
414
- }
415
- };
416
- };
417
- var _default = exports.default = generateStyle;
package/lib/View/theme.js DELETED
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _emotion = require("@instructure/emotion");
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /* Global variables (colors, typography, spacing, etc.) are defined in lib/themes */
33
-
34
- /**
35
- * Generates the theme object for the component from the theme and provided additional information
36
- * @param {Object} theme The actual theme object.
37
- * @return {Object} The final theme object with the overrides and component variables
38
- */
39
- const generateComponentTheme = theme => {
40
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1, _colors$contrasts10, _colors$contrasts11, _colors$contrasts12, _colors$contrasts13, _colors$contrasts14, _colors$contrasts15, _colors$contrasts16, _colors$contrasts17, _colors$contrasts18, _colors$contrasts19, _colors$contrasts20, _colors$contrasts21, _colors$contrasts22;
41
- const colors = theme.colors,
42
- typography = theme.typography,
43
- borders = theme.borders,
44
- breakpoints = theme.breakpoints,
45
- spacing = theme.spacing,
46
- shadows = theme.shadows,
47
- stacking = theme.stacking,
48
- themeName = theme.key;
49
- const themeSpecificStyle = {
50
- canvas: {
51
- color: theme['ic-brand-font-color-dark'],
52
- focusColorInfo: theme['ic-brand-primary'],
53
- backgroundBrand: theme['ic-brand-primary'],
54
- backgroundInfo: theme['ic-brand-primary'],
55
- borderColorBrand: theme['ic-brand-primary'],
56
- borderColorInfo: theme['ic-brand-primary']
57
- }
58
- };
59
- const componentVariables = {
60
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
61
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
62
- colorPrimaryInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
63
- borderColorPrimary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.grey1424,
64
- borderColorSecondary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
65
- borderColorSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.green4570,
66
- borderColorBrand: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.blue4570,
67
- borderColorInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.blue4570,
68
- borderColorAlert: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.blue4570,
69
- borderColorWarning: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.orange4570,
70
- borderColorDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.red4570,
71
- borderColorTransparent: 'transparent',
72
- debugOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.red4570,
73
- backgroundPrimary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts10 = colors.contrasts) === null || _colors$contrasts10 === void 0 ? void 0 : _colors$contrasts10.white1010,
74
- backgroundSecondary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts11 = colors.contrasts) === null || _colors$contrasts11 === void 0 ? void 0 : _colors$contrasts11.grey1111,
75
- backgroundPrimaryInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts12 = colors.contrasts) === null || _colors$contrasts12 === void 0 ? void 0 : _colors$contrasts12.grey125125,
76
- backgroundBrand: colors === null || colors === void 0 ? void 0 : (_colors$contrasts13 = colors.contrasts) === null || _colors$contrasts13 === void 0 ? void 0 : _colors$contrasts13.blue4570,
77
- backgroundInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts14 = colors.contrasts) === null || _colors$contrasts14 === void 0 ? void 0 : _colors$contrasts14.blue4570,
78
- backgroundAlert: colors === null || colors === void 0 ? void 0 : (_colors$contrasts15 = colors.contrasts) === null || _colors$contrasts15 === void 0 ? void 0 : _colors$contrasts15.blue4570,
79
- backgroundSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts16 = colors.contrasts) === null || _colors$contrasts16 === void 0 ? void 0 : _colors$contrasts16.green4570,
80
- backgroundDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts17 = colors.contrasts) === null || _colors$contrasts17 === void 0 ? void 0 : _colors$contrasts17.red4570,
81
- backgroundWarning: colors === null || colors === void 0 ? void 0 : (_colors$contrasts18 = colors.contrasts) === null || _colors$contrasts18 === void 0 ? void 0 : _colors$contrasts18.orange4570,
82
- arrowSize: '0.5rem',
83
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
84
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
85
- focusOutlineOffset: '0.3125rem',
86
- focusOutlineInset: '0rem',
87
- // do not use unitless zero (for CSS calc())
88
-
89
- focusColorInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts19 = colors.contrasts) === null || _colors$contrasts19 === void 0 ? void 0 : _colors$contrasts19.blue4570,
90
- focusColorDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts20 = colors.contrasts) === null || _colors$contrasts20 === void 0 ? void 0 : _colors$contrasts20.red4570,
91
- focusColorSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.green4570,
92
- focusColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts22 = colors.contrasts) === null || _colors$contrasts22 === void 0 ? void 0 : _colors$contrasts22.white1010,
93
- xSmallMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.xSmall,
94
- smallMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.small,
95
- mediumMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.medium,
96
- largeMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.large,
97
- ...(0, _emotion.makeThemeVars)('margin', spacing),
98
- ...(0, _emotion.makeThemeVars)('padding', spacing),
99
- ...(0, _emotion.makeThemeVars)('shadow', shadows),
100
- ...(0, _emotion.makeThemeVars)('stacking', stacking),
101
- ...(0, _emotion.makeThemeVars)('border', borders)
102
- };
103
- return {
104
- ...componentVariables,
105
- ...themeSpecificStyle[themeName]
106
- };
107
- };
108
- var _default = exports.default = generateComponentTheme;
package/lib/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ContextView", {
7
- enumerable: true,
8
- get: function () {
9
- return _ContextView.ContextView;
10
- }
11
- });
12
- Object.defineProperty(exports, "View", {
13
- enumerable: true,
14
- get: function () {
15
- return _View.View;
16
- }
17
- });
18
- var _ContextView = require("./ContextView");
19
- var _View = require("./View");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}