@instructure/ui-view 11.7.3-snapshot-7 → 11.7.3-snapshot-26

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.
@@ -1,3 +1,4 @@
1
+ import "core-js/modules/es.array.includes.js";
1
2
  /*
2
3
  * The MIT License (MIT)
3
4
  *
@@ -30,24 +31,24 @@ const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center
30
31
  const getPlacementStyle = (placement, theme) => {
31
32
  if (endPlacements.includes(placement)) {
32
33
  return {
33
- paddingInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
34
+ paddingInlineStart: theme?.arrowSize,
34
35
  paddingInlineEnd: '0'
35
36
  };
36
37
  }
37
38
  if (startPlacements.includes(placement)) {
38
39
  return {
39
- paddingInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
40
+ paddingInlineEnd: theme?.arrowSize,
40
41
  paddingInlineStart: '0'
41
42
  };
42
43
  }
43
44
  if (bottomPlacements.includes(placement)) {
44
45
  return {
45
- paddingTop: theme === null || theme === void 0 ? void 0 : theme.arrowSize
46
+ paddingTop: theme?.arrowSize
46
47
  };
47
48
  }
48
49
  if (topPlacements.includes(placement)) {
49
50
  return {
50
- paddingBottom: theme === null || theme === void 0 ? void 0 : theme.arrowSize
51
+ paddingBottom: theme?.arrowSize
51
52
  };
52
53
  }
53
54
  return {
@@ -68,24 +69,24 @@ const getArrowCorrections = (placement, theme) => {
68
69
  }
69
70
  if (start.includes(placement)) {
70
71
  return {
71
- insetInlineStart: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
72
+ insetInlineStart: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
72
73
  insetInlineEnd: 'auto'
73
74
  };
74
75
  }
75
76
  if (end.includes(placement)) {
76
77
  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
+ insetInlineStart: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
78
79
  insetInlineEnd: 'auto'
79
80
  };
80
81
  }
81
82
  if (top.includes(placement)) {
82
83
  return {
83
- top: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
84
+ top: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
84
85
  };
85
86
  }
86
87
  if (bottom.includes(placement)) {
87
88
  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
+ top: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
89
90
  };
90
91
  }
91
92
  return {};
@@ -93,31 +94,33 @@ const getArrowCorrections = (placement, theme) => {
93
94
  const getArrowPlacementVariant = (placement, background, theme, props) => {
94
95
  const transformedPlacement = mirrorPlacement(placement, ' ');
95
96
  const isInversed = background === 'inverse';
96
- const borderColor = props.borderColor;
97
+ const {
98
+ borderColor
99
+ } = props;
97
100
  if (endPlacements.includes(transformedPlacement)) {
98
101
  return {
99
102
  main: {
100
103
  top: '50%',
101
104
  insetInlineStart: '100%',
102
105
  insetInlineEnd: 'auto',
103
- marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
106
+ marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
104
107
  borderInlineEndWidth: '0',
105
108
  borderInlineEndColor: 'transparent',
106
- borderInlineStartColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
109
+ borderInlineStartColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
107
110
  borderTopColor: 'transparent',
108
111
  borderBottomColor: 'transparent',
109
- borderInlineStartWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
112
+ borderInlineStartWidth: theme?.arrowSize
110
113
  },
111
114
  __after: {
112
- insetInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
115
+ insetInlineEnd: theme?.arrowBorderWidth,
113
116
  insetInlineStart: 'auto',
114
- marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
117
+ marginTop: `calc(-1 * ${theme?.arrowSize})`,
115
118
  borderInlineEndWidth: '0',
116
119
  borderInlineEndColor: 'transparent',
117
120
  borderTopColor: 'transparent',
118
121
  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
122
+ borderInlineStartWidth: theme?.arrowSize,
123
+ borderInlineStartColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
121
124
  }
122
125
  };
123
126
  }
@@ -127,24 +130,24 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
127
130
  top: '50%',
128
131
  insetInlineEnd: '100%',
129
132
  insetInlineStart: 'auto',
130
- marginTop: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
133
+ marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
131
134
  borderInlineStartWidth: '0',
132
135
  borderInlineStartColor: 'transparent',
133
- borderInlineEndColor: borderColor || (isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBorderColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBorderColor),
136
+ borderInlineEndColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
134
137
  borderTopColor: 'transparent',
135
138
  borderBottomColor: 'transparent',
136
- borderInlineEndWidth: theme === null || theme === void 0 ? void 0 : theme.arrowSize
139
+ borderInlineEndWidth: theme?.arrowSize
137
140
  },
138
141
  __after: {
139
- insetInlineStart: theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth,
142
+ insetInlineStart: theme?.arrowBorderWidth,
140
143
  insetInlineEnd: 'auto',
141
- marginTop: `calc(-1 * ${theme === null || theme === void 0 ? void 0 : theme.arrowSize})`,
144
+ marginTop: `calc(-1 * ${theme?.arrowSize})`,
142
145
  borderInlineStartWidth: '0',
143
146
  borderInlineStartColor: 'transparent',
144
147
  borderTopColor: 'transparent',
145
148
  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
149
+ borderInlineEndWidth: theme?.arrowSize,
150
+ borderInlineEndColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
148
151
  }
149
152
  };
150
153
  }
@@ -152,7 +155,7 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
152
155
  return {
153
156
  main: {
154
157
  top: '100%',
155
- marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
158
+ marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
156
159
  marginInlineEnd: '0',
157
160
  borderBottomWidth: '0',
158
161
  borderBottomColor: 'transparent',
@@ -160,21 +163,21 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
160
163
  borderInlineEndColor: 'transparent'
161
164
  },
162
165
  __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})`,
166
+ bottom: theme?.arrowBorderWidth,
167
+ marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
165
168
  marginInlineEnd: '0',
166
169
  borderBottomWidth: '0',
167
170
  borderBottomColor: 'transparent',
168
171
  borderInlineStartColor: 'transparent',
169
172
  borderInlineEndColor: 'transparent',
170
- borderTopColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
173
+ borderTopColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
171
174
  }
172
175
  };
173
176
  }
174
177
  return {
175
178
  main: {
176
179
  bottom: '100%',
177
- marginInlineStart: `calc(-1 * (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}))`,
180
+ marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
178
181
  marginInlineEnd: '0',
179
182
  borderTopWidth: '0',
180
183
  borderTopColor: 'transparent',
@@ -182,14 +185,14 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
182
185
  borderInlineEndColor: 'transparent'
183
186
  },
184
187
  __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})`,
188
+ top: theme?.arrowBorderWidth,
189
+ marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
187
190
  marginInlineEnd: '0',
188
191
  borderTopWidth: '0',
189
192
  borderTopColor: 'transparent',
190
193
  borderInlineStartColor: 'transparent',
191
194
  borderInlineEndColor: 'transparent',
192
- borderBottomColor: isInversed ? theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColorInverse : theme === null || theme === void 0 ? void 0 : theme.arrowBackgroundColor
195
+ borderBottomColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
193
196
  }
194
197
  };
195
198
  };
@@ -204,9 +207,11 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
204
207
  * @return {Object} The final style object, which will be used in the component
205
208
  */
206
209
  const generateStyle = (componentTheme, props) => {
207
- const placement = props.placement,
208
- background = props.background,
209
- borderColor = props.borderColor;
210
+ const {
211
+ placement,
212
+ background,
213
+ borderColor
214
+ } = props;
210
215
  const arrowBaseStyles = {
211
216
  content: '""',
212
217
  height: '0',
@@ -218,16 +223,16 @@ const generateStyle = (componentTheme, props) => {
218
223
  borderStyle: 'solid'
219
224
  };
220
225
  const arrowBackGroundVariants = {
221
- default: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColor,
222
- inverse: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderColorInverse
226
+ default: componentTheme?.arrowBorderColor,
227
+ inverse: componentTheme?.arrowBorderColorInverse
223
228
  };
224
229
  const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
225
230
  return {
226
- borderRadius: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.borderRadius,
231
+ borderRadius: componentTheme?.borderRadius,
227
232
  contextView: {
228
233
  label: 'contextView',
229
234
  boxSizing: 'border-box',
230
- minHeight: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} * 2)`,
235
+ minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
231
236
  ...getPlacementStyle(placement, componentTheme)
232
237
  },
233
238
  contextView__content: {
@@ -238,12 +243,12 @@ const generateStyle = (componentTheme, props) => {
238
243
  label: 'contextView__arrow',
239
244
  ...arrowBaseStyles,
240
245
  display: 'block',
241
- borderWidth: `calc(${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize} + ${componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowBorderWidth})`,
246
+ borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
242
247
  borderColor: borderColor || arrowBackGroundVariants[background],
243
248
  ...arrowPlacementVariant.main,
244
249
  ...getArrowCorrections(placement, componentTheme),
245
250
  '&::after': {
246
- borderWidth: componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.arrowSize,
251
+ borderWidth: componentTheme?.arrowSize,
247
252
  borderColor: arrowBackGroundVariants[background],
248
253
  ...arrowPlacementVariant.__after,
249
254
  ...arrowBaseStyles
@@ -1,6 +1,4 @@
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;
1
+ var _dec, _dec2, _class;
4
2
  /*
5
3
  * The MIT License (MIT)
6
4
  *
@@ -41,42 +39,73 @@ category: components
41
39
  ---
42
40
  @module View
43
41
  **/
44
- let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_View = class View extends Component {
42
+ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class View extends Component {
43
+ static displayName = "View";
44
+ static componentId = 'View';
45
+ static allowedProps = allowedProps;
46
+ static defaultProps = {
47
+ display: 'auto',
48
+ overflowX: 'visible',
49
+ overflowY: 'visible',
50
+ withVisualDebug: false,
51
+ borderColor: 'primary',
52
+ position: 'static',
53
+ focusPosition: 'offset',
54
+ focusColor: 'info',
55
+ shouldAnimateFocus: true,
56
+ overscrollBehavior: 'auto'
57
+ };
58
+
59
+ // TODO: Remove this code once all components are using passthroughProps in place
60
+ // of omitProps and have removed this function
61
+
62
+ // omitViewProps needs to be called on the composed View component so that the
63
+ // View.allowedProps in the method matches the View.allowedProps that will be called in
64
+ // the consumers. Otherwise the discrepancy could cause unexpected props being
65
+ // allowed through.
66
+
67
+ // Removes View's own props from the given object. Automatically excludes the
68
+ // following props: 'theme', 'children', 'className', 'style', 'styles',
69
+ // 'makeStyles', 'themeOverride'
70
+ // @param props the object to process
71
+ // @param Component The component whose props are processed.
72
+ // Only needed for debug logging in non-production builds.
73
+ static omitViewProps = (props, Component) => {
74
+ // We don't want the theming and styling props to pass
75
+ // (these are added and handled by the `@withStyle` decorator)
76
+ const propsToOmit = [...View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
77
+ if (typeof process !== 'undefined' && process?.env?.NODE_ENV !== 'production') {
78
+ Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
79
+ error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
80
+ });
81
+ }
82
+ return omitProps(props, propsToOmit);
83
+ };
84
+ spanMarginVerified;
45
85
  get _element() {
46
86
  return this.ref;
47
87
  }
48
88
  constructor(props) {
49
89
  super(props);
50
- this.spanMarginVerified = void 0;
51
- this.ref = null;
52
- this.handleElementRef = el => {
53
- if (typeof this.props.elementRef === 'function') {
54
- this.props.elementRef(el);
55
- }
56
- this.ref = el;
57
- };
58
90
  this.spanMarginVerified = false;
59
91
  }
60
92
  componentDidMount() {
61
- var _this$props$makeStyle, _this$props;
62
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
93
+ this.props.makeStyles?.();
63
94
  }
64
95
  componentDidUpdate() {
65
- var _this$props$makeStyle2, _this$props2, _process, _process$env;
66
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
96
+ this.props.makeStyles?.();
67
97
 
68
98
  // Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
69
- if (typeof process !== 'undefined' && ((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'development' && !this.spanMarginVerified) {
99
+ if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
70
100
  // We have to verify margins in the first 'componentDidUpdate',
71
101
  // because that is when all styles are calculated,
72
102
  // but we only want to check once, using a flag
73
103
  this.spanMarginVerified = true;
74
104
  error(!function verifySpanMargin(element, margin) {
75
- var _getCSSStyleDeclarati;
76
105
  if (!element) {
77
106
  return;
78
107
  }
79
- const display = (_getCSSStyleDeclarati = getCSSStyleDeclaration(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : _getCSSStyleDeclarati.display;
108
+ const display = getCSSStyleDeclaration(element)?.display;
80
109
  if (display !== 'inline') {
81
110
  return;
82
111
  }
@@ -96,64 +125,50 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
96
125
  }(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
97
126
  }
98
127
  }
128
+ ref = null;
129
+ handleElementRef = el => {
130
+ if (typeof this.props.elementRef === 'function') {
131
+ this.props.elementRef(el);
132
+ }
133
+ this.ref = el;
134
+ };
99
135
  render() {
100
- const _this$props3 = this.props,
101
- children = _this$props3.children,
102
- textAlign = _this$props3.textAlign,
103
- background = _this$props3.background,
104
- display = _this$props3.display,
105
- withVisualDebug = _this$props3.withVisualDebug,
106
- width = _this$props3.width,
107
- height = _this$props3.height,
108
- minWidth = _this$props3.minWidth,
109
- minHeight = _this$props3.minHeight,
110
- maxWidth = _this$props3.maxWidth,
111
- maxHeight = _this$props3.maxHeight,
112
- overflowX = _this$props3.overflowX,
113
- overflowY = _this$props3.overflowY,
114
- stacking = _this$props3.stacking,
115
- shadow = _this$props3.shadow,
116
- position = _this$props3.position,
117
- focusPosition = _this$props3.focusPosition,
118
- focusColor = _this$props3.focusColor,
119
- shouldAnimateFocus = _this$props3.shouldAnimateFocus,
120
- borderColor = _this$props3.borderColor,
121
- className = _this$props3.className,
122
- overscrollBehavior = _this$props3.overscrollBehavior,
123
- styles = _this$props3.styles,
124
- makeStyles = _this$props3.makeStyles,
125
- props = _objectWithoutProperties(_this$props3, _excluded);
136
+ const {
137
+ children,
138
+ textAlign,
139
+ background,
140
+ display,
141
+ withVisualDebug,
142
+ width,
143
+ height,
144
+ minWidth,
145
+ minHeight,
146
+ maxWidth,
147
+ maxHeight,
148
+ overflowX,
149
+ overflowY,
150
+ stacking,
151
+ shadow,
152
+ position,
153
+ focusPosition,
154
+ focusColor,
155
+ shouldAnimateFocus,
156
+ borderColor,
157
+ className,
158
+ overscrollBehavior,
159
+ styles,
160
+ makeStyles,
161
+ ...props
162
+ } = this.props;
126
163
  const ElementType = getElementType(View, this.props);
127
164
  return _jsx(ElementType, {
128
165
  ...passthroughProps(props),
129
166
  className: className,
130
- css: [styles === null || styles === void 0 ? void 0 : styles.view, styles === null || styles === void 0 ? void 0 : styles.inlineStyles],
167
+ css: [styles?.view, styles?.inlineStyles],
131
168
  ref: this.handleElementRef,
132
169
  children: children
133
170
  });
134
171
  }
135
- }, _View.displayName = "View", _View.componentId = 'View', _View.allowedProps = allowedProps, _View.defaultProps = {
136
- display: 'auto',
137
- overflowX: 'visible',
138
- overflowY: 'visible',
139
- withVisualDebug: false,
140
- borderColor: 'primary',
141
- position: 'static',
142
- focusPosition: 'offset',
143
- focusColor: 'info',
144
- shouldAnimateFocus: true,
145
- overscrollBehavior: 'auto'
146
- }, _View.omitViewProps = (props, Component) => {
147
- var _process2, _process2$env;
148
- // We don't want the theming and styling props to pass
149
- // (these are added and handled by the `@withStyle` decorator)
150
- const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
151
- if (typeof process !== 'undefined' && ((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.NODE_ENV) !== 'production') {
152
- Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
153
- error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
154
- });
155
- }
156
- return omitProps(props, propsToOmit);
157
- }, _View)) || _class) || _class);
172
+ }) || _class) || _class);
158
173
  export default View;
159
174
  export { View };
@@ -97,15 +97,19 @@ const getStyleProps = ({
97
97
  return whitelisted;
98
98
  };
99
99
  const withBorder = props => {
100
- const borderWidth = props.borderWidth;
100
+ const {
101
+ borderWidth
102
+ } = props;
101
103
  return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
102
104
  };
103
105
  const getFocusStyles = (props, componentTheme) => {
104
- const focusColor = props.focusColor,
105
- focusPosition = props.focusPosition,
106
- shouldAnimateFocus = props.shouldAnimateFocus,
107
- withFocusOutline = props.withFocusOutline,
108
- focusWithin = props.focusWithin;
106
+ const {
107
+ focusColor,
108
+ focusPosition,
109
+ shouldAnimateFocus,
110
+ withFocusOutline,
111
+ focusWithin
112
+ } = props;
109
113
  const focusPos = focusPosition == 'offset' || focusPosition == 'inset' ? focusPosition : 'offset';
110
114
  const focusPositionVariants = {
111
115
  offset: {
@@ -159,32 +163,34 @@ const getFocusStyles = (props, componentTheme) => {
159
163
  * @return {Object} The final style object, which will be used in the component
160
164
  */
161
165
  const generateStyle = (componentTheme, props) => {
162
- const borderRadius = props.borderRadius,
163
- borderWidth = props.borderWidth,
164
- margin = props.margin,
165
- padding = props.padding,
166
- position = props.position,
167
- display = props.display,
168
- textAlign = props.textAlign,
169
- borderColor = props.borderColor,
170
- background = props.background,
171
- stacking = props.stacking,
172
- shadow = props.shadow,
173
- overflowY = props.overflowY,
174
- overflowX = props.overflowX,
175
- overscrollBehavior = props.overscrollBehavior,
176
- insetBlockEnd = props.insetBlockEnd,
177
- insetBlockStart = props.insetBlockStart,
178
- insetInlineEnd = props.insetInlineEnd,
179
- insetInlineStart = props.insetInlineStart,
180
- width = props.width,
181
- height = props.height,
182
- minWidth = props.minWidth,
183
- minHeight = props.minHeight,
184
- maxWidth = props.maxWidth,
185
- maxHeight = props.maxHeight,
186
- withVisualDebug = props.withVisualDebug,
187
- dir = props.dir;
166
+ const {
167
+ borderRadius,
168
+ borderWidth,
169
+ margin,
170
+ padding,
171
+ position,
172
+ display,
173
+ textAlign,
174
+ borderColor,
175
+ background,
176
+ stacking,
177
+ shadow,
178
+ overflowY,
179
+ overflowX,
180
+ overscrollBehavior,
181
+ insetBlockEnd,
182
+ insetBlockStart,
183
+ insetInlineEnd,
184
+ insetInlineStart,
185
+ width,
186
+ height,
187
+ minWidth,
188
+ minHeight,
189
+ maxWidth,
190
+ maxHeight,
191
+ withVisualDebug,
192
+ dir
193
+ } = props;
188
194
  const borderStyle = getBorderStyle({
189
195
  theme: componentTheme,
190
196
  borderRadius,
@@ -31,15 +31,16 @@ import { makeThemeVars } from '@instructure/emotion';
31
31
  * @return {Object} The final theme object with the overrides and component variables
32
32
  */
33
33
  const generateComponentTheme = theme => {
34
- 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;
35
- const colors = theme.colors,
36
- typography = theme.typography,
37
- borders = theme.borders,
38
- breakpoints = theme.breakpoints,
39
- spacing = theme.spacing,
40
- shadows = theme.shadows,
41
- stacking = theme.stacking,
42
- themeName = theme.key;
34
+ const {
35
+ colors,
36
+ typography,
37
+ borders,
38
+ breakpoints,
39
+ spacing,
40
+ shadows,
41
+ stacking,
42
+ key: themeName
43
+ } = theme;
43
44
  const themeSpecificStyle = {
44
45
  canvas: {
45
46
  color: theme['ic-brand-font-color-dark'],
@@ -51,43 +52,43 @@ const generateComponentTheme = theme => {
51
52
  }
52
53
  };
53
54
  const componentVariables = {
54
- fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
55
- color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey125125,
56
- colorPrimaryInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.white1010,
57
- borderColorPrimary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.grey1424,
58
- borderColorSecondary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.grey3045,
59
- borderColorSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.green4570,
60
- borderColorBrand: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.blue4570,
61
- borderColorInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.blue4570,
62
- borderColorAlert: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.blue4570,
63
- borderColorWarning: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.orange4570,
64
- borderColorDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.red4570,
55
+ fontFamily: typography?.fontFamily,
56
+ color: colors?.contrasts?.grey125125,
57
+ colorPrimaryInverse: colors?.contrasts?.white1010,
58
+ borderColorPrimary: colors?.contrasts?.grey1424,
59
+ borderColorSecondary: colors?.contrasts?.grey3045,
60
+ borderColorSuccess: colors?.contrasts?.green4570,
61
+ borderColorBrand: colors?.contrasts?.blue4570,
62
+ borderColorInfo: colors?.contrasts?.blue4570,
63
+ borderColorAlert: colors?.contrasts?.blue4570,
64
+ borderColorWarning: colors?.contrasts?.orange4570,
65
+ borderColorDanger: colors?.contrasts?.red4570,
65
66
  borderColorTransparent: 'transparent',
66
- debugOutlineColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.red4570,
67
- backgroundPrimary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts10 = colors.contrasts) === null || _colors$contrasts10 === void 0 ? void 0 : _colors$contrasts10.white1010,
68
- backgroundSecondary: colors === null || colors === void 0 ? void 0 : (_colors$contrasts11 = colors.contrasts) === null || _colors$contrasts11 === void 0 ? void 0 : _colors$contrasts11.grey1111,
69
- backgroundPrimaryInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts12 = colors.contrasts) === null || _colors$contrasts12 === void 0 ? void 0 : _colors$contrasts12.grey125125,
70
- backgroundBrand: colors === null || colors === void 0 ? void 0 : (_colors$contrasts13 = colors.contrasts) === null || _colors$contrasts13 === void 0 ? void 0 : _colors$contrasts13.blue4570,
71
- backgroundInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts14 = colors.contrasts) === null || _colors$contrasts14 === void 0 ? void 0 : _colors$contrasts14.blue4570,
72
- backgroundAlert: colors === null || colors === void 0 ? void 0 : (_colors$contrasts15 = colors.contrasts) === null || _colors$contrasts15 === void 0 ? void 0 : _colors$contrasts15.blue4570,
73
- backgroundSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts16 = colors.contrasts) === null || _colors$contrasts16 === void 0 ? void 0 : _colors$contrasts16.green4570,
74
- backgroundDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts17 = colors.contrasts) === null || _colors$contrasts17 === void 0 ? void 0 : _colors$contrasts17.red4570,
75
- backgroundWarning: colors === null || colors === void 0 ? void 0 : (_colors$contrasts18 = colors.contrasts) === null || _colors$contrasts18 === void 0 ? void 0 : _colors$contrasts18.orange4570,
67
+ debugOutlineColor: colors?.contrasts?.red4570,
68
+ backgroundPrimary: colors?.contrasts?.white1010,
69
+ backgroundSecondary: colors?.contrasts?.grey1111,
70
+ backgroundPrimaryInverse: colors?.contrasts?.grey125125,
71
+ backgroundBrand: colors?.contrasts?.blue4570,
72
+ backgroundInfo: colors?.contrasts?.blue4570,
73
+ backgroundAlert: colors?.contrasts?.blue4570,
74
+ backgroundSuccess: colors?.contrasts?.green4570,
75
+ backgroundDanger: colors?.contrasts?.red4570,
76
+ backgroundWarning: colors?.contrasts?.orange4570,
76
77
  arrowSize: '0.5rem',
77
- focusOutlineStyle: borders === null || borders === void 0 ? void 0 : borders.style,
78
- focusOutlineWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
78
+ focusOutlineStyle: borders?.style,
79
+ focusOutlineWidth: borders?.widthMedium,
79
80
  focusOutlineOffset: '0.3125rem',
80
81
  focusOutlineInset: '0rem',
81
82
  // do not use unitless zero (for CSS calc())
82
83
 
83
- focusColorInfo: colors === null || colors === void 0 ? void 0 : (_colors$contrasts19 = colors.contrasts) === null || _colors$contrasts19 === void 0 ? void 0 : _colors$contrasts19.blue4570,
84
- focusColorDanger: colors === null || colors === void 0 ? void 0 : (_colors$contrasts20 = colors.contrasts) === null || _colors$contrasts20 === void 0 ? void 0 : _colors$contrasts20.red4570,
85
- focusColorSuccess: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.green4570,
86
- focusColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts22 = colors.contrasts) === null || _colors$contrasts22 === void 0 ? void 0 : _colors$contrasts22.white1010,
87
- xSmallMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.xSmall,
88
- smallMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.small,
89
- mediumMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.medium,
90
- largeMaxWidth: breakpoints === null || breakpoints === void 0 ? void 0 : breakpoints.large,
84
+ focusColorInfo: colors?.contrasts?.blue4570,
85
+ focusColorDanger: colors?.contrasts?.red4570,
86
+ focusColorSuccess: colors?.contrasts?.green4570,
87
+ focusColorInverse: colors?.contrasts?.white1010,
88
+ xSmallMaxWidth: breakpoints?.xSmall,
89
+ smallMaxWidth: breakpoints?.small,
90
+ mediumMaxWidth: breakpoints?.medium,
91
+ largeMaxWidth: breakpoints?.large,
91
92
  ...makeThemeVars('margin', spacing),
92
93
  ...makeThemeVars('padding', spacing),
93
94
  ...makeThemeVars('shadow', shadows),