@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,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
  *
@@ -40,42 +38,73 @@ category: components
40
38
  ---
41
39
  @module View
42
40
  **/
43
- let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = (_View = class View extends Component {
41
+ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = class View extends Component {
42
+ static displayName = "View";
43
+ static componentId = 'View';
44
+ static allowedProps = allowedProps;
45
+ static defaultProps = {
46
+ display: 'auto',
47
+ overflowX: 'visible',
48
+ overflowY: 'visible',
49
+ withVisualDebug: false,
50
+ borderColor: 'primary',
51
+ position: 'static',
52
+ focusPosition: 'offset',
53
+ focusColor: 'info',
54
+ shouldAnimateFocus: true,
55
+ overscrollBehavior: 'auto'
56
+ };
57
+
58
+ // TODO: Remove this code once all components are using passthroughProps in place
59
+ // of omitProps and have removed this function
60
+
61
+ // omitViewProps needs to be called on the composed View component so that the
62
+ // View.allowedProps in the method matches the View.allowedProps that will be called in
63
+ // the consumers. Otherwise the discrepancy could cause unexpected props being
64
+ // allowed through.
65
+
66
+ // Removes View's own props from the given object. Automatically excludes the
67
+ // following props: 'theme', 'children', 'className', 'style', 'styles',
68
+ // 'makeStyles', 'themeOverride'
69
+ // @param props the object to process
70
+ // @param Component The component whose props are processed.
71
+ // Only needed for debug logging in non-production builds.
72
+ static omitViewProps = (props, Component) => {
73
+ // We don't want the theming and styling props to pass
74
+ // (these are added and handled by the `@withStyle` decorator)
75
+ const propsToOmit = [...View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
76
+ if (typeof process !== 'undefined' && (process?.env?.GITHUB_PULL_REQUEST_PREVIEW === 'true' || process?.env?.NODE_ENV !== 'production')) {
77
+ Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
78
+ error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
79
+ });
80
+ }
81
+ return omitProps(props, propsToOmit);
82
+ };
83
+ spanMarginVerified;
44
84
  get _element() {
45
85
  return this.ref;
46
86
  }
47
87
  constructor(props) {
48
88
  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
89
  this.spanMarginVerified = false;
58
90
  }
59
91
  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);
92
+ this.props.makeStyles?.();
62
93
  }
