brew-js-react 0.6.2 → 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/app.js +8 -4
- package/dialog.d.ts +57 -21
- package/dialog.js +10 -4
- package/dist/brew-js-react.js +128 -111
- package/dist/brew-js-react.js.map +1 -1
- package/dist/brew-js-react.min.js +2 -2
- package/dist/brew-js-react.min.js.map +1 -1
- package/index.js +1 -0
- package/mixins/FlyoutMixin.d.ts +5 -0
- package/mixins/FlyoutMixin.js +8 -1
- package/package.json +5 -3
- package/view.d.ts +31 -17
- package/view.js +61 -55
package/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { combineFn, throwNotFunction } from "zeta-dom/util";
|
|
2
|
-
import { install } from "brew-js/app";
|
|
2
|
+
import { addExtension, install } from "brew-js/app";
|
|
3
3
|
import defaults from "brew-js/defaults";
|
|
4
4
|
|
|
5
5
|
/** @type {Brew.AppInstance<Brew.WithRouter & Brew.WithI18n>} */
|
|
@@ -8,13 +8,17 @@ export var app;
|
|
|
8
8
|
const appInitCallabcks = [];
|
|
9
9
|
|
|
10
10
|
export function onAppInit(callback) {
|
|
11
|
-
|
|
11
|
+
if (app) {
|
|
12
|
+
callback(app);
|
|
13
|
+
} else {
|
|
14
|
+
appInitCallabcks.push(throwNotFunction(callback));
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
// @ts-ignore: type inference issue
|
|
18
|
+
const extension = addExtension(true, 'react2', ['?router', '?i18n'], function (app_) {
|
|
16
19
|
app = app_;
|
|
17
20
|
combineFn(appInitCallabcks)(app);
|
|
18
21
|
});
|
|
19
22
|
|
|
23
|
+
install('react', extension);
|
|
20
24
|
defaults.react = true;
|
package/dialog.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
|
28
|
+
open(): Promise<DialogResult<T>>;
|
|
15
29
|
/**
|
|
16
30
|
* Closes the dialog, with optional result value.
|
|
17
31
|
*
|
|
18
|
-
* This method is
|
|
32
|
+
* This method is similar to {@link DialogContext.dismissDialog} that {@link DialogOptions.onCommit} will not be called.
|
|
19
33
|
*/
|
|
20
|
-
close
|
|
34
|
+
close(value?: T): Promise<void>;
|
|
21
35
|
}
|
|
22
36
|
|
|
23
|
-
export interface
|
|
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
|
|
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
|
|
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
|
|
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
|
|
107
|
+
* Commits the dialog with result value.
|
|
81
108
|
*
|
|
82
|
-
* When {@link
|
|
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:
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface DialogOptions<T, V = T> extends DialogBaseProps<T, V> {
|
|
114
|
+
closeDialog: DialogCloseCallback<V>;
|
|
89
115
|
/**
|
|
90
|
-
*
|
|
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
|
-
|
|
121
|
+
commitDialog: DialogCloseCallback<V>;
|
|
93
122
|
/**
|
|
94
|
-
*
|
|
95
|
-
* which is useful for reusable layout for dialogs.
|
|
123
|
+
* Closes the dialog without invoking {@link DialogOptions.onCommit}.
|
|
96
124
|
*/
|
|
97
|
-
|
|
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
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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);
|
package/dist/brew-js-react.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*! brew-js-react v0.6.
|
|
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
|
-
module.exports = factory(require("zeta-dom"), require("
|
|
4
|
+
module.exports = factory(require("zeta-dom"), require("brew-js"), require("react"), require("react-dom"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
|
|
5
5
|
else if(typeof define === 'function' && define.amd)
|
|
6
|
-
define("brew-js-react", ["zeta-dom", "
|
|
6
|
+
define("brew-js-react", ["zeta-dom", "brew-js", "react", "react-dom", "zeta-dom-react", "waterpipe", "jquery"], factory);
|
|
7
7
|
else if(typeof exports === 'object')
|
|
8
|
-
exports["brew-js-react"] = factory(require("zeta-dom"), require("
|
|
8
|
+
exports["brew-js-react"] = factory(require("zeta-dom"), require("brew-js"), require("react"), require("react-dom"), require("zeta-dom-react"), require("waterpipe"), require("jquery"));
|
|
9
9
|
else
|
|
10
|
-
root["brew"] = root["brew"] || {}, root["brew"]["react"] = factory(root["zeta"], root["
|
|
11
|
-
})(self, (__WEBPACK_EXTERNAL_MODULE__231__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__33__,
|
|
10
|
+
root["brew"] = root["brew"] || {}, root["brew"]["react"] = factory(root["zeta"], root["brew"], root["React"], root["ReactDOM"], root["zeta"]["react"], root["waterpipe"], root["jQuery"]);
|
|
11
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__231__, __WEBPACK_EXTERNAL_MODULE__760__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__33__, __WEBPACK_EXTERNAL_MODULE__402__, __WEBPACK_EXTERNAL_MODULE__87__, __WEBPACK_EXTERNAL_MODULE__914__) => {
|
|
12
12
|
return /******/ (() => { // webpackBootstrap
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
14
14
|
|
|
@@ -255,7 +255,6 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
255
255
|
pick = _lib$util.pick,
|
|
256
256
|
randomId = _lib$util.randomId,
|
|
257
257
|
resolve = _lib$util.resolve,
|
|
258
|
-
resolveAll = _lib$util.resolveAll,
|
|
259
258
|
setImmediate = _lib$util.setImmediate,
|
|
260
259
|
setImmediateOnce = _lib$util.setImmediateOnce,
|
|
261
260
|
single = _lib$util.single,
|
|
@@ -264,6 +263,39 @@ var _lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_
|
|
|
264
263
|
watch = _lib$util.watch,
|
|
265
264
|
watchable = _lib$util.watchable;
|
|
266
265
|
|
|
266
|
+
// EXTERNAL MODULE: external {"commonjs":"brew-js","commonjs2":"brew-js","amd":"brew-js","root":"brew"}
|
|
267
|
+
var external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_ = __webpack_require__(760);
|
|
268
|
+
;// CONCATENATED MODULE: ./|umd|/brew-js/app.js
|
|
269
|
+
|
|
270
|
+
/* harmony default export */ const app = ((/* unused pure expression or super */ null && (lib)));
|
|
271
|
+
var addExtension = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.addExtension,
|
|
272
|
+
install = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.install;
|
|
273
|
+
|
|
274
|
+
;// CONCATENATED MODULE: ./|umd|/brew-js/defaults.js
|
|
275
|
+
|
|
276
|
+
var defaults = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.defaults;
|
|
277
|
+
/* harmony default export */ const brew_js_defaults = (defaults);
|
|
278
|
+
;// CONCATENATED MODULE: ./src/app.js
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
/** @type {Brew.AppInstance<Brew.WithRouter & Brew.WithI18n>} */
|
|
284
|
+
var app_app;
|
|
285
|
+
var appInitCallabcks = [];
|
|
286
|
+
function onAppInit(callback) {
|
|
287
|
+
if (app_app) {
|
|
288
|
+
callback(app_app);
|
|
289
|
+
} else {
|
|
290
|
+
appInitCallabcks.push(throwNotFunction(callback));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
var extension = addExtension(true, 'react2', ['?router', '?i18n'], function (app_) {
|
|
294
|
+
app_app = app_;
|
|
295
|
+
combineFn(appInitCallabcks)(app_app);
|
|
296
|
+
});
|
|
297
|
+
install('react', extension);
|
|
298
|
+
brew_js_defaults.react = true;
|
|
267
299
|
// EXTERNAL MODULE: external {"commonjs":"react","commonjs2":"react","amd":"react","root":"React"}
|
|
268
300
|
var external_commonjs_react_commonjs2_react_amd_react_root_React_ = __webpack_require__(12);
|
|
269
301
|
;// CONCATENATED MODULE: ./|umd|/react.js
|
|
@@ -283,6 +315,20 @@ var Component = external_commonjs_react_commonjs2_react_amd_react_root_React_.Co
|
|
|
283
315
|
var external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_ = __webpack_require__(33);
|
|
284
316
|
// EXTERNAL MODULE: ./node_modules/@misonou/react-dom-client/fallback.js
|
|
285
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
|
+
|
|
286
332
|
;// CONCATENATED MODULE: ./|umd|/zeta-dom/domUtil.js
|
|
287
333
|
|
|
288
334
|
var domUtil_lib$util = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.util,
|
|
@@ -302,13 +348,10 @@ var reportError = dom.reportError;
|
|
|
302
348
|
|
|
303
349
|
var _lib$dom = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.dom,
|
|
304
350
|
lock = _lib$dom.lock,
|
|
305
|
-
notifyAsync = _lib$dom.notifyAsync,
|
|
306
351
|
preventLeave = _lib$dom.preventLeave,
|
|
307
352
|
runAsync = _lib$dom.runAsync,
|
|
308
353
|
subscribeAsync = _lib$dom.subscribeAsync;
|
|
309
354
|
|
|
310
|
-
// EXTERNAL MODULE: external {"commonjs":"brew-js","commonjs2":"brew-js","amd":"brew-js","root":"brew"}
|
|
311
|
-
var external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_ = __webpack_require__(760);
|
|
312
355
|
;// CONCATENATED MODULE: ./|umd|/brew-js/domAction.js
|
|
313
356
|
|
|
314
357
|
var closeFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.closeFlyout,
|
|
@@ -326,12 +369,14 @@ var closeFlyout = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_b
|
|
|
326
369
|
|
|
327
370
|
|
|
328
371
|
|
|
372
|
+
|
|
329
373
|
/**
|
|
330
374
|
* @param {Partial<import("./dialog").DialogOptions<any>>} props
|
|
331
375
|
*/
|
|
332
376
|
function createDialog(props) {
|
|
333
377
|
var root = document.createElement('div');
|
|
334
378
|
var reactRoot = fallback.createRoot(root);
|
|
379
|
+
var scope = createAsyncScope(root);
|
|
335
380
|
var closeDialog = closeFlyout.bind(0, root);
|
|
336
381
|
var promise;
|
|
337
382
|
zeta_dom_dom.on(root, {
|
|
@@ -362,16 +407,20 @@ function createDialog(props) {
|
|
|
362
407
|
root.setAttribute('is-modal', '');
|
|
363
408
|
}
|
|
364
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;
|
|
365
413
|
var dialogProps = extend({}, props, {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
414
|
+
errorHandler: scope.errorHandler,
|
|
415
|
+
closeDialog: commitDialog,
|
|
416
|
+
commitDialog: commitDialog,
|
|
417
|
+
dismissDialog: closeDialog
|
|
369
418
|
});
|
|
370
419
|
var content = /*#__PURE__*/createElement(props.onRender, dialogProps);
|
|
371
420
|
if (props.wrapper) {
|
|
372
421
|
content = /*#__PURE__*/createElement(props.wrapper, dialogProps, content);
|
|
373
422
|
}
|
|
374
|
-
reactRoot.render( /*#__PURE__*/createElement(StrictMode, null, content));
|
|
423
|
+
reactRoot.render( /*#__PURE__*/createElement(StrictMode, null, /*#__PURE__*/createElement(scope.Provider, null, content)));
|
|
375
424
|
}
|
|
376
425
|
promise = resolve().then(function () {
|
|
377
426
|
zeta_dom_dom.retainFocus(zeta_dom_dom.activeElement, root);
|
|
@@ -411,19 +460,6 @@ function Dialog(props) {
|
|
|
411
460
|
}, [dialog]);
|
|
412
461
|
return /*#__PURE__*/external_commonjs_react_dom_commonjs2_react_dom_amd_react_dom_root_ReactDOM_.createPortal(props.children, dialog.root);
|
|
413
462
|
}
|
|
414
|
-
// EXTERNAL MODULE: external {"commonjs":"zeta-dom-react","commonjs2":"zeta-dom-react","amd":"zeta-dom-react","root":["zeta","react"]}
|
|
415
|
-
var external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_ = __webpack_require__(402);
|
|
416
|
-
;// CONCATENATED MODULE: ./|umd|/zeta-dom-react.js
|
|
417
|
-
|
|
418
|
-
var ViewStateProvider = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.ViewStateProvider,
|
|
419
|
-
classNames = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.classNames,
|
|
420
|
-
useAsync = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useAsync,
|
|
421
|
-
useEagerState = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useEagerState,
|
|
422
|
-
useMemoizedFunction = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useMemoizedFunction,
|
|
423
|
-
useObservableProperty = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useObservableProperty,
|
|
424
|
-
useSingleton = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useSingleton,
|
|
425
|
-
useValueTrigger = external_commonjs_zeta_dom_react_commonjs2_zeta_dom_react_amd_zeta_dom_react_root_zeta_react_.useValueTrigger;
|
|
426
|
-
|
|
427
463
|
;// CONCATENATED MODULE: ./|umd|/zeta-dom/events.js
|
|
428
464
|
|
|
429
465
|
var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_root_zeta_.EventContainer;
|
|
@@ -431,39 +467,14 @@ var EventContainer = external_commonjs_zeta_dom_commonjs2_zeta_dom_amd_zeta_dom_
|
|
|
431
467
|
;// CONCATENATED MODULE: ./|umd|/brew-js/util/common.js
|
|
432
468
|
|
|
433
469
|
var getQueryParam = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.getQueryParam,
|
|
434
|
-
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;
|
|
435
472
|
|
|
436
473
|
;// CONCATENATED MODULE: ./|umd|/brew-js/util/path.js
|
|
437
474
|
|
|
438
475
|
var parsePath = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.parsePath,
|
|
439
476
|
removeQueryAndHash = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.removeQueryAndHash;
|
|
440
477
|
|
|
441
|
-
;// CONCATENATED MODULE: ./|umd|/brew-js/app.js
|
|
442
|
-
|
|
443
|
-
/* harmony default export */ const app = ((/* unused pure expression or super */ null && (lib)));
|
|
444
|
-
var install = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.install;
|
|
445
|
-
|
|
446
|
-
;// CONCATENATED MODULE: ./|umd|/brew-js/defaults.js
|
|
447
|
-
|
|
448
|
-
var defaults = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.defaults;
|
|
449
|
-
/* harmony default export */ const brew_js_defaults = (defaults);
|
|
450
|
-
;// CONCATENATED MODULE: ./src/app.js
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
/** @type {Brew.AppInstance<Brew.WithRouter & Brew.WithI18n>} */
|
|
456
|
-
var app_app;
|
|
457
|
-
var appInitCallabcks = [];
|
|
458
|
-
function onAppInit(callback) {
|
|
459
|
-
appInitCallabcks.push(throwNotFunction(callback));
|
|
460
|
-
}
|
|
461
|
-
install('react', function (app_) {
|
|
462
|
-
// @ts-ignore: type inference issue
|
|
463
|
-
app_app = app_;
|
|
464
|
-
combineFn(appInitCallabcks)(app_app);
|
|
465
|
-
});
|
|
466
|
-
brew_js_defaults.react = true;
|
|
467
478
|
;// CONCATENATED MODULE: ./|umd|/brew-js/anim.js
|
|
468
479
|
|
|
469
480
|
var animateIn = external_commonjs_brew_js_commonjs2_brew_js_amd_brew_js_root_brew_.animateIn,
|
|
@@ -510,6 +521,7 @@ onAppInit(function () {
|
|
|
510
521
|
});
|
|
511
522
|
})(rootState);
|
|
512
523
|
});
|
|
524
|
+
rootState.setPage(app_app.page);
|
|
513
525
|
});
|
|
514
526
|
function ViewContext(view, page, parent) {
|
|
515
527
|
var self = this;
|
|
@@ -545,6 +557,13 @@ function ErrorBoundary() {
|
|
|
545
557
|
}
|
|
546
558
|
ErrorBoundary.contextType = StateContext;
|
|
547
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
|
+
},
|
|
548
567
|
componentDidCatch: function componentDidCatch(error) {
|
|
549
568
|
var self = this;
|
|
550
569
|
if (errorView && !self.state.error) {
|
|
@@ -552,33 +571,37 @@ definePrototype(ErrorBoundary, Component, {
|
|
|
552
571
|
error: error
|
|
553
572
|
});
|
|
554
573
|
} else {
|
|
555
|
-
// emit error in next tick as ref callback may yet to be invoked
|
|
556
|
-
// if error is thrown synchronously in first render
|
|
557
|
-
setImmediate(function () {
|
|
558
|
-
reportError(error, self.context.container);
|
|
559
|
-
});
|
|
560
574
|
// ensure promise sent to beforepageload event is resolved
|
|
561
|
-
self.props.
|
|
575
|
+
self.props.onLoad();
|
|
576
|
+
reportError(error, self.context.container);
|
|
562
577
|
}
|
|
563
578
|
},
|
|
564
579
|
render: function render() {
|
|
565
580
|
var self = this;
|
|
566
|
-
var
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
};
|
|
571
|
-
var onComponentLoaded = self.props.onComponentLoaded;
|
|
572
|
-
if (props.error) {
|
|
573
|
-
return /*#__PURE__*/createElement(errorView, {
|
|
574
|
-
onComponentLoaded: onComponentLoaded,
|
|
575
|
-
viewProps: props
|
|
581
|
+
var context = self.context;
|
|
582
|
+
if (!context.container) {
|
|
583
|
+
setImmediate(function () {
|
|
584
|
+
self.forceUpdate();
|
|
576
585
|
});
|
|
586
|
+
return null;
|
|
577
587
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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
|
+
}
|
|
603
|
+
};
|
|
604
|
+
return /*#__PURE__*/createElement(scope.Provider, null, /*#__PURE__*/createElement(error ? errorView : context.view, childProps));
|
|
582
605
|
},
|
|
583
606
|
reset: function reset() {
|
|
584
607
|
this.setState({
|
|
@@ -637,11 +660,11 @@ definePrototype(ViewContainer, Component, {
|
|
|
637
660
|
(self.unmountView || noop)(true);
|
|
638
661
|
var context = new ViewContext(V, app_app.page, self.context);
|
|
639
662
|
var state = routeMap.get(V);
|
|
640
|
-
var
|
|
663
|
+
var onLoad;
|
|
641
664
|
var promise = new Promise(function (resolve) {
|
|
642
|
-
|
|
665
|
+
onLoad = resolve;
|
|
643
666
|
});
|
|
644
|
-
var unmountView =
|
|
667
|
+
var unmountView = onLoad;
|
|
645
668
|
var initElement = executeOnce(function (element) {
|
|
646
669
|
context.container = element;
|
|
647
670
|
promise.then(function () {
|
|
@@ -664,15 +687,7 @@ definePrototype(ViewContainer, Component, {
|
|
|
664
687
|
}, true);
|
|
665
688
|
}
|
|
666
689
|
});
|
|
667
|
-
notifyAsync(element, promise);
|
|
668
690
|
});
|
|
669
|
-
var viewProps = function viewProps() {
|
|
670
|
-
return freeze({
|
|
671
|
-
navigationType: view_event.navigationType,
|
|
672
|
-
viewContext: context,
|
|
673
|
-
viewData: context.page.data || {}
|
|
674
|
-
});
|
|
675
|
-
};
|
|
676
691
|
var view = /*#__PURE__*/createElement(StateContext.Provider, {
|
|
677
692
|
key: state.id,
|
|
678
693
|
value: context
|
|
@@ -680,8 +695,7 @@ definePrototype(ViewContainer, Component, {
|
|
|
680
695
|
ref: initElement,
|
|
681
696
|
'brew-view': ''
|
|
682
697
|
}), /*#__PURE__*/createElement(ErrorBoundary, {
|
|
683
|
-
|
|
684
|
-
viewProps: viewProps
|
|
698
|
+
onLoad: onLoad
|
|
685
699
|
}))));
|
|
686
700
|
extend(self, _(context), {
|
|
687
701
|
currentContext: context,
|
|
@@ -703,6 +717,9 @@ definePrototype(ViewContainer, Component, {
|
|
|
703
717
|
return any(props.views, isViewMatched) || props.defaultView;
|
|
704
718
|
}
|
|
705
719
|
});
|
|
720
|
+
function normalizePart(value, part) {
|
|
721
|
+
return isUndefinedOrNull(value) || value === '' || value === part ? '' : value[0] === part ? value : part + value;
|
|
722
|
+
}
|
|
706
723
|
function getCurrentParams(view, params) {
|
|
707
724
|
var state = routeMap.get(view);
|
|
708
725
|
if (!state.maxParams) {
|
|
@@ -753,33 +770,23 @@ function createViewComponent(factory) {
|
|
|
753
770
|
factory = createElement.bind(null, factory);
|
|
754
771
|
}
|
|
755
772
|
return function fn(props) {
|
|
756
|
-
var
|
|
757
|
-
var viewProps = useState(props.viewProps);
|
|
758
|
-
var children = !promise && factory(viewProps[0]);
|
|
773
|
+
var children = promise || factory(props.viewProps);
|
|
759
774
|
if (isThenable(children)) {
|
|
760
775
|
promise = children;
|
|
761
|
-
children = null;
|
|
762
776
|
catchAsync(promise);
|
|
777
|
+
} else {
|
|
778
|
+
useEffect(props.onLoad, []);
|
|
779
|
+
return children;
|
|
763
780
|
}
|
|
764
|
-
var
|
|
765
|
-
return promise;
|
|
766
|
-
}
|
|
767
|
-
var loaded = !promise || !state.loading;
|
|
768
|
-
useEffect(function () {
|
|
769
|
-
// listen to property directly so that it is invoked after pagechange event handlers in actual component
|
|
770
|
-
return watch(viewContext, 'page', function () {
|
|
771
|
-
viewProps[1](props.viewProps);
|
|
772
|
-
});
|
|
773
|
-
}, []);
|
|
781
|
+
var component = useAsync(function () {
|
|
782
|
+
return promise.then(null, props.onError);
|
|
783
|
+
})[0];
|
|
774
784
|
useEffect(function () {
|
|
775
|
-
if (
|
|
776
|
-
|
|
785
|
+
if (component) {
|
|
786
|
+
props.onLoad();
|
|
777
787
|
}
|
|
778
|
-
}, [
|
|
779
|
-
|
|
780
|
-
throw state.error;
|
|
781
|
-
}
|
|
782
|
-
return children || (state.value ? /*#__PURE__*/createElement(state.value["default"], viewProps[0]) : null);
|
|
788
|
+
}, [component]);
|
|
789
|
+
return component ? /*#__PURE__*/createElement(component["default"], props.viewProps) : null;
|
|
783
790
|
};
|
|
784
791
|
}
|
|
785
792
|
function useViewContext() {
|
|
@@ -844,10 +851,12 @@ function renderView() {
|
|
|
844
851
|
});
|
|
845
852
|
}
|
|
846
853
|
function resolvePath(view, params) {
|
|
847
|
-
|
|
848
|
-
|
|
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];
|
|
849
858
|
}
|
|
850
|
-
return app_app.route.getPath(getCurrentParams(view, params));
|
|
859
|
+
return (routeMap.has(view) ? app_app.route.getPath(getCurrentParams(view, params)) : '/') + suffix;
|
|
851
860
|
}
|
|
852
861
|
function linkTo(view, params) {
|
|
853
862
|
return app_app.toHref(resolvePath(view, params));
|
|
@@ -1606,6 +1615,13 @@ definePrototype(FlyoutMixin, ClassNameMixin, {
|
|
|
1606
1615
|
onVisibilityChanged: function onVisibilityChanged(callback) {
|
|
1607
1616
|
return this.watch('visible', callback);
|
|
1608
1617
|
},
|
|
1618
|
+
whenVisible: function whenVisible(effect) {
|
|
1619
|
+
var dispose = [];
|
|
1620
|
+
dispose[0] = this.watch('visible', function (visible) {
|
|
1621
|
+
dispose[1] = (visible ? isFunction(effect()) : dispose[1] && void dispose[1]()) || noop;
|
|
1622
|
+
}, true);
|
|
1623
|
+
return combineFn(dispose);
|
|
1624
|
+
},
|
|
1609
1625
|
initElement: function initElement(element, state) {
|
|
1610
1626
|
var self = this;
|
|
1611
1627
|
if (self.elements()[1]) {
|
|
@@ -1850,6 +1866,7 @@ function useMixinRef(mixin) {
|
|
|
1850
1866
|
|
|
1851
1867
|
;// CONCATENATED MODULE: ./src/index.js
|
|
1852
1868
|
|
|
1869
|
+
|
|
1853
1870
|
/* harmony default export */ const src = ((/* unused pure expression or super */ null && (brew)));
|
|
1854
1871
|
|
|
1855
1872
|
|