@instructure/ui-view 11.6.0 → 11.6.1-snapshot-129

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 (97) hide show
  1. package/CHANGELOG.md +42 -307
  2. package/es/ContextView/{index.js → v1/index.js} +2 -2
  3. package/es/ContextView/v2/index.js +125 -0
  4. package/es/ContextView/v2/props.js +26 -0
  5. package/es/ContextView/v2/styles.js +256 -0
  6. package/es/View/{index.js → v1/index.js} +1 -1
  7. package/es/View/v2/index.js +167 -0
  8. package/es/View/v2/props.js +29 -0
  9. package/es/View/v2/styles.js +420 -0
  10. package/es/{index.js → exports/a.js} +2 -2
  11. package/{src/index.ts → es/exports/b.js} +2 -6
  12. package/lib/ContextView/{index.js → v1/index.js} +4 -4
  13. package/lib/ContextView/v2/index.js +130 -0
  14. package/lib/ContextView/v2/props.js +31 -0
  15. package/lib/ContextView/v2/styles.js +262 -0
  16. package/lib/View/{index.js → v1/index.js} +1 -1
  17. package/lib/View/v2/index.js +175 -0
  18. package/lib/View/v2/props.js +34 -0
  19. package/lib/View/v2/styles.js +426 -0
  20. package/lib/{index.js → exports/a.js} +4 -4
  21. package/lib/exports/b.js +19 -0
  22. package/package.json +41 -19
  23. package/src/ContextView/{index.tsx → v1/index.tsx} +2 -2
  24. package/src/ContextView/v2/README.md +53 -0
  25. package/src/ContextView/v2/index.tsx +144 -0
  26. package/src/ContextView/v2/props.ts +98 -0
  27. package/src/ContextView/v2/styles.ts +332 -0
  28. package/src/View/{index.tsx → v1/index.tsx} +1 -1
  29. package/src/View/v2/README.md +803 -0
  30. package/src/View/v2/index.tsx +240 -0
  31. package/src/View/v2/props.ts +278 -0
  32. package/src/View/v2/styles.ts +503 -0
  33. package/src/exports/a.ts +29 -0
  34. package/src/exports/b.ts +29 -0
  35. package/tsconfig.build.tsbuildinfo +1 -1
  36. package/types/ContextView/v1/index.d.ts.map +1 -0
  37. package/types/ContextView/v1/props.d.ts.map +1 -0
  38. package/types/ContextView/v1/styles.d.ts.map +1 -0
  39. package/types/ContextView/v1/theme.d.ts.map +1 -0
  40. package/types/ContextView/v2/index.d.ts +50 -0
  41. package/types/ContextView/v2/index.d.ts.map +1 -0
  42. package/types/ContextView/v2/props.d.ts +36 -0
  43. package/types/ContextView/v2/props.d.ts.map +1 -0
  44. package/types/ContextView/v2/styles.d.ts +14 -0
  45. package/types/ContextView/v2/styles.d.ts.map +1 -0
  46. package/types/View/v1/index.d.ts.map +1 -0
  47. package/types/View/v1/props.d.ts.map +1 -0
  48. package/types/View/v1/styles.d.ts.map +1 -0
  49. package/types/View/v1/theme.d.ts.map +1 -0
  50. package/types/View/v2/index.d.ts +36 -0
  51. package/types/View/v2/index.d.ts.map +1 -0
  52. package/types/View/v2/props.d.ts +157 -0
  53. package/types/View/v2/props.d.ts.map +1 -0
  54. package/types/View/v2/styles.d.ts +11 -0
  55. package/types/View/v2/styles.d.ts.map +1 -0
  56. package/types/exports/a.d.ts +5 -0
  57. package/types/exports/a.d.ts.map +1 -0
  58. package/types/exports/b.d.ts +5 -0
  59. package/types/exports/b.d.ts.map +1 -0
  60. package/types/ContextView/index.d.ts.map +0 -1
  61. package/types/ContextView/props.d.ts.map +0 -1
  62. package/types/ContextView/styles.d.ts.map +0 -1
  63. package/types/ContextView/theme.d.ts.map +0 -1
  64. package/types/View/index.d.ts.map +0 -1
  65. package/types/View/props.d.ts.map +0 -1
  66. package/types/View/styles.d.ts.map +0 -1
  67. package/types/View/theme.d.ts.map +0 -1
  68. package/types/index.d.ts +0 -5
  69. package/types/index.d.ts.map +0 -1
  70. /package/es/ContextView/{props.js → v1/props.js} +0 -0
  71. /package/es/ContextView/{styles.js → v1/styles.js} +0 -0
  72. /package/es/ContextView/{theme.js → v1/theme.js} +0 -0
  73. /package/es/View/{props.js → v1/props.js} +0 -0
  74. /package/es/View/{styles.js → v1/styles.js} +0 -0
  75. /package/es/View/{theme.js → v1/theme.js} +0 -0
  76. /package/lib/ContextView/{props.js → v1/props.js} +0 -0
  77. /package/lib/ContextView/{styles.js → v1/styles.js} +0 -0
  78. /package/lib/ContextView/{theme.js → v1/theme.js} +0 -0
  79. /package/lib/View/{props.js → v1/props.js} +0 -0
  80. /package/lib/View/{styles.js → v1/styles.js} +0 -0
  81. /package/lib/View/{theme.js → v1/theme.js} +0 -0
  82. /package/src/ContextView/{README.md → v1/README.md} +0 -0
  83. /package/src/ContextView/{props.ts → v1/props.ts} +0 -0
  84. /package/src/ContextView/{styles.ts → v1/styles.ts} +0 -0
  85. /package/src/ContextView/{theme.ts → v1/theme.ts} +0 -0
  86. /package/src/View/{README.md → v1/README.md} +0 -0
  87. /package/src/View/{props.ts → v1/props.ts} +0 -0
  88. /package/src/View/{styles.ts → v1/styles.ts} +0 -0
  89. /package/src/View/{theme.ts → v1/theme.ts} +0 -0
  90. /package/types/ContextView/{index.d.ts → v1/index.d.ts} +0 -0
  91. /package/types/ContextView/{props.d.ts → v1/props.d.ts} +0 -0
  92. /package/types/ContextView/{styles.d.ts → v1/styles.d.ts} +0 -0
  93. /package/types/ContextView/{theme.d.ts → v1/theme.d.ts} +0 -0
  94. /package/types/View/{index.d.ts → v1/index.d.ts} +0 -0
  95. /package/types/View/{props.d.ts → v1/props.d.ts} +0 -0
  96. /package/types/View/{styles.d.ts → v1/styles.d.ts} +0 -0
  97. /package/types/View/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,125 @@
