forked from fanruan/fineui
impact
2 years ago
18 changed files with 1685 additions and 1626 deletions
@ -0,0 +1,3 @@
|
||||
export { Editor } from "./editor"; |
||||
export { MultifileEditor } from "./editor.multifile"; |
||||
export { TextAreaEditor } from "./editor.textarea"; |
@ -1,4 +1,10 @@
|
||||
export { Single } from "./0.single"; |
||||
export { Text } from "./1.text"; |
||||
export { PureText } from "./text.pure"; |
||||
export { Icon } from "./icon/icon"; |
||||
export { Html } from "./html/html"; |
||||
export { A } from "./a/a"; |
||||
export * from "./tip"; |
||||
export * from "./label"; |
||||
export * from "./input"; |
||||
export * from "./editor"; |
@ -0,0 +1,2 @@
|
||||
export { Input } from "./input"; |
||||
export { File } from "./file"; |
@ -1,399 +1,400 @@
|
||||
/** |
||||
* Created by dailer on 2019/6/19. |
||||
*/ |
||||
!(function () { |
||||
BI.AbstractLabel = BI.inherit(BI.Single, { |
||||
import { isNumber, createWidget, extend } from "../../../core"; |
||||
import { Single } from "../0.single"; |
||||
|
||||
_defaultConfig: function (props) { |
||||
var conf = BI.AbstractLabel.superclass._defaultConfig.apply(this, arguments); |
||||
export class AbstractLabel extends Single { |
||||
|
||||
return BI.extend(conf, { |
||||
textAlign: "center", |
||||
whiteSpace: "nowrap", // normal or nowrap
|
||||
textWidth: null, |
||||
textHeight: null, |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0, |
||||
highLight: false, |
||||
handler: null, |
||||
enableHover: props.title !== null, |
||||
}); |
||||
}, |
||||
_defaultConfig(props) { |
||||
const conf = super._defaultConfig(arguments); |
||||
|
||||
_createJson: function () { |
||||
var o = this.options; |
||||
return extend(conf, { |
||||
textAlign: "center", |
||||
whiteSpace: "nowrap", // normal or nowrap
|
||||
textWidth: null, |
||||
textHeight: null, |
||||
hgap: 0, |
||||
vgap: 0, |
||||
lgap: 0, |
||||
rgap: 0, |
||||
tgap: 0, |
||||
bgap: 0, |
||||
highLight: false, |
||||
handler: null, |
||||
enableHover: props.title !== null, |
||||
}); |
||||
} |
||||
|
||||
return { |
||||
type: "bi.text", |
||||
textAlign: o.textAlign, |
||||
whiteSpace: o.whiteSpace, |
||||
lineHeight: o.textHeight, |
||||
maxWidth: "100%", |
||||
text: o.text, |
||||
value: o.value, |
||||
py: o.py, |
||||
keyword: o.keyword, |
||||
highLight: o.highLight, |
||||
handler: o.handler, |
||||
}; |
||||
}, |
||||
_createJson() { |
||||
const { textAlign, whiteSpace, textHeight, text, value, py, keyword, highLight, handler } = this.options; |
||||
|
||||
render: function () { |
||||
if (this.options.textAlign === "center") { |
||||
this._createCenterEl(); |
||||
} else { |
||||
this._createNotCenterEl(); |
||||
} |
||||
}, |
||||
return { |
||||
type: "bi.text", |
||||
textAlign, |
||||
whiteSpace, |
||||
lineHeight: textHeight, |
||||
maxWidth: "100%", |
||||
text, |
||||
value, |
||||
py, |
||||
keyword, |
||||
highLight, |
||||
handler, |
||||
}; |
||||
} |
||||
|
||||
_createCenterEl: function () { |
||||
var o = this.options; |
||||
var json = this._createJson(); |
||||
json.textAlign = "left"; |
||||
if (BI.isNumber(o.width) && o.width > 0) { |
||||
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { |
||||
json.maxWidth = o.textWidth; |
||||
if (BI.isNumber(o.height) && o.height > 0) { // 1.1
|
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
height: o.height, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
render() { |
||||
if (this.options.textAlign === "center") { |
||||
this._createCenterEl(); |
||||
} else { |
||||
this._createNotCenterEl(); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
BI.createWidget({ // 1.2
|
||||
_createCenterEl() { |
||||
const { width, textWidth, height, whiteSpace, hgap, vgap, lgap, rgap, tgap, bgap, textAlign } = this.options; |
||||
const json = this._createJson(); |
||||
json.textAlign = "left"; |
||||
if (isNumber(width) && width > 0) { |
||||
if (isNumber(textWidth) && textWidth > 0) { |
||||
json.maxWidth = textWidth; |
||||
if (isNumber(height) && height > 0) { // 1.1
|
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
height, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (o.whiteSpace === "normal") { // 1.3
|
||||
BI.extend(json, { |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
}); |
||||
this.text = BI.createWidget(json); |
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.height) && o.height > 0) { // 1.4
|
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(o.height), |
||||
}); |
||||
json.textAlign = o.textAlign; |
||||
delete json.maxWidth; |
||||
this.text = BI.createWidget(BI.extend(json, { |
||||
element: this, |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
})); |
||||
|
||||
return; |
||||
} |
||||
BI.extend(json, { // 1.5
|
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
maxWidth: "100%", |
||||
}); |
||||
this.text = BI.createWidget(json); |
||||
BI.createWidget({ |
||||
createWidget({ // 1.2
|
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { // 1.6
|
||||
json.maxWidth = o.textWidth; |
||||
BI.createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (o.whiteSpace === "normal") { // 1.7
|
||||
BI.extend(json, { |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
if (whiteSpace === "normal") { // 1.3
|
||||
extend(json, { |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
}); |
||||
this.text = BI.createWidget(json); |
||||
BI.createWidget({ |
||||
this.text = createWidget(json); |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: true, |
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.height) && o.height > 0) { // 1.8
|
||||
if (isNumber(height) && height > 0) { // 1.4
|
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(o.height), |
||||
"line-height": BI.pixFormat(height), |
||||
}); |
||||
json.textAlign = o.textAlign; |
||||
json.textAlign = textAlign; |
||||
delete json.maxWidth; |
||||
this.text = BI.createWidget(BI.extend(json, { |
||||
this.text = createWidget(extend(json, { |
||||
element: this, |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
|
||||
return; |
||||
} |
||||
this.text = BI.createWidget(BI.extend(json, { |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
})); |
||||
BI.createWidget({ |
||||
extend(json, { // 1.5
|
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
maxWidth: "100%", |
||||
}); |
||||
this.text = createWidget(json); |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
}, |
||||
|
||||
_createNotCenterEl: function () { |
||||
var o = this.options; |
||||
var adaptLayout = "bi.vertical_adapt"; |
||||
var json = this._createJson(); |
||||
if (BI.isNumber(o.width) && o.width > 0) { |
||||
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { |
||||
json.maxWidth = o.textWidth; |
||||
if (BI.isNumber(o.height) && o.height > 0) { // 2.1
|
||||
BI.createWidget({ |
||||
type: adaptLayout, |
||||
horizontalAlign: o.textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
height: o.height, |
||||
scrollable: o.whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
return; |
||||
return; |
||||
} |
||||
if (isNumber(textWidth) && textWidth > 0) { // 1.6
|
||||
json.maxWidth = textWidth; |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
BI.createWidget({ // 2.2
|
||||
], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (whiteSpace === "normal") { // 1.7
|
||||
extend(json, { |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
}); |
||||
this.text = createWidget(json); |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: true, |
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (isNumber(height) && height > 0) { // 1.8
|
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(height), |
||||
}); |
||||
json.textAlign = textAlign; |
||||
delete json.maxWidth; |
||||
this.text = createWidget(extend(json, { |
||||
element: this, |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
|
||||
return; |
||||
} |
||||
this.text = createWidget(extend(json, { |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
createWidget({ |
||||
type: "bi.center_adapt", |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
element: this, |
||||
items: [this.text], |
||||
}); |
||||
} |
||||
|
||||
_createNotCenterEl() { |
||||
const { width, textWidth, height, whiteSpace, hgap, vgap, lgap, rgap, tgap, bgap, textAlign } = this.options; |
||||
const adaptLayout = "bi.vertical_adapt"; |
||||
const json = this._createJson(); |
||||
if (isNumber(width) && width > 0) { |
||||
if (isNumber(textWidth) && textWidth > 0) { |
||||
json.maxWidth = textWidth; |
||||
if (isNumber(height) && height > 0) { // 2.1
|
||||
createWidget({ |
||||
type: adaptLayout, |
||||
horizontalAlign: o.textAlign, |
||||
horizontalAlign: textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
height, |
||||
scrollable: whiteSpace === "normal", |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.height) && o.height > 0) { // 2.3
|
||||
if (o.whiteSpace !== "normal") { |
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(o.height - (o.vgap * 2)), |
||||
}); |
||||
} |
||||
delete json.maxWidth; |
||||
this.text = BI.createWidget(BI.extend(json, { |
||||
element: this, |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
})); |
||||
|
||||
return; |
||||
} |
||||
json.maxWidth = o.width - 2 * o.hgap - o.lgap - o.rgap; |
||||
BI.createWidget({ // 2.4
|
||||
createWidget({ // 2.2
|
||||
type: adaptLayout, |
||||
horizontalAlign: o.textAlign, |
||||
horizontalAlign: textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
element: this, |
||||
items: [{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
}], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.textWidth) && o.textWidth > 0) { |
||||
json.maxWidth = o.textWidth; |
||||
BI.createWidget({ // 2.5
|
||||
type: adaptLayout, |
||||
horizontalAlign: o.textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: o.whiteSpace === "normal", |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
scrollable: whiteSpace === "normal", |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = BI.createWidget(json)), |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
if (BI.isNumber(o.height) && o.height > 0) { |
||||
if (o.whiteSpace !== "normal") { |
||||
if (isNumber(height) && height > 0) { // 2.3
|
||||
if (whiteSpace !== "normal") { |
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(o.height - (o.vgap * 2)), |
||||
"line-height": BI.pixFormat(height - (vgap * 2)), |
||||
}); |
||||
} |
||||
delete json.maxWidth; |
||||
this.text = BI.createWidget(BI.extend(json, { // 2.6
|
||||
this.text = createWidget(extend(json, { |
||||
element: this, |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
|
||||
return; |
||||
} |
||||
this.text = BI.createWidget(BI.extend(json, { |
||||
hgap: o.hgap, |
||||
vgap: o.vgap, |
||||
lgap: o.lgap, |
||||
rgap: o.rgap, |
||||
tgap: o.tgap, |
||||
bgap: o.bgap, |
||||
})); |
||||
BI.createWidget({ |
||||
json.maxWidth = width - 2 * hgap - lgap - rgap; |
||||
createWidget({ // 2.4
|
||||
type: adaptLayout, |
||||
horizontalAlign: o.textAlign, |
||||
horizontalAlign: textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: whiteSpace === "normal", |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
element: this, |
||||
scrollable: o.whiteSpace === "normal", |
||||
items: [this.text], |
||||
items: [{ |
||||
el: (this.text = createWidget(json)), |
||||
}], |
||||
}); |
||||
}, |
||||
|
||||
doRedMark: function () { |
||||
this.text.doRedMark.apply(this.text, arguments); |
||||
}, |
||||
return; |
||||
} |
||||
if (isNumber(textWidth) && textWidth > 0) { |
||||
json.maxWidth = textWidth; |
||||
createWidget({ // 2.5
|
||||
type: adaptLayout, |
||||
horizontalAlign: textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
scrollable: whiteSpace === "normal", |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
element: this, |
||||
items: [ |
||||
{ |
||||
el: (this.text = createWidget(json)), |
||||
} |
||||
], |
||||
}); |
||||
|
||||
unRedMark: function () { |
||||
this.text.unRedMark.apply(this.text, arguments); |
||||
}, |
||||
return; |
||||
} |
||||
if (isNumber(height) && height > 0) { |
||||
if (whiteSpace !== "normal") { |
||||
this.element.css({ |
||||
"line-height": BI.pixFormat(height - (vgap * 2)), |
||||
}); |
||||
} |
||||
delete json.maxWidth; |
||||
this.text = createWidget(extend(json, { // 2.6
|
||||
element: this, |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
|
||||
doHighLight: function () { |
||||
this.text.doHighLight.apply(this.text, arguments); |
||||
}, |
||||
return; |
||||
} |
||||
this.text = createWidget(extend(json, { |
||||
hgap, |
||||
vgap, |
||||
lgap, |
||||
rgap, |
||||
tgap, |
||||
bgap, |
||||
})); |
||||
createWidget({ |
||||
type: adaptLayout, |
||||
horizontalAlign: textAlign, |
||||
columnSize: ["auto"], // important! 让文字在flex布局下shrink为1
|
||||
element: this, |
||||
scrollable: whiteSpace === "normal", |
||||
items: [this.text], |
||||
}); |
||||
} |
||||
|
||||
unHighLight: function () { |
||||
this.text.unHighLight.apply(this.text, arguments); |
||||
}, |
||||
doRedMark() { |
||||
this.text.doRedMark.apply(this.text, arguments); |
||||
} |
||||
|
||||
setText: function (v) { |
||||
this.options.text = v; |
||||
this.text.setText(v); |
||||
}, |
||||
unRedMark() { |
||||
this.text.unRedMark.apply(this.text, arguments); |
||||
} |
||||
|
||||
getText: function () { |
||||
return this.options.text; |
||||
}, |
||||
doHighLight() { |
||||
this.text.doHighLight.apply(this.text, arguments); |
||||
} |
||||
|
||||
setStyle: function (css) { |
||||
this.text.setStyle(css); |
||||
}, |
||||
unHighLight() { |
||||
this.text.unHighLight.apply(this.text, arguments); |
||||
} |
||||
|
||||
setValue: function (v) { |
||||
BI.AbstractLabel.superclass.setValue.apply(this, arguments); |
||||
if (!this.isReadOnly()) { |
||||
this.options.text = v; |
||||
this.text.setValue(v); |
||||
} |
||||
}, |
||||
}); |
||||
}()); |
||||
setText(v) { |
||||
this.options.text = v; |
||||
this.text.setText(v); |
||||
} |
||||
|
||||
getText() { |
||||
return this.options.text; |
||||
} |
||||
|
||||
setStyle(css) { |
||||
this.text.setStyle(css); |
||||
} |
||||
|
||||
setValue(v) { |
||||
super.setValue(v); |
||||
if (!this.isReadOnly()) { |
||||
this.options.text = v; |
||||
this.text.setValue(v); |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,26 +1,28 @@
|
||||
/** |
||||
* Created by GUY on 2015/6/26. |
||||
*/ |
||||
import { shortcut } from "../../../core"; |
||||
import { AbstractLabel } from "./abstract.label" |
||||
|
||||
BI.HtmlLabel = BI.inherit(BI.AbstractLabel, { |
||||
@shortcut() |
||||
export class HtmlLabel extends AbstractLabel { |
||||
static xtype = "bi.html_label"; |
||||
|
||||
props: { |
||||
props = { |
||||
baseCls: "bi-html-label", |
||||
}, |
||||
} |
||||
|
||||
_createJson: function () { |
||||
var o = this.options; |
||||
_createJson() { |
||||
const { textAlign, whiteSpace, textHeight, text, value, handler } = this.options; |
||||
|
||||
return { |
||||
type: "bi.html", |
||||
textAlign: o.textAlign, |
||||
whiteSpace: o.whiteSpace, |
||||
lineHeight: o.textHeight, |
||||
text: o.text, |
||||
value: o.value, |
||||
handler: o.handler, |
||||
textAlign, |
||||
whiteSpace, |
||||
lineHeight: textHeight, |
||||
text, |
||||
value, |
||||
handler, |
||||
}; |
||||
}, |
||||
}); |
||||
|
||||
BI.shortcut("bi.html_label", BI.HtmlLabel); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,4 @@
|
||||
export { AbstractLabel } from "./abstract.label"; |
||||
export { HtmlLabel } from "./html.label"; |
||||
export { IconLabel } from "./icon.label"; |
||||
export { Label } from "./label"; |
@ -1,39 +1,41 @@
|
||||
/** |
||||
* Created by GUY on 2015/6/26. |
||||
*/ |
||||
import { shortcut, isFunction, isNotNull } from "../../../core"; |
||||
import { AbstractLabel } from "./abstract.label" |
||||
|
||||
BI.Label = BI.inherit(BI.AbstractLabel, { |
||||
@shortcut() |
||||
export class Label extends AbstractLabel { |
||||
static xtype = "bi.label"; |
||||
|
||||
props: { |
||||
props = { |
||||
baseCls: "bi-label", |
||||
py: "", |
||||
keyword: "", |
||||
}, |
||||
} |
||||
|
||||
getTitle: function () { |
||||
var title = this.options.title; |
||||
var text = this.options.text; |
||||
if (BI.isFunction(title)) { |
||||
getTitle() { |
||||
const title = this.options.title; |
||||
const text = this.options.text; |
||||
if (isFunction(title)) { |
||||
return title(); |
||||
} |
||||
if (BI.isNotNull(title)) { |
||||
if (isNotNull(title)) { |
||||
return title; |
||||
} |
||||
|
||||
if (BI.isFunction(text)) { |
||||
if (isFunction(text)) { |
||||
return text(); |
||||
} |
||||
|
||||
return text; |
||||
}, |
||||
} |
||||
|
||||
doRedMark: function () { |
||||
doRedMark() { |
||||
this.text.doRedMark.apply(this.text, arguments); |
||||
}, |
||||
} |
||||
|
||||
unRedMark: function () { |
||||
unRedMark() { |
||||
this.text.unRedMark.apply(this.text, arguments); |
||||
}, |
||||
}); |
||||
|
||||
BI.shortcut("bi.label", BI.Label); |
||||
} |
||||
} |
||||
|
@ -1,46 +1,47 @@
|
||||
/** |
||||
* 没有html标签的纯文本 |
||||
*/ |
||||
!(function () { |
||||
BI.PureText = BI.inherit(BI.Widget, { |
||||
import { Widget, shortcut, isFunction, isKey, isNotNull } from "../../core"; |
||||
import { Text } from "./1.text"; |
||||
|
||||
props: { |
||||
tagName: null, |
||||
}, |
||||
@shortcut() |
||||
export class PureText extends Widget { |
||||
static xtype = "bi.pure_text"; |
||||
|
||||
render: function () { |
||||
var self = this, o = this.options; |
||||
var text = BI.isFunction(o.text) ? this.__watch(o.text, function (context, newValue) { |
||||
self.setText(newValue); |
||||
}) : o.text; |
||||
if (BI.isKey(text)) { |
||||
this.setText(text); |
||||
} else if (BI.isKey(o.value)) { |
||||
this.setText(o.value); |
||||
} |
||||
}, |
||||
props = { |
||||
tagName: null, |
||||
} |
||||
|
||||
_getShowText: function () { |
||||
var o = this.options; |
||||
var text = BI.isFunction(o.text) ? o.text() : o.text; |
||||
text = BI.isKey(text) ? text : o.value; |
||||
if (!BI.isKey(text)) { |
||||
return ""; |
||||
} |
||||
render() { |
||||
const { text: optionsText, value } = this.options; |
||||
const text = isFunction(optionsText) ? this.__watch(optionsText, (context, newValue) => { |
||||
this.setText(newValue); |
||||
}) : optionsText; |
||||
if (isKey(text)) { |
||||
this.setText(text); |
||||
} else if (isKey(value)) { |
||||
this.setText(value); |
||||
} |
||||
} |
||||
|
||||
return BI.Text.formatText(text + ""); |
||||
}, |
||||
_getShowText() { |
||||
const { text: optionsText, value } = this.options; |
||||
const text = isFunction(optionsText) ? optionsText() : optionsText; |
||||
text = isKey(text) ? text : value; |
||||
if (!isKey(text)) { |
||||
return ""; |
||||
} |
||||
|
||||
setValue: function (value) { |
||||
this.options.value = value; |
||||
this.setText(value); |
||||
}, |
||||
return Text.formatText(text + ""); |
||||
} |
||||
|
||||
setText: function (text) { |
||||
this.options.text = BI.isNotNull(text) ? text : ""; |
||||
this.element.__textKeywordMarked__(this._getShowText()); |
||||
}, |
||||
}); |
||||
BI.shortcut("bi.pure_text", BI.PureText); |
||||
}()); |
||||
setValue(value) { |
||||
this.options.value = value; |
||||
this.setText(value); |
||||
} |
||||
|
||||
setText(text) { |
||||
this.options.text = isNotNull(text) ? text : ""; |
||||
this.element.__textKeywordMarked__(this._getShowText()); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue