@instructure/ui-dialog 8.8.1-snapshot.7 → 8.9.1-snapshot.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
7
+
8
+ ### Bug Fixes
9
+
10
+ - fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
11
+
6
12
  # [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
7
13
 
8
14
  **Note:** Version bump only for package @instructure/ui-dialog
@@ -25,11 +25,11 @@ const _excluded = ["open", "contentElement"];
25
25
  * SOFTWARE.
26
26
  */
27
27
  import React, { Component } from 'react';
28
- import PropTypes from 'prop-types';
29
28
  import { omitProps, getElementType } from '@instructure/ui-react-utils';
30
29
  import { findDOMNode, requestAnimationFrame } from '@instructure/ui-dom-utils';
31
30
  import { logError as error } from '@instructure/console';
32
31
  import { FocusRegionManager } from '@instructure/ui-a11y-utils';
32
+ import { propTypes, allowedProps } from './props';
33
33
 
34
34
  /**
35
35
  ---
@@ -157,57 +157,10 @@ class Dialog extends Component {
157
157
 
158
158
  Dialog.displayName = "Dialog";
159
159
  Dialog.componentId = 'Dialog';
160
- Dialog.propTypes = {
161
- /**
162
- * The children to be rendered within the `<Dialog />`
163
- */
164
- children: PropTypes.node,
165
-
166
- /**
167
- * The element to render as the component root, `span` by default
168
- */
169
- as: PropTypes.elementType,
170
- // eslint-disable-line react/require-default-props
171
- display: PropTypes.oneOf(['auto', 'block', 'inline-block']),
172
- label: PropTypes.string,
173
-
174
- /**
175
- * Whether or not the `<Dialog />` is open
176
- */
177
- open: PropTypes.bool,
178
-
179
- /**
180
- * Function called when tab focus leaves the `<Dialog />` focusable content. This only
181
- * occurs when `shouldContainFocus` is set to false.
182
- */
183
- onBlur: PropTypes.func,
184
- onDismiss: PropTypes.func,
185
-
186
- /**
187
- * An element or a function returning an element to focus by default
188
- */
189
- defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
190
-
191
- /**
192
- * An element or a function returning an element that wraps the content of the `<Dialog />`
193
- */
194
- contentElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
195
-
196
- /**
197
- * An element, function returning an element, or array of elements that will not be hidden from
198
- * the screen reader when the `<Dialog />` is open
199
- */
200
- liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
201
- shouldContainFocus: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['keyboard', 'screenreader'])]),
202
- shouldReturnFocus: PropTypes.bool,
203
- shouldCloseOnDocumentClick: PropTypes.bool,
204
- shouldCloseOnEscape: PropTypes.bool,
205
- shouldFocusOnOpen: PropTypes.bool
206
- };
160
+ Dialog.propTypes = propTypes;
161
+ Dialog.allowedProps = allowedProps;
207
162
  Dialog.defaultProps = {
208
163
  children: null,
209
- display: void 0,
210
- label: void 0,
211
164
  open: false,
212
165
  shouldFocusOnOpen: true,
213
166
  shouldContainFocus: false,
@@ -0,0 +1,73 @@
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 PropTypes from 'prop-types';
25
+ const propTypes = {
26
+ /**
27
+ * The children to be rendered within the `<Dialog />`
28
+ */
29
+ children: PropTypes.node,
30
+
31
+ /**
32
+ * The element to render as the component root, `span` by default
33
+ */
34
+ as: PropTypes.elementType,
35
+ // eslint-disable-line react/require-default-props
36
+ display: PropTypes.oneOf(['auto', 'block', 'inline-block']),
37
+ label: PropTypes.string,
38
+
39
+ /**
40
+ * Whether or not the `<Dialog />` is open
41
+ */
42
+ open: PropTypes.bool,
43
+
44
+ /**
45
+ * Function called when tab focus leaves the `<Dialog />` focusable content. This only
46
+ * occurs when `shouldContainFocus` is set to false.
47
+ */
48
+ onBlur: PropTypes.func,
49
+ onDismiss: PropTypes.func,
50
+
51
+ /**
52
+ * An element or a function returning an element to focus by default
53
+ */
54
+ defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
55
+
56
+ /**
57
+ * An element or a function returning an element that wraps the content of the `<Dialog />`
58
+ */
59
+ contentElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
60
+
61
+ /**
62
+ * An element, function returning an element, or array of elements that will not be hidden from
63
+ * the screen reader when the `<Dialog />` is open
64
+ */
65
+ liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
66
+ shouldContainFocus: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['keyboard', 'screenreader'])]),
67
+ shouldReturnFocus: PropTypes.bool,
68
+ shouldCloseOnDocumentClick: PropTypes.bool,
69
+ shouldCloseOnEscape: PropTypes.bool,
70
+ shouldFocusOnOpen: PropTypes.bool
71
+ };
72
+ const allowedProps = ['children', 'as', 'display', 'label', 'open', 'onBlur', 'onDismiss', 'defaultFocusElement', 'contentElement', 'liveRegion', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'shouldCloseOnEscape', 'shouldFocusOnOpen'];
73
+ export { propTypes, allowedProps };
@@ -13,8 +13,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
13
13
 
