@instructure/ui-options 8.20.1-snapshot.5 → 8.21.0

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 CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.21.0](https://github.com/instructure/instructure-ui/compare/v8.20.0...v8.21.0) (2022-03-30)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-options
9
+
6
10
  # [8.20.0](https://github.com/instructure/instructure-ui/compare/v8.19.0...v8.20.0) (2022-03-22)
7
11
 
8
12
  ### Features
@@ -114,6 +114,18 @@ let Options = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyles, g
114
114
  });
115
115
  }
116
116
 
117
+ get ariaLabelledby() {
118
+ if (this.props.renderLabel) {
119
+ return this._labelId;
120
+ }
121
+
122
+ if (this.props['aria-labelledby']) {
123
+ return this.props['aria-labelledby'];
124
+ }
125
+
126
+ return void 0;
127
+ }
128
+
117
129
  render() {
118
130
  const passthroughProps = View.omitViewProps(omitProps(this.props, Options.allowedProps), Options);
119
131
  const _this$props4 = this.props,
@@ -135,7 +147,7 @@ let Options = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyles, g
135
147
  margin: "none",
136
148
  padding: "none",
137
149
  background: "primary",
138
- "aria-labelledby": renderLabel ? this._labelId : this.props['aria-labelledby'] ? this.props['aria-labelledby'] : void 0
150
+ "aria-labelledby": this.ariaLabelledby
139
151
  }), this.renderChildren()));
140
152
  }
141
153
 
@@ -21,18 +21,16 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- const optionsThemeKeys = ['labelFontWeight', 'background', 'labelColor', 'labelPadding', 'nestedLabelPadding'];
24
+
25
25
  /**
26
26
  * Generates the theme object for the component from the theme and provided additional information
27
27
  * @param {Object} theme The actual theme object.
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
-
31
30
  const generateComponentTheme = theme => {
32
31
  const colors = theme.colors,
33
32
  typography = theme.typography,
34
- spacing = theme.spacing; // TODO: if updated, update optionsThemeKeys array too
35
-
33
+ spacing = theme.spacing;
36
34
  const componentVariables = {
37
35
  labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
38
36
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
@@ -44,5 +42,5 @@ const generateComponentTheme = theme => {
44
42
  };
45
43
  };
46
44
 
47
- export { generateComponentTheme as optionsThemeGenerator, optionsThemeKeys };
45
+ export { generateComponentTheme as optionsThemeGenerator };
48
46
  export default generateComponentTheme;
package/es/index.js CHANGED
@@ -22,6 +22,6 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  export { Options } from './Options';
25
- export { optionsThemeGenerator, optionsThemeKeys } from './Options/theme';
25
+ export { optionsThemeGenerator } from './Options/theme';
26
26
  export { optionsItemThemeGenerator } from './Options/Item/theme';
27
27
  export { optionsSeparatorThemeGenerator } from './Options/Separator/theme';
@@ -109,6 +109,18 @@ let Options = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emo
109
109
  });
110
110
  }
111
111
 
112
+ get ariaLabelledby() {
113
+ if (this.props.renderLabel) {
114
+ return this._labelId;
115
+ }
116
+
117
+ if (this.props['aria-labelledby']) {
118
+ return this.props['aria-labelledby'];
119
+ }
120
+
121
+ return void 0;
122
+ }
123
+
112
124
  render() {
113
125
  const passthroughProps = _uiView.View.omitViewProps((0, _uiReactUtils.omitProps)(this.props, Options.allowedProps), Options);
114
126
 
@@ -131,7 +143,7 @@ let Options = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emo
131
143
  margin: "none",
132
144
  padding: "none",
133
145
  background: "primary",
134
- "aria-labelledby": renderLabel ? this._labelId : this.props['aria-labelledby'] ? this.props['aria-labelledby'] : void 0
146
+ "aria-labelledby": this.ariaLabelledby
135
147
  }), this.renderChildren()));
136
148
  }
137
149
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.optionsThemeKeys = exports.optionsThemeGenerator = exports.default = void 0;
6
+ exports.optionsThemeGenerator = exports.default = void 0;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -28,20 +28,16 @@ exports.optionsThemeKeys = exports.optionsThemeGenerator = exports.default = voi
28
28
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
29
  * SOFTWARE.
30
30
  */
31
- const optionsThemeKeys = ['labelFontWeight', 'background', 'labelColor', 'labelPadding', 'nestedLabelPadding'];
31
+
32
32
  /**
33
33
  * Generates the theme object for the component from the theme and provided additional information
34
34
  * @param {Object} theme The actual theme object.
35
35
  * @return {Object} The final theme object with the overrides and component variables
36
36
  */
37
-
38
- exports.optionsThemeKeys = optionsThemeKeys;
39
-
40
37
  const generateComponentTheme = theme => {
41
38
  const colors = theme.colors,
42
39
  typography = theme.typography,
43
- spacing = theme.spacing; // TODO: if updated, update optionsThemeKeys array too
44
-
40
+ spacing = theme.spacing;
45
41
  const componentVariables = {
46
42
  labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
47
43
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
package/lib/index.js CHANGED
@@ -27,12 +27,6 @@ Object.defineProperty(exports, "optionsThemeGenerator", {
27
27
  return _theme.optionsThemeGenerator;
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "optionsThemeKeys", {
31
- enumerable: true,
32
- get: function () {
33
- return _theme.optionsThemeKeys;
34
- }
35
- });
36
30
 
37
31
  var _Options = require("./Options");
38
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-options",
3
- "version": "8.20.1-snapshot.5+b20e944b1",
3
+ "version": "8.21.0",
4
4
  "description": "A view-only component for composing interactive lists and menus.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,21 +23,21 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.20.1-snapshot.5+b20e944b1",
27
- "@instructure/ui-color-utils": "8.20.1-snapshot.5+b20e944b1",
28
- "@instructure/ui-test-locator": "8.20.1-snapshot.5+b20e944b1",
29
- "@instructure/ui-test-utils": "8.20.1-snapshot.5+b20e944b1",
30
- "@instructure/ui-themes": "8.20.1-snapshot.5+b20e944b1"
26
+ "@instructure/ui-babel-preset": "8.21.0",
27
+ "@instructure/ui-color-utils": "8.21.0",
28
+ "@instructure/ui-test-locator": "8.21.0",
29
+ "@instructure/ui-test-utils": "8.21.0",
30
+ "@instructure/ui-themes": "8.21.0"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.13.10",
34
- "@instructure/emotion": "8.20.1-snapshot.5+b20e944b1",
35
- "@instructure/shared-types": "8.20.1-snapshot.5+b20e944b1",
36
- "@instructure/ui-icons": "8.20.1-snapshot.5+b20e944b1",
37
- "@instructure/ui-prop-types": "8.20.1-snapshot.5+b20e944b1",
38
- "@instructure/ui-react-utils": "8.20.1-snapshot.5+b20e944b1",
39
- "@instructure/ui-testable": "8.20.1-snapshot.5+b20e944b1",
40
- "@instructure/ui-view": "8.20.1-snapshot.5+b20e944b1",
34
+ "@instructure/emotion": "8.21.0",
35
+ "@instructure/shared-types": "8.21.0",
36
+ "@instructure/ui-icons": "8.21.0",
37
+ "@instructure/ui-prop-types": "8.21.0",
38
+ "@instructure/ui-react-utils": "8.21.0",
39
+ "@instructure/ui-testable": "8.21.0",
40
+ "@instructure/ui-view": "8.21.0",
41
41
  "prop-types": "^15"
42
42
  },
43
43
  "peerDependencies": {
@@ -46,6 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "sideEffects": false,
50
- "gitHead": "b20e944b13616f430d7b27eb61ccdb3eb3c87fcf"
49
+ "sideEffects": false
51
50
  }
@@ -140,6 +140,18 @@ class Options extends Component<OptionsProps> {
140
140
  })
141
141
  }
