Browse Source

Merge remote-tracking branch 'origin/master'

research/test
Kobi 12 months ago
parent
commit
709fc4f3d4
  1. 2
      packages/fineui/package.json
  2. 1
      packages/fineui/src/base/combination/bubble.js
  3. 9
      packages/fineui/src/core/2.base.js
  4. 115
      packages/fineui/src/core/constant/writable.var.js
  5. 132
      packages/fineui/src/core/element/element.js
  6. 10
      packages/fineui/src/fix/fix.js
  7. 3
      packages/fineui/src/less/base/single/input/radio.less
  8. 3
      packages/fineui/src/less/widget/intervalslider/intervalslider.label.less
  9. 3
      packages/fineui/src/less/widget/intervalslider/intervalslider.less
  10. 18
      packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
  11. 56
      packages/fineui/src/widget/intervalslider/intervalslider.js
  12. 4
      packages/fineui/src/widget/singleslider/button/editor.sign.text.js

2
packages/fineui/package.json

@ -1,6 +1,6 @@
{ {
"name": "@fui/core", "name": "@fui/core",
"version": "3.0.20230727164622", "version": "3.0.20231204103846",
"description": "fineui", "description": "fineui",
"main": "dist/fineui.min.js", "main": "dist/fineui.min.js",
"module": "dist/lib/index.js", "module": "dist/lib/index.js",

1
packages/fineui/src/base/combination/bubble.js

@ -520,6 +520,7 @@ export class Bubble extends Widget {
this.combo.setValue(v); this.combo.setValue(v);
if (isNull(this.popupView)) { if (isNull(this.popupView)) {
this.options.popup.value = v; this.options.popup.value = v;
!isNull(this.options.popup.el) && (this.options.popup.el.value = v);
} else { } else {
this.popupView.setValue(v); this.popupView.setValue(v);
} }

9
packages/fineui/src/core/2.base.js

@ -912,7 +912,8 @@ export const delay = lodashFns.delay;
export const defer = lodashFns.defer; export const defer = lodashFns.defer;
export const wrap = lodashFns.wrap; export const wrap = lodashFns.wrap;
export const nextTick = (function () {
export let nextTick = /*!PURE*/(function () {
const callbacks = []; const callbacks = [];
let pending = false; let pending = false;
let timerFunc = void 0; let timerFunc = void 0;
@ -971,7 +972,7 @@ export const nextTick = (function () {
pending = true; pending = true;
timerFunc(); timerFunc();
} }
// $flow-disable-line
if (!cb && typeof Promise !== "undefined") { if (!cb && typeof Promise !== "undefined") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
_resolve = resolve; _resolve = resolve;
@ -980,6 +981,10 @@ export const nextTick = (function () {
}; };
})(); })();
export const setNextTick = (fn) => {
nextTick = fn;
}
// 数字相关方法 // 数字相关方法
_.each(["random"], name => { _.each(["random"], name => {
lodashFns[name] = _apply(name); lodashFns[name] = _apply(name);

115
packages/fineui/src/core/constant/writable.var.js

@ -1,51 +1,50 @@
/** /**
* 可写的常量 * 可写的常量
*/ */
import { isNumber } from "../2.base"; import { isNumber, nextTick, setNextTick } from "../2.base";
import { _global } from "../0.foundation"; import { _global } from "../0.foundation";
import { Cache } from "../structure"; import { Cache } from "../structure";
import { Element, setElement } from "../element/element";
import { setDom, DOM } from "../utils"; import { setDom, DOM } from "../utils";
const PropertyDescriptors = {}; const PropertyDescriptors = {};
export function _defineVarProperties(libName) {
Object.defineProperties(libName, PropertyDescriptors);
}
function addDescriptor(key, options) {
options.enumerable = options.enumerable === undefined ? true : options.enumerable;
options.configurable = options.configurable === undefined ? true : options.configurable;
PropertyDescriptors[key] = options;
}
export let EVENT_RESPONSE_TIME = 200; export let EVENT_RESPONSE_TIME = 200;
export const setEventResponseTime = v => { export const setEventResponseTime = v => {
EVENT_RESPONSE_TIME = v; EVENT_RESPONSE_TIME = v;
}; };
PropertyDescriptors["EVENT_RESPONSE_TIME"] = { addDescriptor("EVENT_RESPONSE_TIME", {
enumerable: true, get: () => EVENT_RESPONSE_TIME,
configurable: true,
get: function() {
return EVENT_RESPONSE_TIME;
},
set: setEventResponseTime, set: setEventResponseTime,
}; });
export let pixUnit = "px"; export let pixUnit = "px";
export const setPixUnit = v => { export const setPixUnit = v => {
pixUnit = v; pixUnit = v;
}; };
PropertyDescriptors["pixUnit"] = { addDescriptor("pixUnit", {
enumerable: true, get: () => pixUnit,
configurable: true,
get: function() {
return pixUnit;
},
set: setPixUnit, set: setPixUnit,
}; });
export let pixRatio = 1; export let pixRatio = 1;
export const setPixRatio = v => { export const setPixRatio = v => {
pixRatio = v; pixRatio = v;
}; };
PropertyDescriptors["pixRatio"] = { addDescriptor("pixRatio", {
enumerable: true, get: () => pixRatio,
configurable: true,
get: function() {
return pixRatio;
},
set: setPixRatio, set: setPixRatio,
}; });
export let StartOfWeek = 1; export let StartOfWeek = 1;
export const setStartOfWeek = v => { export const setStartOfWeek = v => {
@ -55,27 +54,19 @@ export const setStartOfWeek = v => {
} }
StartOfWeek = v; StartOfWeek = v;
}; };
PropertyDescriptors["StartOfWeek"] = { addDescriptor("StartOfWeek", {
enumerable: true, get: () => StartOfWeek,
configurable: true,
get: function() {
return StartOfWeek;
},
set: setStartOfWeek, set: setStartOfWeek,
}; });
export let BlankSplitChar = "\u200b \u200b"; export let BlankSplitChar = "\u200b \u200b";
export const setBlankSplitChar = v => { export const setBlankSplitChar = v => {
BlankSplitChar = v; BlankSplitChar = v;
}; };
PropertyDescriptors["BlankSplitChar"] = { addDescriptor("BlankSplitChar", {
enumerable: true, get: () => BlankSplitChar,
configurable: true,
get: function() {
return BlankSplitChar;
},
set: setBlankSplitChar, set: setBlankSplitChar,
}; });
// 一定返回最终的单位 // 一定返回最终的单位
export let pixFormat = (pix, border) => { export let pixFormat = (pix, border) => {
@ -95,14 +86,10 @@ export let pixFormat = (pix, border) => {
export const setPixFormat = v => { export const setPixFormat = v => {
pixFormat = v; pixFormat = v;
}; };
PropertyDescriptors["pixFormat"] = { addDescriptor("pixFormat", {
enumerable: true, get: () => pixFormat,
configurable: true,
get: function() {
return pixFormat;
},
set: setPixFormat, set: setPixFormat,
}; });
export let toPix = (pix, border) => { export let toPix = (pix, border) => {
if (!isNumber(pix)) { if (!isNumber(pix)) {
@ -120,14 +107,10 @@ export let toPix = (pix, border) => {
export let setToPix = v => { export let setToPix = v => {
toPix = v; toPix = v;
}; };
PropertyDescriptors["toPix"] = { addDescriptor("toPix", {
enumerable: true, get: () => toPix,
configurable: true,
get: function() {
return toPix;
},
set: setToPix, set: setToPix,
}; });
const getCacheItem = key => { const getCacheItem = key => {
Cache.getItem(key, { typeConversion: true, defaultValue: true }); Cache.getItem(key, { typeConversion: true, defaultValue: true });
@ -137,24 +120,22 @@ export const setEventBlur = v => {
EVENT_BLUR = v; EVENT_BLUR = v;
Cache.setItem("event.blur", v); Cache.setItem("event.blur", v);
}; };
PropertyDescriptors["EVENT_BLUR"] = { addDescriptor("EVENT_BLUR", {
enumerable: true, get: () => EVENT_BLUR,
configurable: true,
get: function() {
return EVENT_BLUR;
},
set: setEventBlur, set: setEventBlur,
}; });
addDescriptor("Element", {
get: () => Element,
set: setElement,
});
PropertyDescriptors["DOM"] = { addDescriptor("DOM", {
enumerable: true, get: () => DOM,
configurable: true,
get: function() {
return DOM;
},
set: setDom, set: setDom,
}; });
export function _defineVarProperties(libName) { addDescriptor("nextTick", {
Object.defineProperties(libName, PropertyDescriptors); get: () => nextTick,
} set: setNextTick,
});

132
packages/fineui/src/core/element/element.js

@ -1,76 +1,78 @@
import { registFunction } from "./plugins"; import { registFunction } from "./plugins";
import { isWidget, isString } from "../2.base"; import { isWidget, isString } from "../2.base";
export function Element(widget, attribs) { export let Element = class {
this.l = this.r = this.t = this.b = 0; // 边框 constructor(widget, attribs) {
this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; // 间距 this.l = this.r = this.t = this.b = 0; // 边框
this.position = {}; this.marginLeft = this.marginRight = this.marginTop = this.marginBottom = 0; // 间距
this.classMap = {}; this.position = {};
this.classList = []; this.classMap = {};
this.children = []; this.classList = [];
this.attribs = attribs || {}; this.children = [];
this.styles = {}; this.attribs = attribs || {};
// 兼容处理 this.styles = {};
this["0"] = this; // 兼容处理
this.style = {}; this["0"] = this;
if (!widget) { this.style = {};
this.nodeName = "body"; if (!widget) {
this.position.x = 0; this.nodeName = "body";
this.position.y = 0; this.position.x = 0;
this.attribs.id = "body"; this.position.y = 0;
} else if (isWidget(widget)) { this.attribs.id = "body";
this.widget = widget; } else if (isWidget(widget)) {
this.nodeName = widget.options.tagName; this.widget = widget;
this.textBaseLine = widget.options.textBaseLine; this.nodeName = widget.options.tagName;
} else if (isString(widget)) { this.textBaseLine = widget.options.textBaseLine;
this.nodeName = widget; } else if (isString(widget)) {
this.nodeName = widget;
}
} }
}
initElement(Element); appendChild(child) {
registFunction(Element); child.parent = this;
if (this.children.push(child) !== 1) {
const sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
}
append(child) {
child.parent = this;
if (this.children.push(child) !== 1) {
const sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
}
function initElement(element) { getParent() {
element.prototype = { return this.parent;
appendChild(child) { }
child.parent = this;
if (this.children.push(child) !== 1) {
const sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
},
append(child) {
child.parent = this;
if (this.children.push(child) !== 1) {
const sibling = this.children[this.children.length - 2];
sibling.next = child;
child.prev = sibling;
child.next = null;
}
},
getParent() {
return this.parent;
},
getSiblings() {
const parent = this.getParent();
return parent ? parent.getChildren() : [this];
},
getChildren() {
return this.children;
},
getBounds() { getSiblings() {
return {}; const parent = this.getParent();
},
width() { return parent ? parent.getChildren() : [this];
}
}, getChildren() {
height() { return this.children;
}
getBounds() {
return {};
}
width() {}
height() {}
}
registFunction(Element);
}, export function setElement(element) {
}; Element = element;
} }

10
packages/fineui/src/fix/fix.js

@ -7,7 +7,7 @@ const pendingCleanupDeps = [];
const cleanupDeps = () => { const cleanupDeps = () => {
for (let i = 0; i < pendingCleanupDeps.length; i++) { for (let i = 0; i < pendingCleanupDeps.length; i++) {
const dep = pendingCleanupDeps[i]; const dep = pendingCleanupDeps[i];
dep.subs = dep.subs.filter(s => s); dep.subs = dep.subs.filter(s => dep.subsSet.has(s.id));
dep._pending = false; dep._pending = false;
} }
pendingCleanupDeps.length = 0; pendingCleanupDeps.length = 0;
@ -23,14 +23,16 @@ class Dep {
this.id = uid++; this.id = uid++;
this._pending = false; this._pending = false;
this.subs = []; this.subs = [];
this.subsSet = new Set();
} }
addSub(sub) { addSub(sub) {
this.subs.push(sub); this.subs.push(sub);
this.subsSet.add(sub.id);
} }
removeSub(sub) { removeSub(sub) {
this.subs[this.subs.indexOf(sub)] = null; this.subsSet.delete(sub.id);
if (!this._pending) { if (!this._pending) {
this._pending = true; this._pending = true;
pendingCleanupDeps.push(this); pendingCleanupDeps.push(this);
@ -45,7 +47,7 @@ class Dep {
notify(options) { notify(options) {
// stabilize the subscriber list first // stabilize the subscriber list first
const subs = this.subs.filter(s => s); const subs = this.subs.filter(s => this.subsSet.has(s.id));
for (let i = 0, l = subs.length; i < l; i++) { for (let i = 0, l = subs.length; i < l; i++) {
subs[i].update(options); subs[i].update(options);
} }
@ -203,7 +205,7 @@ const nextTick = (function () {
pending = true; pending = true;
timerFunc(); timerFunc();
} }
// $flow-disable-line
if (!cb && typeof Promise !== "undefined") { if (!cb && typeof Promise !== "undefined") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
_resolve = resolve; _resolve = resolve;

3
packages/fineui/src/less/base/single/input/radio.less

@ -15,6 +15,9 @@
border-color: @color-bi-border-hover-active-radio; border-color: @color-bi-border-hover-active-radio;
} }
} }
.bi-radio-icon {
background-color: @color-bi-background-active-radio-content;
}
&.active { &.active {
& .radio-content, &.radio-content { & .radio-content, &.radio-content {
border-color: @color-bi-border-hover-active-radio; border-color: @color-bi-border-hover-active-radio;

3
packages/fineui/src/less/widget/intervalslider/intervalslider.label.less

@ -1,3 +0,0 @@
.bi-interval-slider-label {
min-height: 50px;
}

3
packages/fineui/src/less/widget/intervalslider/intervalslider.less

@ -1,3 +0,0 @@
.bi-interval-slider {
min-height: 50px;
}

18
packages/fineui/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js

@ -181,18 +181,24 @@ export class DynamicDateTimeSelect extends Widget {
} }
_checkHour(value) { _checkHour(value) {
this.hour.setDownEnable(parseInt(value) > 0); const { timeSelectTypes } = this.options;
this.hour.setUpEnable(parseInt(value) < 23); const canSelect = timeSelectTypes.includes(DynamicDateTimeSelect.HOUR);
this.hour.setDownEnable(canSelect && parseInt(value) > 0);
this.hour.setUpEnable(canSelect && parseInt(value) < 23);
} }
_checkMinute(value) { _checkMinute(value) {
this.minute.setDownEnable(parseInt(value) > 0); const { timeSelectTypes } = this.options;
this.minute.setUpEnable(parseInt(value) < 59); const canSelect = timeSelectTypes.includes(DynamicDateTimeSelect.MINUTE);
this.minute.setDownEnable(canSelect && parseInt(value) > 0);
this.minute.setUpEnable(canSelect && parseInt(value) < 59);
} }
_checkSecond(value) { _checkSecond(value) {
this.second.setDownEnable(parseInt(value) > 0); const { timeSelectTypes } = this.options;
this.second.setUpEnable(parseInt(value) < 59); const canSelect = timeSelectTypes.includes(DynamicDateTimeSelect.SECOND);
this.second.setDownEnable(canSelect && parseInt(value) > 0);
this.second.setUpEnable(canSelect && parseInt(value) < 59);
} }
_autoSwitch(v, type) { _autoSwitch(v, type) {

56
packages/fineui/src/widget/intervalslider/intervalslider.js

@ -23,19 +23,17 @@ import { Single, Editor } from "@/base";
import { AccurateCalculationModel } from "./model.accuratecalculation"; import { AccurateCalculationModel } from "./model.accuratecalculation";
import { SignTextEditor, SliderIconButton } from "../singleslider"; import { SignTextEditor, SliderIconButton } from "../singleslider";
const CONSTANTS = {
EDITOR_WIDTH: 58,
EDITOR_HEIGHT: 20,
LABEL_HEIGHT: 30,
SLIDER_HEIGHT: 30,
};
@shortcut() @shortcut()
export class IntervalSlider extends Single { export class IntervalSlider extends Single {
static xtype = "bi.interval_slider"; static xtype = "bi.interval_slider";
_constant = {
EDITOR_WIDTH: 58,
EDITOR_R_GAP: 60,
EDITOR_HEIGHT: 20,
SLIDER_WIDTH_HALF: 15,
LABEL_HEIGHT: 30,
SLIDER_WIDTH: 30,
SLIDER_HEIGHT: 30,
TRACK_HEIGHT: 24,
};
props = { props = {
baseCls: "bi-interval-slider bi-slider-track", baseCls: "bi-interval-slider bi-slider-track",
digit: false, digit: false,
@ -45,6 +43,8 @@ export class IntervalSlider extends Single {
value: { min: "", max: "" }, value: { min: "", max: "" },
lAlign: "center", lAlign: "center",
rAlign: "center", rAlign: "center",
labelHeight: CONSTANTS.LABEL_HEIGHT,
sliderHeight: CONSTANTS.SLIDER_HEIGHT,
}; };
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -59,8 +59,11 @@ export class IntervalSlider extends Single {
this.populate(); this.populate();
} }
getConstant() {
return CONSTANTS;
}
render() { render() {
const c = this._constant;
const o = this.options; const o = this.options;
this.enable = false; this.enable = false;
this.valueOne = ""; this.valueOne = "";
@ -86,8 +89,8 @@ export class IntervalSlider extends Single {
text: unit, text: unit,
allowBlank: false, allowBlank: false,
textAlign: lAlign, textAlign: lAlign,
width: BI.isNull(editorWidth) ? BI.toPix(c.EDITOR_WIDTH, 2) : BI.toPix(editorWidth, 2), width: isNull(editorWidth) ? toPix(CONSTANTS.EDITOR_WIDTH, 2) : toPix(editorWidth, 2),
height: toPix(c.EDITOR_HEIGHT, 2), height: toPix(CONSTANTS.EDITOR_HEIGHT, 2),
validationChecker: v => this._checkValidation(v), validationChecker: v => this._checkValidation(v),
}); });
this.labelOne.element.hover( this.labelOne.element.hover(
@ -116,8 +119,8 @@ export class IntervalSlider extends Single {
text: unit, text: unit,
allowBlank: false, allowBlank: false,
textAlign: rAlign, textAlign: rAlign,
width: BI.isNull(editorWidth) ? BI.toPix(c.EDITOR_WIDTH, 2) : BI.toPix(editorWidth, 2), width: isNull(editorWidth) ? toPix(CONSTANTS.EDITOR_WIDTH, 2) : toPix(editorWidth, 2),
height: toPix(c.EDITOR_HEIGHT, 2), height: toPix(CONSTANTS.EDITOR_HEIGHT, 2),
validationChecker: v => this._checkValidation(v), validationChecker: v => this._checkValidation(v),
}); });
this.labelTwo.element.hover( this.labelTwo.element.hover(
@ -152,7 +155,7 @@ export class IntervalSlider extends Single {
return { return {
type: VerticalFillLayout.xtype, type: VerticalFillLayout.xtype,
rowSize: [o.labelHeight || c.LABEL_HEIGHT, o.sliderHeight || c.SLIDER_HEIGHT], rowSize: [o.labelHeight, o.sliderHeight],
items: [ items: [
this._createLabelWrapper(), this._createLabelWrapper(),
{ {
@ -253,7 +256,6 @@ export class IntervalSlider extends Single {
_createLabelWrapper() { _createLabelWrapper() {
const o = this.options; const o = this.options;
const c = this._constant;
return { return {
el: { el: {
@ -275,7 +277,7 @@ export class IntervalSlider extends Single {
], ],
}, },
], ],
height: o.labelHeight || c.LABEL_HEIGHT, height: o.labelHeight,
}, },
top: 0, top: 0,
left: 0, left: 0,
@ -372,24 +374,6 @@ export class IntervalSlider extends Single {
return valid; return valid;
} }
_checkOverlap() {
const labelOneLeft = this.labelOne.element[0].offsetLeft;
const labelTwoLeft = this.labelTwo.element[0].offsetLeft;
if (labelOneLeft <= labelTwoLeft) {
if (labelTwoLeft - labelOneLeft < 90) {
this.labelTwo.element.css({ top: 40 });
} else {
this.labelTwo.element.css({ top: 0 });
}
} else {
if (labelOneLeft - labelTwoLeft < 90) {
this.labelTwo.element.css({ top: 40 });
} else {
this.labelTwo.element.css({ top: 0 });
}
}
}
_checkLabelPosition(oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) { _checkLabelPosition(oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) {
oldValueOne = parseFloat(oldValueOne); oldValueOne = parseFloat(oldValueOne);
oldValueTwo = parseFloat(oldValueTwo); oldValueTwo = parseFloat(oldValueTwo);

4
packages/fineui/src/widget/singleslider/button/editor.sign.text.js

@ -106,7 +106,7 @@ export class SignTextEditor extends Widget {
_checkText() { _checkText() {
const o = this.options; const o = this.options;
nextTick( nextTick(
bind(() => { () => {
if (this.editor.getValue() === "") { if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || ""); this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark"); this.text.element.addClass("bi-water-mark");
@ -116,7 +116,7 @@ export class SignTextEditor extends Widget {
this.text.setValue(v); this.text.setValue(v);
this.text.element.removeClass("bi-water-mark"); this.text.element.removeClass("bi-water-mark");
} }
}, this) }
); );
} }

Loading…
Cancel
Save