@flexem/fc-gui 3.0.0-alpha.163 → 3.0.0-alpha.165
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/bundles/@flexem/fc-gui.umd.js +61 -22
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/elements/base/state-control-element.js +10 -7
- package/elements/shared/text/text-element.js +1 -1
- package/elements/shared/text/text-state-element.d.ts +2 -0
- package/elements/shared/text/text-state-element.js +33 -8
- package/elements/switch-indicator-light/switch-indicator-light-element.js +7 -1
- package/elements/view-operation/view-operation.element.js +10 -5
- package/model/shared/text/font.d.ts +1 -1
- package/package.json +1 -1
|
@@ -35106,19 +35106,22 @@ class state_control_element_StateControlElement extends conditional_dynamic_disp
|
|
|
35106
35106
|
}
|
|
35107
35107
|
changeState(state) {
|
|
35108
35108
|
switch (state) {
|
|
35109
|
-
case _tmp_model["State"].InvalidMonitor:
|
|
35110
|
-
this.state = _tmp_model["State"].InvalidMonitor;
|
|
35111
|
-
break;
|
|
35112
35109
|
case _tmp_model["State"].Unbind:
|
|
35113
|
-
|
|
35114
|
-
|
|
35115
|
-
}
|
|
35110
|
+
// Unbind 优先级最高,可覆盖任何状态
|
|
35111
|
+
this.state = _tmp_model["State"].Unbind;
|
|
35116
35112
|
break;
|
|
35117
35113
|
case _tmp_model["State"].Offline:
|
|
35118
|
-
|
|
35114
|
+
// Offline 优先级次于 Unbind
|
|
35115
|
+
if (this.state !== _tmp_model["State"].Unbind) {
|
|
35119
35116
|
this.state = _tmp_model["State"].Offline;
|
|
35120
35117
|
}
|
|
35121
35118
|
break;
|
|
35119
|
+
case _tmp_model["State"].InvalidMonitor:
|
|
35120
|
+
// InvalidMonitor 优先级低于 Offline/Unbind
|
|
35121
|
+
if (this.state !== _tmp_model["State"].Unbind && this.state !== _tmp_model["State"].Offline) {
|
|
35122
|
+
this.state = _tmp_model["State"].InvalidMonitor;
|
|
35123
|
+
}
|
|
35124
|
+
break;
|
|
35122
35125
|
case _tmp_model["State"].Loading:
|
|
35123
35126
|
if (this.state !== _tmp_model["State"].Unbind && this.state !== _tmp_model["State"].Offline && this.state !== _tmp_model["State"].InvalidMonitor) {
|
|
35124
35127
|
this.state = _tmp_model["State"].Loading;
|
|
@@ -35877,7 +35880,7 @@ class text_element_TextElementModal {
|
|
|
35877
35880
|
lineHeight = parseInt(font.fontSize, 10) + 5;
|
|
35878
35881
|
fontString += font.fontSize + '/' + lineHeight.toString() + 'px ' + font.fontFamily;
|
|
35879
35882
|
textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};text-align: ${textAlign};`;
|
|
35880
|
-
if (font.isUnderline) {
|
|
35883
|
+
if (font.isUnderline && content.length > 0) {
|
|
35881
35884
|
textDiv.style.textDecoration = 'underline';
|
|
35882
35885
|
}
|
|
35883
35886
|
const spanText = document.createElement('span');
|
|
@@ -39708,10 +39711,23 @@ class text_state_element_TextStateElement {
|
|
|
39708
39711
|
return;
|
|
39709
39712
|
}
|
|
39710
39713
|
const textElement = this.getforeignObjectElement();
|
|
39711
|
-
// 设置 text-anchor 和 dominant-baseline
|
|
39712
|
-
textElement.setAttribute('text-anchor', 'middle');
|
|
39713
|
-
textElement.setAttribute('dominant-baseline', 'middle');
|
|
39714
39714
|
textElement.setAttribute('pointer-events', 'auto');
|
|
39715
|
+
// 根据 textAlign 计算 SVG text-anchor 和 x 坐标
|
|
39716
|
+
const textAlign = font.textAlign || 'center';
|
|
39717
|
+
let textAnchor;
|
|
39718
|
+
let anchorX;
|
|
39719
|
+
if (textAlign === 'left') {
|
|
39720
|
+
textAnchor = 'start';
|
|
39721
|
+
anchorX = 0;
|
|
39722
|
+
}
|
|
39723
|
+
else if (textAlign === 'right') {
|
|
39724
|
+
textAnchor = 'end';
|
|
39725
|
+
anchorX = this.width;
|
|
39726
|
+
}
|
|
39727
|
+
else {
|
|
39728
|
+
textAnchor = 'middle';
|
|
39729
|
+
anchorX = this.width / 2;
|
|
39730
|
+
}
|
|
39715
39731
|
// 拆分换行
|
|
39716
39732
|
const lines = content.split('\n');
|
|
39717
39733
|
const fontSize = parseInt(font.fontSize, 10);
|
|
@@ -39729,16 +39745,16 @@ class text_state_element_TextStateElement {
|
|
|
39729
39745
|
textElement.appendChild(tspan);
|
|
39730
39746
|
}
|
|
39731
39747
|
tspan.setAttribute('display', 'inline');
|
|
39732
|
-
tspan.setAttribute('x',
|
|
39748
|
+
tspan.setAttribute('x', anchorX.toString());
|
|
39733
39749
|
tspan.setAttribute('y', startY + i * lineHeight + 'px');
|
|
39734
|
-
tspan.textContent = lines[i].replace(/ /g, '
|
|
39750
|
+
tspan.textContent = lines[i].replace(/ /g, ' ');
|
|
39735
39751
|
tspan.setAttribute('font-size', font.fontSize);
|
|
39736
39752
|
tspan.setAttribute('fill', font.color);
|
|
39737
39753
|
tspan.setAttribute('font-family', font.fontFamily);
|
|
39738
39754
|
tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
|
|
39739
39755
|
tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
|
|
39740
39756
|
tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
|
|
39741
|
-
tspan.setAttribute('text-anchor',
|
|
39757
|
+
tspan.setAttribute('text-anchor', textAnchor);
|
|
39742
39758
|
tspan.setAttribute('dominant-baseline', 'middle');
|
|
39743
39759
|
}
|
|
39744
39760
|
// 隐藏多余的 tspan(不删除)
|
|
@@ -39796,7 +39812,7 @@ class text_state_element_TextStateElement {
|
|
|
39796
39812
|
}
|
|
39797
39813
|
}
|
|
39798
39814
|
doFaultFlicker(textElement, stateId) {
|
|
39799
|
-
if (this.version > 3 && this.faultFlickers) {
|
|
39815
|
+
if (this.version != null && this.version > 3 && this.faultFlickers) {
|
|
39800
39816
|
this.clearFlickerInterval(textElement);
|
|
39801
39817
|
const faultFlicker = this.faultFlickers.find(t => t.id === stateId);
|
|
39802
39818
|
if (faultFlicker && faultFlicker.faultFlicker) {
|
|
@@ -39825,6 +39841,8 @@ class text_state_element_TextStateElement {
|
|
|
39825
39841
|
}
|
|
39826
39842
|
/**
|
|
39827
39843
|
* 获取指定状态在当前语种下的字体样式
|
|
39844
|
+
* fontStyleCultures 中保存的对象含 fontStyle 字符串但无 isBold/isItalic/fontFamily,
|
|
39845
|
+
* 此处从 fontStyle 解析这三个字段后返回
|
|
39828
39846
|
*/
|
|
39829
39847
|
getFontForState(stateId, defaultFont) {
|
|
39830
39848
|
if (!this.fontStyleCultures) {
|
|
@@ -39845,7 +39863,17 @@ class text_state_element_TextStateElement {
|
|
|
39845
39863
|
};
|
|
39846
39864
|
const targetLanguage = getTargetLanguage();
|
|
39847
39865
|
if (this.fontStyleCultures[stateKey][targetLanguage]) {
|
|
39848
|
-
|
|
39866
|
+
const culturedFont = this.fontStyleCultures[stateKey][targetLanguage];
|
|
39867
|
+
if (culturedFont.fontStyle) {
|
|
39868
|
+
const fs = culturedFont.fontStyle;
|
|
39869
|
+
const isBold = fs.indexOf('bold') !== -1;
|
|
39870
|
+
const isItalic = fs.indexOf('Italic') !== -1;
|
|
39871
|
+
const parts = fs.split(' ');
|
|
39872
|
+
const familyIndex = (isBold ? 1 : 0) + (isItalic ? 1 : 0) + 1;
|
|
39873
|
+
const fontFamily = parts.length > familyIndex ? parts[familyIndex] : null;
|
|
39874
|
+
return Object.assign(Object.assign({}, culturedFont), { isBold, isItalic, fontFamily });
|
|
39875
|
+
}
|
|
39876
|
+
return culturedFont;
|
|
39849
39877
|
}
|
|
39850
39878
|
return defaultFont;
|
|
39851
39879
|
}
|
|
@@ -40517,7 +40545,9 @@ class switch_indicator_light_element_SwitchIndicatorLightElement extends conditi
|
|
|
40517
40545
|
const validNames = (_d = (_c = (_b = (_a = this.guiContext) === null || _a === void 0 ? void 0 : _a.configStore) === null || _b === void 0 ? void 0 : _b.variableStore) === null || _c === void 0 ? void 0 : _c.getAllVariableNames) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
40518
40546
|
if (validNames && !validNames.includes(convertedName)) {
|
|
40519
40547
|
this.updateElementStates([new communication["c" /* VariableState */](convertedName, communication["d" /* VariableStateEnum */].InvalidMonitor)]);
|
|
40520
|
-
|
|
40548
|
+
// 无效变量时先显示第一个状态样式,避免空白;
|
|
40549
|
+
// 但仍继续初始化订阅,以便后续收到 Offline/Unbind 时能正确覆盖
|
|
40550
|
+
this.switchToState(0);
|
|
40521
40551
|
}
|
|
40522
40552
|
}
|
|
40523
40553
|
switch (settings.type) {
|
|
@@ -40548,6 +40578,10 @@ class switch_indicator_light_element_SwitchIndicatorLightElement extends conditi
|
|
|
40548
40578
|
else if (!Object(lodash["isUndefined"])(statusIdValue.value)) {
|
|
40549
40579
|
this.switchToState(statusIdValue.value);
|
|
40550
40580
|
}
|
|
40581
|
+
else {
|
|
40582
|
+
// 变量值为 null/undefined(含无效变量)时,显示第一个状态样式
|
|
40583
|
+
this.switchToState(0);
|
|
40584
|
+
}
|
|
40551
40585
|
}
|
|
40552
40586
|
switchToState(stateId) {
|
|
40553
40587
|
this.textStateElement.switchToState(stateId);
|
|
@@ -41206,14 +41240,19 @@ class view_operation_element_ViewOperationElement extends conditional_enable_ele
|
|
|
41206
41240
|
const targetLanguage = getTargetLanguage();
|
|
41207
41241
|
if (this.model.fontStyleCultures && this.model.fontStyleCultures[targetLanguage]) {
|
|
41208
41242
|
const style = this.model.fontStyleCultures[targetLanguage];
|
|
41243
|
+
const fs = style.fontStyle || '';
|
|
41244
|
+
const isBold = fs.indexOf('bold') !== -1;
|
|
41245
|
+
const isItalic = fs.indexOf('Italic') !== -1;
|
|
41246
|
+
const parts = fs.split(' ');
|
|
41247
|
+
const familyIndex = (isBold ? 1 : 0) + (isItalic ? 1 : 0) + 1;
|
|
41248
|
+
const fontFamily = parts.length > familyIndex ? parts[familyIndex] : null;
|
|
41209
41249
|
return {
|
|
41210
41250
|
isUnderline: style.isUnderline,
|
|
41211
|
-
isBold
|
|
41212
|
-
isItalic
|
|
41251
|
+
isBold,
|
|
41252
|
+
isItalic,
|
|
41213
41253
|
fontSize: style.fontSize,
|
|
41214
|
-
fontFamily:
|
|
41215
|
-
color: style.color
|
|
41216
|
-
textAlign: style.textAlign
|
|
41254
|
+
fontFamily: fontFamily || 'msyh',
|
|
41255
|
+
color: style.color
|
|
41217
41256
|
};
|
|
41218
41257
|
}
|
|
41219
41258
|
return Object.assign(Object.assign({}, this.model.label.font), { fontFamily: this.model.label.font.fontFamily || 'msyh' });
|