baseui 10.12.0 → 11.0.1
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/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +10 -2
- package/data-table/data-table.js.flow +4 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +15 -7
- package/datepicker/calendar.js.flow +23 -9
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +61 -30
- package/datepicker/datepicker.js.flow +77 -37
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- package/datepicker/stateful-container.js.flow +2 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +35 -10
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +6 -2
- package/es/data-table/header-cell.js +3 -0
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +15 -7
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +56 -29
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/form-control/styled-components.js +0 -1
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +20 -20
- package/es/select/styled-components.js +21 -17
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +10 -2
- package/esm/data-table/header-cell.js +3 -0
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +15 -7
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +60 -30
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/form-control/styled-components.js +0 -1
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +20 -20
- package/esm/select/styled-components.js +21 -14
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +3 -2
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +0 -2
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +23 -24
- package/select/select-component.js.flow +25 -14
- package/select/styled-components.js +23 -17
- package/select/styled-components.js.flow +17 -12
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
package/modal/index.d.ts
CHANGED
|
@@ -32,22 +32,22 @@ export interface SharedStylePropsArg {
|
|
|
32
32
|
$size?: SIZE[keyof SIZE];
|
|
33
33
|
$role?: ROLE[keyof ROLE];
|
|
34
34
|
$closeable?: boolean;
|
|
35
|
-
$unstable_ModalBackdropScroll?: boolean;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export interface ModalOverrides {
|
|
39
38
|
Root?: Override<SharedStylePropsArg>;
|
|
40
|
-
Backdrop?: Override<SharedStylePropsArg>;
|
|
41
39
|
Dialog?: Override<SharedStylePropsArg>;
|
|
42
40
|
DialogContainer?: Override<SharedStylePropsArg>;
|
|
43
41
|
Close?: Override<SharedStylePropsArg>;
|
|
44
42
|
}
|
|
45
43
|
export interface ModalProps {
|
|
46
44
|
animate?: boolean;
|
|
47
|
-
autofocus?: boolean;
|
|
48
45
|
autoFocus?: boolean;
|
|
49
46
|
focusLock?: boolean;
|
|
50
|
-
returnFocus?:
|
|
47
|
+
returnFocus?:
|
|
48
|
+
| boolean
|
|
49
|
+
| FocusOptions
|
|
50
|
+
| ((returnTo: Element) => boolean | FocusOptions);
|
|
51
51
|
children?: React.ReactNode;
|
|
52
52
|
closeable?: boolean;
|
|
53
53
|
isOpen?: boolean;
|
|
@@ -56,7 +56,6 @@ export interface ModalProps {
|
|
|
56
56
|
overrides?: ModalOverrides;
|
|
57
57
|
role?: ROLE[keyof ROLE];
|
|
58
58
|
size?: SIZE[keyof SIZE];
|
|
59
|
-
unstable_ModalBackdropScroll?: boolean;
|
|
60
59
|
}
|
|
61
60
|
export interface ModalState {
|
|
62
61
|
isVisible: boolean;
|
|
@@ -92,7 +91,6 @@ export class ModalButton extends React.Component<
|
|
|
92
91
|
export class FocusOnce extends React.Component<{children: React.ReactNode}> {}
|
|
93
92
|
|
|
94
93
|
export const StyledRoot: StyletronComponent<any>;
|
|
95
|
-
export const StyledBackdrop: StyletronComponent<any>;
|
|
96
94
|
export const StyledDialog: StyletronComponent<any>;
|
|
97
95
|
export const StyledDialogContainer: StyletronComponent<any>;
|
|
98
96
|
export const StyledClose: StyletronComponent<any>;
|
package/modal/index.js
CHANGED
|
@@ -45,12 +45,6 @@ Object.defineProperty(exports, "StyledRoot", {
|
|
|
45
45
|
return _styledComponents.Root;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "StyledBackdrop", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function get() {
|
|
51
|
-
return _styledComponents.Backdrop;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
48
|
Object.defineProperty(exports, "StyledDialog", {
|
|
55
49
|
enumerable: true,
|
|
56
50
|
get: function get() {
|
package/modal/index.js.flow
CHANGED
|
@@ -11,7 +11,6 @@ export { default as FocusOnce } from './focus-once.js';
|
|
|
11
11
|
export { SIZE, ROLE, CLOSE_SOURCE } from './constants.js';
|
|
12
12
|
export {
|
|
13
13
|
Root as StyledRoot,
|
|
14
|
-
Backdrop as StyledBackdrop,
|
|
15
14
|
Dialog as StyledDialog,
|
|
16
15
|
DialogContainer as StyledDialogContainer,
|
|
17
16
|
Close as StyledClose,
|
package/modal/modal.js
CHANGED
|
@@ -87,11 +87,13 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
87
87
|
|
|
88
88
|
_defineProperty(_assertThisInitialized(_this), "animateStartTimer", void 0);
|
|
89
89
|
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "dialogContainerRef", /*#__PURE__*/React.createRef());
|
|
91
|
+
|
|
90
92
|
_defineProperty(_assertThisInitialized(_this), "lastFocus", null);
|
|
91
93
|
|
|
92
94
|
_defineProperty(_assertThisInitialized(_this), "lastMountNodeOverflowStyle", null);
|
|
93
95
|
|
|
94
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
96
|
+
_defineProperty(_assertThisInitialized(_this), "rootRef", /*#__PURE__*/React.createRef());
|
|
95
97
|
|
|
96
98
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
97
99
|
isVisible: false,
|
|
@@ -124,10 +126,7 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
124
126
|
});
|
|
125
127
|
|
|
126
128
|
_defineProperty(_assertThisInitialized(_this), "onDocumentClick", function (e) {
|
|
127
|
-
if (e.target && e.target instanceof HTMLElement && (
|
|
128
|
-
e.target.contains(_this.getRef('DialogContainer').current) || // Handles modal closure when unstable_ModalBackdropScroll is set to false
|
|
129
|
-
// $FlowFixMe
|
|
130
|
-
e.target.contains(_this.getRef('DeprecatedBackdrop').current))) {
|
|
129
|
+
if (e.target && e.target instanceof HTMLElement && e.target.contains(_this.dialogContainerRef.current)) {
|
|
131
130
|
_this.onBackdropClick();
|
|
132
131
|
}
|
|
133
132
|
});
|
|
@@ -158,18 +157,10 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
158
157
|
value: function componentDidMount() {
|
|
159
158
|
this.setState({
|
|
160
159
|
mounted: true
|
|
161
|
-
});
|
|
160
|
+
});
|
|
162
161
|
|
|
163
162
|
if (process.env.NODE_ENV !== "production") {
|
|
164
|
-
|
|
165
|
-
console.warn("Consider setting 'unstable_ModalBackdropScroll' prop to true\n to prepare for the next major version upgrade. 'unstable_ModalBackdropScroll'\n prop will be removed in the next major version but implemented as the default behavior.");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (this.props.overrides && this.props.overrides.Backdrop) {
|
|
169
|
-
console.warn("Backdrop element will be removed in the next major version in favor of\n DialogContainer element that will have the backdrop styles and backdrop click handle.\n Consider setting 'unstable_ModalBackdropScroll' prop to true that will apply backdrop\n styles to DialogContainer enable modal scrolling while cursor in over the backdrop.\n Then pass backdrop overrides to DialogContainer instead. Tha will help you with\n the next major version upgrade.");
|
|
170
|
-
} // $FlowFixMe: flow complains that this prop doesn't exist
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
// $FlowFixMe: flow complains that this prop doesn't exist
|
|
173
164
|
if (this.props.closable) {
|
|
174
165
|
console.warn('The property `closable` is not supported on the Modal. Did you mean `closeable`?');
|
|
175
166
|
}
|
|
@@ -237,7 +228,7 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
237
228
|
|
|
238
229
|
// Sometimes scroll starts past zero, possibly due to animation
|
|
239
230
|
// Reset scroll to 0 (other libraries do this as well)
|
|
240
|
-
var rootRef = this.
|
|
231
|
+
var rootRef = this.rootRef.current;
|
|
241
232
|
|
|
242
233
|
if (rootRef) {
|
|
243
234
|
rootRef.scrollTop = 0;
|
|
@@ -277,8 +268,7 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
277
268
|
isOpen = _this$props.isOpen,
|
|
278
269
|
size = _this$props.size,
|
|
279
270
|
role = _this$props.role,
|
|
280
|
-
closeable = _this$props.closeable
|
|
281
|
-
unstable_ModalBackdropScroll = _this$props.unstable_ModalBackdropScroll;
|
|
271
|
+
closeable = _this$props.closeable;
|
|
282
272
|
return {
|
|
283
273
|
$animate: animate,
|
|
284
274
|
$isVisible: this.state.isVisible,
|
|
@@ -286,7 +276,6 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
286
276
|
$size: size,
|
|
287
277
|
$role: role,
|
|
288
278
|
$closeable: !!closeable,
|
|
289
|
-
$unstable_ModalBackdropScroll: unstable_ModalBackdropScroll,
|
|
290
279
|
$isFocusVisible: this.state.isFocusVisible
|
|
291
280
|
};
|
|
292
281
|
}
|
|
@@ -309,15 +298,6 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
309
298
|
var children = this.props.children;
|
|
310
299
|
return typeof children === 'function' ? children() : children;
|
|
311
300
|
}
|
|
312
|
-
}, {
|
|
313
|
-
key: "getRef",
|
|
314
|
-
value: function getRef(component) {
|
|
315
|
-
if (!this._refs[component]) {
|
|
316
|
-
this._refs[component] = /*#__PURE__*/React.createRef();
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return this._refs[component];
|
|
320
|
-
}
|
|
321
301
|
}, {
|
|
322
302
|
key: "renderModal",
|
|
323
303
|
value: function renderModal() {
|
|
@@ -328,15 +308,12 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
328
308
|
overrides = _this$props2$override === void 0 ? {} : _this$props2$override,
|
|
329
309
|
closeable = _this$props2.closeable,
|
|
330
310
|
role = _this$props2.role,
|
|
331
|
-
unstable_ModalBackdropScroll = _this$props2.unstable_ModalBackdropScroll,
|
|
332
|
-
autofocus = _this$props2.autofocus,
|
|
333
311
|
autoFocus = _this$props2.autoFocus,
|
|
334
312
|
focusLock = _this$props2.focusLock,
|
|
335
313
|
returnFocus = _this$props2.returnFocus;
|
|
336
314
|
var RootOverride = overrides.Root,
|
|
337
315
|
DialogOverride = overrides.Dialog,
|
|
338
316
|
DialogContainerOverride = overrides.DialogContainer,
|
|
339
|
-
BackdropOverride = overrides.Backdrop,
|
|
340
317
|
CloseOverride = overrides.Close;
|
|
341
318
|
|
|
342
319
|
var _getOverrides = (0, _overrides.getOverrides)(RootOverride, _styledComponents.Root),
|
|
@@ -344,59 +321,42 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
344
321
|
Root = _getOverrides2[0],
|
|
345
322
|
rootProps = _getOverrides2[1];
|
|
346
323
|
|
|
347
|
-
var _getOverrides3 = (0, _overrides.getOverrides)(
|
|
324
|
+
var _getOverrides3 = (0, _overrides.getOverrides)(DialogContainerOverride, _styledComponents.DialogContainer),
|
|
348
325
|
_getOverrides4 = _slicedToArray(_getOverrides3, 2),
|
|
349
|
-
|
|
350
|
-
|
|
326
|
+
DialogContainer = _getOverrides4[0],
|
|
327
|
+
dialogContainerProps = _getOverrides4[1];
|
|
351
328
|
|
|
352
|
-
var _getOverrides5 = (0, _overrides.getOverrides)(
|
|
329
|
+
var _getOverrides5 = (0, _overrides.getOverrides)(DialogOverride, _styledComponents.Dialog),
|
|
353
330
|
_getOverrides6 = _slicedToArray(_getOverrides5, 2),
|
|
354
|
-
|
|
355
|
-
|
|
331
|
+
Dialog = _getOverrides6[0],
|
|
332
|
+
dialogProps = _getOverrides6[1];
|
|
356
333
|
|
|
357
|
-
var _getOverrides7 = (0, _overrides.getOverrides)(
|
|
334
|
+
var _getOverrides7 = (0, _overrides.getOverrides)(CloseOverride, _styledComponents.Close),
|
|
358
335
|
_getOverrides8 = _slicedToArray(_getOverrides7, 2),
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
var _getOverrides9 = (0, _overrides.getOverrides)(CloseOverride, _styledComponents.Close),
|
|
363
|
-
_getOverrides10 = _slicedToArray(_getOverrides9, 2),
|
|
364
|
-
Close = _getOverrides10[0],
|
|
365
|
-
closeProps = _getOverrides10[1];
|
|
336
|
+
Close = _getOverrides8[0],
|
|
337
|
+
closeProps = _getOverrides8[1];
|
|
366
338
|
|
|
367
339
|
var sharedProps = this.getSharedProps();
|
|
368
340
|
var children = this.getChildren();
|
|
369
|
-
|
|
370
|
-
if (autofocus === false && process.env.NODE_ENV !== "production") {
|
|
371
|
-
console.warn("The prop \"autofocus\" is deprecated in favor of \"autoFocus\" to be consistent across the project.\n The property \"autofocus\" will be removed in a future major version.");
|
|
372
|
-
} // Handles backdrop click when `unstable_ModalBackdropScroll` is set to true
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (dialogContainerProps.ref) {
|
|
376
|
-
this._refs.DialogContainer = dialogContainerProps.ref;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
var dialogContainerConditionalProps = unstable_ModalBackdropScroll ? {
|
|
380
|
-
ref: this.getRef('DialogContainer')
|
|
381
|
-
} : {};
|
|
382
341
|
return /*#__PURE__*/React.createElement(_index.LocaleContext.Consumer, null, function (locale) {
|
|
383
342
|
return /*#__PURE__*/React.createElement(_reactFocusLock.default, {
|
|
384
343
|
disabled: !focusLock // Allow focus to escape when UI is within an iframe
|
|
385
344
|
,
|
|
386
345
|
crossFrame: false,
|
|
387
346
|
returnFocus: returnFocus,
|
|
388
|
-
autoFocus:
|
|
347
|
+
autoFocus: autoFocus
|
|
389
348
|
}, /*#__PURE__*/React.createElement(Root, _extends({
|
|
390
|
-
"data-baseweb": "modal"
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
349
|
+
"data-baseweb": "modal" // flowlint-next-line unclear-type:off
|
|
350
|
+
,
|
|
351
|
+
ref: _this3.rootRef
|
|
352
|
+
}, sharedProps, rootProps), /*#__PURE__*/React.createElement(DialogContainer // flowlint-next-line unclear-type:off
|
|
353
|
+
, _extends({
|
|
354
|
+
ref: _this3.dialogContainerRef
|
|
355
|
+
}, sharedProps, dialogContainerProps), /*#__PURE__*/React.createElement(Dialog, _extends({
|
|
395
356
|
tabIndex: -1,
|
|
396
357
|
"aria-modal": true,
|
|
397
358
|
"aria-label": "dialog",
|
|
398
|
-
role: role
|
|
399
|
-
ref: _this3.getRef('Dialog')
|
|
359
|
+
role: role
|
|
400
360
|
}, sharedProps, dialogProps), children, closeable ? /*#__PURE__*/React.createElement(Close, _extends({
|
|
401
361
|
"aria-label": locale.modal.close,
|
|
402
362
|
onClick: _this3.onCloseClick
|
|
@@ -432,8 +392,6 @@ var Modal = /*#__PURE__*/function (_React$Component) {
|
|
|
432
392
|
|
|
433
393
|
_defineProperty(Modal, "defaultProps", {
|
|
434
394
|
animate: true,
|
|
435
|
-
// TODO(v11): remove
|
|
436
|
-
autofocus: null,
|
|
437
395
|
autoFocus: true,
|
|
438
396
|
focusLock: true,
|
|
439
397
|
returnFocus: true,
|
|
@@ -442,8 +400,7 @@ _defineProperty(Modal, "defaultProps", {
|
|
|
442
400
|
isOpen: false,
|
|
443
401
|
overrides: {},
|
|
444
402
|
role: _constants.ROLE.dialog,
|
|
445
|
-
size: _constants.SIZE.default
|
|
446
|
-
unstable_ModalBackdropScroll: false
|
|
403
|
+
size: _constants.SIZE.default
|
|
447
404
|
});
|
|
448
405
|
|
|
449
406
|
var _default = Modal;
|
package/modal/modal.js.flow
CHANGED
|
@@ -16,27 +16,18 @@ import { Layer } from '../layer/index.js';
|
|
|
16
16
|
import { SIZE, ROLE, CLOSE_SOURCE } from './constants.js';
|
|
17
17
|
import {
|
|
18
18
|
Root as StyledRoot,
|
|
19
|
-
Backdrop as StyledBackdrop,
|
|
20
19
|
Dialog as StyledDialog,
|
|
21
20
|
DialogContainer as StyledDialogContainer,
|
|
22
21
|
Close as StyledClose,
|
|
23
22
|
} from './styled-components.js';
|
|
24
23
|
import { CloseIcon } from './close-icon.js';
|
|
25
24
|
|
|
26
|
-
import type {
|
|
27
|
-
ModalPropsT,
|
|
28
|
-
ModalStateT,
|
|
29
|
-
SharedStylePropsArgT,
|
|
30
|
-
CloseSourceT,
|
|
31
|
-
ElementRefT,
|
|
32
|
-
} from './types.js';
|
|
25
|
+
import type { ModalPropsT, ModalStateT, SharedStylePropsArgT, CloseSourceT } from './types.js';
|
|
33
26
|
import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
|
|
34
27
|
|
|
35
28
|
class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
36
29
|
static defaultProps: $Shape<ModalPropsT> = {
|
|
37
30
|
animate: true,
|
|
38
|
-
// TODO(v11): remove
|
|
39
|
-
autofocus: null,
|
|
40
31
|
autoFocus: true,
|
|
41
32
|
focusLock: true,
|
|
42
33
|
returnFocus: true,
|
|
@@ -46,14 +37,14 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
46
37
|
overrides: {},
|
|
47
38
|
role: ROLE.dialog,
|
|
48
39
|
size: SIZE.default,
|
|
49
|
-
unstable_ModalBackdropScroll: false,
|
|
50
40
|
};
|
|
51
41
|
|
|
52
42
|
animateOutTimer: ?TimeoutID;
|
|
53
43
|
animateStartTimer: ?AnimationFrameID;
|
|
44
|
+
dialogContainerRef = React.createRef<HTMLElement>();
|
|
54
45
|
lastFocus: ?HTMLElement = null;
|
|
55
46
|
lastMountNodeOverflowStyle: ?string = null;
|
|
56
|
-
|
|
47
|
+
rootRef = React.createRef<HTMLElement>();
|
|
57
48
|
|
|
58
49
|
state = {
|
|
59
50
|
isVisible: false,
|
|
@@ -63,21 +54,7 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
63
54
|
|
|
64
55
|
componentDidMount() {
|
|
65
56
|
this.setState({ mounted: true });
|
|
66
|
-
// TODO(v11)
|
|
67
57
|
if (__DEV__) {
|
|
68
|
-
if (!this.props.unstable_ModalBackdropScroll) {
|
|
69
|
-
console.warn(`Consider setting 'unstable_ModalBackdropScroll' prop to true
|
|
70
|
-
to prepare for the next major version upgrade. 'unstable_ModalBackdropScroll'
|
|
71
|
-
prop will be removed in the next major version but implemented as the default behavior.`);
|
|
72
|
-
}
|
|
73
|
-
if (this.props.overrides && this.props.overrides.Backdrop) {
|
|
74
|
-
console.warn(`Backdrop element will be removed in the next major version in favor of
|
|
75
|
-
DialogContainer element that will have the backdrop styles and backdrop click handle.
|
|
76
|
-
Consider setting 'unstable_ModalBackdropScroll' prop to true that will apply backdrop
|
|
77
|
-
styles to DialogContainer enable modal scrolling while cursor in over the backdrop.
|
|
78
|
-
Then pass backdrop overrides to DialogContainer instead. Tha will help you with
|
|
79
|
-
the next major version upgrade.`);
|
|
80
|
-
}
|
|
81
58
|
// $FlowFixMe: flow complains that this prop doesn't exist
|
|
82
59
|
if (this.props.closable) {
|
|
83
60
|
console.warn(
|
|
@@ -149,11 +126,7 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
149
126
|
if (
|
|
150
127
|
e.target &&
|
|
151
128
|
e.target instanceof HTMLElement &&
|
|
152
|
-
|
|
153
|
-
(e.target.contains(this.getRef('DialogContainer').current) ||
|
|
154
|
-
// Handles modal closure when unstable_ModalBackdropScroll is set to false
|
|
155
|
-
// $FlowFixMe
|
|
156
|
-
e.target.contains(this.getRef('DeprecatedBackdrop').current))
|
|
129
|
+
e.target.contains(this.dialogContainerRef.current)
|
|
157
130
|
) {
|
|
158
131
|
this.onBackdropClick();
|
|
159
132
|
}
|
|
@@ -183,7 +156,7 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
183
156
|
didOpen() {
|
|
184
157
|
// Sometimes scroll starts past zero, possibly due to animation
|
|
185
158
|
// Reset scroll to 0 (other libraries do this as well)
|
|
186
|
-
const rootRef = this.
|
|
159
|
+
const rootRef = this.rootRef.current;
|
|
187
160
|
if (rootRef) {
|
|
188
161
|
rootRef.scrollTop = 0;
|
|
189
162
|
}
|
|
@@ -220,7 +193,7 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
220
193
|
};
|
|
221
194
|
|
|
222
195
|
getSharedProps(): $Diff<SharedStylePropsArgT, { children?: React.Node }> {
|
|
223
|
-
const { animate, isOpen, size, role, closeable
|
|
196
|
+
const { animate, isOpen, size, role, closeable } = this.props;
|
|
224
197
|
return {
|
|
225
198
|
$animate: animate,
|
|
226
199
|
$isVisible: this.state.isVisible,
|
|
@@ -228,7 +201,6 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
228
201
|
$size: size,
|
|
229
202
|
$role: role,
|
|
230
203
|
$closeable: !!closeable,
|
|
231
|
-
$unstable_ModalBackdropScroll: unstable_ModalBackdropScroll,
|
|
232
204
|
$isFocusVisible: this.state.isFocusVisible,
|
|
233
205
|
};
|
|
234
206
|
}
|
|
@@ -248,35 +220,17 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
248
220
|
return typeof children === 'function' ? children() : children;
|
|
249
221
|
}
|
|
250
222
|
|
|
251
|
-
getRef(component: string): ElementRefT {
|
|
252
|
-
if (!this._refs[component]) {
|
|
253
|
-
this._refs[component] = React.createRef();
|
|
254
|
-
}
|
|
255
|
-
return this._refs[component];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
223
|
renderModal() {
|
|
259
|
-
const {
|
|
260
|
-
overrides = {},
|
|
261
|
-
closeable,
|
|
262
|
-
role,
|
|
263
|
-
unstable_ModalBackdropScroll,
|
|
264
|
-
autofocus,
|
|
265
|
-
autoFocus,
|
|
266
|
-
focusLock,
|
|
267
|
-
returnFocus,
|
|
268
|
-
} = this.props;
|
|
224
|
+
const { overrides = {}, closeable, role, autoFocus, focusLock, returnFocus } = this.props;
|
|
269
225
|
|
|
270
226
|
const {
|
|
271
227
|
Root: RootOverride,
|
|
272
228
|
Dialog: DialogOverride,
|
|
273
229
|
DialogContainer: DialogContainerOverride,
|
|
274
|
-
Backdrop: BackdropOverride,
|
|
275
230
|
Close: CloseOverride,
|
|
276
231
|
} = overrides;
|
|
277
232
|
|
|
278
233
|
const [Root, rootProps] = getOverrides(RootOverride, StyledRoot);
|
|
279
|
-
const [Backdrop, backdropProps] = getOverrides(BackdropOverride, StyledBackdrop);
|
|
280
234
|
const [DialogContainer, dialogContainerProps] = getOverrides(
|
|
281
235
|
DialogContainerOverride,
|
|
282
236
|
StyledDialogContainer
|
|
@@ -287,23 +241,6 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
287
241
|
const sharedProps = this.getSharedProps();
|
|
288
242
|
const children = this.getChildren();
|
|
289
243
|
|
|
290
|
-
if (autofocus === false && __DEV__) {
|
|
291
|
-
console.warn(
|
|
292
|
-
`The prop "autofocus" is deprecated in favor of "autoFocus" to be consistent across the project.
|
|
293
|
-
The property "autofocus" will be removed in a future major version.`
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Handles backdrop click when `unstable_ModalBackdropScroll` is set to true
|
|
298
|
-
if (dialogContainerProps.ref) {
|
|
299
|
-
this._refs.DialogContainer = dialogContainerProps.ref;
|
|
300
|
-
}
|
|
301
|
-
const dialogContainerConditionalProps = unstable_ModalBackdropScroll
|
|
302
|
-
? {
|
|
303
|
-
ref: this.getRef('DialogContainer'),
|
|
304
|
-
}
|
|
305
|
-
: {};
|
|
306
|
-
|
|
307
244
|
return (
|
|
308
245
|
<LocaleContext.Consumer>
|
|
309
246
|
{(locale) => (
|
|
@@ -312,20 +249,18 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
312
249
|
// Allow focus to escape when UI is within an iframe
|
|
313
250
|
crossFrame={false}
|
|
314
251
|
returnFocus={returnFocus}
|
|
315
|
-
autoFocus={
|
|
252
|
+
autoFocus={autoFocus}
|
|
316
253
|
>
|
|
317
|
-
<Root
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
{...sharedProps}
|
|
325
|
-
{...backdropProps}
|
|
326
|
-
/>
|
|
254
|
+
<Root
|
|
255
|
+
data-baseweb="modal"
|
|
256
|
+
// flowlint-next-line unclear-type:off
|
|
257
|
+
ref={(this.rootRef: any)}
|
|
258
|
+
{...sharedProps}
|
|
259
|
+
{...rootProps}
|
|
260
|
+
>
|
|
327
261
|
<DialogContainer
|
|
328
|
-
|
|
262
|
+
// flowlint-next-line unclear-type:off
|
|
263
|
+
ref={(this.dialogContainerRef: any)}
|
|
329
264
|
{...sharedProps}
|
|
330
265
|
{...dialogContainerProps}
|
|
331
266
|
>
|
|
@@ -334,7 +269,6 @@ class Modal extends React.Component<ModalPropsT, ModalStateT> {
|
|
|
334
269
|
aria-modal
|
|
335
270
|
aria-label="dialog"
|
|
336
271
|
role={role}
|
|
337
|
-
ref={this.getRef('Dialog')}
|
|
338
272
|
{...sharedProps}
|
|
339
273
|
{...dialogProps}
|
|
340
274
|
>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Close = exports.Dialog = exports.DialogContainer = exports.
|
|
6
|
+
exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Close = exports.Dialog = exports.DialogContainer = exports.Root = void 0;
|
|
7
7
|
|
|
8
8
|
var _index = require("../styles/index.js");
|
|
9
9
|
|
|
@@ -50,62 +50,29 @@ var Root = (0, _index.styled)('div', function (props) {
|
|
|
50
50
|
});
|
|
51
51
|
exports.Root = Root;
|
|
52
52
|
Root.displayName = "Root";
|
|
53
|
-
var
|
|
53
|
+
var DialogContainer = (0, _index.styled)('div', function (props) {
|
|
54
54
|
var $animate = props.$animate,
|
|
55
55
|
$isOpen = props.$isOpen,
|
|
56
56
|
$isVisible = props.$isVisible,
|
|
57
|
-
$theme = props.$theme
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if ($unstable_ModalBackdropScroll) {
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return _objectSpread({
|
|
65
|
-
position: 'fixed',
|
|
66
|
-
right: 0,
|
|
67
|
-
bottom: 0,
|
|
68
|
-
top: 0,
|
|
69
|
-
left: 0,
|
|
70
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
71
|
-
// Remove grey highlight
|
|
72
|
-
WebkitTapHighlightColor: 'transparent',
|
|
73
|
-
// Disable scroll capabilities.
|
|
74
|
-
touchAction: 'none',
|
|
75
|
-
opacity: $isVisible && $isOpen ? 1 : 0
|
|
76
|
-
}, $animate ? {
|
|
57
|
+
$theme = props.$theme;
|
|
58
|
+
var animationRules = {
|
|
77
59
|
transitionProperty: 'opacity',
|
|
78
60
|
transitionDuration: $theme.animation.timing400,
|
|
79
61
|
transitionTimingFunction: $theme.animation.easeOutCurve
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
exports.Backdrop = Backdrop;
|
|
83
|
-
Backdrop.displayName = "Backdrop";
|
|
84
|
-
var DialogContainer = (0, _index.styled)('div', function (props) {
|
|
85
|
-
var $animate = props.$animate,
|
|
86
|
-
$isOpen = props.$isOpen,
|
|
87
|
-
$isVisible = props.$isVisible,
|
|
88
|
-
$theme = props.$theme,
|
|
89
|
-
$unstable_ModalBackdropScroll = props.$unstable_ModalBackdropScroll;
|
|
62
|
+
};
|
|
90
63
|
return _objectSpread({
|
|
91
64
|
display: 'flex',
|
|
92
65
|
alignItems: 'center',
|
|
93
66
|
justifyContent: 'center',
|
|
94
67
|
width: '100%',
|
|
95
68
|
minHeight: '100%',
|
|
96
|
-
|
|
97
|
-
userSelect: 'none'
|
|
98
|
-
}, $unstable_ModalBackdropScroll ? _objectSpread({
|
|
69
|
+
userSelect: 'none',
|
|
99
70
|
pointerEvents: 'auto',
|
|
100
71
|
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
101
72
|
// Remove grey highlight
|
|
102
73
|
WebkitTapHighlightColor: 'transparent',
|
|
103
74
|
opacity: $isVisible && $isOpen ? 1 : 0
|
|
104
|
-
}, $animate ?
|
|
105
|
-
transitionProperty: 'opacity',
|
|
106
|
-
transitionDuration: $theme.animation.timing400,
|
|
107
|
-
transitionTimingFunction: $theme.animation.easeOutCurve
|
|
108
|
-
} : null) : {});
|
|
75
|
+
}, $animate ? animationRules : null);
|
|
109
76
|
});
|
|
110
77
|
exports.DialogContainer = DialogContainer;
|
|
111
78
|
DialogContainer.displayName = "DialogContainer";
|
|
@@ -47,59 +47,27 @@ export const Root = styled<SharedStylePropsArgT>('div', (props) => {
|
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
export const
|
|
51
|
-
const { $animate, $isOpen, $isVisible, $theme
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
position: 'fixed',
|
|
57
|
-
right: 0,
|
|
58
|
-
bottom: 0,
|
|
59
|
-
top: 0,
|
|
60
|
-
left: 0,
|
|
61
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
62
|
-
// Remove grey highlight
|
|
63
|
-
WebkitTapHighlightColor: 'transparent',
|
|
64
|
-
// Disable scroll capabilities.
|
|
65
|
-
touchAction: 'none',
|
|
66
|
-
opacity: $isVisible && $isOpen ? 1 : 0,
|
|
67
|
-
...($animate
|
|
68
|
-
? {
|
|
69
|
-
transitionProperty: 'opacity',
|
|
70
|
-
transitionDuration: $theme.animation.timing400,
|
|
71
|
-
transitionTimingFunction: $theme.animation.easeOutCurve,
|
|
72
|
-
}
|
|
73
|
-
: null),
|
|
50
|
+
export const DialogContainer = styled<SharedStylePropsArgT>('div', (props) => {
|
|
51
|
+
const { $animate, $isOpen, $isVisible, $theme } = props;
|
|
52
|
+
const animationRules = {
|
|
53
|
+
transitionProperty: 'opacity',
|
|
54
|
+
transitionDuration: $theme.animation.timing400,
|
|
55
|
+
transitionTimingFunction: $theme.animation.easeOutCurve,
|
|
74
56
|
};
|
|
75
|
-
});
|
|
76
57
|
|
|
77
|
-
export const DialogContainer = styled<SharedStylePropsArgT>('div', (props) => {
|
|
78
|
-
const { $animate, $isOpen, $isVisible, $theme, $unstable_ModalBackdropScroll } = props;
|
|
79
58
|
return {
|
|
80
59
|
display: 'flex',
|
|
81
60
|
alignItems: 'center',
|
|
82
61
|
justifyContent: 'center',
|
|
83
62
|
width: '100%',
|
|
84
63
|
minHeight: '100%',
|
|
85
|
-
pointerEvents: 'none',
|
|
86
64
|
userSelect: 'none',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
opacity: $isVisible && $isOpen ? 1 : 0,
|
|
94
|
-
...($animate
|
|
95
|
-
? {
|
|
96
|
-
transitionProperty: 'opacity',
|
|
97
|
-
transitionDuration: $theme.animation.timing400,
|
|
98
|
-
transitionTimingFunction: $theme.animation.easeOutCurve,
|
|
99
|
-
}
|
|
100
|
-
: null),
|
|
101
|
-
}
|
|
102
|
-
: {}),
|
|
65
|
+
pointerEvents: 'auto',
|
|
66
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
67
|
+
// Remove grey highlight
|
|
68
|
+
WebkitTapHighlightColor: 'transparent',
|
|
69
|
+
opacity: $isVisible && $isOpen ? 1 : 0,
|
|
70
|
+
...($animate ? animationRules : null),
|
|
103
71
|
};
|
|
104
72
|
});
|
|
105
73
|
|
package/modal/types.js.flow
CHANGED
|
@@ -20,15 +20,11 @@ export type CloseSourceT = $Keys<typeof CLOSE_SOURCE>;
|
|
|
20
20
|
|
|
21
21
|
export type OverridesT = {
|
|
22
22
|
Root?: OverrideT,
|
|
23
|
-
Backdrop?: OverrideT,
|
|
24
23
|
Dialog?: OverrideT,
|
|
25
24
|
DialogContainer?: OverrideT,
|
|
26
25
|
Close?: OverrideT,
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
// flowlint-next-line unclear-type:off
|
|
30
|
-
export type ElementRefT = { current: React.ElementRef<any> | null };
|
|
31
|
-
|
|
32
28
|
// Props shared by all flavors of modal
|
|
33
29
|
export type ModalPropsT = {
|
|
34
30
|
/** Sets whether the Modal should be displayed by easing in and out */
|
|
@@ -37,7 +33,6 @@ export type ModalPropsT = {
|
|
|
37
33
|
* If false, the modal container itself will receive focus.
|
|
38
34
|
* Moving focus into a newly opened modal is important for accessibility purposes, so please be careful!
|
|
39
35
|
*/
|
|
40
|
-
autofocus: boolean | null,
|
|
41
36
|
autoFocus: boolean,
|
|
42
37
|
/** If true, focus will be locked to elements within the modal.
|
|
43
38
|
*/
|
|
@@ -53,7 +48,7 @@ export type ModalPropsT = {
|
|
|
53
48
|
* for performance reasons (wont render until opened) */
|
|
54
49
|
children?: React.Node | (() => React.Node),
|
|
55
50
|
/** Whether the modal should be closeable by the user
|
|
56
|
-
* (either via escape,
|
|
51
|
+
* (either via escape, dialog container click, etc). You can set this to
|
|
57
52
|
* false if your modal has an action that the user must take before closing.*/
|
|
58
53
|
closeable: boolean,
|
|
59
54
|
isOpen: boolean,
|
|
@@ -70,9 +65,6 @@ export type ModalPropsT = {
|
|
|
70
65
|
/** Controls the size of the modal (primarily width).
|
|
71
66
|
* Can be a SIZE constant or css width property value. */
|
|
72
67
|
size: SizePropT,
|
|
73
|
-
/** Make modal scrollable while cursor is over the modal's backdrop.
|
|
74
|
-
* Will be removed and implemented as the default behavior in the next major version */
|
|
75
|
-
unstable_ModalBackdropScroll?: boolean,
|
|
76
68
|
};
|
|
77
69
|
|
|
78
70
|
export type ModalPropsWithoutChildrenT = $Diff<ModalPropsT, { children: ?React.Node }>;
|
|
@@ -90,7 +82,6 @@ export type SharedStylePropsArgT = {
|
|
|
90
82
|
$size: SizePropT,
|
|
91
83
|
$role: RolePropT,
|
|
92
84
|
$closeable: boolean,
|
|
93
|
-
$unstable_ModalBackdropScroll?: boolean,
|
|
94
85
|
$isFocusVisible: boolean,
|
|
95
86
|
};
|
|
96
87
|
|