142
142
 
143
+ get ariaLabelledby() {
144
+ if (this.props.renderLabel) {
145
+ return this._labelId
146
+ }
147
+
148
+ if (this.props['aria-labelledby']) {
149
+ return this.props['aria-labelledby']
150
+ }
151
+
152
+ return undefined
153
+ }
154
+
143
155
  render() {
144
156
  const passthroughProps = View.omitViewProps(
145
157
  omitProps(this.props, Options.allowedProps),
@@ -161,13 +173,7 @@ class Options extends Component<OptionsProps> {
161
173
  margin="none"
162
174
  padding="none"
163
175
  background="primary"
164
- aria-labelledby={
165
- renderLabel
166
- ? this._labelId
167
- : this.props['aria-labelledby']
168
- ? this.props['aria-labelledby']
169
- : undefined
170
- }
176
+ aria-labelledby={this.ariaLabelledby}
171
177
  >
172
178
  {this.renderChildren()}
173
179
  </View>
@@ -52,6 +52,7 @@ type OptionsOwnProps = {
52
52
  * Content to render as a label. Mostly for when the component is nested
53
53
  */
54
54
  renderLabel?: React.ReactNode | (() => React.ReactNode)
55
+
55
56
  //TODO children has to be typed better
56
57
  //e.g.: ChildrenPropTypes.oneOf(['Options', 'Item', 'Separator']))
57
58
  children?: React.ReactNode
@@ -63,7 +64,8 @@ type AllowedPropKeys = Readonly<Array<PropKeys>>
63
64
 
64
65
  type OptionsProps = OptionsOwnProps &
65
66
  WithStyleProps<OptionsTheme, OptionsStyle> &
66
- OtherHTMLAttributes<OptionsOwnProps> & WithDeterministicIdProps
67
+ OtherHTMLAttributes<OptionsOwnProps> &
68
+ WithDeterministicIdProps
67
69
 
68
70
  type OptionsStyle = ComponentStyle<'options' | 'list' | 'label'>
69
71
 
@@ -25,14 +25,6 @@
25
25
  import type { Theme } from '@instructure/ui-themes'
26
26
  import type { OptionsTheme } from '@instructure/shared-types'
27
27
 
28
- const optionsThemeKeys: (keyof OptionsTheme)[] = [
29
- 'labelFontWeight',
30
- 'background',
31
- 'labelColor',
32
- 'labelPadding',
33
- 'nestedLabelPadding'
34
- ]
35
-
36
28
  /**
37
29
  * Generates the theme object for the component from the theme and provided additional information
38
30
  * @param {Object} theme The actual theme object.
@@ -41,7 +33,6 @@ const optionsThemeKeys: (keyof OptionsTheme)[] = [
41
33
  const generateComponentTheme = (theme: Theme): OptionsTheme => {
42
34
  const { colors, typography, spacing } = theme
43
35
 
44
- // TODO: if updated, update optionsThemeKeys array too
45
36
  const componentVariables: OptionsTheme = {
46
37
  labelFontWeight: typography?.fontWeightBold,
47
38
 
@@ -57,5 +48,5 @@ const generateComponentTheme = (theme: Theme): OptionsTheme => {
57
48
  }
58
49
  }
59
50
 
60
- export { generateComponentTheme as optionsThemeGenerator, optionsThemeKeys }
51
+ export { generateComponentTheme as optionsThemeGenerator }
61
52
  export default generateComponentTheme
package/src/index.ts CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  export { Options } from './Options'
26
26
 
27
- export { optionsThemeGenerator, optionsThemeKeys } from './Options/theme'
27
+ export { optionsThemeGenerator } from './Options/theme'
28
28
  export { optionsItemThemeGenerator } from './Options/Item/theme'
29
29
  export { optionsSeparatorThemeGenerator } from './Options/Separator/theme'
30
30