@instructure/ui-tree-browser 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.
- package/CHANGELOG.md +33 -288
- package/es/TreeBrowser/{TreeButton → v1/TreeButton}/index.js +2 -2
- package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.js +1 -1
- package/es/TreeBrowser/{TreeNode → v1/TreeNode}/index.js +2 -2
- package/es/TreeBrowser/{index.js → v1/index.js} +1 -1
- package/es/TreeBrowser/v2/TreeBrowserContext.js +39 -0
- package/es/TreeBrowser/v2/TreeButton/index.js +202 -0
- package/es/TreeBrowser/v2/TreeButton/props.js +26 -0
- package/es/TreeBrowser/v2/TreeButton/styles.js +306 -0
- package/es/TreeBrowser/v2/TreeCollection/index.js +367 -0
- package/es/TreeBrowser/v2/TreeCollection/props.js +26 -0
- package/es/TreeBrowser/v2/TreeCollection/styles.js +143 -0
- package/es/TreeBrowser/v2/TreeNode/index.js +156 -0
- package/es/{index.js → TreeBrowser/v2/TreeNode/props.js} +3 -4
- package/es/TreeBrowser/v2/index.js +347 -0
- package/es/TreeBrowser/v2/props.js +35 -0
- package/es/TreeBrowser/v2/styles.js +71 -0
- package/es/exports/a.js +27 -0
- package/es/exports/b.js +27 -0
- package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/index.js +3 -3
- package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.js +1 -1
- package/lib/TreeBrowser/{TreeNode → v1/TreeNode}/index.js +3 -3
- package/lib/TreeBrowser/{index.js → v1/index.js} +3 -3
- package/lib/TreeBrowser/v2/TreeBrowserContext.js +44 -0
- package/lib/TreeBrowser/v2/TreeButton/index.js +208 -0
- package/lib/TreeBrowser/v2/TreeButton/props.js +31 -0
- package/lib/TreeBrowser/v2/TreeButton/styles.js +312 -0
- package/lib/TreeBrowser/v2/TreeCollection/index.js +372 -0
- package/lib/TreeBrowser/v2/TreeCollection/props.js +31 -0
- package/lib/TreeBrowser/v2/TreeCollection/styles.js +149 -0
- package/lib/TreeBrowser/v2/TreeNode/index.js +162 -0
- package/lib/TreeBrowser/v2/TreeNode/props.js +31 -0
- package/lib/TreeBrowser/v2/index.js +353 -0
- package/lib/TreeBrowser/v2/props.js +40 -0
- package/lib/TreeBrowser/v2/styles.js +77 -0
- package/lib/{index.js → exports/a.js} +5 -5
- package/lib/exports/b.js +33 -0
- package/package.json +40 -18
- package/src/TreeBrowser/{TreeButton → v1/TreeButton}/index.tsx +2 -2
- package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.tsx +1 -1
- package/src/TreeBrowser/{TreeNode → v1/TreeNode}/index.tsx +2 -2
- package/src/TreeBrowser/{index.tsx → v1/index.tsx} +1 -1
- package/src/TreeBrowser/v2/README.md +712 -0
- package/src/TreeBrowser/v2/TreeBrowserContext.ts +53 -0
- package/src/TreeBrowser/v2/TreeButton/index.tsx +210 -0
- package/src/TreeBrowser/v2/TreeButton/props.ts +95 -0
- package/src/TreeBrowser/v2/TreeButton/styles.ts +331 -0
- package/src/TreeBrowser/v2/TreeCollection/index.tsx +416 -0
- package/src/TreeBrowser/v2/TreeCollection/props.ts +88 -0
- package/src/TreeBrowser/v2/TreeCollection/styles.ts +157 -0
- package/src/TreeBrowser/v2/TreeNode/index.tsx +158 -0
- package/src/TreeBrowser/v2/TreeNode/props.ts +84 -0
- package/src/TreeBrowser/v2/index.tsx +438 -0
- package/src/TreeBrowser/v2/props.ts +245 -0
- package/src/TreeBrowser/v2/styles.ts +79 -0
- package/src/exports/a.ts +32 -0
- package/src/exports/b.ts +32 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TreeBrowser/v1/TreeBrowserContext.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeButton/theme.d.ts.map +1 -0
- package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/index.d.ts +1 -1
- package/types/TreeBrowser/v1/TreeCollection/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeCollection/theme.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeNode/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/TreeNode/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/index.d.ts.map +1 -0
- package/types/TreeBrowser/v1/props.d.ts.map +1 -0
- package/types/TreeBrowser/v1/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v1/theme.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeBrowserContext.d.ts +24 -0
- package/types/TreeBrowser/v2/TreeBrowserContext.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/index.d.ts +44 -0
- package/types/TreeBrowser/v2/TreeButton/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/props.d.ts +37 -0
- package/types/TreeBrowser/v2/TreeButton/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeButton/styles.d.ts +19 -0
- package/types/TreeBrowser/v2/TreeButton/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/index.d.ts +66 -0
- package/types/TreeBrowser/v2/TreeCollection/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/props.d.ts +24 -0
- package/types/TreeBrowser/v2/TreeCollection/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeCollection/styles.d.ts +18 -0
- package/types/TreeBrowser/v2/TreeCollection/styles.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeNode/index.d.ts +41 -0
- package/types/TreeBrowser/v2/TreeNode/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/TreeNode/props.d.ts +25 -0
- package/types/TreeBrowser/v2/TreeNode/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/index.d.ts +70 -0
- package/types/TreeBrowser/v2/index.d.ts.map +1 -0
- package/types/TreeBrowser/v2/props.d.ts +163 -0
- package/types/TreeBrowser/v2/props.d.ts.map +1 -0
- package/types/TreeBrowser/v2/styles.d.ts +16 -0
- package/types/TreeBrowser/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +9 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +9 -0
- package/types/exports/b.d.ts.map +1 -0
- package/src/index.ts +0 -32
- package/types/TreeBrowser/TreeBrowserContext.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/props.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/styles.d.ts.map +0 -1
- package/types/TreeBrowser/TreeButton/theme.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/props.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/styles.d.ts.map +0 -1
- package/types/TreeBrowser/TreeCollection/theme.d.ts.map +0 -1
- package/types/TreeBrowser/TreeNode/index.d.ts.map +0 -1
- package/types/TreeBrowser/TreeNode/props.d.ts.map +0 -1
- package/types/TreeBrowser/index.d.ts.map +0 -1
- package/types/TreeBrowser/props.d.ts.map +0 -1
- package/types/TreeBrowser/styles.d.ts.map +0 -1
- package/types/TreeBrowser/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -9
- package/types/index.d.ts.map +0 -1
- /package/es/TreeBrowser/{TreeBrowserContext.js → v1/TreeBrowserContext.js} +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/props.js +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/styles.js +0 -0
- /package/es/TreeBrowser/{TreeButton → v1/TreeButton}/theme.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.js +0 -0
- /package/es/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.js +0 -0
- /package/es/TreeBrowser/{TreeNode → v1/TreeNode}/props.js +0 -0
- /package/es/TreeBrowser/{props.js → v1/props.js} +0 -0
- /package/es/TreeBrowser/{styles.js → v1/styles.js} +0 -0
- /package/es/TreeBrowser/{theme.js → v1/theme.js} +0 -0
- /package/lib/TreeBrowser/{TreeBrowserContext.js → v1/TreeBrowserContext.js} +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/props.js +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/styles.js +0 -0
- /package/lib/TreeBrowser/{TreeButton → v1/TreeButton}/theme.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.js +0 -0
- /package/lib/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.js +0 -0
- /package/lib/TreeBrowser/{TreeNode → v1/TreeNode}/props.js +0 -0
- /package/lib/TreeBrowser/{props.js → v1/props.js} +0 -0
- /package/lib/TreeBrowser/{styles.js → v1/styles.js} +0 -0
- /package/lib/TreeBrowser/{theme.js → v1/theme.js} +0 -0
- /package/src/TreeBrowser/{README.md → v1/README.md} +0 -0
- /package/src/TreeBrowser/{TreeBrowserContext.ts → v1/TreeBrowserContext.ts} +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/props.ts +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/styles.ts +0 -0
- /package/src/TreeBrowser/{TreeButton → v1/TreeButton}/theme.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.ts +0 -0
- /package/src/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.ts +0 -0
- /package/src/TreeBrowser/{TreeNode → v1/TreeNode}/props.ts +0 -0
- /package/src/TreeBrowser/{props.ts → v1/props.ts} +0 -0
- /package/src/TreeBrowser/{styles.ts → v1/styles.ts} +0 -0
- /package/src/TreeBrowser/{theme.ts → v1/theme.ts} +0 -0
- /package/types/TreeBrowser/{TreeBrowserContext.d.ts → v1/TreeBrowserContext.d.ts} +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/index.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/props.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/styles.d.ts +0 -0
- /package/types/TreeBrowser/{TreeButton → v1/TreeButton}/theme.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/props.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/styles.d.ts +0 -0
- /package/types/TreeBrowser/{TreeCollection → v1/TreeCollection}/theme.d.ts +0 -0
- /package/types/TreeBrowser/{TreeNode → v1/TreeNode}/index.d.ts +0 -0
- /package/types/TreeBrowser/{TreeNode → v1/TreeNode}/props.d.ts +0 -0
- /package/types/TreeBrowser/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/TreeBrowser/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/TreeBrowser/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/TreeBrowser/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
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.TreeNode = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _latest = require("@instructure/ui-img/latest");
|
|
10
|
+
var _emotion = require("@instructure/emotion");
|
|
11
|
+
var _renderIconWithProps = require("@instructure/ui-icons/lib/IconPropsProvider/renderIconWithProps.js");
|
|
12
|
+
var _styles = _interopRequireDefault(require("../TreeButton/styles"));
|
|
13
|
+
var _props = require("./props");
|
|
14
|
+
var _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
|
|
15
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
|
+
var _dec, _class, _TreeNode;
|
|
17
|
+
/*
|
|
18
|
+
* The MIT License (MIT)
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2021 - present Instructure, Inc.
|
|
21
|
+
*
|
|
22
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
24
|
+
* in the Software without restriction, including without limitation the rights
|
|
25
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
27
|
+
* furnished to do so, subject to the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
30
|
+
* copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
+
* SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
// Map TreeBrowser size tokens to icon size tokens
|
|
41
|
+
const treeBrowserSizeToIconSize = {
|
|
42
|
+
small: 'md',
|
|
43
|
+
medium: 'lg',
|
|
44
|
+
large: 'xl'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Todo: merge TreeButton and TreeNode: TreeButton should be a special type of TreeNode
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
---
|
|
51
|
+
parent: TreeBrowser
|
|
52
|
+
id: TreeBrowser.Node
|
|
53
|
+
---
|
|
54
|
+
A helper class used to render the :renderBeforeItems and :renderAfterItems
|
|
55
|
+
in the TreeBrowser.
|
|
56
|
+
**/
|
|
57
|
+
let TreeNode = exports.TreeNode = (_dec = (0, _emotion.withStyle)(_styles.default, 'TreeBrowserTreeButton'), _dec(_class = (_TreeNode = class TreeNode extends _react.Component {
|
|
58
|
+
constructor(...args) {
|
|
59
|
+
super(...args);
|
|
60
|
+
this.ref = null;
|
|
61
|
+
this.state = {
|
|
62
|
+
isHovered: false
|
|
63
|
+
};
|
|
64
|
+
this.handleRef = el => {
|
|
65
|
+
if (el && typeof this.props.containerRef === 'function') {
|
|
66
|
+
this.props.containerRef(el.parentElement);
|
|
67
|
+
}
|
|
68
|
+
this.ref = el;
|
|
69
|
+
};
|
|
70
|
+
this.handleMouseEnter = () => {
|
|
71
|
+
if (this.props.hoverable) {
|
|
72
|
+
this.setState({
|
|
73
|
+
isHovered: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.handleMouseLeave = () => {
|
|
78
|
+
if (this.props.hoverable) {
|
|
79
|
+
this.setState({
|
|
80
|
+
isHovered: false
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
componentDidMount() {
|
|
86
|
+
var _this$props$makeStyle, _this$props, _this$context;
|
|
87
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
88
|
+
animation: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.animation,
|
|
89
|
+
hoverable: this.props.hoverable
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
componentDidUpdate() {
|
|
93
|
+
var _this$props$makeStyle2, _this$props2, _this$context2;
|
|
94
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
95
|
+
animation: (_this$context2 = this.context) === null || _this$context2 === void 0 ? void 0 : _this$context2.animation,
|
|
96
|
+
hoverable: this.props.hoverable
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getIconColor() {
|
|
100
|
+
const selected = this.props.selected;
|
|
101
|
+
const isHovered = this.state.isHovered;
|
|
102
|
+
|
|
103
|
+
// Priority: selected > hover > default
|
|
104
|
+
if (selected) return 'onColor';
|
|
105
|
+
if (isHovered) return 'inverseColor';
|
|
106
|
+
return 'baseColor';
|
|
107
|
+
}
|
|
108
|
+
renderItemImage() {
|
|
109
|
+
const _this$props3 = this.props,
|
|
110
|
+
thumbnail = _this$props3.thumbnail,
|
|
111
|
+
itemIcon = _this$props3.itemIcon,
|
|
112
|
+
styles = _this$props3.styles,
|
|
113
|
+
size = _this$props3.size;
|
|
114
|
+
if (thumbnail) {
|
|
115
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
116
|
+
css: styles === null || styles === void 0 ? void 0 : styles.thumbnail,
|
|
117
|
+
children: (0, _jsxRuntime.jsx)(_latest.Img, {
|
|
118
|
+
src: thumbnail,
|
|
119
|
+
constrain: "cover",
|
|
120
|
+
alt: ""
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (itemIcon) {
|
|
125
|
+
const iconSize = treeBrowserSizeToIconSize[size];
|
|
126
|
+
const iconColor = this.getIconColor();
|
|
127
|
+
const iconElement = (0, _renderIconWithProps.renderIconWithProps)(itemIcon, iconSize, iconColor);
|
|
128
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
129
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
130
|
+
children: iconElement
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
render() {
|
|
136
|
+
const _this$props4 = this.props,
|
|
137
|
+
children = _this$props4.children,
|
|
138
|
+
styles = _this$props4.styles;
|
|
139
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
140
|
+
ref: this.handleRef,
|
|
141
|
+
tabIndex: -1,
|
|
142
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeButton,
|
|
143
|
+
"data-cid": "TreeNode",
|
|
144
|
+
onMouseEnter: this.handleMouseEnter,
|
|
145
|
+
onMouseLeave: this.handleMouseLeave,
|
|
146
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
147
|
+
css: styles === null || styles === void 0 ? void 0 : styles.layout,
|
|
148
|
+
children: [this.renderItemImage(), (0, _jsxRuntime.jsx)("span", {
|
|
149
|
+
css: styles === null || styles === void 0 ? void 0 : styles.node,
|
|
150
|
+
children: children
|
|
151
|
+
})]
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, _TreeNode.displayName = "TreeNode", _TreeNode.componentId = 'TreeBrowser.Node', _TreeNode.allowedProps = _props.allowedProps, _TreeNode.contextType = _TreeBrowserContext.default, _TreeNode.defaultProps = {
|
|
156
|
+
size: 'medium',
|
|
157
|
+
variant: 'folderTree',
|
|
158
|
+
selected: false,
|
|
159
|
+
focused: false,
|
|
160
|
+
hoverable: true
|
|
161
|
+
}, _TreeNode)) || _class);
|
|
162
|
+
var _default = exports.default = TreeNode;
|
|
@@ -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 = ['id', 'size', 'variant', 'selected', 'focused', 'itemIcon', 'thumbnail', 'level', 'children', 'containerRef', 'onKeyDown', 'onClick', 'hoverable'];
|
|
@@ -0,0 +1,353 @@
|
|
|
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.TreeBrowser = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _keycode = _interopRequireDefault(require("keycode"));
|
|
10
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
11
|
+
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
12
|
+
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
13
|
+
var _emotion = require("@instructure/emotion");
|
|
14
|
+
var _TreeCollection = require("./TreeCollection");
|
|
15
|
+
var _TreeButton = require("./TreeButton");
|
|
16
|
+
var _TreeNode = require("./TreeNode");
|
|
17
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
|
+
var _props = require("./props");
|
|
19
|
+
var _TreeBrowserContext = _interopRequireDefault(require("./TreeBrowserContext"));
|
|
20
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
21
|
+
var _dec, _class, _TreeBrowser;
|
|
22
|
+
/*
|
|
23
|
+
* The MIT License (MIT)
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
26
|
+
*
|
|
27
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
* in the Software without restriction, including without limitation the rights
|
|
30
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
* furnished to do so, subject to the following conditions:
|
|
33
|
+
*
|
|
34
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
* copies or substantial portions of the Software.
|
|
36
|
+
*
|
|
37
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
* SOFTWARE.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
---
|
|
47
|
+
category: components
|
|
48
|
+
---
|
|
49
|
+
**/
|
|
50
|
+
let TreeBrowser = exports.TreeBrowser = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_TreeBrowser = class TreeBrowser extends _react.Component {
|
|
51
|
+
constructor(props) {
|
|
52
|
+
super(props);
|
|
53
|
+
this.ref = null;
|
|
54
|
+
this.handleCollectionClick = (e, collection, expand = true) => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
const onCollectionClick = this.props.onCollectionClick;
|
|
57
|
+
if (expand) this.expandOrCollapseNode(collection);
|
|
58
|
+
onCollectionClick === null || onCollectionClick === void 0 ? void 0 : onCollectionClick(collection.id, collection); // TODO: this should pass the event as the first arg
|
|
59
|
+
this.handleSelection(collection.id, 'collection');
|
|
60
|
+
};
|
|
61
|
+
this.handleItemClick = (e, item) => {
|
|
62
|
+
var _this$props$onItemCli, _this$props;
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
(_this$props$onItemCli = (_this$props = this.props).onItemClick) === null || _this$props$onItemCli === void 0 ? void 0 : _this$props$onItemCli.call(_this$props, item);
|
|
65
|
+
this.handleSelection(item.id, 'item');
|
|
66
|
+
};
|
|
67
|
+
this.handleKeyDown = (event, node) => {
|
|
68
|
+
switch (event.keyCode) {
|
|
69
|
+
case _keycode.default.codes.down:
|
|
70
|
+
case _keycode.default.codes.j:
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
this.moveFocus(1);
|
|
73
|
+
break;
|
|
74
|
+
case _keycode.default.codes.up:
|
|
75
|
+
case _keycode.default.codes.k:
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
this.moveFocus(-1);
|
|
78
|
+
break;
|
|
79
|
+
case _keycode.default.codes.home:
|
|
80
|
+
case _keycode.default.codes.end:
|
|
81
|
+
event.stopPropagation();
|
|
82
|
+
this.homeOrEnd(event.keyCode);
|
|
83
|
+
break;
|
|
84
|
+
case _keycode.default.codes.left:
|
|
85
|
+
case _keycode.default.codes.right:
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
this.handleLeftOrRightArrow(event.keyCode, node);
|
|
88
|
+
break;
|
|
89
|
+
case _keycode.default.codes.enter:
|
|
90
|
+
case _keycode.default.codes.space:
|
|
91
|
+
event.stopPropagation();
|
|
92
|
+
this.handleActivation(event, node);
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
};
|
|
99
|
+
this.clearSelection = () => {
|
|
100
|
+
const onSelectionChange = this.props.onSelectionChange;
|
|
101
|
+
|
|
102
|
+
// Call the callback if provided (for controlled selection)
|
|
103
|
+
if (onSelectionChange) {
|
|
104
|
+
onSelectionChange('', 'item', void 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Update internal state only if uncontrolled
|
|
108
|
+
if (typeof this.props.selection === 'undefined') {
|
|
109
|
+
this.setState({
|
|
110
|
+
selection: ''
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
this.getIsFlattened = collection => {
|
|
115
|
+
const _this$props2 = this.props,
|
|
116
|
+
rootId = _this$props2.rootId,
|
|
117
|
+
showRootCollection = _this$props2.showRootCollection;
|
|
118
|
+
return !showRootCollection && typeof rootId !== 'undefined' && collection.id === rootId;
|
|
119
|
+
};
|
|
120
|
+
const initialState = {
|
|
121
|
+
selection: ''
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Handle expanded state (controlled vs uncontrolled)
|
|
125
|
+
if (typeof this.props.expanded === 'undefined') {
|
|
126
|
+
initialState.expanded = this.props.defaultExpanded;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Handle selection state (controlled vs uncontrolled)
|
|
130
|
+
if (typeof this.props.selection === 'undefined') {
|
|
131
|
+
initialState.selection = this.props.defaultSelection || '';
|
|
132
|
+
}
|
|
133
|
+
this.state = initialState;
|
|
134
|
+
}
|
|
135
|
+
componentDidMount() {
|
|
136
|
+
var _this$props$makeStyle, _this$props3;
|
|
137
|
+
(_this$props$makeStyle = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props3);
|
|
138
|
+
}
|
|
139
|
+
componentDidUpdate() {
|
|
140
|
+
var _this$props$makeStyle2, _this$props4;
|
|
141
|
+
(_this$props$makeStyle2 = (_this$props4 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props4);
|
|
142
|
+
}
|
|
143
|
+
get _root() {
|
|
144
|
+
return this.ref;
|
|
145
|
+
}
|
|
146
|
+
get collections() {
|
|
147
|
+
const _this$props5 = this.props,
|
|
148
|
+
collections = _this$props5.collections,
|
|
149
|
+
rootId = _this$props5.rootId;
|
|
150
|
+
if (typeof rootId !== 'undefined') {
|
|
151
|
+
return [collections[rootId]];
|
|
152
|
+
} else {
|
|
153
|
+
return Object.keys(collections).map(id => collections[id]).filter(collection => collection != null);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
get expanded() {
|
|
157
|
+
return this.getExpanded(this.state, this.props);
|
|
158
|
+
}
|
|
159
|
+
getExpanded(state, props) {
|
|
160
|
+
return typeof props.expanded === 'undefined' ? state.expanded : props.expanded;
|
|
161
|
+
}
|
|
162
|
+
get selection() {
|
|
163
|
+
return this.getSelection(this.state, this.props);
|
|
164
|
+
}
|
|
165
|
+
getSelection(state, props) {
|
|
166
|
+
return typeof props.selection === 'undefined' ? state.selection : props.selection;
|
|
167
|
+
}
|
|
168
|
+
expandOrCollapseNode(collection) {
|
|
169
|
+
var _this$props$onCollect, _this$props6;
|
|
170
|
+
(_this$props$onCollect = (_this$props6 = this.props).onCollectionToggle) === null || _this$props$onCollect === void 0 ? void 0 : _this$props$onCollect.call(_this$props6, collection);
|
|
171
|
+
if (typeof this.props.expanded === 'undefined') {
|
|
172
|
+
this.setState((state, props) => {
|
|
173
|
+
const expanded = [...this.getExpanded(state, props)];
|
|
174
|
+
const expandedIndex = this.getExpandedIndex(expanded, collection.id);
|
|
175
|
+
if (collection.expanded && expandedIndex < 0) {
|
|
176
|
+
expanded.push(collection.id);
|
|
177
|
+
} else if (expandedIndex >= 0) {
|
|
178
|
+
expanded.splice(expandedIndex, 1);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
expanded
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
handleSelection(id, type) {
|
|
187
|
+
const _this$props7 = this.props,
|
|
188
|
+
selectionType = _this$props7.selectionType,
|
|
189
|
+
onSelectionChange = _this$props7.onSelectionChange;
|
|
190
|
+
if (selectionType !== 'single') return;
|
|
191
|
+
const selection = `${type}_${id}`;
|
|
192
|
+
|
|
193
|
+
// Call the callback if provided (for controlled selection)
|
|
194
|
+
if (onSelectionChange) {
|
|
195
|
+
onSelectionChange(selection, type, id);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Update internal state only if uncontrolled
|
|
199
|
+
if (typeof this.props.selection === 'undefined') {
|
|
200
|
+
this.setState(state => {
|
|
201
|
+
if (state.selection !== selection) {
|
|
202
|
+
return {
|
|
203
|
+
selection
|
|
204
|
+
};
|
|
205
|
+
} else {
|
|
206
|
+
return state;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
getNavigableNodes() {
|
|
212
|
+
return Array.from(this.ref.querySelectorAll('[role="treeitem"]'));
|
|
213
|
+
}
|
|
214
|
+
moveFocus(delta) {
|
|
215
|
+
const nodes = this.getNavigableNodes();
|
|
216
|
+
const closest = window.document.activeElement.closest('[role="treeitem"]');
|
|
217
|
+
const active = nodes.indexOf(closest);
|
|
218
|
+
let next = active + delta;
|
|
219
|
+
if (next < 0) {
|
|
220
|
+
next = 0;
|
|
221
|
+
} else if (next >= nodes.length) {
|
|
222
|
+
next = nodes.length - 1;
|
|
223
|
+
}
|
|
224
|
+
nodes.forEach(n => {
|
|
225
|
+
n.setAttribute('tabindex', '-1');
|
|
226
|
+
});
|
|
227
|
+
nodes[next].setAttribute('tabindex', '0');
|
|
228
|
+
nodes[next].focus();
|
|
229
|
+
}
|
|
230
|
+
homeOrEnd(keyCode) {
|
|
231
|
+
const length = this.getNavigableNodes().length;
|
|
232
|
+
if (keyCode === _keycode.default.codes.home) {
|
|
233
|
+
this.moveFocus(1 - length);
|
|
234
|
+
} else {
|
|
235
|
+
this.moveFocus(length - 1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
handleLeftOrRightArrow(keyCode, node) {
|
|
239
|
+
const ltr = !(this.ref.parentElement.dir === 'rtl' || document.dir === 'rtl');
|
|
240
|
+
if (ltr && keyCode === _keycode.default.codes.left || !ltr && keyCode == _keycode.default.codes.right) {
|
|
241
|
+
this.handleCloseOrPrevious(node);
|
|
242
|
+
} else {
|
|
243
|
+
this.handleOpenOrNext(node);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
handleOpenOrNext(node) {
|
|
247
|
+
if (node && !this.expanded.includes(node.id) && node.type === 'collection') {
|
|
248
|
+
this.expandOrCollapseNode(node);
|
|
249
|
+
} else {
|
|
250
|
+
this.moveFocus(1);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
handleCloseOrPrevious(node) {
|
|
254
|
+
if (node && this.expanded.includes(node.id) && node.type === 'collection') {
|
|
255
|
+
this.expandOrCollapseNode(node);
|
|
256
|
+
} else {
|
|
257
|
+
this.moveFocus(-1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
handleActivation(event, node) {
|
|
261
|
+
if (node == null) return;
|
|
262
|
+
if (node.type === 'collection') {
|
|
263
|
+
this.handleCollectionClick(event, node, this.props.selectionType === 'none');
|
|
264
|
+
} else {
|
|
265
|
+
this.handleItemClick(event, node);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
getSubCollections(collection) {
|
|
269
|
+
const collections = collection.collections ? [...collection.collections] : [];
|
|
270
|
+
return collections.map(id => this.getCollectionProps(this.props.collections[id])).filter(collection => collection != null).sort(this.props.sortOrder);
|
|
271
|
+
}
|
|
272
|
+
getItems(collection) {
|
|
273
|
+
if (collection.items) {
|
|
274
|
+
const items = collection.items ? [...collection.items] : [];
|
|
275
|
+
return items.map(id => {
|
|
276
|
+
return {
|
|
277
|
+
...this.props.items[id]
|
|
278
|
+
};
|
|
279
|
+
}).filter(item => item != null).sort(this.props.sortOrder);
|
|
280
|
+
} else {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
getCollectionProps(collection) {
|
|
285
|
+
return {
|
|
286
|
+
id: collection.id,
|
|
287
|
+
name: collection.name,
|
|
288
|
+
collections: this.getSubCollections(collection),
|
|
289
|
+
items: this.getItems(collection),
|
|
290
|
+
descriptor: collection.descriptor,
|
|
291
|
+
containerRef: collection.containerRef,
|
|
292
|
+
renderBeforeItems: collection.renderBeforeItems,
|
|
293
|
+
renderAfterItems: collection.renderAfterItems,
|
|
294
|
+
expanded: this.getExpandedIndex(this.expanded, collection.id) >= 0,
|
|
295
|
+
isCollectionFlattened: this.getIsFlattened(collection),
|
|
296
|
+
compareFunc: collection.compareFunc
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
getExpandedIndex(expanded, id) {
|
|
300
|
+
return expanded.findIndex(expanded => String(expanded) === String(id));
|
|
301
|
+
}
|
|
302
|
+
renderRoot() {
|
|
303
|
+
return this.collections.sort(this.props.sortOrder).map((collection, i) => (0, _jsxRuntime.jsx)(_TreeCollection.TreeCollection, {
|
|
304
|
+
...(0, _pickProps.pickProps)((0, _omitProps.omitProps)(this.props), _TreeCollection.TreeCollection.allowedProps),
|
|
305
|
+
...this.getCollectionProps(collection),
|
|
306
|
+
selection: this.selection,
|
|
307
|
+
onItemClick: this.handleItemClick,
|
|
308
|
+
onCollectionClick: this.handleCollectionClick,
|
|
309
|
+
onKeyDown: this.handleKeyDown,
|
|
310
|
+
numChildren: this.collections.length,
|
|
311
|
+
level: 1,
|
|
312
|
+
position: 1,
|
|
313
|
+
renderContent: this.props.renderContent
|
|
314
|
+
}, i));
|
|
315
|
+
}
|
|
316
|
+
render() {
|
|
317
|
+
const styles = this.props.styles;
|
|
318
|
+
return (0, _jsxRuntime.jsx)(_TreeBrowserContext.default.Provider, {
|
|
319
|
+
value: {
|
|
320
|
+
animation: this.props.animation,
|
|
321
|
+
clearSelection: this.clearSelection
|
|
322
|
+
},
|
|
323
|
+
children: (0, _jsxRuntime.jsx)("ul", {
|
|
324
|
+
css: styles === null || styles === void 0 ? void 0 : styles.treeBrowser,
|
|
325
|
+
tabIndex: 0,
|
|
326
|
+
role: "tree",
|
|
327
|
+
onKeyDown: this.handleKeyDown,
|
|
328
|
+
ref: el => {
|
|
329
|
+
this.ref = el;
|
|
330
|
+
},
|
|
331
|
+
"aria-label": this.props.treeLabel,
|
|
332
|
+
"data-cid": "TreeBrowser",
|
|
333
|
+
children: this.renderRoot()
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}, _TreeBrowser.displayName = "TreeBrowser", _TreeBrowser.componentId = 'TreeBrowser', _TreeBrowser.allowedProps = _props.allowedProps, _TreeBrowser.defaultProps = {
|
|
338
|
+
size: 'medium',
|
|
339
|
+
variant: 'folderTree',
|
|
340
|
+
showRootCollection: true,
|
|
341
|
+
collectionIcon: _uiIcons.FolderClosedInstUIIcon,
|
|
342
|
+
collectionIconExpanded: _uiIcons.FolderClosedInstUIIcon,
|
|
343
|
+
itemIcon: _uiIcons.FileTextInstUIIcon,
|
|
344
|
+
getItemProps: props => props,
|
|
345
|
+
getCollectionProps: props => props,
|
|
346
|
+
defaultExpanded: [],
|
|
347
|
+
selectionType: 'none',
|
|
348
|
+
sortOrder: function () {
|
|
349
|
+
return 0;
|
|
350
|
+
},
|
|
351
|
+
animation: true
|
|
352
|
+
}, _TreeBrowser.Node = _TreeNode.TreeNode, _TreeBrowser.Collection = _TreeCollection.TreeCollection, _TreeBrowser.Button = _TreeButton.TreeButton, _TreeBrowser)) || _class);
|
|
353
|
+
var _default = exports.default = TreeBrowser;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
// props shared between TreeBrowser, TreeCollection
|
|
32
|
+
|
|
33
|
+
// props shared between TreeBrowser, TreeCollection, TreeButton
|
|
34
|
+
|
|
35
|
+
// For now it doesn't need the OtherHTMLAttributes, because the extra props
|
|
36
|
+
// get passed to TreeCollection and it doesn't handle them
|
|
37
|
+
|
|
38
|
+
// this is a sum type, so CompareObject is one of CompareCollection OR CompareItem
|
|
39
|
+
|
|
40
|
+
const allowedProps = exports.allowedProps = ['collections', 'items', 'rootId', 'expanded', 'defaultExpanded', 'selection', 'defaultSelection', 'onSelectionChange', 'selectionType', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'showRootCollection', 'onCollectionClick', 'onCollectionToggle', 'onItemClick', 'treeLabel', 'renderContent', 'sortOrder', 'animation'];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _emotion = require("@instructure/emotion");
|
|
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} sharedTokens Shared token object that stores common values for the theme.
|
|
40
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
41
|
+
* @return {Object} The final style object, which will be used in the component
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
const generateStyles = (componentTheme, _props, sharedTokens) => {
|
|
45
|
+
return {
|
|
46
|
+
treeBrowser: {
|
|
47
|
+
label: 'treeBrowser',
|
|
48
|
+
boxSizing: 'border-box',
|
|
49
|
+
margin: '0',
|
|
50
|
+
padding: '0',
|
|
51
|
+
listStyleType: 'none',
|
|
52
|
+
position: 'relative',
|
|
53
|
+
outline: 'none',
|
|
54
|
+
borderRadius: componentTheme.borderRadius,
|
|
55
|
+
...(0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline),
|
|
56
|
+
'&::before': {
|
|
57
|
+
content: '""',
|
|
58
|
+
pointerEvents: 'none',
|
|
59
|
+
boxSizing: 'border-box',
|
|
60
|
+
display: 'block',
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
top: '-0.25rem',
|
|
63
|
+
bottom: '-0.25rem',
|
|
64
|
+
left: '-0.25rem',
|
|
65
|
+
right: '-0.25rem',
|
|
66
|
+
transition: 'all 0.2s',
|
|
67
|
+
opacity: 0,
|
|
68
|
+
transform: 'scale(0.95)'
|
|
69
|
+
},
|
|
70
|
+
'&:focus::before': {
|
|
71
|
+
opacity: 1,
|
|
72
|
+
transform: 'scale(1)'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var _default = exports.default = generateStyles;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "TreeBrowser", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _v.TreeBrowser;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "TreeButton", {
|
|
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "TreeNode", {
|
|
|
27
27
|
return _TreeNode.TreeNode;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
var
|
|
31
|
-
var _TreeButton = require("
|
|
32
|
-
var _TreeCollection = require("
|
|
33
|
-
var _TreeNode = require("
|
|
30
|
+
var _v = require("../TreeBrowser/v1");
|
|
31
|
+
var _TreeButton = require("../TreeBrowser/v1/TreeButton");
|
|
32
|
+
var _TreeCollection = require("../TreeBrowser/v1/TreeCollection");
|
|
33
|
+
var _TreeNode = require("../TreeBrowser/v1/TreeNode");
|