@wcardinal/wcardinal-ui 0.407.0 → 0.407.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wcardinal/ui/d-text-piece-impl.js +1 -1
- package/dist/wcardinal/ui/d-text-piece-impl.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
- package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
- package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +2 -2
- package/dist/wcardinal-ui.js +2 -2
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -174,7 +174,7 @@ var DTextPieceImpl = /** @class */ (function (_super) {
|
|
|
174
174
|
DTextPieceImpl.prototype.updateObject = function () {
|
|
175
175
|
var computed = this._computed;
|
|
176
176
|
if (computed !== undefined) {
|
|
177
|
-
var formatted = this._formatter(computed, this);
|
|
177
|
+
var formatted = this._formatter(computed, this._parent);
|
|
178
178
|
var object = this._object;
|
|
179
179
|
if (object == null) {
|
|
180
180
|
if (0 < formatted.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-text-piece-impl.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-text-piece-impl.ts"],"names":[],"mappings":";AAAA,OAAO,EAA2B,KAAK,EA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S5D","sourcesContent":["import { DisplayObject, Graphics, utils } from \"pixi.js\";\nimport { DBaseStateSet } from \"./d-base-state-set\";\nimport { DDynamicText } from \"./d-dynamic-text\";\nimport { DDynamicTextStyle } from \"./d-dynamic-text-style\";\nimport { DStateAwareOrValueMightBe } from \"./d-state-aware\";\nimport { isFunction } from \"./util/is-function\";\nimport { DApplications } from \"./d-applications\";\nimport { DImagePieceLayouter } from \"./d-image-piece-layouter\";\nimport {\n\tDTextPiece,\n\tDTextPieceFormatter,\n\tDTextPieceOptions,\n\tDThemeTextPiece\n} from \"./d-text-piece\";\nimport { DApplicationTarget } from \"./d-application-like\";\nimport { DTextPieceAlign } from \"./d-text-piece-align\";\nimport { DTextPieceAlignImpl } from \"./d-text-piece-align-impl\";\nimport { DTextPieceStyle } from \"./d-text-piece-style\";\nimport { DTextPieceStyleImpl } from \"./d-text-piece-style-impl\";\n\nexport interface DTextPieceImplParent extends DApplicationTarget {\n\treadonly state: DBaseStateSet;\n\taddChild(displayObject: DisplayObject): void;\n\tremoveChild(displayObject: DisplayObject): void;\n\ttoDirty(): void;\n\tgetOverflowMask(): Graphics | null;\n}\n\nexport class DTextPieceImpl<VALUE> extends utils.EventEmitter implements DTextPiece<VALUE> {\n\tprotected _parent: DTextPieceImplParent;\n\tprotected _theme: DThemeTextPiece<VALUE>;\n\tprotected _object?: DDynamicText | null;\n\tprotected _value?: DStateAwareOrValueMightBe<VALUE>;\n\tprotected _computed?: VALUE;\n\tprotected _color: DStateAwareOrValueMightBe<number>;\n\tprotected _alpha: DStateAwareOrValueMightBe<number>;\n\tprotected _style: DTextPieceStyleImpl;\n\tprotected _dstyle: DDynamicTextStyle;\n\tprotected _align: DTextPieceAlign;\n\tprotected _formatter: DTextPieceFormatter<VALUE>;\n\tprotected _isVisible: boolean;\n\n\tconstructor(\n\t\tparent: DTextPieceImplParent,\n\t\ttheme: DThemeTextPiece<VALUE>,\n\t\toptions?: DTextPieceOptions<VALUE> | undefined\n\t) {\n\t\tsuper();\n\t\tthis._parent = parent;\n\t\tthis._theme = theme;\n\t\tthis._value = options?.value ?? theme.newTextValue();\n\t\tthis._computed = this.newComputed();\n\t\tthis._color = options?.color;\n\t\tthis._alpha = options?.alpha;\n\t\tconst dstyle = new DDynamicTextStyle(parent, theme, options?.style);\n\t\tthis._dstyle = dstyle;\n\t\tthis._style = new DTextPieceStyleImpl(parent, dstyle);\n\t\tthis._align = new DTextPieceAlignImpl(parent, theme, options?.align);\n\t\tthis._formatter = options?.formatter ?? theme.getTextFormatter();\n\t\tthis._isVisible = true;\n\t\tthis.onComputedChange();\n\t\tif (this.updateObject()) {\n\t\t\tparent.toDirty();\n\t\t\tDApplications.update(parent);\n\t\t}\n\t}\n\n\tget value(): DStateAwareOrValueMightBe<VALUE> {\n\t\treturn this._value;\n\t}\n\n\tset value(value: DStateAwareOrValueMightBe<VALUE>) {\n\t\tif (this._value !== value) {\n\t\t\tthis._value = value;\n\t\t\tthis.onValueChange();\n\t\t}\n\t}\n\n\tgetValue(): DStateAwareOrValueMightBe<VALUE> {\n\t\treturn this._value;\n\t}\n\n\tsetValue(value: DStateAwareOrValueMightBe<VALUE>, forcibly?: boolean): void {\n\t\tif (forcibly || this._value !== value) {\n\t\t\tthis._value = value;\n\t\t\tthis.onValueChange(forcibly);\n\t\t}\n\t}\n\n\tprotected onValueChange(forcibly?: boolean): void {\n\t\tconst newComputed = this.newComputed();\n\t\tif (forcibly || this._computed !== newComputed) {\n\t\t\tthis._computed = newComputed;\n\t\t\tthis.onComputedChange();\n\t\t\tif (this.updateObject()) {\n\t\t\t\tconst parent = this._parent;\n\t\t\t\tparent.toDirty();\n\t\t\t\tDApplications.update(parent);\n\t\t\t}\n\t\t}\n\t}\n\n\tcompute(forcibly?: boolean): void {\n\t\tthis.onValueChange(forcibly);\n\t}\n\n\tget computed(): VALUE | undefined {\n\t\treturn this._computed;\n\t}\n\n\tget formatter(): DTextPieceFormatter<VALUE> {\n\t\treturn this._formatter;\n\t}\n\n\tset formatter(formatter: DTextPieceFormatter<VALUE>) {\n\t\tif (this._formatter !== formatter) {\n\t\t\tthis._formatter = formatter;\n\t\t\tthis.onValueChange(true);\n\t\t}\n\t}\n\n\tget color(): DStateAwareOrValueMightBe<number> {\n\t\treturn this._color;\n\t}\n\n\tset color(color: DStateAwareOrValueMightBe<number>) {\n\t\tif (this._color !== color) {\n\t\t\tthis._color = color;\n\t\t\tthis.onColorChange();\n\t\t}\n\t}\n\n\tget alpha(): DStateAwareOrValueMightBe<number> {\n\t\treturn this._alpha;\n\t}\n\n\tset alpha(alpha: DStateAwareOrValueMightBe<number>) {\n\t\tif (this._alpha !== alpha) {\n\t\t\tthis._alpha = alpha;\n\t\t\tthis.onColorChange();\n\t\t}\n\t}\n\n\tprotected onColorChange(): void {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\tconst parent = this._parent;\n\t\t\tconst state = parent.state;\n\t\t\tconst color = this.newColor(state);\n\t\t\tconst alpha = this.newAlpha(state);\n\t\t\tconst style = object.style;\n\t\t\tif (style.fill !== color || object.alpha !== alpha) {\n\t\t\t\tstyle.fill = color;\n\t\t\t\tobject.alpha = alpha;\n\t\t\t\tDApplications.update(parent);\n\t\t\t}\n\t\t}\n\t}\n\n\tget align(): DTextPieceAlign {\n\t\treturn this._align;\n\t}\n\n\tget style(): DTextPieceStyle {\n\t\treturn this._style;\n\t}\n\n\tget object(): DDynamicText | null | undefined {\n\t\treturn this._object;\n\t}\n\n\tupdate(layouter: DImagePieceLayouter): void {\n\t\t// Compute a value\n\t\tconst newComputed = this.newComputed();\n\t\tif (this._computed !== newComputed) {\n\t\t\tthis._computed = newComputed;\n\t\t\tthis.onComputedChange();\n\t\t\tthis.updateObject();\n\t\t}\n\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\t// Update the color\n\t\t\tconst state = this._parent.state;\n\t\t\tobject.style.fill = this.newColor(state);\n\t\t\tobject.alpha = this.newAlpha(state);\n\n\t\t\t// Layout\n\t\t\tlayouter.set(object);\n\t\t} else {\n\t\t\t// Layout\n\t\t\tlayouter.set(null);\n\t\t}\n\t}\n\n\tprotected updateObject(): boolean {\n\t\tconst computed = this._computed;\n\t\tif (computed !== undefined) {\n\t\t\tconst formatted = this._formatter(computed, this);\n\t\t\tconst object = this._object;\n\t\t\tif (object == null) {\n\t\t\t\tif (0 < formatted.length) {\n\t\t\t\t\tconst newObject = this.newObject();\n\t\t\t\t\tnewObject.visible = this._isVisible;\n\t\t\t\t\tthis._object = newObject;\n\t\t\t\t\tconst parent = this._parent;\n\t\t\t\t\tparent.addChild(newObject);\n\t\t\t\t\tconst overflowMask = parent.getOverflowMask();\n\t\t\t\t\tif (overflowMask) {\n\t\t\t\t\t\tnewObject.mask = overflowMask;\n\t\t\t\t\t}\n\t\t\t\t\tnewObject.text = formatted;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else if (object.text !== formatted) {\n\t\t\t\tobject.text = formatted;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tconst object = this._object;\n\t\t\tif (object != null && object.text !== \"\") {\n\t\t\t\tobject.text = \"\";\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected newComputed(): VALUE | undefined {\n\t\tconst value = this._value;\n\t\tif (value !== undefined) {\n\t\t\tif (isFunction(value)) {\n\t\t\t\tconst result = value(this._parent.state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getTextValue(this._parent.state);\n\t}\n\n\tprotected newColor(state: DBaseStateSet): number {\n\t\tconst color = this._color;\n\t\tif (color !== undefined) {\n\t\t\tif (isFunction(color)) {\n\t\t\t\tconst result = color(state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getColor(state);\n\t}\n\n\tprotected newAlpha(state: DBaseStateSet): number {\n\t\tconst alpha = this._alpha;\n\t\tif (alpha !== undefined) {\n\t\t\tif (isFunction(alpha)) {\n\t\t\t\tconst result = alpha(state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn alpha;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getAlpha(state);\n\t}\n\n\tprotected newObject(): DDynamicText {\n\t\treturn new DDynamicText(this._dstyle);\n\t}\n\n\tget visible(): boolean {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\treturn object.visible;\n\t\t}\n\t\treturn this._isVisible;\n\t}\n\n\tset visible(visible: boolean) {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\tobject.visible = visible;\n\t\t}\n\t\tthis._isVisible = visible;\n\t}\n\n\tshow(): this {\n\t\tthis.visible = true;\n\t\treturn this;\n\t}\n\n\thide(): this {\n\t\tthis.visible = false;\n\t\treturn this;\n\t}\n\n\tisShown(): boolean {\n\t\treturn this.visible;\n\t}\n\n\tprotected onComputedChange(): void {\n\t\tthis.emit(\"change\", this);\n\t}\n\n\tdestroy(): this {\n\t\tconst object = this._object;\n\t\tif (object) {\n\t\t\tthis._object = undefined;\n\t\t\tobject.destroy();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-text-piece-impl.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-text-piece-impl.ts"],"names":[],"mappings":";AAAA,OAAO,EAA2B,KAAK,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUjD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AAX;YACC,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5B,IAAI,MAAM,IAAI,IAAI,EAAE;gBACnB,OAAO,MAAM,CAAC,OAAO,CAAC;aACtB;YACD,OAAO,IAAI,CAAC,UAAU,CAAC;QACxB,CAAC;aAED,UAAY,OAAgB;YAC3B,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;YAC5B,IAAI,MAAM,IAAI,IAAI,EAAE;gBACnB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;aACzB;YACD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;QAC3B,CAAC;;;OARA;IAUD,6BAAI,GAAJ;QACC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6BAAI,GAAJ;QACC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,gCAAO,GAAP;QACC,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAES,yCAAgB,GAA1B;QACC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,gCAAO,GAAP;QACC,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACzB,MAAM,CAAC,OAAO,EAAE,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IACF,qBAAC;AAAD,CAAC,AApSD,CAA2C,KAAK,CAAC,YAAY,GAoS5D","sourcesContent":["import { DisplayObject, Graphics, utils } from \"pixi.js\";\nimport { DBaseStateSet } from \"./d-base-state-set\";\nimport { DDynamicText } from \"./d-dynamic-text\";\nimport { DDynamicTextStyle } from \"./d-dynamic-text-style\";\nimport { DStateAwareOrValueMightBe } from \"./d-state-aware\";\nimport { isFunction } from \"./util/is-function\";\nimport { DApplications } from \"./d-applications\";\nimport { DImagePieceLayouter } from \"./d-image-piece-layouter\";\nimport {\n\tDTextPiece,\n\tDTextPieceFormatter,\n\tDTextPieceOptions,\n\tDThemeTextPiece\n} from \"./d-text-piece\";\nimport { DApplicationTarget } from \"./d-application-like\";\nimport { DTextPieceAlign } from \"./d-text-piece-align\";\nimport { DTextPieceAlignImpl } from \"./d-text-piece-align-impl\";\nimport { DTextPieceStyle } from \"./d-text-piece-style\";\nimport { DTextPieceStyleImpl } from \"./d-text-piece-style-impl\";\n\nexport interface DTextPieceImplParent extends DApplicationTarget {\n\treadonly state: DBaseStateSet;\n\taddChild(displayObject: DisplayObject): void;\n\tremoveChild(displayObject: DisplayObject): void;\n\ttoDirty(): void;\n\tgetOverflowMask(): Graphics | null;\n}\n\nexport class DTextPieceImpl<VALUE> extends utils.EventEmitter implements DTextPiece<VALUE> {\n\tprotected _parent: DTextPieceImplParent;\n\tprotected _theme: DThemeTextPiece<VALUE>;\n\tprotected _object?: DDynamicText | null;\n\tprotected _value?: DStateAwareOrValueMightBe<VALUE>;\n\tprotected _computed?: VALUE;\n\tprotected _color: DStateAwareOrValueMightBe<number>;\n\tprotected _alpha: DStateAwareOrValueMightBe<number>;\n\tprotected _style: DTextPieceStyleImpl;\n\tprotected _dstyle: DDynamicTextStyle;\n\tprotected _align: DTextPieceAlign;\n\tprotected _formatter: DTextPieceFormatter<VALUE>;\n\tprotected _isVisible: boolean;\n\n\tconstructor(\n\t\tparent: DTextPieceImplParent,\n\t\ttheme: DThemeTextPiece<VALUE>,\n\t\toptions?: DTextPieceOptions<VALUE> | undefined\n\t) {\n\t\tsuper();\n\t\tthis._parent = parent;\n\t\tthis._theme = theme;\n\t\tthis._value = options?.value ?? theme.newTextValue();\n\t\tthis._computed = this.newComputed();\n\t\tthis._color = options?.color;\n\t\tthis._alpha = options?.alpha;\n\t\tconst dstyle = new DDynamicTextStyle(parent, theme, options?.style);\n\t\tthis._dstyle = dstyle;\n\t\tthis._style = new DTextPieceStyleImpl(parent, dstyle);\n\t\tthis._align = new DTextPieceAlignImpl(parent, theme, options?.align);\n\t\tthis._formatter = options?.formatter ?? theme.getTextFormatter();\n\t\tthis._isVisible = true;\n\t\tthis.onComputedChange();\n\t\tif (this.updateObject()) {\n\t\t\tparent.toDirty();\n\t\t\tDApplications.update(parent);\n\t\t}\n\t}\n\n\tget value(): DStateAwareOrValueMightBe<VALUE> {\n\t\treturn this._value;\n\t}\n\n\tset value(value: DStateAwareOrValueMightBe<VALUE>) {\n\t\tif (this._value !== value) {\n\t\t\tthis._value = value;\n\t\t\tthis.onValueChange();\n\t\t}\n\t}\n\n\tgetValue(): DStateAwareOrValueMightBe<VALUE> {\n\t\treturn this._value;\n\t}\n\n\tsetValue(value: DStateAwareOrValueMightBe<VALUE>, forcibly?: boolean): void {\n\t\tif (forcibly || this._value !== value) {\n\t\t\tthis._value = value;\n\t\t\tthis.onValueChange(forcibly);\n\t\t}\n\t}\n\n\tprotected onValueChange(forcibly?: boolean): void {\n\t\tconst newComputed = this.newComputed();\n\t\tif (forcibly || this._computed !== newComputed) {\n\t\t\tthis._computed = newComputed;\n\t\t\tthis.onComputedChange();\n\t\t\tif (this.updateObject()) {\n\t\t\t\tconst parent = this._parent;\n\t\t\t\tparent.toDirty();\n\t\t\t\tDApplications.update(parent);\n\t\t\t}\n\t\t}\n\t}\n\n\tcompute(forcibly?: boolean): void {\n\t\tthis.onValueChange(forcibly);\n\t}\n\n\tget computed(): VALUE | undefined {\n\t\treturn this._computed;\n\t}\n\n\tget formatter(): DTextPieceFormatter<VALUE> {\n\t\treturn this._formatter;\n\t}\n\n\tset formatter(formatter: DTextPieceFormatter<VALUE>) {\n\t\tif (this._formatter !== formatter) {\n\t\t\tthis._formatter = formatter;\n\t\t\tthis.onValueChange(true);\n\t\t}\n\t}\n\n\tget color(): DStateAwareOrValueMightBe<number> {\n\t\treturn this._color;\n\t}\n\n\tset color(color: DStateAwareOrValueMightBe<number>) {\n\t\tif (this._color !== color) {\n\t\t\tthis._color = color;\n\t\t\tthis.onColorChange();\n\t\t}\n\t}\n\n\tget alpha(): DStateAwareOrValueMightBe<number> {\n\t\treturn this._alpha;\n\t}\n\n\tset alpha(alpha: DStateAwareOrValueMightBe<number>) {\n\t\tif (this._alpha !== alpha) {\n\t\t\tthis._alpha = alpha;\n\t\t\tthis.onColorChange();\n\t\t}\n\t}\n\n\tprotected onColorChange(): void {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\tconst parent = this._parent;\n\t\t\tconst state = parent.state;\n\t\t\tconst color = this.newColor(state);\n\t\t\tconst alpha = this.newAlpha(state);\n\t\t\tconst style = object.style;\n\t\t\tif (style.fill !== color || object.alpha !== alpha) {\n\t\t\t\tstyle.fill = color;\n\t\t\t\tobject.alpha = alpha;\n\t\t\t\tDApplications.update(parent);\n\t\t\t}\n\t\t}\n\t}\n\n\tget align(): DTextPieceAlign {\n\t\treturn this._align;\n\t}\n\n\tget style(): DTextPieceStyle {\n\t\treturn this._style;\n\t}\n\n\tget object(): DDynamicText | null | undefined {\n\t\treturn this._object;\n\t}\n\n\tupdate(layouter: DImagePieceLayouter): void {\n\t\t// Compute a value\n\t\tconst newComputed = this.newComputed();\n\t\tif (this._computed !== newComputed) {\n\t\t\tthis._computed = newComputed;\n\t\t\tthis.onComputedChange();\n\t\t\tthis.updateObject();\n\t\t}\n\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\t// Update the color\n\t\t\tconst state = this._parent.state;\n\t\t\tobject.style.fill = this.newColor(state);\n\t\t\tobject.alpha = this.newAlpha(state);\n\n\t\t\t// Layout\n\t\t\tlayouter.set(object);\n\t\t} else {\n\t\t\t// Layout\n\t\t\tlayouter.set(null);\n\t\t}\n\t}\n\n\tprotected updateObject(): boolean {\n\t\tconst computed = this._computed;\n\t\tif (computed !== undefined) {\n\t\t\tconst formatted = this._formatter(computed, this._parent);\n\t\t\tconst object = this._object;\n\t\t\tif (object == null) {\n\t\t\t\tif (0 < formatted.length) {\n\t\t\t\t\tconst newObject = this.newObject();\n\t\t\t\t\tnewObject.visible = this._isVisible;\n\t\t\t\t\tthis._object = newObject;\n\t\t\t\t\tconst parent = this._parent;\n\t\t\t\t\tparent.addChild(newObject);\n\t\t\t\t\tconst overflowMask = parent.getOverflowMask();\n\t\t\t\t\tif (overflowMask) {\n\t\t\t\t\t\tnewObject.mask = overflowMask;\n\t\t\t\t\t}\n\t\t\t\t\tnewObject.text = formatted;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else if (object.text !== formatted) {\n\t\t\t\tobject.text = formatted;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tconst object = this._object;\n\t\t\tif (object != null && object.text !== \"\") {\n\t\t\t\tobject.text = \"\";\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected newComputed(): VALUE | undefined {\n\t\tconst value = this._value;\n\t\tif (value !== undefined) {\n\t\t\tif (isFunction(value)) {\n\t\t\t\tconst result = value(this._parent.state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getTextValue(this._parent.state);\n\t}\n\n\tprotected newColor(state: DBaseStateSet): number {\n\t\tconst color = this._color;\n\t\tif (color !== undefined) {\n\t\t\tif (isFunction(color)) {\n\t\t\t\tconst result = color(state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn color;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getColor(state);\n\t}\n\n\tprotected newAlpha(state: DBaseStateSet): number {\n\t\tconst alpha = this._alpha;\n\t\tif (alpha !== undefined) {\n\t\t\tif (isFunction(alpha)) {\n\t\t\t\tconst result = alpha(state);\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn alpha;\n\t\t\t}\n\t\t}\n\t\treturn this._theme.getAlpha(state);\n\t}\n\n\tprotected newObject(): DDynamicText {\n\t\treturn new DDynamicText(this._dstyle);\n\t}\n\n\tget visible(): boolean {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\treturn object.visible;\n\t\t}\n\t\treturn this._isVisible;\n\t}\n\n\tset visible(visible: boolean) {\n\t\tconst object = this._object;\n\t\tif (object != null) {\n\t\t\tobject.visible = visible;\n\t\t}\n\t\tthis._isVisible = visible;\n\t}\n\n\tshow(): this {\n\t\tthis.visible = true;\n\t\treturn this;\n\t}\n\n\thide(): this {\n\t\tthis.visible = false;\n\t\treturn this;\n\t}\n\n\tisShown(): boolean {\n\t\treturn this.visible;\n\t}\n\n\tprotected onComputedChange(): void {\n\t\tthis.emit(\"change\", this);\n\t}\n\n\tdestroy(): this {\n\t\tconst object = this._object;\n\t\tif (object) {\n\t\t\tthis._object = undefined;\n\t\t\tobject.destroy();\n\t\t}\n\n\t\treturn this;\n\t}\n}\n"]}
|
package/dist/wcardinal-ui.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.407.
|
|
2
|
+
Winter Cardinal UI v0.407.1
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
@@ -29956,7 +29956,7 @@ var DTextPieceImpl = /** @class */ (function (_super) {
|
|
|
29956
29956
|
DTextPieceImpl.prototype.updateObject = function () {
|
|
29957
29957
|
var computed = this._computed;
|
|
29958
29958
|
if (computed !== undefined) {
|
|
29959
|
-
var formatted = this._formatter(computed, this);
|
|
29959
|
+
var formatted = this._formatter(computed, this._parent);
|
|
29960
29960
|
var object = this._object;
|
|
29961
29961
|
if (object == null) {
|
|
29962
29962
|
if (0 < formatted.length) {
|
package/dist/wcardinal-ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Winter Cardinal UI v0.407.
|
|
2
|
+
Winter Cardinal UI v0.407.1
|
|
3
3
|
Copyright (C) 2019 Toshiba Corporation
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
@@ -29953,7 +29953,7 @@
|
|
|
29953
29953
|
DTextPieceImpl.prototype.updateObject = function () {
|
|
29954
29954
|
var computed = this._computed;
|
|
29955
29955
|
if (computed !== undefined) {
|
|
29956
|
-
var formatted = this._formatter(computed, this);
|
|
29956
|
+
var formatted = this._formatter(computed, this._parent);
|
|
29957
29957
|
var object = this._object;
|
|
29958
29958
|
if (object == null) {
|
|
29959
29959
|
if (0 < formatted.length) {
|