@instructure/ui-flex 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +30 -281
  2. package/es/Flex/{Item → v1/Item}/index.js +2 -2
  3. package/es/Flex/{index.js → v1/index.js} +2 -2
  4. package/es/Flex/v2/Item/index.js +97 -0
  5. package/es/Flex/v2/Item/props.js +26 -0
  6. package/es/Flex/v2/Item/styles.js +68 -0
  7. package/es/Flex/v2/index.js +119 -0
  8. package/es/Flex/v2/props.js +26 -0
  9. package/es/Flex/v2/styles.js +101 -0
  10. package/es/{index.js → exports/a.js} +1 -1
  11. package/{src/index.ts → es/exports/b.js} +1 -5
  12. package/lib/Flex/{Item → v1/Item}/index.js +3 -3
  13. package/lib/Flex/v1/index.js +135 -0
  14. package/lib/Flex/v2/Item/index.js +102 -0
  15. package/lib/Flex/v2/Item/props.js +31 -0
  16. package/lib/Flex/v2/Item/styles.js +74 -0
  17. package/lib/Flex/{index.js → v2/index.js} +3 -4
  18. package/lib/Flex/v2/props.js +31 -0
  19. package/lib/Flex/v2/styles.js +107 -0
  20. package/lib/{index.js → exports/a.js} +3 -3
  21. package/lib/exports/b.js +18 -0
  22. package/package.json +38 -16
  23. package/src/Flex/{Item → v1/Item}/index.tsx +2 -2
  24. package/src/Flex/{index.tsx → v1/index.tsx} +2 -2
  25. package/src/Flex/v2/Item/index.tsx +115 -0
  26. package/src/Flex/v2/Item/props.ts +146 -0
  27. package/src/Flex/v2/Item/styles.ts +66 -0
  28. package/src/Flex/v2/README.md +419 -0
  29. package/src/Flex/v2/index.tsx +157 -0
  30. package/src/Flex/v2/props.ts +152 -0
  31. package/src/Flex/v2/styles.ts +112 -0
  32. package/src/exports/a.ts +28 -0
  33. package/src/exports/b.ts +28 -0
  34. package/tsconfig.build.tsbuildinfo +1 -1
  35. package/types/Flex/v1/Item/index.d.ts.map +1 -0
  36. package/types/Flex/v1/Item/props.d.ts.map +1 -0
  37. package/types/Flex/v1/Item/styles.d.ts.map +1 -0
  38. package/types/Flex/v1/index.d.ts.map +1 -0
  39. package/types/Flex/v1/props.d.ts.map +1 -0
  40. package/types/Flex/v1/styles.d.ts.map +1 -0
  41. package/types/Flex/v1/theme.d.ts.map +1 -0
  42. package/types/Flex/v2/Item/index.d.ts +41 -0
  43. package/types/Flex/v2/Item/index.d.ts.map +1 -0
  44. package/types/Flex/v2/Item/props.d.ts +79 -0
  45. package/types/Flex/v2/Item/props.d.ts.map +1 -0
  46. package/types/Flex/v2/Item/styles.d.ts +14 -0
  47. package/types/Flex/v2/Item/styles.d.ts.map +1 -0
  48. package/types/Flex/v2/index.d.ts +49 -0
  49. package/types/Flex/v2/index.d.ts.map +1 -0
  50. package/types/Flex/v2/props.d.ts +83 -0
  51. package/types/Flex/v2/props.d.ts.map +1 -0
  52. package/types/Flex/v2/styles.d.ts +19 -0
  53. package/types/Flex/v2/styles.d.ts.map +1 -0
  54. package/types/exports/a.d.ts +4 -0
  55. package/types/exports/a.d.ts.map +1 -0
  56. package/types/exports/b.d.ts +4 -0
  57. package/types/exports/b.d.ts.map +1 -0
  58. package/types/Flex/Item/index.d.ts.map +0 -1
  59. package/types/Flex/Item/props.d.ts.map +0 -1
  60. package/types/Flex/Item/styles.d.ts.map +0 -1
  61. package/types/Flex/index.d.ts.map +0 -1
  62. package/types/Flex/props.d.ts.map +0 -1
  63. package/types/Flex/styles.d.ts.map +0 -1
  64. package/types/Flex/theme.d.ts.map +0 -1
  65. package/types/index.d.ts +0 -4
  66. package/types/index.d.ts.map +0 -1
  67. /package/es/Flex/{Item → v1/Item}/props.js +0 -0
  68. /package/es/Flex/{Item → v1/Item}/styles.js +0 -0
  69. /package/es/Flex/{props.js → v1/props.js} +0 -0
  70. /package/es/Flex/{styles.js → v1/styles.js} +0 -0
  71. /package/es/Flex/{theme.js → v1/theme.js} +0 -0
  72. /package/lib/Flex/{Item → v1/Item}/props.js +0 -0
  73. /package/lib/Flex/{Item → v1/Item}/styles.js +0 -0
  74. /package/lib/Flex/{props.js → v1/props.js} +0 -0
  75. /package/lib/Flex/{styles.js → v1/styles.js} +0 -0
  76. /package/lib/Flex/{theme.js → v1/theme.js} +0 -0
  77. /package/src/Flex/{Item → v1/Item}/props.ts +0 -0
  78. /package/src/Flex/{Item → v1/Item}/styles.ts +0 -0
  79. /package/src/Flex/{README.md → v1/README.md} +0 -0
  80. /package/src/Flex/{props.ts → v1/props.ts} +0 -0
  81. /package/src/Flex/{styles.ts → v1/styles.ts} +0 -0
  82. /package/src/Flex/{theme.ts → v1/theme.ts} +0 -0
  83. /package/types/Flex/{Item → v1/Item}/index.d.ts +0 -0
  84. /package/types/Flex/{Item → v1/Item}/props.d.ts +0 -0
  85. /package/types/Flex/{Item → v1/Item}/styles.d.ts +0 -0
  86. /package/types/Flex/{index.d.ts → v1/index.d.ts} +0 -0
  87. /package/types/Flex/{props.d.ts → v1/props.d.ts} +0 -0
  88. /package/types/Flex/{styles.d.ts → v1/styles.d.ts} +0 -0
  89. /package/types/Flex/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,97 @@
1
+ var _dec, _class, _Item;
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
+
26
+ import { Component } from 'react';
27
+ import { omitProps } from '@instructure/ui-react-utils';
28
+ import { View } from '@instructure/ui-view/latest';
29
+ import { withStyleLegacy as withStyle } from '@instructure/emotion';
30
+ import generateStyle from "./styles.js";
31
+ 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 = (_Item = class Item extends Component {
40
+ constructor(...args) {
41
+ super(...args);
42
+ this.ref = null;
43
+ this.handleRef = el => {
44
+ const elementRef = this.props.elementRef;
45
+ this.ref = el;
46
+ if (typeof elementRef === 'function') {
47
+ elementRef(el);
48
+ }
49
+ };
50
+ }
51
+ componentDidMount() {
52
+ var _this$props$makeStyle, _this$props;
53
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
54
+ }
55
+ componentDidUpdate() {
56
+ var _this$props$makeStyle2, _this$props2;
57
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
58
+ }
59
+ render() {
60
+ const props = omitProps(this.props, Item.allowedProps);
61
+ const _this$props3 = this.props,
62
+ as = _this$props3.as,
63
+ children = _this$props3.children,
64
+ withVisualDebug = _this$props3.withVisualDebug,
65
+ textAlign = _this$props3.textAlign,
66
+ size = _this$props3.size,
67
+ direction = _this$props3.direction,
68
+ margin = _this$props3.margin,
69
+ padding = _this$props3.padding,
70
+ overflowX = _this$props3.overflowX,
71
+ overflowY = _this$props3.overflowY,
72
+ styles = _this$props3.styles;
73
+ const dirColumn = direction === 'column';
74
+ const dirRow = direction === 'row';
75
+ return _jsx(View, {
76
+ ...props,
77
+ css: styles === null || styles === void 0 ? void 0 : styles.flexItem,
78
+ elementRef: this.handleRef,
79
+ as: as,
80
+ minHeight: dirColumn ? size : void 0,
81
+ minWidth: dirRow ? size : void 0,
82
+ textAlign: textAlign,
83
+ margin: margin,
84
+ padding: padding,
85
+ overflowX: overflowX,
86
+ overflowY: overflowY || (dirColumn ? 'auto' : 'visible'),
87
+ withVisualDebug: withVisualDebug,
88
+ children: children
89
+ });
90
+ }
91
+ }, _Item.displayName = "Item", _Item.componentId = 'Flex.Item', _Item.allowedProps = allowedProps, _Item.defaultProps = {
92
+ as: 'span',
93
+ shouldGrow: false,
94
+ shouldShrink: false
95
+ }, _Item)) || _class);
96
+ export default Item;
97
+ export { Item };
@@ -0,0 +1,26 @@
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 };
@@ -0,0 +1,68 @@
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 shouldGrow = props.shouldGrow,
37
+ shouldShrink = props.shouldShrink,
38
+ align = props.align,
39
+ size = props.size,
40
+ order = props.order;
41
+ const alignSelfValues = {
42
+ start: 'flex-start',
43
+ end: 'flex-end',
44
+ center: 'center',
45
+ stretch: 'stretch'
46
+ };
47
+ return {
48
+ flexItem: {
49
+ label: 'flexItem',
50
+ boxSizing: 'border-box',
51
+ minWidth: '0.0625rem',
52
+ flexBasis: size,
53
+ ...(order !== void 0 ? {
54
+ order
55
+ } : {}),
56
+ // initial value is 1, but we want 0 as our default,
57
+ // so users can opt in to shrink like they do grow
58
+ flexShrink: shouldShrink ? 1 : 0,
59
+ ...(shouldGrow && {
60
+ flexGrow: 1
61
+ }),
62
+ ...(align && {
63
+ alignSelf: alignSelfValues[align]
64
+ })
65
+ }
66
+ };
67
+ };
68
+ export default generateStyle;
@@ -0,0 +1,119 @@
1
+ var _dec, _class, _Flex;
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
+
26
+ import { Children, Component } from 'react';
27
+ import { safeCloneElement, passthroughProps, matchComponentTypes, callRenderProp } from '@instructure/ui-react-utils';
28
+ import { View } from '@instructure/ui-view/latest';
29
+ import { withStyle } from '@instructure/emotion';
30
+ import { Item } from "./Item/index.js";
31
+ import generateStyle from "./styles.js";
32
+ import { allowedProps } from "./props.js";
33
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
34
+ /**
35
+ ---
36
+ category: components
37
+ ---
38
+ @module Flex
39
+ **/
40
+ let Flex = (_dec = withStyle(generateStyle), _dec(_class = (_Flex = class Flex extends Component {
41
+ constructor(...args) {
42
+ super(...args);
43
+ this.ref = null;
44
+ this.handleRef = el => {
45
+ const elementRef = this.props.elementRef;
46
+ this.ref = el;
47
+ if (typeof elementRef === 'function') {
48
+ elementRef(el);
49
+ }
50
+ };
51
+ }
52
+ componentDidMount() {
53
+ var _this$props$makeStyle, _this$props;
54
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
55
+ }
56
+ componentDidUpdate() {
57
+ var _this$props$makeStyle2, _this$props2;
58
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
59
+ }
60
+ renderChildren(children) {
61
+ // TODO this might fail if children are () => ReactNode
62
+ return Children.map(children, child => {
63
+ if (!child) {
64
+ return null;
65
+ }
66
+ return matchComponentTypes(child, ['Item']) ? safeCloneElement(child, {
67
+ // child withVisualDebug prop should override parent
68
+ withVisualDebug: this.props.withVisualDebug,
69
+ ...child.props,
70
+ direction: this.props.direction.replace(/-reverse/, '')
71
+ }) : child;
72
+ });
73
+ }
74
+ render() {
75
+ const _this$props3 = this.props,
76
+ as = _this$props3.as,
77
+ withVisualDebug = _this$props3.withVisualDebug,
78
+ height = _this$props3.height,
79
+ display = _this$props3.display,
80
+ margin = _this$props3.margin,
81
+ padding = _this$props3.padding,
82
+ textAlign = _this$props3.textAlign,
83
+ width = _this$props3.width,
84
+ styles = _this$props3.styles,
85
+ gap = _this$props3.gap,
86
+ wrap = _this$props3.wrap;
87
+ const children = callRenderProp(this.props.children);
88
+ const gapValuesArray = gap === null || gap === void 0 ? void 0 : gap.split(' ');
89
+ if (gapValuesArray.length > 1 && wrap === 'no-wrap') {}
90
+ if (children && Children.count(children) > 0) {
91
+ return _jsx(View, {
92
+ ...passthroughProps(this.props),
93
+ css: styles === null || styles === void 0 ? void 0 : styles.flex,
94
+ elementRef: this.handleRef,
95
+ as: as,
96
+ display: display,
97
+ width: width,
98
+ height: height,
99
+ margin: margin,
100
+ padding: padding,
101
+ textAlign: textAlign,
102
+ withVisualDebug: withVisualDebug,
103
+ children: this.renderChildren(children)
104
+ });
105
+ } else {
106
+ return null;
107
+ }
108
+ }
109
+ }, _Flex.displayName = "Flex", _Flex.componentId = 'Flex', _Flex.Item = Item, _Flex.allowedProps = allowedProps, _Flex.defaultProps = {
110
+ as: 'span',
111
+ direction: 'row',
112
+ justifyItems: 'start',
113
+ display: 'flex',
114
+ withVisualDebug: false,
115
+ wrap: 'no-wrap',
116
+ gap: 'none'
117
+ }, _Flex)) || _class);
118
+ export default Flex;
119
+ export { Flex, Item as FlexItem };
@@ -0,0 +1,26 @@
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', 'height', 'width', 'margin', 'padding', 'display', 'textAlign', 'direction', 'alignItems', 'justifyItems', 'wrap', 'withVisualDebug'];
26
+ export { allowedProps };
@@ -0,0 +1,101 @@
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 { getShorthandPropValue, makeThemeVars } 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, sharedTokens) => {
42
+ const justifyItems = props.justifyItems,
43
+ wrap = props.wrap,
44
+ direction = props.direction,
45
+ gap = props.gap;
46
+
47
+ // align-items css prop
48
+ // When flex direction is row, 'center' is the most useful default because it
49
+ // vertically aligns Items. For column direction, though, we want 'stretch'.
50
+ const alignItems = props.alignItems || (direction === 'column' || direction === 'column-reverse' ? 'stretch' : 'center');
51
+ const alignItemsValues = {
52
+ center: 'center',
53
+ start: 'flex-start',
54
+ end: 'flex-end',
55
+ stretch: 'stretch'
56
+ };
57
+
58
+ // justify-content css prop
59
+ const justifyItemsValues = {
60
+ start: 'flex-start',
61
+ end: 'flex-end',
62
+ center: 'center',
63
+ 'space-around': 'space-around',
64
+ 'space-between': 'space-between'
65
+ };
66
+
67
+ // wrap css prop
68
+ const wrapValues = {
69
+ wrap: 'wrap',
70
+ 'wrap-reverse': 'wrap-reverse',
71
+ 'no-wrap': void 0
72
+ };
73
+
74
+ // flex-direction css props
75
+ const flexDirectionValues = {
76
+ column: 'column',
77
+ 'column-reverse': 'column-reverse',
78
+ row: 'row',
79
+ 'row-reverse': 'row-reverse'
80
+ };
81
+
82
+ // gap css prop
83
+ const gapValues = makeThemeVars('gap', {
84
+ ...sharedTokens.spacing,
85
+ ...sharedTokens.legacy.spacing
86
+ });
87
+ const getGapValue = (gap, values) => getShorthandPropValue('Flex', values, gap, 'gap');
88
+ return {
89
+ flex: {
90
+ label: 'flex',
91
+ fontFamily: componentTheme.fontFamily,
92
+ boxSizing: 'border-box',
93
+ alignItems: alignItemsValues[alignItems],
94
+ justifyContent: justifyItemsValues[justifyItems],
95
+ flexWrap: wrapValues[wrap],
96
+ flexDirection: flexDirectionValues[direction],
97
+ gap: getGapValue(gap, gapValues)
98
+ }
99
+ };
100
+ };
101
+ export default generateStyle;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { Flex, FlexItem } from "./Flex/index.js";
24
+ export { Flex, FlexItem } from "../Flex/v1/index.js";
@@ -21,8 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
-
25
- export { Flex, FlexItem } from './Flex'
26
-
27
- export type { FlexProps } from './Flex/props'
28
- export type { FlexItemProps } from './Flex/Item/props'
24
+ export { Flex, FlexItem } from "../Flex/v2/index.js";
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = exports.Item = void 0;
8
8
  var _react = require("react");
