@instructure/ui-flex 8.12.1-snapshot.56 → 8.13.1-snapshot.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/es/Flex/Item/index.js +19 -15
- package/es/Flex/Item/props.js +0 -59
- package/es/Flex/Item/styles.js +1 -1
- package/es/Flex/index.js +24 -20
- package/es/Flex/props.js +0 -62
- package/lib/Flex/Item/index.js +19 -15
- package/lib/Flex/Item/props.js +0 -59
- package/lib/Flex/Item/styles.js +1 -1
- package/lib/Flex/index.js +26 -20
- package/lib/Flex/props.js +0 -62
- package/package.json +10 -10
- package/src/Flex/Item/index.tsx +3 -6
- package/src/Flex/Item/props.ts +54 -41
- package/src/Flex/Item/styles.ts +1 -2
- package/src/Flex/index.tsx +14 -15
- package/src/Flex/props.ts +66 -50
- package/types/Flex/Item/index.d.ts +1 -1
- package/types/Flex/Item/index.d.ts.map +1 -1
- package/types/Flex/Item/props.d.ts +46 -0
- package/types/Flex/Item/props.d.ts.map +1 -1
- package/types/Flex/Item/styles.d.ts +1 -1
- package/types/Flex/Item/styles.d.ts.map +1 -1
- package/types/Flex/index.d.ts +8 -19
- package/types/Flex/index.d.ts.map +1 -1
- package/types/Flex/props.d.ts +53 -2
- package/types/Flex/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-flex
|
|
9
|
+
|
|
6
10
|
# [8.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-flex
|
package/es/Flex/Item/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
37
37
|
parent: Flex
|
|
38
38
|
id: Flex.Item
|
|
39
39
|
---
|
|
40
|
+
@tsProps
|
|
40
41
|
**/
|
|
41
42
|
let Item = (_dec = withStyle(generateStyle, null), _dec(_class = (_temp = _class2 = class Item extends Component {
|
|
42
43
|
constructor() {
|
|
@@ -54,27 +55,31 @@ let Item = (_dec = withStyle(generateStyle, null), _dec(_class = (_temp = _class
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
componentDidMount() {
|
|
57
|
-
|
|
58
|
+
var _this$props$makeStyle, _this$props;
|
|
59
|
+
|
|
60
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
componentDidUpdate() {
|
|
61
|
-
|
|
64
|
+
var _this$props$makeStyle2, _this$props2;
|
|
65
|
+
|
|
66
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
render() {
|
|
65
70
|
const props = omitProps(this.props, Item.allowedProps);
|
|
66
|
-
const _this$
|
|
67
|
-
as = _this$
|
|
68
|
-
children = _this$
|
|
69
|
-
withVisualDebug = _this$
|
|
70
|
-
textAlign = _this$
|
|
71
|
-
size = _this$
|
|
72
|
-
direction = _this$
|
|
73
|
-
margin = _this$
|
|
74
|
-
padding = _this$
|
|
75
|
-
overflowX = _this$
|
|
76
|
-
overflowY = _this$
|
|
77
|
-
styles = _this$
|
|
71
|
+
const _this$props3 = this.props,
|
|
72
|
+
as = _this$props3.as,
|
|
73
|
+
children = _this$props3.children,
|
|
74
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
75
|
+
textAlign = _this$props3.textAlign,
|
|
76
|
+
size = _this$props3.size,
|
|
77
|
+
direction = _this$props3.direction,
|
|
78
|
+
margin = _this$props3.margin,
|
|
79
|
+
padding = _this$props3.padding,
|
|
80
|
+
overflowX = _this$props3.overflowX,
|
|
81
|
+
overflowY = _this$props3.overflowY,
|
|
82
|
+
styles = _this$props3.styles;
|
|
78
83
|
const dirColumn = direction === 'column';
|
|
79
84
|
const dirRow = direction === 'row';
|
|
80
85
|
return jsx(View, Object.assign({}, props, {
|
|
@@ -94,7 +99,6 @@ let Item = (_dec = withStyle(generateStyle, null), _dec(_class = (_temp = _class
|
|
|
94
99
|
|
|
95
100
|
}, _class2.displayName = "Item", _class2.componentId = 'Flex.Item', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
96
101
|
as: 'span',
|
|
97
|
-
elementRef: el => {},
|
|
98
102
|
shouldGrow: false,
|
|
99
103
|
shouldShrink: false
|
|
100
104
|
}, _temp)) || _class);
|
package/es/Flex/Item/props.js
CHANGED
|
@@ -24,78 +24,19 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* The children to render inside the Item`
|
|
29
|
-
*/
|
|
30
27
|
children: PropTypes.node,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* the element type to render as
|
|
34
|
-
*/
|
|
35
28
|
as: PropTypes.elementType,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* provides a reference to the underlying html root element
|
|
39
|
-
*/
|
|
40
29
|
elementRef: PropTypes.func,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
44
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
45
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
46
|
-
*/
|
|
47
30
|
margin: ThemeablePropTypes.spacing,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
51
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
52
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
53
|
-
*/
|
|
54
31
|
padding: ThemeablePropTypes.spacing,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* overrides the parent Flex's alignItems prop, if needed
|
|
58
|
-
*/
|
|
59
32
|
align: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Inherits from the parent Flex component
|
|
63
|
-
*/
|
|
64
33
|
direction: PropTypes.oneOf(['row', 'column']),
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Designates the text alignment inside the Item
|
|
68
|
-
*/
|
|
69
34
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Handles horizontal overflow
|
|
73
|
-
*/
|
|
74
35
|
overflowX: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Handles vertical overflow
|
|
78
|
-
*/
|
|
79
36
|
overflowY: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Should the FlexItem grow to fill any available space?
|
|
83
|
-
*/
|
|
84
37
|
shouldGrow: PropTypes.bool,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Should the FlexItem shrink (stopping at its `size`)?
|
|
88
|
-
*/
|
|
89
38
|
shouldShrink: PropTypes.bool,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Sets the base size of the FlexItem (width if direction is `row`; height if direction is `column`)
|
|
93
|
-
*/
|
|
94
39
|
size: PropTypes.string,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Places dashed lines around the component's borders to help debug your layout
|
|
98
|
-
*/
|
|
99
40
|
withVisualDebug: PropTypes.bool
|
|
100
41
|
};
|
|
101
42
|
const allowedProps = ['children', 'as', 'elementRef', 'margin', 'padding', 'align', 'direction', 'textAlign', 'overflowX', 'overflowY', 'shouldGrow', 'shouldShrink', 'size', 'withVisualDebug'];
|
package/es/Flex/Item/styles.js
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* @param {Object} state the state of the component, the style is applied to
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
|
-
const generateStyle = (
|
|
35
|
+
const generateStyle = (_componentTheme, props) => {
|
|
36
36
|
const shouldGrow = props.shouldGrow,
|
|
37
37
|
shouldShrink = props.shouldShrink,
|
|
38
38
|
align = props.align,
|
package/es/Flex/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _class, _class2, _temp;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import { Children, Component } from 'react';
|
|
28
|
+
import React, { Children, Component } from 'react';
|
|
29
29
|
import { safeCloneElement, passthroughProps, matchComponentTypes, callRenderProp } from '@instructure/ui-react-utils';
|
|
30
30
|
import { View } from '@instructure/ui-view';
|
|
31
31
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
@@ -39,10 +39,11 @@ import { propTypes, allowedProps } from './props';
|
|
|
39
39
|
category: components
|
|
40
40
|
---
|
|
41
41
|
@module Flex
|
|
42
|
+
@tsProps
|
|
42
43
|
**/
|
|
43
44
|
let Flex = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = class Flex extends Component {
|
|
44
|
-
constructor(
|
|
45
|
-
super(
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...arguments);
|
|
46
47
|
this.ref = null;
|
|
47
48
|
|
|
48
49
|
this.handleRef = el => {
|
|
@@ -53,12 +54,18 @@ let Flex = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
53
54
|
elementRef(el);
|
|
54
55
|
}
|
|
55
56
|
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentDidMount() {
|
|
60
|
+
var _this$props$makeStyle, _this$props;
|
|
56
61
|
|
|
57
|
-
props.makeStyles();
|
|
62
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
componentDidUpdate() {
|
|
61
|
-
|
|
66
|
+
var _this$props$makeStyle2, _this$props2;
|
|
67
|
+
|
|
68
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
renderChildren(children) {
|
|
@@ -68,26 +75,25 @@ let Flex = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
return matchComponentTypes(child, ['Item']) ? safeCloneElement(child, {
|
|
78
|
+
// child withVisualDebug prop should override parent
|
|
71
79
|
withVisualDebug: this.props.withVisualDebug,
|
|
72
|
-
...child.props
|
|
73
|
-
/* child withVisualDebug prop should override parent */
|
|
74
|
-
,
|
|
80
|
+
...child.props,
|
|
75
81
|
direction: this.props.direction.replace(/-reverse/, '')
|
|
76
82
|
}) : child;
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
render() {
|
|
81
|
-
const _this$
|
|
82
|
-
as = _this$
|
|
83
|
-
withVisualDebug = _this$
|
|
84
|
-
height = _this$
|
|
85
|
-
display = _this$
|
|
86
|
-
margin = _this$
|
|
87
|
-
padding = _this$
|
|
88
|
-
textAlign = _this$
|
|
89
|
-
width = _this$
|
|
90
|
-
styles = _this$
|
|
87
|
+
const _this$props3 = this.props,
|
|
88
|
+
as = _this$props3.as,
|
|
89
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
90
|
+
height = _this$props3.height,
|
|
91
|
+
display = _this$props3.display,
|
|
92
|
+
margin = _this$props3.margin,
|
|
93
|
+
padding = _this$props3.padding,
|
|
94
|
+
textAlign = _this$props3.textAlign,
|
|
95
|
+
width = _this$props3.width,
|
|
96
|
+
styles = _this$props3.styles;
|
|
91
97
|
const children = callRenderProp(this.props.children);
|
|
92
98
|
|
|
93
99
|
if (children && Children.count(children) > 0) {
|
|
@@ -109,9 +115,7 @@ let Flex = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class
|
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
}, _class2.displayName = "Flex", _class2.componentId = 'Flex', _class2.Item = Item, _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
112
|
-
children: null,
|
|
113
118
|
as: 'span',
|
|
114
|
-
elementRef: el => {},
|
|
115
119
|
direction: 'row',
|
|
116
120
|
justifyItems: 'start',
|
|
117
121
|
display: 'flex',
|
package/es/Flex/props.js
CHANGED
|
@@ -24,81 +24,19 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* It's recommended that you use `Flex.Item` for children, but you can also pass any markup or a function
|
|
29
|
-
* returning markup. Note that if you do not use `Flex.Item`, the `withVisualDebug` and `direction` props
|
|
30
|
-
* will not automatically be set on the children.
|
|
31
|
-
*/
|
|
32
27
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* the element type to render as
|
|
36
|
-
*/
|
|
37
28
|
as: PropTypes.elementType,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* provides a reference to the underlying html root element
|
|
41
|
-
*/
|
|
42
29
|
elementRef: PropTypes.func,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Sets the height of the component's container (optional)
|
|
46
|
-
*/
|
|
47
30
|
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Sets the width of the component's container (optional)
|
|
51
|
-
*/
|
|
52
31
|
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
56
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
57
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
58
|
-
*/
|
|
59
32
|
margin: ThemeablePropTypes.spacing,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
63
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
64
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
65
|
-
*/
|
|
66
33
|
padding: ThemeablePropTypes.spacing,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Sets the CSS display rule for the component's container
|
|
70
|
-
*/
|
|
71
34
|
display: PropTypes.oneOf(['flex', 'inline-flex']),
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Designates the text alignment
|
|
75
|
-
*/
|
|
76
35
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Sets the flex-direction to row (horizontal) or column (vertical)
|
|
80
|
-
*/
|
|
81
36
|
direction: PropTypes.oneOf(['row', 'column', 'row-reverse', 'column-reverse']),
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Aligns Flex.Items on the vertical axis (horizontal if direction is column)
|
|
85
|
-
*/
|
|
86
37
|
alignItems: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Aligns Flex.Items on the horizontal axis (vertical if direction is column)
|
|
90
|
-
*/
|
|
91
38
|
justifyItems: PropTypes.oneOf(['center', 'start', 'end', 'space-around', 'space-between']),
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Determines if the Flex.Items should wrap when they exceed their container's width
|
|
95
|
-
*/
|
|
96
39
|
wrap: PropTypes.oneOf(['wrap', 'no-wrap', 'wrap-reverse']),
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Activate a dotted outline around the component to make building your
|
|
100
|
-
* layout easier
|
|
101
|
-
*/
|
|
102
40
|
withVisualDebug: PropTypes.bool
|
|
103
41
|
};
|
|
104
42
|
const allowedProps = ['children', 'as', 'elementRef', 'height', 'width', 'margin', 'padding', 'display', 'textAlign', 'direction', 'alignItems', 'justifyItems', 'wrap', 'withVisualDebug'];
|
package/lib/Flex/Item/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var _dec, _class, _class2, _temp;
|
|
|
26
26
|
parent: Flex
|
|
27
27
|
id: Flex.Item
|
|
28
28
|
---
|
|
29
|
+
@tsProps
|
|
29
30
|
**/
|
|
30
31
|
let Item = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class = (_temp = _class2 = class Item extends _react.Component {
|
|
31
32
|
constructor() {
|
|
@@ -43,27 +44,31 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class =
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
componentDidMount() {
|
|
46
|
-
|
|
47
|
+
var _this$props$makeStyle, _this$props;
|
|
48
|
+
|
|
49
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
componentDidUpdate() {
|
|
50
|
-
|
|
53
|
+
var _this$props$makeStyle2, _this$props2;
|
|
54
|
+
|
|
55
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
render() {
|
|
54
59
|
const props = (0, _omitProps.omitProps)(this.props, Item.allowedProps);
|
|
55
|
-
const _this$
|
|
56
|
-
as = _this$
|
|
57
|
-
children = _this$
|
|
58
|
-
withVisualDebug = _this$
|
|
59
|
-
textAlign = _this$
|
|
60
|
-
size = _this$
|
|
61
|
-
direction = _this$
|
|
62
|
-
margin = _this$
|
|
63
|
-
padding = _this$
|
|
64
|
-
overflowX = _this$
|
|
65
|
-
overflowY = _this$
|
|
66
|
-
styles = _this$
|
|
60
|
+
const _this$props3 = this.props,
|
|
61
|
+
as = _this$props3.as,
|
|
62
|
+
children = _this$props3.children,
|
|
63
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
64
|
+
textAlign = _this$props3.textAlign,
|
|
65
|
+
size = _this$props3.size,
|
|
66
|
+
direction = _this$props3.direction,
|
|
67
|
+
margin = _this$props3.margin,
|
|
68
|
+
padding = _this$props3.padding,
|
|
69
|
+
overflowX = _this$props3.overflowX,
|
|
70
|
+
overflowY = _this$props3.overflowY,
|
|
71
|
+
styles = _this$props3.styles;
|
|
67
72
|
const dirColumn = direction === 'column';
|
|
68
73
|
const dirRow = direction === 'row';
|
|
69
74
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, props, {
|
|
@@ -83,7 +88,6 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class =
|
|
|
83
88
|
|
|
84
89
|
}, _class2.displayName = "Item", _class2.componentId = 'Flex.Item', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
85
90
|
as: 'span',
|
|
86
|
-
elementRef: el => {},
|
|
87
91
|
shouldGrow: false,
|
|
88
92
|
shouldShrink: false
|
|
89
93
|
}, _temp)) || _class);
|
package/lib/Flex/Item/props.js
CHANGED
|
@@ -35,78 +35,19 @@ var _emotion = require("@instructure/emotion");
|
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*/
|
|
37
37
|
const propTypes = {
|
|
38
|
-
/**
|
|
39
|
-
* The children to render inside the Item`
|
|
40
|
-
*/
|
|
41
38
|
children: _propTypes.default.node,
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* the element type to render as
|
|
45
|
-
*/
|
|
46
39
|
as: _propTypes.default.elementType,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* provides a reference to the underlying html root element
|
|
50
|
-
*/
|
|
51
40
|
elementRef: _propTypes.default.func,
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
55
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
56
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
57
|
-
*/
|
|
58
41
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
62
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
63
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
64
|
-
*/
|
|
65
42
|
padding: _emotion.ThemeablePropTypes.spacing,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* overrides the parent Flex's alignItems prop, if needed
|
|
69
|
-
*/
|
|
70
43
|
align: _propTypes.default.oneOf(['center', 'start', 'end', 'stretch']),
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Inherits from the parent Flex component
|
|
74
|
-
*/
|
|
75
44
|
direction: _propTypes.default.oneOf(['row', 'column']),
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Designates the text alignment inside the Item
|
|
79
|
-
*/
|
|
80
45
|
textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Handles horizontal overflow
|
|
84
|
-
*/
|
|
85
46
|
overflowX: _propTypes.default.oneOf(['auto', 'hidden', 'visible']),
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Handles vertical overflow
|
|
89
|
-
*/
|
|
90
47
|
overflowY: _propTypes.default.oneOf(['auto', 'hidden', 'visible']),
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Should the FlexItem grow to fill any available space?
|
|
94
|
-
*/
|
|
95
48
|
shouldGrow: _propTypes.default.bool,
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Should the FlexItem shrink (stopping at its `size`)?
|
|
99
|
-
*/
|
|
100
49
|
shouldShrink: _propTypes.default.bool,
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Sets the base size of the FlexItem (width if direction is `row`; height if direction is `column`)
|
|
104
|
-
*/
|
|
105
50
|
size: _propTypes.default.string,
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Places dashed lines around the component's borders to help debug your layout
|
|
109
|
-
*/
|
|
110
51
|
withVisualDebug: _propTypes.default.bool
|
|
111
52
|
};
|
|
112
53
|
exports.propTypes = propTypes;
|
package/lib/Flex/Item/styles.js
CHANGED
|
@@ -39,7 +39,7 @@ exports.default = void 0;
|
|
|
39
39
|
* @param {Object} state the state of the component, the style is applied to
|
|
40
40
|
* @return {Object} The final style object, which will be used in the component
|
|
41
41
|
*/
|
|
42
|
-
const generateStyle = (
|
|
42
|
+
const generateStyle = (_componentTheme, props) => {
|
|
43
43
|
const shouldGrow = props.shouldGrow,
|
|
44
44
|
shouldShrink = props.shouldShrink,
|
|
45
45
|
align = props.align,
|
package/lib/Flex/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
3
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -14,7 +16,7 @@ Object.defineProperty(exports, "FlexItem", {
|
|
|
14
16
|
});
|
|
15
17
|
exports.default = void 0;
|
|
16
18
|
|
|
17
|
-
var _react = require("react");
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
18
20
|
|
|
19
21
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
20
22
|
|
|
@@ -43,10 +45,11 @@ var _dec, _class, _class2, _temp;
|
|
|
43
45
|
category: components
|
|
44
46
|
---
|
|
45
47
|
@module Flex
|
|
48
|
+
@tsProps
|
|
46
49
|
**/
|
|
47
50
|
let Flex = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = class Flex extends _react.Component {
|
|
48
|
-
constructor(
|
|
49
|
-
super(
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
50
53
|
this.ref = null;
|
|
51
54
|
|
|
52
55
|
this.handleRef = el => {
|
|
@@ -57,12 +60,18 @@ let Flex = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
57
60
|
elementRef(el);
|
|
58
61
|
}
|
|
59
62
|
};
|
|
63
|
+
}
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
var _this$props$makeStyle, _this$props;
|
|
67
|
+
|
|
68
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
componentDidUpdate() {
|
|
65
|
-
|
|
72
|
+
var _this$props$makeStyle2, _this$props2;
|
|
73
|
+
|
|
74
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
renderChildren(children) {
|
|
@@ -72,26 +81,25 @@ let Flex = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
return (0, _matchComponentTypes.matchComponentTypes)(child, ['Item']) ? (0, _safeCloneElement.safeCloneElement)(child, {
|
|
84
|
+
// child withVisualDebug prop should override parent
|
|
75
85
|
withVisualDebug: this.props.withVisualDebug,
|
|
76
|
-
...child.props
|
|
77
|
-
/* child withVisualDebug prop should override parent */
|
|
78
|
-
,
|
|
86
|
+
...child.props,
|
|
79
87
|
direction: this.props.direction.replace(/-reverse/, '')
|
|
80
88
|
}) : child;
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
render() {
|
|
85
|
-
const _this$
|
|
86
|
-
as = _this$
|
|
87
|
-
withVisualDebug = _this$
|
|
88
|
-
height = _this$
|
|
89
|
-
display = _this$
|
|
90
|
-
margin = _this$
|
|
91
|
-
padding = _this$
|
|
92
|
-
textAlign = _this$
|
|
93
|
-
width = _this$
|
|
94
|
-
styles = _this$
|
|
93
|
+
const _this$props3 = this.props,
|
|
94
|
+
as = _this$props3.as,
|
|
95
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
96
|
+
height = _this$props3.height,
|
|
97
|
+
display = _this$props3.display,
|
|
98
|
+
margin = _this$props3.margin,
|
|
99
|
+
padding = _this$props3.padding,
|
|
100
|
+
textAlign = _this$props3.textAlign,
|
|
101
|
+
width = _this$props3.width,
|
|
102
|
+
styles = _this$props3.styles;
|
|
95
103
|
const children = (0, _callRenderProp.callRenderProp)(this.props.children);
|
|
96
104
|
|
|
97
105
|
if (children && _react.Children.count(children) > 0) {
|
|
@@ -113,9 +121,7 @@ let Flex = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
}, _class2.displayName = "Flex", _class2.componentId = 'Flex', _class2.Item = _Item.Item, _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
116
|
-
children: null,
|
|
117
124
|
as: 'span',
|
|
118
|
-
elementRef: el => {},
|
|
119
125
|
direction: 'row',
|
|
120
126
|
justifyItems: 'start',
|
|
121
127
|
display: 'flex',
|
package/lib/Flex/props.js
CHANGED
|
@@ -35,81 +35,19 @@ var _emotion = require("@instructure/emotion");
|
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*/
|
|
37
37
|
const propTypes = {
|
|
38
|
-
/**
|
|
39
|
-
* It's recommended that you use `Flex.Item` for children, but you can also pass any markup or a function
|
|
40
|
-
* returning markup. Note that if you do not use `Flex.Item`, the `withVisualDebug` and `direction` props
|
|
41
|
-
* will not automatically be set on the children.
|
|
42
|
-
*/
|
|
43
38
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* the element type to render as
|
|
47
|
-
*/
|
|
48
39
|
as: _propTypes.default.elementType,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* provides a reference to the underlying html root element
|
|
52
|
-
*/
|
|
53
40
|
elementRef: _propTypes.default.func,
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Sets the height of the component's container (optional)
|
|
57
|
-
*/
|
|
58
41
|
height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Sets the width of the component's container (optional)
|
|
62
|
-
*/
|
|
63
42
|
width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
67
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
68
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
69
|
-
*/
|
|
70
43
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
74
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
75
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
76
|
-
*/
|
|
77
44
|
padding: _emotion.ThemeablePropTypes.spacing,
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Sets the CSS display rule for the component's container
|
|
81
|
-
*/
|
|
82
45
|
display: _propTypes.default.oneOf(['flex', 'inline-flex']),
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Designates the text alignment
|
|
86
|
-
*/
|
|
87
46
|
textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Sets the flex-direction to row (horizontal) or column (vertical)
|
|
91
|
-
*/
|
|
92
47
|
direction: _propTypes.default.oneOf(['row', 'column', 'row-reverse', 'column-reverse']),
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Aligns Flex.Items on the vertical axis (horizontal if direction is column)
|
|
96
|
-
*/
|
|
97
48
|
alignItems: _propTypes.default.oneOf(['center', 'start', 'end', 'stretch']),
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Aligns Flex.Items on the horizontal axis (vertical if direction is column)
|
|
101
|
-
*/
|
|
102
49
|
justifyItems: _propTypes.default.oneOf(['center', 'start', 'end', 'space-around', 'space-between']),
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Determines if the Flex.Items should wrap when they exceed their container's width
|
|
106
|
-
*/
|
|
107
50
|
wrap: _propTypes.default.oneOf(['wrap', 'no-wrap', 'wrap-reverse']),
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Activate a dotted outline around the component to make building your
|
|
111
|
-
* layout easier
|
|
112
|
-
*/
|
|
113
51
|
withVisualDebug: _propTypes.default.bool
|
|
114
52
|
};
|
|
115
53
|
exports.propTypes = propTypes;
|