@instructure/ui-tree-browser 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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 (86) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/TreeBrowser/v1/TreeNode/props.js → babel.config.cjs} +12 -7
  4. package/es/TreeBrowser/v1/TreeButton/index.js +8 -5
  5. package/es/TreeBrowser/v1/TreeCollection/index.js +6 -6
  6. package/es/TreeBrowser/v1/TreeNode/index.js +8 -5
  7. package/es/TreeBrowser/v1/index.js +9 -9
  8. package/es/TreeBrowser/v2/TreeButton/index.js +7 -4
  9. package/es/TreeBrowser/v2/TreeCollection/index.js +5 -5
  10. package/es/TreeBrowser/v2/TreeNode/index.js +6 -4
  11. package/es/TreeBrowser/v2/index.js +8 -11
  12. package/es/exports/a.js +5 -4
  13. package/es/exports/b.js +5 -4
  14. package/package.json +13 -18
  15. package/src/TreeBrowser/v1/TreeButton/index.tsx +5 -4
  16. package/src/TreeBrowser/v1/TreeCollection/index.tsx +7 -6
  17. package/src/TreeBrowser/v1/TreeCollection/props.ts +1 -1
  18. package/src/TreeBrowser/v1/TreeNode/index.tsx +5 -4
  19. package/src/TreeBrowser/v1/TreeNode/props.ts +1 -1
  20. package/src/TreeBrowser/v1/index.tsx +8 -7
  21. package/src/TreeBrowser/v2/TreeButton/index.tsx +4 -3
  22. package/src/TreeBrowser/v2/TreeCollection/index.tsx +6 -5
  23. package/src/TreeBrowser/v2/TreeCollection/props.ts +1 -1
  24. package/src/TreeBrowser/v2/TreeNode/index.tsx +4 -3
  25. package/src/TreeBrowser/v2/TreeNode/props.ts +1 -1
  26. package/src/TreeBrowser/v2/index.tsx +7 -13
  27. package/src/exports/a.ts +4 -4
  28. package/src/exports/b.ts +4 -4
  29. package/tsconfig.build.tsbuildinfo +1 -1
  30. package/types/TreeBrowser/v1/TreeButton/index.d.ts +4 -3
  31. package/types/TreeBrowser/v1/TreeButton/index.d.ts.map +1 -1
  32. package/types/TreeBrowser/v1/TreeCollection/index.d.ts +5 -4
  33. package/types/TreeBrowser/v1/TreeCollection/index.d.ts.map +1 -1
  34. package/types/TreeBrowser/v1/TreeCollection/props.d.ts +1 -1
  35. package/types/TreeBrowser/v1/TreeCollection/props.d.ts.map +1 -1
  36. package/types/TreeBrowser/v1/TreeNode/index.d.ts +3 -2
  37. package/types/TreeBrowser/v1/TreeNode/index.d.ts.map +1 -1
  38. package/types/TreeBrowser/v1/TreeNode/props.d.ts +1 -1
  39. package/types/TreeBrowser/v1/TreeNode/props.d.ts.map +1 -1
  40. package/types/TreeBrowser/v1/index.d.ts +4 -3
  41. package/types/TreeBrowser/v1/index.d.ts.map +1 -1
  42. package/types/TreeBrowser/v2/TreeButton/index.d.ts +4 -3
  43. package/types/TreeBrowser/v2/TreeButton/index.d.ts.map +1 -1
  44. package/types/TreeBrowser/v2/TreeCollection/index.d.ts +5 -4
  45. package/types/TreeBrowser/v2/TreeCollection/index.d.ts.map +1 -1
  46. package/types/TreeBrowser/v2/TreeCollection/props.d.ts +1 -1
  47. package/types/TreeBrowser/v2/TreeCollection/props.d.ts.map +1 -1
  48. package/types/TreeBrowser/v2/TreeNode/index.d.ts +3 -2
  49. package/types/TreeBrowser/v2/TreeNode/index.d.ts.map +1 -1
  50. package/types/TreeBrowser/v2/TreeNode/props.d.ts +1 -1
  51. package/types/TreeBrowser/v2/TreeNode/props.d.ts.map +1 -1
  52. package/types/TreeBrowser/v2/index.d.ts +4 -4
  53. package/types/TreeBrowser/v2/index.d.ts.map +1 -1
  54. package/types/exports/a.d.ts +4 -4
  55. package/types/exports/a.d.ts.map +1 -1
  56. package/types/exports/b.d.ts +4 -4
  57. package/types/exports/b.d.ts.map +1 -1
  58. package/lib/TreeBrowser/v1/TreeBrowserContext.js +0 -44
  59. package/lib/TreeBrowser/v1/TreeButton/index.js +0 -169
  60. package/lib/TreeBrowser/v1/TreeButton/props.js +0 -31
  61. package/lib/TreeBrowser/v1/TreeButton/styles.js +0 -338
  62. package/lib/TreeBrowser/v1/TreeButton/theme.js +0 -86
  63. package/lib/TreeBrowser/v1/TreeCollection/index.js +0 -382
  64. package/lib/TreeBrowser/v1/TreeCollection/props.js +0 -31
  65. package/lib/TreeBrowser/v1/TreeCollection/styles.js +0 -140
  66. package/lib/TreeBrowser/v1/TreeCollection/theme.js +0 -55
  67. package/lib/TreeBrowser/v1/TreeNode/index.js +0 -122
  68. package/lib/TreeBrowser/v1/index.js +0 -329
  69. package/lib/TreeBrowser/v1/props.js +0 -40
  70. package/lib/TreeBrowser/v1/styles.js +0 -75
  71. package/lib/TreeBrowser/v1/theme.js +0 -51
  72. package/lib/TreeBrowser/v2/TreeBrowserContext.js +0 -44
  73. package/lib/TreeBrowser/v2/TreeButton/index.js +0 -219
  74. package/lib/TreeBrowser/v2/TreeButton/props.js +0 -31
  75. package/lib/TreeBrowser/v2/TreeButton/styles.js +0 -314
  76. package/lib/TreeBrowser/v2/TreeCollection/index.js +0 -383
  77. package/lib/TreeBrowser/v2/TreeCollection/props.js +0 -31
  78. package/lib/TreeBrowser/v2/TreeCollection/styles.js +0 -151
  79. package/lib/TreeBrowser/v2/TreeNode/index.js +0 -168
  80. package/lib/TreeBrowser/v2/TreeNode/props.js +0 -31
  81. package/lib/TreeBrowser/v2/index.js +0 -366
  82. package/lib/TreeBrowser/v2/props.js +0 -40
  83. package/lib/TreeBrowser/v2/styles.js +0 -77
  84. package/lib/exports/a.js +0 -33
  85. package/lib/exports/b.js +0 -33
  86. package/lib/package.json +0 -1
