@instructure/ui-options 8.19.0 → 8.19.1-snapshot.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.
Files changed (37) hide show
  1. package/LICENSE.md +27 -0
  2. package/es/Options/Item/index.js +5 -0
  3. package/es/Options/Item/props.js +2 -1
  4. package/es/Options/Item/styles.js +1 -0
  5. package/es/Options/Item/theme.js +1 -0
  6. package/es/Options/Separator/theme.js +1 -0
  7. package/es/Options/theme.js +5 -2
  8. package/es/index.js +4 -1
  9. package/lib/Options/Item/index.js +5 -0
  10. package/lib/Options/Item/props.js +2 -1
  11. package/lib/Options/Item/styles.js +1 -0
  12. package/lib/Options/Item/theme.js +2 -1
  13. package/lib/Options/Separator/theme.js +2 -1
  14. package/lib/Options/theme.js +8 -3
  15. package/lib/index.js +31 -1
  16. package/package.json +15 -14
  17. package/src/Options/Item/index.tsx +6 -1
  18. package/src/Options/Item/props.ts +6 -0
  19. package/src/Options/Item/styles.ts +1 -0
  20. package/src/Options/Item/theme.ts +1 -0
  21. package/src/Options/Separator/theme.ts +1 -0
  22. package/src/Options/theme.ts +11 -1
  23. package/src/index.ts +4 -0
  24. package/tsconfig.build.tsbuildinfo +1 -1
  25. package/types/Options/Item/index.d.ts +2 -2
  26. package/types/Options/Item/index.d.ts.map +1 -1
  27. package/types/Options/Item/props.d.ts +4 -0
  28. package/types/Options/Item/props.d.ts.map +1 -1
  29. package/types/Options/Item/styles.d.ts.map +1 -1
  30. package/types/Options/Item/theme.d.ts +1 -0
  31. package/types/Options/Item/theme.d.ts.map +1 -1
  32. package/types/Options/Separator/theme.d.ts +1 -0
  33. package/types/Options/Separator/theme.d.ts.map +1 -1
  34. package/types/Options/theme.d.ts +3 -1
  35. package/types/Options/theme.d.ts.map +1 -1
  36. package/types/index.d.ts +3 -0
  37. package/types/index.d.ts.map +1 -1
package/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ ---
6
+
7
+ # The MIT License (MIT)
8
+
9
+ Copyright (c) 2015 Instructure, Inc.
10
+
11
+ **Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions.**
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -86,6 +86,7 @@ let Item = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = te
86
86
  descriptionRole = _this$props4.descriptionRole,
87
87
  renderBeforeLabel = _this$props4.renderBeforeLabel,
88
88
  renderAfterLabel = _this$props4.renderAfterLabel,
89
+ elementRef = _this$props4.elementRef,
89
90
  children = _this$props4.children;
90
91
  const ElementType = getElementType(Item, this.props, () => as);
91
92
  const passthroughProps = omitProps(this.props, Item.allowedProps);