1
+ var _dec, _class, _ContextView;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { withStyle } from '@instructure/emotion';
28
+ import { omitProps } from '@instructure/ui-react-utils';
29
+ import { View } from "../../View/v2/index.js";
30
+ import generateStyle from "./styles.js";
31
+ import { allowedProps } from "./props.js";
32
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
33
+ /**
34
+ ---
35
+ category: components
36
+ ---
37
+ **/
38
+ let ContextView = (_dec = withStyle(generateStyle), _dec(_class = (_ContextView = class ContextView extends Component {
39
+ constructor(...args) {
40
+ super(...args);
41
+ this.ref = null;
42
+ this.handleRef = el => {
43
+ const elementRef = this.props.elementRef;
44
+ this.ref = el;
45
+ if (typeof elementRef === 'function') {
46
+ elementRef(el);
47
+ }
48
+ };
49
+ }
50
+ componentDidMount() {
51
+ var _this$props$makeStyle, _this$props;
52
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
53
+ }
54
+ componentDidUpdate() {
55
+ var _this$props$makeStyle2, _this$props2;
56
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
57
+ }
58
+ render() {
59
+ const _this$props3 = this.props,
60
+ as = _this$props3.as,
61
+ background = _this$props3.background,
62
+ children = _this$props3.children,
63
+ debug = _this$props3.debug,
64
+ height = _this$props3.height,
65
+ width = _this$props3.width,
66
+ maxHeight = _this$props3.maxHeight,
67
+ maxWidth = _this$props3.maxWidth,
68
+ minHeight = _this$props3.minHeight,
69
+ minWidth = _this$props3.minWidth,
70
+ margin = _this$props3.margin,
71
+ padding = _this$props3.padding,
72
+ shadow = _this$props3.shadow,
73
+ stacking = _this$props3.stacking,
74
+ style = _this$props3.style,
75
+ textAlign = _this$props3.textAlign,
76
+ styles = _this$props3.styles,
77
+ borderColor = _this$props3.borderColor;
78
+ return _jsx(View, {
79
+ ...omitProps(this.props, ContextView.allowedProps),
80
+ css: styles === null || styles === void 0 ? void 0 : styles.contextView,
81
+ style: style,
82
+ borderWidth: "none",
83
+ display: "inline-block",
84
+ as: as,
85
+ withVisualDebug: debug,
86
+ elementRef: this.handleRef,
87
+ margin: margin,
88
+ stacking: stacking,
89
+ children: _jsxs(View, {
90
+ css: styles === null || styles === void 0 ? void 0 : styles.contextView__content,
91
+ display: "block",
92
+ borderRadius: styles === null || styles === void 0 ? void 0 : styles.borderRadius,
93
+ borderWidth: "small",
94
+ borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
95
+ background: background === 'default' ? 'primary' : 'primary-inverse',
96
+ withVisualDebug: debug,
97
+ height: height,
98
+ width: width,
99
+ maxHeight: maxHeight,
100
+ maxWidth: maxWidth,
101
+ minHeight: minHeight,
102
+ minWidth: minWidth,
103
+ padding: padding,
104
+ shadow: shadow,
105
+ textAlign: textAlign,
106
+ children: [_jsx("span", {
107
+ css: styles === null || styles === void 0 ? void 0 : styles.contextView__arrow
108
+ }), children]
109
+ })
110
+ });
111
+ }
112
+ }, _ContextView.displayName = "ContextView", _ContextView.componentId = 'ContextView', _ContextView.allowedProps = allowedProps, _ContextView.defaultProps = {
113
+ as: 'span',
114
+ elementRef: () => {},
115
+ debug: false,
116
+ width: 'auto',
117
+ height: 'auto',
118
+ children: null,
119
+ textAlign: 'start',
120
+ background: 'default',
121
+ shadow: 'above',
122
+ placement: 'center end'
123
+ }, _ContextView)) || _class);
124
+ export default ContextView;
125
+ export { ContextView };
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug', 'borderColor'];
26
+ export { allowedProps };
@@ -0,0 +1,256 @@
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 { mirrorPlacement } from '@instructure/ui-position';
26
+ const endPlacements = ['end center', 'end top', 'end bottom', 'end stretch', 'center end', 'end'];
27
+ const startPlacements = ['start center', 'start top', 'start bottom', 'start stretch', 'center start', 'start'];
28
+ const bottomPlacements = ['bottom', 'bottom end', 'bottom start', 'bottom stretch', 'bottom center'];
29
+ const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center'];
30
+ const getPlacementStyle = (placement, theme) => {
31
+ if (endPlacements.includes(placement)) {
32
+ return {
33
+ paddingInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
34
+ paddingInlineEnd: '0'
35
+ };
36
+ }
37
+ if (startPlacements.includes(placement)) {
38
+ return {
39
+ paddingInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
40
+ paddingInlineStart: '0'
41
+ };
42
+ }
43
+ if (bottomPlacements.includes(placement)) {
44
+ return {
45
+ paddingTop: theme === null || theme === void 0 ? void 0 : theme.arrowSize
46
+ };
47
+ }
48
+ if (topPlacements.includes(placement)) {
49
+ return {
50
+ paddingBottom: theme === null || theme === void 0 ? void 0 : theme.arrowSize
51
+ };
52
+ }
53
+ return {
54
+ position: 'absolute',
55
+ left: '-999em'
56
+ };
57
+ };
58
+ const getArrowCorrections = (placement, theme) => {
59
+ const center = ['top', 'bottom', 'top center', 'bottom center', 'top stretch', 'bottom stretch'];
60
+ const start = ['top start', 'bottom start'];
61
+ const end = ['top end', 'bottom end'];
62
+ const top = ['start top', 'end top'];
63
+ const bottom = ['start bottom', 'end bottom'];
64
+ if (center.includes(placement)) {
65
+ return {
66
+ insetInlineStart: '50%'
67
+ };
68
+ }
69
+ if (start.includes(placement)) {
70
+ return {
71
+ insetInlineStart: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
72
+ insetInlineEnd: 'auto'
73
+ };
74
+ }
75
+ if (end.includes(placement)) {
76
+ return {
77
+ insetInlineStart: `calc(100% - (${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 (top.includes(placement)) {
82
+ return {
83
+ top: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
84
+ };
85
+ }
86
+ if (bottom.includes(placement)) {
87
+ return {
88
+ top: `calc(100% - (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
89
+ };
90
+ }
91
+ return {};
92
+ };
93
+ const getArrowPlacementVariant = (placement, background, theme, props) => {
94
+ const transformedPlacement = mirrorPlacement(placement, ' ');
95
+ const isInversed = background === 'inverse';
96
+ const borderColor = props.borderColor;
97
+ if (endPlacements.includes(transformedPlacement)) {
98
+ return {
99
+ main: {
100
+ top: '50%',
101
+ insetInlineStart: '100%',
102
+ insetInlineEnd: 'auto',
103
+ marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
104
+ borderInlineEndWidth: '0',
105
+ borderInlineEndColor: 'transparent',
106
+ borderInlineStartColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
107
+ borderTopColor: 'transparent',
108
+ borderBottomColor: 'transparent',
109
+ borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
110
+ },
111
+ __after: {
112
+ insetInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
113
+ insetInlineStart: 'auto',
114
+ marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
115
+ borderInlineEndWidth: '0',
116
+ borderInlineEndColor: 'transparent',
117
+ borderTopColor: 'transparent',
118
+ borderBottomColor: 'transparent',
119
+ borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
120
+ borderInlineStartColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
121
+ }
122
+ };
123
+ }
124
+ if (startPlacements.includes(transformedPlacement)) {
125
+ return {
126
+ main: {
127
+ top: '50%',
128
+ insetInlineEnd: '100%',
129
+ insetInlineStart: 'auto',
130
+ marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
131
+ borderInlineStartWidth: '0',
132
+ borderInlineStartColor: 'transparent',
133
+ borderInlineEndColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
134
+ borderTopColor: 'transparent',
135
+ borderBottomColor: 'transparent',
136
+ borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
137
+ },
138
+ __after: {
139
+ insetInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
140
+ insetInlineEnd: 'auto',
141
+ marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
142
+ borderInlineStartWidth: '0',
143
+ borderInlineStartColor: 'transparent',
144
+ borderTopColor: 'transparent',
145
+ borderBottomColor: 'transparent',
146
+ borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
147
+ borderInlineEndColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
148
+ }
149
+ };
150
+ }
151
+ if (bottomPlacements.includes(transformedPlacement)) {
152
+ return {
153
+ main: {
154
+ top: '100%',
155
+ marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
156
+ marginInlineEnd: '0',
157
+ borderBottomWidth: '0',
158
+ borderBottomColor: 'transparent',
159
+ borderInlineStartColor: 'transparent',
160
+ borderInlineEndColor: 'transparent'
161
+ },
162
+ __after: {
163
+ bottom: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
164
+ marginInlineStart: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
165
+ marginInlineEnd: '0',
166
+ borderBottomWidth: '0',
167
+ borderBottomColor: 'transparent',
168
+ borderInlineStartColor: 'transparent',
169
+ borderInlineEndColor: 'transparent',
170
+ borderTopColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
171
+ }
172
+ };
173
+ }
174
+ return {
175
+ main: {
176
+ bottom: '100%',
177
+ marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
178
+ marginInlineEnd: '0',
179
+ borderTopWidth: '0',
180
+ borderTopColor: 'transparent',
181
+ borderInlineStartColor: 'transparent',
182
+ borderInlineEndColor: 'transparent'
183
+ },
184
+ __after: {
185
+ top: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
186
+ marginInlineStart: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
187
+ marginInlineEnd: '0',
188
+ borderTopWidth: '0',
189
+ borderTopColor: 'transparent',
190
+ borderInlineStartColor: 'transparent',
191
+ borderInlineEndColor: 'transparent',
192
+ borderBottomColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
193
+ }
194
+ };
195
+ };
196
+
197
+ /**
198
+ * ---
199
+ * private: true
200
+ * ---
201
+ * Generates the style object from the theme and provided additional information
202
+ * @param {Object} componentTheme The theme variable object.
203
+ * @param {Object} props the props of the component, the style is applied to
204
+ * @return {Object} The final style object, which will be used in the component
205
+ */
206
+ const generateStyle = (componentTheme, props) => {
207
+ const placement = props.placement,
208
+ background = props.background,
209
+ borderColor = props.borderColor;
210
+ const arrowBaseStyles = {
211
+ content: '""',
212
+ height: '0',
213
+ width: '0',
214
+ position: 'absolute',
215
+ display: 'block',
216
+ boxSizing: 'border-box',
217
+ pointerEvents: 'none',
218
+ borderStyle: 'solid'
219
+ };
220
+ const arrowBackGroundVariants = {
221
+ default: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColor,
222
+ inverse: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColorInverse
223
+ };
224
+ const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
225
+ return {
226
+ borderRadius: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.borderRadius,
227
+ contextView: {
228
+ label: 'contextView',
229
+ boxSizing: 'border-box',
230
+ minHeight: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} * 2)`,
231
+ ...getPlacementStyle(placement, componentTheme)
232
+ },
233
+ contextView__content: {
234
+ label: 'contextView__content',
235
+ position: 'relative'
236
+ },
237
+ contextView__arrow: {
238
+ label: 'contextView__arrow',
239
+ ...arrowBaseStyles,
240
+ display: 'block',
241
+ borderWidth: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} + ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderWidth})`,
242
+ borderColor: borderColor || arrowBackGroundVariants[background],
243
+ ...arrowPlacementVariant.main,
244
+ ...getArrowCorrections(placement, componentTheme),
245
+ '&::after': {
246
+ borderWidth: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize,
247
+ borderColor: arrowBackGroundVariants[background],
248
+ ...arrowPlacementVariant.__after,
249
+ ...arrowBaseStyles
250
+ }
251
+ },
252
+ arrowSize: componentTheme.arrowSize,
253
+ arrowBorderWidth: componentTheme.arrowBorderWidth
254
+ };
255
+ };
256
+ export default generateStyle;
@@ -30,7 +30,7 @@ import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils';
30
30
  import { textDirectionContextConsumer } from '@instructure/ui-i18n';
