@instructure/ui-drilldown 8.21.1-snapshot.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE.md +27 -0
  3. package/README.md +30 -0
  4. package/es/Drilldown/DrilldownGroup/index.js +56 -0
  5. package/es/Drilldown/DrilldownGroup/props.js +42 -0
  6. package/es/Drilldown/DrilldownLocator.js +144 -0
  7. package/es/Drilldown/DrilldownOption/index.js +59 -0
  8. package/es/Drilldown/DrilldownOption/props.js +46 -0
  9. package/es/Drilldown/DrilldownPage/index.js +56 -0
  10. package/es/Drilldown/DrilldownPage/props.js +41 -0
  11. package/es/Drilldown/DrilldownSeparator/index.js +52 -0
  12. package/es/Drilldown/DrilldownSeparator/props.js +30 -0
  13. package/es/Drilldown/__examples__/Drilldown.examples.js +299 -0
  14. package/es/Drilldown/index.js +1241 -0
  15. package/es/Drilldown/locator.js +26 -0
  16. package/es/Drilldown/props.js +67 -0
  17. package/es/Drilldown/styles.js +82 -0
  18. package/es/Drilldown/theme.js +43 -0
  19. package/es/index.js +24 -0
  20. package/lib/Drilldown/DrilldownGroup/index.js +42 -0
  21. package/lib/Drilldown/DrilldownGroup/props.js +56 -0
  22. package/lib/Drilldown/DrilldownLocator.js +157 -0
  23. package/lib/Drilldown/DrilldownOption/index.js +45 -0
  24. package/lib/Drilldown/DrilldownOption/props.js +57 -0
  25. package/lib/Drilldown/DrilldownPage/index.js +66 -0
  26. package/lib/Drilldown/DrilldownPage/props.js +56 -0
  27. package/lib/Drilldown/DrilldownSeparator/index.js +38 -0
  28. package/lib/Drilldown/DrilldownSeparator/props.js +41 -0
  29. package/lib/Drilldown/__examples__/Drilldown.examples.js +289 -0
  30. package/lib/Drilldown/index.js +1253 -0
  31. package/lib/Drilldown/locator.js +40 -0
  32. package/lib/Drilldown/props.js +83 -0
  33. package/lib/Drilldown/styles.js +90 -0
  34. package/lib/Drilldown/theme.js +51 -0
  35. package/lib/index.js +13 -0
  36. package/lib/package.json +1 -0
  37. package/package.json +58 -0
  38. package/src/Drilldown/DrilldownGroup/index.tsx +64 -0
  39. package/src/Drilldown/DrilldownGroup/props.ts +149 -0
  40. package/src/Drilldown/DrilldownLocator.ts +101 -0
  41. package/src/Drilldown/DrilldownOption/index.tsx +68 -0
  42. package/src/Drilldown/DrilldownOption/props.ts +224 -0
  43. package/src/Drilldown/DrilldownPage/index.tsx +58 -0
  44. package/src/Drilldown/DrilldownPage/props.ts +129 -0
  45. package/src/Drilldown/DrilldownSeparator/index.tsx +60 -0
  46. package/src/Drilldown/DrilldownSeparator/props.ts +65 -0
  47. package/src/Drilldown/README.md +1515 -0
  48. package/src/Drilldown/__examples__/Drilldown.examples.tsx +318 -0
  49. package/src/Drilldown/index.tsx +1492 -0
  50. package/src/Drilldown/locator.ts +28 -0
  51. package/src/Drilldown/props.ts +378 -0
  52. package/src/Drilldown/styles.ts +95 -0
  53. package/src/Drilldown/theme.ts +47 -0
  54. package/src/index.ts +26 -0
  55. package/tsconfig.build.json +30 -0
  56. package/tsconfig.build.tsbuildinfo +1 -0
  57. package/tsconfig.json +4 -0
  58. package/types/Drilldown/DrilldownGroup/index.d.ts +59 -0
  59. package/types/Drilldown/DrilldownGroup/index.d.ts.map +1 -0
  60. package/types/Drilldown/DrilldownGroup/props.d.ts +65 -0
  61. package/types/Drilldown/DrilldownGroup/props.d.ts.map +1 -0
  62. package/types/Drilldown/DrilldownLocator.d.ts +652 -0
  63. package/types/Drilldown/DrilldownLocator.d.ts.map +1 -0
  64. package/types/Drilldown/DrilldownOption/index.d.ts +134 -0
  65. package/types/Drilldown/DrilldownOption/index.d.ts.map +1 -0
  66. package/types/Drilldown/DrilldownOption/props.d.ts +116 -0
  67. package/types/Drilldown/DrilldownOption/props.d.ts.map +1 -0
  68. package/types/Drilldown/DrilldownPage/index.d.ts +45 -0
  69. package/types/Drilldown/DrilldownPage/index.d.ts.map +1 -0
  70. package/types/Drilldown/DrilldownPage/props.d.ts +51 -0
  71. package/types/Drilldown/DrilldownPage/props.d.ts.map +1 -0
  72. package/types/Drilldown/DrilldownSeparator/index.d.ts +27 -0
  73. package/types/Drilldown/DrilldownSeparator/index.d.ts.map +1 -0
  74. package/types/Drilldown/DrilldownSeparator/props.d.ts +18 -0
  75. package/types/Drilldown/DrilldownSeparator/props.d.ts.map +1 -0
  76. package/types/Drilldown/__examples__/Drilldown.examples.d.ts +5 -0
  77. package/types/Drilldown/__examples__/Drilldown.examples.d.ts.map +1 -0
  78. package/types/Drilldown/index.d.ts +246 -0
  79. package/types/Drilldown/index.d.ts.map +1 -0
  80. package/types/Drilldown/locator.d.ts +4 -0
  81. package/types/Drilldown/locator.d.ts.map +1 -0
  82. package/types/Drilldown/props.d.ts +189 -0
  83. package/types/Drilldown/props.d.ts.map +1 -0
  84. package/types/Drilldown/styles.d.ts +15 -0
  85. package/types/Drilldown/styles.d.ts.map +1 -0
  86. package/types/Drilldown/theme.d.ts +10 -0
  87. package/types/Drilldown/theme.d.ts.map +1 -0
  88. package/types/index.d.ts +3 -0
  89. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DrilldownLocator", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _DrilldownLocator.DrilldownLocator;