14
14
  var _react = _interopRequireWildcard(require("react"));
15
15
 
16
- var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
16
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
19
17
 
20
18
  var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
@@ -27,6 +25,8 @@ var _console = require("@instructure/console");
27
25
 
28
26
  var _FocusRegionManager = require("@instructure/ui-a11y-utils/lib/FocusRegionManager.js");
29
27
 
28
+ var _props = require("./props");
29
+
30
30
  const _excluded = ["open", "contentElement"];
31
31
 
32
32
  /**
@@ -156,57 +156,10 @@ class Dialog extends _react.Component {
156
156
  exports.Dialog = Dialog;
157
157
  Dialog.displayName = "Dialog";
158
158
  Dialog.componentId = 'Dialog';
159
- Dialog.propTypes = {
160
- /**
161
- * The children to be rendered within the `<Dialog />`
162
- */
163
- children: _propTypes.default.node,
164
-
165
- /**
166
- * The element to render as the component root, `span` by default
167
- */
168
- as: _propTypes.default.elementType,
169
- // eslint-disable-line react/require-default-props
170
- display: _propTypes.default.oneOf(['auto', 'block', 'inline-block']),
171
- label: _propTypes.default.string,
172
-
173
- /**
174
- * Whether or not the `<Dialog />` is open
175
- */
176
- open: _propTypes.default.bool,
177
-
178
- /**
179
- * Function called when tab focus leaves the `<Dialog />` focusable content. This only
180
- * occurs when `shouldContainFocus` is set to false.
181
- */
182
- onBlur: _propTypes.default.func,
183
- onDismiss: _propTypes.default.func,
184
-
185
- /**
186
- * An element or a function returning an element to focus by default
187
- */
188
- defaultFocusElement: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
189
-
190
- /**
191
- * An element or a function returning an element that wraps the content of the `<Dialog />`
192
- */
193
- contentElement: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
194
-
195
- /**
196
- * An element, function returning an element, or array of elements that will not be hidden from
197
- * the screen reader when the `<Dialog />` is open
198
- */
199
- liveRegion: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.element, _propTypes.default.func]),
200
- shouldContainFocus: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.oneOf(['keyboard', 'screenreader'])]),
201
- shouldReturnFocus: _propTypes.default.bool,
202
- shouldCloseOnDocumentClick: _propTypes.default.bool,
203
- shouldCloseOnEscape: _propTypes.default.bool,
204
- shouldFocusOnOpen: _propTypes.default.bool
205
- };
159
+ Dialog.propTypes = _props.propTypes;
160
+ Dialog.allowedProps = _props.allowedProps;
206
161
  Dialog.defaultProps = {
207
162
  children: null,
208
- display: void 0,
209
- label: void 0,
210
163
  open: false,
211
164
  shouldFocusOnOpen: true,
212
165
  shouldContainFocus: false,
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.allowedProps = exports.propTypes = void 0;
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ /*
13
+ * The MIT License (MIT)
14
+ *
15
+ * Copyright (c) 2015 - present Instructure, Inc.
16
+ *
17
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ * of this software and associated documentation files (the "Software"), to deal
19
+ * in the Software without restriction, including without limitation the rights
20
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ * copies of the Software, and to permit persons to whom the Software is
22
+ * furnished to do so, subject to the following conditions:
23
+ *
24
+ * The above copyright notice and this permission notice shall be included in all
25
+ * copies or substantial portions of the Software.
26
+ *
27
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ * SOFTWARE.
34
+ */
35
+ const propTypes = {
36
+ /**
37
+ * The children to be rendered within the `<Dialog />`
38
+ */
39
+ children: _propTypes.default.node,
40
+
41
+ /**
42
+ * The element to render as the component root, `span` by default
43
+ */
44
+ as: _propTypes.default.elementType,
45
+ // eslint-disable-line react/require-default-props
46
+ display: _propTypes.default.oneOf(['auto', 'block', 'inline-block']),
47
+ label: _propTypes.default.string,
48
+
49
+ /**
50
+ * Whether or not the `<Dialog />` is open
51
+ */
52
+ open: _propTypes.default.bool,
53
+
54
+ /**
55
+ * Function called when tab focus leaves the `<Dialog />` focusable content. This only
56
+ * occurs when `shouldContainFocus` is set to false.
57
+ */
58
+ onBlur: _propTypes.default.func,
59
+ onDismiss: _propTypes.default.func,
60
+
61
+ /**
62
+ * An element or a function returning an element to focus by default
63
+ */
64
+ defaultFocusElement: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
65
+
66
+ /**
67
+ * An element or a function returning an element that wraps the content of the `<Dialog />`
68
+ */
69
+ contentElement: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
70
+
71
+ /**
72
+ * An element, function returning an element, or array of elements that will not be hidden from
73
+ * the screen reader when the `<Dialog />` is open
74
+ */
75
+ liveRegion: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.element, _propTypes.default.func]),
76
+ shouldContainFocus: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.oneOf(['keyboard', 'screenreader'])]),
77
+ shouldReturnFocus: _propTypes.default.bool,
78
+ shouldCloseOnDocumentClick: _propTypes.default.bool,
79
+ shouldCloseOnEscape: _propTypes.default.bool,
80
+ shouldFocusOnOpen: _propTypes.default.bool
81
+ };
82
+ exports.propTypes = propTypes;
83
+ const allowedProps = ['children', 'as', 'display', 'label', 'open', 'onBlur', 'onDismiss', 'defaultFocusElement', 'contentElement', 'liveRegion', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'shouldCloseOnEscape', 'shouldFocusOnOpen'];
84
+ exports.allowedProps = allowedProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-dialog",
3
- "version": "8.8.1-snapshot.7+90b251d58",
3
+ "version": "8.9.1-snapshot.2+7f5faa3df",
4
4
  "description": "A utility component for managing keyboard accessibility and screen reader behavior",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -25,18 +25,18 @@
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@babel/runtime": "^7.13.10",
28
- "@instructure/ui-a11y-utils": "8.8.1-snapshot.7+90b251d58",
29
- "@instructure/ui-dom-utils": "8.8.1-snapshot.7+90b251d58",
30
- "@instructure/ui-react-utils": "8.8.1-snapshot.7+90b251d58",
31
- "@instructure/ui-testable": "8.8.1-snapshot.7+90b251d58",
28
+ "@instructure/shared-types": "8.9.1-snapshot.2+7f5faa3df",
29
+ "@instructure/ui-a11y-utils": "8.9.1-snapshot.2+7f5faa3df",
30
+ "@instructure/ui-dom-utils": "8.9.1-snapshot.2+7f5faa3df",
31
+ "@instructure/ui-react-utils": "8.9.1-snapshot.2+7f5faa3df",
32
+ "@instructure/ui-testable": "8.9.1-snapshot.2+7f5faa3df",
32
33
  "prop-types": "^15"
