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