@wcardinal/wcardinal-ui 0.447.0 → 0.448.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.
@@ -1,4 +1,4 @@
1
- import { DisplayObject, Point, Rectangle } from "pixi.js";
1
+ import { Point, Rectangle } from "pixi.js";
2
2
  import { DAnimation } from "./d-animation";
3
3
  import { DApplicationLayerLike } from "./d-application-layer-like";
4
4
  import { DBase, DBaseEvents, DBaseOptions, DThemeBase } from "./d-base";
@@ -125,8 +125,9 @@ export declare class DDialog<VALUE = void, THEME extends DThemeDialog = DThemeDi
125
125
  * @returns a value of this dialog
126
126
  */
127
127
  open(opener?: DDialogOpener): Promise<VALUE>;
128
- protected onParentChildAdded(): void;
129
- protected compareAlwaysOnTop(this: unknown, a: DisplayObject, b: DisplayObject): number;
128
+ protected onChildFocus(focused: DBase): void;
129
+ protected onFocus(): void;
130
+ protected bringToFront(): void;
130
131
  protected onPrerender(): void;
131
132
  protected onOpen(): void;
132
133
  isOpened(): boolean;
@@ -248,7 +248,6 @@ var DDialog = /** @class */ (function (_super) {
248
248
  */
249
249
  DDialog.prototype.open = function (opener) {
250
250
  var _this = this;
251
- var _a;
252
251
  var result = this._promise;
253
252
  if (result == null) {
254
253
  result = new Promise(function (resolve, reject) {
@@ -292,36 +291,45 @@ var DDialog = /** @class */ (function (_super) {
292
291
  gesture.constraint(this, layer, position.x, position.y);
293
292
  }
294
293
  }
295
- // Always On Top
296
- if (this._alwaysOnTop) {
297
- var parent_2 = this.parent;
298
- if (parent_2 != null) {
299
- parent_2.on("childAdded", ((_a = this._onParentChildAddedBound) !== null && _a !== void 0 ? _a : (this._onParentChildAddedBound = function () {
300
- _this.onParentChildAdded();
301
- })));
302
- this.onParentChildAdded();
303
- }
304
- }
294
+ // Bring To Front
295
+ this.bringToFront();
305
296
  // Done
306
297
  this.onOpen();
307
298
  }
308
299
  return result;
309
300
  };
310
- DDialog.prototype.onParentChildAdded = function () {
301
+ DDialog.prototype.onChildFocus = function (focused) {
302
+ _super.prototype.onChildFocus.call(this, focused);
303
+ this.bringToFront();
304
+ };
305
+ DDialog.prototype.onFocus = function () {
306
+ _super.prototype.onFocus.call(this);
307
+ this.bringToFront();
308
+ };
309
+ DDialog.prototype.bringToFront = function () {
311
310
  var parent = this.parent;
312
- if (parent != null) {
313
- parent.children.sort(this.compareAlwaysOnTop);
311
+ if (parent == null) {
312
+ return;
314
313
  }
315
- };
316
- DDialog.prototype.compareAlwaysOnTop = function (a, b) {
317
- var at = a instanceof DDialog && a.alwaysOnTop;
318
- var bt = b instanceof DDialog && b.alwaysOnTop;
319
- if (at) {
320
- return bt ? 0 : +1;
314
+ var children = parent.children;
315
+ var childrenLength = children.length;
316
+ var index = childrenLength - 1;
317
+ for (; 0 <= index; --index) {
318
+ if (children[index] === this) {
319
+ break;
320
+ }
321
321
  }
322
- else {
323
- return bt ? -1 : 0;
322
+ if (index < 0) {
323
+ return;
324
+ }
325
+ for (var i = index + 1; i < childrenLength; ++i) {
326
+ children[i - 1] = children[i];
324
327
  }
328
+ children[childrenLength - 1] = this;
329
+ children.sort(function (a, b) {
330
+ return ((a instanceof DDialog ? (a._alwaysOnTop ? 2 : 1) : 0) -
331
+ (b instanceof DDialog ? (b._alwaysOnTop ? 2 : 1) : 0));
332
+ });
325
333
  };
326
334
  DDialog.prototype.onPrerender = function () {
327
335
  var _a;
@@ -420,9 +428,9 @@ var DDialog = /** @class */ (function (_super) {
420
428
  }
421
429
  // Always On Top
422
430
  if (this._alwaysOnTop) {
423
- var parent_3 = this.parent;
424
- if (parent_3 != null) {
425
- parent_3.off("childAdded", this._onParentChildAddedBound);
431
+ var parent_2 = this.parent;
432
+ if (parent_2 != null) {
433
+ parent_2.off("childAdded", this._onParentChildAddedBound);
426
434
  }
427
435
  }
428
436
  this.emit("close", this);
@@ -1 +1 @@
1
- {"version":3,"file":"d-dialog.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dialog.ts"],"names":[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AoB,CAAgB;QACnC,IAAI,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,GAAG,EAAE;YACvC,IAAI,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;gBACrC,IAAI,CAAC,SAAS,EAAE,CAAC;aACjB;SACD;QACD,OAAO,iBAAM,SAAS,YAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAES,2BAAS,GAAnB;QACC,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;IAES,qCAAmB,GAA7B,UAA8B,KAAY;QACzC,QAAQ,IAAI,CAAC,KAAK,EAAE;YACnB,KAAK,WAAW,CAAC,KAAK,CAAC;YACvB,KAAK,WAAW,CAAC,IAAI;gBACpB,OAAO,IAAI,CAAC;YACb,KAAK,WAAW,CAAC,QAAQ;gBACxB,OAAO,iBAAM,mBAAmB,YAAC,KAAK,CAAC,CAAC;SACzC;IACF,CAAC;IAES,yBAAO,GAAjB;QACC,OAAO,SAAS,CAAC;IAClB,CAAC;IACF,cAAC;AAAD,CAAC,AA9cD,CAIU,KAAK,GA0cd","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { DisplayObject, Point, Rectangle } from \"pixi.js\";\nimport { DAnimation } from \"./d-animation\";\nimport { DApplicationLayerLike } from \"./d-application-layer-like\";\nimport { DApplications } from \"./d-applications\";\nimport { DBase, DBaseEvents, DBaseOptions, DThemeBase } from \"./d-base\";\nimport { DBaseState } from \"./d-base-state\";\nimport { DControllerFocus, DFocusable } from \"./d-controller-focus\";\nimport { DDialogAlign } from \"./d-dialog-align\";\nimport { DDialogCloseOn } from \"./d-dialog-close-on\";\nimport { DDialogGesture, DDialogGestureOptions } from \"./d-dialog-gesture\";\nimport { DDialogGestureImpl } from \"./d-dialog-gesture-impl\";\nimport { DDialogGestureMode } from \"./d-dialog-gesture-mode\";\nimport { DDialogMode } from \"./d-dialog-mode\";\nimport { DDialogState } from \"./d-dialog-state\";\nimport { DOnOptions } from \"./d-on-options\";\nimport { DPadding } from \"./d-padding\";\nimport { isArray } from \"./util/is-array\";\nimport { isString } from \"./util/is-string\";\nimport { toEnum } from \"./util/to-enum\";\nimport { UtilAttach } from \"./util/util-attach\";\nimport { UtilClickOutside } from \"./util/util-click-outside\";\nimport { UtilKeyboardEvent } from \"./util/util-keyboard-event\";\nimport { UtilOverlay } from \"./util/util-overlay\";\nimport { DApplicationTarget } from \"./d-application-like\";\n\n/**\n * {@link DDialog} events.\n */\nexport interface DDialogEvents<EMITTER> extends DBaseEvents<EMITTER> {\n\t/**\n\t * Triggered when a dialog is opened.\n\t *\n\t * @param emitter this\n\t */\n\topen(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when a dialog is closed.\n\t *\n\t * @param emitter this\n\t */\n\tclose(emitter: EMITTER): void;\n}\n\n/**\n * {@link DDialog} `on` options.\n */\nexport interface DDialogOnOptions<EMITTER> extends Partial<DDialogEvents<EMITTER>>, DOnOptions {}\n\n/**\n * {@link DDialog} options.\n */\nexport interface DDialogOptions<THEME extends DThemeDialog = DThemeDialog, EMITTER = any>\n\textends DBaseOptions<THEME> {\n\tcloseOn?: DDialogCloseOn | Array<keyof typeof DDialogCloseOn> | keyof typeof DDialogCloseOn;\n\n\tanimation?: DAnimation<DBase>;\n\n\t/**\n\t * A dialog mode.\n\t */\n\tmode?: DDialogMode | keyof typeof DDialogMode;\n\n\talwaysOnTop?: boolean;\n\n\tsticky?: boolean;\n\n\tgesture?: boolean | DDialogGestureOptions;\n\n\talign?: DDialogAlign | null | keyof typeof DDialogAlign;\n\n\t/**\n\t * Mappings of event names and handlers.\n\t */\n\ton?: DDialogOnOptions<EMITTER>;\n}\n\n/**\n * {@link DDialog} theme.\n */\nexport interface DThemeDialog extends DThemeBase {\n\tgetMode(): DDialogMode;\n\tcloseOn(mode: DDialogMode): DDialogCloseOn;\n\tisSticky(mode: DDialogMode): boolean;\n\tisAlwaysOnTop(): boolean;\n\tisGestureEnabled(mode: DDialogMode): boolean;\n\tgetGestureMode(mode: DDialogMode): DDialogGestureMode;\n\tgetOffsetX(mode: DDialogMode): number;\n\tgetOffsetY(mode: DDialogMode): number;\n\tgetAlign(mode: DDialogMode): DDialogAlign | null;\n\tnewAnimation(mode: DDialogMode): DAnimation<DBase> | null;\n}\n\nexport interface DDialogOpener extends DApplicationTarget {\n\tgetBounds(skipUpdate?: boolean, rect?: Rectangle): Rectangle;\n}\n\n/**\n * A dialog class.\n *\n * If multiple application instances are there, better to set the constructor\n * option `parent` to an `application.stage` so that the dialog picks a right\n * application. `DDialog` searches applications in a following order:\n *\n * * To begin, `DDialog` tries to find applications which it belongs to.\n * * If `DDialog` can't find applications, then `DDialog` tries to find applications which openers belong to.\n * * If openers are not given, `DDialog` assumes the last created application at the very moment `DDialog` is instantiated is the one it belongs to.\n */\nexport class DDialog<\n\tVALUE = void,\n\tTHEME extends DThemeDialog = DThemeDialog,\n\tOPTIONS extends DDialogOptions<THEME> = DDialogOptions<THEME>\n> extends DBase<THEME, OPTIONS> {\n\tprotected static WORK_BOUNDS?: Rectangle;\n\n\tprotected _promise?: Promise<VALUE>;\n\tprotected _resolve?: (value: VALUE | PromiseLike<VALUE>) => void;\n\tprotected _reject?: (reason?: any) => void;\n\n\tprotected _animation?: DAnimation<DBase> | null;\n\tprotected _closeOn!: DDialogCloseOn;\n\tprotected _focused?: DFocusable | null;\n\tprotected _overlay!: UtilOverlay;\n\tprotected _mode!: DDialogMode;\n\tprotected _alwaysOnTop!: boolean;\n\tprotected _onParentChildAddedBound?: () => void;\n\tprotected _sticky!: boolean;\n\tprotected _onPrerenderBound!: () => void;\n\tprotected _align!: DDialogAlign | null;\n\tprotected _opener?: DDialogOpener | null;\n\n\tprotected _gesture!: DDialogGesture<this>;\n\tprotected _layer!: DApplicationLayerLike | null;\n\n\tprotected init(options?: OPTIONS): void {\n\t\tsuper.init(options);\n\n\t\tthis._onPrerenderBound = (): void => {\n\t\t\tthis.onPrerender();\n\t\t};\n\t\tthis._layer = null;\n\n\t\t// Mode\n\t\tconst theme = this.theme;\n\t\tconst mode = toEnum(options?.mode ?? theme.getMode(), DDialogMode);\n\t\tthis._mode = mode;\n\n\t\t// Always On Top\n\t\tthis._alwaysOnTop = options?.alwaysOnTop ?? theme.isAlwaysOnTop();\n\n\t\t// Sticky\n\t\tthis._sticky = options?.sticky ?? theme.isSticky(mode);\n\n\t\t// Close On\n\t\tconst closeOn = this.toCloseOn(mode, theme, options);\n\t\tthis._closeOn = closeOn;\n\n\t\t// Align\n\t\tthis._align = this.toAlign(mode, theme, options);\n\n\t\t// Overlay\n\t\tthis._overlay = new UtilOverlay();\n\n\t\t// Gesture\n\t\tthis._gesture = new DDialogGestureImpl(this, this.toGestureOptions(mode, theme, options));\n\n\t\t// Visibility\n\t\tthis.visible = false;\n\n\t\t// State\n\t\tswitch (mode) {\n\t\t\tcase DDialogMode.MODAL:\n\t\t\t\tthis.state.addAll(DBaseState.FOCUS_ROOT, DDialogState.MODAL);\n\t\t\t\tbreak;\n\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\tthis.state.add(DDialogState.MODELESS);\n\t\t\t\tbreak;\n\t\t\tcase DDialogMode.MENU:\n\t\t\t\tthis.state.addAll(DBaseState.FOCUS_ROOT, DDialogState.MENU);\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Outside-click handling\n\t\tif (closeOn & DDialogCloseOn.CLICK_OUTSIDE) {\n\t\t\tUtilClickOutside.apply(this, (): void => {\n\t\t\t\tthis.onCloseOn();\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected toCloseOn(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogCloseOn {\n\t\tconst closeOn = options?.closeOn;\n\t\tif (closeOn == null) {\n\t\t\treturn theme.closeOn(mode);\n\t\t} else if (isArray(closeOn)) {\n\t\t\tlet result = DDialogCloseOn.NONE;\n\t\t\tfor (let i = 0, imax = closeOn.length; i < imax; ++i) {\n\t\t\t\tresult |= DDialogCloseOn[closeOn[i]];\n\t\t\t}\n\t\t\treturn result;\n\t\t} else if (isString(closeOn)) {\n\t\t\treturn DDialogCloseOn[closeOn];\n\t\t}\n\t\treturn closeOn;\n\t}\n\n\tprotected toAlign(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogAlign | null {\n\t\tconst align = options?.align;\n\t\tif (align === null) {\n\t\t\treturn null;\n\t\t} else if (align === undefined) {\n\t\t\treturn theme.getAlign(mode);\n\t\t} else {\n\t\t\treturn toEnum(align, DDialogAlign);\n\t\t}\n\t}\n\n\tget mode(): DDialogMode {\n\t\treturn this._mode;\n\t}\n\n\tget align(): DDialogAlign | null {\n\t\treturn this._align;\n\t}\n\n\tset algin(align: DDialogAlign | null) {\n\t\tthis._align = align;\n\t}\n\n\tget alwaysOnTop(): boolean {\n\t\treturn this._alwaysOnTop;\n\t}\n\n\tset alwaysOnTop(alwaysOnTop: boolean) {\n\t\tthis._alwaysOnTop = alwaysOnTop;\n\t}\n\n\tget gesture(): DDialogGesture<this> {\n\t\treturn this._gesture;\n\t}\n\n\tget layer(): DApplicationLayerLike | null {\n\t\treturn this._layer;\n\t}\n\n\tprotected toGestureOptions(\n\t\tmode: DDialogMode,\n\t\ttheme: THEME,\n\t\toptions?: OPTIONS\n\t): DDialogGestureOptions {\n\t\tconst gesture = options?.gesture;\n\t\tif (gesture === true) {\n\t\t\treturn {\n\t\t\t\tenable: true,\n\t\t\t\tmode: theme.getGestureMode(mode)\n\t\t\t};\n\t\t} else if (gesture === false) {\n\t\t\treturn {\n\t\t\t\tenable: false,\n\t\t\t\tmode: theme.getGestureMode(mode)\n\t\t\t};\n\t\t} else if (gesture != null) {\n\t\t\tif (gesture.enable === undefined) {\n\t\t\t\tgesture.enable = theme.isGestureEnabled(mode);\n\t\t\t}\n\t\t\tif (gesture.mode === undefined) {\n\t\t\t\tgesture.mode = theme.getGestureMode(mode);\n\t\t\t}\n\t\t\treturn gesture;\n\t\t}\n\t\treturn {\n\t\t\tenable: theme.isGestureEnabled(mode),\n\t\t\tmode: theme.getGestureMode(mode)\n\t\t};\n\t}\n\n\tonParentResize(parentWidth: number, parentHeight: number, parentPadding: DPadding): void {\n\t\tif (this.isOpened()) {\n\t\t\tconst layer = this._layer;\n\t\t\tif (layer != null) {\n\t\t\t\tconst gesture = this._gesture;\n\t\t\t\tif (gesture.isDirty()) {\n\t\t\t\t\tconst position = this.position;\n\t\t\t\t\tgesture.constraint(this, layer, position.x, position.y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsuper.onParentResize(parentWidth, parentHeight, parentPadding);\n\t}\n\n\tprotected getAnimation(): DAnimation | null {\n\t\tlet result = this._animation;\n\t\tif (result === undefined) {\n\t\t\tresult = this._options?.animation ?? this.theme.newAnimation(this._mode);\n\t\t\tif (result) {\n\t\t\t\tresult.target = this;\n\t\t\t\tresult.on(\"end\", (isReverse: boolean): void => {\n\t\t\t\t\tthis.onAnimationEnd(isReverse);\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._animation = result;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected onAnimationEnd(isReverse: boolean): void {\n\t\tif (isReverse) {\n\t\t\tif (this._mode === DDialogMode.MODELESS) {\n\t\t\t\tthis.hide();\n\t\t\t} else {\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tif (parent) {\n\t\t\t\t\tparent.removeChild(this);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\tif (layer) {\n\t\t\t\tconst focusController = layer.getFocusController();\n\t\t\t\tthis._focused = focusController.get();\n\t\t\t\tfocusController.focus(this.findFirstFocusable(focusController) || this);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected findFirstFocusable(focusController: DControllerFocus): DFocusable | null {\n\t\treturn focusController.find(this, false, true, true);\n\t}\n\n\t/**\n\t * Opens a dialog.\n\t *\n\t * @param opener An opener of a dialog.\n\t * The dialog position is determined based on a position and a size of the opener.\n\t * If the opener is undefined, the dialog is placed at the center of the screen.\n\t *\n\t * @returns a value of this dialog\n\t */\n\topen(opener?: DDialogOpener): Promise<VALUE> {\n\t\tlet result = this._promise;\n\t\tif (result == null) {\n\t\t\tresult = new Promise<VALUE>((resolve, reject): void => {\n\t\t\t\tthis._resolve = resolve;\n\t\t\t\tthis._reject = reject;\n\t\t\t});\n\t\t\tthis._promise = result;\n\n\t\t\tthis._opener = opener;\n\n\t\t\t// Attach to a layer\n\t\t\tlet layer: DApplicationLayerLike | null = null;\n\t\t\tswitch (this._mode) {\n\t\t\t\tcase DDialogMode.MODAL:\n\t\t\t\tcase DDialogMode.MENU:\n\t\t\t\t\tlayer = this._overlay.pick(this, opener);\n\t\t\t\t\tlayer.stage.addChild(this);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\t\tlayer = DApplications.getLayer(this);\n\t\t\t\t\tthis.show();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis._layer = layer;\n\n\t\t\t// Position & size\n\t\t\tconst gesture = this._gesture;\n\t\t\tif (gesture.mode === DDialogGestureMode.CLEAN) {\n\t\t\t\tgesture.toClean();\n\t\t\t}\n\t\t\tif (layer != null) {\n\t\t\t\tif (gesture.isClean()) {\n\t\t\t\t\tconst renderer = layer.renderer;\n\t\t\t\t\tconst onPrerenderBound = this._onPrerenderBound;\n\t\t\t\t\tif (this._sticky) {\n\t\t\t\t\t\trenderer.on(\"prerender\", onPrerenderBound);\n\t\t\t\t\t} else {\n\t\t\t\t\t\trenderer.once(\"prerender\", onPrerenderBound);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst position = this.position;\n\t\t\t\t\tgesture.constraint(this, layer, position.x, position.y);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Always On Top\n\t\t\tif (this._alwaysOnTop) {\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tif (parent != null) {\n\t\t\t\t\tparent.on(\n\t\t\t\t\t\t\"childAdded\",\n\t\t\t\t\t\t(this._onParentChildAddedBound ??= (): void => {\n\t\t\t\t\t\t\tthis.onParentChildAdded();\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t\tthis.onParentChildAdded();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Done\n\t\t\tthis.onOpen();\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected onParentChildAdded(): void {\n\t\tconst parent = this.parent;\n\t\tif (parent != null) {\n\t\t\tparent.children.sort(this.compareAlwaysOnTop);\n\t\t}\n\t}\n\n\tprotected compareAlwaysOnTop(this: unknown, a: DisplayObject, b: DisplayObject): number {\n\t\tconst at = a instanceof DDialog && a.alwaysOnTop;\n\t\tconst bt = b instanceof DDialog && b.alwaysOnTop;\n\t\tif (at) {\n\t\t\treturn bt ? 0 : +1;\n\t\t} else {\n\t\t\treturn bt ? -1 : 0;\n\t\t}\n\t}\n\n\tprotected onPrerender(): void {\n\t\tconst layer = this._layer;\n\t\tif (layer == null) {\n\t\t\treturn;\n\t\t}\n\t\tconst align = this._align;\n\t\tif (align === DDialogAlign.NONE) {\n\t\t\treturn;\n\t\t}\n\t\tconst opener = this._opener;\n\t\tif (align != null && opener != null) {\n\t\t\tconst mode = this._mode;\n\t\t\tconst bounds = opener.getBounds(false, (DDialog.WORK_BOUNDS ??= new Rectangle()));\n\t\t\tconst theme = this.theme;\n\t\t\tUtilAttach.attach(\n\t\t\t\tthis,\n\t\t\t\tbounds,\n\t\t\t\ttheme.getOffsetX(mode),\n\t\t\t\ttheme.getOffsetY(mode),\n\t\t\t\tlayer.width,\n\t\t\t\tlayer.height,\n\t\t\t\talign\n\t\t\t);\n\t\t} else {\n\t\t\tthis.position.set((layer.width - this.width) * 0.5, (layer.height - this.height) * 0.5);\n\t\t}\n\t}\n\n\tprotected onOpen(): void {\n\t\tthis.emit(\"open\", this);\n\n\t\t// Animation\n\t\tconst animation = this.getAnimation();\n\t\tif (animation) {\n\t\t\tanimation.start();\n\t\t} else if (this._mode === DDialogMode.MENU) {\n\t\t\tthis.visible = true;\n\t\t\tthis.onAnimationEnd(false);\n\t\t}\n\t}\n\n\tisOpened(): boolean {\n\t\treturn this._promise != null;\n\t}\n\n\tclose(): void {\n\t\tthis.doReject();\n\t}\n\n\tprotected doResolve(value: VALUE | PromiseLike<VALUE>): void {\n\t\tconst resolve = this._resolve;\n\t\tif (resolve) {\n\t\t\tthis._promise = undefined;\n\t\t\tthis._resolve = undefined;\n\t\t\tthis._reject = undefined;\n\n\t\t\tthis.onClose();\n\n\t\t\tresolve(value);\n\t\t}\n\t}\n\n\tprotected doReject(reason?: any): void {\n\t\tconst reject = this._reject;\n\t\tif (reject) {\n\t\t\tthis._promise = undefined;\n\t\t\tthis._resolve = undefined;\n\t\t\tthis._reject = undefined;\n\n\t\t\tthis.onClose();\n\n\t\t\treject(reason);\n\t\t}\n\t}\n\n\tprotected onClose(): void {\n\t\t// Focus\n\t\tconst layer = this._layer;\n\t\tconst focused = this._focused;\n\t\tif (focused != null) {\n\t\t\tthis._focused = null;\n\t\t\tif (layer) {\n\t\t\t\tconst focusedLayer = DApplications.getLayer(focused);\n\t\t\t\tif (focusedLayer != null && layer !== focusedLayer) {\n\t\t\t\t\tfocusedLayer.view.focus();\n\t\t\t\t}\n\t\t\t\tlayer.getFocusController().focus(focused);\n\t\t\t} else {\n\t\t\t\tthis.blur(true);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.blur(true);\n\t\t}\n\n\t\t// Remove the prerender event handler and forget the layer\n\t\tif (layer) {\n\t\t\tlayer.renderer.off(\"prerender\", this._onPrerenderBound);\n\t\t\tthis._layer = null;\n\t\t}\n\n\t\t// Forget the opener\n\t\tthis._opener = null;\n\n\t\t// Animation\n\t\tconst animation = this.getAnimation();\n\t\tif (animation) {\n\t\t\tanimation.start(true);\n\t\t} else {\n\t\t\tthis.visible = false;\n\t\t\tthis.onAnimationEnd(true);\n\t\t}\n\n\t\t// Always On Top\n\t\tif (this._alwaysOnTop) {\n\t\t\tconst parent = this.parent;\n\t\t\tif (parent != null) {\n\t\t\t\tparent.off(\"childAdded\", this._onParentChildAddedBound);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"close\", this);\n\t}\n\n\tprotected onKeyDown(e: KeyboardEvent): boolean {\n\t\tif (this._closeOn & DDialogCloseOn.ESC) {\n\t\t\tif (UtilKeyboardEvent.isCancelKey(e)) {\n\t\t\t\tthis.onCloseOn();\n\t\t\t}\n\t\t}\n\t\treturn super.onKeyDown(e);\n\t}\n\n\tprotected onCloseOn(): void {\n\t\tthis.close();\n\t}\n\n\tprotected containsGlobalPoint(point: Point): boolean {\n\t\tswitch (this._mode) {\n\t\t\tcase DDialogMode.MODAL:\n\t\t\tcase DDialogMode.MENU:\n\t\t\t\treturn true;\n\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\treturn super.containsGlobalPoint(point);\n\t\t}\n\t}\n\n\tprotected getType(): string {\n\t\treturn \"DDialog\";\n\t}\n}\n"]}
1
+ {"version":3,"file":"d-dialog.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-dialog.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAS,SAAS,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAyC,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,MAAM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rC,IAAI,CAAC,SAAS,EAAE,CAAC;aACjB;SACD;QACD,OAAO,iBAAM,SAAS,YAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAES,2BAAS,GAAnB;QACC,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;IAES,qCAAmB,GAA7B,UAA8B,KAAY;QACzC,QAAQ,IAAI,CAAC,KAAK,EAAE;YACnB,KAAK,WAAW,CAAC,KAAK,CAAC;YACvB,KAAK,WAAW,CAAC,IAAI;gBACpB,OAAO,IAAI,CAAC;YACb,KAAK,WAAW,CAAC,QAAQ;gBACxB,OAAO,iBAAM,mBAAmB,YAAC,KAAK,CAAC,CAAC;SACzC;IACF,CAAC;IAES,yBAAO,GAAjB;QACC,OAAO,SAAS,CAAC;IAClB,CAAC;IACF,cAAC;AAAD,CAAC,AAxdD,CAIU,KAAK,GAodd","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { Point, Rectangle } from \"pixi.js\";\nimport { DAnimation } from \"./d-animation\";\nimport { DApplicationLayerLike } from \"./d-application-layer-like\";\nimport { DApplications } from \"./d-applications\";\nimport { DBase, DBaseEvents, DBaseOptions, DThemeBase } from \"./d-base\";\nimport { DBaseState } from \"./d-base-state\";\nimport { DControllerFocus, DFocusable } from \"./d-controller-focus\";\nimport { DDialogAlign } from \"./d-dialog-align\";\nimport { DDialogCloseOn } from \"./d-dialog-close-on\";\nimport { DDialogGesture, DDialogGestureOptions } from \"./d-dialog-gesture\";\nimport { DDialogGestureImpl } from \"./d-dialog-gesture-impl\";\nimport { DDialogGestureMode } from \"./d-dialog-gesture-mode\";\nimport { DDialogMode } from \"./d-dialog-mode\";\nimport { DDialogState } from \"./d-dialog-state\";\nimport { DOnOptions } from \"./d-on-options\";\nimport { DPadding } from \"./d-padding\";\nimport { isArray } from \"./util/is-array\";\nimport { isString } from \"./util/is-string\";\nimport { toEnum } from \"./util/to-enum\";\nimport { UtilAttach } from \"./util/util-attach\";\nimport { UtilClickOutside } from \"./util/util-click-outside\";\nimport { UtilKeyboardEvent } from \"./util/util-keyboard-event\";\nimport { UtilOverlay } from \"./util/util-overlay\";\nimport { DApplicationTarget } from \"./d-application-like\";\n\n/**\n * {@link DDialog} events.\n */\nexport interface DDialogEvents<EMITTER> extends DBaseEvents<EMITTER> {\n\t/**\n\t * Triggered when a dialog is opened.\n\t *\n\t * @param emitter this\n\t */\n\topen(emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when a dialog is closed.\n\t *\n\t * @param emitter this\n\t */\n\tclose(emitter: EMITTER): void;\n}\n\n/**\n * {@link DDialog} `on` options.\n */\nexport interface DDialogOnOptions<EMITTER> extends Partial<DDialogEvents<EMITTER>>, DOnOptions {}\n\n/**\n * {@link DDialog} options.\n */\nexport interface DDialogOptions<THEME extends DThemeDialog = DThemeDialog, EMITTER = any>\n\textends DBaseOptions<THEME> {\n\tcloseOn?: DDialogCloseOn | Array<keyof typeof DDialogCloseOn> | keyof typeof DDialogCloseOn;\n\n\tanimation?: DAnimation<DBase>;\n\n\t/**\n\t * A dialog mode.\n\t */\n\tmode?: DDialogMode | keyof typeof DDialogMode;\n\n\talwaysOnTop?: boolean;\n\n\tsticky?: boolean;\n\n\tgesture?: boolean | DDialogGestureOptions;\n\n\talign?: DDialogAlign | null | keyof typeof DDialogAlign;\n\n\t/**\n\t * Mappings of event names and handlers.\n\t */\n\ton?: DDialogOnOptions<EMITTER>;\n}\n\n/**\n * {@link DDialog} theme.\n */\nexport interface DThemeDialog extends DThemeBase {\n\tgetMode(): DDialogMode;\n\tcloseOn(mode: DDialogMode): DDialogCloseOn;\n\tisSticky(mode: DDialogMode): boolean;\n\tisAlwaysOnTop(): boolean;\n\tisGestureEnabled(mode: DDialogMode): boolean;\n\tgetGestureMode(mode: DDialogMode): DDialogGestureMode;\n\tgetOffsetX(mode: DDialogMode): number;\n\tgetOffsetY(mode: DDialogMode): number;\n\tgetAlign(mode: DDialogMode): DDialogAlign | null;\n\tnewAnimation(mode: DDialogMode): DAnimation<DBase> | null;\n}\n\nexport interface DDialogOpener extends DApplicationTarget {\n\tgetBounds(skipUpdate?: boolean, rect?: Rectangle): Rectangle;\n}\n\n/**\n * A dialog class.\n *\n * If multiple application instances are there, better to set the constructor\n * option `parent` to an `application.stage` so that the dialog picks a right\n * application. `DDialog` searches applications in a following order:\n *\n * * To begin, `DDialog` tries to find applications which it belongs to.\n * * If `DDialog` can't find applications, then `DDialog` tries to find applications which openers belong to.\n * * If openers are not given, `DDialog` assumes the last created application at the very moment `DDialog` is instantiated is the one it belongs to.\n */\nexport class DDialog<\n\tVALUE = void,\n\tTHEME extends DThemeDialog = DThemeDialog,\n\tOPTIONS extends DDialogOptions<THEME> = DDialogOptions<THEME>\n> extends DBase<THEME, OPTIONS> {\n\tprotected static WORK_BOUNDS?: Rectangle;\n\n\tprotected _promise?: Promise<VALUE>;\n\tprotected _resolve?: (value: VALUE | PromiseLike<VALUE>) => void;\n\tprotected _reject?: (reason?: any) => void;\n\n\tprotected _animation?: DAnimation<DBase> | null;\n\tprotected _closeOn!: DDialogCloseOn;\n\tprotected _focused?: DFocusable | null;\n\tprotected _overlay!: UtilOverlay;\n\tprotected _mode!: DDialogMode;\n\tprotected _alwaysOnTop!: boolean;\n\tprotected _onParentChildAddedBound?: () => void;\n\tprotected _sticky!: boolean;\n\tprotected _onPrerenderBound!: () => void;\n\tprotected _align!: DDialogAlign | null;\n\tprotected _opener?: DDialogOpener | null;\n\n\tprotected _gesture!: DDialogGesture<this>;\n\tprotected _layer!: DApplicationLayerLike | null;\n\n\tprotected init(options?: OPTIONS): void {\n\t\tsuper.init(options);\n\n\t\tthis._onPrerenderBound = (): void => {\n\t\t\tthis.onPrerender();\n\t\t};\n\t\tthis._layer = null;\n\n\t\t// Mode\n\t\tconst theme = this.theme;\n\t\tconst mode = toEnum(options?.mode ?? theme.getMode(), DDialogMode);\n\t\tthis._mode = mode;\n\n\t\t// Always On Top\n\t\tthis._alwaysOnTop = options?.alwaysOnTop ?? theme.isAlwaysOnTop();\n\n\t\t// Sticky\n\t\tthis._sticky = options?.sticky ?? theme.isSticky(mode);\n\n\t\t// Close On\n\t\tconst closeOn = this.toCloseOn(mode, theme, options);\n\t\tthis._closeOn = closeOn;\n\n\t\t// Align\n\t\tthis._align = this.toAlign(mode, theme, options);\n\n\t\t// Overlay\n\t\tthis._overlay = new UtilOverlay();\n\n\t\t// Gesture\n\t\tthis._gesture = new DDialogGestureImpl(this, this.toGestureOptions(mode, theme, options));\n\n\t\t// Visibility\n\t\tthis.visible = false;\n\n\t\t// State\n\t\tswitch (mode) {\n\t\t\tcase DDialogMode.MODAL:\n\t\t\t\tthis.state.addAll(DBaseState.FOCUS_ROOT, DDialogState.MODAL);\n\t\t\t\tbreak;\n\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\tthis.state.add(DDialogState.MODELESS);\n\t\t\t\tbreak;\n\t\t\tcase DDialogMode.MENU:\n\t\t\t\tthis.state.addAll(DBaseState.FOCUS_ROOT, DDialogState.MENU);\n\t\t\t\tbreak;\n\t\t}\n\n\t\t// Outside-click handling\n\t\tif (closeOn & DDialogCloseOn.CLICK_OUTSIDE) {\n\t\t\tUtilClickOutside.apply(this, (): void => {\n\t\t\t\tthis.onCloseOn();\n\t\t\t});\n\t\t}\n\t}\n\n\tprotected toCloseOn(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogCloseOn {\n\t\tconst closeOn = options?.closeOn;\n\t\tif (closeOn == null) {\n\t\t\treturn theme.closeOn(mode);\n\t\t} else if (isArray(closeOn)) {\n\t\t\tlet result = DDialogCloseOn.NONE;\n\t\t\tfor (let i = 0, imax = closeOn.length; i < imax; ++i) {\n\t\t\t\tresult |= DDialogCloseOn[closeOn[i]];\n\t\t\t}\n\t\t\treturn result;\n\t\t} else if (isString(closeOn)) {\n\t\t\treturn DDialogCloseOn[closeOn];\n\t\t}\n\t\treturn closeOn;\n\t}\n\n\tprotected toAlign(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogAlign | null {\n\t\tconst align = options?.align;\n\t\tif (align === null) {\n\t\t\treturn null;\n\t\t} else if (align === undefined) {\n\t\t\treturn theme.getAlign(mode);\n\t\t} else {\n\t\t\treturn toEnum(align, DDialogAlign);\n\t\t}\n\t}\n\n\tget mode(): DDialogMode {\n\t\treturn this._mode;\n\t}\n\n\tget align(): DDialogAlign | null {\n\t\treturn this._align;\n\t}\n\n\tset algin(align: DDialogAlign | null) {\n\t\tthis._align = align;\n\t}\n\n\tget alwaysOnTop(): boolean {\n\t\treturn this._alwaysOnTop;\n\t}\n\n\tset alwaysOnTop(alwaysOnTop: boolean) {\n\t\tthis._alwaysOnTop = alwaysOnTop;\n\t}\n\n\tget gesture(): DDialogGesture<this> {\n\t\treturn this._gesture;\n\t}\n\n\tget layer(): DApplicationLayerLike | null {\n\t\treturn this._layer;\n\t}\n\n\tprotected toGestureOptions(\n\t\tmode: DDialogMode,\n\t\ttheme: THEME,\n\t\toptions?: OPTIONS\n\t): DDialogGestureOptions {\n\t\tconst gesture = options?.gesture;\n\t\tif (gesture === true) {\n\t\t\treturn {\n\t\t\t\tenable: true,\n\t\t\t\tmode: theme.getGestureMode(mode)\n\t\t\t};\n\t\t} else if (gesture === false) {\n\t\t\treturn {\n\t\t\t\tenable: false,\n\t\t\t\tmode: theme.getGestureMode(mode)\n\t\t\t};\n\t\t} else if (gesture != null) {\n\t\t\tif (gesture.enable === undefined) {\n\t\t\t\tgesture.enable = theme.isGestureEnabled(mode);\n\t\t\t}\n\t\t\tif (gesture.mode === undefined) {\n\t\t\t\tgesture.mode = theme.getGestureMode(mode);\n\t\t\t}\n\t\t\treturn gesture;\n\t\t}\n\t\treturn {\n\t\t\tenable: theme.isGestureEnabled(mode),\n\t\t\tmode: theme.getGestureMode(mode)\n\t\t};\n\t}\n\n\tonParentResize(parentWidth: number, parentHeight: number, parentPadding: DPadding): void {\n\t\tif (this.isOpened()) {\n\t\t\tconst layer = this._layer;\n\t\t\tif (layer != null) {\n\t\t\t\tconst gesture = this._gesture;\n\t\t\t\tif (gesture.isDirty()) {\n\t\t\t\t\tconst position = this.position;\n\t\t\t\t\tgesture.constraint(this, layer, position.x, position.y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsuper.onParentResize(parentWidth, parentHeight, parentPadding);\n\t}\n\n\tprotected getAnimation(): DAnimation | null {\n\t\tlet result = this._animation;\n\t\tif (result === undefined) {\n\t\t\tresult = this._options?.animation ?? this.theme.newAnimation(this._mode);\n\t\t\tif (result) {\n\t\t\t\tresult.target = this;\n\t\t\t\tresult.on(\"end\", (isReverse: boolean): void => {\n\t\t\t\t\tthis.onAnimationEnd(isReverse);\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis._animation = result;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected onAnimationEnd(isReverse: boolean): void {\n\t\tif (isReverse) {\n\t\t\tif (this._mode === DDialogMode.MODELESS) {\n\t\t\t\tthis.hide();\n\t\t\t} else {\n\t\t\t\tconst parent = this.parent;\n\t\t\t\tif (parent) {\n\t\t\t\t\tparent.removeChild(this);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst layer = DApplications.getLayer(this);\n\t\t\tif (layer) {\n\t\t\t\tconst focusController = layer.getFocusController();\n\t\t\t\tthis._focused = focusController.get();\n\t\t\t\tfocusController.focus(this.findFirstFocusable(focusController) || this);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected findFirstFocusable(focusController: DControllerFocus): DFocusable | null {\n\t\treturn focusController.find(this, false, true, true);\n\t}\n\n\t/**\n\t * Opens a dialog.\n\t *\n\t * @param opener An opener of a dialog.\n\t * The dialog position is determined based on a position and a size of the opener.\n\t * If the opener is undefined, the dialog is placed at the center of the screen.\n\t *\n\t * @returns a value of this dialog\n\t */\n\topen(opener?: DDialogOpener): Promise<VALUE> {\n\t\tlet result = this._promise;\n\t\tif (result == null) {\n\t\t\tresult = new Promise<VALUE>((resolve, reject): void => {\n\t\t\t\tthis._resolve = resolve;\n\t\t\t\tthis._reject = reject;\n\t\t\t});\n\t\t\tthis._promise = result;\n\n\t\t\tthis._opener = opener;\n\n\t\t\t// Attach to a layer\n\t\t\tlet layer: DApplicationLayerLike | null = null;\n\t\t\tswitch (this._mode) {\n\t\t\t\tcase DDialogMode.MODAL:\n\t\t\t\tcase DDialogMode.MENU:\n\t\t\t\t\tlayer = this._overlay.pick(this, opener);\n\t\t\t\t\tlayer.stage.addChild(this);\n\t\t\t\t\tbreak;\n\t\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\t\tlayer = DApplications.getLayer(this);\n\t\t\t\t\tthis.show();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis._layer = layer;\n\n\t\t\t// Position & size\n\t\t\tconst gesture = this._gesture;\n\t\t\tif (gesture.mode === DDialogGestureMode.CLEAN) {\n\t\t\t\tgesture.toClean();\n\t\t\t}\n\t\t\tif (layer != null) {\n\t\t\t\tif (gesture.isClean()) {\n\t\t\t\t\tconst renderer = layer.renderer;\n\t\t\t\t\tconst onPrerenderBound = this._onPrerenderBound;\n\t\t\t\t\tif (this._sticky) {\n\t\t\t\t\t\trenderer.on(\"prerender\", onPrerenderBound);\n\t\t\t\t\t} else {\n\t\t\t\t\t\trenderer.once(\"prerender\", onPrerenderBound);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst position = this.position;\n\t\t\t\t\tgesture.constraint(this, layer, position.x, position.y);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Bring To Front\n\t\t\tthis.bringToFront();\n\n\t\t\t// Done\n\t\t\tthis.onOpen();\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override onChildFocus(focused: DBase): void {\n\t\tsuper.onChildFocus(focused);\n\t\tthis.bringToFront();\n\t}\n\n\tprotected override onFocus(): void {\n\t\tsuper.onFocus();\n\t\tthis.bringToFront();\n\t}\n\n\tprotected bringToFront(): void {\n\t\tconst parent = this.parent;\n\t\tif (parent == null) {\n\t\t\treturn;\n\t\t}\n\t\tconst children = parent.children;\n\t\tconst childrenLength = children.length;\n\t\tlet index = childrenLength - 1;\n\t\tfor (; 0 <= index; --index) {\n\t\t\tif (children[index] === this) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (index < 0) {\n\t\t\treturn;\n\t\t}\n\t\tfor (let i = index + 1; i < childrenLength; ++i) {\n\t\t\tchildren[i - 1] = children[i];\n\t\t}\n\t\tchildren[childrenLength - 1] = this;\n\t\tchildren.sort((a, b) => {\n\t\t\treturn (\n\t\t\t\t(a instanceof DDialog ? (a._alwaysOnTop ? 2 : 1) : 0) -\n\t\t\t\t(b instanceof DDialog ? (b._alwaysOnTop ? 2 : 1) : 0)\n\t\t\t);\n\t\t});\n\t}\n\n\tprotected onPrerender(): void {\n\t\tconst layer = this._layer;\n\t\tif (layer == null) {\n\t\t\treturn;\n\t\t}\n\t\tconst align = this._align;\n\t\tif (align === DDialogAlign.NONE) {\n\t\t\treturn;\n\t\t}\n\t\tconst opener = this._opener;\n\t\tif (align != null && opener != null) {\n\t\t\tconst mode = this._mode;\n\t\t\tconst bounds = opener.getBounds(false, (DDialog.WORK_BOUNDS ??= new Rectangle()));\n\t\t\tconst theme = this.theme;\n\t\t\tUtilAttach.attach(\n\t\t\t\tthis,\n\t\t\t\tbounds,\n\t\t\t\ttheme.getOffsetX(mode),\n\t\t\t\ttheme.getOffsetY(mode),\n\t\t\t\tlayer.width,\n\t\t\t\tlayer.height,\n\t\t\t\talign\n\t\t\t);\n\t\t} else {\n\t\t\tthis.position.set((layer.width - this.width) * 0.5, (layer.height - this.height) * 0.5);\n\t\t}\n\t}\n\n\tprotected onOpen(): void {\n\t\tthis.emit(\"open\", this);\n\n\t\t// Animation\n\t\tconst animation = this.getAnimation();\n\t\tif (animation) {\n\t\t\tanimation.start();\n\t\t} else if (this._mode === DDialogMode.MENU) {\n\t\t\tthis.visible = true;\n\t\t\tthis.onAnimationEnd(false);\n\t\t}\n\t}\n\n\tisOpened(): boolean {\n\t\treturn this._promise != null;\n\t}\n\n\tclose(): void {\n\t\tthis.doReject();\n\t}\n\n\tprotected doResolve(value: VALUE | PromiseLike<VALUE>): void {\n\t\tconst resolve = this._resolve;\n\t\tif (resolve) {\n\t\t\tthis._promise = undefined;\n\t\t\tthis._resolve = undefined;\n\t\t\tthis._reject = undefined;\n\n\t\t\tthis.onClose();\n\n\t\t\tresolve(value);\n\t\t}\n\t}\n\n\tprotected doReject(reason?: any): void {\n\t\tconst reject = this._reject;\n\t\tif (reject) {\n\t\t\tthis._promise = undefined;\n\t\t\tthis._resolve = undefined;\n\t\t\tthis._reject = undefined;\n\n\t\t\tthis.onClose();\n\n\t\t\treject(reason);\n\t\t}\n\t}\n\n\tprotected onClose(): void {\n\t\t// Focus\n\t\tconst layer = this._layer;\n\t\tconst focused = this._focused;\n\t\tif (focused != null) {\n\t\t\tthis._focused = null;\n\t\t\tif (layer) {\n\t\t\t\tconst focusedLayer = DApplications.getLayer(focused);\n\t\t\t\tif (focusedLayer != null && layer !== focusedLayer) {\n\t\t\t\t\tfocusedLayer.view.focus();\n\t\t\t\t}\n\t\t\t\tlayer.getFocusController().focus(focused);\n\t\t\t} else {\n\t\t\t\tthis.blur(true);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.blur(true);\n\t\t}\n\n\t\t// Remove the prerender event handler and forget the layer\n\t\tif (layer) {\n\t\t\tlayer.renderer.off(\"prerender\", this._onPrerenderBound);\n\t\t\tthis._layer = null;\n\t\t}\n\n\t\t// Forget the opener\n\t\tthis._opener = null;\n\n\t\t// Animation\n\t\tconst animation = this.getAnimation();\n\t\tif (animation) {\n\t\t\tanimation.start(true);\n\t\t} else {\n\t\t\tthis.visible = false;\n\t\t\tthis.onAnimationEnd(true);\n\t\t}\n\n\t\t// Always On Top\n\t\tif (this._alwaysOnTop) {\n\t\t\tconst parent = this.parent;\n\t\t\tif (parent != null) {\n\t\t\t\tparent.off(\"childAdded\", this._onParentChildAddedBound);\n\t\t\t}\n\t\t}\n\n\t\tthis.emit(\"close\", this);\n\t}\n\n\tprotected onKeyDown(e: KeyboardEvent): boolean {\n\t\tif (this._closeOn & DDialogCloseOn.ESC) {\n\t\t\tif (UtilKeyboardEvent.isCancelKey(e)) {\n\t\t\t\tthis.onCloseOn();\n\t\t\t}\n\t\t}\n\t\treturn super.onKeyDown(e);\n\t}\n\n\tprotected onCloseOn(): void {\n\t\tthis.close();\n\t}\n\n\tprotected containsGlobalPoint(point: Point): boolean {\n\t\tswitch (this._mode) {\n\t\t\tcase DDialogMode.MODAL:\n\t\t\tcase DDialogMode.MENU:\n\t\t\t\treturn true;\n\t\t\tcase DDialogMode.MODELESS:\n\t\t\t\treturn super.containsGlobalPoint(point);\n\t\t}\n\t}\n\n\tprotected getType(): string {\n\t\treturn \"DDialog\";\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -30626,7 +30626,6 @@ var DDialog = /** @class */ (function (_super) {
30626
30626
  */
30627
30627
  DDialog.prototype.open = function (opener) {
30628
30628
  var _this = this;
30629
- var _a;
30630
30629
  var result = this._promise;
30631
30630
  if (result == null) {
30632
30631
  result = new Promise(function (resolve, reject) {
@@ -30670,36 +30669,45 @@ var DDialog = /** @class */ (function (_super) {
30670
30669
  gesture.constraint(this, layer, position.x, position.y);
30671
30670
  }
30672
30671
  }
30673
- // Always On Top
30674
- if (this._alwaysOnTop) {
30675
- var parent_2 = this.parent;
30676
- if (parent_2 != null) {
30677
- parent_2.on("childAdded", ((_a = this._onParentChildAddedBound) !== null && _a !== void 0 ? _a : (this._onParentChildAddedBound = function () {
30678
- _this.onParentChildAdded();
30679
- })));
30680
- this.onParentChildAdded();
30681
- }
30682
- }
30672
+ // Bring To Front
30673
+ this.bringToFront();
30683
30674
  // Done
30684
30675
  this.onOpen();
30685
30676
  }
30686
30677
  return result;
30687
30678
  };
30688
- DDialog.prototype.onParentChildAdded = function () {
30679
+ DDialog.prototype.onChildFocus = function (focused) {
30680
+ _super.prototype.onChildFocus.call(this, focused);
30681
+ this.bringToFront();
30682
+ };
30683
+ DDialog.prototype.onFocus = function () {
30684
+ _super.prototype.onFocus.call(this);
30685
+ this.bringToFront();
30686
+ };
30687
+ DDialog.prototype.bringToFront = function () {
30689
30688
  var parent = this.parent;
30690
- if (parent != null) {
30691
- parent.children.sort(this.compareAlwaysOnTop);
30689
+ if (parent == null) {
30690
+ return;
30692
30691
  }
30693
- };
30694
- DDialog.prototype.compareAlwaysOnTop = function (a, b) {
30695
- var at = a instanceof DDialog && a.alwaysOnTop;
30696
- var bt = b instanceof DDialog && b.alwaysOnTop;
30697
- if (at) {
30698
- return bt ? 0 : +1;
30692
+ var children = parent.children;
30693
+ var childrenLength = children.length;
30694
+ var index = childrenLength - 1;
30695
+ for (; 0 <= index; --index) {
30696
+ if (children[index] === this) {
30697
+ break;
30698
+ }
30699
30699
  }
30700
- else {
30701
- return bt ? -1 : 0;
30700
+ if (index < 0) {
30701
+ return;
30702
+ }
30703
+ for (var i = index + 1; i < childrenLength; ++i) {
30704
+ children[i - 1] = children[i];
30702
30705
  }
30706
+ children[childrenLength - 1] = this;
30707
+ children.sort(function (a, b) {
30708
+ return ((a instanceof DDialog ? (a._alwaysOnTop ? 2 : 1) : 0) -
30709
+ (b instanceof DDialog ? (b._alwaysOnTop ? 2 : 1) : 0));
30710
+ });
30703
30711
  };
30704
30712
  DDialog.prototype.onPrerender = function () {
30705
30713
  var _a;
@@ -30798,9 +30806,9 @@ var DDialog = /** @class */ (function (_super) {
30798
30806
  }
30799
30807
  // Always On Top
30800
30808
  if (this._alwaysOnTop) {
30801
- var parent_3 = this.parent;
30802
- if (parent_3 != null) {
30803
- parent_3.off("childAdded", this._onParentChildAddedBound);
30809
+ var parent_2 = this.parent;
30810
+ if (parent_2 != null) {
30811
+ parent_2.off("childAdded", this._onParentChildAddedBound);
30804
30812
  }
30805
30813
  }
30806
30814
  this.emit("close", this);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.447.0
2
+ Winter Cardinal UI v0.448.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -30623,7 +30623,6 @@
30623
30623
  */
30624
30624
  DDialog.prototype.open = function (opener) {
30625
30625
  var _this = this;
30626
- var _a;
30627
30626
  var result = this._promise;
30628
30627
  if (result == null) {
30629
30628
  result = new Promise(function (resolve, reject) {
@@ -30667,36 +30666,45 @@
30667
30666
  gesture.constraint(this, layer, position.x, position.y);
30668
30667
  }
30669
30668
  }
30670
- // Always On Top
30671
- if (this._alwaysOnTop) {
30672
- var parent_2 = this.parent;
30673
- if (parent_2 != null) {
30674
- parent_2.on("childAdded", ((_a = this._onParentChildAddedBound) !== null && _a !== void 0 ? _a : (this._onParentChildAddedBound = function () {
30675
- _this.onParentChildAdded();
30676
- })));
30677
- this.onParentChildAdded();
30678
- }
30679
- }
30669
+ // Bring To Front
30670
+ this.bringToFront();
30680
30671
  // Done
30681
30672
  this.onOpen();
30682
30673
  }
30683
30674
  return result;
30684
30675
  };
30685
- DDialog.prototype.onParentChildAdded = function () {
30676
+ DDialog.prototype.onChildFocus = function (focused) {
30677
+ _super.prototype.onChildFocus.call(this, focused);
30678
+ this.bringToFront();
30679
+ };
30680
+ DDialog.prototype.onFocus = function () {
30681
+ _super.prototype.onFocus.call(this);
30682
+ this.bringToFront();
30683
+ };
30684
+ DDialog.prototype.bringToFront = function () {
30686
30685
  var parent = this.parent;
30687
- if (parent != null) {
30688
- parent.children.sort(this.compareAlwaysOnTop);
30686
+ if (parent == null) {
30687
+ return;
30689
30688
  }
30690
- };
30691
- DDialog.prototype.compareAlwaysOnTop = function (a, b) {
30692
- var at = a instanceof DDialog && a.alwaysOnTop;
30693
- var bt = b instanceof DDialog && b.alwaysOnTop;
30694
- if (at) {
30695
- return bt ? 0 : +1;
30689
+ var children = parent.children;
30690
+ var childrenLength = children.length;
30691
+ var index = childrenLength - 1;
30692
+ for (; 0 <= index; --index) {
30693
+ if (children[index] === this) {
30694
+ break;
30695
+ }
30696
30696
  }
30697
- else {
30698
- return bt ? -1 : 0;
30697
+ if (index < 0) {
30698
+ return;
30699
+ }
30700
+ for (var i = index + 1; i < childrenLength; ++i) {
30701
+ children[i - 1] = children[i];
30699
30702
  }
30703
+ children[childrenLength - 1] = this;
30704
+ children.sort(function (a, b) {
30705
+ return ((a instanceof DDialog ? (a._alwaysOnTop ? 2 : 1) : 0) -
30706
+ (b instanceof DDialog ? (b._alwaysOnTop ? 2 : 1) : 0));
30707
+ });
30700
30708
  };
30701
30709
  DDialog.prototype.onPrerender = function () {
30702
30710
  var _a;
@@ -30795,9 +30803,9 @@
30795
30803
  }
30796
30804
  // Always On Top
30797
30805
  if (this._alwaysOnTop) {
30798
- var parent_3 = this.parent;
30799
- if (parent_3 != null) {
30800
- parent_3.off("childAdded", this._onParentChildAddedBound);
30806
+ var parent_2 = this.parent;
30807
+ if (parent_2 != null) {
30808
+ parent_2.off("childAdded", this._onParentChildAddedBound);
30801
30809
  }
30802
30810
  }
30803
30811
  this.emit("close", this);