brew-js-react 0.6.3 → 0.6.4

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/dialog.d.ts CHANGED
@@ -1,4 +1,18 @@
1
- export type DialogCloseCallback<T> = (value?: T) => Promise<void>;
1
+ import { ErrorHandler } from "zeta-dom-react";
2
+
3
+ type PartialRequired<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: T[P] }
4
+ type VoidOrOptional<T> = [Exclude<T, undefined | void>] extends [never] ? void : Exclude<T, undefined | void>;
5
+
6
+ export type DialogCloseCallback<T> = Zeta.IsAnyOrUnknown<T> extends true ?
7
+ (value?: any) => Promise<void> :
8
+ (value: T extends undefined ? void | undefined : T) => Promise<void>;
9
+ export type DialogResult<T> = T extends void ? undefined : Zeta.IsAnyOrUnknown<T> extends true ? any : T | undefined;
10
+ export type DialogOptionsStrict<T, V> = PartialRequired<DialogOptions<T, V>, 'onCommit'>;
11
+
12
+ /** @deprecated */
13
+ export type DialogBaseProps<T, V = T> = Omit<DialogOptions<T, V | undefined>, 'onRender' | 'wrapper'>;
14
+ /** @deprecated */
15
+ export type DialogRenderComponentProps<T, V = T> = DialogOptions<T, V | undefined> & DialogContext<V | undefined>;
2
16
 
3
17
  export interface DialogState<T> {
4
18
  /**
@@ -8,19 +22,19 @@ export interface DialogState<T> {
8
22
  /**
9
23
  * Opens the dialog.
10
24
  *
11
- * It will receive result from {@link DialogState.close} or {@link DialogRenderComponentProps.closeDialog} when the dialog is properly closed.
25
+ * It will receive result from {@link DialogState.close} or {@link DialogContext.closeDialog} when the dialog is properly closed.
12
26
  * Otherwise in cases such as being closed due to lost of focus, result value will always be `undefined`.
13
27
  */
14
- open: () => Promise<T | undefined>;
28
+ open(): Promise<DialogResult<T>>;
15
29
  /**
16
30
  * Closes the dialog, with optional result value.
17
31
  *
18
- * This method is different from {@link DialogRenderComponentProps.closeDialog} that {@link DialogBaseProps.onCommit} will not be called.
32
+ * This method is similar to {@link DialogContext.dismissDialog} that {@link DialogOptions.onCommit} will not be called.
19
33
  */
20
- close: (value?: T) => Promise<void>;
34
+ close(value?: T): Promise<void>;
21
35
  }
22
36
 