10
+ }
11
+ });
12
+ exports.default = void 0;
13
+
14
+ var _DrilldownLocator = require("./DrilldownLocator");
15
+
16
+ /*
17
+ * The MIT License (MIT)
18
+ *
19
+ * Copyright (c) 2015 - present Instructure, Inc.
20
+ *
21
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ * of this software and associated documentation files (the "Software"), to deal
23
+ * in the Software without restriction, including without limitation the rights
24
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ * copies of the Software, and to permit persons to whom the Software is
26
+ * furnished to do so, subject to the following conditions:
27
+ *
28
+ * The above copyright notice and this permission notice shall be included in all
29
+ * copies or substantial portions of the Software.
30
+ *
31
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ * SOFTWARE.
38
+ */
39
+ var _default = _DrilldownLocator.DrilldownLocator;
40
+ exports.default = _default;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.propTypes = exports.allowedProps = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _Children = require("@instructure/ui-prop-types/lib/Children.js");
13
+
14
+ var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
15
+
16
+ var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
17
+
18
+ var _DrilldownPage = require("./DrilldownPage");
19
+
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
+ const propTypes = {
44
+ rootPageId: _propTypes.default.string.isRequired,
45
+ children: _Children.Children.oneOf([_DrilldownPage.DrilldownPage]),
46
+ id: _propTypes.default.string,
47
+ label: _propTypes.default.string,
48
+ disabled: _propTypes.default.bool,
49
+ rotateFocus: _propTypes.default.bool,
50
+ as: _propTypes.default.elementType,
51
+ role: _propTypes.default.string,
52
+ elementRef: _propTypes.default.func,
53
+ drilldownRef: _propTypes.default.func,
54
+ overflowX: _propTypes.default.oneOf(['auto', 'hidden', 'visible']),
55
+ overflowY: _propTypes.default.oneOf(['auto', 'hidden', 'visible']),
56
+ height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
57
+ width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
58
+ maxHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
59
+ maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
60
+ trigger: _propTypes.default.node,
61
+ placement: _PositionPropTypes.PositionPropTypes.placement,
62
+ defaultShow: _propTypes.default.bool,
63
+ show: (0, _controllable.controllable)(_propTypes.default.bool, 'onToggle', 'defaultShow'),
64
+ onToggle: _propTypes.default.func,
65
+ onSelect: _propTypes.default.func,
66
+ onDismiss: _propTypes.default.func,
67
+ onFocus: _propTypes.default.func,
68
+ onMouseOver: _propTypes.default.func,
69
+ popoverRef: _propTypes.default.func,
70
+ mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
71
+ positionTarget: _PositionPropTypes.PositionPropTypes.mountNode,
72
+ constrain: _PositionPropTypes.PositionPropTypes.constrain,
73
+ shouldHideOnSelect: _propTypes.default.bool,
74
+ shouldContainFocus: _propTypes.default.bool,
75
+ shouldReturnFocus: _propTypes.default.bool,
76
+ withArrow: _propTypes.default.bool,
77
+ offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
78
+ offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
79
+ };
80
+ exports.propTypes = propTypes;
81
+ const allowedProps = ['rootPageId', 'children', 'id', 'label', 'disabled', 'rotateFocus', 'as', 'role', 'overflowX', 'overflowY', 'height', 'width', 'maxHeight', 'maxWidth', // Popover version props
82
+ 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'elementRef', 'drilldownRef', 'popoverRef', 'mountNode', 'positionTarget', 'constrain', 'shouldHideOnSelect', 'shouldContainFocus', 'shouldReturnFocus', 'withArrow', 'offsetX', 'offsetY'];
83
+ exports.allowedProps = allowedProps;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param {Object} componentTheme The theme variable object.
38
+ * @param {Object} props the props of the component, the style is applied to
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (componentTheme, _props, state) => {
43
+ const hasHighlightedOption = state.hasHighlightedOption;
44
+ return {
45
+ drilldown: {
46
+ label: 'drilldown',
47
+ overflow: 'visible',
48
+ // needed for focus ring!
49
+ ...(hasHighlightedOption && {
50
+ '&:focus::before': {
51
+ display: 'none'
52
+ }
53
+ })
54
+ },
55
+ container: {
56
+ label: 'drilldown__container'
57
+ },
58
+ headerBack: {
59
+ label: 'drilldown__headerBack',
60
+ minHeight: '1.25em'
61
+ },
62
+ headerTitle: {
63
+ label: 'drilldown__headerTitle',
64
+ fontWeight: componentTheme.headerTitleFontWeight
65
+ },
66
+ optionContainer: {
67
+ label: 'drilldown__optionContainer',
68
+ alignItems: 'center',
69
+ display: 'flex',
70
+ height: '100%'
71
+ },
72
+ optionLabelInfo: {
73
+ label: 'drilldown__optionLabelInfo',
74
+ display: 'flex',
75
+ flexShrink: 0,
76
+ height: '100%',
77
+ alignItems: 'center',
78
+ paddingInlineStart: componentTheme.labelInfoPadding
79
+ },
80
+ optionContent: {
81
+ label: 'drilldown__optionContent',
82
+ flexGrow: 1
83
+ },
84
+ // we use it in the index file
85
+ headerActionColor: componentTheme.headerActionColor
86
+ };
87
+ };
88
+
89
+ var _default = generateStyle;
90
+ exports.default = _default;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /*
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2015 - present Instructure, Inc.
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all
21
+ * copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ * SOFTWARE.
30
+ */
31
+
32
+ /**
33
+ * Generates the theme object for the component from the theme and provided additional information
34
+ * @param {Object} theme The actual theme object.
35
+ * @return {Object} The final theme object with the overrides and component variables
36
+ */
37
+ const generateComponentTheme = theme => {
38
+ const colors = theme.colors,
39
+ typography = theme.typography,
40
+ spacing = theme.spacing;
41
+ const componentVariables = {
42
+ headerTitleFontWeight: typography.fontWeightBold,
43
+ headerActionColor: colors.textLink,
44
+ labelInfoPadding: spacing === null || spacing === void 0 ? void 0 : spacing.small
45
+ };
46
+ return { ...componentVariables
47
+ };
48
+ };
49
+
50
+ var _default = generateComponentTheme;
51
+ exports.default = _default;
package/lib/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Drilldown", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Drilldown.Drilldown;
10
+ }
11
+ });
12
+
13
+ var _Drilldown = require("./Drilldown");
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@instructure/ui-drilldown",
3
+ "version": "8.21.1-snapshot.10+44e7e13f1",
4
+ "description": "A drilldown menu component",
5
+ "author": "Instructure, Inc. Engineering and Product Design",
6
+ "module": "./es/index.js",
7
+ "main": "./lib/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/instructure/instructure-ui.git"
12
+ },
13
+ "homepage": "https://instructure.github.io/instructure-ui/",
14
+ "bugs": "https://github.com/instructure/instructure-ui/issues",
15
+ "scripts": {
16
+ "lint": "ui-test --lint",
17
+ "lint:fix": "ui-test --lint --fix",
18
+ "clean": "ui-build --clean",
19
+ "build": "ui-build --modules es,cjs",
20
+ "build:watch": "yarn ts:check --watch & ui-build --watch",
21
+ "build:types": "tsc -p tsconfig.build.json",
22
+ "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
23
+ },
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "@babel/runtime": "^7.13.10",
27
+ "@instructure/console": "8.21.1-snapshot.10+44e7e13f1",
28
+ "@instructure/emotion": "8.21.1-snapshot.10+44e7e13f1",
29
+ "@instructure/shared-types": "8.21.1-snapshot.10+44e7e13f1",
30
+ "@instructure/ui-dom-utils": "8.21.1-snapshot.10+44e7e13f1",
31
+ "@instructure/ui-icons": "8.21.1-snapshot.10+44e7e13f1",
32
+ "@instructure/ui-options": "8.21.1-snapshot.10+44e7e13f1",
33
+ "@instructure/ui-popover": "8.21.1-snapshot.10+44e7e13f1",
34
+ "@instructure/ui-position": "8.21.1-snapshot.10+44e7e13f1",
35
+ "@instructure/ui-prop-types": "8.21.1-snapshot.10+44e7e13f1",
36
+ "@instructure/ui-react-utils": "8.21.1-snapshot.10+44e7e13f1",
37
+ "@instructure/ui-selectable": "8.21.1-snapshot.10+44e7e13f1",
38
+ "@instructure/ui-testable": "8.21.1-snapshot.10+44e7e13f1",
39
+ "@instructure/ui-utils": "8.21.1-snapshot.10+44e7e13f1",
40
+ "@instructure/ui-view": "8.21.1-snapshot.10+44e7e13f1",
41
+ "prop-types": "^15"
42
+ },
43
+ "devDependencies": {
44
+ "@instructure/ui-babel-preset": "8.21.1-snapshot.10+44e7e13f1",
45
+ "@instructure/ui-color-utils": "8.21.1-snapshot.10+44e7e13f1",
46
+ "@instructure/ui-test-locator": "8.21.1-snapshot.10+44e7e13f1",
47
+ "@instructure/ui-test-utils": "8.21.1-snapshot.10+44e7e13f1",
48
+ "@instructure/ui-themes": "8.21.1-snapshot.10+44e7e13f1"
49
+ },
50
+ "peerDependencies": {
51
+ "react": ">=16.8 <=17"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "sideEffects": false,
57
+ "gitHead": "44e7e13f1720680be9f7e76a3d3ec0cf94e88d5b"
58
+ }
@@ -0,0 +1,64 @@
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
+ /** @jsx jsx */
26
+ import { Component } from 'react'
27
+
28
+ import { withStyle } from '@instructure/emotion'
29
+ import { optionsThemeGenerator } from '@instructure/ui-options'
30
+
31
+ import { propTypes, allowedProps } from './props'
32
+ import type { DrilldownGroupProps } from './props'
33
+
34
+ /**
35
+ ---
36
+ parent: Drilldown
37
+ id: Drilldown.Group
38
+ ---
39
+ @module DrilldownGroup
40
+ @tsProps
41
+ **/
42
+ // needed for listing the available theme variables on docs page,
43
+ // we pass the themeOverrides to Options
44
+ @withStyle(null, optionsThemeGenerator)
45
+ class DrilldownGroup extends Component<DrilldownGroupProps> {
46
+ static readonly componentId = 'Drilldown.Group'
47
+
48
+ static propTypes = propTypes
49
+ static allowedProps = allowedProps
50
+ static defaultProps = {
51
+ disabled: false,
52
+ withoutSeparators: false,
53
+ role: 'group'
54
+ }
55
+
56
+ render() {
57
+ // this component is only used for prop validation.
58
+ // Drilldown.Group is parsed in Drilldown as an Options component.
59
+ return null
60
+ }
61
+ }
62
+
63
+ export default DrilldownGroup
64
+ export { DrilldownGroup }
@@ -0,0 +1,149 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import { Children } from '@instructure/ui-prop-types'
29
+
30
+ import DrilldownOption from '../DrilldownOption'
31
+ import DrilldownSeparator from '../DrilldownSeparator'
32
+
33
+ import type {
34
+ OtherHTMLAttributes,
35
+ PropValidators,
36
+ OptionsTheme,
37
+ AsElementType
38
+ } from '@instructure/shared-types'
39
+ import type { WithStyleProps } from '@instructure/emotion'
40
+
41
+ import Drilldown from '../index'
42
+ import type { DrilldownOptionValue } from '../DrilldownOption/props'
43
+ import type { OptionChild, SeparatorChild } from '../props'
44
+
45
+ type GroupChildren = OptionChild | SeparatorChild
46
+
47
+ type DrilldownGroupOwnProps = {
48
+ id: string
49
+
50
+ /**
51
+ * Children of type:
52
+ * `<Drilldown.Option />`, `<Drilldown.Separator />`
53
+ */
54
+ children?: GroupChildren | GroupChildren[] // TODO: type Children.oneOf([DrilldownOption, DrilldownSeparator])
55
+
56
+ /**
57
+ * The label of the option group.
58
+ */
59
+ renderGroupTitle?: React.ReactNode | (() => React.ReactNode)
60
+
61
+ /**
62
+ * Hides the separators around the group.
63
+ */
64
+ withoutSeparators?: boolean
65
+
66
+ /**
67
+ * Is the option group disabled.
68
+ */
69
+ disabled?: boolean
70
+
71
+ /**
72
+ * The ARIA role of the element.
73
+ */
74
+ role?: string
75
+
76
+ /**
77
+ * Element type to render as. By default, it inherits Drilldown's `as` prop.
78
+ */
79
+ as?: AsElementType
80
+
81
+ /**
82
+ * Provides a reference to the underlying html root element
83
+ */
84
+ elementRef?: (element: Element | null) => void
85
+
86
+ // selection props
87
+ /**
88
+ * Makes the option group selectable (with "check" icon indicators).
89
+ * Can be set to a single-select (radio) or a multi-select (checkbox) group.
90
+ */
91
+ selectableType?: 'single' | 'multiple'
92
+
93
+ /**
94
+ * An array of the values for the selected items on initial render. Works only with "selectableType" set. If "selectableType" is "single", the array has to have 1 item.
95
+ */
96
+ defaultSelected?: DrilldownOptionValue[]
97
+
98
+ /**
99
+ * Callback fired when an option within the `<Drilldown.Group />` is selected
100
+ */
101
+ onSelect?: (
102
+ event: React.SyntheticEvent,
103
+ args: {
104
+ value: DrilldownOptionValue[]
105
+ isSelected: boolean
106
+ selectedOption: OptionChild
107
+ drilldown: Drilldown
108
+ }
109
+ ) => void
110
+ }
111
+
112
+ type PropKeys = keyof DrilldownGroupOwnProps
113
+
114
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
115
+
116
+ type DrilldownGroupProps = DrilldownGroupOwnProps &
117
+ WithStyleProps<OptionsTheme, null> &
118
+ OtherHTMLAttributes<DrilldownGroupOwnProps>
119
+
120
+ const propTypes: PropValidators<PropKeys> = {
121
+ id: PropTypes.string.isRequired,
122
+ children: Children.oneOf([DrilldownOption, DrilldownSeparator]),
123
+ renderGroupTitle: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
124
+ withoutSeparators: PropTypes.bool,
125
+ disabled: PropTypes.bool,
126
+ role: PropTypes.string,
127
+ as: PropTypes.elementType,
128
+ elementRef: PropTypes.func,
129
+ selectableType: PropTypes.oneOf(['single', 'multiple']),
130
+ defaultSelected: PropTypes.array,
131
+ onSelect: PropTypes.func
132
+ }
133
+
134
+ const allowedProps: AllowedPropKeys = [
135
+ 'id',
136
+ 'children',
137
+ 'renderGroupTitle',
138
+ 'withoutSeparators',
139
+ 'disabled',
140
+ 'role',
141
+ 'as',
142
+ 'elementRef',
143
+ 'selectableType',
144
+ 'defaultSelected',
145
+ 'onSelect'
146
+ ]
147
+
148
+ export type { DrilldownGroupProps, GroupChildren }
149
+ export { propTypes, allowedProps }
@@ -0,0 +1,101 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { locator } from '@instructure/ui-test-locator'
26
+ import { find, findAll, parseQueryArguments } from '@instructure/ui-test-utils'
27
+
28
+ /* eslint-disable no-restricted-imports */
29
+ // @ts-expect-error bypass no type definition found error
30
+ import { OptionsItemLocator } from '@instructure/ui-options/es/Options/Item/OptionsItemLocator'
31
+ // @ts-expect-error bypass no type definition found error
32
+ import { PopoverLocator } from '@instructure/ui-popover/es/Popover/PopoverLocator'
33
+ /* eslint-enable no-restricted-imports */
34
+
35
+ import { Drilldown } from './index'
36
+
37
+ const customMethods = {
38
+ // return the wrapper Option.Items
39
+ findAllOptions: async (...args: any[]) => {
40
+ return await findAll('[role^=menuitem]', ...args)
41
+ },
42
+ findAllOptionWrappers: async (...args: any[]) => {
43
+ return await OptionsItemLocator.findAll(...args)
44
+ },
45
+ findOptionWrapperByOptionId: async (
46
+ _element: any,
47
+ optionId: string,
48
+ ...args: any[]
49
+ ) => {
50
+ return OptionsItemLocator.find(`:has(#${optionId})`, ...args)
51
+ },
52
+ findSizableContainer: async (...args: any[]) => {
53
+ return await find('[class$=-drilldown__container]', ...args)
54
+ },
55
+ findSelectableContainer: async (...args: any[]) => {
56
+ return await find('[id^=Selectable_][id$=-list]', ...args)
57
+ },
58
+ findHeaderTitle: async (...args: any[]) => {
59
+ return await find('[id^=DrilldownHeader-Title]', ...args)
60
+ },
61
+ findHeaderActionOption: async (...args: any[]) => {
62
+ return await find('[id^=DrilldownHeader-Action]', ...args)
63
+ },
64
+ findHeaderBackOption: async (...args: any[]) => {
65
+ return await find('[id^=DrilldownHeader-Back]', ...args)
66
+ },
67
+ findHeaderSeparator: async (...args: any[]) => {
68
+ return await find('[id^=DrilldownHeader-Separator]', ...args)
69
+ },
70
+ findAllSeparators: async (...args: any[]) => {
71
+ return await findAll('[class$=-separator]', ...args)
72
+ },
73
+ findAllGroupLabels: async (...args: any[]) => {
74
+ return await findAll('[class$=-options__label]', ...args)
75
+ },
76
+ findLabelInfo: async (...args: any[]) => {
77
+ return await find('[class$=-drilldown__optionLabelInfo]', ...args)
78
+ },
79
+ findDescription: async (...args: any[]) => {
80
+ return await find('[class$=__description]', ...args)
81
+ },
82
+ findPopoverRoot: (...args: any[]) => {
83
+ return PopoverLocator.find(...args)
84
+ },
85
+ findPopoverTrigger: (...args: any[]) => {
86
+ return PopoverLocator.findTrigger(...args)
87
+ },
88
+ findPopoverContent: (...args: any[]) => {
89
+ const { element, selector, options } = parseQueryArguments(...args)
90
+ return PopoverLocator.findContent(element, selector, {
91
+ ...options,
92
+ customMethods: {
93
+ ...options.customMethods,
94
+ ...customMethods
95
+ }
96
+ })
97
+ }
98
+ }
99
+
100
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
101
+ export const DrilldownLocator = locator(Drilldown.selector, customMethods)