mobx-route 0.21.0 → 0.22.0

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/index.cjs CHANGED
@@ -5,41 +5,51 @@ const complex = require("yummies/complex");
5
5
  const linkedAbortController = require("linked-abort-controller");
6
6
  const mobx = require("mobx");
7
7
  const pathToRegexp = require("path-to-regexp");
8
+ const mobx$1 = require("yummies/mobx");
8
9
  const common = require("yummies/common");
9
- let localHistory;
10
10
  const routeConfig = complex.createGlobalDynamicConfig(
11
- (update) => {
12
- if (localHistory && update?.history && mobxLocationHistory.isObservableHistory(localHistory)) {
13
- localHistory.destroy();
14
- }
11
+ (update, current) => {
15
12
  let history;
13
+ let queryParams;
16
14
  if (update?.history) {
17
15
  history = update.history;
18
- } else {
19
- history = localHistory = mobxLocationHistory.createBrowserHistory();
20
- }
21
- let queryParams;
22
- if (update?.history && !update.queryParams) {
23
- queryParams = new mobxLocationHistory.QueryParams({ history });
24
- } else {
25
- if (update?.queryParams) {
26
- queryParams = update.queryParams;
27
- } else {
28
- queryParams = new mobxLocationHistory.QueryParams({ history });
16
+ queryParams = update.queryParams;
17
+ if (current?.history && mobxLocationHistory.isObservableHistory(current.history)) {
18
+ current.history.destroy();
29
19
  }
20
+ } else if (current?.history) {
21
+ history = current.history;
22
+ queryParams = update?.queryParams ?? current.queryParams;
23
+ } else {
24
+ history = mobxLocationHistory.createBrowserHistory();
30
25
  }
26
+ queryParams ??= mobxLocationHistory.createQueryParams({ history });
31
27
  return {
32
28
  ...update,
33
29
  history,
34
- location,
35
30
  queryParams
36
31
  };
37
32
  },
38
33
  Symbol.for("MOBX_ROUTE_CONFIG")
39
34
  );
35
+ const annotations$3 = [
36
+ [
37
+ mobx.computed,
38
+ "isPathMatched",
39
+ "isOpened",
40
+ "isOpening",
41
+ "path",
42
+ "hasOpenedChildren",
43
+ "isAbleToMergeQuery",
44
+ "baseUrl"
45
+ ],
46
+ [mobx.computed.struct, "parsedPathData", "params"],
47
+ [mobx.observable, "children"],
48
+ [mobx.observable.ref, "parent", "status"]
49
+ ];
40
50
  class Route {
41
- constructor(path, config = {}) {
42
- this.path = path;
51
+ constructor(pathDeclaration, config = {}) {
52
+ this.pathDeclaration = pathDeclaration;
43
53
  this.config = config;
44
54
  this.abortController = new linkedAbortController.LinkedAbortController(config.abortSignal);
45
55
  this.history = config.history ?? routeConfig.get().history;
@@ -49,23 +59,7 @@ class Route {
49
59
  this.meta = this.config.meta;
50
60
  this.status = "unknown";
51
61
  this.parent = config.parent ?? null;
52
- mobx.computed(this, "isPathMatched");
53
- mobx.computed(this, "isOpened");
54
- mobx.computed.struct(this, "data");
55
- mobx.computed.struct(this, "params");
56
- mobx.computed(this, "currentPath");
57
- mobx.computed(this, "hasOpenedChildren");
58
- mobx.computed(this, "isAbleToMergeQuery");
59
- mobx.computed(this, "baseUrl");
60
- mobx.observable(this, "children");
61
- mobx.observable.ref(this, "parent");
62
- mobx.observable.ref(this, "status");
63
- mobx.computed(this, "isOpening");
64
- mobx.action(this, "addChildren");
65
- mobx.action(this, "confirmOpening");
66
- mobx.action(this, "confirmClosing");
67
- mobx.action(this, "removeChildren");
68
- mobx.makeObservable(this);
62
+ mobx$1.applyObservable(this, annotations$3);
69
63
  mobx.reaction(() => this.isPathMatched, this.checkPathMatch, {
70
64
  signal: this.abortController.signal,
71
65
  fireImmediately: true
@@ -78,19 +72,19 @@ class Route {
78
72
  _tokenData;
79
73
  _matcher;
80
74
  _compiler;
81
- skipPathMatchCheck = false;
75
+ ignoreOpenByPathMatch = false;
82
76
  status;
83
77
  meta;
84
78
  /**
85
79
  * Indicates if this route is an index route. Index routes activate when parent route path matches exactly.
86
80
  *
87
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isindex-boolean)
81
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isindex)
88
82
  */
89
83
  isIndex;
90
84
  /**
91
85
  * Indicates if this route is an hash route.
92
86
  *
93
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ishash-boolean)
87
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ishash)
94
88
  */
95
89
  isHash;
96
90
  children = [];
@@ -111,7 +105,7 @@ class Route {
111
105
  }
112
106
  pathnameToCheck = pathnameToCheck.replace(this.baseUrl, "");
113
107
  }
114
- if ((this.path === "" || this.path === "/") && (pathnameToCheck === "/" || pathnameToCheck === "")) {
108
+ if ((this.pathDeclaration === "" || this.pathDeclaration === "/") && (pathnameToCheck === "/" || pathnameToCheck === "")) {
115
109
  return { params: {}, path: pathnameToCheck };
116
110
  }
117
111
  this._matcher ??= pathToRegexp.match(this.tokenData, {
@@ -124,21 +118,24 @@ class Route {
124
118
  }
125
119
  return parsed;
126
120
  }
121
+ /**
122
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopening)
123
+ */
127
124
  get isOpening() {
128
125
  return this.status === "opening";
129
126
  }
130
127
  /**
131
128
  * Matched path segment for current URL.
132
129
  *
133
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#currentpath-parsedpathname-null)
130
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#path)
134
131
  */
135
- get currentPath() {
132
+ get path() {
136
133
  return this.parsedPathData?.path ?? null;
137
134
  }
138
135
  /**
139
136
  * Current parsed path parameters.
140
137
  *
141
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params-parsedpathparams-null)
138
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)
142
139
  */
143
140
  get params() {
144
141
  if (!this.parsedPathData?.params) {
@@ -164,22 +161,25 @@ class Route {
164
161
  /**
165
162
  * Defines the "open" state for this route.
166
163
  *
167
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened-boolean)
164
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)
168
165
  */
169
166
  get isOpened() {
170
167
  if (!this.isPathMatched || this.params === null || this.status !== "open-confirmed") {
171
168
  return false;
172
169
  }
173
- return !this.config.checkOpened || this.config.checkOpened(this.parsedPathData);
170
+ return (
171
+ // this.parsedPathData is defined because this.params !== null
172
+ !this.config.checkOpened || this.config.checkOpened(this.parsedPathData)
173
+ );
174
174
  }
175
175
  /**
176
176
  * Allows to create child route based on this route with merging this route path and extending path.
177
177
  *
178
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend-path-config-route)
178
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend)
179
179
  */
180
- extend(path, config) {
180
+ extend(pathDeclaration, config) {
181
181
  const { index, params, exact, ...configFromCurrentRoute } = this.config;
182
- const extendedChild = new Route(`${this.path}${path}`, {
182
+ const extendedChild = new Route(`${this.pathDeclaration}${pathDeclaration}`, {
183
183
  ...configFromCurrentRoute,
184
184
  ...config,
185
185
  parent: this
@@ -194,7 +194,7 @@ class Route {
194
194
  this.children = this.children.filter((child) => !routes.includes(child));
195
195
  }
196
196
  /**
197
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#hasopenedchildren-boolean)
197
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#hasopenedchildren)
198
198
  */
199
199
  get hasOpenedChildren() {
200
200
  return this.children.some(
@@ -239,7 +239,7 @@ class Route {
239
239
  /**
240
240
  * Navigates to this route.
241
241
  *
242
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open-args)
242
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open)
243
243
  */
244
244
  async open(...args) {
245
245
  const {
@@ -266,47 +266,55 @@ class Route {
266
266
  state,
267
267
  query
268
268
  };
269
- const isConfirmed = await this.confirmOpening(trx);
270
- if (!isConfirmed) {
271
- return;
272
- }
273
- this.skipPathMatchCheck = true;
274
- if (trx.replace) {
275
- this.history.replace(trx.url, trx.state);
276
- } else {
277
- this.history.push(trx.url, trx.state);
269
+ if (await this.confirmOpening(trx)) {
270
+ this.ignoreOpenByPathMatch = true;
278
271
  }
279
272
  }
280
273
  get tokenData() {
281
274
  if (!this._tokenData) {
282
- this._tokenData = pathToRegexp.parse(this.path, this.config.parseOptions);
275
+ this._tokenData = pathToRegexp.parse(this.pathDeclaration, this.config.parseOptions);
283
276
  }
284
277
  return this._tokenData;
285
278
  }
286
279
  async confirmOpening(trx) {
287
- this.status = "opening";
280
+ mobx.runInAction(() => {
281
+ this.status = "opening";
282
+ });
283
+ let skipHistoryUpdate = !!trx.preferSkipHistoryUpdate;
288
284
  if (this.config.beforeOpen) {
289
285
  const feedback = await this.config.beforeOpen(trx);
290
286
  if (feedback === false) {
291
287
  mobx.runInAction(() => {
292
288
  this.status = "open-rejected";
293
289
  });
294
- return false;
295
290
  }
296
291
  if (typeof feedback === "object") {
297
- mobx.runInAction(() => {
298
- this.status = "open-confirmed";
299
- });
300
- return Object.assign(trx, feedback);
292
+ skipHistoryUpdate = false;
293
+ Object.assign(trx, feedback);
301
294
  }
302
295
  }
303
- mobx.runInAction(() => {
304
- this.status = "open-confirmed";
305
- });
296
+ if (this.abortController.signal.aborted) {
297
+ return;
298
+ }
299
+ if (!skipHistoryUpdate) {
300
+ if (trx.replace) {
301
+ this.history.replace(trx.url, trx.state);
302
+ } else {
303
+ this.history.push(trx.url, trx.state);
304
+ }
305
+ }
306
+ if (this.isPathMatched) {
307
+ mobx.runInAction(() => {
308
+ this.status = "open-confirmed";
309
+ });
310
+ this.config.afterOpen?.(this.parsedPathData, this);
311
+ }
306
312
  return true;
307
313
  }
308
314
  confirmClosing() {
309
- this.status = "closed";
315
+ mobx.runInAction(() => {
316
+ this.status = "closed";
317
+ });
310
318
  return true;
311
319
  }
312
320
  firstPathMatchingRun = true;
@@ -317,33 +325,19 @@ class Route {
317
325
  return;
318
326
  }
319
327
  }
320
- if (this.skipPathMatchCheck) {
321
- this.skipPathMatchCheck = false;
322
- return;
323
- }
324
328
  if (isPathMathched) {
329
+ if (this.ignoreOpenByPathMatch) {
330
+ this.ignoreOpenByPathMatch = false;
331
+ return;
332
+ }
325
333
  const trx = {
326
334
  url: this.parsedPathData.path,
327
335
  params: this.parsedPathData.params,
328
336
  state: this.history.location.state,
329
- query: this.query.data
337
+ query: this.query.data,
338
+ preferSkipHistoryUpdate: true
330
339
  };
331
- const nextTrxOrConfirmed = await this.confirmOpening(trx);
332
- if (!nextTrxOrConfirmed) {
333
- return;
334
- }
335
- this.config.afterOpen?.(this.parsedPathData, this);
336
- if (typeof nextTrxOrConfirmed === "object") {
337
- if (nextTrxOrConfirmed.replace) {
338
- this.history.replace(
339
- nextTrxOrConfirmed.url,
340
- nextTrxOrConfirmed.state
341
- );
342
- } else {
343
- this.history.push(nextTrxOrConfirmed.url, nextTrxOrConfirmed.state);
344
- }
345
- }
346
- return;
340
+ await this.confirmOpening(trx);
347
341
  } else {
348
342
  const isConfirmed = this.confirmClosing();
349
343
  if (isConfirmed) {
@@ -359,20 +353,21 @@ class Route {
359
353
  }
360
354
  }
361
355
  const createRoute = (path, config) => new Route(path, config);
356
+ const annotations$2 = [
357
+ [mobx.computed, "isOpened", "indexRoute"],
358
+ [mobx.observable.shallow, "routes"]
359
+ ];
362
360
  class RouteGroup {
363
361
  constructor(routes, _indexRoute) {
364
362
  this._indexRoute = _indexRoute;
365
363
  this.routes = routes;
366
- mobx.computed.struct(this, "isOpened");
367
- mobx.computed.struct(this, "indexRoute");
368
- mobx.observable.shallow(this, "routes");
369
- mobx.makeObservable(this);
364
+ mobx$1.applyObservable(this, annotations$2);
370
365
  }
371
366
  routes;
372
367
  /**
373
368
  * Returns true if at least one route in the group is open.
374
369
  *
375
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#isopened-boolean)
370
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#isopened)
376
371
  */
377
372
  get isOpened() {
378
373
  const routes = Object.values(this.routes);
@@ -383,7 +378,7 @@ class RouteGroup {
383
378
  /**
384
379
  * First found index route.
385
380
  *
386
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#indexroute-route-undefined)
381
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#indexroute)
387
382
  */
388
383
  get indexRoute() {
389
384
  return this._indexRoute ?? Object.values(this.routes).find(
@@ -393,7 +388,7 @@ class RouteGroup {
393
388
  /**
394
389
  * Main navigation method for the group.
395
390
  *
396
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#open-args-any-void)
391
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#open)
397
392
  */
398
393
  open(...args) {
399
394
  let lastGroupRoute;
@@ -417,6 +412,9 @@ class RouteGroup {
417
412
  }
418
413
  }
419
414
  const createRouteGroup = (routes, indexRoute) => new RouteGroup(routes, indexRoute);
415
+ const annotations$1 = [
416
+ [mobx.computed.struct, "location"]
417
+ ];
420
418
  class Router {
421
419
  routes;
422
420
  history;
@@ -425,8 +423,7 @@ class Router {
425
423
  this.routes = config.routes;
426
424
  this.history = config.history ?? routeConfig.get().history;
427
425
  this.query = config.queryParams ?? routeConfig.get().queryParams;
428
- mobx.computed.struct(this, "location");
429
- mobx.makeObservable(this);
426
+ mobx$1.applyObservable(this, annotations$1);
430
427
  }
431
428
  get location() {
432
429
  return this.history.location;
@@ -444,6 +441,12 @@ class Router {
444
441
  }
445
442
  const createRouter = (config) => new Router(config);
446
443
  const isRouteEntity = (route) => route && "isOpened" in route;
444
+ const annotations = [
445
+ [mobx.observable, "params"],
446
+ [mobx.observable.ref, "status", "trx", "openChecker", "isOuterOpened"],
447
+ [mobx.computed, "isOpened", "isOpening", "isClosing"],
448
+ [mobx.action, "setOpenChecker", "open", "close"]
449
+ ];
447
450
  class VirtualRoute {
448
451
  constructor(config = {}) {
449
452
  this.config = config;
@@ -451,110 +454,156 @@ class VirtualRoute {
451
454
  this.query = config.queryParams ?? routeConfig.get().queryParams;
452
455
  this.params = common.callFunction(config.initialParams, this) ?? null;
453
456
  this.openChecker = config.checkOpened;
454
- this.isLocalOpened = this.openChecker?.(this) ?? false;
455
- mobx.observable(this, "params");
456
- mobx.observable.ref(this, "isLocalOpened");
457
- mobx.observable.ref(this, "_isOpened");
458
- mobx.computed.struct(this, "isOpened");
459
- mobx.action(this, "setOpenChecker");
460
- mobx.action(this, "open");
461
- mobx.action(this, "close");
462
- mobx.makeObservable(this);
463
- mobx.onBecomeObserved(this, "isOpened", () => {
464
- if (!config.afterOpen && !config.afterClose) {
465
- return;
466
- }
467
- this.reactionDisposer = mobx.reaction(
468
- () => this.isOpened,
469
- this.processOpenedState,
470
- {
471
- signal: this.abortController.signal,
472
- fireImmediately: true
457
+ this.skipAutoOpenClose = false;
458
+ this.isOuterOpened = this.openChecker?.(this);
459
+ this.status = this.isOuterOpened ? "opened" : "unknown";
460
+ mobx$1.applyObservable(this, annotations);
461
+ this.abortController.signal.addEventListener(
462
+ "abort",
463
+ mobx.action(() => {
464
+ this.status = "unknown";
465
+ })
466
+ );
467
+ mobx.reaction(
468
+ () => this.openChecker?.(this),
469
+ mobx.action((isOuterOpened) => {
470
+ this.isOuterOpened = isOuterOpened;
471
+ if (this.skipAutoOpenClose || this.status === "closing" || this.status === "opening") {
472
+ return;
473
473
  }
474
- );
475
- });
476
- mobx.onBecomeUnobserved(this, "isOpened", () => {
477
- this.reactionDisposer?.();
478
- this.reactionDisposer = void 0;
479
- });
474
+ if (this.isOuterOpened) {
475
+ if (this.status === "opened") {
476
+ return;
477
+ }
478
+ this.confirmOpening({
479
+ params: this.params ?? null,
480
+ ...this.config.getAutomatedOpenParams?.(this)
481
+ });
482
+ } else {
483
+ if (this.status === "closed" || this.status === "unknown") {
484
+ return;
485
+ }
486
+ this.confirmClosing();
487
+ }
488
+ }),
489
+ { signal: this.abortController.signal, fireImmediately: true }
490
+ );
491
+ if (this.status === "opened") {
492
+ this.config.afterOpen?.(this.params, this);
493
+ }
480
494
  }
481
- abortController;
482
495
  query;
483
496
  params;
484
- isLocalOpened;
497
+ abortController;
498
+ status;
485
499
  openChecker;
486
- reactionDisposer;
500
+ trx;
501
+ skipAutoOpenClose;
502
+ /**
503
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isouteropened)
504
+ */
505
+ isOuterOpened;
487
506
  /**
488
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened-boolean)
507
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened)
489
508
  */
490
509
  get isOpened() {
491
- const isOuterOpened = this.openChecker == null || this.openChecker(this);
492
- return this.isLocalOpened && isOuterOpened;
510
+ return this.status === "opened" && this.isOuterOpened !== false;
511
+ }
512
+ /**
513
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopening)
514
+ */
515
+ get isOpening() {
516
+ return this.status === "opening";
517
+ }
518
+ /**
519
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isclosing)
520
+ */
521
+ get isClosing() {
522
+ return this.status === "closing";
493
523
  }
494
524
  /**
495
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker-openchecker-void)
525
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker)
496
526
  */
497
527
  setOpenChecker(openChecker) {
498
528
  this.openChecker = openChecker;
499
529
  }
500
530
  async open(...args) {
501
- const params = args[0] ?? {};
502
- const extraParams = args[1];
503
- if (this.config.beforeOpen) {
504
- const beforeOpenResult = await this.config.beforeOpen(params, this);
505
- if (beforeOpenResult === false) {
506
- return;
507
- }
508
- }
509
- if (this.config.open == null) {
531
+ const params = args[0] ?? null;
532
+ const extra = args[1];
533
+ this.skipAutoOpenClose = true;
534
+ this.trx = {
535
+ params,
536
+ extra,
537
+ manual: true
538
+ };
539
+ await this.confirmOpening(this.trx);
540
+ this.skipAutoOpenClose = false;
541
+ }
542
+ /**
543
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close)
544
+ */
545
+ async close() {
546
+ this.skipAutoOpenClose = true;
547
+ const result = await this.confirmClosing();
548
+ this.skipAutoOpenClose = false;
549
+ return result;
550
+ }
551
+ async confirmOpening(trx) {
552
+ mobx.runInAction(() => {
553
+ this.trx = void 0;
554
+ this.status = "opening";
555
+ });
556
+ if (await this.config.beforeOpen?.(trx.params, this) === false) {
510
557
  mobx.runInAction(() => {
511
- this.isLocalOpened = true;
558
+ this.status = "open-rejected";
559
+ this.trx = void 0;
512
560
  });
513
- } else {
514
- const result = await this.config.open(params, this);
561
+ return;
562
+ }
563
+ if (await this.config.open?.(trx.params, this) === false) {
515
564
  mobx.runInAction(() => {
516
- this.isLocalOpened = result !== false;
565
+ this.status = "open-rejected";
566
+ this.trx = void 0;
517
567
  });
518
- }
519
- if (!this.isLocalOpened) {
520
568
  return;
521
569
  }
522
- if (extraParams?.query) {
523
- this.query.update(extraParams.query, extraParams.replace);
524
- }
525
570
  mobx.runInAction(() => {
526
- this.params = params;
527
- });
528
- if (!this.reactionDisposer && this.isOpened) {
571
+ if (trx.extra?.query) {
572
+ this.query.update(trx.extra.query, trx.extra.replace);
573
+ }
574
+ this.trx = void 0;
575
+ this.params = trx.params;
576
+ this.status = "opened";
529
577
  this.config.afterOpen?.(this.params, this);
530
- }
578
+ });
579
+ return true;
531
580
  }
532
- /**
533
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close-void)
534
- */
535
- close() {
536
- if (this.config.close == null) {
537
- this.isLocalOpened = false;
538
- } else {
539
- const result = this.config.close(this);
540
- this.isLocalOpened = result !== false;
581
+ async confirmClosing() {
582
+ if (this.status === "closed") {
583
+ return true;
541
584
  }
542
- this.params = null;
543
- }
544
- firstOpenedStateCheck = true;
545
- processOpenedState = (isOpened) => {
546
- if (this.firstOpenedStateCheck) {
547
- this.firstOpenedStateCheck = false;
548
- if (!isOpened) {
549
- return;
550
- }
585
+ const lastStatus = this.status;
586
+ mobx.runInAction(() => {
587
+ this.status = "closing";
588
+ });
589
+ if (await this.config.beforeClose?.() === false) {
590
+ mobx.runInAction(() => {
591
+ this.status = lastStatus;
592
+ });
593
+ return;
551
594
  }
552
- if (isOpened) {
553
- this.config.afterOpen?.(this.params, this);
554
- } else {
555
- this.config.afterClose?.();
595
+ if (this.config.close?.(this) === false) {
596
+ mobx.runInAction(() => {
597
+ this.status = lastStatus;
598
+ });
599
+ return;
556
600
  }
557
- };
601
+ mobx.runInAction(() => {
602
+ this.status = "closed";
603
+ this.params = null;
604
+ });
605
+ return true;
606
+ }
558
607
  destroy() {
559
608
  this.abortController.abort();
560
609
  }