31
31
  import { logError as error } from '@instructure/console';
32
32
  import { getElementType, omitProps, pickProps, passthroughProps } from '@instructure/ui-react-utils';
33
- import { withStyle } from '@instructure/emotion';
33
+ import { withStyleLegacy as withStyle } from '@instructure/emotion';
34
34
  import generateStyle from "./styles.js";
35
35
  import generateComponentTheme from "./theme.js";
36
36
  import { allowedProps } from "./props.js";
@@ -0,0 +1,167 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ 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"];
3
+ var _dec, _dec2, _class, _View;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2015 - present Instructure, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ import { Component } from 'react';
29
+ import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils';
30
+ import { textDirectionContextConsumer } from '@instructure/ui-i18n';
31
+ import { logError as error } from '@instructure/console';
32
+ import { getElementType, omitProps, pickProps, passthroughProps } from '@instructure/ui-react-utils';
33
+ import { withStyle } from '@instructure/emotion';
34
+ import generateStyle from "./styles.js";
35
+ import { allowedProps } from "./props.js";
36
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
37
+ /**
38
+ ---
39
+ category: components
40
+ ---
41
+ @module View
42
+ **/
43
+ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = (_View = class View extends Component {
44
+ get _element() {
45
+ return this.ref;
46
+ }
47
+ constructor(props) {
48
+ super(props);
49
+ this.spanMarginVerified = void 0;
50
+ this.ref = null;
51
+ this.handleElementRef = el => {
52
+ if (typeof this.props.elementRef === 'function') {
53
+ this.props.elementRef(el);
54
+ }
55
+ this.ref = el;
56
+ };
57
+ this.spanMarginVerified = false;
58
+ }
59
+ componentDidMount() {
60
+ var _this$props$makeStyle, _this$props;
61
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
62
+ }
63
+ componentDidUpdate() {
64
+ var _this$props$makeStyle2, _this$props2;
65
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
66
+
67
+ // Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
68
+ if (process.env.NODE_ENV === 'development' && !this.spanMarginVerified) {
69
+ // We have to verify margins in the first 'componentDidUpdate',
70
+ // because that is when all styles are calculated,
71
+ // but we only want to check once, using a flag
72
+ this.spanMarginVerified = true;
73
+ error(!function verifySpanMargin(element, margin, _getCSSStyleDeclarati) {
74
+ if (!element) {
75
+ return;
76
+ }
77
+ const display = (_getCSSStyleDeclarati = getCSSStyleDeclaration(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : _getCSSStyleDeclarati.display;
78
+ if (display !== 'inline') {
79
+ return;
80
+ }
81
+ const marginValues = margin ? margin.split(' ') : null;
82
+ let verticalMargin = false;
83
+
84
+ // either top or bottom margin are set
85
+ if (margin) {
86
+ if (marginValues && marginValues[0] && marginValues[0] !== 'none' && marginValues[0] !== '0') {
87
+ verticalMargin = true;
88
+ }
89
+ if (marginValues && marginValues[2] && marginValues[2] !== 'none' && marginValues[2] !== '0') {
90
+ verticalMargin = true;
91
+ }
92
+ }
93
+ return verticalMargin;
94
+ }(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
95
+ }
96
+ }
97
+ render() {
98
+ const _this$props3 = this.props,
99
+ children = _this$props3.children,
100
+ textAlign = _this$props3.textAlign,
101
+ background = _this$props3.background,
102
+ display = _this$props3.display,
103
+ withVisualDebug = _this$props3.withVisualDebug,
104
+ width = _this$props3.width,
105
+ height = _this$props3.height,
106
+ minWidth = _this$props3.minWidth,
107
+ minHeight = _this$props3.minHeight,
108
+ maxWidth = _this$props3.maxWidth,
109
+ maxHeight = _this$props3.maxHeight,
110
+ overflowX = _this$props3.overflowX,
111
+ overflowY = _this$props3.overflowY,
112
+ stacking = _this$props3.stacking,
113
+ shadow = _this$props3.shadow,
114
+ position = _this$props3.position,
115
+ focusPosition = _this$props3.focusPosition,
116
+ focusColor = _this$props3.focusColor,
117
+ shouldAnimateFocus = _this$props3.shouldAnimateFocus,
118
+ borderColor = _this$props3.borderColor,
119
+ className = _this$props3.className,
120
+ overscrollBehavior = _this$props3.overscrollBehavior,
121
+ styles = _this$props3.styles,
122
+ makeStyles = _this$props3.makeStyles,
123
+ props = _objectWithoutProperties(_this$props3, _excluded);
124
+ const ElementType = getElementType(View, this.props);
125
+ return _jsx(ElementType, {
126
+ ...passthroughProps(props),
127
+ className: className,
128
+ css: [styles === null || styles === void 0 ? void 0 : styles.view, styles === null || styles === void 0 ? void 0 : styles.inlineStyles],
129
+ ref: this.handleElementRef,
130
+ children: children
131
+ });
132
+ }
133
+ }, _View.displayName = "View", _View.componentId = 'View', _View.allowedProps = allowedProps, _View.defaultProps = {
134
+ display: 'auto',
135
+ overflowX: 'visible',
136
+ overflowY: 'visible',
137
+ withVisualDebug: false,
138
+ borderColor: 'primary',
139
+ position: 'static',
140
+ focusPosition: 'offset',
141
+ focusColor: 'info',
142
+ shouldAnimateFocus: true,
143
+ overscrollBehavior: 'auto'
144
+ }, _View.omitViewProps = (props, Component) => {
145
+ // We don't want the theming and styling props to pass
146
+ // (these are added and handled by the `@withStyle` decorator)
147
+ const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
148
+ let shouldLogError = true;
149
+ try {
150
+ shouldLogError = process.env.NODE_ENV !== 'production' || process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true';
151
+ } catch (e) {
152
+ if (e instanceof ReferenceError) {
153
+ // if process is not available a ReferenceError is thrown
154
+ shouldLogError = false;
155
+ } else {
156
+ throw e;
157
+ }
158
+ }
159
+ if (shouldLogError) {
160
+ Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
161
+ error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
162
+ });
163
+ }
164
+ return omitProps(props, propsToOmit);
165
+ }, _View)) || _class) || _class);
166
+ export default View;
167
+ export { View };
@@ -0,0 +1,29 @@
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
+ // This variable will be attached as static property on the `View` component
26
+ // so we don't rely on the `PropTypes` validators for our internal logic.
27
+ // This means on prod builds the consuming applications can safely delete propTypes.
28
+ const 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'];
29
+ export { allowedProps };