@instructure/ui-options 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 (149) hide show
  1. package/CHANGELOG.md +36 -294
  2. package/es/Options/{Item → v1/Item}/index.js +1 -1
  3. package/es/Options/{Separator → v1/Separator}/index.js +1 -1
  4. package/es/Options/{index.js → v1/index.js} +2 -2
  5. package/es/Options/v2/Item/index.js +127 -0
  6. package/es/Options/v2/Item/props.js +26 -0
  7. package/es/Options/v2/Item/styles.js +189 -0
  8. package/es/Options/v2/Item/theme.js +72 -0
  9. package/es/Options/v2/Separator/index.js +69 -0
  10. package/es/Options/v2/Separator/props.js +26 -0
  11. package/es/Options/v2/Separator/styles.js +46 -0
  12. package/es/Options/v2/Separator/theme.js +45 -0
  13. package/es/Options/v2/index.js +147 -0
  14. package/es/Options/v2/props.js +26 -0
  15. package/es/Options/v2/styles.js +57 -0
  16. package/es/Options/v2/theme.js +47 -0
  17. package/es/{index.js → exports/a.js} +6 -6
  18. package/es/exports/b.js +29 -0
  19. package/lib/Options/{Item → v1/Item}/index.js +1 -1
  20. package/lib/Options/{Separator → v1/Separator}/index.js +1 -1
  21. package/lib/Options/v1/index.js +153 -0
  22. package/lib/Options/v2/Item/index.js +132 -0
  23. package/lib/Options/v2/Item/props.js +31 -0
  24. package/lib/Options/v2/Item/styles.js +195 -0
  25. package/lib/Options/v2/Item/theme.js +78 -0
  26. package/lib/Options/v2/Separator/index.js +74 -0
  27. package/lib/Options/v2/Separator/props.js +31 -0
  28. package/lib/Options/v2/Separator/styles.js +52 -0
  29. package/lib/Options/v2/Separator/theme.js +51 -0
  30. package/lib/Options/{index.js → v2/index.js} +4 -5
  31. package/lib/Options/v2/props.js +31 -0
  32. package/lib/Options/v2/styles.js +63 -0
  33. package/lib/Options/v2/theme.js +53 -0
  34. package/lib/{index.js → exports/a.js} +7 -7
  35. package/lib/exports/b.js +47 -0
  36. package/package.json +40 -18
  37. package/src/Options/{Item → v1/Item}/index.tsx +1 -1
  38. package/src/Options/{Separator → v1/Separator}/index.tsx +1 -1
  39. package/src/Options/{index.tsx → v1/index.tsx} +2 -2
  40. package/src/Options/v2/Item/index.tsx +180 -0
  41. package/src/Options/v2/Item/props.ts +136 -0
  42. package/src/Options/v2/Item/styles.ts +205 -0
  43. package/src/Options/v2/Item/theme.ts +79 -0
  44. package/src/Options/v2/README.md +409 -0
  45. package/src/Options/v2/Separator/index.tsx +79 -0
  46. package/src/Options/v2/Separator/props.ts +52 -0
  47. package/src/Options/v2/Separator/styles.ts +52 -0
  48. package/src/Options/v2/Separator/theme.ts +48 -0
  49. package/src/Options/v2/index.tsx +188 -0
  50. package/src/Options/v2/props.ts +76 -0
  51. package/src/Options/v2/styles.ts +63 -0
  52. package/src/Options/v2/theme.ts +52 -0
  53. package/src/{index.ts → exports/a.ts} +9 -9
  54. package/src/exports/b.ts +38 -0
  55. package/tsconfig.build.tsbuildinfo +1 -1
  56. package/types/Options/v1/Item/index.d.ts.map +1 -0
  57. package/types/Options/v1/Item/props.d.ts.map +1 -0
  58. package/types/Options/v1/Item/styles.d.ts.map +1 -0
  59. package/types/Options/v1/Item/theme.d.ts.map +1 -0
  60. package/types/Options/v1/Separator/index.d.ts.map +1 -0
  61. package/types/Options/v1/Separator/props.d.ts.map +1 -0
  62. package/types/Options/v1/Separator/styles.d.ts.map +1 -0
  63. package/types/Options/v1/Separator/theme.d.ts.map +1 -0
  64. package/types/Options/v1/index.d.ts.map +1 -0
  65. package/types/Options/v1/props.d.ts.map +1 -0
  66. package/types/Options/v1/styles.d.ts.map +1 -0
  67. package/types/Options/v1/theme.d.ts.map +1 -0
  68. package/types/Options/v2/Item/index.d.ts +31 -0
  69. package/types/Options/v2/Item/index.d.ts.map +1 -0
  70. package/types/Options/v2/Item/props.d.ts +70 -0
  71. package/types/Options/v2/Item/props.d.ts.map +1 -0
  72. package/types/Options/v2/Item/styles.d.ts +15 -0
  73. package/types/Options/v2/Item/styles.d.ts.map +1 -0
  74. package/types/Options/v2/Item/theme.d.ts +11 -0
  75. package/types/Options/v2/Item/theme.d.ts.map +1 -0
  76. package/types/Options/v2/Separator/index.d.ts +22 -0
  77. package/types/Options/v2/Separator/index.d.ts.map +1 -0
  78. package/types/Options/v2/Separator/props.d.ts +17 -0
  79. package/types/Options/v2/Separator/props.d.ts.map +1 -0
  80. package/types/Options/v2/Separator/styles.d.ts +15 -0
  81. package/types/Options/v2/Separator/styles.d.ts.map +1 -0
  82. package/types/Options/v2/Separator/theme.d.ts +11 -0
  83. package/types/Options/v2/Separator/theme.d.ts.map +1 -0
  84. package/types/Options/v2/index.d.ts +43 -0
  85. package/types/Options/v2/index.d.ts.map +1 -0
  86. package/types/Options/v2/props.d.ts +32 -0
  87. package/types/Options/v2/props.d.ts.map +1 -0
  88. package/types/Options/v2/styles.d.ts +15 -0
  89. package/types/Options/v2/styles.d.ts.map +1 -0
  90. package/types/Options/v2/theme.d.ts +11 -0
  91. package/types/Options/v2/theme.d.ts.map +1 -0
  92. package/types/exports/a.d.ts +10 -0
  93. package/types/exports/a.d.ts.map +1 -0
  94. package/types/exports/b.d.ts +10 -0
  95. package/types/exports/b.d.ts.map +1 -0
  96. package/types/Options/Item/index.d.ts.map +0 -1
  97. package/types/Options/Item/props.d.ts.map +0 -1
  98. package/types/Options/Item/styles.d.ts.map +0 -1
  99. package/types/Options/Item/theme.d.ts.map +0 -1
  100. package/types/Options/Separator/index.d.ts.map +0 -1
  101. package/types/Options/Separator/props.d.ts.map +0 -1
  102. package/types/Options/Separator/styles.d.ts.map +0 -1
  103. package/types/Options/Separator/theme.d.ts.map +0 -1
  104. package/types/Options/index.d.ts.map +0 -1
  105. package/types/Options/props.d.ts.map +0 -1
  106. package/types/Options/styles.d.ts.map +0 -1
  107. package/types/Options/theme.d.ts.map +0 -1
  108. package/types/index.d.ts +0 -10
  109. package/types/index.d.ts.map +0 -1
  110. /package/es/Options/{Item → v1/Item}/props.js +0 -0
  111. /package/es/Options/{Item → v1/Item}/styles.js +0 -0
  112. /package/es/Options/{Item → v1/Item}/theme.js +0 -0
  113. /package/es/Options/{Separator → v1/Separator}/props.js +0 -0
  114. /package/es/Options/{Separator → v1/Separator}/styles.js +0 -0
  115. /package/es/Options/{Separator → v1/Separator}/theme.js +0 -0
  116. /package/es/Options/{props.js → v1/props.js} +0 -0
  117. /package/es/Options/{styles.js → v1/styles.js} +0 -0
  118. /package/es/Options/{theme.js → v1/theme.js} +0 -0
  119. /package/lib/Options/{Item → v1/Item}/props.js +0 -0
  120. /package/lib/Options/{Item → v1/Item}/styles.js +0 -0
  121. /package/lib/Options/{Item → v1/Item}/theme.js +0 -0
  122. /package/lib/Options/{Separator → v1/Separator}/props.js +0 -0
  123. /package/lib/Options/{Separator → v1/Separator}/styles.js +0 -0
  124. /package/lib/Options/{Separator → v1/Separator}/theme.js +0 -0
  125. /package/lib/Options/{props.js → v1/props.js} +0 -0
  126. /package/lib/Options/{styles.js → v1/styles.js} +0 -0
  127. /package/lib/Options/{theme.js → v1/theme.js} +0 -0
  128. /package/src/Options/{Item → v1/Item}/props.ts +0 -0
  129. /package/src/Options/{Item → v1/Item}/styles.ts +0 -0
  130. /package/src/Options/{Item → v1/Item}/theme.ts +0 -0
  131. /package/src/Options/{README.md → v1/README.md} +0 -0
  132. /package/src/Options/{Separator → v1/Separator}/props.ts +0 -0
  133. /package/src/Options/{Separator → v1/Separator}/styles.ts +0 -0
  134. /package/src/Options/{Separator → v1/Separator}/theme.ts +0 -0
  135. /package/src/Options/{props.ts → v1/props.ts} +0 -0
  136. /package/src/Options/{styles.ts → v1/styles.ts} +0 -0
  137. /package/src/Options/{theme.ts → v1/theme.ts} +0 -0
  138. /package/types/Options/{Item → v1/Item}/index.d.ts +0 -0
  139. /package/types/Options/{Item → v1/Item}/props.d.ts +0 -0
  140. /package/types/Options/{Item → v1/Item}/styles.d.ts +0 -0
  141. /package/types/Options/{Item → v1/Item}/theme.d.ts +0 -0
  142. /package/types/Options/{Separator → v1/Separator}/index.d.ts +0 -0
  143. /package/types/Options/{Separator → v1/Separator}/props.d.ts +0 -0
  144. /package/types/Options/{Separator → v1/Separator}/styles.d.ts +0 -0
  145. /package/types/Options/{Separator → v1/Separator}/theme.d.ts +0 -0
  146. /package/types/Options/{index.d.ts → v1/index.d.ts} +0 -0
  147. /package/types/Options/{props.d.ts → v1/props.d.ts} +0 -0
  148. /package/types/Options/{styles.d.ts → v1/styles.d.ts} +0 -0
  149. /package/types/Options/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,147 @@