33
34
  },
34
35
  "devDependencies": {
35
- "@instructure/console": "8.8.1-snapshot.7+90b251d58",
36
- "@instructure/shared-types": "8.8.1-snapshot.7+90b251d58",
37
- "@instructure/ui-babel-preset": "8.8.1-snapshot.7+90b251d58",
38
- "@instructure/ui-prop-types": "8.8.1-snapshot.7+90b251d58",
39
- "@instructure/ui-test-utils": "8.8.1-snapshot.7+90b251d58"
36
+ "@instructure/console": "8.9.1-snapshot.2+7f5faa3df",
37
+ "@instructure/ui-babel-preset": "8.9.1-snapshot.2+7f5faa3df",
38
+ "@instructure/ui-prop-types": "8.9.1-snapshot.2+7f5faa3df",
39
+ "@instructure/ui-test-utils": "8.9.1-snapshot.2+7f5faa3df"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=16.8 <=17"
@@ -45,5 +45,5 @@
45
45
  "access": "public"
46
46
  },
47
47
  "sideEffects": false,
48
- "gitHead": "90b251d580c75205b6cbb884fe922059cfc494dd"
48
+ "gitHead": "7f5faa3df83667636304e0901ef1008d98dffc9a"
49
49
  }
@@ -23,7 +23,6 @@
23
23
  */
