@instructure/ui-drilldown 8.21.1-snapshot.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE.md +27 -0
  3. package/README.md +30 -0
  4. package/es/Drilldown/DrilldownGroup/index.js +56 -0
  5. package/es/Drilldown/DrilldownGroup/props.js +42 -0
  6. package/es/Drilldown/DrilldownLocator.js +144 -0
  7. package/es/Drilldown/DrilldownOption/index.js +59 -0
  8. package/es/Drilldown/DrilldownOption/props.js +46 -0
  9. package/es/Drilldown/DrilldownPage/index.js +56 -0
  10. package/es/Drilldown/DrilldownPage/props.js +41 -0
  11. package/es/Drilldown/DrilldownSeparator/index.js +52 -0
  12. package/es/Drilldown/DrilldownSeparator/props.js +30 -0
  13. package/es/Drilldown/__examples__/Drilldown.examples.js +299 -0
  14. package/es/Drilldown/index.js +1241 -0
  15. package/es/Drilldown/locator.js +26 -0
  16. package/es/Drilldown/props.js +67 -0
  17. package/es/Drilldown/styles.js +82 -0
  18. package/es/Drilldown/theme.js +43 -0
  19. package/es/index.js +24 -0
  20. package/lib/Drilldown/DrilldownGroup/index.js +42 -0
  21. package/lib/Drilldown/DrilldownGroup/props.js +56 -0
  22. package/lib/Drilldown/DrilldownLocator.js +157 -0
  23. package/lib/Drilldown/DrilldownOption/index.js +45 -0
  24. package/lib/Drilldown/DrilldownOption/props.js +57 -0
  25. package/lib/Drilldown/DrilldownPage/index.js +66 -0
  26. package/lib/Drilldown/DrilldownPage/props.js +56 -0
  27. package/lib/Drilldown/DrilldownSeparator/index.js +38 -0
  28. package/lib/Drilldown/DrilldownSeparator/props.js +41 -0
  29. package/lib/Drilldown/__examples__/Drilldown.examples.js +289 -0
  30. package/lib/Drilldown/index.js +1253 -0
  31. package/lib/Drilldown/locator.js +40 -0
  32. package/lib/Drilldown/props.js +83 -0
  33. package/lib/Drilldown/styles.js +90 -0
  34. package/lib/Drilldown/theme.js +51 -0
  35. package/lib/index.js +13 -0
  36. package/lib/package.json +1 -0
  37. package/package.json +58 -0
  38. package/src/Drilldown/DrilldownGroup/index.tsx +64 -0
  39. package/src/Drilldown/DrilldownGroup/props.ts +149 -0
  40. package/src/Drilldown/DrilldownLocator.ts +101 -0
  41. package/src/Drilldown/DrilldownOption/index.tsx +68 -0
  42. package/src/Drilldown/DrilldownOption/props.ts +224 -0
  43. package/src/Drilldown/DrilldownPage/index.tsx +58 -0
  44. package/src/Drilldown/DrilldownPage/props.ts +129 -0
  45. package/src/Drilldown/DrilldownSeparator/index.tsx +60 -0
  46. package/src/Drilldown/DrilldownSeparator/props.ts +65 -0
  47. package/src/Drilldown/README.md +1515 -0
  48. package/src/Drilldown/__examples__/Drilldown.examples.tsx +318 -0
  49. package/src/Drilldown/index.tsx +1492 -0
  50. package/src/Drilldown/locator.ts +28 -0
  51. package/src/Drilldown/props.ts +378 -0
  52. package/src/Drilldown/styles.ts +95 -0
  53. package/src/Drilldown/theme.ts +47 -0
  54. package/src/index.ts +26 -0
  55. package/tsconfig.build.json +30 -0
  56. package/tsconfig.build.tsbuildinfo +1 -0
  57. package/tsconfig.json +4 -0
  58. package/types/Drilldown/DrilldownGroup/index.d.ts +59 -0
  59. package/types/Drilldown/DrilldownGroup/index.d.ts.map +1 -0
  60. package/types/Drilldown/DrilldownGroup/props.d.ts +65 -0
  61. package/types/Drilldown/DrilldownGroup/props.d.ts.map +1 -0
  62. package/types/Drilldown/DrilldownLocator.d.ts +652 -0
  63. package/types/Drilldown/DrilldownLocator.d.ts.map +1 -0
  64. package/types/Drilldown/DrilldownOption/index.d.ts +134 -0
  65. package/types/Drilldown/DrilldownOption/index.d.ts.map +1 -0
  66. package/types/Drilldown/DrilldownOption/props.d.ts +116 -0
  67. package/types/Drilldown/DrilldownOption/props.d.ts.map +1 -0
  68. package/types/Drilldown/DrilldownPage/index.d.ts +45 -0
  69. package/types/Drilldown/DrilldownPage/index.d.ts.map +1 -0
  70. package/types/Drilldown/DrilldownPage/props.d.ts +51 -0
  71. package/types/Drilldown/DrilldownPage/props.d.ts.map +1 -0
  72. package/types/Drilldown/DrilldownSeparator/index.d.ts +27 -0
  73. package/types/Drilldown/DrilldownSeparator/index.d.ts.map +1 -0
  74. package/types/Drilldown/DrilldownSeparator/props.d.ts +18 -0
  75. package/types/Drilldown/DrilldownSeparator/props.d.ts.map +1 -0
  76. package/types/Drilldown/__examples__/Drilldown.examples.d.ts +5 -0
  77. package/types/Drilldown/__examples__/Drilldown.examples.d.ts.map +1 -0
  78. package/types/Drilldown/index.d.ts +246 -0
  79. package/types/Drilldown/index.d.ts.map +1 -0
  80. package/types/Drilldown/locator.d.ts +4 -0
  81. package/types/Drilldown/locator.d.ts.map +1 -0
  82. package/types/Drilldown/props.d.ts +189 -0
  83. package/types/Drilldown/props.d.ts.map +1 -0
  84. package/types/Drilldown/styles.d.ts +15 -0
  85. package/types/Drilldown/styles.d.ts.map +1 -0
  86. package/types/Drilldown/theme.d.ts +10 -0
  87. package/types/Drilldown/theme.d.ts.map +1 -0
  88. package/types/index.d.ts +3 -0
  89. package/types/index.d.ts.map +1 -0
