@instructure/ui-flex 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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,99 +1,43 @@
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
1
  import { getShorthandPropValue } from '@instructure/emotion';
26
- /**
27
- * ---
28
- * private: true
29
- * ---
30
- * Generates the style object from the theme and provided additional information
31
- * @param {Object} componentTheme The theme variable object.
32
- * @param {Object} props the props of the component, the style is applied to
33
- * @param {string} props.justifyItems
34
- * @param {string} props.direction
35
- * @param {string} props.alignItems
36
- * @param {string} props.wrap
37
- * @param {Object} state the state of the component, the style is applied to
38
- * @return {Object} The final style object, which will be used in the component
39
- */
40
-
41
- const generateStyle = (componentTheme, props) => {
42
- const {
43
- justifyItems,
44
- wrap,
45
- direction,
46
- gap
47
- } = props;
48
-
49
- // align-items css prop
50
- // When flex direction is row, 'center' is the most useful default because it
51
- // vertically aligns Items. For column direction, though, we want 'stretch'.
52
- const alignItems = props.alignItems || (direction === 'column' || direction === 'column-reverse' ? 'stretch' : 'center');
53
- const alignItemsValues = {
54
- center: 'center',
55
- start: 'flex-start',
56
- end: 'flex-end',
57
- stretch: 'stretch'
58
- };
59
-
60
- // justify-content css prop
61
- const justifyItemsValues = {
62
- start: 'flex-start',
63
- end: 'flex-end',
64
- center: 'center',
65
- 'space-around': 'space-around',
66
- 'space-between': 'space-between'
67
- };
68
-
69
- // wrap css prop
70
- const wrapValues = {
71
- wrap: 'wrap',
72
- 'wrap-reverse': 'wrap-reverse',
73
- 'no-wrap': undefined
74
- };
75
-
76
- // flex-direction css props
77
- const flexDirectionValues = {
78
- column: 'column',
79
- 'column-reverse': 'column-reverse',
80
- row: 'row',
81
- 'row-reverse': 'row-reverse'
82
- };
83
-
84
- // gap css prop
85
- const getGapValue = (gap, theme) => getShorthandPropValue('Flex', theme, gap, 'gap');
86
- return {
87
- flex: {
88
- label: 'flex',
89
- fontFamily: componentTheme.fontFamily,
90
- boxSizing: 'border-box',
91
- alignItems: alignItemsValues[alignItems],
92
- justifyContent: justifyItemsValues[justifyItems],
93
- flexWrap: wrapValues[wrap],
94
- flexDirection: flexDirectionValues[direction],
95
- gap: getGapValue(gap, componentTheme)
96
- }
97
- };
2
+ const generateStyle = (componentTheme, props)=>{
3
+ const { justifyItems, wrap, direction, gap } = props;
4
+ const alignItems = props.alignItems || (direction === 'column' || direction === 'column-reverse' ? 'stretch' : 'center');
5
+ const alignItemsValues = {
6
+ center: 'center',
7
+ start: 'flex-start',
8
+ end: 'flex-end',
9
+ stretch: 'stretch'
10
+ };
11
+ const justifyItemsValues = {
12
+ start: 'flex-start',
13
+ end: 'flex-end',
14
+ center: 'center',
15
+ 'space-around': 'space-around',
16
+ 'space-between': 'space-between'
17
+ };
18
+ const wrapValues = {
19
+ wrap: 'wrap',
20
+ 'wrap-reverse': 'wrap-reverse',
21
+ 'no-wrap': undefined
22
+ };
23
+ const flexDirectionValues = {
24
+ column: 'column',
25
+ 'column-reverse': 'column-reverse',
26
+ row: 'row',
27
+ 'row-reverse': 'row-reverse'
28
+ };
29
+ const getGapValue = (gap, theme)=>getShorthandPropValue('Flex', theme, gap, 'gap');
30
+ return {
31
+ flex: {
32
+ label: 'flex',
33
+ fontFamily: componentTheme.fontFamily,
34
+ boxSizing: 'border-box',
35
+ alignItems: alignItemsValues[alignItems],
36
+ justifyContent: justifyItemsValues[justifyItems],
37
+ flexWrap: wrapValues[wrap],
38
+ flexDirection: flexDirectionValues[direction],
39
+ gap: getGapValue(gap, componentTheme)
40
+ }
41
+ };
98
42
  };
99
- export default generateStyle;
43
+ export default generateStyle;
@@ -1,44 +1,12 @@
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
1
  import { makeThemeVars } from '@instructure/emotion';
26
- /**
27
- * Generates the theme object for the component from the theme and provided additional information
28
- * @param {Object} theme The actual theme object.
29
- * @return {Object} The final theme object with the overrides and component variables
30
- */
31
- const generateComponentTheme = theme => {
32
- const {
33
- typography,
34
- spacing
35
- } = theme;
36
- const componentVariables = {
37
- fontFamily: typography?.fontFamily,
38
- ...makeThemeVars('gap', spacing)
39
- };
40
- return {
41
- ...componentVariables
42
- };
2
+ const generateComponentTheme = (theme)=>{
3
+ const { typography, spacing } = theme;
4
+ const componentVariables = {
5
+ fontFamily: typography?.fontFamily,
6
+ ...makeThemeVars('gap', spacing)
7
+ };
8
+ return {
9
+ ...componentVariables
10
+ };
43
11
  };
44
- export default generateComponentTheme;
12
+ export default generateComponentTheme;
@@ -1,99 +1,67 @@
1
- var _dec, _class;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
26
3
  import { Component } from 'react';
27
4
  import { omitProps } from '@instructure/ui-react-utils';
28
5
  import { View } from '@instructure/ui-view/latest';
29
6
  import { withStyle } from '@instructure/emotion';
30
7
  import generateStyle from './styles.js';
31
8
  import { allowedProps } from './props.js';
32
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
33
- /**
34
- ---
35
- parent: Flex
36
- id: Flex.Item
37
- ---
38
- **/
39
- let Item = (_dec = withStyle(generateStyle, null), _dec(_class = class Item extends Component {
40
- static displayName = 'Item';
41
- static componentId = 'Flex.Item';
42
- componentDidMount() {
43
- this.props.makeStyles?.();
44
- }
45
- componentDidUpdate() {
46
- this.props.makeStyles?.();
47
- }
48
- static allowedProps = allowedProps;
49
- static defaultProps = {
50
- as: 'span',
51
- shouldGrow: false,
52
- shouldShrink: false
53
- };
54
- ref = null;
55
- handleRef = el => {
56
- const {
57
- elementRef
58
- } = this.props;
59
- this.ref = el;
60
- if (typeof elementRef === 'function') {
61
- elementRef(el);
9
+ class Item extends Component {
10
+ static{
11
+ this.displayName = 'Item';
12
+ }
13
+ static{
14
+ this.componentId = 'Flex.Item';
15
+ }
16
+ componentDidMount() {
17
+ this.props.makeStyles?.();
18
+ }
19
+ componentDidUpdate() {
20
+ this.props.makeStyles?.();
21
+ }
22
+ static{
23
+ this.allowedProps = allowedProps;
24
+ }
25
+ static{
26
+ this.defaultProps = {
27
+ as: 'span',
28
+ shouldGrow: false,
29
+ shouldShrink: false
30
+ };
31
+ }
32
+ render() {
33
+ const props = omitProps(this.props, Item.allowedProps);
34
+ const { as, children, withVisualDebug, textAlign, size, direction, margin, padding, overflowX, overflowY, styles } = this.props;
35
+ const dirColumn = direction === 'column';
36
+ const dirRow = direction === 'row';
37
+ return /*#__PURE__*/ _jsx(View, {
38
+ ...props,
39
+ css: styles?.flexItem,
40
+ elementRef: this.handleRef,
41
+ as: as,
42
+ minHeight: dirColumn ? size : undefined,
43
+ minWidth: dirRow ? size : undefined,
44
+ textAlign: textAlign,
45
+ margin: margin,
46
+ padding: padding,
47
+ overflowX: overflowX,
48
+ overflowY: overflowY || (dirColumn ? 'auto' : 'visible'),
49
+ withVisualDebug: withVisualDebug,
50
+ children: children
51
+ });
52
+ }
53
+ constructor(...args){
54
+ super(...args), this.ref = null, this.handleRef = (el)=>{
55
+ const { elementRef } = this.props;
56
+ this.ref = el;
57
+ if (typeof elementRef === 'function') {
58
+ elementRef(el);
59
+ }
60
+ };
62
61
  }
63
- };
64
- render() {
65
- const props = omitProps(this.props, Item.allowedProps);
66
- const {
67
- as,
68
- children,
69
- withVisualDebug,
70
- textAlign,
71
- size,
72
- direction,
73
- margin,
74
- padding,
75
- overflowX,
76
- overflowY,
77
- styles
78
- } = this.props;
79
- const dirColumn = direction === 'column';
80
- const dirRow = direction === 'row';
81
- return _jsx(View, {
82
- ...props,
83
- css: styles?.flexItem,
84
- elementRef: this.handleRef,
85
- as: as,
86
- minHeight: dirColumn ? size : undefined,
87
- minWidth: dirRow ? size : undefined,
88
- textAlign: textAlign,
89
- margin: margin,
90
- padding: padding,
91
- overflowX: overflowX,
92
- overflowY: overflowY || (dirColumn ? 'auto' : 'visible'),
93
- withVisualDebug: withVisualDebug,
94
- children: children
95
- });
96
- }
97
- }) || _class);
62
+ }
63
+ Item = _ts_decorate([
64
+ withStyle(generateStyle, null)
65
+ ], Item);
98
66
  export default Item;
99
- export { Item };
67
+ export { Item };
@@ -1,26 +1,18 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const allowedProps = ['children', 'as', 'elementRef', 'margin', 'padding', 'align', 'direction', 'textAlign', 'overflowX', 'overflowY', 'shouldGrow', 'shouldShrink', 'size', 'withVisualDebug', 'order'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'children',
3
+ 'as',
4
+ 'elementRef',
5
+ 'margin',
6
+ 'padding',
7
+ 'align',
8
+ 'direction',
9
+ 'textAlign',
10
+ 'overflowX',
11
+ 'overflowY',
12
+ 'shouldGrow',
13
+ 'shouldShrink',
14
+ 'size',
15
+ 'withVisualDebug',
16
+ 'order'
17
+ ];
18
+ export { allowedProps };
@@ -1,70 +1,28 @@
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
- /**
26
- * ---
27
- * private: true
28
- * ---
29
- * Generates the style object from the theme and provided additional information
30
- * @param {Object} componentTheme The theme variable object.
31
- * @param {Object} props the props of the component, the style is applied to
32
- * @param {Object} state the state of the component, the style is applied to
33
- * @return {Object} The final style object, which will be used in the component
34
- */
35
- const generateStyle = (_componentTheme, props) => {
36
- const {
37
- shouldGrow,
38
- shouldShrink,
39
- align,
40
- size,
41
- order
42
- } = props;
43
- const alignSelfValues = {
44
- start: 'flex-start',
45
- end: 'flex-end',
46
- center: 'center',
47
- stretch: 'stretch'
48
- };
49
- return {
50
- flexItem: {
51
- label: 'flexItem',
52
- boxSizing: 'border-box',
53
- minWidth: '0.0625rem',
54
- flexBasis: size,
55
- ...(order !== undefined ? {
56
- order
57
- } : {}),
58
- // initial value is 1, but we want 0 as our default,
59
- // so users can opt in to shrink like they do grow
60
- flexShrink: shouldShrink ? 1 : 0,
61
- ...(shouldGrow && {
62
- flexGrow: 1
63
- }),
64
- ...(align && {
65
- alignSelf: alignSelfValues[align]
66
- })
67
- }
68
- };
1
+ const generateStyle = (_componentTheme, props)=>{
2
+ const { shouldGrow, shouldShrink, align, size, order } = props;
3
+ const alignSelfValues = {
4
+ start: 'flex-start',
5
+ end: 'flex-end',
6
+ center: 'center',
7
+ stretch: 'stretch'
8
+ };
9
+ return {
10
+ flexItem: {
11
+ label: 'flexItem',
12
+ boxSizing: 'border-box',
13
+ minWidth: '0.0625rem',
14
+ flexBasis: size,
15
+ ...order !== undefined ? {
16
+ order
17
+ } : {},
18
+ flexShrink: shouldShrink ? 1 : 0,
19
+ ...shouldGrow && {
20
+ flexGrow: 1
21
+ },
22
+ ...align && {
23
+ alignSelf: alignSelfValues[align]
24
+ }
25
+ }
26
+ };
69
27
  };
70
- export default generateStyle;
28
+ export default generateStyle;