24
24
 
25
25
  import React, { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
28
27
  import { omitProps, getElementType } from '@instructure/ui-react-utils'
29
28
  import { findDOMNode, requestAnimationFrame } from '@instructure/ui-dom-utils'
@@ -32,7 +31,8 @@ import { logError as error } from '@instructure/console'
32
31
  import type { OtherHTMLAttributes } from '@instructure/shared-types'
33
32
  import { FocusRegionManager } from '@instructure/ui-a11y-utils'
34
33
 
35
- import { DialogProps } from './types'
34
+ import { propTypes, allowedProps } from './props'
35
+ import type { DialogProps } from './props'
36
36
 
37
37
  /**
38
38
  ---
@@ -44,70 +44,10 @@ category: components/utilities
44
44
  class Dialog extends Component<DialogProps & OtherHTMLAttributes<DialogProps>> {
45
45
  static readonly componentId = 'Dialog'
46
46
 
47
- static propTypes = {
48
- /**
49
- * The children to be rendered within the `<Dialog />`
50
- */
51
- children: PropTypes.node,
52
-
53
- /**
54
- * The element to render as the component root, `span` by default
55
- */
56
- as: PropTypes.elementType, // eslint-disable-line react/require-default-props
57
-
58
- display: PropTypes.oneOf(['auto', 'block', 'inline-block']),
59
-
60
- label: PropTypes.string,
61
-
62
- /**
63
- * Whether or not the `<Dialog />` is open
64
- */
65
- open: PropTypes.bool,
66
-
67
- /**
68
- * Function called when tab focus leaves the `<Dialog />` focusable content. This only
69
- * occurs when `shouldContainFocus` is set to false.
70
- */
71
- onBlur: PropTypes.func,
72
-
73
- onDismiss: PropTypes.func,
74
-
75
- /**
76
- * An element or a function returning an element to focus by default
77
- */
78
- defaultFocusElement: PropTypes.oneOfType([
79
- PropTypes.element,
80
- PropTypes.func
81
- ]),
82
-
83
- /**
84
- * An element or a function returning an element that wraps the content of the `<Dialog />`
85
- */
86
- contentElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
87
-
88
- /**
89
- * An element, function returning an element, or array of elements that will not be hidden from
90
- * the screen reader when the `<Dialog />` is open
91
- */
92
- liveRegion: PropTypes.oneOfType([
93
- PropTypes.arrayOf(PropTypes.element),
94
- PropTypes.element,
95
- PropTypes.func
96
- ]),
97
- shouldContainFocus: PropTypes.oneOfType([
98
- PropTypes.bool,
99
- PropTypes.oneOf(['keyboard', 'screenreader'])
100
- ]),
101
- shouldReturnFocus: PropTypes.bool,
102
- shouldCloseOnDocumentClick: PropTypes.bool,
103
- shouldCloseOnEscape: PropTypes.bool,
104
- shouldFocusOnOpen: PropTypes.bool
105
- } as const
106
-
47
+ static propTypes = propTypes
48
+ static allowedProps = allowedProps
107
49
  static defaultProps = {
108
50
  children: null,
109
- display: undefined,
110
- label: undefined,
111
51
  open: false,
112
52
  shouldFocusOnOpen: true,
113
53
  shouldContainFocus: false,
@@ -243,7 +183,7 @@ class Dialog extends Component<DialogProps & OtherHTMLAttributes<DialogProps>> {
243
183
 
244
184
  return this.props.open ? (
245
185
  <ElementType
246
- //@ts-expect-error TODO: `ref` prop causes: "Expression produces a union type that is too complex to represent.ts(2590)"
186
+ // @ts-expect-error TODO: `ref` prop causes: "Expression produces a union type that is too complex to represent.ts(2590)"
247
187
  {...omitProps(this.props, Dialog.propTypes)}
248
188
  role={this.props.label ? 'dialog' : undefined}
249
189
  aria-label={this.props.label}
@@ -0,0 +1,133 @@
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 type { AsElementType, PropValidators } from '@instructure/shared-types'
29
+
30
+ type DialogOwnProps = {
31
+ children?: React.ReactNode
32
+ as?: AsElementType
33
+ display?: 'auto' | 'block' | 'inline-block'
34
+ label?: string
35
+ open?: boolean
36
+ onBlur?: (...args: any[]) => any
37
+ onDismiss?: (...args: any[]) => any
38
+ defaultFocusElement?: React.ReactElement | ((...args: any[]) => any)
39
+ contentElement?: React.ReactElement | ((...args: any[]) => any)
40
+ liveRegion?:
41
+ | React.ReactElement[]
42
+ | React.ReactElement
43
+ | ((...args: any[]) => any)
44
+ shouldContainFocus?: boolean | ('keyboard' | 'screenreader')
45
+ shouldReturnFocus?: boolean
46
+ shouldCloseOnDocumentClick?: boolean
47
+ shouldCloseOnEscape?: boolean
48
+ shouldFocusOnOpen?: boolean
49
+ }
50
+
51
+ type PropKeys = keyof DialogOwnProps
52
+
53
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
54
+
55
+ type DialogProps = DialogOwnProps
56
+
57
+ const propTypes: PropValidators<PropKeys> = {
58
+ /**
59
+ * The children to be rendered within the `<Dialog />`
60
+ */
61
+ children: PropTypes.node,
62
+
63
+ /**
64
+ * The element to render as the component root, `span` by default
65
+ */
66
+ as: PropTypes.elementType, // eslint-disable-line react/require-default-props
67
+
68
+ display: PropTypes.oneOf(['auto', 'block', 'inline-block']),
69
+
70
+ label: PropTypes.string,
71
+
72
+ /**
73
+ * Whether or not the `<Dialog />` is open
74
+ */
75
+ open: PropTypes.bool,
76
+
77
+ /**
78
+ * Function called when tab focus leaves the `<Dialog />` focusable content. This only
79
+ * occurs when `shouldContainFocus` is set to false.
80
+ */
81
+ onBlur: PropTypes.func,
82
+
83
+ onDismiss: PropTypes.func,
84
+
85
+ /**
86
+ * An element or a function returning an element to focus by default
87
+ */
88
+ defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
89
+
90
+ /**
91
+ * An element or a function returning an element that wraps the content of the `<Dialog />`
92
+ */
93
+ contentElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
94
+
95
+ /**
96
+ * An element, function returning an element, or array of elements that will not be hidden from
97
+ * the screen reader when the `<Dialog />` is open
98
+ */
99
+ liveRegion: PropTypes.oneOfType([
100
+ PropTypes.arrayOf(PropTypes.element),
101
+ PropTypes.element,
102
+ PropTypes.func
103
+ ]),
104
+ shouldContainFocus: PropTypes.oneOfType([
105
+ PropTypes.bool,
106
+ PropTypes.oneOf(['keyboard', 'screenreader'])
107
+ ]),
108
+ shouldReturnFocus: PropTypes.bool,
109
+ shouldCloseOnDocumentClick: PropTypes.bool,
110
+ shouldCloseOnEscape: PropTypes.bool,
111
+ shouldFocusOnOpen: PropTypes.bool
112
+ }
113
+
114
+ const allowedProps: AllowedPropKeys = [
115
+ 'children',
116
+ 'as',
117
+ 'display',
118
+ 'label',
119
+ 'open',
120
+ 'onBlur',
121
+ 'onDismiss',
122
+ 'defaultFocusElement',
123
+ 'contentElement',
124
+ 'liveRegion',
125
+ 'shouldContainFocus',
126
+ 'shouldReturnFocus',
127
+ 'shouldCloseOnDocumentClick',
128
+ 'shouldCloseOnEscape',
129
+ 'shouldFocusOnOpen'
130
+ ]
131
+
132
+ export type { DialogProps }
133
+ export { propTypes, allowedProps }
package/src/index.ts CHANGED
@@ -22,4 +22,4 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  export { Dialog } from './Dialog'
25
- export type { DialogProps } from './Dialog/types'
25
+ export type { DialogProps } from './Dialog/props'
@@ -1,8 +1,7 @@
1
- import { Component } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import React, { Component } from 'react';
3
2
  import type { RequestAnimationFrameType } from '@instructure/ui-dom-utils';
4
3
  import type { OtherHTMLAttributes } from '@instructure/shared-types';
5
- import { DialogProps } from './types';
4
+ import type { DialogProps } from './props';
6
5
  /**
7
6
  ---
8
7
  category: components/utilities
@@ -11,50 +10,42 @@ category: components/utilities
11
10
  **/
12
11
  declare class Dialog extends Component<DialogProps & OtherHTMLAttributes<DialogProps>> {
13
12
  static readonly componentId = "Dialog";
14
- static propTypes: {
15
- /**
16
- * The children to be rendered within the `<Dialog />`
17
- */
18
- readonly children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
19
- /**
20
- * The element to render as the component root, `span` by default
21
- */
22
- readonly as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
23
- readonly display: PropTypes.Requireable<string>;
24
- readonly label: PropTypes.Requireable<string>;
25
- /**
26
- * Whether or not the `<Dialog />` is open
27
- */
28
- readonly open: PropTypes.Requireable<boolean>;
29
- /**
30
- * Function called when tab focus leaves the `<Dialog />` focusable content. This only
31
- * occurs when `shouldContainFocus` is set to false.
32
- */
33
- readonly onBlur: PropTypes.Requireable<(...args: any[]) => any>;
34
- readonly onDismiss: PropTypes.Requireable<(...args: any[]) => any>;
35
- /**
36
- * An element or a function returning an element to focus by default
37
- */
38
- readonly defaultFocusElement: PropTypes.Requireable<PropTypes.ReactElementLike | ((...args: any[]) => any)>;
39
- /**
40
- * An element or a function returning an element that wraps the content of the `<Dialog />`
41
- */
42
- readonly contentElement: PropTypes.Requireable<PropTypes.ReactElementLike | ((...args: any[]) => any)>;
43
- /**
44
- * An element, function returning an element, or array of elements that will not be hidden from
45
- * the screen reader when the `<Dialog />` is open
46
- */
47
- readonly liveRegion: PropTypes.Requireable<PropTypes.ReactElementLike | ((...args: any[]) => any) | (PropTypes.ReactElementLike | null | undefined)[]>;
48
- readonly shouldContainFocus: PropTypes.Requireable<string | boolean>;
49
- readonly shouldReturnFocus: PropTypes.Requireable<boolean>;
50
- readonly shouldCloseOnDocumentClick: PropTypes.Requireable<boolean>;
51
- readonly shouldCloseOnEscape: PropTypes.Requireable<boolean>;
52
- readonly shouldFocusOnOpen: PropTypes.Requireable<boolean>;
53
- };
13
+ static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
14
+ children?: React.ReactNode;
15
+ as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
16
+ display?: "auto" | "block" | "inline-block" | undefined;
17
+ label?: string | undefined;
18
+ open?: boolean | undefined;
19
+ onBlur?: ((...args: any[]) => any) | undefined;
20
+ onDismiss?: ((...args: any[]) => any) | undefined;
21
+ defaultFocusElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
22
+ contentElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
23
+ liveRegion?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((...args: any[]) => any) | undefined;
24
+ shouldContainFocus?: boolean | "keyboard" | "screenreader" | undefined;
25
+ shouldReturnFocus?: boolean | undefined;
26
+ shouldCloseOnDocumentClick?: boolean | undefined;
27
+ shouldCloseOnEscape?: boolean | undefined;
28
+ shouldFocusOnOpen?: boolean | undefined;
29
+ }>;
30
+ static allowedProps: readonly (keyof {
31
+ children?: React.ReactNode;
32
+ as?: import("@instructure/shared-types/types/CommonProps").AsElementType | undefined;
33
+ display?: "auto" | "block" | "inline-block" | undefined;
34
+ label?: string | undefined;
35
+ open?: boolean | undefined;
36
+ onBlur?: ((...args: any[]) => any) | undefined;
37
+ onDismiss?: ((...args: any[]) => any) | undefined;
38
+ defaultFocusElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
39
+ contentElement?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((...args: any[]) => any) | undefined;
40
+ liveRegion?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((...args: any[]) => any) | undefined;
41
+ shouldContainFocus?: boolean | "keyboard" | "screenreader" | undefined;
42
+ shouldReturnFocus?: boolean | undefined;
43
+ shouldCloseOnDocumentClick?: boolean | undefined;
44
+ shouldCloseOnEscape?: boolean | undefined;
45
+ shouldFocusOnOpen?: boolean | undefined;
46
+ })[];
54
47
  static defaultProps: {
55
48
  readonly children: null;
56
- readonly display: undefined;
57
- readonly label: undefined;
58
49
  readonly open: false;
59
50
  readonly shouldFocusOnOpen: true;
60
51
  readonly shouldContainFocus: false;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dialog/index.tsx"],"names":[],"mappings":"AAwBA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAGpE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AAEH,cAAM,MAAO,SAAQ,SAAS,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAC5E,MAAM,CAAC,QAAQ,CAAC,WAAW,YAAW;IAEtC,MAAM,CAAC,SAAS;QACd;;WAEG;;QAGH;;WAEG;;;;QAOH;;WAEG;;QAGH;;;WAGG;;;QAKH;;WAEG;;QAMH;;WAEG;;QAGH;;;WAGG;;;;;;;MAcK;IAEV,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;MAiBT;IAEV,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,EAAE,CAAK;IAC/C,IAAI,EAAE,yBAAyB,EAAE,CAAK;IACtC,YAAY,OAAO;IACnB,iBAAiB;IAOjB,kBAAkB,CAAC,SAAS,KAAA;IAe5B,oBAAoB;IAWpB,IAAI;IAyBJ,KAAK;IAOL,KAAK;IAYL,IAAI;IAUJ,MAAM,oBAGL;IAED,IAAI,cAAc,qCASjB;IAED,IAAI,OAAO,qBAOV;IAED,MAAM;CAgBP;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dialog/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAIpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;GAKG;AAEH,cAAM,MAAO,SAAQ,SAAS,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAC5E,MAAM,CAAC,QAAQ,CAAC,WAAW,YAAW;IAEtC,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;;;;;;;;;;;MAeT;IAEV,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,EAAE,CAAK;IAC/C,IAAI,EAAE,yBAAyB,EAAE,CAAK;IACtC,YAAY,OAAO;IACnB,iBAAiB;IAOjB,kBAAkB,CAAC,SAAS,KAAA;IAe5B,oBAAoB;IAWpB,IAAI;IAyBJ,KAAK;IAOL,KAAK;IAYL,IAAI;IAUJ,MAAM,oBAGL;IAED,IAAI,cAAc,qCASjB;IAED,IAAI,OAAO,qBAOV;IAED,MAAM;CAgBP;AAED,eAAe,MAAM,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -1,6 +1,7 @@
1
- import type { ReactNode } from 'react';
2
- import { AsElementType } from '@instructure/shared-types';
3
- export declare type DialogProps = {
1
+ import React from 'react';
2
+ import type { AsElementType, PropValidators } from '@instructure/shared-types';
3
+ declare type DialogOwnProps = {
4
+ children?: React.ReactNode;
4
5
  as?: AsElementType;
5
6
  display?: 'auto' | 'block' | 'inline-block';
6
7
  label?: string;
@@ -15,6 +16,12 @@ export declare type DialogProps = {
15
16
  shouldCloseOnDocumentClick?: boolean;
16
17
  shouldCloseOnEscape?: boolean;
17
18
  shouldFocusOnOpen?: boolean;
18
- children?: ReactNode;
19
19
  };
20
- //# sourceMappingURL=types.d.ts.map
20
+ declare type PropKeys = keyof DialogOwnProps;
21
+ declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
22
+ declare type DialogProps = DialogOwnProps;
23
+ declare const propTypes: PropValidators<PropKeys>;
24
+ declare const allowedProps: AllowedPropKeys;
25
+ export type { DialogProps };
26
+ export { propTypes, allowedProps };
27
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/Dialog/props.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE9E,aAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,CAAA;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IAChC,SAAS,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACnC,mBAAmB,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IACpE,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC/D,UAAU,CAAC,EACP,KAAK,CAAC,YAAY,EAAE,GACpB,KAAK,CAAC,YAAY,GAClB,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC7B,kBAAkB,CAAC,EAAE,OAAO,GAAG,CAAC,UAAU,GAAG,cAAc,CAAC,CAAA;IAC5D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,aAAK,QAAQ,GAAG,MAAM,cAAc,CAAA;AAEpC,aAAK,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEhD,aAAK,WAAW,GAAG,cAAc,CAAA;AAEjC,QAAA,MAAM,SAAS,EAAE,cAAc,CAAC,QAAQ,CAuDvC,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,eAgBnB,CAAA;AAED,YAAY,EAAE,WAAW,EAAE,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAA"}
package/types/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Dialog } from './Dialog';
2
- export type { DialogProps } from './Dialog/types';
2
+ export type { DialogProps } from './Dialog/props';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,47 +0,0 @@
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 { ReactNode } from 'react'
26
- import { AsElementType } from '@instructure/shared-types'
27
-
28
- export type DialogProps = {
29
- as?: AsElementType
30
- display?: 'auto' | 'block' | 'inline-block'
31
- label?: string
32
- open?: boolean
33
- onBlur?: (...args: any[]) => any
34
- onDismiss?: (...args: any[]) => any
35
- defaultFocusElement?: React.ReactElement | ((...args: any[]) => any)
36
- contentElement?: React.ReactElement | ((...args: any[]) => any)
37
- liveRegion?:
38
- | React.ReactElement[]
39
- | React.ReactElement
40
- | ((...args: any[]) => any)
41
- shouldContainFocus?: boolean | ('keyboard' | 'screenreader')
42
- shouldReturnFocus?: boolean
43
- shouldCloseOnDocumentClick?: boolean
44
- shouldCloseOnEscape?: boolean
45
- shouldFocusOnOpen?: boolean
46
- children?: ReactNode
47
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/Dialog/types.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,oBAAY,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,CAAA;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IAChC,SAAS,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;IACnC,mBAAmB,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IACpE,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC/D,UAAU,CAAC,EACP,KAAK,CAAC,YAAY,EAAE,GACpB,KAAK,CAAC,YAAY,GAClB,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC7B,kBAAkB,CAAC,EAAE,OAAO,GAAG,CAAC,UAAU,GAAG,cAAc,CAAC,CAAA;IAC5D,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA"}