@@ -0,0 +1,28 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { DrilldownLocator } from './DrilldownLocator'
26
+
27
+ export { DrilldownLocator }
28
+ export default DrilldownLocator
@@ -0,0 +1,378 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import { Children, controllable } from '@instructure/ui-prop-types'
29
+ import { PositionPropTypes } from '@instructure/ui-position'
30
+ import { Popover } from '@instructure/ui-popover'
31
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
32
+
33
+ import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
34
+ import type {
35
+ PlacementPropValues,
36
+ PositionConstraint,
37
+ PositionMountNode
38
+ } from '@instructure/ui-position'
39
+ import type {
40
+ DrilldownTheme,
41
+ OtherHTMLAttributes,
42
+ PropValidators,
43
+ AsElementType
44
+ } from '@instructure/shared-types'
45
+
46
+ import { DrilldownPage } from './DrilldownPage'
47
+ import type { DrilldownPageProps } from './DrilldownPage/props'
48
+ import { DrilldownGroup } from './DrilldownGroup'
49
+ import type { DrilldownGroupProps } from './DrilldownGroup/props'
50
+ import { DrilldownOption } from './DrilldownOption'
51
+ import type {
52
+ DrilldownOptionProps,
53
+ DrilldownOptionValue
54
+ } from './DrilldownOption/props'
55
+ import { DrilldownSeparator } from './DrilldownSeparator'
56
+ import type { DrilldownSeparatorProps } from './DrilldownSeparator/props'
57
+
58
+ import { Drilldown } from './index'
59
+
60
+ type PageChild = React.ComponentElement<DrilldownPageProps, DrilldownPage>
61
+ type GroupChild = React.ComponentElement<DrilldownGroupProps, DrilldownGroup>
62
+ type OptionChild = React.ComponentElement<DrilldownOptionProps, DrilldownOption>
63
+ type SeparatorChild = React.ComponentElement<
64
+ DrilldownSeparatorProps,
65
+ DrilldownSeparator
66
+ >
67
+
68
+ type DrilldownOwnProps = {
69
+ /**
70
+ * The id of the root page
71
+ */
72
+ rootPageId: string
73
+
74
+ /**
75
+ * Children of type `<Drilldown.Page />`
76
+ */
77
+ children?: PageChild | PageChild[] // TODO: type Children.oneOf([DrilldownPage])
78
+
79
+ /**
80
+ * The id of the `<Drilldown />`
81
+ */
82
+ id?: string
83
+
84
+ /**
85
+ * Description of the `<Drilldown />` (used as `aria-label` attribute)
86
+ */
87
+ label?: string
88
+
89
+ /**
90
+ * Is the `<Drilldown />` disabled
91
+ */
92
+ disabled?: boolean
93
+
94
+ /**
95
+ * Whether the focus should rotate with keyboard navigation
96
+ * when reaching the first or last option
97
+ */
98
+ rotateFocus?: boolean
99
+
100
+ /**
101
+ * Element type to render as.
102
+ */
103
+ as?: AsElementType
104
+
105
+ /**
106
+ * The ARIA role of the element
107
+ */
108
+ role?: string
109
+
110
+ /**
111
+ * A function that returns a reference to root HTML element
112
+ */
113
+ elementRef?: (el: Element | null) => void
114
+
115
+ /**
116
+ * A function that returns a reference to the `<Drilldown />`
117
+ */
118
+ drilldownRef?: (el: HTMLDivElement | null) => void
119
+
120
+ // View props
121
+ overflowX?: 'auto' | 'hidden' | 'visible'
122
+ overflowY?: 'auto' | 'hidden' | 'visible'
123
+ height?: string | number
124
+ width?: string | number
125
+ maxHeight?: string | number
126
+ maxWidth?: string | number
127
+
128
+ // Popover version props
129
+ /**
130
+ * The trigger element, if the `<Drilldown />` is to render as a popover
131
+ */
132
+ trigger?: React.ReactNode
133
+
134
+ /**
135
+ * If a trigger is supplied, where should the `<Drilldown />` be placed (relative to the trigger)
136
+ */
137
+ placement?: PlacementPropValues
138
+
139
+ /**
140
+ * Should the `<Drilldown />` be open for the initial render
141
+ */
142
+ defaultShow?: boolean
143
+
144
+ /**
145
+ * Is the `<Drilldown />` open (should be accompanied by `onToggle`)
146
+ */
147
+ show?: boolean // TODO: type controllable(PropTypes.bool, 'onToggle', 'defaultShow')
148
+
149
+ /**
150
+ * Callback fired when the `<Drilldown />` is toggled open/closed.
151
+ * When used with `show`, the component will not control its own state.
152
+ */
153
+ onToggle?: (
154
+ event: React.UIEvent | React.FocusEvent,
155
+ args: {
156
+ shown: boolean
157
+ drilldown: Drilldown
158
+ pageHistory: string[]
159
+ goToPage: (
160
+ pageId: string
161
+ ) => { prevPageId: string; newPageId: string } | undefined
162
+ goToPreviousPage: () =>
163
+ | { prevPageId: string; newPageId: string }
164
+ | undefined
165
+ }
166
+ ) => void
167
+
168
+ /**
169
+ * Callback fired when an item within the `<Drilldown />` is selected
170
+ */
171
+ onSelect?: (
172
+ event: React.SyntheticEvent,
173
+ args: {
174
+ value: DrilldownOptionValue | DrilldownOptionValue[]
175
+ isSelected: boolean
176
+ selectedOption: OptionChild
177
+ drilldown: Drilldown
178
+ }
179
+ ) => void
180
+
181
+ /**
182
+ * If a trigger is supplied, callback fired when the `<Drilldown />` is closed
183
+ */
184
+ onDismiss?: (
185
+ event: React.UIEvent | React.FocusEvent,
186
+ documentClick: boolean
187
+ ) => void
188
+
189
+ /**
190
+ * If a trigger is supplied, callback fired when the `<Drilldown />` trigger is focused
191
+ */
192
+ onFocus?: (event: React.FocusEvent) => void
193
+
194
+ /**
195
+ * If a trigger is supplied, callback fired onMouseOver for the `<Drilldown />` trigger
196
+ */
197
+ onMouseOver?: (event: React.MouseEvent) => void
198
+
199
+ /**
200
+ * If a trigger is supplied, A function that returns a reference to the `<Popover />`
201
+ */
202
+ popoverRef?: (el: Popover | null) => void
203
+
204
+ /**
205
+ * If a trigger is supplied, an element or a function returning an element
206
+ * to use as the mount node for the `<Drilldown />` (defaults to `document.body`)
207
+ */
208
+ mountNode?: PositionMountNode
209
+
210
+ /**
211
+ * Target element for positioning the Popover (if it differs from the trigger)
212
+ */
213
+ positionTarget?: PositionMountNode
214
+
215
+ /**
216
+ * The parent in which to constrain the placement.
217
+ */
218
+ constrain?: PositionConstraint
219
+
220
+ /**
221
+ * If a trigger is supplied, should the `<Drilldown />` hide when an item is selected
222
+ */
223
+ shouldHideOnSelect?: boolean
224
+
225
+ /**
226
+ * Whether focus should be contained within the `<Drilldown/>` when it is open.
227
+ * Works only if `trigger` is provided.
228
+ */
229
+ shouldContainFocus?: boolean
230
+
231
+ /**
232
+ * Whether focus should be returned to the trigger
233
+ * when the `<Drilldown/>` is closed.
234
+ * Works only if `trigger` is provided.
235
+ */
236
+ shouldReturnFocus?: boolean
237
+
238
+ /**
239
+ * Whether or not an arrow pointing to the trigger should be rendered.
240
+ * Works only if `trigger` is provided.
241
+ */
242
+ withArrow?: boolean
243
+
244
+ /**
245
+ * The horizontal offset for the positioned content.
246
+ * Works only if `trigger` is provided.
247
+ */
248
+ offsetX?: string | number
249
+
250
+ /**
251
+ * The vertical offset for the positioned content.
252
+ * Works only if `trigger` is provided.
253
+ */
254
+ offsetY?: string | number
255
+ }
256
+
257
+ type PropKeys = keyof DrilldownOwnProps
258
+
259
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
260
+
261
+ type DrilldownProps = DrilldownOwnProps &
262
+ WithStyleProps<DrilldownTheme, DrilldownStyle> &
263
+ WithDeterministicIdProps &
264
+ OtherHTMLAttributes<DrilldownOwnProps>
265
+
266
+ type DrilldownStyle = ComponentStyle<
267
+ | 'drilldown'
268
+ | 'container'
269
+ | 'headerBack'
270
+ | 'headerTitle'
271
+ | 'optionContainer'
272
+ | 'optionLabelInfo'
273
+ | 'optionContent'
274
+ > & { headerActionColor: string }
275
+
276
+ type DrilldownStyleProps = {
277
+ hasHighlightedOption: boolean
278
+ }
279
+
280
+ type DrilldownState = {
281
+ isShowingPopover: boolean
282
+ activePageId: string
283
+ highlightedOptionId?: string
284
+ // needed for rerender
285
+ lastSelectedId?: string
286
+ }
287
+
288
+ const propTypes: PropValidators<PropKeys> = {
289
+ rootPageId: PropTypes.string.isRequired,
290
+ children: Children.oneOf([DrilldownPage]),
291
+ id: PropTypes.string,
292
+ label: PropTypes.string,
293
+ disabled: PropTypes.bool,
294
+ rotateFocus: PropTypes.bool,
295
+ as: PropTypes.elementType,
296
+ role: PropTypes.string,
297
+ elementRef: PropTypes.func,
298
+ drilldownRef: PropTypes.func,
299
+ overflowX: PropTypes.oneOf(['auto', 'hidden', 'visible']),
300
+ overflowY: PropTypes.oneOf(['auto', 'hidden', 'visible']),
301
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
302
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
303
+ maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
304
+ maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
305
+
306
+ trigger: PropTypes.node,
307
+ placement: PositionPropTypes.placement,
308
+ defaultShow: PropTypes.bool,
309
+ show: controllable(PropTypes.bool, 'onToggle', 'defaultShow'),
310
+ onToggle: PropTypes.func,
311
+ onSelect: PropTypes.func,
312
+ onDismiss: PropTypes.func,
313
+ onFocus: PropTypes.func,
314
+ onMouseOver: PropTypes.func,
315
+ popoverRef: PropTypes.func,
316
+ mountNode: PositionPropTypes.mountNode,
317
+ positionTarget: PositionPropTypes.mountNode,
318
+ constrain: PositionPropTypes.constrain,
319
+ shouldHideOnSelect: PropTypes.bool,
320
+ shouldContainFocus: PropTypes.bool,
321
+ shouldReturnFocus: PropTypes.bool,
322
+ withArrow: PropTypes.bool,
323
+ offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
324
+ offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
325
+ }
326
+
327
+ const allowedProps: AllowedPropKeys = [
328
+ 'rootPageId',
329
+ 'children',
330
+ 'id',
331
+ 'label',
332
+ 'disabled',
333
+ 'rotateFocus',
334
+ 'as',
335
+ 'role',
336
+ 'overflowX',
337
+ 'overflowY',
338
+ 'height',
339
+ 'width',
340
+ 'maxHeight',
341
+ 'maxWidth',
342
+
343
+ // Popover version props
344
+ 'trigger',
345
+ 'placement',
346
+ 'defaultShow',
347
+ 'show',
348
+ 'onToggle',
349
+ 'onSelect',
350
+ 'onDismiss',
351
+ 'onFocus',
352
+ 'onMouseOver',
353
+ 'elementRef',
354
+ 'drilldownRef',
355
+ 'popoverRef',
356
+ 'mountNode',
357
+ 'positionTarget',
358
+ 'constrain',
359
+ 'shouldHideOnSelect',
360
+ 'shouldContainFocus',
361
+ 'shouldReturnFocus',
362
+ 'withArrow',
363
+ 'offsetX',
364
+ 'offsetY'
365
+ ]
366
+
367
+ export type {
368
+ DrilldownProps,
369
+ DrilldownState,
370
+ DrilldownStyle,
371
+ DrilldownStyleProps,
372
+ DrilldownPageProps,
373
+ PageChild,
374
+ GroupChild,
375
+ OptionChild,
376
+ SeparatorChild
377
+ }
378
+ export { propTypes, allowedProps }
@@ -0,0 +1,95 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { DrilldownTheme } from '@instructure/shared-types'
26
+ import type {
27
+ DrilldownProps,
28
+ DrilldownStyleProps,
29
+ DrilldownStyle
30
+ } from './props'
31
+
32
+ /**
33
+ * ---
34
+ * private: true
35
+ * ---
36
+ * Generates the style object from the theme and provided additional information
37
+ * @param {Object} componentTheme The theme variable object.
38
+ * @param {Object} props the props of the component, the style is applied to
39
+ * @param {Object} state the state of the component, the style is applied to
40
+ * @return {Object} The final style object, which will be used in the component
41
+ */
42
+ const generateStyle = (
43
+ componentTheme: DrilldownTheme,
44
+ _props: DrilldownProps,
45
+ state: DrilldownStyleProps
46
+ ): DrilldownStyle => {
47
+ const { hasHighlightedOption } = state
48
+
49
+ return {
50
+ drilldown: {
51
+ label: 'drilldown',
52
+ overflow: 'visible', // needed for focus ring!
53
+
54
+ ...(hasHighlightedOption && {
55
+ '&:focus::before': {
56
+ display: 'none'
57
+ }
58
+ })
59
+ },
60
+ container: {
61
+ label: 'drilldown__container'
62
+ },
63
+ headerBack: {
64
+ label: 'drilldown__headerBack',
65
+ minHeight: '1.25em'
66
+ },
67
+ headerTitle: {
68
+ label: 'drilldown__headerTitle',
69
+ fontWeight: componentTheme.headerTitleFontWeight
70
+ },
71
+ optionContainer: {
72
+ label: 'drilldown__optionContainer',
73
+ alignItems: 'center',
74
+ display: 'flex',
75
+ height: '100%'
76
+ },
77
+ optionLabelInfo: {
78
+ label: 'drilldown__optionLabelInfo',
79
+ display: 'flex',
80
+ flexShrink: 0,
81
+ height: '100%',
82
+ alignItems: 'center',
83
+ paddingInlineStart: componentTheme.labelInfoPadding
84
+ },
85
+ optionContent: {
86
+ label: 'drilldown__optionContent',
87
+ flexGrow: 1
88
+ },
89
+
90
+ // we use it in the index file
91
+ headerActionColor: componentTheme.headerActionColor
92
+ }
93
+ }
94
+
95
+ export default generateStyle
@@ -0,0 +1,47 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { Theme } from '@instructure/ui-themes'
26
+ import type { DrilldownTheme } from '@instructure/shared-types'
27
+
28
+ /**
29
+ * Generates the theme object for the component from the theme and provided additional information
30
+ * @param {Object} theme The actual theme object.
31
+ * @return {Object} The final theme object with the overrides and component variables
32
+ */
33
+ const generateComponentTheme = (theme: Theme): DrilldownTheme => {
34
+ const { colors, typography, spacing } = theme
35
+
36
+ const componentVariables: DrilldownTheme = {
37
+ headerTitleFontWeight: typography.fontWeightBold,
38
+ headerActionColor: colors.textLink,
39
+ labelInfoPadding: spacing?.small
40
+ }
41
+
42
+ return {
43
+ ...componentVariables
44
+ }
45
+ }
46
+
47
+ export default generateComponentTheme
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export { Drilldown } from './Drilldown'
26
+ export type { DrilldownProps } from './Drilldown/props'
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "../../tsconfig.build.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./types",
6
+ "composite": true
7
+ },
8
+ "include": ["src"],
9
+ "references": [
10
+ { "path": "../console/tsconfig.build.json" },
11
+ { "path": "../emotion/tsconfig.build.json" },
12
+ { "path": "../shared-types/tsconfig.build.json" },
13
+ { "path": "../ui-dom-utils/tsconfig.build.json" },
14
+ { "path": "../ui-icons/tsconfig.build.json" },
15
+ { "path": "../ui-options/tsconfig.build.json" },
16
+ { "path": "../ui-popover/tsconfig.build.json" },
17
+ { "path": "../ui-position/tsconfig.build.json" },
18
+ { "path": "../ui-prop-types/tsconfig.build.json" },
19
+ { "path": "../ui-react-utils/tsconfig.build.json" },
20
+ { "path": "../ui-selectable/tsconfig.build.json" },
21
+ { "path": "../ui-testable/tsconfig.build.json" },
22
+ { "path": "../ui-utils/tsconfig.build.json" },
23
+ { "path": "../ui-view/tsconfig.build.json" },
24
+ { "path": "../ui-babel-preset/tsconfig.build.json" },
25
+ { "path": "../ui-color-utils/tsconfig.build.json" },
26
+ { "path": "../ui-test-locator/tsconfig.build.json" },
27
+ { "path": "../ui-test-utils/tsconfig.build.json" },
28
+ { "path": "../ui-themes/tsconfig.build.json" }
29
+ ]
30
+ }