63
94
  componentDidUpdate() {
64
- var _this$props$makeStyle2, _this$props2, _process, _process$env;
65
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
95
+ this.props.makeStyles?.();
66
96
 
67
97
  // Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
68
- 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) {
98
+ if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
69
99
  // We have to verify margins in the first 'componentDidUpdate',
70
100
  // because that is when all styles are calculated,
71
101
  // but we only want to check once, using a flag
72
102
  this.spanMarginVerified = true;
73
103
  error(!function verifySpanMargin(element, margin) {
74
- var _getCSSStyleDeclarati;
75
104
  if (!element) {
76
105
  return;
77
106
  }
78
- const display = (_getCSSStyleDeclarati = getCSSStyleDeclaration(element)) === null || _getCSSStyleDeclarati === void 0 ? void 0 : _getCSSStyleDeclarati.display;
107
+ const display = getCSSStyleDeclaration(element)?.display;
79
108
  if (display !== 'inline') {
80
109
  return;
81
110
  }
@@ -95,64 +124,50 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
95
124
  }(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
96
125
  }
97
126
  }
127
+ ref = null;
128
+ handleElementRef = el => {
129
+ if (typeof this.props.elementRef === 'function') {
130
+ this.props.elementRef(el);
131
+ }
132
+ this.ref = el;
133
+ };
98
134
  render() {
99
- const _this$props3 = this.props,
100
- children = _this$props3.children,
101
- textAlign = _this$props3.textAlign,
102
- background = _this$props3.background,
103
- display = _this$props3.display,
104
- withVisualDebug = _this$props3.withVisualDebug,
105
- width = _this$props3.width,
106
- height = _this$props3.height,
107
- minWidth = _this$props3.minWidth,
108
- minHeight = _this$props3.minHeight,
109
- maxWidth = _this$props3.maxWidth,
110
- maxHeight = _this$props3.maxHeight,
111
- overflowX = _this$props3.overflowX,
112
- overflowY = _this$props3.overflowY,
113
- stacking = _this$props3.stacking,
114
- shadow = _this$props3.shadow,
115
- position = _this$props3.position,
116
- focusPosition = _this$props3.focusPosition,
117
- focusColor = _this$props3.focusColor,
118
- shouldAnimateFocus = _this$props3.shouldAnimateFocus,
119
- borderColor = _this$props3.borderColor,
120
- className = _this$props3.className,
121
- overscrollBehavior = _this$props3.overscrollBehavior,
122
- styles = _this$props3.styles,
123
- makeStyles = _this$props3.makeStyles,
124
- props = _objectWithoutProperties(_this$props3, _excluded);
135
+ const {
136
+ children,
137
+ textAlign,
138
+ background,
139
+ display,
140
+ withVisualDebug,
141
+ width,
142
+ height,
143
+ minWidth,
144
+ minHeight,
145
+ maxWidth,
146
+ maxHeight,
147
+ overflowX,
148
+ overflowY,
149
+ stacking,
150
+ shadow,
151
+ position,
152
+ focusPosition,
153
+ focusColor,
154
+ shouldAnimateFocus,
155
+ borderColor,
156
+ className,
157
+ overscrollBehavior,
158
+ styles,
159
+ makeStyles,
160
+ ...props
161
+ } = this.props;
125
162
  const ElementType = getElementType(View, this.props);
126
163
  return _jsx(ElementType, {
127
164
  ...passthroughProps(props),
128
165
  className: className,
129
- css: [styles === null || styles === void 0 ? void 0 : styles.view, styles === null || styles === void 0 ? void 0 : styles.inlineStyles],
166
+ css: [styles?.view, styles?.inlineStyles],
130
167
  ref: this.handleElementRef,
131
168
  children: children
132
169
  });
133
170
  }
134
- }, _View.displayName = "View", _View.componentId = 'View', _View.allowedProps = allowedProps, _View.defaultProps = {
135
- display: 'auto',
136
- overflowX: 'visible',
137
- overflowY: 'visible',
138
- withVisualDebug: false,
139
- borderColor: 'primary',
140
- position: 'static',
141
- focusPosition: 'offset',
142
- focusColor: 'info',
143
- shouldAnimateFocus: true,
144
- overscrollBehavior: 'auto'
145
- }, _View.omitViewProps = (props, Component) => {
146
- var _process2, _process2$env, _process3, _process3$env;
147
- // We don't want the theming and styling props to pass
148
- // (these are added and handled by the `@withStyle` decorator)
149
- const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
150
- 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.GITHUB_PULL_REQUEST_PREVIEW) === 'true' || ((_process3 = process) === null || _process3 === void 0 ? void 0 : (_process3$env = _process3.env) === null || _process3$env === void 0 ? void 0 : _process3$env.NODE_ENV) !== 'production')) {
151
- Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
152
- error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
153
- });
154
- }
155
- return omitProps(props, propsToOmit);
156
- }, _View)) || _class) || _class);
171
+ }) || _class) || _class);
157
172
  export default View;
158
173
  export { View };
@@ -146,7 +146,9 @@ const getStyleProps = ({
146
146
  return whitelisted;
147
147
  };
148
148
  const withBorder = props => {
149
- const borderWidth = props.borderWidth;
149
+ const {
150
+ borderWidth
151
+ } = props;
150
152
  return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
151
153
  };
152
154
 
@@ -157,32 +159,34 @@ const withBorder = props => {
157
159
  * @return {Object} The final style object, which will be used in the component
158
160
  */
159
161
  const generateStyle = (componentTheme, props, sharedTokens) => {
160
- const borderRadius = props.borderRadius,
161
- borderWidth = props.borderWidth,
162
- margin = props.margin,
163
- padding = props.padding,
164
- position = props.position,
165
- display = props.display,
166
- textAlign = props.textAlign,
167
- borderColor = props.borderColor,
168
- background = props.background,
169
- stacking = props.stacking,
170
- shadow = props.shadow,
171
- overflowY = props.overflowY,
172
- overflowX = props.overflowX,
173
- overscrollBehavior = props.overscrollBehavior,
174
- insetBlockEnd = props.insetBlockEnd,
175
- insetBlockStart = props.insetBlockStart,
176
- insetInlineEnd = props.insetInlineEnd,
177
- insetInlineStart = props.insetInlineStart,
178
- width = props.width,
179
- height = props.height,
180
- minWidth = props.minWidth,
181
- minHeight = props.minHeight,
182
- maxWidth = props.maxWidth,
183
- maxHeight = props.maxHeight,
184
- withVisualDebug = props.withVisualDebug,
185
- dir = props.dir;
162
+ const {
163
+ borderRadius,
164
+ borderWidth,
165
+ margin,
166
+ padding,
167
+ position,
168
+ display,
169
+ textAlign,
170
+ borderColor,
171
+ background,
172
+ stacking,
173
+ shadow,
174
+ overflowY,
175
+ overflowX,
176
+ overscrollBehavior,
177
+ insetBlockEnd,
178
+ insetBlockStart,
179
+ insetInlineEnd,
180
+ insetInlineStart,
181
+ width,
182
+ height,
183
+ minWidth,
184
+ minHeight,
185
+ maxWidth,
186
+ maxHeight,
187
+ withVisualDebug,
188
+ dir
189
+ } = props;
186
190
  const borderStyle = getBorderStyle({
187
191
  sharedTokens,
188
192
  borderRadius,
@@ -360,11 +364,13 @@ const generateStyle = (componentTheme, props, sharedTokens) => {
360
364
  },
361
365
  none: {}
362
366
  };
363
- const focusColor = props.focusColor,
364
- focusPosition = props.focusPosition,
365
- shouldAnimateFocus = props.shouldAnimateFocus,
366
- withFocusOutline = props.withFocusOutline,
367
- focusWithin = props.focusWithin;
367
+ const {
368
+ focusColor,
369
+ focusPosition,
370
+ shouldAnimateFocus,
371
+ withFocusOutline,
372
+ focusWithin
373
+ } = props;
368
374
  const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline, {
369
375
  focusColor,
370
376
  focusPosition,
@@ -13,7 +13,7 @@ var _styles = _interopRequireDefault(require("./styles"));
13
13
  var _theme = _interopRequireDefault(require("./theme"));
14
14
  var _props = require("./props");
15
15
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
16
- var _dec, _class, _ContextView;
16
+ var _dec, _class;
17
17
  /*
18
18
  * The MIT License (MIT)
19
19
  *
@@ -42,49 +42,62 @@ var _dec, _class, _ContextView;
42
42
  category: components
43
43
  ---
44
44
  **/
45
- let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_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
- }
45
+ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class ContextView extends _react.Component {
46
+ static displayName = "ContextView";
47
+ static componentId = 'ContextView';
48
+ static allowedProps = _props.allowedProps;
49
+ static defaultProps = {
50
+ as: 'span',
51
+ elementRef: () => {},
52
+ debug: false,
53
+ width: 'auto',
54
+ height: 'auto',
55
+ children: null,
56
+ textAlign: 'start',
57
+ background: 'default',
58
+ shadow: 'resting',
59
+ placement: 'center end'
60
+ };
57
61
  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);
62
+ this.props.makeStyles?.();
60
63
  }
61
64
  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);
65
+ this.props.makeStyles?.();
64
66
  }
67
+ ref = null;
68
+ handleRef = el => {
69
+ const {
70
+ elementRef
71
+ } = this.props;
72
+ this.ref = el;
73
+ if (typeof elementRef === 'function') {
74
+ elementRef(el);
75
+ }
76
+ };
65
77
  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;
78
+ const {
79
+ as,
80
+ background,
81
+ children,
82
+ debug,
83
+ height,
84
+ width,
85
+ maxHeight,
86
+ maxWidth,
87
+ minHeight,
88
+ minWidth,
89
+ margin,
90
+ padding,
91
+ shadow,
92
+ stacking,
93
+ style,
94
+ textAlign,
95
+ styles,
96
+ borderColor
97
+ } = this.props;
85
98
  return (0, _jsxRuntime.jsx)(_v.View, {
86
99
  ...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
87
- css: styles === null || styles === void 0 ? void 0 : styles.contextView,
100
+ css: styles?.contextView,
88
101
  style: style,
89
102
  borderWidth: "none",
90
103
  display: "inline-block",
@@ -94,7 +107,7 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_s
94
107
  margin: margin,
95
108
  stacking: stacking,
96
109
  children: (0, _jsxRuntime.jsxs)(_v.View, {
97
- css: styles === null || styles === void 0 ? void 0 : styles.contextView__content,
110
+ css: styles?.contextView__content,
98
111
  display: "block",
99
112
  borderRadius: "medium",
100
113
  borderWidth: "small",
@@ -111,21 +124,10 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_s
111
124
  shadow: shadow,
112
125
  textAlign: textAlign,
113
126
  children: [(0, _jsxRuntime.jsx)("span", {
114
- css: styles === null || styles === void 0 ? void 0 : styles.contextView__arrow
127
+ css: styles?.contextView__arrow
115
128
  }), children]
116
129
  })
117
130
  });
118
131
  }
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);
132
+ }) || _class);
131
133
  var _default = exports.default = ContextView;