@instructure/ui-flex 8.8.1-snapshot.8 → 8.9.1
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 +10 -0
- package/es/Flex/Item/index.js +4 -85
- package/es/Flex/Item/props.js +102 -0
- package/es/Flex/index.js +5 -92
- package/es/Flex/props.js +105 -0
- package/lib/Flex/Item/index.js +4 -85
- package/lib/Flex/Item/props.js +114 -0
- package/lib/Flex/index.js +5 -92
- package/lib/Flex/props.js +117 -0
- package/package.json +10 -11
- package/src/Flex/Item/index.tsx +7 -73
- package/src/Flex/Item/props.ts +137 -0
- package/src/Flex/Item/styles.ts +1 -1
- package/src/Flex/__examples__/Flex.examples.tsx +1 -1
- package/src/Flex/index.tsx +8 -93
- package/src/Flex/props.ts +150 -0
- package/src/Flex/styles.ts +1 -1
- package/src/index.ts +2 -2
- package/types/Flex/Item/index.d.ts +33 -66
- package/types/Flex/Item/index.d.ts.map +1 -1
- package/types/Flex/Item/props.d.ts +27 -0
- package/types/Flex/Item/props.d.ts.map +1 -0
- package/types/Flex/Item/styles.d.ts +1 -1
- package/types/Flex/__examples__/Flex.examples.d.ts +1 -1
- package/types/Flex/index.d.ts +33 -75
- package/types/Flex/index.d.ts.map +1 -1
- package/types/Flex/props.d.ts +27 -0
- package/types/Flex/props.d.ts.map +1 -0
- package/types/Flex/styles.d.ts +1 -1
- package/types/index.d.ts +2 -2
- package/LICENSE.md +0 -27
- package/es/Flex/Item/types.js +0 -1
- package/es/Flex/types.js +0 -1
- package/lib/Flex/Item/types.js +0 -1
- package/lib/Flex/types.js +0 -1
- package/src/Flex/Item/types.ts +0 -44
- package/src/Flex/types.ts +0 -45
- package/types/Flex/Item/types.d.ts +0 -20
- package/types/Flex/Item/types.d.ts.map +0 -1
- package/types/Flex/types.d.ts +0 -21
- package/types/Flex/types.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-flex",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.1",
|
|
4
4
|
"description": "A component that makes it easy to align content using flexbox CSS",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/console": "8.
|
|
29
|
-
"@instructure/emotion": "8.
|
|
30
|
-
"@instructure/shared-types": "8.
|
|
31
|
-
"@instructure/ui-react-utils": "8.
|
|
32
|
-
"@instructure/ui-view": "8.
|
|
28
|
+
"@instructure/console": "8.9.1",
|
|
29
|
+
"@instructure/emotion": "8.9.1",
|
|
30
|
+
"@instructure/shared-types": "8.9.1",
|
|
31
|
+
"@instructure/ui-react-utils": "8.9.1",
|
|
32
|
+
"@instructure/ui-view": "8.9.1",
|
|
33
33
|
"prop-types": "^15"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@instructure/ui-babel-preset": "8.
|
|
37
|
-
"@instructure/ui-test-utils": "8.
|
|
38
|
-
"@instructure/ui-themes": "8.
|
|
36
|
+
"@instructure/ui-babel-preset": "8.9.1",
|
|
37
|
+
"@instructure/ui-test-utils": "8.9.1",
|
|
38
|
+
"@instructure/ui-themes": "8.9.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=16.8 <=17"
|
|
@@ -43,6 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"sideEffects": false
|
|
47
|
-
"gitHead": "7b83164f4c5872f3a217e010563f59bf584ae4fc"
|
|
46
|
+
"sideEffects": false
|
|
48
47
|
}
|
package/src/Flex/Item/index.tsx
CHANGED
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
30
29
|
import { View } from '@instructure/ui-view'
|
|
31
|
-
import { withStyle, jsx
|
|
30
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
32
31
|
|
|
33
32
|
import generateStyle from './styles'
|
|
34
|
-
|
|
33
|
+
|
|
34
|
+
import { propTypes, allowedProps } from './props'
|
|
35
|
+
import type { FlexItemProps } from './props'
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
---
|
|
@@ -53,75 +54,8 @@ class Item extends Component<FlexItemProps> {
|
|
|
53
54
|
this.props.makeStyles()
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
static
|
|
58
|
-
// eslint-disable-next-line react/require-default-props
|
|
59
|
-
makeStyles: PropTypes.func,
|
|
60
|
-
// eslint-disable-next-line react/require-default-props
|
|
61
|
-
styles: PropTypes.object,
|
|
62
|
-
/**
|
|
63
|
-
* The children to render inside the Item`
|
|
64
|
-
*/
|
|
65
|
-
children: PropTypes.node,
|
|
66
|
-
/**
|
|
67
|
-
* the element type to render as
|
|
68
|
-
*/
|
|
69
|
-
as: PropTypes.elementType,
|
|
70
|
-
/**
|
|
71
|
-
* provides a reference to the underlying html root element
|
|
72
|
-
*/
|
|
73
|
-
elementRef: PropTypes.func,
|
|
74
|
-
/**
|
|
75
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
76
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
77
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
78
|
-
*/
|
|
79
|
-
margin: ThemeablePropTypes.spacing,
|
|
80
|
-
/**
|
|
81
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
82
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
83
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
84
|
-
*/
|
|
85
|
-
padding: ThemeablePropTypes.spacing,
|
|
86
|
-
/**
|
|
87
|
-
* overrides the parent Flex's alignItems prop, if needed
|
|
88
|
-
*/
|
|
89
|
-
align: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
90
|
-
/**
|
|
91
|
-
* Inherits from the parent Flex component
|
|
92
|
-
*/
|
|
93
|
-
direction: PropTypes.oneOf(['row', 'column']),
|
|
94
|
-
/**
|
|
95
|
-
* Designates the text alignment inside the Item
|
|
96
|
-
*/
|
|
97
|
-
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
98
|
-
/**
|
|
99
|
-
* Handles horizontal overflow
|
|
100
|
-
*/
|
|
101
|
-
overflowX: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
102
|
-
/**
|
|
103
|
-
* Handles vertical overflow
|
|
104
|
-
*/
|
|
105
|
-
overflowY: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
106
|
-
/**
|
|
107
|
-
* Should the FlexItem grow to fill any available space?
|
|
108
|
-
*/
|
|
109
|
-
shouldGrow: PropTypes.bool,
|
|
110
|
-
/**
|
|
111
|
-
* Should the FlexItem shrink (stopping at its `size`)?
|
|
112
|
-
*/
|
|
113
|
-
shouldShrink: PropTypes.bool,
|
|
114
|
-
/**
|
|
115
|
-
* Sets the base size of the FlexItem (width if direction is `row`; height if direction is `column`)
|
|
116
|
-
*/
|
|
117
|
-
size: PropTypes.string,
|
|
118
|
-
/**
|
|
119
|
-
* Places dashed lines around the component's borders to help debug your layout
|
|
120
|
-
*/
|
|
121
|
-
withVisualDebug: PropTypes.bool
|
|
122
|
-
}
|
|
123
|
-
/* eslint-enable react/require-default-props */
|
|
124
|
-
|
|
57
|
+
static propTypes = propTypes
|
|
58
|
+
static allowedProps = allowedProps
|
|
125
59
|
static defaultProps = {
|
|
126
60
|
as: 'span',
|
|
127
61
|
// @ts-expect-error ts-migrate(6133) FIXME: 'el' is declared but its value is never read.
|
|
@@ -154,7 +88,7 @@ class Item extends Component<FlexItemProps> {
|
|
|
154
88
|
return (
|
|
155
89
|
<View
|
|
156
90
|
{...props}
|
|
157
|
-
css={styles
|
|
91
|
+
css={styles?.flexItem}
|
|
158
92
|
elementRef={elementRef}
|
|
159
93
|
as={as}
|
|
160
94
|
minHeight={dirColumn ? size : undefined}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
31
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
32
|
+
|
|
33
|
+
type FlexItemOwnProps = {
|
|
34
|
+
children?: React.ReactNode
|
|
35
|
+
as?: AsElementType
|
|
36
|
+
elementRef?: (...args: any[]) => any
|
|
37
|
+
margin?: Spacing
|
|
38
|
+
padding?: Spacing
|
|
39
|
+
align?: 'center' | 'start' | 'end' | 'stretch'
|
|
40
|
+
direction?: 'row' | 'column'
|
|
41
|
+
textAlign?: 'start' | 'center' | 'end'
|
|
42
|
+
overflowX?: 'auto' | 'hidden' | 'visible'
|
|
43
|
+
overflowY?: 'auto' | 'hidden' | 'visible'
|
|
44
|
+
shouldGrow?: boolean
|
|
45
|
+
shouldShrink?: boolean
|
|
46
|
+
size?: string
|
|
47
|
+
withVisualDebug?: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type PropKeys = keyof FlexItemOwnProps
|
|
51
|
+
|
|
52
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
53
|
+
|
|
54
|
+
type FlexItemProps = FlexItemOwnProps & WithStyleProps
|
|
55
|
+
|
|
56
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
57
|
+
/**
|
|
58
|
+
* The children to render inside the Item`
|
|
59
|
+
*/
|
|
60
|
+
children: PropTypes.node,
|
|
61
|
+
/**
|
|
62
|
+
* the element type to render as
|
|
63
|
+
*/
|
|
64
|
+
as: PropTypes.elementType,
|
|
65
|
+
/**
|
|
66
|
+
* provides a reference to the underlying html root element
|
|
67
|
+
*/
|
|
68
|
+
elementRef: PropTypes.func,
|
|
69
|
+
/**
|
|
70
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
73
|
+
*/
|
|
74
|
+
margin: ThemeablePropTypes.spacing,
|
|
75
|
+
/**
|
|
76
|
+
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
77
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
78
|
+
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
79
|
+
*/
|
|
80
|
+
padding: ThemeablePropTypes.spacing,
|
|
81
|
+
/**
|
|
82
|
+
* overrides the parent Flex's alignItems prop, if needed
|
|
83
|
+
*/
|
|
84
|
+
align: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
85
|
+
/**
|
|
86
|
+
* Inherits from the parent Flex component
|
|
87
|
+
*/
|
|
88
|
+
direction: PropTypes.oneOf(['row', 'column']),
|
|
89
|
+
/**
|
|
90
|
+
* Designates the text alignment inside the Item
|
|
91
|
+
*/
|
|
92
|
+
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
93
|
+
/**
|
|
94
|
+
* Handles horizontal overflow
|
|
95
|
+
*/
|
|
96
|
+
overflowX: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
97
|
+
/**
|
|
98
|
+
* Handles vertical overflow
|
|
99
|
+
*/
|
|
100
|
+
overflowY: PropTypes.oneOf(['auto', 'hidden', 'visible']),
|
|
101
|
+
/**
|
|
102
|
+
* Should the FlexItem grow to fill any available space?
|
|
103
|
+
*/
|
|
104
|
+
shouldGrow: PropTypes.bool,
|
|
105
|
+
/**
|
|
106
|
+
* Should the FlexItem shrink (stopping at its `size`)?
|
|
107
|
+
*/
|
|
108
|
+
shouldShrink: PropTypes.bool,
|
|
109
|
+
/**
|
|
110
|
+
* Sets the base size of the FlexItem (width if direction is `row`; height if direction is `column`)
|
|
111
|
+
*/
|
|
112
|
+
size: PropTypes.string,
|
|
113
|
+
/**
|
|
114
|
+
* Places dashed lines around the component's borders to help debug your layout
|
|
115
|
+
*/
|
|
116
|
+
withVisualDebug: PropTypes.bool
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const allowedProps: AllowedPropKeys = [
|
|
120
|
+
'children',
|
|
121
|
+
'as',
|
|
122
|
+
'elementRef',
|
|
123
|
+
'margin',
|
|
124
|
+
'padding',
|
|
125
|
+
'align',
|
|
126
|
+
'direction',
|
|
127
|
+
'textAlign',
|
|
128
|
+
'overflowX',
|
|
129
|
+
'overflowY',
|
|
130
|
+
'shouldGrow',
|
|
131
|
+
'shouldShrink',
|
|
132
|
+
'size',
|
|
133
|
+
'withVisualDebug'
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
export type { FlexItemProps }
|
|
137
|
+
export { propTypes, allowedProps }
|
package/src/Flex/Item/styles.ts
CHANGED
package/src/Flex/index.tsx
CHANGED
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Children, Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import {
|
|
30
29
|
safeCloneElement,
|
|
@@ -33,13 +32,15 @@ import {
|
|
|
33
32
|
callRenderProp
|
|
34
33
|
} from '@instructure/ui-react-utils'
|
|
35
34
|
import { View } from '@instructure/ui-view'
|
|
36
|
-
import { withStyle, jsx
|
|
35
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
37
36
|
|
|
38
37
|
import { Item } from './Item'
|
|
39
38
|
|
|
40
39
|
import generateStyle from './styles'
|
|
41
40
|
import generateComponentTheme from './theme'
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
import { propTypes, allowedProps } from './props'
|
|
43
|
+
import type { FlexProps } from './props'
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
---
|
|
@@ -64,88 +65,8 @@ class Flex extends Component<FlexProps> {
|
|
|
64
65
|
|
|
65
66
|
static Item = Item
|
|
66
67
|
|
|
67
|
-
static propTypes =
|
|
68
|
-
|
|
69
|
-
* It's recommended that you use `Flex.Item` for children, but you can also pass any markup or a function
|
|
70
|
-
* returning markup. Note that if you do not use `Flex.Item`, the `withVisualDebug` and `direction` props
|
|
71
|
-
* will not automatically be set on the children.
|
|
72
|
-
*/
|
|
73
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
74
|
-
/**
|
|
75
|
-
* the element type to render as
|
|
76
|
-
*/
|
|
77
|
-
as: PropTypes.elementType,
|
|
78
|
-
/**
|
|
79
|
-
* provides a reference to the underlying html root element
|
|
80
|
-
*/
|
|
81
|
-
elementRef: PropTypes.func,
|
|
82
|
-
/**
|
|
83
|
-
* Sets the height of the component's container (optional)
|
|
84
|
-
*/
|
|
85
|
-
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
86
|
-
/**
|
|
87
|
-
* Sets the width of the component's container (optional)
|
|
88
|
-
*/
|
|
89
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
90
|
-
/**
|
|
91
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
92
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
93
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
94
|
-
*/
|
|
95
|
-
margin: ThemeablePropTypes.spacing,
|
|
96
|
-
/**
|
|
97
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
98
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
99
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
100
|
-
*/
|
|
101
|
-
padding: ThemeablePropTypes.spacing,
|
|
102
|
-
/**
|
|
103
|
-
* Sets the CSS display rule for the component's container
|
|
104
|
-
*/
|
|
105
|
-
display: PropTypes.oneOf(['flex', 'inline-flex']),
|
|
106
|
-
/**
|
|
107
|
-
* Designates the text alignment
|
|
108
|
-
*/
|
|
109
|
-
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
110
|
-
/**
|
|
111
|
-
* Sets the flex-direction to row (horizontal) or column (vertical)
|
|
112
|
-
*/
|
|
113
|
-
direction: PropTypes.oneOf([
|
|
114
|
-
'row',
|
|
115
|
-
'column',
|
|
116
|
-
'row-reverse',
|
|
117
|
-
'column-reverse'
|
|
118
|
-
]),
|
|
119
|
-
/**
|
|
120
|
-
* Aligns Flex.Items on the vertical axis (horizontal if direction is column)
|
|
121
|
-
*/
|
|
122
|
-
alignItems: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
123
|
-
/**
|
|
124
|
-
* Aligns Flex.Items on the horizontal axis (vertical if direction is column)
|
|
125
|
-
*/
|
|
126
|
-
justifyItems: PropTypes.oneOf([
|
|
127
|
-
'center',
|
|
128
|
-
'start',
|
|
129
|
-
'end',
|
|
130
|
-
'space-around',
|
|
131
|
-
'space-between'
|
|
132
|
-
]),
|
|
133
|
-
/**
|
|
134
|
-
* Determines if the Flex.Items should wrap when they exceed their container's width
|
|
135
|
-
*/
|
|
136
|
-
wrap: PropTypes.oneOf(['wrap', 'no-wrap', 'wrap-reverse']),
|
|
137
|
-
/**
|
|
138
|
-
* Activate a dotted outline around the component to make building your
|
|
139
|
-
* layout easier
|
|
140
|
-
*/
|
|
141
|
-
withVisualDebug: PropTypes.bool,
|
|
142
|
-
|
|
143
|
-
// eslint-disable-next-line react/require-default-props
|
|
144
|
-
makeStyles: PropTypes.func,
|
|
145
|
-
// eslint-disable-next-line react/require-default-props
|
|
146
|
-
styles: PropTypes.object
|
|
147
|
-
}
|
|
148
|
-
|
|
68
|
+
static propTypes = propTypes
|
|
69
|
+
static allowedProps = allowedProps
|
|
149
70
|
static defaultProps = {
|
|
150
71
|
children: null,
|
|
151
72
|
as: 'span',
|
|
@@ -155,13 +76,7 @@ class Flex extends Component<FlexProps> {
|
|
|
155
76
|
justifyItems: 'start',
|
|
156
77
|
display: 'flex',
|
|
157
78
|
withVisualDebug: false,
|
|
158
|
-
wrap: 'no-wrap'
|
|
159
|
-
width: undefined,
|
|
160
|
-
height: undefined,
|
|
161
|
-
padding: undefined,
|
|
162
|
-
margin: undefined,
|
|
163
|
-
alignItems: undefined,
|
|
164
|
-
textAlign: undefined
|
|
79
|
+
wrap: 'no-wrap'
|
|
165
80
|
}
|
|
166
81
|
|
|
167
82
|
renderChildren(children: any) {
|
|
@@ -201,7 +116,7 @@ class Flex extends Component<FlexProps> {
|
|
|
201
116
|
return (
|
|
202
117
|
<View
|
|
203
118
|
{...passthroughProps(this.props)}
|
|
204
|
-
css={styles
|
|
119
|
+
css={styles?.flex}
|
|
205
120
|
elementRef={elementRef}
|
|
206
121
|
as={as}
|
|
207
122
|
display={display}
|
|
@@ -0,0 +1,150 @@
|
|
|
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 PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
28
|
+
|
|
29
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
30
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
type FlexOwnProps = {
|
|
33
|
+
children?: React.ReactNode | ((...args: any[]) => React.ReactNode)
|
|
34
|
+
as?: AsElementType
|
|
35
|
+
elementRef?: (...args: any[]) => any
|
|
36
|
+
height?: string | number
|
|
37
|
+
width?: string | number
|
|
38
|
+
margin?: Spacing
|
|
39
|
+
padding?: Spacing
|
|
40
|
+
display?: 'flex' | 'inline-flex'
|
|
41
|
+
textAlign?: 'start' | 'center' | 'end'
|
|
42
|
+
direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
|
|
43
|
+
alignItems?: 'center' | 'start' | 'end' | 'stretch'
|
|
44
|
+
justifyItems?: 'center' | 'start' | 'end' | 'space-around' | 'space-between'
|
|
45
|
+
wrap?: 'wrap' | 'no-wrap' | 'wrap-reverse'
|
|
46
|
+
withVisualDebug?: boolean
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type PropKeys = keyof FlexOwnProps
|
|
50
|
+
|
|
51
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
52
|
+
|
|
53
|
+
type FlexProps = FlexOwnProps & WithStyleProps
|
|
54
|
+
|
|
55
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
56
|
+
/**
|
|
57
|
+
* It's recommended that you use `Flex.Item` for children, but you can also pass any markup or a function
|
|
58
|
+
* returning markup. Note that if you do not use `Flex.Item`, the `withVisualDebug` and `direction` props
|
|
59
|
+
* will not automatically be set on the children.
|
|
60
|
+
*/
|
|
61
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
62
|
+
/**
|
|
63
|
+
* the element type to render as
|
|
64
|
+
*/
|
|
65
|
+
as: PropTypes.elementType,
|
|
66
|
+
/**
|
|
67
|
+
* provides a reference to the underlying html root element
|
|
68
|
+
*/
|
|
69
|
+
elementRef: PropTypes.func,
|
|
70
|
+
/**
|
|
71
|
+
* Sets the height of the component's container (optional)
|
|
72
|
+
*/
|
|
73
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
74
|
+
/**
|
|
75
|
+
* Sets the width of the component's container (optional)
|
|
76
|
+
*/
|
|
77
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
78
|
+
/**
|
|
79
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
80
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
81
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
82
|
+
*/
|
|
83
|
+
margin: ThemeablePropTypes.spacing,
|
|
84
|
+
/**
|
|
85
|
+
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
86
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
87
|
+
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
88
|
+
*/
|
|
89
|
+
padding: ThemeablePropTypes.spacing,
|
|
90
|
+
/**
|
|
91
|
+
* Sets the CSS display rule for the component's container
|
|
92
|
+
*/
|
|
93
|
+
display: PropTypes.oneOf(['flex', 'inline-flex']),
|
|
94
|
+
/**
|
|
95
|
+
* Designates the text alignment
|
|
96
|
+
*/
|
|
97
|
+
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
98
|
+
/**
|
|
99
|
+
* Sets the flex-direction to row (horizontal) or column (vertical)
|
|
100
|
+
*/
|
|
101
|
+
direction: PropTypes.oneOf([
|
|
102
|
+
'row',
|
|
103
|
+
'column',
|
|
104
|
+
'row-reverse',
|
|
105
|
+
'column-reverse'
|
|
106
|
+
]),
|
|
107
|
+
/**
|
|
108
|
+
* Aligns Flex.Items on the vertical axis (horizontal if direction is column)
|
|
109
|
+
*/
|
|
110
|
+
alignItems: PropTypes.oneOf(['center', 'start', 'end', 'stretch']),
|
|
111
|
+
/**
|
|
112
|
+
* Aligns Flex.Items on the horizontal axis (vertical if direction is column)
|
|
113
|
+
*/
|
|
114
|
+
justifyItems: PropTypes.oneOf([
|
|
115
|
+
'center',
|
|
116
|
+
'start',
|
|
117
|
+
'end',
|
|
118
|
+
'space-around',
|
|
119
|
+
'space-between'
|
|
120
|
+
]),
|
|
121
|
+
/**
|
|
122
|
+
* Determines if the Flex.Items should wrap when they exceed their container's width
|
|
123
|
+
*/
|
|
124
|
+
wrap: PropTypes.oneOf(['wrap', 'no-wrap', 'wrap-reverse']),
|
|
125
|
+
/**
|
|
126
|
+
* Activate a dotted outline around the component to make building your
|
|
127
|
+
* layout easier
|
|
128
|
+
*/
|
|
129
|
+
withVisualDebug: PropTypes.bool
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const allowedProps: AllowedPropKeys = [
|
|
133
|
+
'children',
|
|
134
|
+
'as',
|
|
135
|
+
'elementRef',
|
|
136
|
+
'height',
|
|
137
|
+
'width',
|
|
138
|
+
'margin',
|
|
139
|
+
'padding',
|
|
140
|
+
'display',
|
|
141
|
+
'textAlign',
|
|
142
|
+
'direction',
|
|
143
|
+
'alignItems',
|
|
144
|
+
'justifyItems',
|
|
145
|
+
'wrap',
|
|
146
|
+
'withVisualDebug'
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
export type { FlexProps }
|
|
150
|
+
export { propTypes, allowedProps }
|