9
9
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
- var _View = require("@instructure/ui-view/lib/View");
10
+ var _v11_ = require("@instructure/ui-view/v11_6");
11
11
  var _emotion = require("@instructure/emotion");
12
12
  var _styles = _interopRequireDefault(require("./styles"));
13
13
  var _props = require("./props");
@@ -42,7 +42,7 @@ parent: Flex
42
42
  id: Flex.Item
43
43
  ---
44
44
  **/
45
- let Item = exports.Item = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class = (_Item = class Item extends _react.Component {
45
+ let Item = exports.Item = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, null), _dec(_class = (_Item = class Item extends _react.Component {
46
46
  constructor(...args) {
47
47
  super(...args);
48
48
  this.ref = null;
@@ -78,7 +78,7 @@ let Item = exports.Item = (_dec = (0, _emotion.withStyle)(_styles.default, null)
78
78
  styles = _this$props3.styles;
79
79
  const dirColumn = direction === 'column';
80
80
  const dirRow = direction === 'row';
81
- return (0, _jsxRuntime.jsx)(_View.View, {
81
+ return (0, _jsxRuntime.jsx)(_v11_.View, {
82
82
  ...props,
83
83
  css: styles === null || styles === void 0 ? void 0 : styles.flexItem,
84
84
  elementRef: this.handleRef,
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Flex = void 0;
8
+ Object.defineProperty(exports, "FlexItem", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _Item.Item;
12
+ }
13
+ });
14
+ exports.default = void 0;
15
+ var _react = require("react");
16
+ var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
17
+ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
18
+ var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
19
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
20
+ var _v11_ = require("@instructure/ui-view/v11_6");
21
+ var _emotion = require("@instructure/emotion");
22
+ var _Item = require("./Item");
23
+ var _styles = _interopRequireDefault(require("./styles"));
24
+ var _theme = _interopRequireDefault(require("./theme"));
25
+ var _props = require("./props");
26
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
27
+ var _dec, _class, _Flex;
28
+ /*
29
+ * The MIT License (MIT)
30
+ *
31
+ * Copyright (c) 2015 - present Instructure, Inc.
32
+ *
33
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
34
+ * of this software and associated documentation files (the "Software"), to deal
35
+ * in the Software without restriction, including without limitation the rights
36
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
+ * copies of the Software, and to permit persons to whom the Software is
38
+ * furnished to do so, subject to the following conditions:
39
+ *
40
+ * The above copyright notice and this permission notice shall be included in all
41
+ * copies or substantial portions of the Software.
42
+ *
43
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
+ * SOFTWARE.
50
+ */
51
+ /**
52
+ ---
53
+ category: components
54
+ ---
55
+ @module Flex
56
+ **/
57
+ let Flex = exports.Flex = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_Flex = class Flex extends _react.Component {
58
+ constructor(...args) {
59
+ super(...args);
60
+ this.ref = null;
61
+ this.handleRef = el => {
62
+ const elementRef = this.props.elementRef;
63
+ this.ref = el;
64
+ if (typeof elementRef === 'function') {
65
+ elementRef(el);
66
+ }
67
+ };
68
+ }
69
+ componentDidMount() {
70
+ var _this$props$makeStyle, _this$props;
71
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
72
+ }
73
+ componentDidUpdate() {
74
+ var _this$props$makeStyle2, _this$props2;
75
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
76
+ }
77
+ renderChildren(children) {
78
+ // TODO this might fail if children are () => ReactNode
79
+ return _react.Children.map(children, child => {
80
+ if (!child) {
81
+ return null;
82
+ }
83
+ return (0, _matchComponentTypes.matchComponentTypes)(child, ['Item']) ? (0, _safeCloneElement.safeCloneElement)(child, {
84
+ // child withVisualDebug prop should override parent
85
+ withVisualDebug: this.props.withVisualDebug,
86
+ ...child.props,
87
+ direction: this.props.direction.replace(/-reverse/, '')
88
+ }) : child;
89
+ });
90
+ }
91
+ render() {
92
+ const _this$props3 = this.props,
93
+ as = _this$props3.as,
94
+ withVisualDebug = _this$props3.withVisualDebug,
95
+ height = _this$props3.height,
96
+ display = _this$props3.display,
97
+ margin = _this$props3.margin,
98
+ padding = _this$props3.padding,
99
+ textAlign = _this$props3.textAlign,
100
+ width = _this$props3.width,
101
+ styles = _this$props3.styles,
102
+ gap = _this$props3.gap,
103
+ wrap = _this$props3.wrap;
104
+ const children = (0, _callRenderProp.callRenderProp)(this.props.children);
105
+ const gapValuesArray = gap === null || gap === void 0 ? void 0 : gap.split(' ');
106
+ if (gapValuesArray.length > 1 && wrap === 'no-wrap') {}
107
+ if (children && _react.Children.count(children) > 0) {
108
+ return (0, _jsxRuntime.jsx)(_v11_.View, {
109
+ ...(0, _passthroughProps.passthroughProps)(this.props),
110
+ css: styles === null || styles === void 0 ? void 0 : styles.flex,
111
+ elementRef: this.handleRef,
112
+ as: as,
113
+ display: display,
114
+ width: width,
115
+ height: height,
116
+ margin: margin,
117
+ padding: padding,
118
+ textAlign: textAlign,
119
+ withVisualDebug: withVisualDebug,
120
+ children: this.renderChildren(children)
121
+ });
122
+ } else {
123
+ return null;
124
+ }
125
+ }
126
+ }, _Flex.displayName = "Flex", _Flex.componentId = 'Flex', _Flex.Item = _Item.Item, _Flex.allowedProps = _props.allowedProps, _Flex.defaultProps = {
127
+ as: 'span',
128
+ direction: 'row',
129
+ justifyItems: 'start',
130
+ display: 'flex',
131
+ withVisualDebug: false,
132
+ wrap: 'no-wrap',
133
+ gap: 'none'
134
+ }, _Flex)) || _class);
135
+ var _default = exports.default = Flex;