Browse Source

KERNEL-14316 chore: 代码同步

es6
Treecat 2 years ago
parent
commit
071b74a780
  1. 1
      packages/fineui/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  2. 1
      packages/fineui/src/case/trigger/trigger.text.js
  3. 2
      packages/fineui/src/case/trigger/trigger.text.select.js
  4. 193
      packages/fineui/src/core/2.base.js
  5. 12
      packages/fineui/src/core/utils/events/mousemovetracker.js

1
packages/fineui/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js

@ -39,6 +39,7 @@ export class TextValueCheckCombo extends Widget {
height: toPix(o.height, 2), height: toPix(o.height, 2),
text: o.text, text: o.text,
value: o.value, value: o.value,
defaultText: o.defaultText
}); });
this.popup = createWidget({ this.popup = createWidget({
type: TextValueCheckComboPopup.xtype, type: TextValueCheckComboPopup.xtype,

1
packages/fineui/src/case/trigger/trigger.text.js

@ -47,6 +47,7 @@ export class TextTrigger extends Trigger {
height: o.height, height: o.height,
text: text || o.defaultText, text: text || o.defaultText,
tipType: o.tipType, tipType: o.tipType,
title: o.title,
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
hgap: o.textHgap, hgap: o.textHgap,
vgap: o.textVgap, vgap: o.textVgap,

2
packages/fineui/src/case/trigger/trigger.text.select.js

@ -43,7 +43,7 @@ export class SelectTextTrigger extends Trigger {
textTgap: o.textTgap, textTgap: o.textTgap,
textBgap: o.textBgap, textBgap: o.textBgap,
tipType: o.tipType, tipType: o.tipType,
title: null, title: o.title,
allowClear: o.allowClear, allowClear: o.allowClear,
listeners: [ listeners: [
{ {

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

@ -8,8 +8,7 @@ import { Widget } from "./4.widget";
import { createWidget } from "./5.inject"; import { createWidget } from "./5.inject";
import { prepares, _global } from "./0.foundation"; import { prepares, _global } from "./0.foundation";
import { CRYPT_TYPE, aesDecrypt, aesEncrypt } from "./structure/aes"; import { CRYPT_TYPE, aesDecrypt, aesEncrypt } from "./structure/aes";
import { Date as DateEnum } from "./func/date"; import { Date as DateEnum, getMonthDays } from "./func/date";
/** /**
* todo: 理论这么写逻辑没问题摇个人把这个 BI 干掉 * todo: 理论这么写逻辑没问题摇个人把这个 BI 干掉
@ -29,9 +28,7 @@ function _apply(name) {
function _applyFunc(name) { function _applyFunc(name) {
return function () { return function () {
const args = Array.prototype.slice.call(arguments, 0); const args = Array.prototype.slice.call(arguments, 0);
args[1] = BI._.isFunction(args[1]) args[1] = BI._.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
? traverse(args[1], args[2])
: args[1];
return BI._[name](...args); return BI._[name](...args);
}; };
@ -60,24 +57,7 @@ export function warn(message) {
} }
export function UUID() { export function UUID() {
const f = [ const f = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f"
];
let str = ""; let str = "";
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
const r = _global.parseInt(f.length * Math.random(), 10); const r = _global.parseInt(f.length * Math.random(), 10);
@ -102,18 +82,12 @@ export function createWidgets(items, options, context) {
options || (options = {}); options || (options = {});
} }
return map(flatten(items), (i, item) => return map(flatten(items), (i, item) => createWidget(item, deepClone(options), context));
createWidget(item, deepClone(options), context)
);
} }
export function createItems(data, innerAttr, outerAttr) { export function createItems(data, innerAttr, outerAttr) {
innerAttr = isArray(innerAttr) innerAttr = isArray(innerAttr) ? innerAttr : makeArray(flatten(data).length, innerAttr || {});
? innerAttr outerAttr = isArray(outerAttr) ? outerAttr : makeArray(flatten(data).length, outerAttr || {});
: makeArray(flatten(data).length, innerAttr || {});
outerAttr = isArray(outerAttr)
? outerAttr
: makeArray(flatten(data).length, outerAttr || {});
return map(data, (i, item) => { return map(data, (i, item) => {
if (isArray(item)) { if (isArray(item)) {
@ -157,7 +131,7 @@ export function packageItems(items, layouts) {
items: [ items: [
extend({}, layouts[i].el, { extend({}, layouts[i].el, {
el: it, el: it,
}) }),
], ],
}) })
); );
@ -186,21 +160,9 @@ export function trans2Element(widgets) {
} }
// 集合相关方法 // 集合相关方法
BI._.each( BI._.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], name => {
[ BI[name] = _apply(name);
"where", });
"findWhere",
"invoke",
"pluck",
"shuffle",
"sample",
"toArray",
"size"
],
name => {
BI[name] = _apply(name);
}
);
BI._.each( BI._.each(
[ [
"get", "get",
@ -223,7 +185,7 @@ BI._.each(
"indexBy", "indexBy",
"countBy", "countBy",
"partition", "partition",
"clamp" "clamp",
], ],
name => { name => {
if (name === "any") { if (name === "any") {
@ -398,9 +360,7 @@ export function remove(obj, target, context) {
if (isArray(obj)) { if (isArray(obj)) {
for (i = 0; i < obj.length; i++) { for (i = 0; i < obj.length; i++) {
if ( if (
(targetIsFunction && (targetIsFunction && (target === obj[i] || target.apply(context, [i, obj[i]]) === true)) ||
(target === obj[i] ||
target.apply(context, [i, obj[i]]) === true)) ||
(!targetIsFunction && contains(target, obj[i])) (!targetIsFunction && contains(target, obj[i]))
) { ) {
obj.splice(i--, 1); obj.splice(i--, 1);
@ -409,9 +369,7 @@ export function remove(obj, target, context) {
} else { } else {
each(obj, (i, v) => { each(obj, (i, v) => {
if ( if (
(targetIsFunction && (targetIsFunction && (target === obj[i] || target.apply(context, [i, obj[i]]) === true)) ||
(target === obj[i] ||
target.apply(context, [i, obj[i]]) === true)) ||
(!targetIsFunction && contains(target, obj[i])) (!targetIsFunction && contains(target, obj[i]))
) { ) {
delete obj[i]; delete obj[i];
@ -450,11 +408,7 @@ export function abc2Int(string) {
str = string.toUpperCase(); str = string.toUpperCase();
for (let i = 0, len = str.length; i < len; ++i) { for (let i = 0, len = str.length; i < len; ++i) {
idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1; idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1;
if ( if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) {
idx >
(2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) /
26
) {
return 0; return 0;
} }
} }
@ -489,7 +443,7 @@ export function int2Abc(num) {
"W", "W",
"X", "X",
"Y", "Y",
"Z" "Z",
]; ];
let idx = num, let idx = num,
str = ""; str = "";
@ -530,7 +484,7 @@ BI._.each(
"range", "range",
"take", "take",
"takeRight", "takeRight",
"uniqBy" "uniqBy",
], ],
name => { name => {
BI[name] = _apply(name); BI[name] = _apply(name);
@ -658,7 +612,7 @@ BI._.each(
"isUndefined", "isUndefined",
"zipObject", "zipObject",
"cloneDeep", "cloneDeep",
"pickBy" "pickBy",
], ],
name => { name => {
BI[name] = _apply(name); BI[name] = _apply(name);
@ -730,10 +684,7 @@ export function init() {
while (prepares && prepares.length > 0) { while (prepares && prepares.length > 0) {
prepares.shift()(); prepares.shift()();
} }
while ( while (_global.___fineuiExposedFunction && _global.___fineuiExposedFunction.length > 0) {
_global.___fineuiExposedFunction &&
_global.___fineuiExposedFunction.length > 0
) {
_global.___fineuiExposedFunction.shift()(); _global.___fineuiExposedFunction.shift()();
} }
BI.initialized = true; BI.initialized = true;
@ -778,12 +729,7 @@ export function isWidthOrHeight(w) {
if (typeof w === "number") { if (typeof w === "number") {
return w >= 0; return w >= 0;
} else if (typeof w === "string") { } else if (typeof w === "string") {
return ( return /^\d{1,3}(\.\d)?%$/.test(w) || w === "auto" || /^\d+(\.\d+)?px$/.test(w) || /^calc/.test(w);
/^\d{1,3}(\.\d)?%$/.test(w) ||
w === "auto" ||
/^\d+(\.\d+)?px$/.test(w) ||
/^calc/.test(w)
);
} }
} }
@ -842,9 +788,7 @@ export function isDeepMatch(object, attrs) {
export function contains(obj, target, fromIndex) { export function contains(obj, target, fromIndex) {
if (!BI._.isArrayLike(obj)) obj = values(obj); if (!BI._.isArrayLike(obj)) obj = values(obj);
return ( return indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0;
indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0
);
} }
export function deepContains(obj, copy) { export function deepContains(obj, copy) {
@ -943,21 +887,9 @@ export function deepDiff(object, other) {
} }
// 通用方法 // 通用方法
BI._.each( BI._.each(["uniqueId", "result", "chain", "iteratee", "unescape", "before", "after", "chunk"], name => {
[ BI[name] = (...args) => BI._[name](...args);
"uniqueId", });
"result",
"chain",
"iteratee",
"unescape",
"before",
"after",
"chunk"
],
name => {
BI[name] = (...args) => BI._[name](...args);
}
);
export const uniqueId = BI.uniqueId; export const uniqueId = BI.uniqueId;
export const result = BI.result; export const result = BI.result;
export const chain = BI.chain; export const chain = BI.chain;
@ -968,21 +900,9 @@ export const after = BI.after;
export const chunk = BI.chunk; export const chunk = BI.chunk;
// 事件相关方法 // 事件相关方法
BI._.each( BI._.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], name => {
[ BI[name] = (...args) => BI._[name](...args);
"bind", });
"once",
"partial",
"debounce",
"throttle",
"delay",
"defer",
"wrap"
],
name => {
BI[name] = (...args) => BI._[name](...args);
}
);
export const bind = BI.bind; export const bind = BI.bind;
export const once = BI.once; export const once = BI.once;
export const partial = BI.partial; export const partial = BI.partial;
@ -1058,7 +978,7 @@ export const nextTick = (function () {
}); });
} }
}; };
}()); })();
// 数字相关方法 // 数字相关方法
BI._.each(["random"], name => { BI._.each(["random"], name => {
@ -1081,11 +1001,7 @@ export function parseInt(number) {
export function parseSafeInt(value) { export function parseSafeInt(value) {
const MAX_SAFE_INTEGER = 9007199254740991; const MAX_SAFE_INTEGER = 9007199254740991;
return value return value ? clamp(parseInt(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) : value === 0 ? value : 0;
? clamp(parseInt(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
: value === 0
? value
: 0;
} }
export function parseFloat(number) { export function parseFloat(number) {
@ -1113,9 +1029,7 @@ export function isInteger(number) {
} }
export function isNumeric(number) { export function isNumeric(number) {
return ( return !_global.isNaN(_global.parseFloat(number)) && _global.isFinite(number);
!_global.isNaN(_global.parseFloat(number)) && _global.isFinite(number)
);
} }
export function isFloat(number) { export function isFloat(number) {
@ -1372,10 +1286,7 @@ export function parseDateTime(str, fmt) {
const otherlength = 2; const otherlength = 2;
a[0] = str.substring(0, yearlength); a[0] = str.substring(0, yearlength);
a[1] = str.substring(yearlength, yearlength + otherlength); a[1] = str.substring(yearlength, yearlength + otherlength);
a[2] = str.substring( a[2] = str.substring(yearlength + otherlength, yearlength + otherlength * 2);
yearlength + otherlength,
yearlength + otherlength * 2
);
} }
const b = fmt.match(/%./g); const b = fmt.match(/%./g);
let i = 0, let i = 0,
@ -1406,11 +1317,7 @@ export function parseDateTime(str, fmt) {
case "%b": case "%b":
case "%B": case "%B":
for (j = 0; j < 12; ++j) { for (j = 0; j < 12; ++j) {
if ( if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() === a[i].toLowerCase()) {
BI.getMonthName(j)
.substr(0, a[i].length)
.toLowerCase() === a[i].toLowerCase()
) {
m = j; m = j;
break; break;
} }
@ -1455,7 +1362,7 @@ export function parseDateTime(str, fmt) {
m = today.getMonth(); m = today.getMonth();
} }
if (_global.isNaN(d)) { if (_global.isNaN(d)) {
d = today.getDate(); d = Math.min(getMonthDays(getDate(y, m)), today.getDate());
} }
if (_global.isNaN(hr)) { if (_global.isNaN(hr)) {
hr = today.getHours(); hr = today.getHours();
@ -1476,10 +1383,7 @@ export function parseDateTime(str, fmt) {
if (a[i].search(/[a-zA-Z]+/) !== -1) { if (a[i].search(/[a-zA-Z]+/) !== -1) {
let t = -1; let t = -1;
for (j = 0; j < 12; ++j) { for (j = 0; j < 12; ++j) {
if ( if (BI.getMonthName(j).substr(0, a[i].length).toLowerCase() === a[i].toLowerCase()) {
BI.getMonthName(j).substr(0, a[i].length).toLowerCase() ===
a[i].toLowerCase()
) {
t = j; t = j;
break; break;
} }
@ -1546,25 +1450,13 @@ export function getDate(...args) {
break; break;
// new Date(year, month, day, hour, minute, second, millisecond) // new Date(year, month, day, hour, minute, second, millisecond)
case 7: case 7:
dt = new Date( dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
args[0],
args[1],
args[2],
args[3],
args[4],
args[5],
args[6]
);
break; break;
default: default:
dt = new Date(); dt = new Date();
break; break;
} }
if ( if (isNotNull(BI.timeZone) && (arguments.length === 0 || (arguments.length === 1 && isNumber(arguments[0])))) {
isNotNull(BI.timeZone) &&
(arguments.length === 0 ||
(arguments.length === 1 && isNumber(arguments[0])))
) {
const localTime = dt.getTime(); const localTime = dt.getTime();
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准 // BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
const localOffset = dt.getTimezoneOffset() * 60000; // 获得当地时间偏移的毫秒数 const localOffset = dt.getTimezoneOffset() * 60000; // 获得当地时间偏移的毫秒数
@ -1611,15 +1503,7 @@ export function getTime() {
break; break;
// new Date(year, month, day, hour, minute, second, millisecond) // new Date(year, month, day, hour, minute, second, millisecond)
case 7: case 7:
dt = new Date( dt = new Date(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
args[0],
args[1],
args[2],
args[3],
args[4],
args[5],
args[6]
);
break; break;
default: default:
dt = new Date(); dt = new Date();
@ -1627,11 +1511,8 @@ export function getTime() {
} }
if (isNotNull(BI.timeZone)) { if (isNotNull(BI.timeZone)) {
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准 // BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
return ( return dt.getTime() - BI.timeZone - new Date().getTimezoneOffset() * 60000;
dt.getTime() - BI.timeZone - new Date().getTimezoneOffset() * 60000
);
} }
return dt.getTime(); return dt.getTime();
} }

12
packages/fineui/src/core/utils/events/mousemovetracker.js

@ -84,7 +84,7 @@ export class MouseMoveTracker {
// The mouse may move faster then the animation frame does. // The mouse may move faster then the animation frame does.
// Use `requestAnimationFrame` to avoid over-updating. // Use `requestAnimationFrame` to avoid over-updating.
this._animationFrameID = this._animationFrameID =
requestAnimationFrame(this._didMouseMove); requestAnimationFrame(() => this._didMouseMove(event));
} }
this._x = x; this._x = x;
@ -92,17 +92,17 @@ export class MouseMoveTracker {
event.preventDefault ? event.preventDefault() : (event.returnValue = false); event.preventDefault ? event.preventDefault() : (event.returnValue = false);
} }
_didMouseMove() { _didMouseMove(event) {
this._animationFrameID = null; this._animationFrameID = null;
this._onMove(this._deltaX, this._deltaY); this._onMove(this._deltaX, this._deltaY, event);
this._deltaX = 0; this._deltaX = 0;
this._deltaY = 0; this._deltaY = 0;
} }
_onMouseUp() { _onMouseUp(event) {
if (this._animationFrameID) { if (this._animationFrameID) {
this._didMouseMove(); this._didMouseMove(event);
} }
this._onMoveEnd(); this._onMoveEnd(event);
} }
} }

Loading…
Cancel
Save