@@ -1,382 +0,0 @@
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.TreeCollection = void 0;
8
- var _react = require("react");
9
- var _emotion = require("@instructure/emotion");
10
- var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
11
- var _TreeButton = require("../TreeButton");
12
- var _styles = _interopRequireDefault(require("./styles"));
13
- var _theme = _interopRequireDefault(require("./theme"));
14
- var _props = require("./props");
15
- var _TreeBrowserContext = _interopRequireDefault(require("../TreeBrowserContext"));
16
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
- var _react2 = require("@emotion/react");
18
- var _dec, _class;
19
- /*
20
- * The MIT License (MIT)
21
- *
22
- * Copyright (c) 2015 - present Instructure, Inc.
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining a copy
25
- * of this software and associated documentation files (the "Software"), to deal
26
- * in the Software without restriction, including without limitation the rights
27
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28
- * copies of the Software, and to permit persons to whom the Software is
29
- * furnished to do so, subject to the following conditions:
30
- *
31
- * The above copyright notice and this permission notice shall be included in all
32
- * copies or substantial portions of the Software.
33
- *
34
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40
- * SOFTWARE.
41
- */
42
- /**
43
- ---
44
- parent: TreeBrowser
45
- id: TreeBrowser.Collection
46
- ---
47
- **/
48
- let TreeCollection = exports.TreeCollection = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = class TreeCollection extends _react.Component {
49
- static displayName = "TreeCollection";
50
- static componentId = 'TreeBrowser.Collection';
51
- static allowedProps = _props.allowedProps;
52
- static contextType = _TreeBrowserContext.default;
53
- static defaultProps = {
54
- collections: [],
55
- items: [],
56
- expanded: false,
57
- selection: '',
58
- size: 'medium',
59
- variant: 'folderTree',
60
- getItemProps: props => props,
61
- getCollectionProps: props => props,
62
- isCollectionFlattened: false
63
- };
64
- ref = null;
65
- constructor(props) {
66
- super(props);
67
- this.state = {
68
- focused: ''
69
- };
70
- }
71
- componentDidMount() {
72
- this.props.makeStyles?.({
73
- animation: this.context?.animation
74
- });
75
- }
76
- componentDidUpdate() {
77
- this.props.makeStyles?.({
78
- animation: this.context?.animation
79
- });
80
- }
81
- get itemsLevel() {
82
- const {
83
- level,
84
- isCollectionFlattened
85
- } = this.props;
86
- return isCollectionFlattened ? level : level + 1;
87
- }
88
- handleFocus = (e, item) => {
89
- e.stopPropagation();
90
- this.setState({
91
- focused: `${item.type}_${item.id}`
92
- });
93
- };
94
- handleBlur = (e, _item) => {
95
- e.stopPropagation();
96
- this.setState({
97
- focused: ''
98
- });
99
- };
100
- handleCollectionClick = e => {
101
- const {
102
- id,
103
- onCollectionClick,
104
- expanded
105
- } = this.props;
106
- const collection = {
107
- id,
108
- expanded: !expanded,
109
- type: 'collection'
110
- };
111
- if (onCollectionClick && typeof onCollectionClick === 'function') {
112
- onCollectionClick(e, collection);
113
- }
114
- };
115
- handleCollectionKeyDown = e => {
116
- const {
117
- id,
118
- onKeyDown,
119
- expanded
120
- } = this.props;
121
- const collection = {
122
- id,
123
- expanded: !expanded,
124
- type: 'collection'
125
- };
126
- if (onKeyDown && typeof onKeyDown === 'function') {
127
- onKeyDown(e, collection);
128
- }
129
- };
130
- get collectionsCount() {
131
- const collections = this.props.collections;
132
- return collections && collections.length > 0 ? collections.length : 0;
133
- }
134
- get itemsCount() {
135
- const items = this.props.items;
136
- return items && items.length > 0 ? items.length : 0;
137
- }
138
- get childCount() {
139
- return this.collectionsCount + this.itemsCount + (this.props.renderBeforeItems ? 1 : 0) + (this.props.renderAfterItems ? 1 : 0);
140
- }
141
- sortChildren() {
142
- const {
143
- collections,
144
- items,
145
- compareFunc
146
- } = this.props;
147
- if (!compareFunc) return [];
148
- const collections_ = collections ? collections.map(collection => {
149
- return {
150
- ...collection,
151
- type: 'collection'
152
- };
153
- }) : [];
154
- const items_ = items ? items.map(item => {
155
- return {
156
- ...item,
157
- type: 'item'
158
- };
159
- }) : [];
160
- const renderQueue = collections_.concat(items_);
161
- renderQueue.sort(compareFunc);
162
- return renderQueue;
163
- }
164
- renderChildren() {
165
- const {
166
- collections,
167
- items,
168
- id,
169
- renderBeforeItems,
170
- renderAfterItems,
171
- compareFunc
172
- } = this.props;
173
- let position = 1;
174
- const sortedChildren = this.sortChildren();
175
- return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
176
- children: [renderBeforeItems && this.renderCollectionChildren(id, renderBeforeItems, position++, 'before'), !compareFunc && collections.map(collection => {
177
- return this.renderCollectionNode(collection, position++);
178
- }), !compareFunc && items.map(item => {
179
- return this.renderItemNode(item, position++);
180
- }), compareFunc && sortedChildren.map(child => {
181
- if (child.type === 'collection') {
182
- return this.renderCollectionNode(child, position++);
183
- } else {
184
- return this.renderItemNode(child, position++);
185
- }
186
- }), renderAfterItems && this.renderCollectionChildren(id, renderAfterItems, position++, 'after')]
187
- });
188
- }
189
- renderCollectionChildren(collectionId, child, position, keyword) {
190
- const {
191
- selection,
192
- onKeyDown,
193
- getItemProps,
194
- styles
195
- } = this.props;
196
- const key = `${collectionId}_${keyword}`;
197
- const ariaSelected = {};
198
- if (selection) {
199
- ariaSelected['aria-selected'] = selection === `child_${key}`;
200
- }
201
- const itemHash = {
202
- id: key,
203
- type: 'child'
204
- };
205
- const itemProps = getItemProps({
206
- key: key,
207
- selected: selection === `child_${key}`,
208
- focused: this.state.focused === `child_${key}`,
209
- level: this.itemsLevel
210
- });
211
- return (0, _jsxRuntime.jsx)("li", {
212
- id: key
213
- /* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
214
- role: "treeitem",
215
- css: styles?.item,
216
- tabIndex: -1,
217
- "aria-posinset": position,
218
- "aria-setsize": this.childCount,
219
- "aria-level": this.itemsLevel,
220
- ...ariaSelected,
221
- onClick: e => {
222
- if (typeof child.props.onClick === 'function') {
223
- child.props.onClick(e);
224
- } else {
225
- e.stopPropagation();
226
- }
227
- },
228
- onFocus: e => this.handleFocus(e, itemHash),
229
- onKeyDown: e => {
230
- if (typeof child.props.onKeyDown === 'function') {
231
- child.props.onKeyDown(e);
232
- } else {
233
- onKeyDown?.(e, itemHash);
234
- }
235
- },
236
- onBlur: e => this.handleBlur(e, itemHash),
237
- children: (0, _safeCloneElement.safeCloneElement)(child, itemProps)
238
- }, key);
239
- }
240
- renderCollectionNode(collection, position) {
241
- return (0, _react2.createElement)(TreeCollection, {
242
- ...this.props,
243
- key: `c${position}`,
244
- id: collection.id,
245
- name: collection.name,
246
- descriptor: collection.descriptor,
247
- expanded: collection.expanded,
248
- items: collection.items,
249
- collections: collection.collections,
250
- numChildren: this.childCount,
251
- level: this.itemsLevel,
252
- containerRef: collection.containerRef,
253
- position: position,
254
- renderBeforeItems: collection.renderBeforeItems,
255
- renderAfterItems: collection.renderAfterItems,
256
- isCollectionFlattened: false // only the root needs to be flattened
257
- ,
258
- compareFunc: collection.compareFunc
259
- });
260
- }
261
- renderItemNode(item, position) {
262
- const {
263
- selection,
264
- onItemClick,
265
- onKeyDown,
266
- getItemProps,
267
- styles
268
- } = this.props;
269
- const ariaSelected = {};
270
- if (selection) {
271
- ariaSelected['aria-selected'] = selection === `item_${item.id}`;
272
- }
273
- const itemHash = {
274
- id: item.id,
275
- type: 'item'
276
- };
277
- const itemProps = getItemProps({
278
- ...this.getCommonButtonProps(),
279
- id: item.id,
280
- name: item.name,
281
- descriptor: item.descriptor,
282
- thumbnail: item.thumbnail,
283
- selected: selection === `item_${item.id}`,
284
- focused: this.state.focused === `item_${item.id}`,
285
- type: 'item'
286
- });
287
- return (0, _jsxRuntime.jsx)("li", {
288
- tabIndex: -1
289
- /* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
290
- role: "treeitem",
291
- "aria-label": item.name,
292
- css: styles?.item,
293
- "aria-level": this.itemsLevel,
294
- "aria-posinset": position,
295
- "aria-setsize": this.childCount,
296
- onClick: e => onItemClick?.(e, itemHash),
297
- onKeyDown: e => onKeyDown?.(e, itemHash),
298
- onFocus: e => this.handleFocus(e, itemHash),
299
- onBlur: e => this.handleBlur(e, itemHash),
300
- ...ariaSelected,
301
- children: (0, _jsxRuntime.jsx)(_TreeButton.TreeButton, {
302
- ...itemProps
303
- })
304
- }, `i${position}`);
305
- }
306
- getCommonButtonProps() {
307
- return {
308
- id: this.props.id,
309
- name: this.props.name,
310
- descriptor: this.props.descriptor,
311
- size: this.props.size,
312
- variant: this.props.variant,
313
- itemIcon: this.props.itemIcon,
314
- level: this.itemsLevel,
315
- renderContent: this.props.renderContent
316
- };
317
- }
318
- render() {
319
- const {
320
- id,
321
- name,
322
- expanded,
323
- collectionIcon,
324
- collectionIconExpanded,
325
- isCollectionFlattened,
326
- getCollectionProps,
327
- level,
328
- position,
329
- styles
330
- } = this.props;
331
- const collectionProps = getCollectionProps({
332
- ...this.getCommonButtonProps(),
333
- expanded: expanded,
334
- collectionIcon: collectionIcon,
335
- collectionIconExpanded: collectionIconExpanded,
336
- type: 'collection',
337
- containerRef: this.props.containerRef,
338
- selected: this.props.selection === `collection_${id}`,
339
- focused: this.state.focused === `collection_${id}`,
340
- level
341
- });
342
- const ariaSelected = {
343
- 'aria-selected': undefined
344
- };
345
- if (this.props.selection) ariaSelected['aria-selected'] = this.props.selection === `collection_${id}`;
346
- return isCollectionFlattened ? this.renderChildren() : (0, _jsxRuntime.jsxs)("li", {
347
- ref: el => {
348
- this.ref = el;
349
- },
350
- css: styles?.treeCollection,
351
- tabIndex: -1
352
- /* eslint-disable-next-line jsx-a11y/role-has-required-aria-props */,
353
- role: "treeitem",
354
- "aria-label": `${this.props.name}${this.props.descriptor ? ` ${this.props.descriptor}` : ''}`,
355
- "aria-level": level,
356
- "aria-posinset": position,
357
- "aria-setsize": this.props.numChildren,
358
- "aria-expanded": expanded,
359
- onClick: this.handleCollectionClick,
360
- onKeyDown: this.handleCollectionKeyDown,
361
- onFocus: e => this.handleFocus(e, {
362
- id: id,
363
- type: 'collection'
364
- }),
365
- onBlur: e => this.handleBlur(e, {
366
- id: id,
367
- type: 'collection'
368
- }),
369
- ...ariaSelected,
370
- "data-cid": "TreeCollection",
371
- children: [(0, _jsxRuntime.jsx)(_TreeButton.TreeButton, {
372
- ...collectionProps
373
- }), expanded && this.childCount > 0 && (0, _jsxRuntime.jsx)("ul", {
374
- "aria-label": name,
375
- css: styles?.list,
376
- role: "group",
377
- children: this.renderChildren()
378
- })]
379
- });
380
- }
381
- }) || _class);
382
- var _default = exports.default = TreeCollection;
@@ -1,31 +0,0 @@
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', 'name', 'descriptor', 'items', 'collections', 'expanded', 'selection', 'size', 'variant', 'collectionIcon', 'collectionIconExpanded', 'itemIcon', 'getItemProps', 'getCollectionProps', 'onItemClick', 'onCollectionClick', 'onKeyDown', 'numChildren', 'level', 'position', 'renderBeforeItems', 'renderAfterItems', 'containerRef', 'isCollectionFlattened', 'renderContent'];
@@ -1,140 +0,0 @@
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
- const list = (0, _emotion.keyframes)`
33
- to {
34
- transform: scaleY(1);
35
- }`;
36
-
37
- /**
38
- * ---
39
- * private: true
40
- * ---
41
- * Generates the style object from the theme and provided additional information
42
- * @param {Object} componentTheme The theme variable object.
43
- * @param {Object} props the props of the component, the style is applied to
44
- * @param {Object} state the state of the component, the style is applied to
45
- * @return {Object} The final style object, which will be used in the component
46
- */
47
-
48
- const generateStyles = (componentTheme, props, state) => {
49
- const {
50
- size,
51
- variant
52
- } = props;
53
- const sizeMap = {
54
- small: {
55
- indent: {
56
- marginInlineStart: `calc(${componentTheme.baseSpacingSmall} * 3)`,
57
- marginInlineEnd: 0
58
- },
59
- folderTree: {
60
- marginInlineStart: `calc(${componentTheme.baseSpacingSmall} * 2)`,
61
- marginInlineEnd: 0,
62
- paddingTop: `calc(1.75 * ${componentTheme.baseSpacingSmall})`,
63
- marginTop: `calc(-1.75 * ${componentTheme.baseSpacingSmall})`
64
- }
65
- },
66
- medium: {
67
- indent: {
68
- marginInlineStart: `calc(${componentTheme.baseSpacingMedium} * 3)`,
69
- marginInlineEnd: 0
70
- },
71
- folderTree: {
72
- marginInlineStart: `calc(${componentTheme.baseSpacingMedium} * 2)`,
73
- marginInlineEnd: 0,
74
- paddingTop: componentTheme.baseSpacingMedium,
75
- marginTop: `calc(-1 * ${componentTheme.baseSpacingMedium})`
76
- }
77
- },
78
- large: {
79
- indent: {
80
- marginInlineStart: `calc(${componentTheme.baseSpacingLarge} * 3)`,
81
- marginInlineEnd: 0
82
- },
83
- folderTree: {
84
- marginInlineStart: `calc(${componentTheme.baseSpacingLarge} * 2)`,
85
- marginInlineEnd: 0,
86
- paddingTop: `calc(0.875 * ${componentTheme.baseSpacingMedium})`,
87
- marginTop: `calc(-0.875 * ${componentTheme.baseSpacingMedium})`
88
- }
89
- }
90
- };
91
- return {
92
- treeCollection: {
93
- label: 'treeCollection',
94
- fontFamily: componentTheme.fontFamily,
95
- margin: 0,
96
- padding: 0,
97
- '&:focus': {
98
- outline: 0
99
- }
100
- },
101
- list: {
102
- label: 'treeCollection__list',
103
- fontFamily: 'inherit',
104
- boxSizing: 'border-box',
105
- margin: 0,
106
- padding: 0,
107
- listStyleType: 'none',
108
- position: 'relative',
109
- ...(variant === 'folderTree' && {
110
- '&::before': {
111
- content: '""',
112
- position: 'absolute',
113
- top: '0.25rem',
114
- bottom: '1.1875rem',
115
- insetInlineStart: '0',
116
- insetInlineEnd: 'auto',
117
- ...(state.animation ? {
118
- transform: 'scaleY(0.01)',
119
- transformOrigin: 'center top',
120
- animationName: list,
121
- animationDuration: '0.2s',
122
- animationFillMode: 'forwards',
123
- animationTimingFunction: 'ease-out'
124
- } : {}),
125
- pointerEvents: 'none',
126
- width: componentTheme.borderWidth,
127
- background: componentTheme.borderColor
128
- }
129
- }),
130
- ...sizeMap[size][variant]
131
- },
132
- item: {
133
- label: 'treeCollection__label',
134
- '&:focus': {
135
- outline: 0
136
- }
137
- }
138
- };
139
- };
140
- var _default = exports.default = generateStyles;
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = 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
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- const {
38
- colors,
39
- spacing,
40
- typography,
41
- borders
42
- } = theme;
43
- const componentVariables = {
44
- fontFamily: typography?.fontFamily,
45
- baseSpacingSmall: spacing?.xSmall,
46
- baseSpacingMedium: spacing?.small,
47
- baseSpacingLarge: '1rem',
48
- borderWidth: borders?.widthSmall,
49
- borderColor: colors?.contrasts?.grey4570
50
- };
51
- return {
52
- ...componentVariables
53
- };
54
- };
55
- var _default = exports.default = generateComponentTheme;