@instructure/ui-popover 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.
Files changed (56) hide show
  1. package/CHANGELOG.md +38 -288
  2. package/es/Popover/{index.js → v1/index.js} +3 -3
  3. package/es/Popover/v2/index.js +499 -0
  4. package/es/Popover/v2/props.js +26 -0
  5. package/es/Popover/v2/styles.js +39 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -2
  8. package/lib/Popover/{index.js → v1/index.js} +5 -6
  9. package/lib/Popover/v2/index.js +514 -0
  10. package/lib/Popover/v2/props.js +31 -0
  11. package/lib/Popover/v2/styles.js +45 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +46 -24
  15. package/src/Popover/{index.tsx → v1/index.tsx} +5 -5
  16. package/src/Popover/v2/README.md +455 -0
  17. package/src/Popover/v2/index.tsx +645 -0
  18. package/src/Popover/v2/props.ts +354 -0
  19. package/src/Popover/v2/styles.ts +45 -0
  20. package/src/exports/a.ts +25 -0
  21. package/src/exports/b.ts +25 -0
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/Popover/v1/index.d.ts +83 -0
  24. package/types/Popover/v1/index.d.ts.map +1 -0
  25. package/types/Popover/v1/props.d.ts.map +1 -0
  26. package/types/Popover/v1/styles.d.ts.map +1 -0
  27. package/types/Popover/v1/theme.d.ts.map +1 -0
  28. package/types/Popover/v2/index.d.ts.map +1 -0
  29. package/types/Popover/v2/props.d.ts +225 -0
  30. package/types/Popover/v2/props.d.ts.map +1 -0
  31. package/types/Popover/v2/styles.d.ts +13 -0
  32. package/types/Popover/v2/styles.d.ts.map +1 -0
  33. package/types/exports/a.d.ts +3 -0
  34. package/types/exports/a.d.ts.map +1 -0
  35. package/types/exports/b.d.ts +3 -0
  36. package/types/exports/b.d.ts.map +1 -0
  37. package/types/Popover/index.d.ts.map +0 -1
  38. package/types/Popover/props.d.ts.map +0 -1
  39. package/types/Popover/styles.d.ts.map +0 -1
  40. package/types/Popover/theme.d.ts.map +0 -1
  41. package/types/index.d.ts +0 -3
  42. package/types/index.d.ts.map +0 -1
  43. /package/es/Popover/{props.js → v1/props.js} +0 -0
  44. /package/es/Popover/{styles.js → v1/styles.js} +0 -0
  45. /package/es/Popover/{theme.js → v1/theme.js} +0 -0
  46. /package/lib/Popover/{props.js → v1/props.js} +0 -0
  47. /package/lib/Popover/{styles.js → v1/styles.js} +0 -0
  48. /package/lib/Popover/{theme.js → v1/theme.js} +0 -0
  49. /package/src/Popover/{README.md → v1/README.md} +0 -0
  50. /package/src/Popover/{props.ts → v1/props.ts} +0 -0
  51. /package/src/Popover/{styles.ts → v1/styles.ts} +0 -0
  52. /package/src/Popover/{theme.ts → v1/theme.ts} +0 -0
  53. /package/types/Popover/{props.d.ts → v1/props.d.ts} +0 -0
  54. /package/types/Popover/{styles.d.ts → v1/styles.d.ts} +0 -0
  55. /package/types/Popover/{theme.d.ts → v1/theme.d.ts} +0 -0
  56. /package/types/Popover/{index.d.ts → v2/index.d.ts} +0 -0
@@ -0,0 +1,354 @@
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
+ import React from 'react'
25
+ import { BorderWidth } from '@instructure/emotion'
26
+
27
+ import type { Shadow, Stacking, WithStyleProps } from '@instructure/emotion'
28
+
29
+ import type {
30
+ PlacementPropValues,
31
+ PositionConstraint,
32
+ PositionMountNode,
33
+ PositionObject
34
+ } from '@instructure/ui-position'
35
+ import type { TextDirectionContextConsumerProps } from '@instructure/ui-i18n'
36
+ import type {
37
+ LiveRegion,
38
+ UIElement,
39
+ Renderable,
40
+ PopoverTheme
41
+ } from '@instructure/shared-types'
42
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
43
+
44
+ type PopoverOwnProps = {
45
+ /**
46
+ * Whether or not the `<Popover />` content is shown
47
+ */
48
+ isShowingContent?: boolean
49
+
50
+ /**
51
+ * Whether or not to show the content by default, when uncontrolled
52
+ */
53
+ defaultIsShowingContent?: boolean
54
+
55
+ /**
56
+ * The action that causes the content to display (`click`, `hover`, `focus`)
57
+ */
58
+ on?: ('click' | 'hover' | 'focus') | ('click' | 'hover' | 'focus')[]
59
+
60
+ /**
61
+ * Whether or not an arrow pointing to the trigger should be rendered
62
+ */
63
+ withArrow?: boolean
64
+
65
+ /**
66
+ * Color variant of the popover content
67
+ */
68
+ color?: 'primary' | 'primary-inverse'
69
+
70
+ /**
71
+ * Controls the shadow depth for the `<Popover />`
72
+ */
73
+ shadow?: Shadow
74
+
75
+ /**
76
+ * Controls the z-index depth for the `<Popover />` content
77
+ */
78
+ stacking?: Stacking
79
+
80
+ /**
81
+ * A function that returns a reference to the content element
82
+ */
83
+ contentRef?: (contentElement: Element | null) => void
84
+
85
+ /**
86
+ * An element or a function returning an element to focus by default
87
+ */
88
+ defaultFocusElement?: UIElement
89
+
90
+ /**
91
+ * An element, function returning an element, or array of elements that will
92
+ * not be hidden from the screen reader when the `<Popover />` is open
93
+ */
94
+ liveRegion?: LiveRegion
95
+
96
+ /**
97
+ * An accessible label for the `<Popover />` content
98
+ */
99
+ screenReaderLabel?: string
100
+
101
+ /**
102
+ * The horizontal offset for the positioned content
103
+ */
104
+ offsetX?: string | number
105
+
106
+ /**
107
+ * The vertical offset for the positioned content
108
+ */
109
+ offsetY?: string | number
110
+
111
+ // TODO: remove list when types can be read from other packages
112
+ /**
113
+ * The placement of the content in relation to the trigger
114
+ *
115
+ * One of: 'top', 'bottom', 'start', 'end', 'top start', 'top center',
116
+ * 'top end', 'top stretch', 'bottom start', 'bottom center', 'bottom end',
117
+ * 'bottom stretch', 'start top', 'start center', 'start bottom',
118
+ * 'start stretch', 'end top', 'end center', 'end bottom', 'end stretch',
119
+ * 'center start', 'center end', 'offscreen'
120
+ */
121
+ placement?: PlacementPropValues
122
+
123
+ /**
124
+ * The parent in which to constrain the popover.
125
+ *
126
+ * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
127
+ * or a function returning an element
128
+ */
129
+ constrain?: PositionConstraint
130
+
131
+ /**
132
+ * An element or a function returning an element to use as the mount node
133
+ * for the `<Popover />` (defaults to `document.body`)
134
+ */
135
+ mountNode?: PositionMountNode
136
+
137
+ /**
138
+ * Target element for positioning the Popover (if it differs from the trigger)
139
+ */
140
+ positionTarget?: PositionMountNode
141
+
142
+ /**
143
+ * Set the CSS `display` property on the `<span>` container element of the underlying Position component
144
+ */
145
+ positionContainerDisplay?: 'inline-block' | 'block'
146
+
147
+ /**
148
+ * Insert the element at the 'top' of the mountNode or at the 'bottom'
149
+ */
150
+ insertAt?: 'bottom' | 'top'
151
+
152
+ /**
153
+ * An id is generated if not supplied.
154
+ */
155
+ id?: string
156
+
157
+ /**
158
+ * Whether or not the content should offset to align by its arrow
159
+ */
160
+ shouldAlignArrow?: boolean
161
+
162
+ /**
163
+ * Whether or not position should be tracked or just set on initial render
164
+ */
165
+ shouldTrackPosition?: boolean
166
+
167
+ /**
168
+ * Should the `<Popover />` render offscreen when visually hidden
169
+ */
170
+ shouldRenderOffscreen?: boolean
171
+
172
+ /**
173
+ * Whether focus should contained within the `<Popover/>` when it is open
174
+ */
175
+ shouldContainFocus?: boolean
176
+
177
+ /**
178
+ * Whether focus should be returned to the trigger when the `<Popover/>` is closed
179
+ */
180
+ shouldReturnFocus?: boolean
181
+
182
+ /**
183
+ * Should the `<Popover />` hide when clicks occur outside the content
184
+ */
185
+ shouldCloseOnDocumentClick?: boolean
186
+
187
+ /**
188
+ * Should the `<Popover />` hide when the escape key is pressed
189
+ */
190
+ shouldCloseOnEscape?: boolean
191
+
192
+ /**
193
+ * Should the content become focused when the trigger is blurred
194
+ */
195
+ shouldFocusContentOnTriggerBlur?: boolean
196
+
197
+ /**
198
+ * Callback fired when content is shown. When controlled, this callback is
199
+ * fired when the Popover expects to be shown
200
+ */
201
+ onShowContent?: (event: React.UIEvent | React.FocusEvent) => void
202
+
203
+ /**
204
+ * Callback fired when content is hidden. When controlled, this callback is
205
+ * fired when the Popover expects to be hidden
206
+ */
207
+ onHideContent?: (
208
+ event: React.UIEvent | React.FocusEvent,
209
+ args: { documentClick: boolean }
210
+ ) => void
211
+
212
+ /**
213
+ * Callback fired when content has been is initially positioned.
214
+ * If `shouldRenderOffscreen` is true, it will only fire once, the first
215
+ * time the content is shown
216
+ */
217
+ onPositioned?: (position: PositionObject) => void
218
+
219
+ /**
220
+ * Callback fired when the position changes
221
+ */
222
+ onPositionChanged?: (position: PositionObject) => void
223
+
224
+ /**
225
+ * Callback fired when component is clicked
226
+ */
227
+ onClick?: (event: React.MouseEvent) => void
228
+
229
+ /**
230
+ * Callback fired when trigger is focused
231
+ */
232
+ onFocus?: (event: React.FocusEvent) => void
233
+
234
+ /**
235
+ * Callback fired when component is blurred
236
+ */
237
+ onBlur?: (event: React.FocusEvent) => void
238
+
239
+ /**
240
+ * Callback fired on keydown
241
+ */
242
+ onKeyDown?: (event: React.KeyboardEvent) => void
243
+
244
+ /**
245
+ * Callback fired on keyup
246
+ */
247
+ onKeyUp?: (event: React.KeyboardEvent) => void
248
+
249
+ /**
250
+ * Callback fired when mouse is over trigger
251
+ */
252
+ onMouseOver?: (event: React.MouseEvent) => void
253
+
254
+ /**
255
+ * Callback fired when mouse leaves trigger
256
+ */
257
+ onMouseOut?: (event: React.MouseEvent) => void
258
+
259
+ /**
260
+ * The element that triggers the popover
261
+ */
262
+ renderTrigger?: Renderable
263
+
264
+ /**
265
+ * The content to be shown by the popover
266
+ */
267
+ children?: Renderable
268
+
269
+ /**
270
+ * Provides a reference to the underlying HTML root element
271
+ */
272
+ elementRef?: (element: Element | null) => void
273
+ /**
274
+ * Allowed values: 0, 'none', 'small', 'medium', 'large'.
275
+ *
276
+ * Accepts the familiar CSS shorthand to designate border widths corresponding to edges. (e.g. 'none large none large).
277
+ *
278
+ * Only applies to a Popover without an arrow.
279
+ */
280
+ borderWidth?: BorderWidth
281
+ /**
282
+ * If true (default), then the aria-expanded prop is added to the trigger.
283
+ * If its supplied via the aria-expanded prop then it takes the given value,
284
+ * otherwise its calculated automatically based on whether the content is shown.
285
+ */
286
+ shouldSetAriaExpanded?: boolean
287
+ }
288
+
289
+ type PopoverProps = PopoverOwnProps &
290
+ TextDirectionContextConsumerProps &
291
+ WithDeterministicIdProps &
292
+ WithStyleProps<PopoverTheme, PopoverStyle>
293
+
294
+ type PopoverState = {
295
+ placement: PopoverOwnProps['placement']
296
+ offsetX: PopoverOwnProps['offsetX']
297
+ offsetY: PopoverOwnProps['offsetY']
298
+ isShowingContent?: boolean
299
+ }
300
+
301
+ type PropKeys = keyof PopoverOwnProps
302
+
303
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
304
+
305
+ type PopoverStyle = { borderRadius: string; borderColor: string }
306
+ const allowedProps: AllowedPropKeys = [
307
+ 'isShowingContent',
308
+ 'defaultIsShowingContent',
309
+ 'on',
310
+ 'withArrow',
311
+ 'color',
312
+ 'placement',
313
+ 'shadow',
314
+ 'stacking',
315
+ 'contentRef',
316
+ 'defaultFocusElement',
317
+ 'screenReaderLabel',
318
+ 'offsetX',
319
+ 'offsetY',
320
+ 'constrain',
321
+ 'positionTarget',
322
+ 'positionContainerDisplay',
323
+ 'mountNode',
324
+ 'insertAt',
325
+ 'liveRegion',
326
+ 'id',
327
+ 'shouldAlignArrow',
328
+ 'shouldTrackPosition',
329
+ 'shouldRenderOffscreen',
330
+ 'shouldContainFocus',
331
+ 'shouldReturnFocus',
332
+ 'shouldCloseOnDocumentClick',
333
+ 'shouldCloseOnEscape',
334
+ 'shouldFocusContentOnTriggerBlur',
335
+ 'onShowContent',
336
+ 'onHideContent',
337
+ 'onPositioned',
338
+ 'onPositionChanged',
339
+ 'onClick',
340
+ 'onFocus',
341
+ 'onBlur',
342
+ 'onKeyDown',
343
+ 'onKeyUp',
344
+ 'onMouseOver',
345
+ 'onMouseOut',
346
+ 'renderTrigger',
347
+ 'children',
348
+ 'elementRef',
349
+ 'borderWidth',
350
+ 'shouldSetAriaExpanded'
351
+ ]
352
+
353
+ export type { PopoverOwnProps, PopoverProps, PopoverState, PopoverStyle }
354
+ export { allowedProps }
@@ -0,0 +1,45 @@
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 { NewComponentTypes } from '@instructure/ui-themes'
26
+ import type { PopoverStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @return {Object} The final style object, which will be used in the component
35
+ */
36
+ const generateStyle = (
37
+ componentTheme: NewComponentTypes['Popover']
38
+ ): PopoverStyle => {
39
+ return {
40
+ borderColor: componentTheme.borderColor,
41
+ borderRadius: componentTheme.borderRadius
42
+ }
43
+ }
44
+
45
+ export default generateStyle
@@ -0,0 +1,25 @@
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
+ export { Popover } from '../Popover/v1'
25
+ export type { PopoverOwnProps, PopoverProps } from '../Popover/v1/props'
@@ -0,0 +1,25 @@
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
+ export { Popover } from '../Popover/v2'
25
+ export type { PopoverOwnProps, PopoverProps } from '../Popover/v2/props'