1
+ var _dec, _dec2, _class, _Options;
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, Children } from 'react';
27
+ import { omitProps, matchComponentTypes, callRenderProp, safeCloneElement, withDeterministicId } from '@instructure/ui-react-utils';
28
+ import { View } from '@instructure/ui-view/latest';
29
+ import { withStyle } from '@instructure/emotion';
30
+ import generateStyles from "./styles.js";
31
+ import { Item } from "./Item/index.js";
32
+ import { Separator } from "./Separator/index.js";
33
+ import { allowedProps } from "./props.js";
34
+ import { isAndroidOrIOS } from '@instructure/ui-utils';
35
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
36
+ /**
37
+ ---
38
+ category: components/utilities
39
+ ---
40
+ **/
41
+ let Options = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyles), _dec(_class = _dec2(_class = (_Options = class Options extends Component {
42
+ constructor(...args) {
43
+ super(...args);
44
+ this.ref = null;
45
+ this.handleRef = el => {
46
+ this.ref = el;
47
+ };
48
+ this._labelId = this.props.deterministicId('Options-label');
49
+ }
50
+ componentDidMount() {
51
+ var _this$props$makeStyle, _this$props;
52
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
53
+ }
54
+ componentDidUpdate() {
55
+ var _this$props$makeStyle2, _this$props2;
56
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
57
+ }
58
+ get childAs() {
59
+ const as = this.props.as;
60
+ if (as === 'ul' || as === 'ol') {
61
+ return 'li';
62
+ }
63
+ return void 0;
64
+ }
65
+ renderLabel() {
66
+ const _this$props3 = this.props,
67
+ renderLabel = _this$props3.renderLabel,
68
+ styles = _this$props3.styles;
69
+ return _jsx("span", {
70
+ id: this._labelId,
71
+ role: "presentation"
72
+ // because TalkBack and iOS VoiceOver don't announce sub-menu labels, aria-hidden needs to be false to achive that
73
+ ,
74
+ "aria-hidden": isAndroidOrIOS() ? 'false' : 'true',
75
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
76
+ children: callRenderProp(renderLabel)
77
+ });
78
+ }
79
+ renderSubList(subOptions) {
80
+ const styles = this.props.styles;
81
+ return _jsx(Item, {
82
+ as: this.childAs,
83
+ role: "presentation",
84
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
85
+ children: subOptions
86
+ });
87
+ }
88
+ renderChildren() {
89
+ const children = this.props.children;
90
+ return Children.map(children, child => {
91
+ if (matchComponentTypes(child, ['Options'])) {
92
+ return this.renderSubList(child);
93
+ }
94
+ if (matchComponentTypes(child, ['Item', 'Separator'])) {
95
+ return safeCloneElement(child, {
96
+ as: this.childAs || child.props.as
97
+ });
98
+ }
99
+ return void 0;
100
+ });
101
+ }
102
+ get ariaLabelledby() {
103
+ if (this.props.renderLabel) {
104
+ return this._labelId;
105
+ }
106
+ if (this.props['aria-labelledby']) {
107
+ return this.props['aria-labelledby'];
108
+ }
109
+ return void 0;
110
+ }
111
+ render() {
112
+ const passthroughProps = View.omitViewProps(omitProps(this.props, Options.allowedProps), Options);
113
+ const _this$props4 = this.props,
114
+ as = _this$props4.as,
115
+ role = _this$props4.role,
116
+ renderLabel = _this$props4.renderLabel,
117
+ elementRef = _this$props4.elementRef,
118
+ styles = _this$props4.styles;
119
+ return _jsxs("div", {
120
+ css: styles === null || styles === void 0 ? void 0 : styles.options,
121
+ role: "presentation",
122
+ ref: this.handleRef,
123
+ "data-cid": "Options",
124
+ children: [renderLabel && this.renderLabel(), _jsx(View, {
125
+ ...passthroughProps,
126
+ elementRef: elementRef,
127
+ css: styles === null || styles === void 0 ? void 0 : styles.list,
128
+ as: as,
129
+ role: role,
130
+ display: "block",
131
+ margin: "none",
132
+ padding: "none",
133
+ background: "primary",
134
+ "aria-labelledby": this.ariaLabelledby,
135
+ children: this.renderChildren()
136
+ })]
137
+ });
138
+ }
139
+ }, _Options.displayName = "Options", _Options.componentId = 'Options', _Options.allowedProps = allowedProps, _Options.defaultProps = {
140
+ as: 'span',
141
+ role: 'list',
142
+ elementRef: () => {},
143
+ renderLabel: null,
144
+ children: null
145
+ }, _Options.Item = Item, _Options.Separator = Separator, _Options)) || _class) || _class);
146
+ export default Options;
147
+ export { Options };
@@ -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 = ['as', 'role', 'elementRef', 'renderLabel', 'children'];
26
+ export { allowedProps };
@@ -0,0 +1,57 @@
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 => {
36
+ return {
37
+ options: {
38
+ label: 'options',
39
+ boxSizing: 'border-box',
40
+ wordWrap: 'break-word'
41
+ },
42
+ list: {
43
+ label: 'options__list',
44
+ listStyleType: 'none',
45
+ position: 'relative'
46
+ },
47
+ label: {
48
+ label: 'options__label',
49
+ color: componentTheme.labelColor,
50
+ cursor: 'default',
51
+ display: 'block',
52
+ fontWeight: componentTheme.labelFontWeight,
53
+ padding: `${componentTheme.nestedLabelPaddingVertical} ${componentTheme.nestedLabelPaddingHorizontal}`
54
+ }
55
+ };
56
+ };
57
+ export default generateStyle;
@@ -0,0 +1,47 @@
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
+ * Generates the theme object for the component from the theme and provided additional information
27
+ * @param {Object} theme The actual theme object.
28
+ * @return {Object} The final theme object with the overrides and component variables
29
+ */
30
+ const generateComponentTheme = theme => {
31
+ var _colors$contrasts, _colors$contrasts2;
32
+ const colors = theme.colors,
33
+ typography = theme.typography,
34
+ spacing = theme.spacing;
35
+ const componentVariables = {
36
+ labelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
37
+ background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.white1010,
38
+ labelColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey125125,
39
+ labelPadding: `${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall} 0`,
40
+ nestedLabelPadding: `${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall} ${spacing === null || spacing === void 0 ? void 0 : spacing.small}`
41
+ };
42
+ return {
43
+ ...componentVariables
44
+ };
45
+ };
46
+ export { generateComponentTheme as optionsThemeGenerator };
47
+ export default generateComponentTheme;
@@ -21,9 +21,9 @@
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/index.js";
25
- export { Item as OptionItem } from "./Options/Item/index.js";
26
- export { Separator as OptionSeparator } from "./Options/Separator/index.js";
27
- export { optionsThemeGenerator } from "./Options/theme.js";
28
- export { optionsItemThemeGenerator } from "./Options/Item/theme.js";
29
- export { optionsSeparatorThemeGenerator } from "./Options/Separator/theme.js";
24
+ export { Options } from "../Options/v1/index.js";
25
+ export { Item as OptionItem } from "../Options/v1/Item/index.js";
26
+ export { Separator as OptionSeparator } from "../Options/v1/Separator/index.js";
27
+ export { optionsThemeGenerator } from "../Options/v1/theme.js";
28
+ export { optionsItemThemeGenerator } from "../Options/v1/Item/theme.js";
29
+ export { optionsSeparatorThemeGenerator } from "../Options/v1/Separator/theme.js";
@@ -0,0 +1,29 @@
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
+ export { Options } from "../Options/v2/index.js";
25
+ export { Item as OptionItem } from "../Options/v2/Item/index.js";
26
+ export { Separator as OptionSeparator } from "../Options/v2/Separator/index.js";
27
+ export { optionsThemeGenerator } from "../Options/v2/theme.js";
28
+ export { optionsItemThemeGenerator } from "../Options/v2/Item/theme.js";
29
+ export { optionsSeparatorThemeGenerator } from "../Options/v2/Separator/theme.js";
@@ -42,7 +42,7 @@ parent: Options
42
42
  id: Options.Item