23
- export interface DialogBaseProps<T, V = T> {
37
+ export interface DialogOptions<T, V = T | undefined> {
24
38
  /**
25
39
  * Specifies dialog title.
26
40
  * This property is intended to be handled by {@link DialogOptions.onRender} or {@link DialogOptions.wrapper}.
@@ -58,13 +72,13 @@ export interface DialogBaseProps<T, V = T> {
58
72
  /**
59
73
  * Callback to perform asynchronous action when user confirms the dialog.
60
74
  *
61
- * The callback will receive value sent from {@link DialogRenderComponentProps.closeDialog},
75
+ * The callback will receive value sent from {@link DialogContext.commitDialog} or {@link DialogContext.closeDialog},
62
76
  * and will send resolved value to promise returned by {@link DialogState.open}.
63
77
  *
64
78
  * The dialog will be held open until the returned promise resolves.
65
79
  * When the promise rejects, the dialog will remain open.
66
80
  */
67
- onCommit?: (value: V | undefined, context: Zeta.RunAsyncContext) => T | Promise<T> | void;
81
+ onCommit?: (value: V, context: Zeta.RunAsyncContext) => T | Promise<T> | undefined | void;
68
82
  /**
69
83
  * Callback to be invoked when dialog has opened.
70
84
  */
@@ -73,28 +87,42 @@ export interface DialogBaseProps<T, V = T> {
73
87
  * Callback to be invoked when dialog has closed, after outro animation and before React DOM is unmounted.
74
88
  */
75
89
  onClose?: (root: HTMLElement) => void;
90
+ /**
91
+ * A callback that render dialog contents.
92
+ */
93
+ onRender: React.VFC<DialogContext<V> & this>;
94
+ /**
95
+ * Specifies wrapper component that envelops content from {@link DialogOptions.onRender},
96
+ * which is useful for reusable layout for dialogs.
97
+ */
98
+ wrapper?: React.FC<DialogContext<V> & this & React.PropsWithChildren<{}>>;
76
99
  }
77
100
 
78
- export interface DialogRenderComponentProps<T, V = T> extends DialogBaseProps<T, V> {
101
+ export interface DialogContext<V> {
102
+ /**
103
+ * Gets an {@link ErrorHandler} object that catches errors emitted from rendered content.
104
+ */
105
+ errorHandler: ErrorHandler;
79
106
  /**
80
- * Commits the dialog, with optional result value.
107
+ * Commits the dialog with result value.
81
108
  *
82
- * When {@link DialogBaseProps.onCommit} is specified, it is invoked with the value passed in.
109
+ * When {@link DialogOptions.onCommit} is specified, it is invoked with the value passed in.
83
110
  * Dialog will be closed when async operation is completed, or remain open if the operation failed.
111
+ *
112
+ * @deprecated Alias of {@link DialogContext.commitDialog}.
84
113
  */
85
- closeDialog: (value?: V) => Promise<void>;
86
- }
87
-
88
- export interface DialogOptions<T, V = T> extends DialogBaseProps<T, V> {
114
+ closeDialog: DialogCloseCallback<V>;
89
115
  /**
90
- * A callback that render dialog contents.
116
+ * Commits the dialog with result value.
117
+ *
118
+ * When {@link DialogOptions.onCommit} is specified, it is invoked with the value passed in.
119
+ * Dialog will be closed when async operation is completed, or remain open if the operation failed.
91
120
  */
92
- onRender: React.FC<DialogRenderComponentProps<T, V> & this>;
121
+ commitDialog: DialogCloseCallback<V>;
93
122
  /**
94
- * Specifies wrapper component that envelops content from {@link DialogOptions.onRender},
95
- * which is useful for reusable layout for dialogs.
123
+ * Closes the dialog without invoking {@link DialogOptions.onCommit}.
96
124
  */
97
- wrapper?: React.FC<React.PropsWithChildren<DialogRenderComponentProps<T, V> & this>>;
125
+ dismissDialog: DialogCloseCallback<void>;
98
126
  }
99
127
 
100
128
  export interface DialogProps<T, V = T> extends React.PropsWithChildren<DialogBaseProps<T, V>> {
@@ -108,7 +136,15 @@ export interface DialogProps<T, V = T> extends React.PropsWithChildren<DialogBas
108
136
  * Creates a controller to render dialog.
109
137
  * @param props A dictionary containing options.
110
138
  */
111
- export function createDialog<T = any, V = T>(props: DialogOptions<T, V>): DialogState<T>;
139
+ export function createDialog<T, V>(props: DialogOptionsStrict<T, V>): DialogState<VoidOrOptional<T>>;
140
+
141
+ export function createDialog<T, V>(props: DialogOptions<T, V>): DialogState<VoidOrOptional<T | V>>;
142
+
143
+ export function createDialog<T, V = T>(props: DialogOptions<T, V | undefined>): DialogState<VoidOrOptional<T | V>>;
144
+
145
+ export function createDialog<P extends DialogOptionsStrict<any, any>>(props: P): DialogState<VoidOrOptional<P extends DialogOptionsStrict<infer T, any> ? T : unknown>>;
146
+
147
+ export function createDialog<P extends DialogOptions<any, any>>(props: P): DialogState<VoidOrOptional<P extends DialogOptions<infer T, infer V> ? T | V : unknown>>;
112
148
 
113
149
  /**
114
150
  * Renders a dialog declaratively.
package/dialog.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createElement, StrictMode, useEffect, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import ReactDOMClient from "@misonou/react-dom-client";
4
+ import { createAsyncScope } from "zeta-dom-react";
4
5
  import { either, extend, noop, pick, resolve } from "zeta-dom/util";
5
6
  import { containsOrEquals, removeNode } from "zeta-dom/domUtil";
6
7
  import dom from "zeta-dom/dom";
@@ -13,6 +14,7 @@ import { closeFlyout, openFlyout } from "brew-js/domAction";
13
14
  export function createDialog(props) {
14
15
  var root = document.createElement('div');
15
16
  var reactRoot = ReactDOMClient.createRoot(root);
17
+ var scope = createAsyncScope(root);
16
18
  var closeDialog = closeFlyout.bind(0, root);
17
19
  var promise;
18
20
 
@@ -45,16 +47,20 @@ export function createDialog(props) {
45
47
  root.setAttribute('is-modal', '');
46
48
  }
47
49
  if (props.onRender) {
50
+ var commitDialog = props.onCommit ? function (value) {
51
+ return runAsync(dom.activeElement, props.onCommit.bind(this, value)).then(closeDialog);
52
+ } : closeDialog;
48
53
  var dialogProps = extend({}, props, {
49
- closeDialog: props.onCommit ? function (value) {
50
- return runAsync(dom.activeElement, props.onCommit.bind(this, value)).then(closeDialog);
51
- } : closeDialog
54
+ errorHandler: scope.errorHandler,
55
+ closeDialog: commitDialog,
56
+ commitDialog: commitDialog,
57
+ dismissDialog: closeDialog
52
58
  });
53
59
  var content = createElement(props.onRender, dialogProps);
54
60
  if (props.wrapper) {
55
61
  content = createElement(props.wrapper, dialogProps, content);
56
62
  }
57
- reactRoot.render(createElement(StrictMode, null, content));
63
+ reactRoot.render(createElement(StrictMode, null, createElement(scope.Provider, null, content)));
58
64
  }
59
65
  promise = resolve().then(function () {
60
66
  dom.retainFocus(dom.activeElement, root);
@@ -1,4 +1,4 @@
1
- /*! brew-js-react v0.6.3 | (c) misonou | https://misonou.github.io */
1
+ /*! brew-js-react v0.6.4 | (c) misonou | https://misonou.github.io */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("zeta-dom"), require("brew-js"), require("react"), require("react-dom"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
@@ -315,6 +315,20 @@ var Component = external_commonjs_react_commonjs2_react_amd_react_root_React_.Co
315
315
  var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(33);
316
316
  // EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/fallback.js
317
317
  var fallback = __webpack_require__(621);
318
+ // EXTERNAL MODULE: external {"commonjs":"zeta-dom-react","commonjs2":"zeta-dom-react","amd":"zeta-dom-react","root":["zeta","react"]}
319
+ var external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_ = __webpack_require__(402);
320
+ ;// CONCATENATED MODULE: ./|umd|/zeta-dom-react.js
321
+
322
+ var ViewStateProvider = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.ViewStateProvider,
323
+ classNames = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.classNames,
324
+ createAsyncScope = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.createAsyncScope,
325
+ useAsync = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useAsync,
326
+ useEagerState = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useEagerState,
327
+ useMemoizedFunction = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useMemoizedFunction,
328
+ useObservableProperty = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty,
329
+ useSingleton = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useSingleton,
330
+ useValueTrigger = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useValueTrigger;
331
+
318
332
  ;// CONCATENATED MODULE: ./|umd|/zeta-dom/domUtil.js
319
333
 
320
334
  var domUtil_lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.util,
@@ -355,12 +369,14 @@ var closeFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_b
355
369
 
356
370
 
357
371
 
372
+
358
373
  /**
359
374
  * @param {Partial<import("./dialog").DialogOptions<any>>} props
360
375
  */
361
376
  function createDialog(props) {
362
377
  var root = document.createElement('div');
363
378
  var reactRoot = fallback.createRoot(root);
379
+ var scope = createAsyncScope(root);
364
380
  var closeDialog = closeFlyout.bind(0, root);
365
381
  var promise;
366
382
  zeta_dom_dom.on(root, {
@@ -391,16 +407,20 @@ function createDialog(props) {
391
407
  root.setAttribute('is-modal', '');
392
408
  }
393
409
  if (props.onRender) {
410
+ var commitDialog = props.onCommit ? function (value) {
411
+ return runAsync(zeta_dom_dom.activeElement, props.onCommit.bind(this, value)).then(closeDialog);
412
+ } : closeDialog;
394
413
  var dialogProps = extend({}, props, {
395
- closeDialog: props.onCommit ? function (value) {
396
- return runAsync(zeta_dom_dom.activeElement, props.onCommit.bind(this, value)).then(closeDialog);
397
- } : closeDialog
414
+ errorHandler: scope.errorHandler,
415
+ closeDialog: commitDialog,
416
+ commitDialog: commitDialog,
417
+ dismissDialog: closeDialog
398
418
  });
399
419
  var content = /*#__PURE__*/createElement(props.onRender, dialogProps);
400
420
  if (props.wrapper) {
401
421
  content = /*#__PURE__*/createElement(props.wrapper, dialogProps, content);
402
422
  }
403
- reactRoot.render( /*#__PURE__*/createElement(StrictMode, null, content));
423
+ reactRoot.render( /*#__PURE__*/createElement(StrictMode, null, /*#__PURE__*/createElement(scope.Provider, null, content)));
404
424
  }
405
425
  promise = resolve().then(function () {
406
426
  zeta_dom_dom.retainFocus(zeta_dom_dom.activeElement, root);
@@ -440,19 +460,6 @@ function Dialog(props) {
440
460
  }, [dialog]);
441
461
  return /*#__PURE__*/external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
442
462
  }
443
- // EXTERNAL MODULE: external {"commonjs":"zeta-dom-react","commonjs2":"zeta-dom-react","amd":"zeta-dom-react","root":["zeta","react"]}
444
- var external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_ = __webpack_require__(402);
445
- ;// CONCATENATED MODULE: ./|umd|/zeta-dom-react.js
446
-
447
- var ViewStateProvider = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.ViewStateProvider,
448
- classNames = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.classNames,
449
- useAsync = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useAsync,
450
- useEagerState = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useEagerState,
451
- useMemoizedFunction = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useMemoizedFunction,
452
- useObservableProperty = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty,
453
- useSingleton = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useSingleton,
454
- useValueTrigger = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useValueTrigger;
455
-
456
463
  ;// CONCATENATED MODULE: ./|umd|/zeta-dom/events.js
457
464
 
458
465
  var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
@@ -460,7 +467,8 @@ var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_
460
467
  ;// CONCATENATED MODULE: ./|umd|/brew-js/util/common.js
461
468
 
462
469
  var getQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.getQueryParam,
463
- setQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.setQueryParam;
470
+ setQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.setQueryParam,
471
+ toQueryString = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.toQueryString;
464
472
 
465
473
  ;// CONCATENATED MODULE: ./|umd|/brew-js/util/path.js
466
474
 
@@ -482,6 +490,7 @@ var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_bre
482
490
 
483
491
 
484
492
 
493
+
485
494
  var _ = createPrivateStore();
486
495
  var root = zeta_dom_dom.root;
487
496
  var routeMap = new Map();
@@ -548,6 +557,13 @@ function ErrorBoundary() {
548
557
  }
549
558
  ErrorBoundary.contextType = StateContext;
550
559
  definePrototype(ErrorBoundary, Component, {
560
+ componentDidMount: function componentDidMount() {
561
+ var self = this;
562
+ self.componentWillUnmount = watch(self.context, 'page', function () {
563
+ self.state.error = null;
564
+ self.forceUpdate();
565
+ });
566
+ },
551
567
  componentDidCatch: function componentDidCatch(error) {
552
568
  var self = this;
553
569
  if (errorView && !self.state.error) {
@@ -556,37 +572,36 @@ definePrototype(ErrorBoundary, Component, {
556
572
  });
557
573
  } else {
558
574
  // ensure promise sent to beforepageload event is resolved
559
- self.props.onComponentLoaded();
575
+ self.props.onLoad();
560
576
  reportError(error, self.context.container);
561
577
  }
562
578
  },
563
579
  render: function render() {
564
580
  var self = this;
565
- if (!self.context.container) {
581
+ var context = self.context;
582
+ if (!context.container) {
566
583
  setImmediate(function () {
567
584
  self.forceUpdate();
568
585
  });
569
586
  return null;
570
587
  }
571
- var props = {
572
- view: self.context.view,
573
- error: self.state.error,
574
- reset: self.reset.bind(self)
588
+ var error = self.state.error;
589
+ var scope = self.scope || (self.scope = createAsyncScope(context.container));
590
+ var childProps = {
591
+ onLoad: self.props.onLoad,
592
+ onError: self.componentDidCatch.bind(self),
593
+ viewProps: error ? {
594
+ view: context.view,
595
+ error: error,
596
+ reset: self.reset.bind(self)
597
+ } : {
598
+ errorHandler: scope.errorHandler,
599
+ navigationType: view_event.navigationType,
600
+ viewContext: context,
601
+ viewData: context.page.data || {}
602
+ }
575
603
  };
576
- var onComponentLoaded = self.props.onComponentLoaded;
577
- var onError = self.componentDidCatch.bind(self);
578
- if (props.error) {
579
- return /*#__PURE__*/createElement(errorView, {
580
- onComponentLoaded: onComponentLoaded,
581
- onError: onError,
582
- viewProps: props
583
- });
584
- }
585
- return /*#__PURE__*/createElement(props.view, {
586
- onComponentLoaded: onComponentLoaded,
587
- onError: onError,
588
- viewProps: self.props.viewProps
589
- });
604
+ return /*#__PURE__*/createElement(scope.Provider, null, /*#__PURE__*/createElement(error ? errorView : context.view, childProps));
590
605
  },
591
606
  reset: function reset() {
592
607
  this.setState({
@@ -645,11 +660,11 @@ definePrototype(ViewContainer, Component, {
645
660
  (self.unmountView || noop)(true);
646
661
  var context = new ViewContext(V, app_app.page, self.context);
647
662
  var state = routeMap.get(V);
648
- var onComponentLoaded;
663
+ var onLoad;
649
664
  var promise = new Promise(function (resolve) {
650
- onComponentLoaded = resolve;
665
+ onLoad = resolve;
651
666
  });
652
- var unmountView = onComponentLoaded;
667
+ var unmountView = onLoad;
653
668
  var initElement = executeOnce(function (element) {
654
669
  context.container = element;
655
670
  promise.then(function () {
@@ -673,13 +688,6 @@ definePrototype(ViewContainer, Component, {
673
688
  }
674
689
  });
675
690
  });
676
- var viewProps = function viewProps() {
677
- return freeze({
678
- navigationType: view_event.navigationType,
679
- viewContext: context,
680
- viewData: context.page.data || {}
681
- });
682
- };
683
691
  var view = /*#__PURE__*/createElement(StateContext.Provider, {
684
692
  key: state.id,
685
693
  value: context
@@ -687,8 +695,7 @@ definePrototype(ViewContainer, Component, {
687
695
  ref: initElement,
688
696
  'brew-view': ''
689
697
  }), /*#__PURE__*/createElement(ErrorBoundary, {
690
- onComponentLoaded: onComponentLoaded,
691
- viewProps: viewProps
698
+ onLoad: onLoad
692
699
  }))));
693
700
  extend(self, _(context), {
694
701
  currentContext: context,
@@ -710,6 +717,9 @@ definePrototype(ViewContainer, Component, {
710
717
  return any(props.views, isViewMatched) || props.defaultView;
711
718
  }
712
719
  });
720
+ function normalizePart(value, part) {
721
+ return isUndefinedOrNull(value) || value === '' || value === part ? '' : value[0] === part ? value : part + value;
722
+ }
713
723
  function getCurrentParams(view, params) {
714
724
  var state = routeMap.get(view);
715
725
  if (!state.maxParams) {
@@ -760,31 +770,23 @@ function createViewComponent(factory) {
760
770
  factory = createElement.bind(null, factory);
761
771
  }
762
772
  return function fn(props) {
763
- var viewContext = useContext(StateContext);
764
- var viewProps = useState(props.viewProps);
765
- var children = !promise && factory(viewProps[0]);
773
+ var children = promise || factory(props.viewProps);
766
774
  if (isThenable(children)) {
767
775
  promise = children;
768
- children = null;
769
776
  catchAsync(promise);
777
+ } else {
778
+ useEffect(props.onLoad, []);
779
+ return children;
770
780
  }
771
- var state = useAsync(function () {
781
+ var component = useAsync(function () {
772
782
  return promise.then(null, props.onError);
773
- }, !!promise)[1];
774
- var loaded = !promise || !state.loading;
775
- useEffect(function () {
776
- state.elementRef(viewContext.container);
777
- // listen to property directly so that it is invoked after pagechange event handlers in actual component
778
- return watch(viewContext, 'page', function () {
779
- viewProps[1](props.viewProps);
780
- });
781
- }, []);
783
+ })[0];
782
784
  useEffect(function () {
783
- if (loaded) {
784
- setImmediate(props.onComponentLoaded);
785
+ if (component) {
786
+ props.onLoad();
785
787
  }
786
- }, [loaded]);
787
- return children || (state.value ? /*#__PURE__*/createElement(state.value["default"], viewProps[0]) : null);
788
+ }, [component]);
789
+ return component ? /*#__PURE__*/createElement(component["default"], props.viewProps) : null;
788
790
  };
789
791
  }
790
792
  function useViewContext() {
@@ -849,10 +851,12 @@ function renderView() {
849
851
  });
850
852
  }
851
853
  function resolvePath(view, params) {
852
- if (!routeMap.has(view)) {
853
- return '/';
854
+ var suffix = '';
855
+ if (isArray(params)) {
856
+ suffix = normalizePart(isPlainObject(params[1]) ? toQueryString(params[1]) : params[1], '?') + normalizePart(params[2], '#');
857
+ params = params[0];
854
858
  }
855
- return app_app.route.getPath(getCurrentParams(view, params));
859
+ return (routeMap.has(view) ? app_app.route.getPath(getCurrentParams(view, params)) : '/') + suffix;
856
860
  }
857
861
  function linkTo(view, params) {
858
862
  return app_app.toHref(resolvePath(view, params));