@instructure/ui-options 8.14.1-snapshot.7 → 8.15.1-snapshot.2
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 +7 -0
- package/es/Options/Item/__examples__/Item.examples.js +28 -2
- package/es/Options/Item/index.js +11 -4
- package/es/Options/Item/props.js +5 -1
- package/es/Options/Item/styles.js +46 -6
- package/es/Options/Item/theme.js +8 -1
- package/es/Options/index.js +4 -4
- package/lib/Options/Item/__examples__/Item.examples.js +28 -2
- package/lib/Options/Item/index.js +11 -4
- package/lib/Options/Item/props.js +5 -1
- package/lib/Options/Item/styles.js +46 -6
- package/lib/Options/Item/theme.js +8 -1
- package/lib/Options/index.js +5 -3
- package/package.json +15 -15
- package/src/Options/Item/__examples__/Item.examples.ts +44 -5
- package/src/Options/Item/index.tsx +14 -4
- package/src/Options/Item/props.ts +31 -3
- package/src/Options/Item/styles.ts +51 -5
- package/src/Options/Item/theme.ts +10 -1
- package/src/Options/README.md +78 -2
- package/src/Options/index.tsx +14 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Options/Item/OptionsItemLocator.d.ts +4 -4
- package/types/Options/Item/__examples__/Item.examples.d.ts +3 -26
- package/types/Options/Item/__examples__/Item.examples.d.ts.map +1 -1
- package/types/Options/Item/index.d.ts +5 -5
- package/types/Options/Item/index.d.ts.map +1 -1
- package/types/Options/Item/props.d.ts +18 -3
- package/types/Options/Item/props.d.ts.map +1 -1
- package/types/Options/Item/styles.d.ts.map +1 -1
- package/types/Options/Item/theme.d.ts.map +1 -1
- package/types/Options/OptionsLocator.d.ts +14 -14
- package/types/Options/index.d.ts +8 -7
- package/types/Options/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
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.15.0](https://github.com/instructure/instructure-ui/compare/v8.14.0...v8.15.0) (2022-01-26)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **ui-options:** add `description` and `descriptionRole` props to Options.Item ([a2cfa0c](https://github.com/instructure/instructure-ui/commit/a2cfa0cd8bf43d6072f1b352bbd6e43542081be8))
|
|
11
|
+
- **ui-options:** add props to set the vALign of Options.Item before/after content ([be635ba](https://github.com/instructure/instructure-ui/commit/be635ba5c734c0a40f9778131b251f32decddb75))
|
|
12
|
+
|
|
6
13
|
# [8.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @instructure/ui-options
|
|
@@ -26,14 +26,40 @@ export default {
|
|
|
26
26
|
maxExamplesPerPage: 50,
|
|
27
27
|
propValues: {
|
|
28
28
|
renderAfterLabel: [null, IconArrowOpenEndSolid],
|
|
29
|
-
renderBeforeLabel: [null, IconCheckSolid]
|
|
29
|
+
renderBeforeLabel: [null, IconCheckSolid],
|
|
30
|
+
description: [null, 'Curabitur fringilla, urna ut efficitur molestie, nibh lacus tincidunt elit, ut tempor ipsum nunc sit amet massa. Integer sit amet ante vitae lectus gravida pulvinar.']
|
|
30
31
|
},
|
|
31
32
|
getComponentProps: props => {
|
|
32
33
|
return {
|
|
33
34
|
renderAfterLabel: props.renderAfterLabel,
|
|
34
35
|
renderBeforeLabel: props.renderBeforeLabel,
|
|
35
36
|
children: 'Lorem ipsum dolor sit amet',
|
|
36
|
-
role: 'none'
|
|
37
|
+
role: 'none',
|
|
38
|
+
descriptionRole: 'note'
|
|
37
39
|
};
|
|
40
|
+
},
|
|
41
|
+
getExampleProps: () => {
|
|
42
|
+
return {
|
|
43
|
+
width: '400px'
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
filter: props => {
|
|
47
|
+
if (props.description) {
|
|
48
|
+
if (props.beforeLabelContentVAlign !== 'center' && (!props.renderBeforeLabel || props.renderAfterLabel)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (props.afterLabelContentVAlign !== 'center' && (!props.renderAfterLabel || props.renderBeforeLabel)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!props.description) {
|
|
58
|
+
if (props.afterLabelContentVAlign !== 'center' || props.beforeLabelContentVAlign !== 'center') {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return false;
|
|
38
64
|
}
|
|
39
65
|
};
|
package/es/Options/Item/index.js
CHANGED
|
@@ -82,11 +82,15 @@ let Item = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = te
|
|
|
82
82
|
as = _this$props4.as,
|
|
83
83
|
role = _this$props4.role,
|
|
84
84
|
styles = _this$props4.styles,
|
|
85
|
+
description = _this$props4.description,
|
|
86
|
+
descriptionRole = _this$props4.descriptionRole,
|
|
85
87
|
renderBeforeLabel = _this$props4.renderBeforeLabel,
|
|
86
88
|
renderAfterLabel = _this$props4.renderAfterLabel,
|
|
87
89
|
children = _this$props4.children;
|
|
88
90
|
const ElementType = getElementType(Item, this.props, () => as);
|
|
89
91
|
const passthroughProps = omitProps(this.props, Item.allowedProps);
|
|
92
|
+
const childrenContent = callRenderProp(children);
|
|
93
|
+
const descriptionContent = callRenderProp(description);
|
|
90
94
|
return jsx(ElementType, {
|
|
91
95
|
role: "none",
|
|
92
96
|
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
@@ -96,16 +100,19 @@ let Item = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = te
|
|
|
96
100
|
}, jsx("span", Object.assign({}, passthroughProps, {
|
|
97
101
|
css: styles === null || styles === void 0 ? void 0 : styles.container,
|
|
98
102
|
role: role
|
|
99
|
-
}),
|
|
103
|
+
}), childrenContent, descriptionContent && jsx("span", {
|
|
104
|
+
css: styles === null || styles === void 0 ? void 0 : styles.description,
|
|
105
|
+
role: descriptionRole
|
|
106
|
+
}, descriptionContent)), renderBeforeLabel && this.renderContent(renderBeforeLabel, styles === null || styles === void 0 ? void 0 : styles.contentBefore), renderAfterLabel && this.renderContent(renderAfterLabel, styles === null || styles === void 0 ? void 0 : styles.contentAfter));
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
}, _class2.displayName = "Item", _class2.componentId = 'Options.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
103
110
|
as: 'span',
|
|
104
111
|
variant: 'default',
|
|
105
112
|
role: 'listitem',
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
descriptionRole: 'note',
|
|
114
|
+
beforeLabelContentVAlign: 'center',
|
|
115
|
+
afterLabelContentVAlign: 'center'
|
|
109
116
|
}, _temp)) || _class) || _class);
|
|
110
117
|
export default Item;
|
|
111
118
|
export { Item };
|
package/es/Options/Item/props.js
CHANGED
|
@@ -28,7 +28,11 @@ const propTypes = {
|
|
|
28
28
|
role: PropTypes.string,
|
|
29
29
|
renderBeforeLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
30
30
|
renderAfterLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
31
|
+
beforeLabelContentVAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
32
|
+
afterLabelContentVAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
33
|
+
description: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
34
|
+
descriptionRole: PropTypes.string,
|
|
31
35
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
32
36
|
};
|
|
33
|
-
const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
|
|
37
|
+
const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'children'];
|
|
34
38
|
export { propTypes, allowedProps };
|
|
@@ -37,8 +37,11 @@ const generateStyle = (componentTheme, props) => {
|
|
|
37
37
|
const variant = props.variant,
|
|
38
38
|
children = props.children,
|
|
39
39
|
hasContentBeforeLabel = props.renderBeforeLabel,
|
|
40
|
-
hasContentAfterLabel = props.renderAfterLabel
|
|
41
|
-
|
|
40
|
+
hasContentAfterLabel = props.renderAfterLabel,
|
|
41
|
+
beforeLabelContentVAlign = props.beforeLabelContentVAlign,
|
|
42
|
+
afterLabelContentVAlign = props.afterLabelContentVAlign;
|
|
43
|
+
const containsList = matchComponentTypes(children, ['Options']); // used for label and description too
|
|
44
|
+
|
|
42
45
|
const variantVariants = {
|
|
43
46
|
highlighted: {
|
|
44
47
|
background: componentTheme.highlightedBackground,
|
|
@@ -54,6 +57,28 @@ const generateStyle = (componentTheme, props) => {
|
|
|
54
57
|
},
|
|
55
58
|
default: {}
|
|
56
59
|
};
|
|
60
|
+
|
|
61
|
+
const getContentVAlign = type => {
|
|
62
|
+
const vAlign = type === 'before' ? beforeLabelContentVAlign : afterLabelContentVAlign;
|
|
63
|
+
const vOffset = type === 'before' ? componentTheme.beforeLabelContentVOffset : componentTheme.afterLabelContentVOffset;
|
|
64
|
+
return {
|
|
65
|
+
start: {
|
|
66
|
+
alignItems: 'flex-start',
|
|
67
|
+
paddingBlockStart: vOffset
|
|
68
|
+
},
|
|
69
|
+
center: {
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
paddingBlockStart: vOffset,
|
|
72
|
+
paddingBlockEnd: vOffset
|
|
73
|
+
},
|
|
74
|
+
end: {
|
|
75
|
+
alignItems: 'flex-end',
|
|
76
|
+
paddingBlockEnd: vOffset
|
|
77
|
+
}
|
|
78
|
+
}[vAlign];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const transition = 'background 200ms';
|
|
57
82
|
return {
|
|
58
83
|
item: {
|
|
59
84
|
label: 'optionItem',
|
|
@@ -67,7 +92,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
67
92
|
lineHeight: componentTheme.lineHeight,
|
|
68
93
|
outline: 'none',
|
|
69
94
|
position: 'relative',
|
|
70
|
-
transition
|
|
95
|
+
transition,
|
|
71
96
|
userSelect: 'none',
|
|
72
97
|
...variantVariants[variant],
|
|
73
98
|
...(containsList && {
|
|
@@ -107,9 +132,9 @@ const generateStyle = (componentTheme, props) => {
|
|
|
107
132
|
},
|
|
108
133
|
content: {
|
|
109
134
|
label: 'optionItem__content',
|
|
110
|
-
alignItems: 'center',
|
|
111
135
|
display: 'flex',
|
|
112
136
|
height: '100%',
|
|
137
|
+
boxSizing: 'border-box',
|
|
113
138
|
pointerEvents: 'none',
|
|
114
139
|
position: 'absolute',
|
|
115
140
|
top: '0'
|
|
@@ -117,12 +142,27 @@ const generateStyle = (componentTheme, props) => {
|
|
|
117
142
|
contentBefore: {
|
|
118
143
|
label: 'optionItem__content--before',
|
|
119
144
|
insetInlineEnd: 'auto',
|
|
120
|
-
insetInlineStart: componentTheme.iconPadding
|
|
145
|
+
insetInlineStart: componentTheme.iconPadding,
|
|
146
|
+
...getContentVAlign('before')
|
|
121
147
|
},
|
|
122
148
|
contentAfter: {
|
|
123
149
|
label: 'optionItem__content--after',
|
|
124
150
|
insetInlineEnd: componentTheme.iconPadding,
|
|
125
|
-
insetInlineStart: 'auto'
|
|
151
|
+
insetInlineStart: 'auto',
|
|
152
|
+
...getContentVAlign('after')
|
|
153
|
+
},
|
|
154
|
+
description: {
|
|
155
|
+
label: 'optionItem__description',
|
|
156
|
+
display: 'block',
|
|
157
|
+
transition,
|
|
158
|
+
paddingBlockStart: componentTheme.descriptionPaddingStart,
|
|
159
|
+
fontWeight: componentTheme.descriptionFontWeight,
|
|
160
|
+
fontSize: componentTheme.descriptionFontSize,
|
|
161
|
+
lineHeight: componentTheme.descriptionLineHeight,
|
|
162
|
+
color: componentTheme.descriptionColor,
|
|
163
|
+
...variantVariants[variant],
|
|
164
|
+
background: 'none' // needed to clear variant background
|
|
165
|
+
|
|
126
166
|
}
|
|
127
167
|
};
|
|
128
168
|
};
|
package/es/Options/Item/theme.js
CHANGED
|
@@ -51,7 +51,14 @@ const generateComponentTheme = theme => {
|
|
|
51
51
|
selectedBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
52
52
|
padding: `${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall} ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
|
|
53
53
|
iconPadding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
54
|
-
nestedPadding: spacing === null || spacing === void 0 ? void 0 : spacing.medium
|
|
54
|
+
nestedPadding: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
55
|
+
beforeLabelContentVOffset: '0.625rem',
|
|
56
|
+
afterLabelContentVOffset: '0.625rem',
|
|
57
|
+
descriptionFontSize: typography.fontSizeSmall,
|
|
58
|
+
descriptionFontWeight: typography.fontWeightNormal,
|
|
59
|
+
descriptionLineHeight: typography.lineHeight,
|
|
60
|
+
descriptionPaddingStart: '0.25em',
|
|
61
|
+
descriptionColor: colors.textDark
|
|
55
62
|
};
|
|
56
63
|
return { ...componentVariables,
|
|
57
64
|
...themeSpecificStyle[themeName]
|
package/es/Options/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import { Component, Children } from 'react';
|
|
28
|
+
import React, { Component, Children } from 'react';
|
|
29
29
|
import { omitProps, matchComponentTypes, callRenderProp, safeCloneElement } from '@instructure/ui-react-utils';
|
|
30
30
|
import { testable } from '@instructure/ui-testable';
|
|
31
31
|
import { uid } from '@instructure/uid';
|
|
@@ -36,13 +36,13 @@ import generateComponentTheme from './theme';
|
|
|
36
36
|
import { Item } from './Item';
|
|
37
37
|
import { Separator } from './Separator';
|
|
38
38
|
import { allowedProps, propTypes } from './props';
|
|
39
|
+
|
|
39
40
|
/**
|
|
40
41
|
---
|
|
41
42
|
category: components
|
|
42
43
|
---
|
|
43
44
|
@tsProps
|
|
44
45
|
**/
|
|
45
|
-
|
|
46
46
|
let Options = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Options extends Component {
|
|
47
47
|
constructor() {
|
|
48
48
|
super(...arguments);
|
|
@@ -89,13 +89,13 @@ let Options = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 =
|
|
|
89
89
|
}, callRenderProp(renderLabel));
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
renderSubList(
|
|
92
|
+
renderSubList(subOptions) {
|
|
93
93
|
const styles = this.props.styles;
|
|
94
94
|
return jsx(Item, {
|
|
95
95
|
as: this.childAs,
|
|
96
96
|
role: "presentation",
|
|
97
97
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
98
|
-
},
|
|
98
|
+
}, subOptions);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
renderChildren() {
|
|
@@ -34,15 +34,41 @@ var _default = {
|
|
|
34
34
|
maxExamplesPerPage: 50,
|
|
35
35
|
propValues: {
|
|
36
36
|
renderAfterLabel: [null, _uiIcons.IconArrowOpenEndSolid],
|
|
37
|
-
renderBeforeLabel: [null, _uiIcons.IconCheckSolid]
|
|
37
|
+
renderBeforeLabel: [null, _uiIcons.IconCheckSolid],
|
|
38
|
+
description: [null, 'Curabitur fringilla, urna ut efficitur molestie, nibh lacus tincidunt elit, ut tempor ipsum nunc sit amet massa. Integer sit amet ante vitae lectus gravida pulvinar.']
|
|
38
39
|
},
|
|
39
40
|
getComponentProps: props => {
|
|
40
41
|
return {
|
|
41
42
|
renderAfterLabel: props.renderAfterLabel,
|
|
42
43
|
renderBeforeLabel: props.renderBeforeLabel,
|
|
43
44
|
children: 'Lorem ipsum dolor sit amet',
|
|
44
|
-
role: 'none'
|
|
45
|
+
role: 'none',
|
|
46
|
+
descriptionRole: 'note'
|
|
45
47
|
};
|
|
48
|
+
},
|
|
49
|
+
getExampleProps: () => {
|
|
50
|
+
return {
|
|
51
|
+
width: '400px'
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
filter: props => {
|
|
55
|
+
if (props.description) {
|
|
56
|
+
if (props.beforeLabelContentVAlign !== 'center' && (!props.renderBeforeLabel || props.renderAfterLabel)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (props.afterLabelContentVAlign !== 'center' && (!props.renderAfterLabel || props.renderBeforeLabel)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!props.description) {
|
|
66
|
+
if (props.afterLabelContentVAlign !== 'center' || props.beforeLabelContentVAlign !== 'center') {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false;
|
|
46
72
|
}
|
|
47
73
|
};
|
|
48
74
|
exports.default = _default;
|
|
@@ -72,11 +72,15 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
72
72
|
as = _this$props4.as,
|
|
73
73
|
role = _this$props4.role,
|
|
74
74
|
styles = _this$props4.styles,
|
|
75
|
+
description = _this$props4.description,
|
|
76
|
+
descriptionRole = _this$props4.descriptionRole,
|
|
75
77
|
renderBeforeLabel = _this$props4.renderBeforeLabel,
|
|
76
78
|
renderAfterLabel = _this$props4.renderAfterLabel,
|
|
77
79
|
children = _this$props4.children;
|
|
78
80
|
const ElementType = (0, _uiReactUtils.getElementType)(Item, this.props, () => as);
|
|
79
81
|
const passthroughProps = (0, _uiReactUtils.omitProps)(this.props, Item.allowedProps);
|
|
82
|
+
const childrenContent = (0, _uiReactUtils.callRenderProp)(children);
|
|
83
|
+
const descriptionContent = (0, _uiReactUtils.callRenderProp)(description);
|
|
80
84
|
return (0, _emotion.jsx)(ElementType, {
|
|
81
85
|
role: "none",
|
|
82
86
|
css: styles === null || styles === void 0 ? void 0 : styles.item,
|
|
@@ -86,16 +90,19 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
86
90
|
}, (0, _emotion.jsx)("span", Object.assign({}, passthroughProps, {
|
|
87
91
|
css: styles === null || styles === void 0 ? void 0 : styles.container,
|
|
88
92
|
role: role
|
|
89
|
-
}),
|
|
93
|
+
}), childrenContent, descriptionContent && (0, _emotion.jsx)("span", {
|
|
94
|
+
css: styles === null || styles === void 0 ? void 0 : styles.description,
|
|
95
|
+
role: descriptionRole
|
|
96
|
+
}, descriptionContent)), renderBeforeLabel && this.renderContent(renderBeforeLabel, styles === null || styles === void 0 ? void 0 : styles.contentBefore), renderAfterLabel && this.renderContent(renderAfterLabel, styles === null || styles === void 0 ? void 0 : styles.contentAfter));
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
}, _class2.displayName = "Item", _class2.componentId = 'Options.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
93
100
|
as: 'span',
|
|
94
101
|
variant: 'default',
|
|
95
102
|
role: 'listitem',
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
descriptionRole: 'note',
|
|
104
|
+
beforeLabelContentVAlign: 'center',
|
|
105
|
+
afterLabelContentVAlign: 'center'
|
|
99
106
|
}, _temp)) || _class) || _class);
|
|
100
107
|
exports.Item = Item;
|
|
101
108
|
var _default = Item;
|
|
@@ -38,8 +38,12 @@ const propTypes = {
|
|
|
38
38
|
role: _propTypes.default.string,
|
|
39
39
|
renderBeforeLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
40
40
|
renderAfterLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
41
|
+
beforeLabelContentVAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
42
|
+
afterLabelContentVAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
|
|
43
|
+
description: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
44
|
+
descriptionRole: _propTypes.default.string,
|
|
41
45
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
|
|
42
46
|
};
|
|
43
47
|
exports.propTypes = propTypes;
|
|
44
|
-
const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'children'];
|
|
48
|
+
const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'children'];
|
|
45
49
|
exports.allowedProps = allowedProps;
|
|
@@ -45,8 +45,11 @@ const generateStyle = (componentTheme, props) => {
|
|
|
45
45
|
const variant = props.variant,
|
|
46
46
|
children = props.children,
|
|
47
47
|
hasContentBeforeLabel = props.renderBeforeLabel,
|
|
48
|
-
hasContentAfterLabel = props.renderAfterLabel
|
|
49
|
-
|
|
48
|
+
hasContentAfterLabel = props.renderAfterLabel,
|
|
49
|
+
beforeLabelContentVAlign = props.beforeLabelContentVAlign,
|
|
50
|
+
afterLabelContentVAlign = props.afterLabelContentVAlign;
|
|
51
|
+
const containsList = (0, _uiReactUtils.matchComponentTypes)(children, ['Options']); // used for label and description too
|
|
52
|
+
|
|
50
53
|
const variantVariants = {
|
|
51
54
|
highlighted: {
|
|
52
55
|
background: componentTheme.highlightedBackground,
|
|
@@ -62,6 +65,28 @@ const generateStyle = (componentTheme, props) => {
|
|
|
62
65
|
},
|
|
63
66
|
default: {}
|
|
64
67
|
};
|
|
68
|
+
|
|
69
|
+
const getContentVAlign = type => {
|
|
70
|
+
const vAlign = type === 'before' ? beforeLabelContentVAlign : afterLabelContentVAlign;
|
|
71
|
+
const vOffset = type === 'before' ? componentTheme.beforeLabelContentVOffset : componentTheme.afterLabelContentVOffset;
|
|
72
|
+
return {
|
|
73
|
+
start: {
|
|
74
|
+
alignItems: 'flex-start',
|
|
75
|
+
paddingBlockStart: vOffset
|
|
76
|
+
},
|
|
77
|
+
center: {
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
paddingBlockStart: vOffset,
|
|
80
|
+
paddingBlockEnd: vOffset
|
|
81
|
+
},
|
|
82
|
+
end: {
|
|
83
|
+
alignItems: 'flex-end',
|
|
84
|
+
paddingBlockEnd: vOffset
|
|
85
|
+
}
|
|
86
|
+
}[vAlign];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const transition = 'background 200ms';
|
|
65
90
|
return {
|
|
66
91
|
item: {
|
|
67
92
|
label: 'optionItem',
|
|
@@ -75,7 +100,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
75
100
|
lineHeight: componentTheme.lineHeight,
|
|
76
101
|
outline: 'none',
|
|
77
102
|
position: 'relative',
|
|
78
|
-
transition
|
|
103
|
+
transition,
|
|
79
104
|
userSelect: 'none',
|
|
80
105
|
...variantVariants[variant],
|
|
81
106
|
...(containsList && {
|
|
@@ -115,9 +140,9 @@ const generateStyle = (componentTheme, props) => {
|
|
|
115
140
|
},
|
|
116
141
|
content: {
|
|
117
142
|
label: 'optionItem__content',
|
|
118
|
-
alignItems: 'center',
|
|
119
143
|
display: 'flex',
|
|
120
144
|
height: '100%',
|
|
145
|
+
boxSizing: 'border-box',
|
|
121
146
|
pointerEvents: 'none',
|
|
122
147
|
position: 'absolute',
|
|
123
148
|
top: '0'
|
|
@@ -125,12 +150,27 @@ const generateStyle = (componentTheme, props) => {
|
|
|
125
150
|
contentBefore: {
|
|
126
151
|
label: 'optionItem__content--before',
|
|
127
152
|
insetInlineEnd: 'auto',
|
|
128
|
-
insetInlineStart: componentTheme.iconPadding
|
|
153
|
+
insetInlineStart: componentTheme.iconPadding,
|
|
154
|
+
...getContentVAlign('before')
|
|
129
155
|
},
|
|
130
156
|
contentAfter: {
|
|
131
157
|
label: 'optionItem__content--after',
|
|
132
158
|
insetInlineEnd: componentTheme.iconPadding,
|
|
133
|
-
insetInlineStart: 'auto'
|
|
159
|
+
insetInlineStart: 'auto',
|
|
160
|
+
...getContentVAlign('after')
|
|
161
|
+
},
|
|
162
|
+
description: {
|
|
163
|
+
label: 'optionItem__description',
|
|
164
|
+
display: 'block',
|
|
165
|
+
transition,
|
|
166
|
+
paddingBlockStart: componentTheme.descriptionPaddingStart,
|
|
167
|
+
fontWeight: componentTheme.descriptionFontWeight,
|
|
168
|
+
fontSize: componentTheme.descriptionFontSize,
|
|
169
|
+
lineHeight: componentTheme.descriptionLineHeight,
|
|
170
|
+
color: componentTheme.descriptionColor,
|
|
171
|
+
...variantVariants[variant],
|
|
172
|
+
background: 'none' // needed to clear variant background
|
|
173
|
+
|
|
134
174
|
}
|
|
135
175
|
};
|
|
136
176
|
};
|
|
@@ -58,7 +58,14 @@ const generateComponentTheme = theme => {
|
|
|
58
58
|
selectedBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundDark,
|
|
59
59
|
padding: `${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall} ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`,
|
|
60
60
|
iconPadding: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
61
|
-
nestedPadding: spacing === null || spacing === void 0 ? void 0 : spacing.medium
|
|
61
|
+
nestedPadding: spacing === null || spacing === void 0 ? void 0 : spacing.medium,
|
|
62
|
+
beforeLabelContentVOffset: '0.625rem',
|
|
63
|
+
afterLabelContentVOffset: '0.625rem',
|
|
64
|
+
descriptionFontSize: typography.fontSizeSmall,
|
|
65
|
+
descriptionFontWeight: typography.fontWeightNormal,
|
|
66
|
+
descriptionLineHeight: typography.lineHeight,
|
|
67
|
+
descriptionPaddingStart: '0.25em',
|
|
68
|
+
descriptionColor: colors.textDark
|
|
62
69
|
};
|
|
63
70
|
return { ...componentVariables,
|
|
64
71
|
...themeSpecificStyle[themeName]
|
package/lib/Options/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", {
|
|
@@ -7,7 +9,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
9
|
});
|
|
8
10
|
exports.default = exports.Options = void 0;
|
|
9
11
|
|
|
10
|
-
var _react = require("react");
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
13
15
|
|
|
@@ -83,13 +85,13 @@ let Options = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
83
85
|
}, (0, _uiReactUtils.callRenderProp)(renderLabel));
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
renderSubList(
|
|
88
|
+
renderSubList(subOptions) {
|
|
87
89
|
const styles = this.props.styles;
|
|
88
90
|
return (0, _emotion.jsx)(_Item.Item, {
|
|
89
91
|
as: this.childAs,
|
|
90
92
|
role: "presentation",
|
|
91
93
|
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
92
|
-
},
|
|
94
|
+
}, subOptions);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
renderChildren() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-options",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.15.1-snapshot.2+00f55c738",
|
|
4
4
|
"description": "A view-only component for composing interactive lists and menus.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/ui-babel-preset": "8.
|
|
28
|
-
"@instructure/ui-color-utils": "8.
|
|
29
|
-
"@instructure/ui-test-locator": "8.
|
|
30
|
-
"@instructure/ui-test-utils": "8.
|
|
31
|
-
"@instructure/ui-themes": "8.
|
|
27
|
+
"@instructure/ui-babel-preset": "8.15.1-snapshot.2+00f55c738",
|
|
28
|
+
"@instructure/ui-color-utils": "8.15.1-snapshot.2+00f55c738",
|
|
29
|
+
"@instructure/ui-test-locator": "8.15.1-snapshot.2+00f55c738",
|
|
30
|
+
"@instructure/ui-test-utils": "8.15.1-snapshot.2+00f55c738",
|
|
31
|
+
"@instructure/ui-themes": "8.15.1-snapshot.2+00f55c738"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.13.10",
|
|
35
|
-
"@instructure/emotion": "8.
|
|
36
|
-
"@instructure/shared-types": "8.
|
|
37
|
-
"@instructure/ui-icons": "8.
|
|
38
|
-
"@instructure/ui-prop-types": "8.
|
|
39
|
-
"@instructure/ui-react-utils": "8.
|
|
40
|
-
"@instructure/ui-testable": "8.
|
|
41
|
-
"@instructure/ui-view": "8.
|
|
42
|
-
"@instructure/uid": "8.
|
|
35
|
+
"@instructure/emotion": "8.15.1-snapshot.2+00f55c738",
|
|
36
|
+
"@instructure/shared-types": "8.15.1-snapshot.2+00f55c738",
|
|
37
|
+
"@instructure/ui-icons": "8.15.1-snapshot.2+00f55c738",
|
|
38
|
+
"@instructure/ui-prop-types": "8.15.1-snapshot.2+00f55c738",
|
|
39
|
+
"@instructure/ui-react-utils": "8.15.1-snapshot.2+00f55c738",
|
|
40
|
+
"@instructure/ui-testable": "8.15.1-snapshot.2+00f55c738",
|
|
41
|
+
"@instructure/ui-view": "8.15.1-snapshot.2+00f55c738",
|
|
42
|
+
"@instructure/uid": "8.15.1-snapshot.2+00f55c738",
|
|
43
43
|
"prop-types": "^15"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "00f55c7382e82209ea553c107951c4356ba202bf"
|
|
53
53
|
}
|
|
@@ -23,20 +23,59 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons'
|
|
26
|
-
import {
|
|
26
|
+
import type { StoryConfig } from '@instructure/ui-test-utils'
|
|
27
|
+
import type { OptionsItemProps } from '../props'
|
|
27
28
|
|
|
28
29
|
export default {
|
|
29
30
|
maxExamplesPerPage: 50,
|
|
30
31
|
propValues: {
|
|
31
32
|
renderAfterLabel: [null, IconArrowOpenEndSolid],
|
|
32
|
-
renderBeforeLabel: [null, IconCheckSolid]
|
|
33
|
+
renderBeforeLabel: [null, IconCheckSolid],
|
|
34
|
+
description: [
|
|
35
|
+
null,
|
|
36
|
+
'Curabitur fringilla, urna ut efficitur molestie, nibh lacus tincidunt elit, ut tempor ipsum nunc sit amet massa. Integer sit amet ante vitae lectus gravida pulvinar.'
|
|
37
|
+
]
|
|
33
38
|
},
|
|
34
|
-
getComponentProps: (props
|
|
39
|
+
getComponentProps: (props) => {
|
|
35
40
|
return {
|
|
36
41
|
renderAfterLabel: props.renderAfterLabel,
|
|
37
42
|
renderBeforeLabel: props.renderBeforeLabel,
|
|
38
43
|
children: 'Lorem ipsum dolor sit amet',
|
|
39
|
-
role: 'none'
|
|
44
|
+
role: 'none',
|
|
45
|
+
descriptionRole: 'note'
|
|
40
46
|
}
|
|
47
|
+
},
|
|
48
|
+
getExampleProps: () => {
|
|
49
|
+
return {
|
|
50
|
+
width: '400px'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
filter: (props) => {
|
|
54
|
+
if (props.description) {
|
|
55
|
+
if (
|
|
56
|
+
props.beforeLabelContentVAlign !== 'center' &&
|
|
57
|
+
(!props.renderBeforeLabel || props.renderAfterLabel)
|
|
58
|
+
) {
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
props.afterLabelContentVAlign !== 'center' &&
|
|
64
|
+
(!props.renderAfterLabel || props.renderBeforeLabel)
|
|
65
|
+
) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!props.description) {
|
|
71
|
+
if (
|
|
72
|
+
props.afterLabelContentVAlign !== 'center' ||
|
|
73
|
+
props.beforeLabelContentVAlign !== 'center'
|
|
74
|
+
) {
|
|
75
|
+
return true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return false
|
|
41
80
|
}
|
|
42
|
-
}
|
|
81
|
+
} as StoryConfig<OptionsItemProps>
|