43
43
  ---
44
44
  **/
45
- let Item = exports.Item = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Item = class Item extends _react.Component {
45
+ let Item = exports.Item = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Item = class Item extends _react.Component {
46
46
  constructor(props) {
47
47
  super(props);
48
48
  this.ref = null;
@@ -45,7 +45,7 @@ id: Options.Separator
45
45
  ---
46
46
  @module Separator
47
47
  **/
48
- let Separator = exports.Separator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_Separator = class Separator extends _react.Component {
48
+ let Separator = exports.Separator = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_Separator = class Separator extends _react.Component {
49
49
  componentDidMount() {
50
50
  var _this$props$makeStyle, _this$props;
51
51
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Options = void 0;
8
+ var _react = require("react");
9
+ var _uiReactUtils = require("@instructure/ui-react-utils");
10
+ var _v11_ = require("@instructure/ui-view/v11_6");
11
+ var _emotion = require("@instructure/emotion");
12
+ var _styles = _interopRequireDefault(require("./styles"));
13
+ var _theme = _interopRequireDefault(require("./theme"));
14
+ var _Item = require("./Item");
15
+ var _Separator = require("./Separator");
16
+ var _props = require("./props");
17
+ var _uiUtils = require("@instructure/ui-utils");
18
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
19
+ var _dec, _dec2, _class, _Options;
20
+ /*
21
+ * The MIT License (MIT)
22
+ *
23
+ * Copyright (c) 2015 - present Instructure, Inc.
24
+ *
25
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ * of this software and associated documentation files (the "Software"), to deal
27
+ * in the Software without restriction, including without limitation the rights
28
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ * copies of the Software, and to permit persons to whom the Software is
30
+ * furnished to do so, subject to the following conditions:
31
+ *
32
+ * The above copyright notice and this permission notice shall be included in all
33
+ * copies or substantial portions of the Software.
34
+ *
35
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ * SOFTWARE.
42
+ */
43
+ /**
44
+ ---
45
+ category: components/utilities
46
+ ---
47
+ **/
48
+ let Options = exports.Options = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Options = class Options extends _react.Component {
49
+ constructor(...args) {
50
+ super(...args);
51
+ this.ref = null;
52
+ this.handleRef = el => {
53
+ this.ref = el;
54
+ };
55
+ this._labelId = this.props.deterministicId('Options-label');
56
+ }
57
+ componentDidMount() {
58
+ var _this$props$makeStyle, _this$props;
59
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
60
+ }
61
+ componentDidUpdate() {
62
+ var _this$props$makeStyle2, _this$props2;
63
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
64
+ }
65
+ get childAs() {
66
+ const as = this.props.as;
67
+ if (as === 'ul' || as === 'ol') {
68
+ return 'li';
69
+ }
70
+ return void 0;
71
+ }
72
+ renderLabel() {
73
+ const _this$props3 = this.props,
74
+ renderLabel = _this$props3.renderLabel,
75
+ styles = _this$props3.styles;
76
+ return (0, _jsxRuntime.jsx)("span", {
77
+ id: this._labelId,
78
+ role: "presentation"
79
+ // because TalkBack and iOS VoiceOver don't announce sub-menu labels, aria-hidden needs to be false to achive that
80
+ ,
81
+ "aria-hidden": (0, _uiUtils.isAndroidOrIOS)() ? 'false' : 'true',
82
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
83
+ children: (0, _uiReactUtils.callRenderProp)(renderLabel)
84
+ });
85
+ }
86
+ renderSubList(subOptions) {
87
+ const styles = this.props.styles;
88
+ return (0, _jsxRuntime.jsx)(_Item.Item, {
89
+ as: this.childAs,
90
+ role: "presentation",
91
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
92
+ children: subOptions
93
+ });
94
+ }
95
+ renderChildren() {
96
+ const children = this.props.children;
97
+ return _react.Children.map(children, child => {
98
+ if ((0, _uiReactUtils.matchComponentTypes)(child, ['Options'])) {
99
+ return this.renderSubList(child);
100
+ }
101
+ if ((0, _uiReactUtils.matchComponentTypes)(child, ['Item', 'Separator'])) {
102
+ return (0, _uiReactUtils.safeCloneElement)(child, {
103
+ as: this.childAs || child.props.as
104
+ });
105
+ }
106
+ return void 0;
107
+ });
108
+ }
109
+ get ariaLabelledby() {
110
+ if (this.props.renderLabel) {
111
+ return this._labelId;
112
+ }
113
+ if (this.props['aria-labelledby']) {
114
+ return this.props['aria-labelledby'];
115
+ }
116
+ return void 0;
117
+ }
118
+ render() {
119
+ const passthroughProps = _v11_.View.omitViewProps((0, _uiReactUtils.omitProps)(this.props, Options.allowedProps), Options);
120
+ const _this$props4 = this.props,
121
+ as = _this$props4.as,
122
+ role = _this$props4.role,
123
+ renderLabel = _this$props4.renderLabel,
124
+ elementRef = _this$props4.elementRef,
125
+ styles = _this$props4.styles;
126
+ return (0, _jsxRuntime.jsxs)("div", {
127
+ css: styles === null || styles === void 0 ? void 0 : styles.options,
128
+ role: "presentation",
129
+ ref: this.handleRef,
130
+ "data-cid": "Options",
131
+ children: [renderLabel && this.renderLabel(), (0, _jsxRuntime.jsx)(_v11_.View, {
132
+ ...passthroughProps,
133
+ elementRef: elementRef,
134
+ css: styles === null || styles === void 0 ? void 0 : styles.list,
135
+ as: as,
136
+ role: role,
137
+ display: "block",
138
+ margin: "none",
139
+ padding: "none",
140
+ background: "primary",
141
+ "aria-labelledby": this.ariaLabelledby,
142
+ children: this.renderChildren()
143
+ })]
144
+ });
145
+ }
146
+ }, _Options.displayName = "Options", _Options.componentId = 'Options', _Options.allowedProps = _props.allowedProps, _Options.defaultProps = {
147
+ as: 'span',
148
+ role: 'list',
149
+ elementRef: () => {},
150
+ renderLabel: null,
151
+ children: null
152
+ }, _Options.Item = _Item.Item, _Options.Separator = _Separator.Separator, _Options)) || _class) || _class);
153
+ var _default = exports.default = Options;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Item = void 0;
8
+ var _react = require("react");
9
+ var _uiReactUtils = require("@instructure/ui-react-utils");
10
+ var _emotion = require("@instructure/emotion");
11
+ var _styles = _interopRequireDefault(require("./styles"));
12
+ var _props = require("./props");
13
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
+ var _dec, _dec2, _class, _Item;
15
+ /*
16
+ * The MIT License (MIT)
17
+ *
18
+ * Copyright (c) 2015 - present Instructure, Inc.
19
+ *
20
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
21
+ * of this software and associated documentation files (the "Software"), to deal
22
+ * in the Software without restriction, including without limitation the rights
23
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ * copies of the Software, and to permit persons to whom the Software is
25
+ * furnished to do so, subject to the following conditions:
26
+ *
27
+ * The above copyright notice and this permission notice shall be included in all
28
+ * copies or substantial portions of the Software.
29
+ *
30
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
+ * SOFTWARE.
37
+ */
38
+ /**
39
+ ---
40
+ parent: Options
41
+ id: Options.Item
42
+ ---
43
+ **/
44
+ let Item = exports.Item = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = (_Item = class Item extends _react.Component {
45
+ constructor(props) {
46
+ super(props);
47
+ this.ref = null;
48
+ this._descriptionId = void 0;
49
+ this._descriptionId = props.deterministicId('OptionsItem-description');
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
+ renderContent(renderLabel, contentVariant) {
60
+ const _this$props3 = this.props,
61
+ styles = _this$props3.styles,
62
+ variant = _this$props3.variant,
63
+ as = _this$props3.as,
64
+ role = _this$props3.role,
65
+ children = _this$props3.children;
66
+ return (0, _jsxRuntime.jsx)("span", {
67
+ css: [styles === null || styles === void 0 ? void 0 : styles.content, contentVariant],
68
+ role: "presentation",
69
+ "aria-hidden": "true",
70
+ children: (0, _uiReactUtils.callRenderProp)(renderLabel, {
71
+ variant,
72
+ as,
73
+ role,
74
+ children
75
+ })
76
+ });
77
+ }
78
+ render() {
79
+ const _this$props4 = this.props,
80
+ as = _this$props4.as,
81
+ href = _this$props4.href,
82
+ role = _this$props4.role,
83
+ styles = _this$props4.styles,
84
+ description = _this$props4.description,
85
+ descriptionRole = _this$props4.descriptionRole,
86
+ renderBeforeLabel = _this$props4.renderBeforeLabel,
87
+ renderAfterLabel = _this$props4.renderAfterLabel,
88
+ elementRef = _this$props4.elementRef,
89
+ children = _this$props4.children,
90
+ voiceoverRoleBugWorkaround = _this$props4.voiceoverRoleBugWorkaround;
91
+ const ElementType = (0, _uiReactUtils.getElementType)(Item, this.props, () => as);
92
+ const InnerElementType = href ? 'a' : 'span';
93
+ const passthroughProps = (0, _uiReactUtils.omitProps)(this.props, Item.allowedProps);
94
+ const childrenContent = (0, _uiReactUtils.callRenderProp)(children);
95
+ const descriptionContent = (0, _uiReactUtils.callRenderProp)(description);
96
+ const ariaDescribedBy = this.props['aria-describedby'] || (descriptionContent ? this._descriptionId : void 0);
97
+ return (0, _jsxRuntime.jsxs)(ElementType, {
98
+ role: voiceoverRoleBugWorkaround ? role : 'none',
99
+ "data-cid": "Options.Item",
100
+ css: styles === null || styles === void 0 ? void 0 : styles.item,
101
+ ref: element => {
102
+ this.ref = element;
103
+ if (typeof elementRef === 'function') {
104
+ elementRef(element);
105
+ }
106
+ },
107
+ "aria-describedby": voiceoverRoleBugWorkaround ? ariaDescribedBy : void 0,
108
+ children: [(0, _jsxRuntime.jsxs)(InnerElementType, {
109
+ ...passthroughProps,
110
+ css: styles === null || styles === void 0 ? void 0 : styles.container,
111
+ role: href || voiceoverRoleBugWorkaround ? void 0 : role,
112
+ href: href,
113
+ "aria-describedby": voiceoverRoleBugWorkaround ? void 0 : ariaDescribedBy,
114
+ children: [childrenContent, descriptionContent && (0, _jsxRuntime.jsx)("span", {
115
+ css: styles === null || styles === void 0 ? void 0 : styles.description,
116
+ role: descriptionRole,
117
+ id: this._descriptionId,
118
+ children: descriptionContent
119
+ })]
120
+ }), 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)]
121
+ });
122
+ }
123
+ }, _Item.displayName = "Item", _Item.componentId = 'Options.Item', _Item.allowedProps = _props.allowedProps, _Item.defaultProps = {
124
+ as: 'span',
125
+ variant: 'default',
126
+ role: 'listitem',
127
+ voiceoverRoleBugWorkaround: false,
128
+ beforeLabelContentVAlign: 'center',
129
+ afterLabelContentVAlign: 'center',
130
+ isSelected: false
131
+ }, _Item)) || _class) || _class);
132
+ var _default = exports.default = Item;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['as', 'variant', 'role', 'renderBeforeLabel', 'renderAfterLabel', 'beforeLabelContentVAlign', 'afterLabelContentVAlign', 'description', 'descriptionRole', 'voiceoverRoleBugWorkaround', 'href', 'elementRef', 'children', 'isSelected'];