@@ -96,6 +97,10 @@ let Item = (_dec = withStyle(generateStyles, generateComponentTheme), _dec2 = te
96
97
  css: styles === null || styles === void 0 ? void 0 : styles.item,
97
98
  ref: element => {
98
99
  this.ref = element;
100
+
101
+ if (typeof elementRef === 'function') {
102
+ elementRef(element);
103
+ }
99
104
  }
100
105
  }, jsx("span", Object.assign({}, passthroughProps, {
101
106
  css: styles === null || styles === void 0 ? void 0 : styles.container,
@@ -32,7 +32,8 @@ const propTypes = {
32
32
  afterLabelContentVAlign: PropTypes.oneOf(['start', 'center', 'end']),
33
33
  description: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
34
34
  descriptionRole: PropTypes.string,
35
+ elementRef: PropTypes.func,
35
36
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
36
37
  };
37
- const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'children'];
38
+ const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'elementRef', 'children'];
38
39
  export { propTypes, allowedProps };
@@ -113,6 +113,7 @@ const generateStyle = (componentTheme, props) => {
113
113
  container: {
114
114
  label: 'optionItem__container',
115
115
  display: 'block',
116
+ outline: 'none',
116
117
  padding: componentTheme.padding,
117
118
  ...(containsList && {
118
119
  padding: '0'
@@ -65,4 +65,5 @@ const generateComponentTheme = theme => {
65
65
  };
66
66
  };
67
67
 
68
+ export { generateComponentTheme as optionsItemThemeGenerator };
68
69
  export default generateComponentTheme;
@@ -40,4 +40,5 @@ const generateComponentTheme = theme => {
40
40
  };
41
41
  };
42
42
 
43
+ export { generateComponentTheme as optionsSeparatorThemeGenerator };
43
44
  export default generateComponentTheme;
@@ -21,16 +21,18 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
-
24
+ const optionsThemeKeys = ['labelFontWeight', 'background', 'labelColor', 'labelPadding', 'nestedLabelPadding'];
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
+
30
31
  const generateComponentTheme = theme => {
31
32
  const colors = theme.colors,
32
33
  typography = theme.typography,
33
- spacing = theme.spacing;
34
+ spacing = theme.spacing; // TODO: if updated, update optionsThemeKeys array too
35
+
34
36
  const componentVariables = {
35
37
  labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
36
38
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
@@ -42,4 +44,5 @@ const generateComponentTheme = theme => {
42
44
  };
43
45
  };
44
46
 
47
+ export { generateComponentTheme as optionsThemeGenerator, optionsThemeKeys };
45
48
  export default generateComponentTheme;
package/es/index.js CHANGED
@@ -21,4 +21,7 @@
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 { Options } from './Options';
24
+ export { Options } from './Options';
25
+ export { optionsThemeGenerator, optionsThemeKeys } from './Options/theme';
26
+ export { optionsItemThemeGenerator } from './Options/Item/theme';
27
+ export { optionsSeparatorThemeGenerator } from './Options/Separator/theme';
@@ -76,6 +76,7 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
76
76
  descriptionRole = _this$props4.descriptionRole,
77
77
  renderBeforeLabel = _this$props4.renderBeforeLabel,
78
78
  renderAfterLabel = _this$props4.renderAfterLabel,
79
+ elementRef = _this$props4.elementRef,
79
80
  children = _this$props4.children;
80
81
  const ElementType = (0, _uiReactUtils.getElementType)(Item, this.props, () => as);
81
82
  const passthroughProps = (0, _uiReactUtils.omitProps)(this.props, Item.allowedProps);
@@ -86,6 +87,10 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
86
87
  css: styles === null || styles === void 0 ? void 0 : styles.item,
87
88
  ref: element => {
88
89
  this.ref = element;
90
+
91
+ if (typeof elementRef === 'function') {
92
+ elementRef(element);
93
+ }
89
94
  }
90
95
  }, (0, _emotion.jsx)("span", Object.assign({}, passthroughProps, {
91
96
  css: styles === null || styles === void 0 ? void 0 : styles.container,
@@ -42,8 +42,9 @@ const propTypes = {
42
42
  afterLabelContentVAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
43
43
  description: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
44
44
  descriptionRole: _propTypes.default.string,
45
+ elementRef: _propTypes.default.func,
45
46
  children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
46
47
  };
47
48
  exports.propTypes = propTypes;
48
- const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'children'];
49
+ const allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'elementRef', 'children'];
49
50
  exports.allowedProps = allowedProps;
@@ -121,6 +121,7 @@ const generateStyle = (componentTheme, props) => {
121
121
  container: {
122
122
  label: 'optionItem__container',
123
123
  display: 'block',
124
+ outline: 'none',
124
125
  padding: componentTheme.padding,
125
126
  ...(containsList && {
126
127
  padding: '0'
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.optionsItemThemeGenerator = exports.default = void 0;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -72,5 +72,6 @@ const generateComponentTheme = theme => {
72
72
  };
73
73
  };
74
74
 
75
+ exports.optionsItemThemeGenerator = generateComponentTheme;
75
76
  var _default = generateComponentTheme;
76
77
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.optionsSeparatorThemeGenerator = exports.default = void 0;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -47,5 +47,6 @@ const generateComponentTheme = theme => {
47
47
  };
48
48
  };
49
49
 
50
+ exports.optionsSeparatorThemeGenerator = generateComponentTheme;
50
51
  var _default = generateComponentTheme;
51
52
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.optionsThemeKeys = exports.optionsThemeGenerator = exports.default = void 0;
7
7
 
8
8
  /*
9
9
  * The MIT License (MIT)
@@ -28,16 +28,20 @@ exports.default = void 0;
28
28
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
29
  * SOFTWARE.
30
30
  */
31
-
31
+ const optionsThemeKeys = ['labelFontWeight', 'background', 'labelColor', 'labelPadding', 'nestedLabelPadding'];
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
+
37
40
  const generateComponentTheme = theme => {
38
41
  const colors = theme.colors,
39
42
  typography = theme.typography,
40
- spacing = theme.spacing;
43
+ spacing = theme.spacing; // TODO: if updated, update optionsThemeKeys array too
44
+
41
45
  const componentVariables = {
42
46
  labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
43
47
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
@@ -49,5 +53,6 @@ const generateComponentTheme = theme => {
49
53
  };
50
54
  };
51
55
 
56
+ exports.optionsThemeGenerator = generateComponentTheme;
52
57
  var _default = generateComponentTheme;
53
58
  exports.default = _default;
package/lib/index.js CHANGED
@@ -9,5 +9,35 @@ Object.defineProperty(exports, "Options", {
9
9
  return _Options.Options;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "optionsItemThemeGenerator", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _theme2.optionsItemThemeGenerator;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "optionsSeparatorThemeGenerator", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _theme3.optionsSeparatorThemeGenerator;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "optionsThemeGenerator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _theme.optionsThemeGenerator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "optionsThemeKeys", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _theme.optionsThemeKeys;
34
+ }
35
+ });
36
+
37
+ var _Options = require("./Options");
38
+
39
+ var _theme = require("./Options/theme");
40
+
41
+ var _theme2 = require("./Options/Item/theme");
12
42
 
13
- var _Options = require("./Options");
43
+ var _theme3 = require("./Options/Separator/theme");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-options",
3
- "version": "8.19.0",
3
+ "version": "8.19.1-snapshot.0+257cc2783",
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.19.0",
27
- "@instructure/ui-color-utils": "8.19.0",
28
- "@instructure/ui-test-locator": "8.19.0",
29
- "@instructure/ui-test-utils": "8.19.0",
30
- "@instructure/ui-themes": "8.19.0"
26
+ "@instructure/ui-babel-preset": "8.19.1-snapshot.0+257cc2783",
27
+ "@instructure/ui-color-utils": "8.19.1-snapshot.0+257cc2783",
28
+ "@instructure/ui-test-locator": "8.19.1-snapshot.0+257cc2783",
29
+ "@instructure/ui-test-utils": "8.19.1-snapshot.0+257cc2783",
30
+ "@instructure/ui-themes": "8.19.1-snapshot.0+257cc2783"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.13.10",
34
- "@instructure/emotion": "8.19.0",
35
- "@instructure/shared-types": "8.19.0",
36
- "@instructure/ui-icons": "8.19.0",
37
- "@instructure/ui-prop-types": "8.19.0",
38
- "@instructure/ui-react-utils": "8.19.0",
39
- "@instructure/ui-testable": "8.19.0",
40
- "@instructure/ui-view": "8.19.0",
34
+ "@instructure/emotion": "8.19.1-snapshot.0+257cc2783",
35
+ "@instructure/shared-types": "8.19.1-snapshot.0+257cc2783",
36
+ "@instructure/ui-icons": "8.19.1-snapshot.0+257cc2783",
37
+ "@instructure/ui-prop-types": "8.19.1-snapshot.0+257cc2783",
38
+ "@instructure/ui-react-utils": "8.19.1-snapshot.0+257cc2783",
39
+ "@instructure/ui-testable": "8.19.1-snapshot.0+257cc2783",
40
+ "@instructure/ui-view": "8.19.1-snapshot.0+257cc2783",
41
41
  "prop-types": "^15"
42
42
  },
43
43
  "peerDependencies": {
@@ -46,5 +46,6 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "sideEffects": false
49
+ "sideEffects": false,
50
+ "gitHead": "257cc27836b9f56296eb692e601bc7acda4e1d1e"
50
51
  }
@@ -108,6 +108,7 @@ class Item extends Component<OptionsItemProps> {
108
108
  descriptionRole,
109
109
  renderBeforeLabel,
110
110
  renderAfterLabel,
111
+ elementRef,
111
112
  children
112
113
  } = this.props
113
114
 
@@ -122,8 +123,12 @@ class Item extends Component<OptionsItemProps> {
122
123
  role="none"
123
124
  css={styles?.item}
124
125
  // @ts-expect-error TODO: fix produces an union that is too complex to represent
125
- ref={(element: any) => {
126
+ ref={(element: Element | null) => {
126
127
  this.ref = element
128
+
129
+ if (typeof elementRef === 'function') {
130
+ elementRef(element)
131
+ }
127
132
  }}
128
133
  >
129
134
  <span {...passthroughProps} css={styles?.container} role={role}>
@@ -76,6 +76,10 @@ type OptionsItemOwnProps = ItemProps & {
76
76
  * The ARIA role of the description element
77
77
  */
78
78
  descriptionRole?: string
79
+ /**
80
+ * provides a reference to the underlying html root element
81
+ */
82
+ elementRef?: (element: Element | null) => void
79
83
  }
80
84
 
81
85
  type PropKeys = keyof OptionsItemOwnProps
@@ -105,6 +109,7 @@ const propTypes: PropValidators<PropKeys> = {
105
109
  afterLabelContentVAlign: PropTypes.oneOf(['start', 'center', 'end']),
106
110
  description: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
107
111
  descriptionRole: PropTypes.string,
112
+ elementRef: PropTypes.func,
108
113
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
109
114
  }
110
115
 
@@ -118,6 +123,7 @@ const allowedProps: AllowedPropKeys = [
118
123
  'afterLabelContentVAlign',
119
124
  'description',
120
125
  'descriptionRole',
126
+ 'elementRef',
121
127
  'children'
122
128
  ]
123
129
 
@@ -128,6 +128,7 @@ const generateStyle = (
128
128
  container: {
129
129
  label: 'optionItem__container',
130
130
  display: 'block',
131
+ outline: 'none',
131
132
  padding: componentTheme.padding,
132
133
  ...(containsList && { padding: '0' }),
133
134
  ...(hasContentBeforeLabel && {
@@ -73,4 +73,5 @@ const generateComponentTheme = (theme: Theme): OptionsItemTheme => {
73
73
  }
74
74
  }
75
75
 
76
+ export { generateComponentTheme as optionsItemThemeGenerator }
76
77
  export default generateComponentTheme
@@ -44,4 +44,5 @@ const generateComponentTheme = (theme: Theme): OptionsSeparatorTheme => {
44
44
  }
45
45
  }
46
46
 
47
+ export { generateComponentTheme as optionsSeparatorThemeGenerator }
47
48
  export default generateComponentTheme
@@ -23,7 +23,15 @@
23
23
  */
24
24
 
25
25
  import type { Theme } from '@instructure/ui-themes'
26
- import { OptionsTheme } from '@instructure/shared-types'
26
+ import type { OptionsTheme } from '@instructure/shared-types'
27
+
28
+ const optionsThemeKeys: (keyof OptionsTheme)[] = [
29
+ 'labelFontWeight',
30
+ 'background',
31
+ 'labelColor',
32
+ 'labelPadding',
33
+ 'nestedLabelPadding'
34
+ ]
27
35
 
28
36
  /**
29
37
  * Generates the theme object for the component from the theme and provided additional information
@@ -33,6 +41,7 @@ import { OptionsTheme } from '@instructure/shared-types'
33
41
  const generateComponentTheme = (theme: Theme): OptionsTheme => {
34
42
  const { colors, typography, spacing } = theme
35
43
 
44
+ // TODO: if updated, update optionsThemeKeys array too
36
45
  const componentVariables: OptionsTheme = {
37
46
  labelFontWeight: typography?.fontWeightBold,
38
47
 
@@ -48,4 +57,5 @@ const generateComponentTheme = (theme: Theme): OptionsTheme => {
48
57
  }
49
58
  }
50
59
 
60
+ export { generateComponentTheme as optionsThemeGenerator, optionsThemeKeys }
51
61
  export default generateComponentTheme
package/src/index.ts CHANGED
@@ -24,6 +24,10 @@
24
24
 
25
25
  export { Options } from './Options'
26
26
 
27
+ export { optionsThemeGenerator, optionsThemeKeys } from './Options/theme'
28
+ export { optionsItemThemeGenerator } from './Options/Item/theme'
29
+ export { optionsSeparatorThemeGenerator } from './Options/Separator/theme'
30
+
27
31
  export type { OptionsProps } from './Options/props'
28
32
  export type { OptionsItemProps } from './Options/Item/props'
29
33
  export type { OptionsSeparatorProps } from './Options/Separator/props'