MCPcopy Create free account
hub / github.com/microsoft/SandDance / ModalBase1

Function ModalBase1

docs/app/js/sanddance-app.js:42972–43165  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

42970var ModalBase = /** @class */ function(_super) {
42971 (0, _tslib.__extends)(ModalBase1, _super);
42972 function ModalBase1(props) {
42973 var _this = _super.call(this, props) || this;
42974 _this._focusTrapZone = _react.createRef();
42975 _this._focusTrapZoneMergedRef = (0, _utilities.createMergedRef)();
42976 _this._registerInitialModalPosition = function() {
42977 var _a;
42978 var dialogMain = document.querySelector("[data-id=" + _this.state.id + "]");
42979 if (dialogMain) {
42980 var modalRectangle = dialogMain.getBoundingClientRect();
42981 if (((_a = _this.props.dragOptions) === null || _a === void 0 ? void 0 : _a.keepInBounds) && !_this._minClampedPosition && !_this._maxClampedPosition) {
42982 _this._minClampedPosition = {
42983 x: -modalRectangle.x,
42984 y: -modalRectangle.y
42985 };
42986 _this._maxClampedPosition = {
42987 x: modalRectangle.x,
42988 y: modalRectangle.y
42989 };
42990 }
42991 _this.setState({
42992 modalRectangleTop: modalRectangle.top
42993 });
42994 }
42995 };
42996 // Allow the user to scroll within the modal but not on the body
42997 _this._allowScrollOnModal = function(elt) {
42998 if (elt) {
42999 if (_this._allowTouchBodyScroll) (0, _utilities.allowOverscrollOnElement)(elt, _this._events);
43000 else (0, _utilities.allowScrollOnElement)(elt, _this._events);
43001 } else _this._events.off(_this._scrollableContent);
43002 _this._scrollableContent = elt;
43003 };
43004 _this._onModalContextMenuClose = function() {
43005 _this.setState({
43006 isModalMenuOpen: false
43007 });
43008 };
43009 _this._onModalClose = function() {
43010 _this._lastSetX = 0;
43011 _this._lastSetY = 0;
43012 _this.setState({
43013 isModalMenuOpen: false,
43014 isInKeyboardMoveMode: false,
43015 isOpen: false,
43016 x: 0,
43017 y: 0
43018 });
43019 if (_this.props.dragOptions && _this._hasRegisteredKeyUp) _this._events.off(window, "keyup", _this._onKeyUp, true);
43020 // Call the onDismiss callback
43021 if (_this.props.onDismissed) _this.props.onDismissed();
43022 };
43023 _this._onDragStart = function() {
43024 _this.setState({
43025 isModalMenuOpen: false,
43026 isInKeyboardMoveMode: false
43027 });
43028 };
43029 _this._onDrag = function(_, ui) {

Callers

nothing calls this directly

Calls 4

offMethod · 0.45
focusMethod · 0.45
stopPropagationMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected