mobx-route 0.21.0 → 0.22.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/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,56 @@ 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;
290
+ return;
295
291
  }
296
292
  if (typeof feedback === "object") {
297
- mobx.runInAction(() => {
298
- this.status = "open-confirmed";
299
- });
300
- return Object.assign(trx, feedback);
293
+ skipHistoryUpdate = false;
294
+ Object.assign(trx, feedback);
301
295
  }
302
296
  }
303
- mobx.runInAction(() => {
304
- this.status = "open-confirmed";
305
- });
297
+ if (this.abortController.signal.aborted) {
298
+ return;
299
+ }
300
+ if (!skipHistoryUpdate) {
301
+ if (trx.replace) {
302
+ this.history.replace(trx.url, trx.state);
303
+ } else {
304
+ this.history.push(trx.url, trx.state);
305
+ }
306
+ }
307
+ if (this.isPathMatched) {
308
+ mobx.runInAction(() => {
309
+ this.status = "open-confirmed";
310
+ });
311
+ this.config.afterOpen?.(this.parsedPathData, this);
312
+ }
306
313
  return true;
307
314
  }
308
315
  confirmClosing() {
309
- this.status = "closed";
316
+ mobx.runInAction(() => {
317
+ this.status = "closed";
318
+ });
310
319
  return true;
311
320
  }
312
321
  firstPathMatchingRun = true;
@@ -317,33 +326,19 @@ class Route {
317
326
  return;
318
327
  }
319
328
  }
320
- if (this.skipPathMatchCheck) {
321
- this.skipPathMatchCheck = false;
322
- return;
323
- }
324
329
  if (isPathMathched) {
330
+ if (this.ignoreOpenByPathMatch) {
331
+ this.ignoreOpenByPathMatch = false;
332
+ return;
333
+ }
325
334
  const trx = {
326
335
  url: this.parsedPathData.path,
327
336
  params: this.parsedPathData.params,
328
337
  state: this.history.location.state,
329
- query: this.query.data
338
+ query: this.query.data,
339
+ preferSkipHistoryUpdate: true
330
340
  };
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;
341
+ await this.confirmOpening(trx);
347
342
  } else {
348
343
  const isConfirmed = this.confirmClosing();
349
344
  if (isConfirmed) {
@@ -359,20 +354,21 @@ class Route {
359
354
  }
360
355
  }
361
356
  const createRoute = (path, config) => new Route(path, config);
357
+ const annotations$2 = [
358
+ [mobx.computed, "isOpened", "indexRoute"],
359
+ [mobx.observable.shallow, "routes"]
360
+ ];
362
361
  class RouteGroup {
363
362
  constructor(routes, _indexRoute) {
364
363
  this._indexRoute = _indexRoute;
365
364
  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);
365
+ mobx$1.applyObservable(this, annotations$2);
370
366
  }
371
367
  routes;
372
368
  /**
373
369
  * Returns true if at least one route in the group is open.
374
370
  *
375
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#isopened-boolean)
371
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#isopened)
376
372
  */
377
373
  get isOpened() {
378
374
  const routes = Object.values(this.routes);
@@ -383,7 +379,7 @@ class RouteGroup {
383
379
  /**
384
380
  * First found index route.
385
381
  *
386
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#indexroute-route-undefined)
382
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#indexroute)
387
383
  */
388
384
  get indexRoute() {
389
385
  return this._indexRoute ?? Object.values(this.routes).find(
@@ -393,7 +389,7 @@ class RouteGroup {
393
389
  /**
394
390
  * Main navigation method for the group.
395
391
  *
396
- * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#open-args-any-void)
392
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#open)
397
393
  */
398
394
  open(...args) {
399
395
  let lastGroupRoute;
@@ -417,6 +413,9 @@ class RouteGroup {
417
413
  }
418
414
  }
419
415
  const createRouteGroup = (routes, indexRoute) => new RouteGroup(routes, indexRoute);
416
+ const annotations$1 = [
417
+ [mobx.computed.struct, "location"]
418
+ ];
420
419
  class Router {
421
420
  routes;
422
421
  history;
@@ -425,8 +424,7 @@ class Router {
425
424
  this.routes = config.routes;
426
425
  this.history = config.history ?? routeConfig.get().history;
427
426
  this.query = config.queryParams ?? routeConfig.get().queryParams;
428
- mobx.computed.struct(this, "location");
429
- mobx.makeObservable(this);
427
+ mobx$1.applyObservable(this, annotations$1);
430
428
  }
431
429
  get location() {
432
430
  return this.history.location;
@@ -444,6 +442,12 @@ class Router {
444
442
  }
445
443
  const createRouter = (config) => new Router(config);
446
444
  const isRouteEntity = (route) => route && "isOpened" in route;
445
+ const annotations = [
446
+ [mobx.observable, "params"],
447
+ [mobx.observable.ref, "status", "trx", "openChecker", "isOuterOpened"],
448
+ [mobx.computed, "isOpened", "isOpening", "isClosing"],
449
+ [mobx.action, "setOpenChecker", "open", "close"]
450
+ ];
447
451
  class VirtualRoute {
448
452
  constructor(config = {}) {
449
453
  this.config = config;
@@ -451,110 +455,156 @@ class VirtualRoute {
451
455
  this.query = config.queryParams ?? routeConfig.get().queryParams;
452
456
  this.params = common.callFunction(config.initialParams, this) ?? null;
453
457
  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
458
+ this.skipAutoOpenClose = false;
459
+ this.isOuterOpened = this.openChecker?.(this);
460
+ this.status = this.isOuterOpened ? "opened" : "unknown";
461
+ mobx$1.applyObservable(this, annotations);
462
+ this.abortController.signal.addEventListener(
463
+ "abort",
464
+ mobx.action(() => {
465
+ this.status = "unknown";
466
+ })
467
+ );
468
+ mobx.reaction(
469
+ () => this.openChecker?.(this),
470
+ mobx.action((isOuterOpened) => {
471
+ this.isOuterOpened = isOuterOpened;
472
+ if (this.skipAutoOpenClose || this.status === "closing" || this.status === "opening") {
473
+ return;
473
474
  }
474
- );
475
- });
476
- mobx.onBecomeUnobserved(this, "isOpened", () => {
477
- this.reactionDisposer?.();
478
- this.reactionDisposer = void 0;
479
- });
475
+ if (this.isOuterOpened) {
476
+ if (this.status === "opened") {
477
+ return;
478
+ }
479
+ this.confirmOpening({
480
+ params: this.params ?? null,
481
+ ...this.config.getAutomatedOpenParams?.(this)
482
+ });
483
+ } else {
484
+ if (this.status === "closed" || this.status === "unknown") {
485
+ return;
486
+ }
487
+ this.confirmClosing();
488
+ }
489
+ }),
490
+ { signal: this.abortController.signal, fireImmediately: true }
491
+ );
492
+ if (this.status === "opened") {
493
+ this.config.afterOpen?.(this.params, this);
494
+ }
480
495
  }
481
- abortController;
482
496
  query;
483
497
  params;
484
- isLocalOpened;
498
+ abortController;
499
+ status;
485
500
  openChecker;
486
- reactionDisposer;
501
+ trx;
502
+ skipAutoOpenClose;
503
+ /**
504
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isouteropened)
505
+ */
506
+ isOuterOpened;
487
507
  /**
488
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened-boolean)
508
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened)
489
509
  */
490
510
  get isOpened() {
491
- const isOuterOpened = this.openChecker == null || this.openChecker(this);
492
- return this.isLocalOpened && isOuterOpened;
511
+ return this.status === "opened" && this.isOuterOpened !== false;
512
+ }
513
+ /**
514
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopening)
515
+ */
516
+ get isOpening() {
517
+ return this.status === "opening";
518
+ }
519
+ /**
520
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isclosing)
521
+ */
522
+ get isClosing() {
523
+ return this.status === "closing";
493
524
  }
494
525
  /**
495
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker-openchecker-void)
526
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker)
496
527
  */
497
528
  setOpenChecker(openChecker) {
498
529
  this.openChecker = openChecker;
499
530
  }
500
531
  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) {
532
+ const params = args[0] ?? null;
533
+ const extra = args[1];
534
+ this.skipAutoOpenClose = true;
535
+ this.trx = {
536
+ params,
537
+ extra,
538
+ manual: true
539
+ };
540
+ await this.confirmOpening(this.trx);
541
+ this.skipAutoOpenClose = false;
542
+ }
543
+ /**
544
+ * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close)
545
+ */
546
+ async close() {
547
+ this.skipAutoOpenClose = true;
548
+ const result = await this.confirmClosing();
549
+ this.skipAutoOpenClose = false;
550
+ return result;
551
+ }
552
+ async confirmOpening(trx) {
553
+ mobx.runInAction(() => {
554
+ this.trx = void 0;
555
+ this.status = "opening";
556
+ });
557
+ if (await this.config.beforeOpen?.(trx.params, this) === false) {
510
558
  mobx.runInAction(() => {
511
- this.isLocalOpened = true;
559
+ this.status = "open-rejected";
560
+ this.trx = void 0;
512
561
  });
513
- } else {
514
- const result = await this.config.open(params, this);
562
+ return;
563
+ }
564
+ if (await this.config.open?.(trx.params, this) === false) {
515
565
  mobx.runInAction(() => {
516
- this.isLocalOpened = result !== false;
566
+ this.status = "open-rejected";
567
+ this.trx = void 0;
517
568
  });
518
- }
519
- if (!this.isLocalOpened) {
520
569
  return;
521
570
  }
522
- if (extraParams?.query) {
523
- this.query.update(extraParams.query, extraParams.replace);
524
- }
525
571
  mobx.runInAction(() => {
526
- this.params = params;
527
- });
528
- if (!this.reactionDisposer && this.isOpened) {
572
+ if (trx.extra?.query) {
573
+ this.query.update(trx.extra.query, trx.extra.replace);
574
+ }
575
+ this.trx = void 0;
576
+ this.params = trx.params;
577
+ this.status = "opened";
529
578
  this.config.afterOpen?.(this.params, this);
530
- }
579
+ });
580
+ return true;
531
581
  }
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;
582
+ async confirmClosing() {
583
+ if (this.status === "closed") {
584
+ return true;
541
585
  }
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
- }
586
+ const lastStatus = this.status;
587
+ mobx.runInAction(() => {
588
+ this.status = "closing";
589
+ });
590
+ if (await this.config.beforeClose?.() === false) {
591
+ mobx.runInAction(() => {
592
+ this.status = lastStatus;
593
+ });
594
+ return;
551
595
  }
552
- if (isOpened) {
553
- this.config.afterOpen?.(this.params, this);
554
- } else {
555
- this.config.afterClose?.();
596
+ if (this.config.close?.(this) === false) {
597
+ mobx.runInAction(() => {
598
+ this.status = lastStatus;
599
+ });
600
+ return;
556
601
  }
557
- };
602
+ mobx.runInAction(() => {
603
+ this.status = "closed";
604
+ this.params = null;
605
+ });
606
+ return true;
607
+ }
558
608
  destroy() {
559
609
  this.abortController.abort();
560
610
  }