Browse Source

Pull request #3404: KERNEL-14076 feat: 脚本循环依赖修复 && 无jira 替换 case 全部 xtype

Merge in VISUAL/fineui from ~TREECAT/fineui:es6 to es6

* commit '072054c7cddd7b0b7c32d449a2ce9600d6340cd4':
  KERNEL-14076 feat: 循环依赖修复 && 无jira 替换 case 全部 xtype
es6
treecat-罗群 2 years ago
parent
commit
825f83c574
  1. 175
      es6.js
  2. 59
      es6.xtype.js
  3. 14
      src/case/button/icon/icon.change.js
  4. 4
      src/case/button/icon/icon.trigger.js
  5. 8
      src/case/button/icon/iconhalf/icon.half.image.js
  6. 14
      src/case/button/icon/iconhalf/icon.half.js
  7. 25
      src/case/button/item.multiselect.js
  8. 8
      src/case/button/item.singleselect.icontext.js
  9. 9
      src/case/button/item.singleselect.js
  10. 32
      src/case/button/item.singleselect.radio.js
  11. 21
      src/case/button/node/node.arrow.js
  12. 38
      src/case/button/node/node.icon.arrow.js
  13. 11
      src/case/button/node/node.multilayer.icon.arrow.js
  14. 20
      src/case/button/node/node.plus.js
  15. 22
      src/case/button/node/siwtcher.tree.node.js
  16. 23
      src/case/button/switch.js
  17. 40
      src/case/button/treeitem/item.icon.treeleaf.js
  18. 16
      src/case/button/treeitem/item.multilayer.icon.treeleaf.js
  19. 14
      src/case/calendar/calendar.date.item.js
  20. 91
      src/case/calendar/calendar.js
  21. 76
      src/case/calendar/calendar.year.js
  22. 5
      src/case/checkbox/check.arrownode.js
  23. 5
      src/case/checkbox/check.checkingmarknode.js
  24. 10
      src/case/checkbox/check.first.treenode.js
  25. 10
      src/case/checkbox/check.last.treenode.js
  26. 10
      src/case/checkbox/check.mid.treenode.js
  27. 10
      src/case/checkbox/check.treenode.js
  28. 37
      src/case/colorchooser/colorchooser.custom.js
  29. 30
      src/case/colorchooser/colorchooser.js
  30. 170
      src/case/colorchooser/colorchooser.popup.hex.js
  31. 14
      src/case/colorchooser/colorchooser.popup.hex.simple.js
  32. 85
      src/case/colorchooser/colorchooser.popup.js
  33. 5
      src/case/colorchooser/colorchooser.simple.js
  34. 40
      src/case/colorchooser/colorchooser.trigger.js
  35. 37
      src/case/colorchooser/colorchooser.trigger.long.js
  36. 12
      src/case/colorchooser/colorpicker/button/button.colorpicker.js
  37. 15
      src/case/colorchooser/colorpicker/button/button.colorshow.js
  38. 24
      src/case/colorchooser/colorpicker/colorpicker.hex.js
  39. 221
      src/case/colorchooser/colorpicker/colorpicker.js
  40. 111
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.js
  41. 90
      src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js
  42. 95
      src/case/colorchooser/colorpicker/editor.colorpicker.js
  43. 60
      src/case/colorchooser/colorpicker/editor.colorpicker.simple.js
  44. 74
      src/case/colorchooser/farbtastic/farbtastic.js
  45. 18
      src/case/combo/bubblecombo/combo.bubble.js
  46. 2
      src/case/combo/bubblecombo/popup.bubble.js
  47. 13
      src/case/combo/editoriconcheckcombo/combo.editiconcheck.js
  48. 14
      src/case/combo/iconcombo/combo.icon.js
  49. 10
      src/case/combo/iconcombo/popup.iconcombo.js
  50. 11
      src/case/combo/iconcombo/trigger.iconcombo.js
  51. 10
      src/case/combo/icontextvaluecombo/combo.icontextvalue.js
  52. 10
      src/case/combo/icontextvaluecombo/popup.icontextvalue.js
  53. 36
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  54. 27
      src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js
  55. 45
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  56. 24
      src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js
  57. 16
      src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js
  58. 48
      src/case/combo/textvaluecombo/combo.textvalue.js
  59. 19
      src/case/combo/textvaluecombo/combo.textvaluesmall.js
  60. 39
      src/case/combo/textvaluecombo/popup.textvalue.js
  61. 69
      src/case/editor/editor.clear.js
  62. 66
      src/case/editor/editor.defaulttext.js
  63. 77
      src/case/editor/editor.shelter.js
  64. 79
      src/case/editor/editor.sign.js
  65. 88
      src/case/editor/editor.state.js
  66. 69
      src/case/editor/editor.state.simple.js
  67. 17
      src/case/layer/layer.multipopup.js
  68. 22
      src/case/layer/layer.panel.js
  69. 42
      src/case/layer/pane.list.js
  70. 38
      src/case/layer/panel.js
  71. 38
      src/case/linearsegment/button.linear.segment.js
  72. 44
      src/case/linearsegment/linear.segment.js
  73. 29
      src/case/list/list.select.js
  74. 8
      src/case/loader/loader.lazy.js
  75. 84
      src/case/loader/loader.list.js
  76. 26
      src/case/loader/sort.list.js
  77. 83
      src/case/pager/pager.all.count.js
  78. 104
      src/case/pager/pager.detail.js
  79. 57
      src/case/pager/pager.direction.js
  80. 6
      src/case/segment/button.segment.js
  81. 43
      src/case/segment/segment.js
  82. 37
      src/case/toolbar/toolbar.multiselect.js
  83. 24
      src/case/tree/tree.level.js
  84. 13
      src/case/tree/treeexpander/tree.expander.popup.js
  85. 18
      src/case/trigger/trigger.editor.js
  86. 5
      src/case/trigger/trigger.icon.js
  87. 29
      src/case/trigger/trigger.icon.text.js
  88. 5
      src/case/trigger/trigger.icon.text.select.js
  89. 51
      src/case/trigger/trigger.text.js
  90. 14
      src/case/trigger/trigger.text.select.js
  91. 5
      src/case/trigger/trigger.text.select.small.js
  92. 22
      src/case/trigger/trigger.text.small.js
  93. 14
      src/case/ztree/asynctree.js
  94. 529
      src/case/ztree/jquery.ztree.core-3.5.js
  95. 196
      src/case/ztree/jquery.ztree.excheck-3.5.js
  96. 12
      src/case/ztree/list/listasynctree.js
  97. 21
      src/case/ztree/list/listparttree.js
  98. 6
      src/case/ztree/list/listtreeview.js
  99. 40
      src/case/ztree/parttree.js
  100. 10
      src/case/ztree/tree.display.js
  101. Some files were not shown because too many files have changed in this diff Show More

175
es6.js

@ -3,7 +3,8 @@ const path = require("path");
const prettier = require("prettier"); const prettier = require("prettier");
const { exec } = require("child_process"); const { exec } = require("child_process");
const { search, initDepts, depts } = require("./es6.xtype"); const { search, initDepts, depts } = require("./es6.xtype");
const _ = require("lodash"); const lodash = require("lodash");
const DEPTS = depts;
// const XTYPE_ONLY = false; // const XTYPE_ONLY = false;
// const THIS_REPLACE = false; // const THIS_REPLACE = false;
@ -32,7 +33,8 @@ function parserImport(code) {
while (regResult) { while (regResult) {
importMap[regResult[2]] = regResult[1] importMap[regResult[2]] = regResult[1]
.split(",") .split(",")
.map(el => el.trim()).filter(el => el); .map(el => el.trim())
.filter(el => el);
regResult = reg.exec(code); regResult = reg.exec(code);
} }
@ -46,7 +48,7 @@ async function saveAndFixCode(path, code) {
} }
const prettierCode = prettier.format(_code, { const prettierCode = prettier.format(_code, {
tabWidth: 4, tabWidth: 4,
parser: 'babel', parser: "babel",
printWidth: 120, printWidth: 120,
}); });
fs.writeFileSync(path, prettierCode); fs.writeFileSync(path, prettierCode);
@ -58,56 +60,18 @@ async function saveAndFixCode(path, code) {
}); });
} }
const target = [ // const target = [];
"isNull",
"toPix",
"isKey",
"isObject",
"map",
"extend",
"isFunction",
"isEmptyArray",
"isArray",
"Controller",
"createWidget",
"Events",
"emptyFn",
"nextTick",
"bind",
"i18nText",
"isNotNull",
"isString",
"isNumber",
"isEmpty",
"isEmptyString",
"any",
"deepContains",
"isNotEmptyString",
"each",
"contains",
"remove",
"createItems",
"makeArrayByArray",
"VerticalAlign",
"pushDistinct",
"endWith",
"transformItems",
"print",
"Tree",
"Func",
"Selection",
];
// 加载模块 // 加载模块
const loader = { const loader = {
// G: { "@/core": { shortcut: true } }, // G: { "@/core": { shortcut: true } },
load(srcName, module) { load(srcName, module) {
const G = loader.G; const G = loader.G;
if (target.indexOf(module) >= 0) { // if (target.indexOf(module) >= 0) {
G["@/core"][module] = true; // G["@/core"][module] = true;
return true; // return true;
} // }
if (module.startsWith('"bi.')) { if (module.startsWith('"bi.')) {
const key = search(srcName, module); const key = search(srcName, module);
if (key) { if (key) {
@ -136,7 +100,7 @@ const loader = {
async function handleFile(srcName) { async function handleFile(srcName) {
await saveAndFixCode(srcName); await saveAndFixCode(srcName);
// 全局状态回归 // 全局状态回归
let G = loader.G = { }; let G = (loader.G = {});
const sourceCode = fs.readFileSync(srcName).toString(); const sourceCode = fs.readFileSync(srcName).toString();
@ -144,7 +108,7 @@ async function handleFile(srcName) {
if (!result) { if (!result) {
// console.log(`已经es6过,替换 xtype => ${srcName}`); // console.log(`已经es6过,替换 xtype => ${srcName}`);
if (!/export class/.test(sourceCode)) { if (!/export class/.test(sourceCode)) {
console.log("忽略文件", srcName); // console.log("忽略文件", srcName);
return; return;
} }
@ -167,7 +131,7 @@ async function handleFile(srcName) {
const importMap = parserImport(noXtypeCode); const importMap = parserImport(noXtypeCode);
// 合并原来的 import 到 G // 合并原来的 import 到 G
_.forEach(importMap, (depts, module) => { lodash.forEach(importMap, (depts, module) => {
depts.forEach(dept => { depts.forEach(dept => {
if (!G[module]) { if (!G[module]) {
G[module] = {}; G[module] = {};
@ -177,54 +141,108 @@ async function handleFile(srcName) {
}); });
}); });
// 合并 core
const crossPackages = fs.readdirSync("src"); // 合并包
_.forEach(G, (depts, module) => { const crossPackages = fs.readdirSync("src").map(el => `@/${el}`);
lodash.forEach(G, (depts, module) => {
crossPackages.forEach(crosspackage => { crossPackages.forEach(crosspackage => {
if (module.indexOf(crosspackage) >= 0) { if (module.indexOf(crosspackage.replace(/^@\//, "")) >= 0) {
if (!G[`@/${crosspackage}`]) { if (!G[crosspackage]) {
G[`@/${crosspackage}`] = {}; G[crosspackage] = {};
} }
Object.assign(G[`@/${crosspackage}`], depts); Object.assign(G[crosspackage], depts);
} }
}); });
}); });
const tmpG = {}; const tmpG = {};
_.forEach(G, (depts, module) => { lodash.forEach(G, (depts, module) => {
const flag = _.some(crossPackages, crosspackage => module.indexOf(crosspackage) >= 0 && !module.startsWith("@")); const flag = lodash.some(
crossPackages,
crosspackage =>
module.indexOf(crosspackage) >= 0 && !module.startsWith("@"),
);
if (!flag) { if (!flag) {
tmpG[module] = depts; tmpG[module] = depts;
} }
}); });
// 较验手工 import 错误
const map = {};
let conflict = false;
let circle = false; let circle = false;
_.forEach(tmpG, (imports, fromStr) => { // 处理循环依赖
if (srcName.indexOf("base") >= 0) { const forbiddenCrossRules = {
if (fromStr === "@/case" || fromStr === "@/base") { base: ["@/case", "@/base", "@/widget"],
"case": ["@/case", "@/widget"],
widget: ["@/widget"],
};
const forbiddenKeys = [];
const circleG = {};
lodash.forEach(G, (depts, module) => {
// 找出 rule
const packages = Object.keys(forbiddenCrossRules);
let key = packages.filter(
_package => srcName.indexOf(_package) >= 0,
);
if (key.length !== 1) {
throw new Error(
"理论不可能出现这个问题,需要 treecat 优化下找包逻辑1",
);
}
key = key[0];
const rule = forbiddenCrossRules[key];
if (lodash.includes(rule, module)) {
circle = true; circle = true;
const deptsArr = Object.keys(depts);
if (deptsArr.filter(dept => !DEPTS[dept]).length > 0) {
throw new Error(
"理论不可能出现这个问题,需要 treecat 优化下找包逻辑2",
);
} }
deptsArr
.filter(dept => DEPTS[dept])
.forEach(dept => {
const value = `@${DEPTS[dept].replace(path.resolve("src"), "").replace(/\\/g, "/").replace(/\.js$/, "")}`;
if (!tmpG[value]) {
tmpG[value] = {};
} }
tmpG[value][dept] = true;
});
forbiddenKeys.push(module);
}
});
Object.assign(tmpG, circleG);
forbiddenKeys.forEach(key => {
delete tmpG[key];
});
// 较验手工 import 错误
const map = {};
let conflict = false;
_.forEach(imports, (bools, _import) => { lodash.forEach(tmpG, (depts, module) => {
if (map[_import] && map[_import] !== fromStr) { lodash.forEach(depts, (_, _import) => {
if (map[_import] && map[_import] !== module) {
conflict = true; conflict = true;
} }
map[_import] = fromStr; map[_import] = module;
}); });
}); });
conflict && ConflictImport.push(srcName); conflict && ConflictImport.push(srcName);
circle && CircularDependency.push(srcName); circle && CircularDependency.push(srcName);
G = tmpG; G = tmpG;
const noImportCode = noXtypeCode.replace(/import {([\s\S]*?)} from "(.*?)";/g, ""); const noImportCode = noXtypeCode.replace(
/import {([\s\S]*?)} from "(.*?)";/g,
"",
);
let I = ""; let I = "";
Object.keys(G).forEach(key => { Object.keys(G).forEach(key => {
@ -243,7 +261,6 @@ async function handleFile(srcName) {
moduleKey = `./${moduleKey}`; moduleKey = `./${moduleKey}`;
} }
I += `import {${i}} from '${moduleKey}'\n`; I += `import {${i}} from '${moduleKey}'\n`;
}); });
const code = `${I}\n${noImportCode}`; const code = `${I}\n${noImportCode}`;
@ -255,7 +272,6 @@ async function handleFile(srcName) {
G["@/core"] = { shortcut: true }; G["@/core"] = { shortcut: true };
const clzName = result[1]; const clzName = result[1];
if (!clzName) { if (!clzName) {
@ -463,19 +479,6 @@ async function traverse(srcName) {
const srcName = process.argv[2]; const srcName = process.argv[2];
initDepts().then(async () => { initDepts().then(async () => {
const content = fs.readFileSync("src/core/2.base.js").toString();
let result = content.match(/export function (.*?)\(/g);
target.push(
...result.map(el =>
el.replace("export function ", "").replace("(", ""),
),
);
result = content.match(/export const (.*?) =/g);
target.push(
...result.map(el => el.replace("export const ", "").replace(" =", "")),
);
await traverse(srcName); await traverse(srcName);
// 对数据处理 // 对数据处理
@ -483,6 +486,6 @@ initDepts().then(async () => {
console.log(`导入冲突 ${el}`); console.log(`导入冲突 ${el}`);
}); });
CircularDependency.forEach(el => { CircularDependency.forEach(el => {
console.log(`出现循环依赖 ${el}`); console.log(`出现循环依赖(已经fixed) ${el}`);
}); });
}); });

59
es6.xtype.js

@ -1,35 +1,49 @@
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const lodash = require("lodash");
const depts = {}; const depts = {};
async function handle(filename) { async function handle(filename) {
// 找clzName if (path.extname(filename) !== ".js") {
const code = fs.readFileSync(filename); return;
}
const code = fs.readFileSync(filename).toString();
const inheritRegResult = /BI\.(.*?)\s=\sBI\.inherit\(/.exec(code); const inheritRegResult = /BI\.(.*?)\s=\sBI\.inherit\(/.exec(code);
let clzName;
if (inheritRegResult) { if (inheritRegResult) {
clzName = inheritRegResult[1]; const clzName = inheritRegResult[1];
} else { depts[clzName] = filename;
const clzRegResult = /export\s+class\s+(.*?)\s+/.exec(code);
if (clzRegResult) {
clzName = clzRegResult[1];
} else { } else {
return; // 一个文件夹里面可能有多个 xtype
} const reg = /export\s+class\s+(.*?)([\s|{])([\w\W]*?)static xtype\s?=\s?((["|'])(.*?)(\5))/g;
const xtypeResult = /static xtype = (.*?)(;|\s)/.exec(code); Array.from(code.matchAll(reg)).forEach(res => {
// 找一下 xtype const xtype = res[4];
if (xtypeResult) { depts[xtype] = {
depts[xtypeResult[1]] = { clzName: res[1],
clzName,
clzPath: filename, clzPath: filename,
}; };
} else { });
// console.log(`${filename} 没有 xtype`); // 同时找一下 export
if (path.basename(filename) !== "index.js") {
const regs = [
/export function (.*?)\(/g,
/export const (.*?) =/g,
/export class (.*?) /g,
/export \{([\w\W]*?)\}/g,
];
regs.forEach((reg, index) => {
Array.from(code.matchAll(reg)).forEach(el => {
depts[el[1]] = filename;
if (index === 3) {
el[1].split(",").map(el => el.trim()).forEach(key => {
depts[key] = filename;
});
}
});
});
} }
} }
depts[clzName] = filename;
} }
function isExist(filePath) { function isExist(filePath) {
@ -53,6 +67,13 @@ async function bfs(filename) {
async function initDepts() { async function initDepts() {
// dfs 构建依赖关系 // dfs 构建依赖关系
await bfs(path.resolve("src")); await bfs(path.resolve("src"));
const m = {};
lodash.forEach(depts, value => {
if (typeof value === "object") {
m[value.clzName] = value.clzPath;
}
});
Object.assign(depts, m);
} }

14
src/case/button/icon/icon.change.js

@ -1,6 +1,5 @@
import { Single } from "../../../base/single/0.single"; import { IconButton, Single } from "@/base";
import { IconButton } from "../../../base/single/button/buttons/button.icon"; import { shortcut, extend, emptyFn, isFunction, createWidget, Controller } from "@/core";
import { shortcut, extend, emptyFn, isFunction, createWidget, Controller } from "../../../core";
/** /**
* 可以改变图标的button * 可以改变图标的button
@ -15,7 +14,6 @@ export class IconChangeButton extends Single {
static xtype = "bi.icon_change_button"; static xtype = "bi.icon_change_button";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -42,12 +40,14 @@ export class IconChangeButton extends Single {
_init() { _init() {
const o = this.options; const o = this.options;
o.iconCls = isFunction(o.iconCls) ? this.__watch(o.iconCls, (context, newValue) => { o.iconCls = isFunction(o.iconCls)
? this.__watch(o.iconCls, (context, newValue) => {
this.setIcon(newValue); this.setIcon(newValue);
}) : o.iconCls; })
: o.iconCls;
super._init(...arguments); super._init(...arguments);
this.button = createWidget({ this.button = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
element: this, element: this,
cls: o.iconCls, cls: o.iconCls,
height: o.height, height: o.height,

4
src/case/button/icon/icon.trigger.js

@ -1,5 +1,5 @@
import { IconButton } from "../../../base/single/button/buttons/button.icon"; import { IconButton } from "@/base";
import { shortcut, extend } from "../../../core"; import { shortcut, extend } from "@/core";
/** /**
* 统一的trigger图标按钮 * 统一的trigger图标按钮

8
src/case/button/icon/iconhalf/icon.half.image.js

@ -1,6 +1,5 @@
import { IconButton } from "../../../../base/single/button/buttons/button.icon"; import { IconButton } from "@/base";
import { shortcut, extend } from "../../../../core"; import { shortcut, extend } from "@/core";
/** /**
* guy * guy
@ -10,7 +9,7 @@ import { shortcut, extend } from "../../../../core";
@shortcut() @shortcut()
export class HalfIconButton extends IconButton { export class HalfIconButton extends IconButton {
static xtype = "bi.half_icon_button"; static xtype = "bi.half_icon_button";
static EVENT_CHANGE = IconButton.EVENT_CHANGE static EVENT_CHANGE = IconButton.EVENT_CHANGE;
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -25,4 +24,3 @@ export class HalfIconButton extends IconButton {
}); });
} }
} }

14
src/case/button/icon/iconhalf/icon.half.js

@ -1,5 +1,5 @@
import { BasicButton } from "../../../../base/single/button/button.basic"; import { CenterAdaptLayout, DefaultLayout, shortcut, extend } from "@/core";
import { shortcut, extend } from "../../../../core"; import { BasicButton } from "@/base";
/** /**
* guy * guy
@ -27,13 +27,15 @@ export class HalfButton extends BasicButton {
const o = this.options; const o = this.options;
return { return {
type: "bi.center_adapt", type: CenterAdaptLayout.xtype,
items: [{ items: [
type: "bi.default", {
type: DefaultLayout.xtype,
cls: "bi-half-button bi-high-light-border", cls: "bi-half-button bi-high-light-border",
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight, height: o.iconHeight,
}], },
],
}; };
} }

25
src/case/button/item.multiselect.js

@ -1,5 +1,5 @@
import { BasicButton } from "../../base/single/button/button.basic"; import { Checkbox, Label, BasicButton } from "@/base";
import { shortcut, extend, createWidget } from "../../core"; import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend, createWidget } from "@/core";
/** /**
* guy * guy
@ -11,7 +11,6 @@ export class MultiSelectItem extends BasicButton {
static xtype = "bi.multi_select_item"; static xtype = "bi.multi_select_item";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
extraCls: "bi-multi-select-item", extraCls: "bi-multi-select-item",
@ -26,19 +25,21 @@ export class MultiSelectItem extends BasicButton {
render() { render() {
const o = this.options; const o = this.options;
this.checkbox = createWidget({ this.checkbox = createWidget({
type: "bi.checkbox", type: Checkbox.xtype,
}); });
return { return {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{ items: [
type: "bi.center_adapt", {
type: CenterAdaptLayout.xtype,
items: [this.checkbox], items: [this.checkbox],
}, { },
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: (_ref) => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -55,7 +56,8 @@ export class MultiSelectItem extends BasicButton {
value: o.value, value: o.value,
py: o.py, py: o.py,
}, },
}], },
],
}; };
} }
@ -88,4 +90,3 @@ export class MultiSelectItem extends BasicButton {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }

8
src/case/button/item.singleselect.icontext.js

@ -1,5 +1,5 @@
import { Single } from "../../base/single/0.single"; import { IconTextItem, Single } from "@/base";
import { shortcut, extend, createWidget, Controller } from "../../core"; import { shortcut, extend, createWidget, Controller } from "@/core";
/** /**
* Created by GUY on 2016/2/2. * Created by GUY on 2016/2/2.
@ -25,7 +25,7 @@ export class SingleSelectIconTextItem extends Single {
render() { render() {
const o = this.options; const o = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.icon_text_item", type: IconTextItem.xtype,
element: this, element: this,
cls: o.iconCls, cls: o.iconCls,
once: o.once, once: o.once,
@ -73,5 +73,3 @@ export class SingleSelectIconTextItem extends Single {
this.text.unRedMark(...arguments); this.text.unRedMark(...arguments);
} }
} }

9
src/case/button/item.singleselect.js

@ -1,5 +1,5 @@
import { BasicButton } from "../../base/single/button/button.basic"; import { Label, BasicButton } from "@/base";
import { shortcut, extend, createWidget } from "../../core"; import { shortcut, extend, createWidget } from "@/core";
@shortcut() @shortcut()
export class SingleSelectItem extends BasicButton { export class SingleSelectItem extends BasicButton {
@ -21,7 +21,7 @@ export class SingleSelectItem extends BasicButton {
render() { render() {
const o = this.options; const o = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
element: this, element: this,
textAlign: o.textAlign, textAlign: o.textAlign,
whiteSpace: "nowrap", whiteSpace: "nowrap",
@ -66,6 +66,3 @@ export class SingleSelectItem extends BasicButton {
super.setSelected(...arguments); super.setSelected(...arguments);
} }
} }

32
src/case/button/item.singleselect.radio.js

@ -1,5 +1,5 @@
import { BasicButton } from "../../base/single/button/button.basic"; import { VerticalAdaptLayout, CenterAdaptLayout, shortcut, extend } from "@/core";
import { shortcut, extend } from "../../core"; import { Radio, Label, BasicButton } from "@/base";
/** /**
* guy * guy
@ -27,20 +27,24 @@ export class SingleSelectRadioItem extends BasicButton {
const o = this.options; const o = this.options;
return { return {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [{ items: [
type: "bi.center_adapt", {
items: [{ type: CenterAdaptLayout.xtype,
type: "bi.radio", items: [
ref: _ref => { {
type: Radio.xtype,
ref: (_ref) => {
this.radio = _ref; this.radio = _ref;
}, },
}], },
}, { ],
},
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: (_ref) => {
this.text = _ref; this.text = _ref;
}, },
cls: "list-item-text", cls: "list-item-text",
@ -57,7 +61,8 @@ export class SingleSelectRadioItem extends BasicButton {
value: o.value, value: o.value,
py: o.py, py: o.py,
}, },
}], },
],
}; };
} }
@ -90,4 +95,3 @@ export class SingleSelectRadioItem extends BasicButton {
this.radio.setSelected(v); this.radio.setSelected(v);
} }
} }

21
src/case/button/node/node.arrow.js

@ -1,5 +1,6 @@
import { NodeButton } from "../../../base/single/button/button.node"; import { ArrowTreeGroupNodeCheckbox } from "../../checkbox";
import { shortcut, extend, createWidget } from "../../../core"; import { VerticalAdaptLayout, shortcut, extend, createWidget } from "@/core";
import { Label, NodeButton } from "@/base";
/** /**
* Created by roy on 15/10/16. * Created by roy on 15/10/16.
@ -24,18 +25,20 @@ export class ArrowNode extends NodeButton {
render() { render() {
const o = this.options; const o = this.options;
this.checkbox = createWidget({ this.checkbox = createWidget({
type: "bi.arrow_group_node_checkbox", type: ArrowTreeGroupNodeCheckbox.xtype,
expandIcon: o.expandIcon, expandIcon: o.expandIcon,
collapseIcon: o.collapseIcon, collapseIcon: o.collapseIcon,
}); });
return { return {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, { items: [
this.checkbox,
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: (_ref) => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -51,7 +54,8 @@ export class ArrowNode extends NodeButton {
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
}, },
}], },
],
}; };
} }
@ -78,4 +82,3 @@ export class ArrowNode extends NodeButton {
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
} }
} }

38
src/case/button/node/node.icon.arrow.js

@ -1,5 +1,6 @@
import { NodeButton } from "../../../base/single/button/button.node"; import { ArrowTreeGroupNodeCheckbox } from "../../checkbox";
import { shortcut, extend, createWidget, Controller, isNotNull } from "../../../core"; import { IconLabel, Label, NodeButton } from "@/base";
import { shortcut, extend, createWidget, Controller, isNotNull } from "@/core";
/** /**
* Created by User on 2016/3/31. * Created by User on 2016/3/31.
@ -35,7 +36,7 @@ export class IconArrowNode extends NodeButton {
super._init.apply(this, arguments); super._init.apply(this, arguments);
const o = this.options; const o = this.options;
this.checkbox = createWidget({ this.checkbox = createWidget({
type: "bi.arrow_group_node_checkbox", type: ArrowTreeGroupNodeCheckbox.xtype,
expandIcon: o.expandIcon, expandIcon: o.expandIcon,
collapseIcon: o.collapseIcon, collapseIcon: o.collapseIcon,
width: 24, width: 24,
@ -43,7 +44,7 @@ export class IconArrowNode extends NodeButton {
}); });
const icon = createWidget({ const icon = createWidget({
type: "bi.icon_label", type: IconLabel.xtype,
width: 24, width: 24,
cls: o.iconCls, cls: o.iconCls,
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
@ -51,7 +52,7 @@ export class IconArrowNode extends NodeButton {
}); });
createWidget({ createWidget({
type: "bi.label", type: Label.xtype,
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
@ -62,7 +63,7 @@ export class IconArrowNode extends NodeButton {
py: o.py, py: o.py,
keyword: o.keyword, keyword: o.keyword,
}); });
this.checkbox.on(Controller.EVENT_CHANGE, type => { this.checkbox.on(Controller.EVENT_CHANGE, (type) => {
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
if (this.checkbox.isSelected()) { if (this.checkbox.isSelected()) {
this.triggerExpand(); this.triggerExpand();
@ -72,19 +73,32 @@ export class IconArrowNode extends NodeButton {
} }
}); });
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(
BI.Direction.Left,
{
width: o.iconWrapperWidth, width: o.iconWrapperWidth,
el: this.checkbox, el: this.checkbox,
}, { },
{
width: 16, width: 16,
el: icon, el: icon,
}, this.text); },
createWidget(extend({ this.text
);
createWidget(
extend(
{
element: this, element: this,
}, BI.LogicFactory.createLogic(type, extend(o.logic, { },
BI.LogicFactory.createLogic(
type,
extend(o.logic, {
items, items,
rgap: 5, rgap: 5,
})))); })
)
)
);
} }
doRedMark() { doRedMark() {

11
src/case/button/node/node.multilayer.icon.arrow.js

@ -1,5 +1,6 @@
import { NodeButton } from "../../../base/single/button/button.node"; import { IconArrowNode } from "./node.icon.arrow";
import { shortcut, extend, createWidget, Controller, count, makeArray } from "../../../core"; import { Layout, HorizontalAdaptLayout, shortcut, extend, createWidget, Controller, count, makeArray } from "@/core";
import { NodeButton } from "@/base";
@shortcut() @shortcut()
export class MultiLayerIconArrowNode extends NodeButton { export class MultiLayerIconArrowNode extends NodeButton {
@ -25,7 +26,7 @@ export class MultiLayerIconArrowNode extends NodeButton {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.node = createWidget({ this.node = createWidget({
type: "bi.icon_arrow_node", type: IconArrowNode.xtype,
iconCls: o.iconCls, iconCls: o.iconCls,
cls: "bi-list-item-none", cls: "bi-list-item-none",
id: o.id, id: o.id,
@ -48,14 +49,14 @@ export class MultiLayerIconArrowNode extends NodeButton {
const items = []; const items = [];
count(0, o.layer, () => { count(0, o.layer, () => {
items.push({ items.push({
type: "bi.layout", type: Layout.xtype,
width: 15, width: 15,
height: o.height, height: o.height,
}); });
}); });
items.push(this.node); items.push(this.node);
createWidget({ createWidget({
type: "bi.horizontal_adapt", type: HorizontalAdaptLayout.xtype,
element: this, element: this,
columnSize: makeArray(o.layer, 15), columnSize: makeArray(o.layer, 15),
items, items,

20
src/case/button/node/node.plus.js

@ -1,5 +1,6 @@
import { NodeButton } from "../../../base/single/button/button.node"; import { TreeNodeCheckbox } from "../../checkbox";
import { shortcut, extend, createWidget, Controller } from "../../../core"; import { VerticalAdaptLayout, shortcut, extend, createWidget, Controller } from "@/core";
import { Label, NodeButton } from "@/base";
/** /**
* 加号表示的组节点 * 加号表示的组节点
@ -26,7 +27,7 @@ export class PlusGroupNode extends NodeButton {
render() { render() {
const o = this.options; const o = this.options;
this.checkbox = createWidget({ this.checkbox = createWidget({
type: "bi.tree_node_checkbox", type: TreeNodeCheckbox.xtype,
iconHeight: o.height, iconHeight: o.height,
iconWidth: o.iconWrapperWidth || o.height, iconWidth: o.iconWrapperWidth || o.height,
}); });
@ -39,12 +40,14 @@ export class PlusGroupNode extends NodeButton {
}); });
return { return {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: [o.iconWrapperWidth || o.height, "fill"], columnSize: [o.iconWrapperWidth || o.height, "fill"],
items: [this.checkbox, { items: [
this.checkbox,
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: (_ref) => {
this.text = _ref; this.text = _ref;
}, },
textAlign: "left", textAlign: "left",
@ -60,7 +63,8 @@ export class PlusGroupNode extends NodeButton {
keyword: o.keyword, keyword: o.keyword,
py: o.py, py: o.py,
}, },
}], },
],
}; };
} }

22
src/case/button/node/siwtcher.tree.node.js

@ -1,5 +1,5 @@
import { NodeButton } from "../../../base/single/button/button.node"; import { IconLabel, NodeButton } from "@/base";
import { shortcut, extend } from "../../../core"; import { shortcut, extend } from "@/core";
@shortcut() @shortcut()
export class TreeNodeSwitcher extends NodeButton { export class TreeNodeSwitcher extends NodeButton {
@ -21,7 +21,7 @@ export class TreeNodeSwitcher extends NodeButton {
const [collapse, expand] = this.getIconCls(); const [collapse, expand] = this.getIconCls();
return { return {
type: "bi.icon_label", type: IconLabel.xtype,
iconWidth: this.options.iconWidth, iconWidth: this.options.iconWidth,
iconHeight: this.options.iconHeight, iconHeight: this.options.iconHeight,
cls: this.options.open ? expand : collapse, cls: this.options.open ? expand : collapse,
@ -32,16 +32,24 @@ export class TreeNodeSwitcher extends NodeButton {
const options = this.options; const options = this.options;
if (options.layer === 0 && options.isFirstNode && options.isLastNode) { if (options.layer === 0 && options.isFirstNode && options.isLastNode) {
// 只有一层,并且是第一个节点,并且是最后一个节点 // 只有一层,并且是第一个节点,并且是最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type1", "tree-expand-icon-type1"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type1", "tree-expand-icon-type1"];
} else if (options.layer === 0 && options.isFirstNode) { } else if (options.layer === 0 && options.isFirstNode) {
// 第一层,并且是第一个节点 // 第一层,并且是第一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type2", "tree-expand-icon-type2"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type2", "tree-expand-icon-type2"];
} else if (options.isLastNode) { } else if (options.isLastNode) {
// 最后一个节点 // 最后一个节点
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type4", "tree-expand-icon-type4"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type4", "tree-expand-icon-type4"];
} else { } else {
// 其他情况 // 其他情况
return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"] : ["tree-collapse-icon-type3", "tree-expand-icon-type3"]; return BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? ["tree-solid-collapse-icon-type1", "tree-solid-expand-icon-type1"]
: ["tree-collapse-icon-type3", "tree-expand-icon-type3"];
} }
} }

23
src/case/button/switch.js

@ -1,10 +1,11 @@
import { AbsoluteLayout, shortcut } from "@/core";
import { TextButton, Label, BasicButton } from "@/base";
/** /**
* Created by Windy on 2018/2/1. * Created by Windy on 2018/2/1.
*/ */
import { BasicButton } from "../../base/single/button/button.basic";
import { shortcut } from "../../core";
@shortcut() @shortcut()
export class Switch extends BasicButton { export class Switch extends BasicButton {
static xtype = "bi.switch"; static xtype = "bi.switch";
@ -30,14 +31,14 @@ export class Switch extends BasicButton {
const tgap = (o.height - c.CIRCLE_SIZE) / 2; const tgap = (o.height - c.CIRCLE_SIZE) / 2;
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
ref: _ref => { ref: (_ref) => {
this.layout = _ref; this.layout = _ref;
}, },
items: [ items: [
{ {
el: { el: {
type: "bi.text_button", type: TextButton.xtype,
cls: "circle-button", cls: "circle-button",
}, },
width: 12, width: 12,
@ -46,27 +47,27 @@ export class Switch extends BasicButton {
left: o.selected ? 28 : 4, left: o.selected ? 28 : 4,
}, },
{ {
type: "bi.label", type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Open"), text: BI.i18nText("BI-Basic_Simple_Open"),
cls: "content-tip", cls: "content-tip",
left: 8, left: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && o.selected), invisible: !(o.showTip && o.selected),
ref: _ref => { ref: (_ref) => {
this.openTip = _ref; this.openTip = _ref;
}, },
}, },
{ {
type: "bi.label", type: Label.xtype,
text: BI.i18nText("BI-Basic_Simple_Close"), text: BI.i18nText("BI-Basic_Simple_Close"),
cls: "content-tip", cls: "content-tip",
right: 8, right: 8,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && !o.selected), invisible: !(o.showTip && !o.selected),
ref: _ref => { ref: (_ref) => {
this.closeTip = _ref; this.closeTip = _ref;
}, },
} },
], ],
}; };
} }

40
src/case/button/treeitem/item.icon.treeleaf.js

@ -1,5 +1,5 @@
import { BasicButton } from "../../../base/single/button/button.basic"; import { CenterAdaptLayout, shortcut, extend, createWidget } from "@/core";
import { shortcut, extend, createWidget } from "../../../core"; import { Icon, Label, BasicButton } from "@/base";
@shortcut() @shortcut()
export class IconTreeLeafItem extends BasicButton { export class IconTreeLeafItem extends BasicButton {
@ -23,18 +23,20 @@ export class IconTreeLeafItem extends BasicButton {
const o = this.options; const o = this.options;
const icon = createWidget({ const icon = createWidget({
type: "bi.center_adapt", type: CenterAdaptLayout.xtype,
width: 24, width: 24,
cls: o.iconCls, cls: o.iconCls,
items: [{ items: [
type: "bi.icon", {
type: Icon.xtype,
width: o.iconWidth, width: o.iconWidth,
height: o.iconHeight, height: o.iconHeight,
}], },
],
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
@ -46,18 +48,30 @@ export class IconTreeLeafItem extends BasicButton {
keyword: o.keyword, keyword: o.keyword,
}); });
const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { const items = BI.LogicFactory.createLogicItemsByDirection(
BI.Direction.Left,
{
width: 16, width: 16,
el: icon, el: icon,
}, { },
{
el: this.text, el: this.text,
}); }
createWidget(extend({ );
createWidget(
extend(
{
element: this, element: this,
}, BI.LogicFactory.createLogic(type, extend(o.logic, { },
BI.LogicFactory.createLogic(
type,
extend(o.logic, {
items, items,
hgap: 5, hgap: 5,
})))); })
)
)
);
} }
doRedMark() { doRedMark() {

16
src/case/button/treeitem/item.multilayer.icon.treeleaf.js

@ -1,5 +1,6 @@
import { BasicButton } from "../../../base/single/button/button.basic"; import { IconTreeLeafItem } from "./item.icon.treeleaf";
import { shortcut, extend, createWidget, Controller, makeArray, count } from "../../../core"; import { Layout, HorizontalAdaptLayout, shortcut, extend, createWidget, Controller, makeArray, count } from "@/core";
import { BasicButton } from "@/base";
/** /**
* @class BI.MultiLayerIconTreeLeafItem * @class BI.MultiLayerIconTreeLeafItem
@ -24,7 +25,7 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.item = createWidget({ this.item = createWidget({
type: "bi.icon_tree_leaf_item", type: IconTreeLeafItem.xtype,
cls: "bi-list-item-none", cls: "bi-list-item-none",
iconCls: o.iconCls, iconCls: o.iconCls,
id: o.id, id: o.id,
@ -41,7 +42,8 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
}); });
this.item.on(Controller.EVENT_CHANGE, (...args) => { this.item.on(Controller.EVENT_CHANGE, (...args) => {
const [type] = args; const [type] = args;
if (type === BI.Events.CLICK) {// 本身实现click功能 if (type === BI.Events.CLICK) {
// 本身实现click功能
return; return;
} }
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
@ -50,14 +52,14 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
const items = []; const items = [];
count(0, o.layer, () => { count(0, o.layer, () => {
items.push({ items.push({
type: "bi.layout", type: Layout.xtype,
width: 15, width: 15,
height: o.height, height: o.height,
}); });
}); });
items.push(this.item); items.push(this.item);
createWidget({ createWidget({
type: "bi.horizontal_adapt", type: HorizontalAdaptLayout.xtype,
element: this, element: this,
columnSize: makeArray(o.layer, 15), columnSize: makeArray(o.layer, 15),
items, items,
@ -102,5 +104,3 @@ export class MultiLayerIconTreeLeafItem extends BasicButton {
return this.options.value; return this.options.value;
} }
} }

14
src/case/calendar/calendar.date.item.js

@ -1,5 +1,5 @@
import { shortcut } from "@/core"; import { AbsoluteLayout, shortcut } from "@/core";
import { BasicButton } from "@/base"; import { TextItem, BasicButton } from "@/base";
/** /**
* 专门为calendar的视觉加的button作为私有button,不能配置任何属性也不要用这个玩意 * 专门为calendar的视觉加的button作为私有button,不能配置任何属性也不要用这个玩意
@ -19,10 +19,11 @@ export class CalendarDateItem extends BasicButton {
const { text, value, lgap, rgap, tgap, bgap } = this.options; const { text, value, lgap, rgap, tgap, bgap } = this.options;
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: { el: {
type: "bi.text_item", type: TextItem.xtype,
cls: "bi-border-radius bi-list-item-select", cls: "bi-border-radius bi-list-item-select",
textAlign: "center", textAlign: "center",
text, text,
@ -35,7 +36,8 @@ export class CalendarDateItem extends BasicButton {
right: rgap, right: rgap,
top: tgap, top: tgap,
bottom: bgap, bottom: bgap,
}], }
],
}; };
} }

91
src/case/calendar/calendar.js

@ -1,4 +1,27 @@
import { shortcut, Widget, getDate, each, range, extend, isLeapYear, Date, StartOfWeek, checkDateVoid, map, createWidget, createItems, LogicFactory, Controller, getShortDayName, getOffsetDate, isNotEmptyString, parseInt } from "@/core"; import { Label, ButtonGroup } from "@/base";
import {
CenterLayout,
shortcut,
Widget,
getDate,
each,
range,
extend,
isLeapYear,
Date,
StartOfWeek,
checkDateVoid,
map,
createWidget,
createItems,
LogicFactory,
Controller,
getShortDayName,
getOffsetDate,
isNotEmptyString,
parseInt
} from "@/core";
import { CalendarDateItem } from "./calendar.date.item";
/** /**
* Created by GUY on 2015/8/28. * Created by GUY on 2015/8/28.
@ -29,7 +52,7 @@ export class Calendar extends Widget {
if (page < 0 && page % 12 !== 0) { if (page < 0 && page % 12 !== 0) {
year--; year--;
} }
const month = page >= 0 ? (page % 12) : ((12 + page % 12) % 12); const month = page >= 0 ? page % 12 : (12 + (page % 12)) % 12;
return { return {
year: getDate().getFullYear() + year, year: getDate().getFullYear() + year,
@ -53,7 +76,9 @@ export class Calendar extends Widget {
}); });
} }
_dateCreator(Y, M, D) { _dateCreator(Y, M, D) {
const { min, max } = this.options, log = {}, De = getDate(); const { min, max } = this.options,
log = {},
De = getDate();
const mins = min.match(/\d+/g); const mins = min.match(/\d+/g);
const maxs = max.match(/\d+/g); const maxs = max.match(/\d+/g);
@ -78,7 +103,9 @@ export class Calendar extends Widget {
const items = []; const items = [];
each(range(42), i => { each(range(42), i => {
const td = {}; const td = {};
let YY = log.ymd[0], MM = log.ymd[1] + 1, DD; let YY = log.ymd[0],
MM = log.ymd[1] + 1,
DD;
// 上个月的日期 // 上个月的日期
if (i < offSetFDay) { if (i < offSetFDay) {
td.lastMonth = true; td.lastMonth = true;
@ -112,45 +139,59 @@ export class Calendar extends Widget {
const { year, month, day, logic } = this.options; const { year, month, day, logic } = this.options;
const items = map(this._getWeekLabel(), (i, value) => { const items = map(this._getWeekLabel(), (i, value) => {
return { return {
type: "bi.label", type: Label.xtype,
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
text: value, text: value,
}; };
}); });
const title = createWidget({ const title = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
height: 44, height: 44,
items, items,
layouts: [{ layouts: [
type: "bi.center", {
type: CenterLayout.xtype,
hgap: 5, hgap: 5,
vgap: 10, vgap: 10,
}], }
],
}); });
this.days = createWidget({ this.days = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
items: createItems(this._getItems(), {}), items: createItems(this._getItems(), {}),
value: `${year}-${month}-${day}`, value: `${year}-${month}-${day}`,
layouts: [LogicFactory.createLogic("table", extend({}, logic, { layouts: [
LogicFactory.createLogic(
"table",
extend({}, logic, {
columns: 7, columns: 7,
rows: 6, rows: 6,
columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7], columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8, rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + 8,
}))], })
)
],
}); });
this.days.on(Controller.EVENT_CHANGE, (...args) => { this.days.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
createWidget(extend({ createWidget(
extend(
{
element: this, element: this,
},
}, LogicFactory.createLogic("vertical", extend({}, logic, { LogicFactory.createLogic(
"vertical",
extend({}, logic, {
items: LogicFactory.createLogicItemsByDirection("top", title, { items: LogicFactory.createLogicItemsByDirection("top", title, {
el: this.days, el: this.days,
tgap: -5, tgap: -5,
}), }),
})))); })
)
)
);
} }
_getWeekLabel() { _getWeekLabel() {
@ -160,7 +201,9 @@ export class Calendar extends Widget {
isFrontDate() { isFrontDate() {
const { year, month, min, max } = this.options; const { year, month, min, max } = this.options;
let Y = year; let Y = year;
const M = month, De = getDate(), day = De.getDay(); const M = month,
De = getDate(),
day = De.getDay();
Y = Y | 0; Y = Y | 0;
De.setFullYear(Y, M, 1); De.setFullYear(Y, M, 1);
const newDate = getOffsetDate(De, -1 * (day + 1)); const newDate = getOffsetDate(De, -1 * (day + 1));
@ -171,7 +214,9 @@ export class Calendar extends Widget {
isFinalDate() { isFinalDate() {
const { year, month, min, max } = this.options; const { year, month, min, max } = this.options;
let Y = year; let Y = year;
const M = month, De = getDate(), day = De.getDay(); const M = month,
De = getDate(),
day = De.getDay();
Y = Y | 0; Y = Y | 0;
De.setFullYear(Y, M, 1); De.setFullYear(Y, M, 1);
const newDate = getOffsetDate(De, 42 - day); const newDate = getOffsetDate(De, 42 - day);
@ -190,8 +235,9 @@ export class Calendar extends Widget {
items.push(days.slice(28, 35)); items.push(days.slice(28, 35));
items.push(days.slice(35, 42)); items.push(days.slice(35, 42));
return map(items, (i, item) => map(item, (j, td) => { return map(items, (i, item) =>
let month = td.lastMonth ? o.month - 1 : (td.nextMonth ? o.month + 1 : o.month); map(item, (j, td) => {
let month = td.lastMonth ? o.month - 1 : td.nextMonth ? o.month + 1 : o.month;
let year = o.year; let year = o.year;
if (month > 12) { if (month > 12) {
month = 1; month = 1;
@ -202,7 +248,7 @@ export class Calendar extends Widget {
} }
return extend(td, { return extend(td, {
type: "bi.calendar_date_item", type: CalendarDateItem.xtype,
once: false, once: false,
forceSelected: true, forceSelected: true,
value: `${year}-${month}-${td.text}`, value: `${year}-${month}-${td.text}`,
@ -214,7 +260,8 @@ export class Calendar extends Widget {
bgap: 4, bgap: 4,
// selected: td.currentDay // selected: td.currentDay
}); });
})); })
);
} }
_populate() { _populate() {

76
src/case/calendar/calendar.year.js

@ -1,4 +1,23 @@
import { shortcut, Widget, extend, parseDateTime, range, checkDateVoid, print, getDate, each, createWidget, createItems, LogicFactory, Controller, makeArray, map, isNotEmptyString } from "@/core"; import { ButtonGroup, TextItem } from "@/base";
import {
CenterAdaptLayout,
shortcut,
Widget,
extend,
parseDateTime,
range,
checkDateVoid,
print,
getDate,
each,
createWidget,
createItems,
LogicFactory,
Controller,
makeArray,
map,
isNotEmptyString
} from "@/core";
/** /**
* Created by GUY on 2015/8/28. * Created by GUY on 2015/8/28.
@ -14,7 +33,7 @@ export class YearCalendar extends Widget {
static getStartYear(year) { static getStartYear(year) {
const cur = getDate().getFullYear(); const cur = getDate().getFullYear();
return year - ((year - cur + 3) % YearCalendar.INTERVAL + 12) % YearCalendar.INTERVAL; return year - ((((year - cur + 3) % YearCalendar.INTERVAL) + 12) % YearCalendar.INTERVAL);
} }
static getEndYear(year) { static getEndYear(year) {
@ -53,7 +72,15 @@ export class YearCalendar extends Widget {
const endDate = parseDateTime(max, "%Y-%X-%d"); const endDate = parseDateTime(max, "%Y-%X-%d");
each(range(YearCalendar.INTERVAL), i => { each(range(YearCalendar.INTERVAL), i => {
const td = {}; const td = {};
if (checkDateVoid(start + i, 1, 1, print(getDate(startDate.getFullYear(), 0, 1), "%Y-%X-%d"), print(getDate(endDate.getFullYear(), 0, 1), "%Y-%X-%d"))[0]) { if (
checkDateVoid(
start + i,
1,
1,
print(getDate(startDate.getFullYear(), 0, 1), "%Y-%X-%d"),
print(getDate(endDate.getFullYear(), 0, 1), "%Y-%X-%d")
)[0]
) {
td.disabled = true; td.disabled = true;
} }
td.text = start + i; td.text = start + i;
@ -68,30 +95,44 @@ export class YearCalendar extends Widget {
this.currentYear = getDate().getFullYear(); this.currentYear = getDate().getFullYear();
this.years = createWidget({ this.years = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
behaviors, behaviors,
items: createItems(this._getItems(), {}), items: createItems(this._getItems(), {}),
layouts: [LogicFactory.createLogic("table", extend({}, logic, { layouts: [
LogicFactory.createLogic(
"table",
extend({}, logic, {
columns: 2, columns: 2,
rows: 6, rows: 6,
columnSize: [1 / 2, 1 / 2], columnSize: [1 / 2, 1 / 2],
rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, rowSize: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
})), { })
type: "bi.center_adapt", ),
{
type: CenterAdaptLayout.xtype,
vgap: 2, vgap: 2,
}], }
],
}); });
this.years.on(Controller.EVENT_CHANGE, (...args) => { this.years.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
createWidget(extend({ createWidget(
extend(
{
element: this, element: this,
}, LogicFactory.createLogic("vertical", extend({}, logic, { },
LogicFactory.createLogic(
"vertical",
extend({}, logic, {
scrolly: true, scrolly: true,
vgap: 5, vgap: 5,
hgap: 6, hgap: 6,
items: LogicFactory.createLogicItemsByDirection("top", this.years), items: LogicFactory.createLogicItemsByDirection("top", this.years),
})))); })
)
)
);
} }
isFrontYear() { isFrontYear() {
@ -115,7 +156,8 @@ export class YearCalendar extends Widget {
const years = this._yearCreator(year || this.currentYear); const years = this._yearCreator(year || this.currentYear);
// 纵向排列年 // 纵向排列年
const len = years.length, tyears = makeArray(len, ""); const len = years.length,
tyears = makeArray(len, "");
const mapArr = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; const mapArr = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
each(years, (i, y) => { each(years, (i, y) => {
tyears[i] = years[mapArr[i]]; tyears[i] = years[mapArr[i]];
@ -129,8 +171,10 @@ export class YearCalendar extends Widget {
items.push(tyears.slice(8, 10)); items.push(tyears.slice(8, 10));
items.push(tyears.slice(10, 12)); items.push(tyears.slice(10, 12));
return map(items, (i, item) => map(item, (j, td) => extend(td, { return map(items, (i, item) =>
type: "bi.text_item", map(item, (j, td) =>
extend(td, {
type: TextItem.xtype,
cls: "bi-list-item-select bi-border-radius", cls: "bi-list-item-select bi-border-radius",
textAlign: "center", textAlign: "center",
whiteSpace: "normal", whiteSpace: "normal",
@ -140,7 +184,9 @@ export class YearCalendar extends Widget {
width: 45, width: 45,
value: td.text, value: td.text,
disabled: td.disabled, disabled: td.disabled,
}))); })
)
);
} }
_populate() { _populate() {

5
src/case/checkbox/check.arrownode.js

@ -1,9 +1,10 @@
import { shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* Created by roy on 15/10/16. * Created by roy on 15/10/16.
* 右与下箭头切换的树节点 * 右与下箭头切换的树节点
*/ */
import { shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class ArrowTreeGroupNodeCheckbox extends IconButton { export class ArrowTreeGroupNodeCheckbox extends IconButton {

5
src/case/checkbox/check.checkingmarknode.js

@ -1,10 +1,11 @@
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* 十字型的树节点 * 十字型的树节点
* @class BI.CheckingMarkNode * @class BI.CheckingMarkNode
* @extends BI.IconButton * @extends BI.IconButton
*/ */
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class CheckingMarkNode extends IconButton { export class CheckingMarkNode extends IconButton {

10
src/case/checkbox/check.first.treenode.js

@ -1,10 +1,11 @@
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* 十字型的树节点 * 十字型的树节点
* @class BI.FirstTreeNodeCheckbox * @class BI.FirstTreeNodeCheckbox
* @extends BI.IconButton * @extends BI.IconButton
*/ */
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class FirstTreeNodeCheckbox extends IconButton { export class FirstTreeNodeCheckbox extends IconButton {
@ -12,7 +13,10 @@ export class FirstTreeNodeCheckbox extends IconButton {
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type2" : "tree-collapse-icon-type2", extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type2"
: "tree-collapse-icon-type2",
iconWidth: 24, iconWidth: 24,
iconHeight: 24, iconHeight: 24,
}); });

10
src/case/checkbox/check.last.treenode.js

@ -1,10 +1,11 @@
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* 十字型的树节点 * 十字型的树节点
* @class BI.LastTreeNodeCheckbox * @class BI.LastTreeNodeCheckbox
* @extends BI.IconButton * @extends BI.IconButton
*/ */
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class LastTreeNodeCheckbox extends IconButton { export class LastTreeNodeCheckbox extends IconButton {
@ -12,7 +13,10 @@ export class LastTreeNodeCheckbox extends IconButton {
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type4" : "tree-collapse-icon-type4", extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type4"
: "tree-collapse-icon-type4",
iconWidth: 24, iconWidth: 24,
iconHeight: 24, iconHeight: 24,
}); });

10
src/case/checkbox/check.mid.treenode.js

@ -1,10 +1,11 @@
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* 十字型的树节点 * 十字型的树节点
* @class BI.MidTreeNodeCheckbox * @class BI.MidTreeNodeCheckbox
* @extends BI.IconButton * @extends BI.IconButton
*/ */
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class MidTreeNodeCheckbox extends IconButton { export class MidTreeNodeCheckbox extends IconButton {
@ -12,7 +13,10 @@ export class MidTreeNodeCheckbox extends IconButton {
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type3" : "tree-collapse-icon-type3", extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type3"
: "tree-collapse-icon-type3",
iconWidth: 24, iconWidth: 24,
iconHeight: 24, iconHeight: 24,
}); });

10
src/case/checkbox/check.treenode.js

@ -1,10 +1,11 @@
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
/** /**
* 十字型的树节点 * 十字型的树节点
* @class BI.TreeNodeCheckbox * @class BI.TreeNodeCheckbox
* @extends BI.IconButton * @extends BI.IconButton
*/ */
import { extend, shortcut } from "@/core";
import { IconButton } from "@/base";
@shortcut() @shortcut()
export class TreeNodeCheckbox extends IconButton { export class TreeNodeCheckbox extends IconButton {
@ -12,7 +13,10 @@ export class TreeNodeCheckbox extends IconButton {
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type1" : "tree-collapse-icon-type1", extraCls:
BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid"
? "tree-solid-collapse-icon-type1"
: "tree-collapse-icon-type1",
iconWidth: 24, iconWidth: 24,
iconHeight: 24, iconHeight: 24,
}); });

37
src/case/colorchooser/colorchooser.custom.js

@ -1,6 +1,7 @@
import { shortcut, Widget, extend, createWidget } from "@/core"; import { SimpleHexColorPickerEditor, ColorPickerEditor } from "./colorpicker";
import { ColorPickerEditor } from "./colorpicker";
import { Farbtastic } from "./farbtastic/farbtastic"; import { Farbtastic } from "./farbtastic/farbtastic";
import { VTapeLayout, AbsoluteLayout, shortcut, Widget, extend, createWidget } from "@/core";
/** /**
* 自定义选色 * 自定义选色
@ -27,14 +28,14 @@ export class CustomColorChooser extends Widget {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.editor = createWidget(o.editor, { this.editor = createWidget(o.editor, {
type: "bi.simple_hex_color_picker_editor", type: SimpleHexColorPickerEditor.xtype,
value: o.value, value: o.value,
}); });
this.editor.on(ColorPickerEditor.EVENT_CHANGE, () => { this.editor.on(ColorPickerEditor.EVENT_CHANGE, () => {
this.setValue(this.editor.getValue()); this.setValue(this.editor.getValue());
}); });
this.farbtastic = createWidget({ this.farbtastic = createWidget({
type: "bi.farbtastic", type: Farbtastic.xtype,
value: o.value, value: o.value,
}); });
this.farbtastic.on(Farbtastic.EVENT_CHANGE, () => { this.farbtastic.on(Farbtastic.EVENT_CHANGE, () => {
@ -42,27 +43,34 @@ export class CustomColorChooser extends Widget {
}); });
createWidget({ createWidget({
type: "bi.vtape", type: VTapeLayout.xtype,
element: this, element: this,
items: [{ items: [
type: "bi.absolute", {
items: [{ type: AbsoluteLayout.xtype,
items: [
{
el: this.editor, el: this.editor,
left: 10, left: 10,
top: 0, top: 0,
right: 10, right: 10,
}], },
],
height: 50, height: 50,
}, { },
type: "bi.absolute", {
items: [{ type: AbsoluteLayout.xtype,
items: [
{
el: this.farbtastic, el: this.farbtastic,
left: 46, left: 46,
right: 46, right: 46,
top: 7, top: 7,
}], },
],
height: 215, height: 215,
}], },
],
}); });
} }
@ -75,4 +83,3 @@ export class CustomColorChooser extends Widget {
return this.editor.getValue(); return this.editor.getValue();
} }
} }

30
src/case/colorchooser/colorchooser.js

@ -1,5 +1,6 @@
import { shortcut, Widget, extend, createWidget, toPix, isNotEmptyString } from "@/core";
import { Combo } from "@/base"; import { Combo } from "@/base";
import { HexColorChooserPopup } from "./colorchooser.popup.hex";
import { shortcut, Widget, extend, createWidget, toPix, isNotEmptyString } from "@/core";
import { ColorChooserPopup } from "./colorchooser.popup"; import { ColorChooserPopup } from "./colorchooser.popup";
/** /**
@ -36,14 +37,15 @@ export class ColorChooser extends Widget {
super._init(...arguments); super._init(...arguments);
o.value = (o.value || "").toLowerCase(); o.value = (o.value || "").toLowerCase();
this.combo = createWidget({ this.combo = createWidget({
type: "bi.combo", type: Combo.xtype,
element: this, element: this,
container: o.container, container: o.container,
adjustLength: 1, adjustLength: 1,
destroyWhenHide: o.destroyWhenHide, destroyWhenHide: o.destroyWhenHide,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
el: extend({ el: extend(
{
type: o.width <= 24 ? "bi.color_chooser_trigger" : "bi.long_color_chooser_trigger", type: o.width <= 24 ? "bi.color_chooser_trigger" : "bi.long_color_chooser_trigger",
simple: o.simple, simple: o.simple,
ref: _ref => { ref: _ref => {
@ -52,16 +54,20 @@ export class ColorChooser extends Widget {
value: o.value, value: o.value,
width: o.el.type ? o.width : toPix(o.width, 2), width: o.el.type ? o.width : toPix(o.width, 2),
height: o.el.type ? o.height : toPix(o.height, 2), height: o.el.type ? o.height : toPix(o.height, 2),
}, o.el), },
o.el
),
popup: () => { popup: () => {
return { return {
el: extend({ el: extend(
type: "bi.hex_color_chooser_popup", {
type: HexColorChooserPopup.xtype,
recommendColorsGetter: o.recommendColorsGetter, recommendColorsGetter: o.recommendColorsGetter,
ref: _ref => { ref: _ref => {
this.colorPicker = _ref; this.colorPicker = _ref;
}, },
listeners: [{ listeners: [
{
eventName: ColorChooserPopup.EVENT_VALUE_CHANGE, eventName: ColorChooserPopup.EVENT_VALUE_CHANGE,
action: () => { action: () => {
fn(); fn();
@ -69,14 +75,18 @@ export class ColorChooser extends Widget {
this.combo.hideView(); this.combo.hideView();
} }
}, },
}, { },
{
eventName: ColorChooserPopup.EVENT_CHANGE, eventName: ColorChooserPopup.EVENT_CHANGE,
action: () => { action: () => {
fn(); fn();
this.combo.hideView(); this.combo.hideView();
}, },
}], }
}, o.popup), ],
},
o.popup
),
value: o.value, value: o.value,
width: 300, width: 300,
}; };

170
src/case/colorchooser/colorchooser.popup.hex.js

@ -1,7 +1,26 @@
import { shortcut, Widget, isNotNull, extend, isNotEmptyString, array2String, map, count, string2Array, filter, isArray, Cache, Queue } from "@/core"; import {
import { Combo } from "@/base"; VerticalLayout,
Layout,
AbsoluteLayout,
shortcut,
Widget,
isNotNull,
extend,
isNotEmptyString,
array2String,
map,
count,
string2Array,
filter,
isArray,
Cache,
Queue
} from "@/core";
import { Label, Combo, TextItem } from "@/base";
import { PopupPanel } from "../layer";
import { CustomColorChooser } from "./colorchooser.custom";
import { ColorChooserPopup } from "./colorchooser.popup"; import { ColorChooserPopup } from "./colorchooser.popup";
import { ColorPickerEditor, ColorPicker } from "./colorpicker"; import { ColorPickerEditor, ColorPicker, HexColorPicker } from "./colorpicker";
/** /**
* @author windy * @author windy
@ -20,105 +39,134 @@ export class HexColorChooserPopup extends Widget {
width: 300, width: 300,
recommendColorsGetter: BI.emptyFn, // 推荐色获取接口 recommendColorsGetter: BI.emptyFn, // 推荐色获取接口
simple: false, // 简单模式, popup中没有自动和透明 simple: false, // 简单模式, popup中没有自动和透明
} };
render() { render() {
const o = this.options; const o = this.options;
const hasRecommendColors = isNotNull(o.recommendColorsGetter()); const hasRecommendColors = isNotNull(o.recommendColorsGetter());
return [{ return [
type: "bi.vertical", {
items: [{ type: VerticalLayout.xtype,
items: [
{
el: { el: {
type: "bi.vertical", type: VerticalLayout.xtype,
hgap: 15, hgap: 15,
items: [extend({ items: [
type: o.simple ? "bi.simple_hex_color_picker_editor" : "bi.hex_color_picker_editor", extend(
{
type: o.simple
? "bi.simple_hex_color_picker_editor"
: "bi.hex_color_picker_editor",
value: o.value, value: o.value,
height: o.simple ? 36 : 70, height: o.simple ? 36 : 70,
listeners: [{ listeners: [
{
eventName: ColorPickerEditor.EVENT_CHANGE, eventName: ColorPickerEditor.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.setValue(this.colorEditor.getValue()); this.setValue(this.colorEditor.getValue());
this._dealStoreColors(); this._dealStoreColors();
this.fireEvent(ColorChooserPopup.EVENT_VALUE_CHANGE, ...args); this.fireEvent(ColorChooserPopup.EVENT_VALUE_CHANGE, ...args);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.colorEditor = _ref; this.colorEditor = _ref;
}, },
}, o.editor), { },
o.editor
),
{
el: { el: {
type: "bi.hex_color_picker", type: HexColorPicker.xtype,
cls: "bi-border-bottom bi-border-right", cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(this._getStoreColors())], items: [this._digestStoreColors(this._getStoreColors())],
height: 22, height: 22,
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: ColorPicker.EVENT_CHANGE, eventName: ColorPicker.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.setValue(this.storeColors.getValue()[0]); this.setValue(this.storeColors.getValue()[0]);
this._dealStoreColors(); this._dealStoreColors();
this.fireEvent(ColorChooserPopup.EVENT_CHANGE, ...args); this.fireEvent(ColorChooserPopup.EVENT_CHANGE, ...args);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.storeColors = _ref; this.storeColors = _ref;
}, },
}, },
tgap: 10, tgap: 10,
height: 22, height: 22,
}, { },
el: hasRecommendColors ? { {
type: "bi.vertical", el: hasRecommendColors
items: [{ ? {
type: "bi.label", type: VerticalLayout.xtype,
items: [
{
type: Label.xtype,
text: BI.i18nText("BI-Basic_Recommend_Color"), text: BI.i18nText("BI-Basic_Recommend_Color"),
textAlign: "left", textAlign: "left",
height: 24, height: 24,
}, { },
type: "bi.hex_color_picker", {
type: HexColorPicker.xtype,
cls: "bi-border-bottom bi-border-right", cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(o.recommendColorsGetter())], items: [this._digestStoreColors(o.recommendColorsGetter())],
height: 22, height: 22,
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: ColorPicker.EVENT_CHANGE, eventName: ColorPicker.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.setValue(this.recommendColors.getValue()[0]); this.setValue(this.recommendColors.getValue()[0]);
this._dealStoreColors(); this._dealStoreColors();
this.fireEvent(ColorChooserPopup.EVENT_CHANGE, ...args); this.fireEvent(
ColorChooserPopup.EVENT_CHANGE,
...args
);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.recommendColors = _ref; this.recommendColors = _ref;
}, },
}], }
} : { type: "bi.layout" }, ],
}
: { type: Layout.xtype },
tgap: hasRecommendColors ? 10 : 0, tgap: hasRecommendColors ? 10 : 0,
height: hasRecommendColors ? 47 : 0, height: hasRecommendColors ? 47 : 0,
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "bi-border-top", cls: "bi-border-top",
}, },
vgap: 10, vgap: 10,
height: 1, height: 1,
}, { },
type: "bi.absolute", {
items: [{ type: AbsoluteLayout.xtype,
items: [
{
el: { el: {
type: "bi.hex_color_picker", type: HexColorPicker.xtype,
space: true, space: true,
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: ColorPicker.EVENT_CHANGE, eventName: ColorPicker.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.setValue(this.colorPicker.getValue()[0]); this.setValue(this.colorPicker.getValue()[0]);
this._dealStoreColors(); this._dealStoreColors();
this.fireEvent(ColorChooserPopup.EVENT_CHANGE, ...args); this.fireEvent(ColorChooserPopup.EVENT_CHANGE, ...args);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.colorPicker = _ref; this.colorPicker = _ref;
}, },
@ -127,19 +175,22 @@ export class HexColorChooserPopup extends Widget {
left: 0, left: 0,
right: 0, right: 0,
bottom: 1, bottom: 1,
}], }
],
height: 80, height: 80,
}], }
],
},
}, },
}, { {
el: { el: {
type: "bi.combo", type: Combo.xtype,
cls: "bi-border-top", cls: "bi-border-top",
container: null, container: null,
direction: "right,top", direction: "right,top",
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
el: { el: {
type: "bi.text_item", type: TextItem.xtype,
cls: "color-chooser-popup-more bi-list-item", cls: "color-chooser-popup-more bi-list-item",
textAlign: "center", textAlign: "center",
height: 24, height: 24,
@ -147,11 +198,11 @@ export class HexColorChooserPopup extends Widget {
text: `${BI.i18nText("BI-Basic_More")}...`, text: `${BI.i18nText("BI-Basic_More")}...`,
}, },
popup: { popup: {
type: "bi.popup_panel", type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"), title: BI.i18nText("BI-Custom_Color"),
el: { el: {
type: "bi.custom_color_chooser", type: CustomColorChooser.xtype,
value: o.value, value: o.value,
editor: o.editor, editor: o.editor,
ref: _ref => { ref: _ref => {
@ -163,7 +214,8 @@ export class HexColorChooserPopup extends Widget {
rgap: 1, rgap: 1,
lgap: 1, lgap: 1,
minWidth: 227, minWidth: 227,
listeners: [{ listeners: [
{
eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, eventName: BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON,
action: (index, ...args) => { action: (index, ...args) => {
switch (index) { switch (index) {
@ -185,26 +237,32 @@ export class HexColorChooserPopup extends Widget {
break; break;
} }
}, },
}], }
],
}, },
listeners: [{ listeners: [
{
eventName: Combo.EVENT_AFTER_POPUPVIEW, eventName: Combo.EVENT_AFTER_POPUPVIEW,
action: () => { action: () => {
this.customColorChooser.setValue(this.getValue()); this.customColorChooser.setValue(this.getValue());
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.more = _ref; this.more = _ref;
}, },
}, },
tgap: 10, tgap: 10,
height: 24, height: 24,
}], }
}, { ],
type: "bi.absolute", },
items: [{ {
type: AbsoluteLayout.xtype,
items: [
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "disable-mask", cls: "disable-mask",
invisible: !o.disabled, invisible: !o.disabled,
ref: () => { ref: () => {
@ -215,8 +273,10 @@ export class HexColorChooserPopup extends Widget {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
}]; ],
}
];
} }
// 这里就实现的不好了,setValue里面有个editor,editor的setValue会检测错误然后出bubble提示 // 这里就实现的不好了,setValue里面有个editor,editor的setValue会检测错误然后出bubble提示
@ -264,7 +324,7 @@ export class HexColorChooserPopup extends Widget {
const o = this.options; const o = this.options;
const colorsArray = string2Array(Cache.getItem("colors") || ""); const colorsArray = string2Array(Cache.getItem("colors") || "");
return filter(colorsArray, (idx, color) => o.simple ? this._isRGBColor(color) : true); return filter(colorsArray, (idx, color) => (o.simple ? this._isRGBColor(color) : true));
} }
_isRGBColor(color) { _isRGBColor(color) {

14
src/case/colorchooser/colorchooser.popup.hex.simple.js

@ -1,3 +1,4 @@
import { HexColorChooserPopup } from "./colorchooser.popup.hex";
import { shortcut, Widget } from "@/core"; import { shortcut, Widget } from "@/core";
import { ColorChooserPopup } from "./colorchooser.popup"; import { ColorChooserPopup } from "./colorchooser.popup";
import { SimpleColorChooserPopup } from "./colorchooser.popup.simple"; import { SimpleColorChooserPopup } from "./colorchooser.popup.simple";
@ -16,27 +17,30 @@ export class SimpleHexColorChooserPopup extends Widget {
props = { props = {
baseCls: "bi-color-chooser-popup", baseCls: "bi-color-chooser-popup",
} };
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.hex_color_chooser_popup", type: HexColorChooserPopup.xtype,
recommendColorsGetter: o.recommendColorsGetter, recommendColorsGetter: o.recommendColorsGetter,
value: o.value, value: o.value,
simple: true, // 是否有自动 simple: true, // 是否有自动
listeners: [{ listeners: [
{
eventName: ColorChooserPopup.EVENT_CHANGE, eventName: ColorChooserPopup.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.fireEvent(SimpleColorChooserPopup.EVENT_CHANGE, ...args); this.fireEvent(SimpleColorChooserPopup.EVENT_CHANGE, ...args);
}, },
}, { },
{
eventName: ColorChooserPopup.EVENT_VALUE_CHANGE, eventName: ColorChooserPopup.EVENT_VALUE_CHANGE,
action: (...args) => { action: (...args) => {
this.fireEvent(SimpleColorChooserPopup.EVENT_VALUE_CHANGE, ...args); this.fireEvent(SimpleColorChooserPopup.EVENT_VALUE_CHANGE, ...args);
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.popup = _ref; this.popup = _ref;
}, },

85
src/case/colorchooser/colorchooser.popup.js

@ -1,5 +1,24 @@
import { shortcut, Widget, createWidget, Cache, string2Array, isNotNull, Queue, array2String, map, count, filter, isNotEmptyString, isArray } from "@/core"; import { CustomColorChooser } from "./colorchooser.custom";
import { Combo } from "@/base"; import { PopupPanel } from "../layer";
import { Combo, TextItem } from "@/base";
import {
AbsoluteLayout,
VTapeLayout,
Layout,
shortcut,
Widget,
createWidget,
Cache,
string2Array,
isNotNull,
Queue,
array2String,
map,
count,
filter,
isNotEmptyString,
isArray
} from "@/core";
import { ColorPickerEditor, ColorPicker } from "./colorpicker"; import { ColorPickerEditor, ColorPicker } from "./colorpicker";
/** /**
@ -21,7 +40,7 @@ export class ColorChooserPopup extends Widget {
width: 230, width: 230,
height: 145, height: 145,
simple: false, // 简单模式, popup中没有自动和透明 simple: false, // 简单模式, popup中没有自动和透明
} };
render() { render() {
const o = this.options; const o = this.options;
@ -39,7 +58,7 @@ export class ColorChooserPopup extends Widget {
}); });
this.storeColors = createWidget({ this.storeColors = createWidget({
type: "bi.color_picker", type: ColorPicker.xtype,
cls: "bi-border-bottom bi-border-right", cls: "bi-border-bottom bi-border-right",
items: [this._digestStoreColors(this._getStoreColors())], items: [this._digestStoreColors(this._getStoreColors())],
width: 210, width: 210,
@ -53,7 +72,7 @@ export class ColorChooserPopup extends Widget {
}); });
this.colorPicker = createWidget({ this.colorPicker = createWidget({
type: "bi.color_picker", type: ColorPicker.xtype,
width: 210, width: 210,
height: 50, height: 50,
value: o.value, value: o.value,
@ -66,12 +85,12 @@ export class ColorChooserPopup extends Widget {
}); });
this.customColorChooser = createWidget({ this.customColorChooser = createWidget({
type: "bi.custom_color_chooser", type: CustomColorChooser.xtype,
editor: o.editor, editor: o.editor,
}); });
const panel = createWidget({ const panel = createWidget({
type: "bi.popup_panel", type: PopupPanel.xtype,
buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
title: BI.i18nText("BI-Custom_Color"), title: BI.i18nText("BI-Custom_Color"),
el: this.customColorChooser, el: this.customColorChooser,
@ -83,13 +102,13 @@ export class ColorChooserPopup extends Widget {
}); });
this.more = createWidget({ this.more = createWidget({
type: "bi.combo", type: Combo.xtype,
cls: "bi-border-top", cls: "bi-border-top",
container: null, container: null,
direction: "right,top", direction: "right,top",
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
el: { el: {
type: "bi.text_item", type: TextItem.xtype,
cls: "color-chooser-popup-more bi-list-item", cls: "color-chooser-popup-more bi-list-item",
textAlign: "center", textAlign: "center",
height: 24, height: 24,
@ -119,45 +138,56 @@ export class ColorChooserPopup extends Widget {
}); });
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: { el: {
type: "bi.vtape", type: VTapeLayout.xtype,
items: [this.colorEditor, { items: [
this.colorEditor,
{
el: { el: {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: this.storeColors, el: this.storeColors,
left: 10, left: 10,
right: 10, right: 10,
top: 5, top: 5,
}], },
],
}, },
height: 29, height: 29,
}, { },
{
el: { el: {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: this.colorPicker, el: this.colorPicker,
left: 10, left: 10,
right: 10, right: 10,
top: 5, top: 5,
bottom: 5, bottom: 5,
}], },
],
}, },
height: 60, height: 60,
}, { },
{
el: this.more, el: this.more,
height: 24, height: 24,
}], },
],
}, },
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "disable-mask", cls: "disable-mask",
invisible: !o.disabled, invisible: !o.disabled,
ref: () => { ref: () => {
@ -168,7 +198,8 @@ export class ColorChooserPopup extends Widget {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], },
],
}; };
} }
@ -203,7 +234,7 @@ export class ColorChooserPopup extends Widget {
value: color, value: color,
}; };
}); });
count(colors.length, 8, i => { count(colors.length, 8, (i) => {
items.push({ items.push({
value: "", value: "",
disabled: true, disabled: true,
@ -217,7 +248,7 @@ export class ColorChooserPopup extends Widget {
const o = this.options; const o = this.options;
const colorsArray = string2Array(Cache.getItem("colors") || ""); const colorsArray = string2Array(Cache.getItem("colors") || "");
return filter(colorsArray, (idx, color) => o.simple ? this._isRGBColor(color) : true); return filter(colorsArray, (idx, color) => (o.simple ? this._isRGBColor(color) : true));
} }
_isRGBColor(color) { _isRGBColor(color) {

5
src/case/colorchooser/colorchooser.simple.js

@ -1,3 +1,4 @@
import { SimpleHexColorChooserPopup } from "./colorchooser.popup.hex.simple";
import { shortcut, Widget, extend, createWidget } from "@/core"; import { shortcut, Widget, extend, createWidget } from "@/core";
import { ColorChooser } from "./colorchooser"; import { ColorChooser } from "./colorchooser";
@ -27,7 +28,7 @@ export class SimpleColorChooser extends Widget {
const o = this.options; const o = this.options;
this.combo = createWidget({ this.combo = createWidget({
type: "bi.color_chooser", type: ColorChooser.xtype,
simple: o.simple, simple: o.simple,
element: this, element: this,
container: o.container, container: o.container,
@ -36,7 +37,7 @@ export class SimpleColorChooser extends Widget {
height: o.height, height: o.height,
destroyWhenHide: o.destroyWhenHide, destroyWhenHide: o.destroyWhenHide,
popup: { popup: {
type: "bi.simple_hex_color_chooser_popup", type: SimpleHexColorChooserPopup.xtype,
recommendColorsGetter: o.recommendColorsGetter, recommendColorsGetter: o.recommendColorsGetter,
}, },
}); });

40
src/case/colorchooser/colorchooser.trigger.js

@ -1,5 +1,5 @@
import { shortcut, extend, createWidget, isNotNull } from "@/core"; import { Layout, AbsoluteLayout, shortcut, extend, createWidget, isNotNull } from "@/core";
import { Trigger } from "@/base"; import { IconButton, Trigger } from "@/base";
/** /**
* 选色控件 * 选色控件
@ -18,7 +18,9 @@ export class ColorChooserTrigger extends Trigger {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-color-chooser-trigger bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`, baseCls: `${conf.baseCls || ""} bi-color-chooser-trigger bi-focus-shadow ${
config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
height: 22, height: 22,
}); });
} }
@ -26,12 +28,12 @@ export class ColorChooserTrigger extends Trigger {
_init() { _init() {
super._init(...arguments); super._init(...arguments);
this.colorContainer = createWidget({ this.colorContainer = createWidget({
type: "bi.layout", type: Layout.xtype,
cls: "color-chooser-trigger-content" + (BI.isIE9Below && BI.isIE9Below() ? " hack" : "") cls: `color-chooser-trigger-content${BI.isIE9Below && BI.isIE9Below() ? " hack" : ""}`,
}); });
const down = createWidget({ const down = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
disableSelected: true, disableSelected: true,
cls: "icon-combo-down-icon trigger-triangle-font icon-size-12", cls: "icon-combo-down-icon trigger-triangle-font icon-size-12",
width: 12, width: 12,
@ -39,19 +41,22 @@ export class ColorChooserTrigger extends Trigger {
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.colorContainer, el: this.colorContainer,
left: 2, left: 2,
right: 2, right: 2,
top: 2, top: 2,
bottom: 2, bottom: 2,
}, { },
{
el: down, el: down,
right: -1, right: -1,
bottom: 1, bottom: 1,
}], }
],
}); });
if (isNotNull(this.options.value)) { if (isNotNull(this.options.value)) {
this.setValue(this.options.value); this.setValue(this.options.value);
@ -61,11 +66,20 @@ export class ColorChooserTrigger extends Trigger {
setValue(color) { setValue(color) {
super.setValue(...arguments); super.setValue(...arguments);
if (color === "") { if (color === "") {
this.colorContainer.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background"); this.colorContainer.element
.css("background-color", "")
.removeClass("trans-color-background")
.addClass("auto-color-background");
} else if (color === "transparent") { } else if (color === "transparent") {
this.colorContainer.element.css("background-color", "").removeClass("auto-color-background").addClass("trans-color-background"); this.colorContainer.element
.css("background-color", "")
.removeClass("auto-color-background")
.addClass("trans-color-background");
} else { } else {
this.colorContainer.element.css({ "background-color": color }).removeClass("auto-color-background").removeClass("trans-color-background"); this.colorContainer.element
.css({ "background-color": color })
.removeClass("auto-color-background")
.removeClass("trans-color-background");
} }
} }
} }

37
src/case/colorchooser/colorchooser.trigger.long.js

@ -1,5 +1,6 @@
import { shortcut, extend, createWidget } from "@/core"; import { HTapeLayout, AbsoluteLayout, shortcut, extend, createWidget } from "@/core";
import { Trigger } from "@/base"; import { IconChangeButton } from "../button";
import { Label, IconButton, Trigger } from "@/base";
/** /**
* 选色控件 * 选色控件
@ -18,7 +19,9 @@ export class LongColorChooserTrigger extends Trigger {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-color-chooser-trigger bi-focus-shadow ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`, baseCls: `${conf.baseCls || ""} bi-color-chooser-trigger bi-focus-shadow ${
config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
}`,
height: 24, height: 24,
}); });
} }
@ -26,10 +29,11 @@ export class LongColorChooserTrigger extends Trigger {
_init() { _init() {
super._init(...arguments); super._init(...arguments);
this.colorContainer = createWidget({ this.colorContainer = createWidget({
type: "bi.htape", type: HTapeLayout.xtype,
cls: "color-chooser-trigger-content", cls: "color-chooser-trigger-content",
items: [{ items: [
type: "bi.icon_change_button", {
type: IconChangeButton.xtype,
ref: _ref => { ref: _ref => {
this.changeIcon = _ref; this.changeIcon = _ref;
}, },
@ -38,9 +42,10 @@ export class LongColorChooserTrigger extends Trigger {
width: 24, width: 24,
iconWidth: 16, iconWidth: 16,
iconHeight: 16, iconHeight: 16,
}, { },
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: _ref => {
this.label = _ref; this.label = _ref;
}, },
@ -49,11 +54,12 @@ export class LongColorChooserTrigger extends Trigger {
height: 18, height: 18,
text: BI.i18nText("BI-Basic_Auto"), text: BI.i18nText("BI-Basic_Auto"),
}, },
}], }
],
}); });
const down = createWidget({ const down = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
disableSelected: true, disableSelected: true,
cls: "icon-combo-down-icon trigger-triangle-font icon-size-12", cls: "icon-combo-down-icon trigger-triangle-font icon-size-12",
width: 12, width: 12,
@ -61,19 +67,22 @@ export class LongColorChooserTrigger extends Trigger {
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.colorContainer, el: this.colorContainer,
left: 2, left: 2,
right: 2, right: 2,
top: 2, top: 2,
bottom: 2, bottom: 2,
}, { },
{
el: down, el: down,
right: 3, right: 3,
bottom: 3, bottom: 3,
}], }
],
}); });
if (this.options.value) { if (this.options.value) {
this.setValue(this.options.value); this.setValue(this.options.value);

12
src/case/colorchooser/colorpicker/button/button.colorpicker.js

@ -34,21 +34,25 @@ export class ColorPickerButton extends BasicButton {
this.element.css("background-color", o.value); this.element.css("background-color", o.value);
} }
const name = this.getName(); const name = this.getName();
this.element.hover(() => { this.element.hover(
() => {
this._createMask(); this._createMask();
if (this.isEnabled()) { if (this.isEnabled()) {
Maskers.show(name); Maskers.show(name);
} }
}, () => { },
() => {
if (!this.isSelected()) { if (!this.isSelected()) {
Maskers.hide(name); Maskers.hide(name);
} }
}); }
);
} }
} }
_createMask() { _createMask() {
const o = this.options, name = this.getName(); const o = this.options,
name = this.getName();
if (this.isEnabled() && !Maskers.has(name)) { if (this.isEnabled() && !Maskers.has(name)) {
const w = Maskers.make(name, this, { const w = Maskers.make(name, this, {
offset: { offset: {

15
src/case/colorchooser/colorpicker/button/button.colorshow.js

@ -1,5 +1,5 @@
import { shortcut } from "@/core"; import { HTapeLayout, shortcut } from "@/core";
import { BasicButton } from "@/base"; import { IconLabel, Label, BasicButton } from "@/base";
/** /**
* @author windy * @author windy
@ -14,17 +14,17 @@ export class ColorChooserShowButton extends BasicButton {
props = { props = {
baseCls: "bi-color-chooser-show-button bi-border bi-list-item-effect bi-border-radius", baseCls: "bi-color-chooser-show-button bi-border bi-list-item-effect bi-border-radius",
} };
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.htape", type: HTapeLayout.xtype,
items: [ items: [
{ {
el: { el: {
type: "bi.icon_label", type: IconLabel.xtype,
ref: _ref => { ref: _ref => {
this.icon = _ref; this.icon = _ref;
}, },
@ -33,8 +33,9 @@ export class ColorChooserShowButton extends BasicButton {
}, },
hgap: 20, hgap: 20,
width: 16, width: 16,
}, { },
type: "bi.label", {
type: Label.xtype,
textAlign: "left", textAlign: "left",
text: o.text, text: o.text,
} }

24
src/case/colorchooser/colorpicker/colorpicker.hex.js

@ -1,5 +1,6 @@
import { shortcut, Widget, extend, each } from "@/core";
import { ButtonGroup } from "@/base"; import { ButtonGroup } from "@/base";
import { GridLayout, Layout, shortcut, Widget, extend, each } from "@/core";
import { ColorPickerButton } from "./button";
/** /**
* @author windy * @author windy
@ -15,7 +16,7 @@ export class HexColorPicker extends Widget {
props = { props = {
baseCls: "bi-hex-color-picker", baseCls: "bi-hex-color-picker",
items: null, items: null,
} };
_items = [ _items = [
[ [
@ -163,17 +164,17 @@ export class HexColorPicker extends Widget {
value: "#B30072", value: "#B30072",
} }
] ]
] ];
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.button_group", type: ButtonGroup.xtype,
items: this._digest(o.items || this._items), items: this._digest(o.items || this._items),
layouts: [ layouts: [
{ {
type: "bi.grid", type: GridLayout.xtype,
} }
], ],
value: o.value, value: o.value,
@ -197,13 +198,18 @@ export class HexColorPicker extends Widget {
each(items, (idx, row) => { each(items, (idx, row) => {
const bRow = []; const bRow = [];
each(row, (idx, item) => { each(row, (idx, item) => {
bRow.push(extend({ bRow.push(
type: "bi.color_picker_button", extend(
{
type: ColorPickerButton.xtype,
once: false, once: false,
cls: o.space ? "bi-border-right" : "", cls: o.space ? "bi-border-right" : "",
}, item)); },
item
)
);
if (o.space && idx < row.length - 1) { if (o.space && idx < row.length - 1) {
bRow.push({ type: "bi.layout" }); bRow.push({ type: Layout.xtype });
} }
}); });
blocks.push(bRow); blocks.push(bRow);

221
src/case/colorchooser/colorpicker/colorpicker.js

@ -1,5 +1,6 @@
import { shortcut, Widget, extend, createItems, createWidget } from "@/core";
import { ButtonGroup } from "@/base"; import { ButtonGroup } from "@/base";
import { ColorPickerButton } from "./button";
import { GridLayout, shortcut, Widget, extend, createItems, createWidget } from "@/core";
/** /**
* 简单选色控件 * 简单选色控件
@ -22,153 +23,223 @@ export class ColorPicker extends Widget {
} }
_items = [ _items = [
[{ [
{
value: "#ffffff", value: "#ffffff",
}, { },
{
value: "#f2f2f2", value: "#f2f2f2",
}, { },
{
value: "#e5e5e5", value: "#e5e5e5",
}, { },
{
value: "#d9d9d9", value: "#d9d9d9",
}, { },
{
value: "#cccccc", value: "#cccccc",
}, { },
{
value: "#bfbfbf", value: "#bfbfbf",
}, { },
{
value: "#b2b2b2", value: "#b2b2b2",
}, { },
{
value: "#a6a6a6", value: "#a6a6a6",
}, { },
{
value: "#999999", value: "#999999",
}, { },
{
value: "#8c8c8c", value: "#8c8c8c",
}, { },
{
value: "#808080", value: "#808080",
}, { },
{
value: "#737373", value: "#737373",
}, { },
{
value: "#666666", value: "#666666",
}, { },
{
value: "#4d4d4d", value: "#4d4d4d",
}, { },
{
value: "#333333", value: "#333333",
}, { },
{
value: "#000000", value: "#000000",
}], }
[{ ],
[
{
value: "#d8b5a6", value: "#d8b5a6",
}, { },
{
value: "#ff9e9a", value: "#ff9e9a",
}, { },
{
value: "#ffc17d", value: "#ffc17d",
}, { },
{
value: "#f5e56b", value: "#f5e56b",
}, { },
{
value: "#d8e698", value: "#d8e698",
}, { },
{
value: "#e0ebaf", value: "#e0ebaf",
}, { },
{
value: "#c3d825", value: "#c3d825",
}, { },
{
value: "#bbe2e7", value: "#bbe2e7",
}, { },
{
value: "#85d3cd", value: "#85d3cd",
}, { },
{
value: "#bde1e6", value: "#bde1e6",
}, { },
{
value: "#a0d8ef", value: "#a0d8ef",
}, { },
{
value: "#89c3eb", value: "#89c3eb",
}, { },
{
value: "#bbc8e6", value: "#bbc8e6",
}, { },
{
value: "#bbbcde", value: "#bbbcde",
}, { },
{
value: "#d6b4cc", value: "#d6b4cc",
}, { },
{
value: "#fbc0d3", value: "#fbc0d3",
}], }
[{ ],
[
{
value: "#bb9581", value: "#bb9581",
}, { },
{
value: "#f37d79", value: "#f37d79",
}, { },
{
value: "#fba74f", value: "#fba74f",
}, { },
{
value: "#ffdb4f", value: "#ffdb4f",
}, { },
{
value: "#c7dc68", value: "#c7dc68",
}, { },
{
value: "#b0ca71", value: "#b0ca71",
}, { },
{
value: "#99ab4e", value: "#99ab4e",
}, { },
{
value: "#84b9cb", value: "#84b9cb",
}, { },
{
value: "#00a3af", value: "#00a3af",
}, { },
{
value: "#2ca9e1", value: "#2ca9e1",
}, { },
{
value: "#0095d9", value: "#0095d9",
}, { },
{
value: "#4c6cb3", value: "#4c6cb3",
}, { },
{
value: "#8491c3", value: "#8491c3",
}, { },
{
value: "#a59aca", value: "#a59aca",
}, { },
{
value: "#cc7eb1", value: "#cc7eb1",
}, { },
{
value: "#e89bb4", value: "#e89bb4",
}], }
[{ ],
[
{
value: "#9d775f", value: "#9d775f",
}, { },
{
value: "#dd4b4b", value: "#dd4b4b",
}, { },
{
value: "#ef8b07", value: "#ef8b07",
}, { },
{
value: "#fcc800", value: "#fcc800",
}, { },
{
value: "#aacf53", value: "#aacf53",
}, { },
{
value: "#82ae46", value: "#82ae46",
}, { },
{
value: "#69821b", value: "#69821b",
}, { },
{
value: "#59b9c6", value: "#59b9c6",
}, { },
{
value: "#2a83a2", value: "#2a83a2",
}, { },
{
value: "#007bbb", value: "#007bbb",
}, { },
{
value: "#19448e", value: "#19448e",
}, { },
{
value: "#274a78", value: "#274a78",
}, { },
{
value: "#4a488e", value: "#4a488e",
}, { },
{
value: "#7058a3", value: "#7058a3",
}, { },
{
value: "#884898", value: "#884898",
}, { },
{
value: "#d47596", value: "#d47596",
}] }
] ]
];
_init() { _init() {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.colors = createWidget({ this.colors = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
element: this, element: this,
items: createItems(o.items || this._items, { items: createItems(o.items || this._items, {
type: "bi.color_picker_button", type: ColorPickerButton.xtype,
once: false, once: false,
}), }),
layouts: [{ layouts: [
type: "bi.grid", {
}], type: GridLayout.xtype,
}
],
value: o.value, value: o.value,
}); });
this.colors.on(ButtonGroup.EVENT_CHANGE, (...args) => { this.colors.on(ButtonGroup.EVENT_CHANGE, (...args) => {
@ -179,7 +250,7 @@ export class ColorPicker extends Widget {
populate(items) { populate(items) {
const args = [].slice.call(arguments); const args = [].slice.call(arguments);
args[0] = createItems(items, { args[0] = createItems(items, {
type: "bi.color_picker_button", type: ColorPickerButton.xtype,
once: false, once: false,
}); });
this.colors.populate.apply(this.colors, args); this.colors.populate.apply(this.colors, args);

111
src/case/colorchooser/colorpicker/editor.colorpicker.hex.js

@ -1,8 +1,27 @@
import { shortcut, Widget, createItems, map, isNumeric, range, extend, isEmptyString, isNull, DOM } from "@/core"; import { Label } from "@/base";
import { ColorPickerEditor } from "./editor.colorpicker"; import {
AbsoluteLayout,
VerticalLayout,
VerticalAdaptLayout,
Layout,
shortcut,
Widget,
createItems,
map,
isNumeric,
range,
extend,
isEmptyString,
isNull,
DOM
} from "@/core";
import { ColorChooserShowButton } from "./button"; import { ColorChooserShowButton } from "./button";
import { ColorPickerEditor } from "./editor.colorpicker";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
const RGB_WIDTH = 32, HEX_WIDTH = 70, HEX_PREFIX_POSITION = 1; const RGB_WIDTH = 32,
HEX_WIDTH = 70,
HEX_PREFIX_POSITION = 1;
/** /**
* 简单选色控件 * 简单选色控件
@ -20,12 +39,12 @@ export class HexColorPickerEditor extends Widget {
props = { props = {
baseCls: "bi-color-picker-editor", baseCls: "bi-color-picker-editor",
height: 30, height: 30,
} };
render() { render() {
this.storeValue = {}; this.storeValue = {};
const RGB = createItems([{ text: "R" }, { text: "G" }, { text: "B" }], { const RGB = createItems([{ text: "R" }, { text: "G" }, { text: "B" }], {
type: "bi.label", type: Label.xtype,
cls: "color-picker-editor-label", cls: "color-picker-editor-label",
height: 20, height: 20,
}); });
@ -33,7 +52,7 @@ export class HexColorPickerEditor extends Widget {
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = map(range(0, 3), () => { const Ws = map(range(0, 3), () => {
return { return {
type: "bi.small_text_editor", type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
@ -46,7 +65,11 @@ export class HexColorPickerEditor extends Widget {
eventName: BI.TextEditor.EVENT_CHANGE, eventName: BI.TextEditor.EVENT_CHANGE,
action: () => { action: () => {
this._checkEditors(); this._checkEditors();
if (checker(this.storeValue.r) && checker(this.storeValue.g) && checker(this.storeValue.b)) { if (
checker(this.storeValue.r) &&
checker(this.storeValue.g) &&
checker(this.storeValue.b)
) {
this.colorShow.element.css("background-color", this.getValue()); this.colorShow.element.css("background-color", this.getValue());
this.fireEvent(ColorPickerEditor.EVENT_CHANGE); this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
} }
@ -57,20 +80,20 @@ export class HexColorPickerEditor extends Widget {
}); });
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [ items: [
{ {
el: { el: {
type: "bi.vertical", type: VerticalLayout.xtype,
tgap: 10, tgap: 10,
items: [ items: [
{ {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: ["fill", "fill"], columnSize: ["fill", "fill"],
height: 24, height: 24,
items: [ items: [
{ {
type: "bi.color_picker_show_button", type: ColorChooserShowButton.xtype,
cls: "trans-color-icon", cls: "trans-color-icon",
height: 22, height: 22,
title: BI.i18nText("BI-Transparent_Color"), title: BI.i18nText("BI-Transparent_Color"),
@ -87,9 +110,10 @@ export class HexColorPickerEditor extends Widget {
ref: _ref => { ref: _ref => {
this.transparent = _ref; this.transparent = _ref;
}, },
}, { },
{
el: { el: {
type: "bi.color_picker_show_button", type: ColorChooserShowButton.xtype,
cls: "auto-color-icon", cls: "auto-color-icon",
height: 22, height: 22,
title: BI.i18nText("BI-Basic_Auto"), title: BI.i18nText("BI-Basic_Auto"),
@ -110,16 +134,17 @@ export class HexColorPickerEditor extends Widget {
lgap: 10, lgap: 10,
} }
], ],
}, { },
{
el: { el: {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
columnSize: [22, 10, "fill", 12, RGB_WIDTH, 12, RGB_WIDTH, 12, RGB_WIDTH], columnSize: [22, 10, "fill", 12, RGB_WIDTH, 12, RGB_WIDTH, 12, RGB_WIDTH],
rgap: 5, rgap: 5,
items: [ items: [
{ {
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
height: 22, height: 22,
width: 22, width: 22,
@ -128,12 +153,14 @@ export class HexColorPickerEditor extends Widget {
}, },
}, },
width: 18, width: 18,
}, { },
type: "bi.label", {
type: Label.xtype,
text: "#", text: "#",
width: 10, width: 10,
}, { },
type: "bi.small_text_editor", {
type: SmallTextEditor.xtype,
ref: _ref => { ref: _ref => {
this.hexEditor = _ref; this.hexEditor = _ref;
}, },
@ -148,28 +175,41 @@ export class HexColorPickerEditor extends Widget {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this._checkHexEditor(); this._checkHexEditor();
if (checker(this.storeValue.r) && checker(this.storeValue.g) && checker(this.storeValue.b)) { if (
this.colorShow.element.css("background-color", this.getValue()); checker(this.storeValue.r) &&
checker(this.storeValue.g) &&
checker(this.storeValue.b)
) {
this.colorShow.element.css(
"background-color",
this.getValue()
);
this.fireEvent(ColorPickerEditor.EVENT_CHANGE); this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
} }
}, },
} }
], ],
}, RGB[0], { },
RGB[0],
{
el: extend(Ws[0], { el: extend(Ws[0], {
ref: _ref => { ref: _ref => {
this.R = _ref; this.R = _ref;
}, },
}), }),
width: RGB_WIDTH, width: RGB_WIDTH,
}, RGB[1], { },
RGB[1],
{
el: extend(Ws[1], { el: extend(Ws[1], {
ref: _ref => { ref: _ref => {
this.G = _ref; this.G = _ref;
}, },
}), }),
width: RGB_WIDTH, width: RGB_WIDTH,
}, RGB[2], { },
RGB[2],
{
el: extend(Ws[2], { el: extend(Ws[2], {
ref: _ref => { ref: _ref => {
this.B = _ref; this.B = _ref;
@ -235,11 +275,20 @@ export class HexColorPickerEditor extends Widget {
_showPreColor(color) { _showPreColor(color) {
if (color === "") { if (color === "") {
this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-square-normal-background"); this.colorShow.element
.css("background-color", "")
.removeClass("trans-color-background")
.addClass("auto-color-square-normal-background");
} else if (color === "transparent") { } else if (color === "transparent") {
this.colorShow.element.css("background-color", "").removeClass("auto-color-square-normal-background").addClass("trans-color-background"); this.colorShow.element
.css("background-color", "")
.removeClass("auto-color-square-normal-background")
.addClass("trans-color-background");
} else { } else {
this.colorShow.element.css({ "background-color": color }).removeClass("auto-color-square-normal-background").removeClass("trans-color-background"); this.colorShow.element
.css({ "background-color": color })
.removeClass("auto-color-square-normal-background")
.removeClass("trans-color-background");
} }
} }
@ -294,10 +343,12 @@ export class HexColorPickerEditor extends Widget {
return "transparent"; return "transparent";
} }
return DOM.rgb2hex(DOM.json2rgb({ return DOM.rgb2hex(
DOM.json2rgb({
r: this.storeValue.r, r: this.storeValue.r,
g: this.storeValue.g, g: this.storeValue.g,
b: this.storeValue.b, b: this.storeValue.b,
})); })
);
} }
} }

90
src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js

@ -1,8 +1,27 @@
import { shortcut, Widget, extend, isEmptyObject, createItems, isNull, isNumeric, map, isEmptyString, range, DOM } from "@/core"; import { Label } from "@/base";
import {
VerticalLayout,
VerticalAdaptLayout,
Layout,
shortcut,
Widget,
extend,
isEmptyObject,
createItems,
isNull,
isNumeric,
map,
isEmptyString,
range,
DOM
} from "@/core";
import { SimpleColorPickerEditor } from "./editor.colorpicker.simple"; import { SimpleColorPickerEditor } from "./editor.colorpicker.simple";
import { ColorPickerEditor } from "./editor.colorpicker"; import { ColorPickerEditor } from "./editor.colorpicker";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
const RGB_WIDTH = 32, HEX_WIDTH = 70, HEX_PREFIX_POSITION = 1; const RGB_WIDTH = 32,
HEX_WIDTH = 70,
HEX_PREFIX_POSITION = 1;
/** /**
* @author windy * @author windy
@ -18,19 +37,19 @@ export class SimpleHexColorPickerEditor extends Widget {
props = { props = {
baseCls: "bi-color-picker-editor", baseCls: "bi-color-picker-editor",
height: 36, height: 36,
} };
render() { render() {
const RGB = createItems([{ text: "R" }, { text: "G" }, { text: "B" }], { const RGB = createItems([{ text: "R" }, { text: "G" }, { text: "B" }], {
type: "bi.label", type: Label.xtype,
cls: "color-picker-editor-label", cls: "color-picker-editor-label",
height: 20, height: 20,
}); });
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = map(range(0, 3), () => { const Ws = map(range(0, 3), () => {
return { return {
type: "bi.small_text_editor", type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
@ -48,39 +67,41 @@ export class SimpleHexColorPickerEditor extends Widget {
this.fireEvent(SimpleColorPickerEditor.EVENT_CHANGE); this.fireEvent(SimpleColorPickerEditor.EVENT_CHANGE);
} }
}, },
} },
], ],
}; };
}); });
return { return {
type: "bi.vertical", type: VerticalLayout.xtype,
tgap: 10, tgap: 10,
items: [ items: [
{ {
el: { el: {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
rgap: 5, rgap: 5,
columnSize: [22, 10, "fill", 12, RGB_WIDTH, 12, RGB_WIDTH, 12, RGB_WIDTH], columnSize: [22, 10, "fill", 12, RGB_WIDTH, 12, RGB_WIDTH, 12, RGB_WIDTH],
items: [ items: [
{ {
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
height: 22, height: 22,
width: 22, width: 22,
ref: _ref => { ref: (_ref) => {
this.colorShow = _ref; this.colorShow = _ref;
}, },
}, },
width: 18, width: 18,
}, { },
type: "bi.label", {
type: Label.xtype,
text: "#", text: "#",
width: 10, width: 10,
}, { },
type: "bi.small_text_editor", {
ref: _ref => { type: SmallTextEditor.xtype,
ref: (_ref) => {
this.hexEditor = _ref; this.hexEditor = _ref;
}, },
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
@ -94,41 +115,50 @@ export class SimpleHexColorPickerEditor extends Widget {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this._checkHexEditor(); this._checkHexEditor();
if (checker(this.storeValue.r) && checker(this.storeValue.g) && checker(this.storeValue.b)) { if (
checker(this.storeValue.r) &&
checker(this.storeValue.g) &&
checker(this.storeValue.b)
) {
this.colorShow.element.css("background-color", this.getValue()); this.colorShow.element.css("background-color", this.getValue());
this.fireEvent(ColorPickerEditor.EVENT_CHANGE); this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
} }
}, },
} },
], ],
}, RGB[0], { },
RGB[0],
{
el: extend(Ws[0], { el: extend(Ws[0], {
ref: _ref => { ref: (_ref) => {
this.R = _ref; this.R = _ref;
}, },
}), }),
width: RGB_WIDTH, width: RGB_WIDTH,
}, RGB[1], { },
RGB[1],
{
el: extend(Ws[1], { el: extend(Ws[1], {
ref: _ref => { ref: (_ref) => {
this.G = _ref; this.G = _ref;
}, },
}), }),
width: RGB_WIDTH, width: RGB_WIDTH,
}, RGB[2], { },
RGB[2],
{
el: extend(Ws[2], { el: extend(Ws[2], {
ref: _ref => { ref: (_ref) => {
this.B = _ref; this.B = _ref;
}, },
}), }),
rgap: -5, rgap: -5,
width: RGB_WIDTH, width: RGB_WIDTH,
} },
], ],
}, },
} },
], ],
}; };
} }
@ -174,10 +204,12 @@ export class SimpleHexColorPickerEditor extends Widget {
} }
getValue() { getValue() {
return DOM.rgb2hex(DOM.json2rgb({ return DOM.rgb2hex(
DOM.json2rgb({
r: this.R.getValue(), r: this.R.getValue(),
g: this.G.getValue(), g: this.G.getValue(),
b: this.B.getValue(), b: this.B.getValue(),
})); })
);
} }
} }

95
src/case/colorchooser/colorpicker/editor.colorpicker.js

@ -1,5 +1,21 @@
import { shortcut, Widget, extend, createWidgets, createItems, createWidget, each, isEmptyString, isNumeric, isNull, DOM } from "@/core"; import {
import { IconButton } from "@/base"; Layout,
AbsoluteLayout,
VerticalAdaptLayout,
shortcut,
Widget,
extend,
createWidgets,
createItems,
createWidget,
each,
isEmptyString,
isNumeric,
isNull,
DOM
} from "@/core";
import { Label, IconButton } from "@/base";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
const RGB_WIDTH = 32; const RGB_WIDTH = 32;
@ -28,21 +44,23 @@ export class ColorPickerEditor extends Widget {
super._init(...arguments); super._init(...arguments);
this.storeValue = {}; this.storeValue = {};
this.colorShow = createWidget({ this.colorShow = createWidget({
type: "bi.layout", type: Layout.xtype,
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
height: 16, height: 16,
width: 16, width: 16,
}); });
const RGB = createWidgets(createItems([{ text: "R" }, { text: "G" }, { text: "B" }], { const RGB = createWidgets(
type: "bi.label", createItems([{ text: "R" }, { text: "G" }, { text: "B" }], {
type: Label.xtype,
cls: "color-picker-editor-label", cls: "color-picker-editor-label",
width: 20, width: 20,
height: 20, height: 20,
})); })
);
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = createWidgets([{}, {}, {}], { const Ws = createWidgets([{}, {}, {}], {
type: "bi.small_text_editor", type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
@ -65,7 +83,7 @@ export class ColorPickerEditor extends Widget {
this.B = Ws[2]; this.B = Ws[2];
this.none = createWidget({ this.none = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
cls: "auto-color-icon", cls: "auto-color-icon",
width: 16, width: 16,
height: 16, height: 16,
@ -76,11 +94,11 @@ export class ColorPickerEditor extends Widget {
this.none.on(IconButton.EVENT_CHANGE, () => { this.none.on(IconButton.EVENT_CHANGE, () => {
const value = this.getValue(); const value = this.getValue();
this.setValue(""); this.setValue("");
(value !== "") && this.fireEvent(ColorPickerEditor.EVENT_CHANGE); value !== "" && this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
}); });
this.transparent = createWidget({ this.transparent = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
cls: "trans-color-icon", cls: "trans-color-icon",
width: 16, width: 16,
height: 16, height: 16,
@ -91,54 +109,62 @@ export class ColorPickerEditor extends Widget {
this.transparent.on(IconButton.EVENT_CHANGE, () => { this.transparent.on(IconButton.EVENT_CHANGE, () => {
const value = this.getValue(); const value = this.getValue();
this.setValue("transparent"); this.setValue("transparent");
(value !== "transparent") && this.fireEvent(ColorPickerEditor.EVENT_CHANGE); value !== "transparent" && this.fireEvent(ColorPickerEditor.EVENT_CHANGE);
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [ items: [
{ {
el: { el: {
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
items: [ items: [
{ {
el: this.colorShow, el: this.colorShow,
width: 16, width: 16,
}, { },
{
el: RGB[0], el: RGB[0],
width: 20, width: 20,
}, { },
{
el: this.R, el: this.R,
width: RGB_WIDTH, width: RGB_WIDTH,
}, { },
{
el: RGB[1], el: RGB[1],
width: 20, width: 20,
}, { },
{
el: this.G, el: this.G,
width: RGB_WIDTH, width: RGB_WIDTH,
}, { },
{
el: RGB[2], el: RGB[2],
width: 20, width: 20,
}, { },
{
el: this.B, el: this.B,
width: RGB_WIDTH, width: RGB_WIDTH,
}, { },
{
el: this.transparent, el: this.transparent,
width: 16, width: 16,
lgap: 5, lgap: 5,
}, { },
{
el: this.none, el: this.none,
width: 16, width: 16,
lgap: 5, lgap: 5,
} },
], ],
}, },
left: 10, left: 10,
right: 10, right: 10,
top: 0, top: 0,
bottom: 0, bottom: 0,
} },
], ],
}); });
} }
@ -166,11 +192,20 @@ export class ColorPickerEditor extends Widget {
_showPreColor(color) { _showPreColor(color) {
if (color === "") { if (color === "") {
this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-normal-background"); this.colorShow.element
.css("background-color", "")
.removeClass("trans-color-background")
.addClass("auto-color-normal-background");
} else if (color === "transparent") { } else if (color === "transparent") {
this.colorShow.element.css("background-color", "").removeClass("auto-color-normal-background").addClass("trans-color-background"); this.colorShow.element
.css("background-color", "")
.removeClass("auto-color-normal-background")
.addClass("trans-color-background");
} else { } else {
this.colorShow.element.css({ "background-color": color }).removeClass("auto-color-normal-background").removeClass("trans-color-background"); this.colorShow.element
.css({ "background-color": color })
.removeClass("auto-color-normal-background")
.removeClass("trans-color-background");
} }
} }
@ -223,10 +258,12 @@ export class ColorPickerEditor extends Widget {
return "transparent"; return "transparent";
} }
return DOM.rgb2hex(DOM.json2rgb({ return DOM.rgb2hex(
DOM.json2rgb({
r: this.storeValue.r, r: this.storeValue.r,
g: this.storeValue.g, g: this.storeValue.g,
b: this.storeValue.b, b: this.storeValue.b,
})); })
);
} }
} }

60
src/case/colorchooser/colorpicker/editor.colorpicker.simple.js

@ -1,4 +1,20 @@
import { shortcut, Widget, extend, isNull, createWidget, isNumeric, createItems, createWidgets, each, isEmptyString, DOM } from "@/core"; import {
Layout,
VerticalAdaptLayout,
shortcut,
Widget,
extend,
isNull,
createWidget,
isNumeric,
createItems,
createWidgets,
each,
isEmptyString,
DOM
} from "@/core";
import { Label } from "@/base";
import { SmallTextEditor } from "@/widget/editor/editor.text.small.js";
const RGB_WIDTH = 32; const RGB_WIDTH = 32;
@ -26,21 +42,23 @@ export class SimpleColorPickerEditor extends Widget {
_init() { _init() {
super._init(...arguments); super._init(...arguments);
this.colorShow = createWidget({ this.colorShow = createWidget({
type: "bi.layout", type: Layout.xtype,
cls: "color-picker-editor-display bi-card bi-border", cls: "color-picker-editor-display bi-card bi-border",
height: 16, height: 16,
width: 16, width: 16,
}); });
const RGB = createWidgets(createItems([{ text: "R" }, { text: "G" }, { text: "B" }], { const RGB = createWidgets(
type: "bi.label", createItems([{ text: "R" }, { text: "G" }, { text: "B" }], {
type: Label.xtype,
cls: "color-picker-editor-label", cls: "color-picker-editor-label",
width: 20, width: 20,
height: 20, height: 20,
})); })
);
const checker = v => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; const checker = (v) => isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
const Ws = createWidgets([{}, {}, {}], { const Ws = createWidgets([{}, {}, {}], {
type: "bi.small_text_editor", type: SmallTextEditor.xtype,
cls: "color-picker-editor-input bi-border-radius", cls: "color-picker-editor-input bi-border-radius",
validationChecker: checker, validationChecker: checker,
errorText: BI.i18nText("BI-Color_Picker_Error_Text"), errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
@ -63,7 +81,7 @@ export class SimpleColorPickerEditor extends Widget {
this.B = Ws[2]; this.B = Ws[2];
createWidget({ createWidget({
type: "bi.vertical_adapt", type: VerticalAdaptLayout.xtype,
element: this, element: this,
items: [ items: [
{ {
@ -71,25 +89,31 @@ export class SimpleColorPickerEditor extends Widget {
width: 16, width: 16,
lgap: 20, lgap: 20,
rgap: 15, rgap: 15,
}, { },
{
el: RGB[0], el: RGB[0],
width: 20, width: 20,
}, { },
{
el: this.R, el: this.R,
width: RGB_WIDTH, width: RGB_WIDTH,
}, { },
{
el: RGB[1], el: RGB[1],
width: 20, width: 20,
}, { },
{
el: this.G, el: this.G,
width: RGB_WIDTH, width: RGB_WIDTH,
}, { },
{
el: RGB[2], el: RGB[2],
width: 20, width: 20,
}, { },
{
el: this.B, el: this.B,
width: RGB_WIDTH, width: RGB_WIDTH,
} },
], ],
}); });
} }
@ -115,10 +139,12 @@ export class SimpleColorPickerEditor extends Widget {
} }
getValue() { getValue() {
return DOM.rgb2hex(DOM.json2rgb({ return DOM.rgb2hex(
DOM.json2rgb({
r: this.R.getValue(), r: this.R.getValue(),
g: this.G.getValue(), g: this.G.getValue(),
b: this.B.getValue(), b: this.B.getValue(),
})); })
);
} }
} }

74
src/case/colorchooser/farbtastic/farbtastic.js

@ -1,7 +1,9 @@
import { shortcut, isKey, DOM } from "@/core"; import { AbsoluteLayout, Layout, shortcut, isKey, DOM } from "@/core";
import { BasicButton } from "@/base"; import { BasicButton } from "@/base";
const RADIUS = 84, SQUARE = 100, WIDTH = 194; const RADIUS = 84,
SQUARE = 100,
WIDTH = 194;
@shortcut() @shortcut()
export class Farbtastic extends BasicButton { export class Farbtastic extends BasicButton {
@ -15,16 +17,17 @@ export class Farbtastic extends BasicButton {
height: 195, height: 195,
stopPropagation: true, stopPropagation: true,
value: "#000000", value: "#000000",
} };
render() { render() {
this._defaultState(); this._defaultState();
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "", cls: "",
ref: _ref => { ref: _ref => {
this.colorWrapper = _ref; this.colorWrapper = _ref;
@ -34,9 +37,10 @@ export class Farbtastic extends BasicButton {
left: 47, left: 47,
width: 101, width: 101,
height: 101, height: 101,
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "wheel", cls: "wheel",
ref: _ref => { ref: _ref => {
this.wheel = _ref; this.wheel = _ref;
@ -46,9 +50,10 @@ export class Farbtastic extends BasicButton {
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "overlay", cls: "overlay",
ref: _ref => { ref: _ref => {
this.overlay = _ref; this.overlay = _ref;
@ -58,9 +63,10 @@ export class Farbtastic extends BasicButton {
left: 47, left: 47,
width: 101, width: 101,
height: 101, height: 101,
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "marker", cls: "marker",
ref: _ref => { ref: _ref => {
this.hMarker = _ref; this.hMarker = _ref;
@ -69,9 +75,10 @@ export class Farbtastic extends BasicButton {
width: 17, width: 17,
height: 17, height: 17,
}, },
}, { },
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "marker", cls: "marker",
ref: _ref => { ref: _ref => {
this.slMarker = _ref; this.slMarker = _ref;
@ -80,7 +87,8 @@ export class Farbtastic extends BasicButton {
width: 17, width: 17,
height: 17, height: 17,
}, },
}], }
],
}; };
} }
@ -97,13 +105,17 @@ export class Farbtastic extends BasicButton {
_unpack(color) { _unpack(color) {
if (color.length === 7) { if (color.length === 7) {
return [parseInt("0x" + color.substring(1, 3)) / 255, return [
parseInt("0x" + color.substring(3, 5)) / 255, parseInt(`0x${color.substring(1, 3)}`) / 255,
parseInt("0x" + color.substring(5, 7)) / 255]; parseInt(`0x${color.substring(3, 5)}`) / 255,
parseInt(`0x${color.substring(5, 7)}`) / 255
];
} else if (color.length === 4) { } else if (color.length === 4) {
return [parseInt("0x" + color.substring(1, 2)) / 15, return [
parseInt("0x" + color.substring(2, 3)) / 15, parseInt(`0x${color.substring(1, 2)}`) / 15,
parseInt("0x" + color.substring(3, 4)) / 15]; parseInt(`0x${color.substring(2, 3)}`) / 15,
parseInt(`0x${color.substring(3, 4)}`) / 15
];
} }
} }
@ -112,9 +124,15 @@ export class Farbtastic extends BasicButton {
const g = Math.round(rgb[1] * 255); const g = Math.round(rgb[1] * 255);
const b = Math.round(rgb[2] * 255); const b = Math.round(rgb[2] * 255);
return "#" + (r < 16 ? "0" : "") + r.toString(16) + return (
(g < 16 ? "0" : "") + g.toString(16) + `#${
(b < 16 ? "0" : "") + b.toString(16); r < 16 ? "0" : ""
}${r.toString(16)
}${g < 16 ? "0" : ""
}${g.toString(16)
}${b < 16 ? "0" : ""
}${b.toString(16)}`
);
} }
_setColor(color) { _setColor(color) {
@ -152,8 +170,8 @@ export class Farbtastic extends BasicButton {
}); });
this.slMarker.element.css({ this.slMarker.element.css({
left: `${Math.round(SQUARE * (.5 - this.hsl[1]) + WIDTH / 2)}px`, left: `${Math.round(SQUARE * (0.5 - this.hsl[1]) + WIDTH / 2)}px`,
top: `${Math.round(SQUARE * (.5 - this.hsl[2]) + WIDTH / 2)}px`, top: `${Math.round(SQUARE * (0.5 - this.hsl[2]) + WIDTH / 2)}px`,
}); });
// Saturation/Luminance gradient // Saturation/Luminance gradient
@ -232,8 +250,8 @@ export class Farbtastic extends BasicButton {
if (hue < 0) hue += 1; if (hue < 0) hue += 1;
this._setHSL([hue, this.hsl[1], this.hsl[2]]); this._setHSL([hue, this.hsl[1], this.hsl[2]]);
} else { } else {
const sat = Math.max(0, Math.min(1, -(pos.x / SQUARE) + .5)); const sat = Math.max(0, Math.min(1, -(pos.x / SQUARE) + 0.5));
const lum = Math.max(0, Math.min(1, -(pos.y / SQUARE) + .5)); const lum = Math.max(0, Math.min(1, -(pos.y / SQUARE) + 0.5));
this._setHSL([this.hsl[0], sat, lum]); this._setHSL([this.hsl[0], sat, lum]);
} }
this.fireEvent(Farbtastic.EVENT_CHANGE, this.getValue(), this); this.fireEvent(Farbtastic.EVENT_CHANGE, this.getValue(), this);

18
src/case/combo/bubblecombo/combo.bubble.js

@ -1,11 +1,5 @@
import { import { BubblePopupView } from "./popup.bubble";
shortcut, import { shortcut, Widget, extend, emptyFn, createWidget, isFunction } from "@/core";
Widget,
extend,
emptyFn,
createWidget,
isFunction
} from "@/core";
import { Combo } from "@/base"; import { Combo } from "@/base";
@shortcut() @shortcut()
@ -76,14 +70,12 @@ export class BubbleCombo extends Widget {
popup: () => popup: () =>
extend( extend(
{ {
type: "bi.bubble_popup_view", type: BubblePopupView.xtype,
animation: "bi-zoom-big", animation: "bi-zoom-big",
animationDuring: 200, animationDuring: 200,
primary: o.primary, primary: o.primary,
}, },
isFunction(this.options.popup) isFunction(this.options.popup) ? this.options.popup() : this.options.popup
? this.options.popup()
: this.options.popup
), ),
}); });
this.combo.on(Combo.EVENT_TRIGGER_CHANGE, (...args) => { this.combo.on(Combo.EVENT_TRIGGER_CHANGE, (...args) => {
@ -135,5 +127,3 @@ export class BubbleCombo extends Widget {
this.combo.adjustHeight(); this.combo.adjustHeight();
} }
} }

2
src/case/combo/bubblecombo/popup.bubble.js

@ -26,7 +26,7 @@ export class BubblePopupView extends PopupView {
text: o.text, text: o.text,
whiteSpace: "normal", whiteSpace: "normal",
textAlign: "left", textAlign: "left",
ref: _ref => { ref: (_ref) => {
this.text = _ref; this.text = _ref;
}, },
}; };

13
src/case/combo/editoriconcheckcombo/combo.editiconcheck.js

@ -1,14 +1,7 @@
import { import { TextValueCheckComboPopup } from "../textvaluecheckcombo/popup.textvaluecheck";
shortcut, import { shortcut, Widget, extend, emptyFn, createWidget, Controller } from "@/core";
Widget,
extend,
emptyFn,
createWidget,
Controller
} from "@/core";
import { ButtonGroup, Combo } from "@/base"; import { ButtonGroup, Combo } from "@/base";
import { EditorTrigger } from "../../trigger"; import { EditorTrigger } from "../../trigger";
import { TextValueCheckComboPopup } from "../textvaluecheckcombo/popup.textvaluecheck";
@shortcut() @shortcut()
export class EditorIconCheckCombo extends Widget { export class EditorIconCheckCombo extends Widget {
@ -66,7 +59,7 @@ export class EditorIconCheckCombo extends Widget {
}); });
this.popup = createWidget({ this.popup = createWidget({
type: "bi.text_value_check_combo_popup", type: TextValueCheckComboPopup.xtype,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
value: o.value, value: o.value,

14
src/case/combo/iconcombo/combo.icon.js

@ -1,13 +1,5 @@
import { import { IconComboTrigger } from "./trigger.iconcombo";
shortcut, import { shortcut, Widget, extend, isFunction, createWidget, Controller, isNull, isArray } from "@/core";
Widget,
extend,
isFunction,
createWidget,
Controller,
isNull,
isArray
} from "@/core";
import { ButtonGroup, Combo } from "@/base"; import { ButtonGroup, Combo } from "@/base";
import { IconComboPopup } from "./popup.iconcombo"; import { IconComboPopup } from "./popup.iconcombo";
@ -52,7 +44,7 @@ export class IconCombo extends Widget {
: o.items; : o.items;
super._init(...arguments); super._init(...arguments);
this.trigger = createWidget(o.el, { this.trigger = createWidget(o.el, {
type: "bi.icon_combo_trigger", type: IconComboTrigger.xtype,
iconCls: o.iconCls, iconCls: o.iconCls,
title: o.title, title: o.title,
items: o.items, items: o.items,

10
src/case/combo/iconcombo/popup.iconcombo.js

@ -1,12 +1,4 @@
import { import { shortcut, extend, createWidget, createItems, Controller, Events, VerticalLayout } from "@/core";
shortcut,
extend,
createWidget,
createItems,
Controller,
Events,
VerticalLayout
} from "@/core";
import { Pane, ButtonGroup } from "@/base"; import { Pane, ButtonGroup } from "@/base";
import { SingleSelectIconTextItem } from "../../button"; import { SingleSelectIconTextItem } from "../../button";

11
src/case/combo/iconcombo/trigger.iconcombo.js

@ -1,13 +1,4 @@
import { import { shortcut, extend, isKey, createWidget, isNotEmptyString, AbsoluteLayout, isArray, any } from "@/core";
shortcut,
extend,
isKey,
createWidget,
isNotEmptyString,
AbsoluteLayout,
isArray,
any
} from "@/core";
import { Trigger, IconButton } from "@/base"; import { Trigger, IconButton } from "@/base";
import { IconChangeButton } from "../../button"; import { IconChangeButton } from "../../button";

10
src/case/combo/icontextvaluecombo/combo.icontextvalue.js

@ -1,3 +1,4 @@
import { IconTextValueComboPopup } from "./popup.icontextvalue";
import { import {
shortcut, shortcut,
Widget, Widget,
@ -14,7 +15,6 @@ import {
find, find,
contains contains
} from "@/core"; } from "@/core";
import { IconTextValueComboPopup } from "./popup.icontextvalue";
import { SelectIconTextTrigger } from "../../trigger"; import { SelectIconTextTrigger } from "../../trigger";
import { Combo } from "@/base"; import { Combo } from "@/base";
@ -26,11 +26,7 @@ export class IconTextValueCombo extends Widget {
_defaultConfig(config) { _defaultConfig(config) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: baseCls: `bi-icon-text-value-combo ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
`bi-icon-text-value-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
height: 24, height: 24,
iconHeight: null, iconHeight: null,
iconWidth: null, iconWidth: null,
@ -66,7 +62,7 @@ export class IconTextValueCombo extends Widget {
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
}); });
this.popup = createWidget({ this.popup = createWidget({
type: "bi.icon_text_value_combo_popup", type: IconTextValueComboPopup.xtype,
items: o.items, items: o.items,
value: o.value, value: o.value,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,

10
src/case/combo/icontextvaluecombo/popup.icontextvalue.js

@ -1,12 +1,4 @@
import { import { shortcut, extend, createWidget, createItems, Controller, Events, VerticalLayout } from "@/core";
shortcut,
extend,
createWidget,
createItems,
Controller,
Events,
VerticalLayout
} from "@/core";
import { Pane, ButtonGroup } from "@/base"; import { Pane, ButtonGroup } from "@/base";
import { SingleSelectIconTextItem } from "../../button"; import { SingleSelectIconTextItem } from "../../button";

36
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -1,3 +1,5 @@
import { SearchTextValueTrigger } from "./trigger.searchtextvalue";
import { TextValueComboPopup } from "../textvaluecombo/popup.textvalue";
import { import {
shortcut, shortcut,
Widget, Widget,
@ -11,9 +13,7 @@ import {
find, find,
contains contains
} from "@/core"; } from "@/core";
import { SearchTextValueTrigger } from "./trigger.searchtextvalue";
import { ButtonGroup, Combo } from "@/base"; import { ButtonGroup, Combo } from "@/base";
import { TextValueComboPopup } from "../textvaluecombo/popup.textvalue";
@shortcut() @shortcut()
export class SearchTextValueCombo extends Widget { export class SearchTextValueCombo extends Widget {
@ -49,21 +49,19 @@ export class SearchTextValueCombo extends Widget {
return { return {
type: Combo.xtype, type: Combo.xtype,
cls: cls: `${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"} bi-focus-shadow`,
`${o.simple ? "bi-border-bottom" : "bi-border bi-border-radius"
} bi-focus-shadow`,
container: o.container, container: o.container,
adjustLength: 2, adjustLength: 2,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
width: toPix(o.width, 2), width: toPix(o.width, 2),
ref: _ref => { ref: (_ref) => {
this.combo = _ref; this.combo = _ref;
}, },
el: { el: {
type: "bi.search_text_value_trigger", type: SearchTextValueTrigger.xtype,
cls: "search-text-value-trigger", cls: "search-text-value-trigger",
watermark: o.watermark, watermark: o.watermark,
ref: _ref => { ref: (_ref) => {
this.trigger = _ref; this.trigger = _ref;
}, },
items: o.items, items: o.items,
@ -90,16 +88,16 @@ export class SearchTextValueCombo extends Widget {
this._clear(); this._clear();
this.fireEvent(SearchTextValueCombo.EVENT_CHANGE); this.fireEvent(SearchTextValueCombo.EVENT_CHANGE);
}, },
} },
], ],
}, },
popup: { popup: {
el: { el: {
type: "bi.text_value_combo_popup", type: TextValueComboPopup.xtype,
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
value: o.value, value: o.value,
items: o.items, items: o.items,
ref: _ref => { ref: (_ref) => {
this.popup = _ref; this.popup = _ref;
this.trigger.getSearcher().setAdapter(this.popup); this.trigger.getSearcher().setAdapter(this.popup);
}, },
@ -109,11 +107,9 @@ export class SearchTextValueCombo extends Widget {
action: () => { action: () => {
this.setValue(this.getValue()[0]); this.setValue(this.getValue()[0]);
this.combo.hideView(); this.combo.hideView();
this.fireEvent( this.fireEvent(SearchTextValueCombo.EVENT_CHANGE);
SearchTextValueCombo.EVENT_CHANGE },
);
}, },
}
], ],
}, },
value: o.value, value: o.value,
@ -125,19 +121,15 @@ export class SearchTextValueCombo extends Widget {
eventName: Combo.EVENT_AFTER_HIDEVIEW, eventName: Combo.EVENT_AFTER_HIDEVIEW,
action: () => { action: () => {
this.trigger.stopEditing(); this.trigger.stopEditing();
this.fireEvent( this.fireEvent(SearchTextValueCombo.EVENT_AFTER_HIDEVIEW);
SearchTextValueCombo.EVENT_AFTER_HIDEVIEW
);
}, },
}, },
{ {
eventName: Combo.EVENT_BEFORE_POPUPVIEW, eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
this.fireEvent( this.fireEvent(SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW);
SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW },
);
}, },
}
], ],
}; };
} }

27
src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js

@ -1,12 +1,4 @@
import { import { shortcut, Controller, Events, VerticalLayout, map, extend, concat } from "@/core";
shortcut,
Controller,
Events,
VerticalLayout,
map,
extend,
concat
} from "@/core";
import { ButtonGroup, Pane } from "@/base"; import { ButtonGroup, Pane } from "@/base";
import { SingleSelectItem } from "../../button"; import { SingleSelectItem } from "../../button";
@ -48,16 +40,9 @@ export class SearchTextValueComboPopup extends Pane {
eventName: Controller.EVENT_CHANGE, eventName: Controller.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
const [type, val, obj] = args; const [type, val, obj] = args;
this.fireEvent( this.fireEvent(Controller.EVENT_CHANGE, ...args);
Controller.EVENT_CHANGE,
...args
);
if (type === Events.CLICK) { if (type === Events.CLICK) {
this.fireEvent( this.fireEvent(SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
SearchTextValueComboPopup.EVENT_CHANGE,
val,
obj
);
} }
}, },
} }
@ -70,14 +55,16 @@ export class SearchTextValueComboPopup extends Pane {
_formatItems(items) { _formatItems(items) {
const o = this.options; const o = this.options;
return map(items, (i, item) => extend( return map(items, (i, item) =>
extend(
{ {
type: SingleSelectItem.xtype, type: SingleSelectItem.xtype,
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text, title: item.title || item.text,
}, },
item item
)); )
);
} }
mounted() { mounted() {

45
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -1,16 +1,6 @@
import { import { HorizontalFillLayout, shortcut, find, i18nText, isNotEmptyString, VerticalAdaptLayout } from "@/core";
shortcut, import { SearchTextValueComboPopup } from "./popup.searchtextvalue";
find, import { ButtonGroup, Trigger, Searcher, IconButton } from "@/base";
i18nText,
isNotEmptyString,
VerticalAdaptLayout
} from "@/core";
import {
ButtonGroup,
Trigger,
Searcher,
IconButton
} from "@/base";
import { TriggerIconButton } from "../../button"; import { TriggerIconButton } from "../../button";
import { DefaultTextEditor } from "../../editor"; import { DefaultTextEditor } from "../../editor";
@ -50,7 +40,7 @@ export class SearchTextValueTrigger extends Trigger {
const stateText = this._digest(o.value, o.items) || o.text; const stateText = this._digest(o.value, o.items) || o.text;
return { return {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", 24], columnSize: ["fill", 24],
items: [ items: [
{ {
@ -72,17 +62,14 @@ export class SearchTextValueTrigger extends Trigger {
height: o.height, height: o.height,
}, },
popup: { popup: {
type: "bi.search_text_value_combo_popup", type: SearchTextValueComboPopup.xtype,
cls: "bi-card", cls: "bi-card",
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
tipText: i18nText("BI-No_Select"), tipText: i18nText("BI-No_Select"),
}, },
onSearch(obj, callback) { onSearch(obj, callback) {
const keyword = obj.keyword; const keyword = obj.keyword;
const finding = BI.Func.getSearchResult( const finding = BI.Func.getSearchResult(o.items, keyword);
o.items,
keyword
);
const matched = finding.match, const matched = finding.match,
find = finding.find; find = finding.find;
callback(matched, find); callback(matched, find);
@ -91,9 +78,7 @@ export class SearchTextValueTrigger extends Trigger {
{ {
eventName: Searcher.EVENT_CHANGE, eventName: Searcher.EVENT_CHANGE,
action: () => { action: () => {
this.fireEvent( this.fireEvent(SearchTextValueTrigger.EVENT_CHANGE);
SearchTextValueTrigger.EVENT_CHANGE
);
}, },
} }
], ],
@ -112,20 +97,13 @@ export class SearchTextValueTrigger extends Trigger {
ref: _ref => { ref: _ref => {
this.clearBtn = _ref; this.clearBtn = _ref;
}, },
cls: cls: `close-h-font ${o.allowClear ? "clear-button" : ""}`,
`close-h-font ${
o.allowClear
? "clear-button"
: ""}`,
stopPropagation: true, stopPropagation: true,
invisible: invisible: !isNotEmptyString(stateText),
!isNotEmptyString(stateText),
width: o.height, width: o.height,
height: o.height, height: o.height,
handler: () => { handler: () => {
this.fireEvent( this.fireEvent(SearchTextValueTrigger.EVENT_CLEAR);
SearchTextValueTrigger.EVENT_CLEAR
);
}, },
}, },
}, },
@ -166,8 +144,7 @@ export class SearchTextValueTrigger extends Trigger {
setValue(vals) { setValue(vals) {
const digestText = this._digest(vals, this.options.items); const digestText = this._digest(vals, this.options.items);
this._setState(digestText); this._setState(digestText);
this.options.allowClear && this.options.allowClear && this.clearBtn.setVisible(isNotEmptyString(digestText));
this.clearBtn.setVisible(isNotEmptyString(digestText));
} }
getValue() { getValue() {

24
src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js

@ -1,15 +1,4 @@
import { import { shortcut, Widget, extend, isFunction, createWidget, toPix, Controller, isKey, isNull, isArray } from "@/core";
shortcut,
Widget,
extend,
isFunction,
createWidget,
toPix,
Controller,
isKey,
isNull,
isArray
} from "@/core";
import { ButtonGroup, Combo } from "@/base"; import { ButtonGroup, Combo } from "@/base";
import { TextValueCheckComboPopup } from "./popup.textvaluecheck"; import { TextValueCheckComboPopup } from "./popup.textvaluecheck";
import { SelectTextTrigger } from "../../trigger"; import { SelectTextTrigger } from "../../trigger";
@ -22,9 +11,7 @@ export class TextValueCheckCombo extends Widget {
_defaultConfig(config) { _defaultConfig(config) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: baseCls: `bi-text-value-check-combo ${config.simple ? "bi-border-bottom" : "bi-border"}`,
`bi-text-value-check-combo ${
config.simple ? "bi-border-bottom" : "bi-border"}`,
width: 100, width: 100,
height: 24, height: 24,
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
@ -64,9 +51,12 @@ export class TextValueCheckCombo extends Widget {
this.textIconCheckCombo.hideView(); this.textIconCheckCombo.hideView();
this.fireEvent(TextValueCheckCombo.EVENT_CHANGE); this.fireEvent(TextValueCheckCombo.EVENT_CHANGE);
}); });
this.popup.on(Controller.EVENT_CHANGE, ...args => { this.popup.on(
Controller.EVENT_CHANGE,
...args => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); }
);
this.textIconCheckCombo = createWidget({ this.textIconCheckCombo = createWidget({
type: Combo.xtype, type: Combo.xtype,
container: o.container, container: o.container,

16
src/case/combo/textvaluecheckcombo/popup.textvaluecheck.js

@ -1,12 +1,4 @@
import { import { shortcut, extend, createWidget, Controller, Events, VerticalLayout, map } from "@/core";
shortcut,
extend,
createWidget,
Controller,
Events,
VerticalLayout,
map
} from "@/core";
import { Pane, ButtonGroup } from "@/base"; import { Pane, ButtonGroup } from "@/base";
import { SingleSelectItem } from "../../button"; import { SingleSelectItem } from "../../button";
@ -57,7 +49,8 @@ export class TextValueCheckComboPopup extends Pane {
_formatItems(items) { _formatItems(items) {
const o = this.options; const o = this.options;
return map(items, (i, item) => extend( return map(items, (i, item) =>
extend(
{ {
type: SingleSelectItem.xtype, type: SingleSelectItem.xtype,
cls: "bi-list-item", cls: "bi-list-item",
@ -65,7 +58,8 @@ export class TextValueCheckComboPopup extends Pane {
title: item.title || item.text, title: item.title || item.text,
}, },
item item
)); )
);
} }
populate(items) { populate(items) {

48
src/case/combo/textvaluecombo/combo.textvalue.js

@ -1,3 +1,4 @@
import { TextValueComboPopup } from "./popup.textvalue";
import { import {
shortcut, shortcut,
Widget, Widget,
@ -15,7 +16,6 @@ import {
} from "@/core"; } from "@/core";
import { ButtonGroup, Combo } from "@/base"; import { ButtonGroup, Combo } from "@/base";
import { SelectTextTrigger } from "../../trigger"; import { SelectTextTrigger } from "../../trigger";
import { TextValueComboPopup } from "./popup.textvalue";
@shortcut() @shortcut()
export class TextValueCombo extends Widget { export class TextValueCombo extends Widget {
@ -25,11 +25,7 @@ export class TextValueCombo extends Widget {
_defaultConfig(config) { _defaultConfig(config) {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: baseCls: `bi-text-value-combo ${config.simple ? "bi-border-bottom" : "bi-border bi-border-radius"}`,
`bi-text-value-combo ${
config.simple
? "bi-border-bottom"
: "bi-border bi-border-radius"}`,
height: 24, height: 24,
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE,
text: "", text: "",
@ -79,7 +75,7 @@ export class TextValueCombo extends Widget {
const trigger = { const trigger = {
type: SelectTextTrigger.xtype, type: SelectTextTrigger.xtype,
ref: ref => (this.trigger = ref), ref: (ref) => (this.trigger = ref),
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: toPix(o.height, o.simple ? 1 : 2), height: toPix(o.height, o.simple ? 1 : 2),
@ -95,14 +91,14 @@ export class TextValueCombo extends Widget {
this._clear(); this._clear();
this.fireEvent(TextValueCombo.EVENT_CHANGE); this.fireEvent(TextValueCombo.EVENT_CHANGE);
}, },
} },
], ],
...o.el, ...o.el,
}; };
let changeTag = false; let changeTag = false;
const popup = { const popup = {
type: "bi.text_value_combo_popup", type: TextValueComboPopup.xtype,
ref: ref => (this.popup = ref), ref: (ref) => (this.popup = ref),
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
allowSelectAll: o.allowSelectAll, allowSelectAll: o.allowSelectAll,
@ -115,15 +111,9 @@ export class TextValueCombo extends Widget {
this.setValue(value); this.setValue(value);
if (o.chooseType === ButtonGroup.CHOOSE_TYPE_SINGLE) { if (o.chooseType === ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.combo.hideView(...args); this.combo.hideView(...args);
this.fireEvent( this.fireEvent(TextValueCombo.EVENT_CHANGE, ...args);
TextValueCombo.EVENT_CHANGE,
...args
);
} }
if ( if (o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI && isEmptyArray(value)) {
o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI &&
isEmptyArray(value)
) {
this._clear(); this._clear();
} }
}, },
@ -147,7 +137,7 @@ export class TextValueCombo extends Widget {
action: (...args) => { action: (...args) => {
this.combo.hideView(); this.combo.hideView();
}, },
} },
], ],
}; };
@ -155,7 +145,7 @@ export class TextValueCombo extends Widget {
type: Combo.xtype, type: Combo.xtype,
height: toPix(o.height, 2), height: toPix(o.height, 2),
width: toPix(o.width, 2), width: toPix(o.width, 2),
ref: ref => (this.combo = ref), ref: (ref) => (this.combo = ref),
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
adjustLength: 2, adjustLength: 2,
@ -170,27 +160,17 @@ export class TextValueCombo extends Widget {
{ {
eventName: Combo.EVENT_AFTER_HIDEVIEW, eventName: Combo.EVENT_AFTER_HIDEVIEW,
action: (...args) => { action: (...args) => {
if ( if (o.chooseType !== ButtonGroup.CHOOSE_TYPE_SINGLE && changeTag) {
o.chooseType !== ButtonGroup.CHOOSE_TYPE_SINGLE && this.fireEvent(TextValueCombo.EVENT_CHANGE, ...args);
changeTag
) {
this.fireEvent(
TextValueCombo.EVENT_CHANGE,
...args
);
} }
}, },
} },
], ],
popup: { popup: {
el: popup, el: popup,
value: o.value, value: o.value,
maxHeight: 240, maxHeight: 240,
minHeight: minHeight: o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI && o.allowSelectAll ? 55 : 25,
o.chooseType === ButtonGroup.CHOOSE_TYPE_MULTI &&
o.allowSelectAll
? 55
: 25,
}, },
}; };
} }

19
src/case/combo/textvaluecombo/combo.textvaluesmall.js

@ -1,11 +1,7 @@
import { import { TextValueCombo } from "./combo.textvalue";
shortcut, import { shortcut, Widget, extend } from "@/core";
Widget,
extend
} from "@/core";
import { ButtonGroup } from "@/base"; import { ButtonGroup } from "@/base";
import { SmallSelectTextTrigger } from "../../trigger"; import { SmallSelectTextTrigger } from "../../trigger";
import { TextValueCombo } from "./combo.textvalue";
@shortcut() @shortcut()
export class SmallTextValueCombo extends Widget { export class SmallTextValueCombo extends Widget {
@ -27,8 +23,8 @@ export class SmallTextValueCombo extends Widget {
const o = this.options; const o = this.options;
return { return {
type: "bi.text_value_combo", type: TextValueCombo.xtype,
ref: _ref => { ref: (_ref) => {
this.combo = _ref; this.combo = _ref;
}, },
height: o.height, height: o.height,
@ -47,12 +43,9 @@ export class SmallTextValueCombo extends Widget {
{ {
eventName: TextValueCombo.EVENT_CHANGE, eventName: TextValueCombo.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
this.fireEvent( this.fireEvent(SmallTextValueCombo.EVENT_CHANGE, ...args);
SmallTextValueCombo.EVENT_CHANGE, },
...args
);
}, },
}
], ],
}; };
} }

39
src/case/combo/textvaluecombo/popup.textvalue.js

@ -55,16 +55,9 @@ export class TextValueComboPopup extends Pane {
{ {
eventName: Controller.EVENT_CHANGE, eventName: Controller.EVENT_CHANGE,
action: (type, val, obj) => { action: (type, val, obj) => {
this.fireEvent( this.fireEvent(Controller.EVENT_CHANGE, arguments);
Controller.EVENT_CHANGE,
arguments
);
if (type === Events.CLICK) { if (type === Events.CLICK) {
this.fireEvent( this.fireEvent(TextValueComboPopup.EVENT_CHANGE, val, obj);
TextValueComboPopup.EVENT_CHANGE,
val,
obj
);
} }
}, },
} }
@ -105,10 +98,7 @@ export class TextValueComboPopup extends Pane {
{ {
eventName: SelectList.EVENT_CHANGE, eventName: SelectList.EVENT_CHANGE,
action(val) { action(val) {
this.fireEvent( this.fireEvent(TextValueComboPopup.EVENT_CHANGE, val);
TextValueComboPopup.EVENT_CHANGE,
val
);
}, },
} }
], ],
@ -123,18 +113,14 @@ export class TextValueComboPopup extends Pane {
type: TextButton.xtype, type: TextButton.xtype,
text: i18nText("BI-Basic_Clears"), text: i18nText("BI-Basic_Clears"),
handler: () => { handler: () => {
this.fireEvent( this.fireEvent(TextValueComboPopup.EVENT_CLEAR);
TextValueComboPopup.EVENT_CLEAR
);
}, },
}, },
{ {
type: TextButton.xtype, type: TextButton.xtype,
text: i18nText("BI-Basic_OK"), text: i18nText("BI-Basic_OK"),
handler: () => { handler: () => {
this.fireEvent( this.fireEvent(TextValueComboPopup.EVENT_CONFIRM);
TextValueComboPopup.EVENT_CONFIRM
);
}, },
} }
], ],
@ -168,10 +154,7 @@ export class TextValueComboPopup extends Pane {
{ {
eventName: ListPane.EVENT_CHANGE, eventName: ListPane.EVENT_CHANGE,
action: val => { action: val => {
this.fireEvent( this.fireEvent(TextValueComboPopup.EVENT_CHANGE, val);
TextValueComboPopup.EVENT_CHANGE,
val
);
}, },
} }
], ],
@ -189,18 +172,18 @@ export class TextValueComboPopup extends Pane {
_formatItems(items) { _formatItems(items) {
const o = this.options; const o = this.options;
return map(items, (i, item) => extend( return map(items, (i, item) =>
extend(
{ {
type: type:
o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI o.chooseType !== ButtonGroup.CHOOSE_TYPE_MULTI ? SingleSelectItem.xtype : MultiSelectItem.xtype,
? SingleSelectItem.xtype
: MultiSelectItem.xtype,
iconWrapperWidth: 36, iconWrapperWidth: 36,
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text, title: item.title || item.text,
}, },
item item
)); )
);
} }
populate(items) { populate(items) {

69
src/case/editor/editor.clear.js

@ -1,5 +1,16 @@
import { shortcut, Widget, extend, emptyFn, isKey, isFunction, createWidget, Controller, Events } from "@/core";
import { Editor, IconButton } from "@/base"; import { Editor, IconButton } from "@/base";
import {
HTapeLayout,
shortcut,
Widget,
extend,
emptyFn,
isKey,
isFunction,
createWidget,
Controller,
Events
} from "@/core";
/** /**
* 有清除按钮的文本框 * 有清除按钮的文本框
@ -9,27 +20,27 @@ import { Editor, IconButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class ClearEditor extends Widget { export class ClearEditor extends Widget {
static xtype = "bi.clear_editor" static xtype = "bi.clear_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_BACKSPACE = "EVENT_BACKSPACE" static EVENT_BACKSPACE = "EVENT_BACKSPACE";
static EVENT_CLEAR = "EVENT_CLEAR" static EVENT_CLEAR = "EVENT_CLEAR";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_REMOVE = "EVENT_REMOVE" static EVENT_REMOVE = "EVENT_REMOVE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -46,12 +57,14 @@ export class ClearEditor extends Widget {
_init() { _init() {
const o = this.options; const o = this.options;
o.value = isFunction(o.value) ? this.__watch(o.value, (context, newValue) => { o.value = isFunction(o.value)
? this.__watch(o.value, (context, newValue) => {
this.setValue(newValue); this.setValue(newValue);
}) : o.value; })
: o.value;
super._init(...arguments); super._init(...arguments);
this.editor = createWidget({ this.editor = createWidget({
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
watermark: o.watermark, watermark: o.watermark,
@ -63,7 +76,7 @@ export class ClearEditor extends Widget {
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.clear = createWidget({ this.clear = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
stopEvent: true, stopEvent: true,
invisible: !isKey(o.value), invisible: !isKey(o.value),
cls: "search-close-h-font", cls: "search-close-h-font",
@ -75,8 +88,9 @@ export class ClearEditor extends Widget {
}); });
createWidget({ createWidget({
element: this, element: this,
type: "bi.htape", type: HTapeLayout.xtype,
items: [{ items: [
{
el: this.editor, el: this.editor,
}, },
{ {
@ -112,7 +126,6 @@ export class ClearEditor extends Widget {
this.fireEvent(ClearEditor.EVENT_BACKSPACE); this.fireEvent(ClearEditor.EVENT_BACKSPACE);
}); });
this.editor.on(Editor.EVENT_VALID, () => { this.editor.on(Editor.EVENT_VALID, () => {
this.fireEvent(ClearEditor.EVENT_VALID); this.fireEvent(ClearEditor.EVENT_VALID);
}); });

66
src/case/editor/editor.defaulttext.js

@ -1,6 +1,15 @@
import { shortcut, Widget, emptyFn, isKey, isFunction, createWidget, nextTick, Controller } from "@/core";
import { Editor, TextButton } from "@/base"; import { Editor, TextButton } from "@/base";
import {
AbsoluteLayout,
shortcut,
Widget,
emptyFn,
isKey,
isFunction,
createWidget,
nextTick,
Controller
} from "@/core";
/** /**
* dailer * dailer
@ -10,25 +19,25 @@ import { Editor, TextButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class DefaultTextEditor extends Widget { export class DefaultTextEditor extends Widget {
static xtype = "bi.default_text_editor" static xtype = "bi.default_text_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL" static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
props() { props() {
return { return {
@ -54,7 +63,7 @@ export class DefaultTextEditor extends Widget {
render() { render() {
const o = this.options; const o = this.options;
this.editor = createWidget(o.el, { this.editor = createWidget(o.el, {
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
@ -76,7 +85,7 @@ export class DefaultTextEditor extends Widget {
const showText = isFunction(o.text) ? o.text() : o.text; const showText = isFunction(o.text) ? o.text() : o.text;
this.text = createWidget({ this.text = createWidget({
type: "bi.text_button", type: TextButton.xtype,
cls: isKey(showText) ? "tip-text-style" : "bi-water-mark tip-text-style", cls: isKey(showText) ? "tip-text-style" : "bi-water-mark tip-text-style",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
@ -153,20 +162,23 @@ export class DefaultTextEditor extends Widget {
}); });
return { return {
type: "bi.absolute", type: AbsoluteLayout.xtype,
items: [{ items: [
{
el: this.editor, el: this.editor,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}, { },
{
el: this.text, el: this.text,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
],
}; };
} }

77
src/case/editor/editor.shelter.js

@ -1,5 +1,17 @@
import { shortcut, Widget, extend, emptyFn, isFunction, createWidget, Controller, isKey, nextTick, bind } from "@/core";
import { Editor, TextButton } from "@/base"; import { Editor, TextButton } from "@/base";
import {
AbsoluteLayout,
shortcut,
Widget,
extend,
emptyFn,
isFunction,
createWidget,
Controller,
isKey,
nextTick,
bind
} from "@/core";
/** /**
* 带标记的文本框 * 带标记的文本框
@ -9,25 +21,25 @@ import { Editor, TextButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class ShelterEditor extends Widget { export class ShelterEditor extends Widget {
static xtype = "bi.shelter_editor" static xtype = "bi.shelter_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL" static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -52,12 +64,14 @@ export class ShelterEditor extends Widget {
_init() { _init() {
const o = this.options; const o = this.options;
o.value = isFunction(o.value) ? this.__watch(o.value, (context, newValue) => { o.value = isFunction(o.value)
? this.__watch(o.value, (context, newValue) => {
this.setValue(newValue); this.setValue(newValue);
}) : o.value; })
: o.value;
super._init(...arguments); super._init(...arguments);
this.editor = createWidget({ this.editor = createWidget({
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
@ -75,7 +89,7 @@ export class ShelterEditor extends Widget {
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.text_button", type: TextButton.xtype,
cls: "shelter-editor-text", cls: "shelter-editor-text",
title: o.title, title: o.title,
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
@ -149,15 +163,18 @@ export class ShelterEditor extends Widget {
this.fireEvent(ShelterEditor.EVENT_EMPTY, ...args); this.fireEvent(ShelterEditor.EVENT_EMPTY, ...args);
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.text, el: this.text,
inset: 0, inset: 0,
}, { },
{
el: this.editor, el: this.editor,
inset: 0, inset: 0,
}], }
],
}); });
this._showHint(); this._showHint();
this._checkText(); this._checkText();
@ -165,7 +182,8 @@ export class ShelterEditor extends Widget {
_checkText() { _checkText() {
const o = this.options; const o = this.options;
nextTick(bind(function () { nextTick(
bind(function () {
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");
@ -174,7 +192,8 @@ export class ShelterEditor extends Widget {
this.text.element.removeClass("bi-water-mark"); this.text.element.removeClass("bi-water-mark");
} }
isKey(o.keyword) && this.text.doRedMark(o.keyword); isKey(o.keyword) && this.text.doRedMark(o.keyword);
}, this)); }, this)
);
} }
_showInput() { _showInput() {

79
src/case/editor/editor.sign.js

@ -1,5 +1,17 @@
import { shortcut, Widget, extend, emptyFn, isFunction, createWidget, nextTick, isKey, bind, Controller } from "@/core";
import { Editor, TextButton } from "@/base"; import { Editor, TextButton } from "@/base";
import {
AbsoluteLayout,
shortcut,
Widget,
extend,
emptyFn,
isFunction,
createWidget,
nextTick,
isKey,
bind,
Controller
} from "@/core";
/** /**
* 带标记的文本框 * 带标记的文本框
@ -9,26 +21,26 @@ import { Editor, TextButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class SignEditor extends Widget { export class SignEditor extends Widget {
static xtype = "bi.sign_editor" static xtype = "bi.sign_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN" static EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN";
static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL" static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -53,12 +65,14 @@ export class SignEditor extends Widget {
_init() { _init() {
const o = this.options; const o = this.options;
o.value = isFunction(o.value) ? this.__watch(o.value, (context, newValue) => { o.value = isFunction(o.value)
? this.__watch(o.value, (context, newValue) => {
this.setValue(newValue); this.setValue(newValue);
}) : o.value; })
: o.value;
super._init(...arguments); super._init(...arguments);
this.editor = createWidget({ this.editor = createWidget({
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
@ -76,7 +90,7 @@ export class SignEditor extends Widget {
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.text_button", type: TextButton.xtype,
cls: "sign-editor-text", cls: "sign-editor-text",
title: o.title, title: o.title,
warningTitle: o.warningTitle, warningTitle: o.warningTitle,
@ -156,15 +170,18 @@ export class SignEditor extends Widget {
this.fireEvent(SignEditor.EVENT_EMPTY, ...args); this.fireEvent(SignEditor.EVENT_EMPTY, ...args);
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.text, el: this.text,
inset: 0, inset: 0,
}, { },
{
el: this.editor, el: this.editor,
inset: 0, inset: 0,
}], }
],
}); });
this._showHint(); this._showHint();
this._checkText(); this._checkText();
@ -172,7 +189,8 @@ export class SignEditor extends Widget {
_checkText() { _checkText() {
const o = this.options; const o = this.options;
nextTick(bind(function () { nextTick(
bind(function () {
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");
@ -181,7 +199,8 @@ export class SignEditor extends Widget {
this.text.element.removeClass("bi-water-mark"); this.text.element.removeClass("bi-water-mark");
isKey(o.keyword) && this.text.doRedMark(o.keyword); isKey(o.keyword) && this.text.doRedMark(o.keyword);
} }
}, this)); }, this)
);
} }
_showInput() { _showInput() {

88
src/case/editor/editor.state.js

@ -1,5 +1,22 @@
import { shortcut, Widget, extend, emptyFn, i18nText, isArray, createWidget, nextTick, Controller, isNotNull, isString, isKey, isFunction, isNumber, isEmpty } from "@/core"; import { Editor, TextButton } from "@/base";
import { TextButton, Editor } from "@/base"; import {
AbsoluteLayout,
shortcut,
Widget,
extend,
emptyFn,
i18nText,
isArray,
createWidget,
nextTick,
Controller,
isNotNull,
isString,
isKey,
isFunction,
isNumber,
isEmpty
} from "@/core";
/** /**
* guy * guy
@ -9,25 +26,25 @@ import { TextButton, Editor } from "@/base";
*/ */
@shortcut() @shortcut()
export class StateEditor extends Widget { export class StateEditor extends Widget {
static xtype = "bi.state_editor" static xtype = "bi.state_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL" static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -56,7 +73,7 @@ export class StateEditor extends Widget {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.editor = createWidget(o.el, { this.editor = createWidget(o.el, {
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
@ -74,7 +91,7 @@ export class StateEditor extends Widget {
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.text_button", type: TextButton.xtype,
cls: "bi-water-mark tip-text-style", cls: "bi-water-mark tip-text-style",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
@ -85,7 +102,9 @@ export class StateEditor extends Widget {
this.editor.focus(); this.editor.focus();
this.editor.setValue(""); this.editor.setValue("");
}, },
title: isNotNull(o.tipText) ? o.tipText : () => { title: isNotNull(o.tipText)
? o.tipText
: () => {
let title = ""; let title = "";
if (isString(this.stateValue)) { if (isString(this.stateValue)) {
title = this.stateValue; title = this.stateValue;
@ -159,15 +178,18 @@ export class StateEditor extends Widget {
this.fireEvent(StateEditor.EVENT_EMPTY, ...args); this.fireEvent(StateEditor.EVENT_EMPTY, ...args);
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.text, el: this.text,
inset: 0, inset: 0,
}, { },
{
el: this.editor, el: this.editor,
inset: 0, inset: 0,
}], }
],
}); });
this._showHint(); this._showHint();
if (isNotNull(o.text)) { if (isNotNull(o.text)) {
@ -279,7 +301,9 @@ export class StateEditor extends Widget {
this.text.element.removeClass("bi-water-mark"); this.text.element.removeClass("bi-water-mark");
} else { } else {
this._setText(isKey(defaultText) ? defaultText : o.text); this._setText(isKey(defaultText) ? defaultText : o.text);
isKey(defaultText) ? this.text.element.addClass("bi-water-mark") : this.text.element.removeClass("bi-water-mark"); isKey(defaultText)
? this.text.element.addClass("bi-water-mark")
: this.text.element.removeClass("bi-water-mark");
} }
return; return;
@ -287,14 +311,18 @@ export class StateEditor extends Widget {
if (isString(v)) { if (isString(v)) {
this._setText(v); this._setText(v);
// 配置了defaultText才判断标灰,其他情况不标灰 // 配置了defaultText才判断标灰,其他情况不标灰
(isKey(defaultText) && defaultText === v) ? this.text.element.addClass("bi-water-mark") : this.text.element.removeClass("bi-water-mark"); isKey(defaultText) && defaultText === v
? this.text.element.addClass("bi-water-mark")
: this.text.element.removeClass("bi-water-mark");
return; return;
} }
if (isArray(v)) { if (isArray(v)) {
if (isEmpty(v)) { if (isEmpty(v)) {
this._setText(isKey(defaultText) ? defaultText : o.text); this._setText(isKey(defaultText) ? defaultText : o.text);
isKey(defaultText) ? this.text.element.addClass("bi-water-mark") : this.text.element.removeClass("bi-water-mark"); isKey(defaultText)
? this.text.element.addClass("bi-water-mark")
: this.text.element.removeClass("bi-water-mark");
} else if (v.length === 1) { } else if (v.length === 1) {
this._setText(v[0]); this._setText(v[0]);
this.text.element.removeClass("bi-water-mark"); this.text.element.removeClass("bi-water-mark");

69
src/case/editor/editor.state.simple.js

@ -1,5 +1,22 @@
import { shortcut, Widget, extend, emptyFn, i18nText, Controller, createWidget, nextTick, isNotNull, isKey, isFunction, isArray, isNumber, isEmpty } from "@/core";
import { Editor, TextButton } from "@/base"; import { Editor, TextButton } from "@/base";
import {
AbsoluteLayout,
VerticalLayout,
shortcut,
Widget,
extend,
emptyFn,
i18nText,
Controller,
createWidget,
nextTick,
isNotNull,
isKey,
isFunction,
isArray,
isNumber,
isEmpty
} from "@/core";
/** /**
* 无限制-已选择状态输入框 * 无限制-已选择状态输入框
@ -9,25 +26,25 @@ import { Editor, TextButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class SimpleStateEditor extends Widget { export class SimpleStateEditor extends Widget {
static xtype = "bi.simple_state_editor" static xtype = "bi.simple_state_editor";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_FOCUS = "EVENT_FOCUS" static EVENT_FOCUS = "EVENT_FOCUS";
static EVENT_BLUR = "EVENT_BLUR" static EVENT_BLUR = "EVENT_BLUR";
static EVENT_CLICK = "EVENT_CLICK" static EVENT_CLICK = "EVENT_CLICK";
static EVENT_KEY_DOWN = "EVENT_KEY_DOWN" static EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL" static EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
static EVENT_START = "EVENT_START" static EVENT_START = "EVENT_START";
static EVENT_PAUSE = "EVENT_PAUSE" static EVENT_PAUSE = "EVENT_PAUSE";
static EVENT_STOP = "EVENT_STOP" static EVENT_STOP = "EVENT_STOP";
static EVENT_CONFIRM = "EVENT_CONFIRM" static EVENT_CONFIRM = "EVENT_CONFIRM";
static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM" static EVENT_CHANGE_CONFIRM = "EVENT_CHANGE_CONFIRM";
static EVENT_VALID = "EVENT_VALID" static EVENT_VALID = "EVENT_VALID";
static EVENT_ERROR = "EVENT_ERROR" static EVENT_ERROR = "EVENT_ERROR";
static EVENT_ENTER = "EVENT_ENTER" static EVENT_ENTER = "EVENT_ENTER";
static EVENT_RESTRICT = "EVENT_RESTRICT" static EVENT_RESTRICT = "EVENT_RESTRICT";
static EVENT_SPACE = "EVENT_SPACE" static EVENT_SPACE = "EVENT_SPACE";
static EVENT_EMPTY = "EVENT_EMPTY" static EVENT_EMPTY = "EVENT_EMPTY";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -56,7 +73,7 @@ export class SimpleStateEditor extends Widget {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.editor = createWidget({ this.editor = createWidget({
type: "bi.editor", type: Editor.xtype,
simple: o.simple, simple: o.simple,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
@ -74,7 +91,7 @@ export class SimpleStateEditor extends Widget {
autoTrim: o.autoTrim, autoTrim: o.autoTrim,
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.text_button", type: TextButton.xtype,
cls: "bi-water-mark", cls: "bi-water-mark",
textAlign: "left", textAlign: "left",
text: o.text, text: o.text,
@ -92,15 +109,17 @@ export class SimpleStateEditor extends Widget {
}); });
}); });
createWidget({ createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
element: this, element: this,
items: [{ items: [
{
el: this.text, el: this.text,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
bottom: 0, bottom: 0,
}], }
],
}); });
this.editor.on(Controller.EVENT_CHANGE, (...args) => { this.editor.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
@ -157,7 +176,7 @@ export class SimpleStateEditor extends Widget {
this.fireEvent(SimpleStateEditor.EVENT_EMPTY, ...args); this.fireEvent(SimpleStateEditor.EVENT_EMPTY, ...args);
}); });
createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
scrolly: false, scrolly: false,
element: this, element: this,
items: [this.editor], items: [this.editor],

17
src/case/layer/layer.multipopup.js

@ -1,11 +1,12 @@
import { ButtonGroup, TextButton, PopupView } from "@/base";
import { CenterLayout, shortcut, extend, i18nText, each, createWidget, createItems } from "@/core";
/** /**
* 下拉框弹出层的多选版本toolbar带有若干按钮, zIndex在1000w * 下拉框弹出层的多选版本toolbar带有若干按钮, zIndex在1000w
* @class BI.MultiPopupView * @class BI.MultiPopupView
* @extends BI.Widget * @extends BI.Widget
*/ */
import { shortcut, extend, i18nText, each, createWidget, createItems } from "@/core";
import { PopupView, ButtonGroup } from "@/base";
@shortcut() @shortcut()
export class MultiPopupView extends PopupView { export class MultiPopupView extends PopupView {
static xtype = "bi.multi_popup_view"; static xtype = "bi.multi_popup_view";
@ -35,20 +36,22 @@ export class MultiPopupView extends PopupView {
}); });
this.buttongroup = createWidget({ this.buttongroup = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
cls: "list-view-toolbar bi-high-light bi-split-top", cls: "list-view-toolbar bi-high-light bi-split-top",
height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
items: createItems(text, { items: createItems(text, {
type: "bi.text_button", type: TextButton.xtype,
once: false, once: false,
shadow: true, shadow: true,
isShadowShowingOnSelected: true, isShadowShowingOnSelected: true,
}), }),
layouts: [{ layouts: [
type: "bi.center", {
type: CenterLayout.xtype,
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
}], }
],
}); });
this.buttongroup.on(ButtonGroup.EVENT_CHANGE, (value, obj) => { this.buttongroup.on(ButtonGroup.EVENT_CHANGE, (value, obj) => {

22
src/case/layer/layer.panel.js

@ -1,12 +1,13 @@
import { IconButton, Label } from "@/base";
import { HTapeLayout, shortcut, extend, createWidget } from "@/core";
import { MultiPopupView } from "./layer.multipopup";
/** /**
* 可以理解为MultiPopupView和Panel两个面板的结合体 * 可以理解为MultiPopupView和Panel两个面板的结合体
* @class BI.PopupPanel * @class BI.PopupPanel
* @extends BI.MultiPopupView * @extends BI.MultiPopupView
*/ */
import { shortcut, extend, createWidget } from "@/core";
import { IconButton } from "@/base";
import { MultiPopupView } from "./layer.multipopup";
@shortcut() @shortcut()
export class PopupPanel extends MultiPopupView { export class PopupPanel extends MultiPopupView {
static xtype = "bi.popup_panel"; static xtype = "bi.popup_panel";
@ -25,7 +26,7 @@ export class PopupPanel extends MultiPopupView {
_createTool() { _createTool() {
const o = this.options; const o = this.options;
const close = createWidget({ const close = createWidget({
type: "bi.icon_button", type: IconButton.xtype,
cls: "close-h-font", cls: "close-h-font",
width: 25, width: 25,
height: 25, height: 25,
@ -36,21 +37,24 @@ export class PopupPanel extends MultiPopupView {
}); });
return createWidget({ return createWidget({
type: "bi.htape", type: HTapeLayout.xtype,
cls: "popup-panel-title bi-header-background", cls: "popup-panel-title bi-header-background",
height: 25, height: 25,
items: [{ items: [
{
el: { el: {
type: "bi.label", type: Label.xtype,
textAlign: "left", textAlign: "left",
text: o.title, text: o.title,
height: 25, height: 25,
lgap: 10, lgap: 10,
}, },
}, { },
{
el: close, el: close,
width: 25, width: 25,
}], }
],
}); });
} }
} }

42
src/case/layer/pane.list.js

@ -1,10 +1,3 @@
/**
* list面板
*
* Created by GUY on 2015/10/30.
* @class BI.ListPane
* @extends BI.Pane
*/
import { import {
shortcut, shortcut,
extend, extend,
@ -27,6 +20,14 @@ import {
} from "@/core"; } from "@/core";
import { Pane, ButtonGroup } from "@/base"; import { Pane, ButtonGroup } from "@/base";
/**
* list面板
*
* Created by GUY on 2015/10/30.
* @class BI.ListPane
* @extends BI.Pane
*/
@shortcut() @shortcut()
export class ListPane extends Pane { export class ListPane extends Pane {
static xtype = "bi.list_pane"; static xtype = "bi.list_pane";
@ -102,9 +103,15 @@ export class ListPane extends Pane {
}); });
this.check(); this.check();
createWidget(extend({ createWidget(
extend(
{
element: this, element: this,
}, LogicFactory.createLogic(LogicFactory.createLogicTypeByDirection(Direction.Top), extend({ },
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(Direction.Top),
extend(
{
scrolly: true, scrolly: true,
lgap: o.lgap, lgap: o.lgap,
rgap: o.rgap, rgap: o.rgap,
@ -112,9 +119,15 @@ export class ListPane extends Pane {
bgap: o.bgap, bgap: o.bgap,
vgap: o.vgap, vgap: o.vgap,
hgap: o.hgap, hgap: o.hgap,
}, o.logic, { },
o.logic,
{
items: LogicFactory.createLogicItemsByDirection(Direction.Top, this.button_group), items: LogicFactory.createLogicItemsByDirection(Direction.Top, this.button_group),
})))); }
)
)
)
);
} }
hasPrev() { hasPrev() {
@ -146,9 +159,11 @@ export class ListPane extends Pane {
populate(items) { populate(items) {
const o = this.options; const o = this.options;
if (arguments.length === 0 && (isFunction(this.button_group.attr("itemsCreator")))) {// 接管loader的populate方法 if (arguments.length === 0 && isFunction(this.button_group.attr("itemsCreator"))) {
// 接管loader的populate方法
this.button_group.attr("itemsCreator").apply(this, [ this.button_group.attr("itemsCreator").apply(this, [
{ times: 1 }, (...args) => { { times: 1 },
(...args) => {
if (args.length === 0) { if (args.length === 0) {
throw new Error("参数不能为空"); throw new Error("参数不能为空");
} }
@ -229,4 +244,3 @@ export class ListPane extends Pane {
return this.button_group.getNodeByValue(value); return this.button_group.getNodeByValue(value);
} }
} }

38
src/case/layer/panel.js

@ -1,15 +1,21 @@
import {
import { shortcut, Widget, extend, toPix, Controller, createWidget } from "@/core"; VerticalFillLayout,
import { ButtonGroup } from "@/base"; CenterAdaptLayout,
LeftRightVerticalAdaptLayout,
shortcut,
Widget,
extend,
toPix,
Controller,
createWidget
} from "@/core";
import { Label, ButtonGroup } from "@/base";
@shortcut() @shortcut()
export class Panel extends Widget { export class Panel extends Widget {
static xtype = "bi.panel" static xtype = "bi.panel";
static EVENT_CHANGE = "EVENT_CHANGE"
static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -26,7 +32,7 @@ export class Panel extends Widget {
render() { render() {
return { return {
type: "bi.vertical_fill", type: VerticalFillLayout.xtype,
rowSize: ["", "fill"], rowSize: ["", "fill"],
items: [this._createTitle(), this.options.el], items: [this._createTitle(), this.options.el],
}; };
@ -35,19 +41,21 @@ export class Panel extends Widget {
_createTitle() { _createTitle() {
const o = this.options; const o = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
cls: "panel-title-text", cls: "panel-title-text",
text: o.title, text: o.title,
height: o.titleHeight, height: o.titleHeight,
}); });
this.button_group = createWidget({ this.button_group = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
items: o.titleButtons, items: o.titleButtons,
layouts: [{ layouts: [
type: "bi.center_adapt", {
type: CenterAdaptLayout.xtype,
lgap: 10, lgap: 10,
}], }
],
}); });
this.button_group.on(Controller.EVENT_CHANGE, (...args) => { this.button_group.on(Controller.EVENT_CHANGE, (...args) => {
@ -60,7 +68,7 @@ export class Panel extends Widget {
return { return {
// el: { // el: {
type: "bi.left_right_vertical_adapt", type: LeftRightVerticalAdaptLayout.xtype,
cls: "panel-title bi-header-background bi-border-bottom", cls: "panel-title bi-header-background bi-border-bottom",
height: toPix(o.titleHeight, 1), height: toPix(o.titleHeight, 1),
items: { items: {

38
src/case/linearsegment/button.linear.segment.js

@ -1,20 +1,24 @@
import { Label, BasicButton } from "@/base";
import { shortcut, toPix } from "@/core"; import { AbsoluteLayout, Layout, shortcut, toPix } from "@/core";
import { BasicButton } from "@/base";
@shortcut() @shortcut()
export class LinearSegmentButton extends BasicButton { export class LinearSegmentButton extends BasicButton {
static xtype = "bi.linear_segment_button" static xtype = "bi.linear_segment_button";
props = { extraCls:"bi-line-segment-button bi-list-item-effect", once:true, readonly:true, hgap:10, height:24 };
props = {
extraCls: "bi-line-segment-button bi-list-item-effect",
once: true,
readonly: true,
hgap: 10,
height: 24,
};
render() { render() {
const o = this.options; const o = this.options;
return [{ return [
type: "bi.label", {
type: Label.xtype,
text: o.text, text: o.text,
height: o.height, height: o.height,
textHeight: toPix(o.height, 2), textHeight: toPix(o.height, 2),
@ -23,11 +27,13 @@ export class LinearSegmentButton extends BasicButton {
ref: _ref => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
}, { },
type: "bi.absolute", {
items: [{ type: AbsoluteLayout.xtype,
items: [
{
el: { el: {
type: "bi.layout", type: Layout.xtype,
cls: "line-segment-button-line", cls: "line-segment-button-line",
height: 2, height: 2,
ref: _ref => { ref: _ref => {
@ -37,8 +43,10 @@ export class LinearSegmentButton extends BasicButton {
left: 0, left: 0,
right: 0, right: 0,
bottom: 0, bottom: 0,
}], }
}]; ],
}
];
} }
setSelected(v) { setSelected(v) {

44
src/case/linearsegment/linear.segment.js

@ -1,39 +1,45 @@
import { ButtonGroup } from "@/base";
import { shortcut, Widget, createItems, makeArrayByArray } from "@/core"; import { LinearSegmentButton } from "./button.linear.segment";
import { TableLayout, shortcut, Widget, createItems, makeArrayByArray } from "@/core";
@shortcut() @shortcut()
export class LinearSegment extends Widget { export class LinearSegment extends Widget {
static xtype = "bi.linear_segment" static xtype = "bi.linear_segment";
props = { baseCls: "bi-linear-segment", items: [], height: 30 }; props = { baseCls: "bi-linear-segment", items: [], height: 30 };
render() { render() {
const o = this.options; const o = this.options;
return { return {
type: "bi.button_group", type: ButtonGroup.xtype,
items: [createItems(o.items, { items: [
type: "bi.linear_segment_button", createItems(o.items, {
type: LinearSegmentButton.xtype,
height: o.height, height: o.height,
})], })
layouts: [{ ],
type: "bi.table", layouts: [
{
type: TableLayout.xtype,
columnSize: makeArrayByArray(o.items, "fill"), columnSize: makeArrayByArray(o.items, "fill"),
}], }
],
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: "__EVENT_CHANGE__", eventName: "__EVENT_CHANGE__",
action: (...args) => { action: (...args) => {
this.fireEvent("__EVENT_CHANGE__", ...args); this.fireEvent("__EVENT_CHANGE__", ...args);
}, },
}, { },
{
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",
action: () => { action: () => {
this.fireEvent("EVENT_CHANGE"); this.fireEvent("EVENT_CHANGE");
}, },
}], }
],
ref: _ref => { ref: _ref => {
this.buttonGroup = _ref; this.buttonGroup = _ref;
}, },
@ -54,9 +60,11 @@ export class LinearSegment extends Widget {
populate(buttons) { populate(buttons) {
const o = this.options; const o = this.options;
this.buttonGroup.populate([createItems(buttons, { this.buttonGroup.populate([
type: "bi.linear_segment_button", createItems(buttons, {
type: LinearSegmentButton.xtype,
height: o.height, height: o.height,
})]); })
]);
} }
} }

29
src/case/list/list.select.js

@ -1,5 +1,3 @@
/* eslint-disable no-mixed-spaces-and-tabs */
import { import {
shortcut, shortcut,
Widget, Widget,
@ -21,6 +19,8 @@ import { ButtonGroup } from "@/base";
import { MultiSelectBar } from "../toolbar/toolbar.multiselect"; import { MultiSelectBar } from "../toolbar/toolbar.multiselect";
import { ListPane } from "../layer/pane.list"; import { ListPane } from "../layer/pane.list";
/* eslint-disable no-mixed-spaces-and-tabs */
@shortcut() @shortcut()
export class SelectList extends Widget { export class SelectList extends Widget {
static xtype = "bi.select_list"; static xtype = "bi.select_list";
@ -94,13 +94,25 @@ export class SelectList extends Widget {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
createWidget(extend({ createWidget(
extend(
{
element: this, element: this,
}, LogicFactory.createLogic(LogicFactory.createLogicTypeByDirection(o.direction), extend({ },
LogicFactory.createLogic(
LogicFactory.createLogicTypeByDirection(o.direction),
extend(
{
scrolly: true, scrolly: true,
}, o.logic, { },
o.logic,
{
items: LogicFactory.createLogicItemsByDirection(o.direction, this.toolbar, this.list), items: LogicFactory.createLogicItemsByDirection(o.direction, this.toolbar, this.list),
})))); }
)
)
)
);
if (o.items.length <= 0) { if (o.items.length <= 0) {
this.toolbar.setVisible(false); this.toolbar.setVisible(false);
@ -214,8 +226,9 @@ export class SelectList extends Widget {
resetHeight(h) { resetHeight(h) {
const toolHeight = (this.toolbar.element.outerHeight() || 25) * (this.toolbar.isVisible() ? 1 : 0); const toolHeight = (this.toolbar.element.outerHeight() || 25) * (this.toolbar.isVisible() ? 1 : 0);
this.list.resetHeight ? this.list.resetHeight(h - toolHeight) : this.list.resetHeight
this.list.element.css({ "max-height": pixFormat(h - toolHeight) }); ? this.list.resetHeight(h - toolHeight)
: this.list.element.css({ "max-height": pixFormat(h - toolHeight) });
} }
setNotSelectedValue() { setNotSelectedValue() {

8
src/case/loader/loader.lazy.js

@ -1,15 +1,15 @@
import { shortcut, Widget, extend, createWidget, takeRight, take } from "@/core";
import { Loader } from "@/base"; import { Loader } from "@/base";
import { shortcut, Widget, extend, createWidget, takeRight, take } from "@/core";
@shortcut() @shortcut()
export class LazyLoader extends Widget { export class LazyLoader extends Widget {
static xtype = "bi.lazy_loader" static xtype = "bi.lazy_loader";
_const = { _const = {
PAGE: 100, PAGE: 100,
}; };
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -24,7 +24,7 @@ export class LazyLoader extends Widget {
super._init(...arguments); super._init(...arguments);
const all = o.items.length; const all = o.items.length;
this.loader = createWidget({ this.loader = createWidget({
type: "bi.loader", type: Loader.xtype,
element: this, element: this,
// 下面是button_group的属性 // 下面是button_group的属性
el: o.el, el: o.el,

84
src/case/loader/loader.list.js

@ -1,4 +1,23 @@
import { shortcut, Widget, extend, emptyFn, Controller, createWidget, Events, nextTick, bind, isEmpty, isNumber, isObject, isFunction, each, isNotEmptyArray, DOM } from "@/core"; import { ButtonGroup, LoadingBar } from "@/base";
import {
VerticalLayout,
shortcut,
Widget,
extend,
emptyFn,
Controller,
createWidget,
Events,
nextTick,
bind,
isEmpty,
isNumber,
isObject,
isFunction,
each,
isNotEmptyArray,
DOM
} from "@/core";
/** /**
* 恶心的加载控件 为解决排序问题引入的控件 * 恶心的加载控件 为解决排序问题引入的控件
@ -9,9 +28,9 @@ import { shortcut, Widget, extend, emptyFn, Controller, createWidget, Events, ne
*/ */
@shortcut() @shortcut()
export class ListLoader extends Widget { export class ListLoader extends Widget {
static xtype = "bi.list_loader" static xtype = "bi.list_loader";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -19,7 +38,7 @@ export class ListLoader extends Widget {
isDefaultInit: true, // 是否默认初始化数据 isDefaultInit: true, // 是否默认初始化数据
// 下面是button_group的属性 // 下面是button_group的属性
el: { el: {
type: "bi.button_group", type: ButtonGroup.xtype,
}, },
items: [], items: [],
itemsCreator: emptyFn, itemsCreator: emptyFn,
@ -34,12 +53,15 @@ export class ListLoader extends Widget {
_nextLoad() { _nextLoad() {
const o = this.options; const o = this.options;
this.next.setLoading(); this.next.setLoading();
o.itemsCreator.apply(this, [{ o.itemsCreator.apply(this, [
{
times: ++this.times, times: ++this.times,
}, (...args) => { },
(...args) => {
this.next.setLoaded(); this.next.setLoaded();
this.addItems(...args); this.addItems(...args);
}]); }
]);
} }
_init() { _init() {
@ -50,14 +72,16 @@ export class ListLoader extends Widget {
} }
this.button_group = createWidget(o.el, { this.button_group = createWidget(o.el, {
type: "bi.button_group", type: ButtonGroup.xtype,
element: this, element: this,
chooseType: 0, chooseType: 0,
items: o.items, items: o.items,
behaviors: {}, behaviors: {},
layouts: [{ layouts: [
type: "bi.vertical", {
}], type: VerticalLayout.xtype,
}
],
}); });
this.button_group.on(Controller.EVENT_CHANGE, (...args) => { this.button_group.on(Controller.EVENT_CHANGE, (...args) => {
const [type, , obj] = args; const [type, , obj] = args;
@ -68,9 +92,14 @@ export class ListLoader extends Widget {
}); });
if (o.next !== false) { if (o.next !== false) {
this.next = createWidget(extend({ this.next = createWidget(
type: "bi.loading_bar", extend(
}, o.next)); {
type: LoadingBar.xtype,
},
o.next
)
);
this.next.on(Controller.EVENT_CHANGE, type => { this.next.on(Controller.EVENT_CHANGE, type => {
if (type === Events.CLICK) { if (type === Events.CLICK) {
this._nextLoad(); this._nextLoad();
@ -79,14 +108,18 @@ export class ListLoader extends Widget {
} }
createWidget({ createWidget({
type: "bi.vertical", type: VerticalLayout.xtype,
element: this, element: this,
items: [this.next], items: [this.next],
}); });
o.isDefaultInit && isEmpty(o.items) && nextTick(bind(function () { o.isDefaultInit &&
isEmpty(o.items) &&
nextTick(
bind(function () {
this.populate(); this.populate();
}, this)); }, this)
);
if (isNotEmptyArray(o.items)) { if (isNotEmptyArray(o.items)) {
this.populate(o.items); this.populate(o.items);
} }
@ -98,10 +131,12 @@ export class ListLoader extends Widget {
return this.count < o.count; return this.count < o.count;
} }
return !!o.hasNext.apply(this, [{ return !!o.hasNext.apply(this, [
{
times: this.times, times: this.times,
count: this.count, count: this.count,
}]); }
]);
} }
addItems(items) { addItems(items) {
@ -120,16 +155,19 @@ export class ListLoader extends Widget {
populate(items) { populate(items) {
const o = this.options; const o = this.options;
if (arguments.length === 0 && (isFunction(o.itemsCreator))) { if (arguments.length === 0 && isFunction(o.itemsCreator)) {
o.itemsCreator.apply(this, [{ o.itemsCreator.apply(this, [
{
times: 1, times: 1,
}, (...args) => { },
(...args) => {
if (args.length === 0) { if (args.length === 0) {
throw new Error("参数不能为空"); throw new Error("参数不能为空");
} }
this.populate(...args); this.populate(...args);
o.onLoaded(); o.onLoaded();
}]); }
]);
return; return;
} }

26
src/case/loader/sort.list.js

@ -1,4 +1,6 @@
import { shortcut, Widget, extend, emptyFn, Controller, createWidget, Events, each, stripEL } from "@/core"; import { ButtonGroup } from "@/base";
import { ListLoader } from "./loader.list";
import { Layout, shortcut, Widget, extend, emptyFn, Controller, createWidget, Events, each, stripEL } from "@/core";
/** /**
* Created by GUY on 2016/4/29. * Created by GUY on 2016/4/29.
@ -8,9 +10,9 @@ import { shortcut, Widget, extend, emptyFn, Controller, createWidget, Events, ea
*/ */
@shortcut() @shortcut()
export class SortList extends Widget { export class SortList extends Widget {
static xtype = "bi.sort_list" static xtype = "bi.sort_list";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -18,7 +20,7 @@ export class SortList extends Widget {
isDefaultInit: true, // 是否默认初始化数据 isDefaultInit: true, // 是否默认初始化数据
// 下面是button_group的属性 // 下面是button_group的属性
el: { el: {
type: "bi.button_group", type: ButtonGroup.xtype,
}, },
items: [], items: [],
itemsCreator: emptyFn, itemsCreator: emptyFn,
@ -36,7 +38,7 @@ export class SortList extends Widget {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.loader = createWidget({ this.loader = createWidget({
type: "bi.list_loader", type: ListLoader.xtype,
element: this, element: this,
isDefaultInit: o.isDefaultInit, isDefaultInit: o.isDefaultInit,
el: o.el, el: o.el,
@ -68,7 +70,7 @@ export class SortList extends Widget {
placeholder: { placeholder: {
element($currentItem) { element($currentItem) {
const holder = createWidget({ const holder = createWidget({
type: "bi.layout", type: Layout.xtype,
cls: "bi-sortable-holder", cls: "bi-sortable-holder",
height: $currentItem.outerHeight(), height: $currentItem.outerHeight(),
}); });
@ -82,19 +84,13 @@ export class SortList extends Widget {
return holder.element; return holder.element;
}, },
update () { update() {},
},
},
start (event, ui) {
}, },
start(event, ui) {},
stop: (event, ui) => { stop: (event, ui) => {
this.fireEvent(SortList.EVENT_CHANGE); this.fireEvent(SortList.EVENT_CHANGE);
}, },
over (event, ui) { over(event, ui) {},
},
}); });
} }

83
src/case/pager/pager.all.count.js

@ -1,10 +1,26 @@
import { Pager, IconButton, Label } from "@/base";
import {
HorizontalLayout,
VerticalAdaptLayout,
FloatLeftLayout,
shortcut,
Widget,
extend,
isPositiveInteger,
createWidget,
parseInt,
HorizontalAlign,
isNotEmptyObject
} from "@/core";
import { SmallTextEditor } from "@/widget/editor/editor.text.small";
/** /**
* 有总页数和总行数的分页控件 * 有总页数和总行数的分页控件
* Created by Young's on 2016/10/13. * Created by Young's on 2016/10/13.
*/ */
import { shortcut, Widget, extend, isPositiveInteger, createWidget, parseInt, HorizontalAlign, isNotEmptyObject } from "@/core";
// import { TextEditor } from "@/widget/editor/editor.text"; //
import { Pager } from "@/base";
@shortcut() @shortcut()
export class AllCountPager extends Widget { export class AllCountPager extends Widget {
static xtype = "bi.all_count_pager"; static xtype = "bi.all_count_pager";
@ -24,9 +40,10 @@ export class AllCountPager extends Widget {
} }
_init() { _init() {
super._init(...arguments); super._init(...arguments);
const { pages, curr, hasPrev, hasNext, firstPage, lastPage, height, showRowCount } = this.options, pagerIconCls = this._getPagerIconCls(); const { pages, curr, hasPrev, hasNext, firstPage, lastPage, height, showRowCount } = this.options,
pagerIconCls = this._getPagerIconCls();
this.editor = createWidget({ this.editor = createWidget({
type: "bi.small_text_editor", type: SmallTextEditor.xtype,
cls: "pager-editor bi-border-radius", cls: "pager-editor bi-border-radius",
validationChecker(v) { validationChecker(v) {
return (pages === 0 && v === "0") || isPositiveInteger(v); return (pages === 0 && v === "0") || isPositiveInteger(v);
@ -41,12 +58,14 @@ export class AllCountPager extends Widget {
}); });
this.pager = createWidget({ this.pager = createWidget({
type: "bi.pager", type: Pager.xtype,
width: 58, width: 58,
layouts: [{ layouts: [
type: "bi.horizontal", {
type: HorizontalLayout.xtype,
lgap: 5, lgap: 5,
}], }
],
dynamicShow: false, dynamicShow: false,
pages, pages,
@ -56,7 +75,7 @@ export class AllCountPager extends Widget {
first: false, first: false,
last: false, last: false,
prev: { prev: {
type: "bi.icon_button", type: IconButton.xtype,
value: "prev", value: "prev",
title: BI.i18nText("BI-Previous_Page"), title: BI.i18nText("BI-Previous_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
@ -65,7 +84,7 @@ export class AllCountPager extends Widget {
cls: `bi-border bi-border-radius all-pager-prev bi-list-item-select2 ${pagerIconCls.preCls}`, cls: `bi-border bi-border-radius all-pager-prev bi-list-item-select2 ${pagerIconCls.preCls}`,
}, },
next: { next: {
type: "bi.icon_button", type: IconButton.xtype,
value: "next", value: "next",
title: BI.i18nText("BI-Next_Page"), title: BI.i18nText("BI-Next_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
@ -94,7 +113,7 @@ export class AllCountPager extends Widget {
}); });
this.allPages = createWidget({ this.allPages = createWidget({
type: "bi.label", type: Label.xtype,
title: pages, title: pages,
height, height,
text: `/${pages}`, text: `/${pages}`,
@ -102,21 +121,22 @@ export class AllCountPager extends Widget {
invisible: pages <= 1, invisible: pages <= 1,
}); });
createWidget(showRowCount ? { createWidget(
type: "bi.vertical_adapt", showRowCount
? {
type: VerticalAdaptLayout.xtype,
element: this, element: this,
scrollx: false, scrollx: false,
columnSize: ["fill", ""], columnSize: ["fill", ""],
horizontalAlign: HorizontalAlign.Right, horizontalAlign: HorizontalAlign.Right,
items: [ items: [this._getRowCountObject(), this.editor, this.allPages, this.pager],
this._getRowCountObject(), }
this.editor, this.allPages, this.pager : {
], type: VerticalAdaptLayout.xtype,
} : {
type: "bi.vertical_adapt",
element: this, element: this,
items: [this.editor, this.allPages, this.pager], items: [this.editor, this.allPages, this.pager],
}); }
);
} }
_getPagerIconCls() { _getPagerIconCls() {
@ -140,22 +160,24 @@ export class AllCountPager extends Widget {
const { height, count, rowInfoObject } = this.options; const { height, count, rowInfoObject } = this.options;
return { return {
type: "bi.left", type: FloatLeftLayout.xtype,
height, height,
scrollable: false, scrollable: false,
ref: _ref => { ref: _ref => {
this.rowCountObject = _ref; this.rowCountObject = _ref;
}, },
items: [{ items: [
type: "bi.label", {
type: Label.xtype,
height, height,
text: BI.i18nText("BI-Basic_Total"), text: BI.i18nText("BI-Basic_Total"),
ref: _ref => { ref: _ref => {
this.prevText = _ref; this.prevText = _ref;
}, },
}, { },
{
el: { el: {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: _ref => {
this.rowCount = _ref; this.rowCount = _ref;
}, },
@ -165,12 +187,15 @@ export class AllCountPager extends Widget {
title: count, title: count,
}, },
hgap: 5, hgap: 5,
}, { },
type: "bi.label", {
type: Label.xtype,
height, height,
text: BI.i18nText("BI-Tiao_Data"), text: BI.i18nText("BI-Tiao_Data"),
textAlign: "left", textAlign: "left",
}, isNotEmptyObject(rowInfoObject) ? rowInfoObject : null], },
isNotEmptyObject(rowInfoObject) ? rowInfoObject : null
],
}; };
} }

104
src/case/pager/pager.detail.js

@ -1,3 +1,21 @@
import {
HorizontalLayout,
shortcut,
Widget,
extend,
emptyFn,
result,
debounce,
isKey,
createWidget,
createItems,
Controller,
Events,
MIN,
MAX
} from "@/core";
import { Label, ButtonGroup } from "@/base";
/** /**
* 分页控件 * 分页控件
* *
@ -6,7 +24,6 @@
* @extends BI.Widget * @extends BI.Widget
*/ */
import { shortcut, Widget, extend, emptyFn, result, debounce, isKey, createWidget, createItems, Controller, Events, MIN, MAX } from "@/core";
@shortcut() @shortcut()
export class DetailPager extends Widget { export class DetailPager extends Widget {
static xtype = "bi.detail_pager"; static xtype = "bi.detail_pager";
@ -16,9 +33,11 @@ export class DetailPager extends Widget {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
baseCls: "bi-detail-pager", baseCls: "bi-detail-pager",
behaviors: {}, behaviors: {},
layouts: [{ layouts: [
type: "bi.horizontal", {
}], type: HorizontalLayout.xtype,
}
],
dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
// dynamicShow为false时以下两个有用 // dynamicShow为false时以下两个有用
@ -37,7 +56,8 @@ export class DetailPager extends Widget {
next: "下一页", next: "下一页",
firstPage: 1, firstPage: 1,
lastPage () { // 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法 lastPage() {
// 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法
return 1; return 1;
}, },
hasPrev: emptyFn, // pages不可用时有效 hasPrev: emptyFn, // pages不可用时有效
@ -55,8 +75,11 @@ export class DetailPager extends Widget {
this._populate(); this._populate();
} }
_populate() { _populate() {
const o = this.options, view = [], dict = {}; const o = this.options,
const { dynamicShow, dynamicShowPrevNext, hasPrev, dynamicShowFirstLast, hasNext, behaviors, layouts, jump } = this.options; view = [],
dict = {};
const { dynamicShow, dynamicShowPrevNext, hasPrev, dynamicShowFirstLast, hasNext, behaviors, layouts, jump } =
this.options;
this.empty(); this.empty();
const pages = result(o, "pages"); const pages = result(o, "pages");
const curr = result(this, "currPage"); const curr = result(this, "currPage");
@ -75,7 +98,7 @@ export class DetailPager extends Widget {
} }
// 计算当前组 // 计算当前组
dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups)); dict.index = Math.ceil((curr + (groups > 1 && groups !== pages ? 1 : 0)) / (groups === 0 ? 1 : groups));
// 当前页非首页,则输出上一页 // 当前页非首页,则输出上一页
if (((!dynamicShow && !dynamicShowPrevNext) || curr > 1) && prev !== false) { if (((!dynamicShow && !dynamicShowPrevNext) || curr > 1) && prev !== false) {
@ -86,9 +109,14 @@ export class DetailPager extends Widget {
disabled: pages === false ? hasPrev(curr) === false : !(curr > 1 && prev !== false), disabled: pages === false ? hasPrev(curr) === false : !(curr > 1 && prev !== false),
}); });
} else { } else {
view.push(extend({ view.push(
extend(
{
disabled: pages === false ? hasPrev(curr) === false : !(curr > 1 && prev !== false), disabled: pages === false ? hasPrev(curr) === false : !(curr > 1 && prev !== false),
}, prev)); },
prev
)
);
} }
} }
@ -101,7 +129,7 @@ export class DetailPager extends Widget {
}); });
if (dict.index > 1 && groups !== 0) { if (dict.index > 1 && groups !== 0) {
view.push({ view.push({
type: "bi.label", type: Label.xtype,
cls: "page-ellipsis", cls: "page-ellipsis",
text: "\u2026", text: "\u2026",
}); });
@ -111,16 +139,21 @@ export class DetailPager extends Widget {
// 输出当前页组 // 输出当前页组
dict.poor = Math.floor((groups - 1) / 2); dict.poor = Math.floor((groups - 1) / 2);
dict.start = dict.index > 1 ? curr - dict.poor : 1; dict.start = dict.index > 1 ? curr - dict.poor : 1;
dict.end = dict.index > 1 ? (function () { dict.end =
dict.index > 1
? (function () {
const max = curr + (groups - dict.poor - 1); const max = curr + (groups - dict.poor - 1);
return max > pages ? pages : max; return max > pages ? pages : max;
}()) : groups; }())
if (dict.end - dict.start < groups - 1) { // 最后一组状态 : groups;
if (dict.end - dict.start < groups - 1) {
// 最后一组状态
dict.start = dict.end - groups + 1; dict.start = dict.end - groups + 1;
} }
let s = dict.start, e = dict.end; let s = dict.start,
if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) { e = dict.end;
if (first && last && dict.index > 1 && groups !== 0 && pages > groups && dict.end < pages && groups !== 0) {
s++; s++;
e--; e--;
} }
@ -143,7 +176,7 @@ export class DetailPager extends Widget {
if (((!dynamicShow && !dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { if (((!dynamicShow && !dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) {
if (pages > groups && dict.end < pages && groups !== 0) { if (pages > groups && dict.end < pages && groups !== 0) {
view.push({ view.push({
type: "bi.label", type: Label.xtype,
cls: "page-ellipsis", cls: "page-ellipsis",
text: "\u2026", text: "\u2026",
}); });
@ -157,28 +190,32 @@ export class DetailPager extends Widget {
// 当前页不为尾页时,输出下一页 // 当前页不为尾页时,输出下一页
dict.flow = !prev && groups === 0; dict.flow = !prev && groups === 0;
if (((!dynamicShow && !dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) { if ((!dynamicShow && !dynamicShowPrevNext && next) || (curr !== pages && next) || dict.flow) {
view.push((function () { view.push(
(function () {
if (isKey(next)) { if (isKey(next)) {
if (pages === false) { if (pages === false) {
return { text: next, value: "next", disabled: hasNext(curr) === false }; return { text: next, value: "next", disabled: hasNext(curr) === false };
} }
return (dict.flow && curr === pages) return dict.flow && curr === pages
? ? { text: next, value: "next", disabled: true }
{ text: next, value: "next", disabled: true } : { text: next, value: "next", disabled: !((curr !== pages && next) || dict.flow) };
:
{ text: next, value: "next", disabled: !(curr !== pages && next || dict.flow) };
} }
return extend({ return extend(
disabled: pages === false ? hasNext(curr) === false : !(curr !== pages && next || dict.flow), {
}, next); disabled:
}())); pages === false ? hasNext(curr) === false : !((curr !== pages && next) || dict.flow),
},
next
);
})()
);
} }
this.button_group = createWidget({ this.button_group = createWidget({
type: "bi.button_group", type: ButtonGroup.xtype,
element: this, element: this,
items: createItems(view, { items: createItems(view, {
cls: "page-item bi-border bi-list-item-active", cls: "page-item bi-border bi-list-item-active",
@ -212,10 +249,12 @@ export class DetailPager extends Widget {
this.currPage = v; this.currPage = v;
break; break;
} }
jump.apply(this, [{ jump.apply(this, [
{
pages, pages,
curr: this.currPage, curr: this.currPage,
}]); }
]);
this._populate(); this._populate();
this.fireEvent(DetailPager.EVENT_CHANGE, obj); this.fireEvent(DetailPager.EVENT_CHANGE, obj);
} }
@ -257,7 +296,8 @@ export class DetailPager extends Widget {
if (pages === false) { if (pages === false) {
const lastPage = result(o, "lastPage"); const lastPage = result(o, "lastPage");
let firstPage = 1; let firstPage = 1;
this.currPage = v > lastPage ? lastPage : ((firstPage = result(o, "firstPage")), (v < firstPage ? firstPage : v)); this.currPage =
v > lastPage ? lastPage : ((firstPage = result(o, "firstPage")), v < firstPage ? firstPage : v);
} else { } else {
v = v > pages ? pages : v; v = v > pages ? pages : v;
this.currPage = v; this.currPage = v;

57
src/case/pager/pager.direction.js

@ -1,3 +1,6 @@
import { AbsoluteLayout, HorizontalLayout, shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { Label, Pager, IconButton } from "@/base";
/** /**
* 显示页码的分页控件 * 显示页码的分页控件
* *
@ -6,8 +9,6 @@
* @extends BI.Widget * @extends BI.Widget
*/ */
import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core";
import { Pager } from "@/base";
@shortcut() @shortcut()
export class DirectionPager extends Widget { export class DirectionPager extends Widget {
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -42,33 +43,38 @@ export class DirectionPager extends Widget {
this._createVPager(); this._createVPager();
this._createHPager(); this._createHPager();
this.layout = createWidget({ this.layout = createWidget({
type: "bi.absolute", type: AbsoluteLayout.xtype,
scrollable: false, scrollable: false,
element: this, element: this,
items: [{ items: [
{
el: this.vpager, el: this.vpager,
top: 0, top: 0,
right: 86, right: 86,
}, { },
{
el: this.vlabel, el: this.vlabel,
top: 0, top: 0,
right: 110, right: 110,
}, { },
{
el: this.hpager, el: this.hpager,
top: 0, top: 0,
right: 0, right: 0,
}, { },
{
el: this.hlabel, el: this.hlabel,
top: 0, top: 0,
right: 24, right: 24,
}], }
],
}); });
} }
_createVPager() { _createVPager() {
const v = this.options.vertical; const v = this.options.vertical;
this.vlabel = createWidget({ this.vlabel = createWidget({
type: "bi.label", type: Label.xtype,
width: 24, width: 24,
height: 24, height: 24,
value: v.curr, value: v.curr,
@ -76,13 +82,15 @@ export class DirectionPager extends Widget {
invisible: true, invisible: true,
}); });
this.vpager = createWidget({ this.vpager = createWidget({
type: "bi.pager", type: Pager.xtype,
width: 72, width: 72,
layouts: [{ layouts: [
type: "bi.horizontal", {
type: HorizontalLayout.xtype,
scrollx: false, scrollx: false,
rgap: 24, rgap: 24,
}], }
],
invisible: true, invisible: true,
dynamicShow: false, dynamicShow: false,
@ -93,7 +101,7 @@ export class DirectionPager extends Widget {
first: false, first: false,
last: false, last: false,
prev: { prev: {
type: "bi.icon_button", type: IconButton.xtype,
value: "prev", value: "prev",
title: BI.i18nText("BI-Up_Page"), title: BI.i18nText("BI-Up_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
@ -102,7 +110,7 @@ export class DirectionPager extends Widget {
cls: "bi-border bi-border-radius direction-pager-prev column-pre-page-h-font bi-list-item-select2", cls: "bi-border bi-border-radius direction-pager-prev column-pre-page-h-font bi-list-item-select2",
}, },
next: { next: {
type: "bi.icon_button", type: IconButton.xtype,
value: "next", value: "next",
title: BI.i18nText("BI-Down_Page"), title: BI.i18nText("BI-Down_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
@ -128,7 +136,7 @@ export class DirectionPager extends Widget {
_createHPager() { _createHPager() {
const h = this.options.horizontal; const h = this.options.horizontal;
this.hlabel = createWidget({ this.hlabel = createWidget({
type: "bi.label", type: Label.xtype,
width: 24, width: 24,
height: 24, height: 24,
value: h.curr, value: h.curr,
@ -136,13 +144,15 @@ export class DirectionPager extends Widget {
invisible: true, invisible: true,
}); });
this.hpager = createWidget({ this.hpager = createWidget({
type: "bi.pager", type: Pager.xtype,
width: 72, width: 72,
layouts: [{ layouts: [
type: "bi.horizontal", {
type: HorizontalLayout.xtype,
scrollx: false, scrollx: false,
rgap: 24, rgap: 24,
}], }
],
invisible: true, invisible: true,
dynamicShow: false, dynamicShow: false,
@ -153,7 +163,7 @@ export class DirectionPager extends Widget {
first: false, first: false,
last: false, last: false,
prev: { prev: {
type: "bi.icon_button", type: IconButton.xtype,
value: "prev", value: "prev",
title: BI.i18nText("BI-Left_Page"), title: BI.i18nText("BI-Left_Page"),
warningTitle: BI.i18nText("BI-Current_Is_First_Page"), warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
@ -162,7 +172,7 @@ export class DirectionPager extends Widget {
cls: "bi-border bi-border-radius direction-pager-prev row-pre-page-h-font bi-list-item-select2", cls: "bi-border bi-border-radius direction-pager-prev row-pre-page-h-font bi-list-item-select2",
}, },
next: { next: {
type: "bi.icon_button", type: IconButton.xtype,
value: "next", value: "next",
title: BI.i18nText("BI-Right_Page"), title: BI.i18nText("BI-Right_Page"),
warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
@ -235,7 +245,8 @@ export class DirectionPager extends Widget {
populate() { populate() {
this.vpager.populate(); this.vpager.populate();
this.hpager.populate(); this.hpager.populate();
let vShow = false, hShow = false; let vShow = false,
hShow = false;
if (!this.hasHNext() && !this.hasHPrev()) { if (!this.hasHNext() && !this.hasHPrev()) {
this.setHPagerVisible(false); this.setHPagerVisible(false);
} else { } else {

6
src/case/segment/button.segment.js

@ -1,5 +1,5 @@
import { Label, BasicButton } from "@/base";
import { shortcut, extend, createWidget } from "@/core"; import { shortcut, extend, createWidget } from "@/core";
import { BasicButton } from "@/base";
/** /**
* 分段控件使用的button * 分段控件使用的button
@ -10,7 +10,7 @@ import { BasicButton } from "@/base";
*/ */
@shortcut() @shortcut()
export class SegmentButton extends BasicButton { export class SegmentButton extends BasicButton {
static xtype = "bi.segment_button" static xtype = "bi.segment_button";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -27,7 +27,7 @@ export class SegmentButton extends BasicButton {
super._init(...arguments); super._init(...arguments);
const opts = this.options; const opts = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
element: this, element: this,
textHeight: opts.height, textHeight: opts.height,
whiteSpace: opts.whiteSpace, whiteSpace: opts.whiteSpace,

43
src/case/segment/segment.js

@ -1,5 +1,16 @@
import { shortcut, Widget, extend, toPix, Controller, createWidget, createItems, makeArrayByArray } from "@/core";
import { ButtonGroup } from "@/base"; import { ButtonGroup } from "@/base";
import { SegmentButton } from "./button.segment";
import {
TableLayout,
shortcut,
Widget,
extend,
toPix,
Controller,
createWidget,
createItems,
makeArrayByArray
} from "@/core";
/** /**
* 单选按钮组 * 单选按钮组
@ -10,9 +21,9 @@ import { ButtonGroup } from "@/base";
*/ */
@shortcut() @shortcut()
export class Segment extends Widget { export class Segment extends Widget {
static xtype = "bi.segment" static xtype = "bi.segment";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -27,17 +38,21 @@ export class Segment extends Widget {
const o = this.options; const o = this.options;
this.buttonGroup = createWidget({ this.buttonGroup = createWidget({
element: this, element: this,
type: "bi.button_group", type: ButtonGroup.xtype,
value: o.value, value: o.value,
items: [createItems(o.items, { items: [
type: "bi.segment_button", createItems(o.items, {
type: SegmentButton.xtype,
height: toPix(o.height, 2), height: toPix(o.height, 2),
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
})], })
layouts: [{ ],
type: "bi.table", layouts: [
{
type: TableLayout.xtype,
columnSize: makeArrayByArray(o.items, "fill"), columnSize: makeArrayByArray(o.items, "fill"),
}], }
],
}); });
this.buttonGroup.on(Controller.EVENT_CHANGE, (...args) => { this.buttonGroup.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
@ -70,10 +85,12 @@ export class Segment extends Widget {
populate(buttons) { populate(buttons) {
const o = this.options; const o = this.options;
this.buttonGroup.populate([createItems(buttons, { this.buttonGroup.populate([
type: "bi.segment_button", createItems(buttons, {
type: SegmentButton.xtype,
height: toPix(o.height, 2), height: toPix(o.height, 2),
whiteSpace: o.whiteSpace, whiteSpace: o.whiteSpace,
})]); })
]);
} }
} }

37
src/case/toolbar/toolbar.multiselect.js

@ -1,6 +1,16 @@
import { shortcut, extend, emptyFn, i18nText, Controller, createWidget, Events } from "@/core"; import { Checkbox, Label, BasicButton } from "@/base";
import { BasicButton, Checkbox } from "@/base";
import { HalfIconButton } from "../button"; import { HalfIconButton } from "../button";
import {
HTapeLayout,
CenterAdaptLayout,
shortcut,
extend,
emptyFn,
i18nText,
Controller,
createWidget,
Events
} from "@/core";
/** /**
* guy * guy
@ -11,9 +21,9 @@ import { HalfIconButton } from "../button";
*/ */
@shortcut() @shortcut()
export class MultiSelectBar extends BasicButton { export class MultiSelectBar extends BasicButton {
static xtype = "bi.multi_select_bar" static xtype = "bi.multi_select_bar";
static EVENT_CHANGE = "EVENT_CHANGE" static EVENT_CHANGE = "EVENT_CHANGE";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -39,7 +49,7 @@ export class MultiSelectBar extends BasicButton {
const isSelect = o.selected === true; const isSelect = o.selected === true;
const isHalfSelect = !o.selected && o.halfSelected; const isHalfSelect = !o.selected && o.halfSelected;
this.checkbox = createWidget({ this.checkbox = createWidget({
type: "bi.checkbox", type: Checkbox.xtype,
stopPropagation: true, stopPropagation: true,
handler: () => { handler: () => {
this.setSelected(this.isSelected()); this.setSelected(this.isSelected());
@ -50,7 +60,7 @@ export class MultiSelectBar extends BasicButton {
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
}); });
this.half = createWidget({ this.half = createWidget({
type: "bi.half_icon_button", type: HalfIconButton.xtype,
stopPropagation: true, stopPropagation: true,
handler: () => { handler: () => {
this.setSelected(true); this.setSelected(true);
@ -72,7 +82,7 @@ export class MultiSelectBar extends BasicButton {
this.fireEvent(MultiSelectBar.EVENT_CHANGE, this.isSelected(), this); this.fireEvent(MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
}); });
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
textAlign: "left", textAlign: "left",
whiteSpace: "nowrap", whiteSpace: "nowrap",
textHeight: o.height, textHeight: o.height,
@ -84,17 +94,20 @@ export class MultiSelectBar extends BasicButton {
py: o.py, py: o.py,
}); });
createWidget({ createWidget({
type: "bi.htape", type: HTapeLayout.xtype,
element: this, element: this,
items: [{ items: [
{
width: o.iconWrapperWidth, width: o.iconWrapperWidth,
el: { el: {
type: "bi.center_adapt", type: CenterAdaptLayout.xtype,
items: [this.checkbox, this.half], items: [this.checkbox, this.half],
}, },
}, { },
{
el: this.text, el: this.text,
}], }
],
}); });
} }

24
src/case/tree/tree.level.js

@ -9,11 +9,14 @@ import {
isNotEmptyArray, isNotEmptyArray,
Tree, Tree,
createWidget, createWidget,
VerticalLayout, Controller, Events VerticalLayout,
Controller,
Events
} from "@/core"; } from "@/core";
import { ButtonTree, CustomTree } from "@/base"; import { ButtonTree, CustomTree } from "@/base";
import { TreeExpander } from "./treeexpander/tree.expander"; import { TreeExpander } from "./treeexpander/tree.expander";
import { BasicTreeItem, BasicTreeNode } from "@/case"; import { BasicTreeItem } from "@/case/button/treeitem/treeitem";
import { BasicTreeNode } from "@/case/button/node/treenode";
@shortcut() @shortcut()
export class LevelTree extends Widget { export class LevelTree extends Widget {
@ -74,13 +77,15 @@ export class LevelTree extends Widget {
} }
initTree(nodes) { initTree(nodes) {
const self = this, o = this.options; const self = this,
o = this.options;
this.empty(); this.empty();
this._assertId(nodes); this._assertId(nodes);
this.tree = createWidget({ this.tree = createWidget({
type: CustomTree.xtype, type: CustomTree.xtype,
element: this, element: this,
expander: extend({ expander: extend(
{
type: TreeExpander.xtype, type: TreeExpander.xtype,
el: {}, el: {},
isDefaultInit: false, isDefaultInit: false,
@ -88,11 +93,14 @@ export class LevelTree extends Widget {
popup: { popup: {
type: CustomTree.xtype, type: CustomTree.xtype,
}, },
}, o.expander), },
o.expander
),
items: this._formatItems(Tree.transformToTreeFormat(nodes), 0), items: this._formatItems(Tree.transformToTreeFormat(nodes), 0),
value: o.value, value: o.value,
el: extend({ el: extend(
{
type: ButtonTree.xtype, type: ButtonTree.xtype,
chooseType: 0, chooseType: 0,
layouts: [ layouts: [
@ -100,7 +108,9 @@ export class LevelTree extends Widget {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
} }
], ],
}, o.el), },
o.el
),
}); });
this.tree.on(Controller.EVENT_CHANGE, function (type, value, ob) { this.tree.on(Controller.EVENT_CHANGE, function (type, value, ob) {
self.fireEvent(Controller.EVENT_CHANGE, arguments); self.fireEvent(Controller.EVENT_CHANGE, arguments);

13
src/case/tree/treeexpander/tree.expander.popup.js

@ -19,10 +19,13 @@ export class TreeExpanderPopup extends Widget {
const { el, value, layer, showLine, isLastNode } = this.options; const { el, value, layer, showLine, isLastNode } = this.options;
const offset = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2; const offset = BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT / 2;
this.popupView = createWidget({ this.popupView = createWidget(
{
...el, ...el,
value, value,
}, this); },
this
);
this.popupView.on(Controller.EVENT_CHANGE, function () { this.popupView.on(Controller.EVENT_CHANGE, function () {
self.fireEvent(Controller.EVENT_CHANGE, arguments); self.fireEvent(Controller.EVENT_CHANGE, arguments);
@ -35,11 +38,9 @@ export class TreeExpanderPopup extends Widget {
return { return {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
cls: (showLine && !isLastNode) ? (BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "", cls: showLine && !isLastNode ? (BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "line solid" : "line") : "",
scrolly: null, scrolly: null,
items: [ items: [this.popupView],
this.popupView
],
}; };
} }

18
src/case/trigger/trigger.editor.js

@ -1,6 +1,7 @@
import { shortcut, extend, emptyFn, createWidget, toPix, Controller } from "@/core";
import { Trigger } from "@/base";
import { SignEditor } from "../editor"; import { SignEditor } from "../editor";
import { HorizontalFillLayout, shortcut, extend, emptyFn, createWidget, toPix, Controller } from "@/core";
import { TriggerIconButton } from "../button";
import { Trigger } from "@/base";
/** /**
* 文本输入框trigger * 文本输入框trigger
@ -22,7 +23,9 @@ export class EditorTrigger extends Trigger {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
return extend(conf, { return extend(conf, {
baseCls: `${conf.baseCls || ""} bi-editor-trigger bi-border-radius ${config.simple ? "bi-border-bottom" : "bi-border"}`, baseCls: `${conf.baseCls || ""} bi-editor-trigger bi-border-radius ${
config.simple ? "bi-border-bottom" : "bi-border"
}`,
height: 24, height: 24,
validationChecker: emptyFn, validationChecker: emptyFn,
quitChecker: emptyFn, quitChecker: emptyFn,
@ -36,7 +39,7 @@ export class EditorTrigger extends Trigger {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.editor = createWidget({ this.editor = createWidget({
type: "bi.sign_editor", type: SignEditor.xtype,
height: toPix(o.height, 2), height: toPix(o.height, 2),
value: o.value, value: o.value,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
@ -67,15 +70,16 @@ export class EditorTrigger extends Trigger {
createWidget({ createWidget({
element: this, element: this,
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
height: toPix(o.height, 2), height: toPix(o.height, 2),
items: [ items: [
{ {
el: this.editor, el: this.editor,
width: "fill", width: "fill",
}, { },
{
el: { el: {
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
width: o.triggerWidth || toPix(o.height, 2), width: o.triggerWidth || toPix(o.height, 2),
}, },
width: "", width: "",

5
src/case/trigger/trigger.icon.js

@ -1,3 +1,4 @@
import { TriggerIconButton } from "../button";
import { shortcut, extend, createWidget } from "@/core"; import { shortcut, extend, createWidget } from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
@ -10,7 +11,7 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class IconTrigger extends Trigger { export class IconTrigger extends Trigger {
static xtype = "bi.icon_trigger" static xtype = "bi.icon_trigger";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -25,7 +26,7 @@ export class IconTrigger extends Trigger {
const o = this.options; const o = this.options;
super._init(...arguments); super._init(...arguments);
this.iconButton = createWidget(o.el, { this.iconButton = createWidget(o.el, {
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,

29
src/case/trigger/trigger.icon.text.js

@ -1,5 +1,6 @@
import { shortcut, extend, isKey, createWidget, isEmptyString } from "@/core"; import { Label, Trigger } from "@/base";
import { Trigger } from "@/base"; import { TriggerIconButton, IconChangeButton } from "../button";
import { HorizontalFillLayout, shortcut, extend, isKey, createWidget, isEmptyString } from "@/core";
/** /**
* 文字trigger * 文字trigger
@ -10,7 +11,7 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class IconTextTrigger extends Trigger { export class IconTextTrigger extends Trigger {
static xtype = "bi.icon_text_trigger" static xtype = "bi.icon_text_trigger";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -28,8 +29,8 @@ export class IconTextTrigger extends Trigger {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
cls: `select-text-label${isKey(o.textCls) ? (` ${o.textCls}`) : ""}`, cls: `select-text-label${isKey(o.textCls) ? ` ${o.textCls}` : ""}`,
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
hgap: o.textHgap, hgap: o.textHgap,
@ -41,20 +42,21 @@ export class IconTextTrigger extends Trigger {
text: o.text, text: o.text,
}); });
this.trigerButton = createWidget({ this.trigerButton = createWidget({
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
}); });
createWidget({ createWidget({
element: this, element: this,
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["", "fill", ""], columnSize: ["", "fill", ""],
ref: _ref => { ref: _ref => {
this.wrapper = _ref; this.wrapper = _ref;
}, },
items: [{ items: [
{
el: { el: {
type: "bi.icon_change_button", type: IconChangeButton.xtype,
cls: "icon-combo-trigger-icon", cls: "icon-combo-trigger-icon",
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
iconCls: o.iconCls, iconCls: o.iconCls,
@ -66,12 +68,15 @@ export class IconTextTrigger extends Trigger {
iconWidth: o.iconWidth, iconWidth: o.iconWidth,
disableSelected: true, disableSelected: true,
}, },
}, { },
{
el: this.text, el: this.text,
lgap: isEmptyString(o.iconCls) ? 5 : 0, lgap: isEmptyString(o.iconCls) ? 5 : 0,
}, { },
{
el: this.trigerButton, el: this.trigerButton,
}], }
],
}); });
} }

5
src/case/trigger/trigger.icon.text.select.js

@ -1,3 +1,4 @@
import { IconTextTrigger } from "./trigger.icon.text";
import { shortcut, extend, createWidget, isFunction, isArray, isNotNull, any, deepContains, Tree } from "@/core"; import { shortcut, extend, createWidget, isFunction, isArray, isNotNull, any, deepContains, Tree } from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
@ -6,7 +7,7 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class SelectIconTextTrigger extends Trigger { export class SelectIconTextTrigger extends Trigger {
static xtype = "bi.select_icon_text_trigger" static xtype = "bi.select_icon_text_trigger";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -23,7 +24,7 @@ export class SelectIconTextTrigger extends Trigger {
const o = this.options; const o = this.options;
const obj = this._digist(o.value, o.items); const obj = this._digist(o.value, o.items);
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.icon_text_trigger", type: IconTextTrigger.xtype,
element: this, element: this,
text: obj.text, text: obj.text,
textCls: obj.textCls, textCls: obj.textCls,

51
src/case/trigger/trigger.text.js

@ -1,5 +1,6 @@
import { shortcut, isFunction, isKey, isNotEmptyString } from "@/core"; import { Label, IconButton, Trigger } from "@/base";
import { Trigger } from "@/base"; import { TriggerIconButton } from "../button";
import { HorizontalFillLayout, VerticalAdaptLayout, shortcut, isFunction, isKey, isNotEmptyString } from "@/core";
/** /**
* 文字trigger * 文字trigger
@ -10,9 +11,9 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class TextTrigger extends Trigger { export class TextTrigger extends Trigger {
static xtype = "bi.text_trigger" static xtype = "bi.text_trigger";
static EVENT_CLEAR = "EVENT_CLEAR" static EVENT_CLEAR = "EVENT_CLEAR";
props() { props() {
return { return {
@ -35,11 +36,13 @@ export class TextTrigger extends Trigger {
const defaultText = this.getDefaultText(); const defaultText = this.getDefaultText();
const label = { const label = {
type: "bi.label", type: Label.xtype,
ref: _ref => { ref: _ref => {
this.text = _ref; this.text = _ref;
}, },
cls: `select-text-label ${o.textCls} ${!isNotEmptyString(text) && isNotEmptyString(defaultText) ? "bi-tips" : ""}`, cls: `select-text-label ${o.textCls} ${
!isNotEmptyString(text) && isNotEmptyString(defaultText) ? "bi-tips" : ""
}`,
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: text || o.defaultText, text: text || o.defaultText,
@ -55,29 +58,33 @@ export class TextTrigger extends Trigger {
}; };
const triggerButton = { const triggerButton = {
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
ref: _ref => { ref: _ref => {
this.triggerButton = _ref; this.triggerButton = _ref;
}, },
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
}; };
return ({ return {
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
columnSize: ["fill", ""], columnSize: ["fill", ""],
items: [{ items: [
{
el: label, el: label,
width: "fill", width: "fill",
}, { },
el: o.allowClear ? { {
type: "bi.vertical_adapt", el: o.allowClear
? {
type: VerticalAdaptLayout.xtype,
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
height: o.height, height: o.height,
horizontalAlign: "left", horizontalAlign: "left",
scrollable: false, scrollable: false,
items: [{ items: [
{
el: { el: {
type: "bi.icon_button", type: IconButton.xtype,
ref: _ref => { ref: _ref => {
this.clearBtn = _ref; this.clearBtn = _ref;
}, },
@ -89,12 +96,16 @@ export class TextTrigger extends Trigger {
this.fireEvent(TextTrigger.EVENT_CLEAR); this.fireEvent(TextTrigger.EVENT_CLEAR);
}, },
}, },
}, { },
{
el: triggerButton, el: triggerButton,
}], }
} : triggerButton, ],
}], }
}); : triggerButton,
}
],
};
} }
getText() { getText() {

14
src/case/trigger/trigger.text.select.js

@ -1,6 +1,6 @@
import { TextTrigger } from "./trigger.text";
import { shortcut, extend, emptyFn, createWidget, isFunction, isArray, Tree, each, contains, remove } from "@/core"; import { shortcut, extend, emptyFn, createWidget, isFunction, isArray, Tree, each, contains, remove } from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
import { TextTrigger } from "./trigger.text";
/** /**
* 选择字段trigger * 选择字段trigger
@ -11,9 +11,9 @@ import { TextTrigger } from "./trigger.text";
*/ */
@shortcut() @shortcut()
export class SelectTextTrigger extends Trigger { export class SelectTextTrigger extends Trigger {
static xtype = "bi.select_text_trigger" static xtype = "bi.select_text_trigger";
static EVENT_CLEAR = "EVENT_CLEAR" static EVENT_CLEAR = "EVENT_CLEAR";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -30,7 +30,7 @@ export class SelectTextTrigger extends Trigger {
const o = this.options; const o = this.options;
const text = this._digest(o.value, o.items); const text = this._digest(o.value, o.items);
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.text_trigger", type: TextTrigger.xtype,
element: this, element: this,
height: o.height, height: o.height,
readonly: o.readonly, readonly: o.readonly,
@ -45,13 +45,15 @@ export class SelectTextTrigger extends Trigger {
tipType: o.tipType, tipType: o.tipType,
title: null, title: null,
allowClear: o.allowClear, allowClear: o.allowClear,
listeners: [{ listeners: [
{
eventName: TextTrigger.EVENT_CLEAR, eventName: TextTrigger.EVENT_CLEAR,
action: () => { action: () => {
this.setText(""); this.setText("");
this.fireEvent(SelectTextTrigger.EVENT_CLEAR); this.fireEvent(SelectTextTrigger.EVENT_CLEAR);
}, },
}], },
],
}); });
} }

5
src/case/trigger/trigger.text.select.small.js

@ -1,3 +1,4 @@
import { SmallTextTrigger } from "./trigger.text.small";
import { shortcut, extend, toPix, createWidget, isArray, deepContains, each, contains, Tree } from "@/core"; import { shortcut, extend, toPix, createWidget, isArray, deepContains, each, contains, Tree } from "@/core";
import { Trigger } from "@/base"; import { Trigger } from "@/base";
@ -9,7 +10,7 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class SmallSelectTextTrigger extends Trigger { export class SmallSelectTextTrigger extends Trigger {
static xtype = "bi.small_select_text_trigger" static xtype = "bi.small_select_text_trigger";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -23,7 +24,7 @@ export class SmallSelectTextTrigger extends Trigger {
const o = this.options; const o = this.options;
const obj = this._digest(o.value, o.items); const obj = this._digest(o.value, o.items);
this.trigger = createWidget({ this.trigger = createWidget({
type: "bi.small_text_trigger", type: SmallTextTrigger.xtype,
element: this, element: this,
height: toPix(o.height, 2), height: toPix(o.height, 2),
text: obj.text, text: obj.text,

22
src/case/trigger/trigger.text.small.js

@ -1,5 +1,6 @@
import { shortcut, extend, createWidget } from "@/core"; import { Label, Trigger } from "@/base";
import { Trigger } from "@/base"; import { TriggerIconButton } from "../button";
import { HorizontalFillLayout, shortcut, extend, createWidget } from "@/core";
/** /**
* 文字trigger(右边小三角小一号的) == * 文字trigger(右边小三角小一号的) ==
@ -9,7 +10,7 @@ import { Trigger } from "@/base";
*/ */
@shortcut() @shortcut()
export class SmallTextTrigger extends Trigger { export class SmallTextTrigger extends Trigger {
static xtype = "bi.small_text_trigger" static xtype = "bi.small_text_trigger";
_defaultConfig() { _defaultConfig() {
const conf = super._defaultConfig(...arguments); const conf = super._defaultConfig(...arguments);
@ -25,7 +26,7 @@ export class SmallTextTrigger extends Trigger {
super._init(...arguments); super._init(...arguments);
const o = this.options; const o = this.options;
this.text = createWidget({ this.text = createWidget({
type: "bi.label", type: Label.xtype,
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
@ -37,20 +38,23 @@ export class SmallTextTrigger extends Trigger {
bgap: o.textBgap, bgap: o.textBgap,
}); });
this.trigerButton = createWidget({ this.trigerButton = createWidget({
type: "bi.trigger_icon_button", type: TriggerIconButton.xtype,
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
}); });
createWidget({ createWidget({
element: this, element: this,
type: "bi.horizontal_fill", type: HorizontalFillLayout.xtype,
items: [{ items: [
{
el: this.text, el: this.text,
width: "fill", width: "fill",
}, { },
{
el: this.trigerButton, el: this.trigerButton,
width: "", width: "",
}], }
],
}); });
} }

14
src/case/ztree/asynctree.js

@ -162,14 +162,15 @@ export class Asynctree extends TreeView {
// 展开节点 // 展开节点
_beforeExpandNode(treeId, treeNode) { _beforeExpandNode(treeId, treeNode) {
const self = this, o = this.options; const self = this,
o = this.options;
function complete(d) { function complete(d) {
const nodes = d.items || []; const nodes = d.items || [];
if (nodes.length > 0) { if (nodes.length > 0) {
callback(self._dealWidthNodes(nodes), !!d.hasNext); callback(self._dealWidthNodes(nodes), !!d.hasNext);
} }
}; }
function callback(nodes, hasNext) { function callback(nodes, hasNext) {
self.nodes.addNodes(treeNode, nodes); self.nodes.addNodes(treeNode, nodes);
@ -184,12 +185,17 @@ export class Asynctree extends TreeView {
// console.log(times); // console.log(times);
options = options || {}; options = options || {};
const parentValues = treeNode.parentValues || self._getParentValues(treeNode); const parentValues = treeNode.parentValues || self._getParentValues(treeNode);
const op = extend({}, o.paras, { const op = extend(
{},
o.paras,
{
id: treeNode.id, id: treeNode.id,
times: options.times, times: options.times,
parentValues: parentValues.concat(self._getNodeValue(treeNode)), parentValues: parentValues.concat(self._getNodeValue(treeNode)),
checkState: treeNode.getCheckStatus(), checkState: treeNode.getCheckStatus(),
}, options); },
options
);
o.itemsCreator(op, complete); o.itemsCreator(op, complete);
} }

529
src/case/ztree/jquery.ztree.core-3.5.js

File diff suppressed because it is too large Load Diff

196
src/case/ztree/jquery.ztree.excheck-3.5.js

@ -15,10 +15,10 @@
//default consts of excheck //default consts of excheck
var _consts = { var _consts = {
event: { event: {
CHECK: "ztree_check" CHECK: "ztree_check",
}, },
id: { id: {
CHECK: "_check" CHECK: "_check",
}, },
checkbox: { checkbox: {
STYLE: "checkbox", STYLE: "checkbox",
@ -28,13 +28,13 @@
TRUE: "true", TRUE: "true",
FULL: "full", FULL: "full",
PART: "part", PART: "part",
FOCUS: "focus" FOCUS: "focus",
}, },
radio: { radio: {
STYLE: "radio", STYLE: "radio",
TYPE_ALL: "all", TYPE_ALL: "all",
TYPE_LEVEL: "level" TYPE_LEVEL: "level",
} },
}, },
//default setting of excheck //default setting of excheck
_setting = { _setting = {
@ -46,19 +46,19 @@
chkDisabledInherit: false, chkDisabledInherit: false,
radioType: _consts.radio.TYPE_LEVEL, radioType: _consts.radio.TYPE_LEVEL,
chkboxType: { chkboxType: {
"Y": "ps", Y: "ps",
"N": "ps" N: "ps",
} },
}, },
data: { data: {
key: { key: {
checked: "checked" checked: "checked",
} },
}, },
callback: { callback: {
beforeCheck: null, beforeCheck: null,
onCheck: null onCheck: null,
} },
}, },
//default root of excheck //default root of excheck
_initRoot = function (setting) { _initRoot = function (setting) {
@ -66,8 +66,7 @@
r.radioCheckedList = []; r.radioCheckedList = [];
}, },
//default cache of excheck //default cache of excheck
_initCache = function (treeId) { _initCache = function (treeId) {},
},
//default bind event of excheck //default bind event of excheck
_bindEvent = function (setting) { _bindEvent = function (setting) {
var o = setting.treeObj, var o = setting.treeObj,
@ -86,22 +85,37 @@
_eventProxy = function (e) { _eventProxy = function (e) {
var target = e.target, var target = e.target,
setting = data.getSetting(e.data.treeId), setting = data.getSetting(e.data.treeId),
tId = "", node = null, tId = "",
nodeEventType = "", treeEventType = "", node = null,
nodeEventCallback = null, treeEventCallback = null; nodeEventType = "",
treeEventType = "",
nodeEventCallback = null,
treeEventCallback = null;
if (tools.eqs(e.type, "mouseover")) { if (tools.eqs(e.type, "mouseover")) {
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { if (
setting.check.enable &&
tools.eqs(target.tagName, "span") &&
target.getAttribute("treeNode" + consts.id.CHECK) !== null
) {
tId = tools.getNodeMainDom(target).id; tId = tools.getNodeMainDom(target).id;
nodeEventType = "mouseoverCheck"; nodeEventType = "mouseoverCheck";
} }
} else if (tools.eqs(e.type, "mouseout")) { } else if (tools.eqs(e.type, "mouseout")) {
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { if (
setting.check.enable &&
tools.eqs(target.tagName, "span") &&
target.getAttribute("treeNode" + consts.id.CHECK) !== null
) {
tId = tools.getNodeMainDom(target).id; tId = tools.getNodeMainDom(target).id;
nodeEventType = "mouseoutCheck"; nodeEventType = "mouseoutCheck";
} }
} else if (tools.eqs(e.type, "click")) { } else if (tools.eqs(e.type, "click")) {
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { if (
setting.check.enable &&
tools.eqs(target.tagName, "span") &&
target.getAttribute("treeNode" + consts.id.CHECK) !== null
) {
tId = tools.getNodeMainDom(target).id; tId = tools.getNodeMainDom(target).id;
nodeEventType = "checkNode"; nodeEventType = "checkNode";
} }
@ -126,7 +140,7 @@
nodeEventType: nodeEventType, nodeEventType: nodeEventType,
nodeEventCallback: nodeEventCallback, nodeEventCallback: nodeEventCallback,
treeEventType: treeEventType, treeEventType: treeEventType,
treeEventCallback: treeEventCallback treeEventCallback: treeEventCallback,
}; };
return proxyResult; return proxyResult;
}, },
@ -140,7 +154,8 @@
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); n.chkDisabled =
!!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
n.halfCheck = !!n.halfCheck; n.halfCheck = !!n.halfCheck;
n.check_Child_State = -1; n.check_Child_State = -1;
@ -149,7 +164,11 @@
return data.getCheckStatus(setting, n); return data.getCheckStatus(setting, n);
}; };
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey]) { if (
setting.check.chkStyle == consts.radio.STYLE &&
setting.check.radioType == consts.radio.TYPE_ALL &&
n[checkedKey]
) {
var r = data.getRoot(setting); var r = data.getRoot(setting);
r.radioCheckedList.push(n); r.radioCheckedList.push(n);
} }
@ -159,7 +178,17 @@
var checkedKey = setting.data.key.checked; var checkedKey = setting.data.key.checked;
if (setting.check.enable) { if (setting.check.enable) {
data.makeChkFlag(setting, node); data.makeChkFlag(setting, node);
html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true ? " style='display:none;'" : ""), "></span>"); html.push(
"<span ID='",
node.tId,
consts.id.CHECK,
"' class='",
view.makeChkClass(setting, node),
"' treeNode",
consts.id.CHECK,
node.nocheck === true ? " style='display:none;'" : "",
"></span>"
);
} }
}, },
//update zTreeObj, add method of check //update zTreeObj, add method of check
@ -174,13 +203,17 @@
if (node[checkedKey] === checked && !checkTypeFlag) { if (node[checkedKey] === checked && !checkTypeFlag) {
return; return;
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { } else if (
callbackFlag &&
tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false
) {
return; return;
} }
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
node[checkedKey] = checked; node[checkedKey] = checked;
var checkObj = $$(node, consts.id.CHECK, this.setting); var checkObj = $$(node, consts.id.CHECK, this.setting);
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE)
view.checkNodeRelation(this.setting, node);
view.setChkClass(this.setting, checkObj, node); view.setChkClass(this.setting, checkObj, node);
view.repairParentChkClassWithSelf(this.setting, node); view.repairParentChkClassWithSelf(this.setting, node);
if (callbackFlag) { if (callbackFlag) {
@ -195,7 +228,7 @@
zTreeTools.getCheckedNodes = function (checked) { zTreeTools.getCheckedNodes = function (checked) {
var childKey = this.setting.data.key.children; var childKey = this.setting.data.key.children;
checked = (checked !== false); checked = checked !== false;
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked); return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
}; };
@ -219,7 +252,8 @@
var nObj = $$(node, this.setting); var nObj = $$(node, this.setting);
if (nObj.get(0) && tools.uCanDo(this.setting)) { if (nObj.get(0) && tools.uCanDo(this.setting)) {
var checkObj = $$(node, consts.id.CHECK, this.setting); var checkObj = $$(node, consts.id.CHECK, this.setting);
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE)
view.checkNodeRelation(this.setting, node);
view.setChkClass(this.setting, checkObj, node); view.setChkClass(this.setting, checkObj, node);
view.repairParentChkClassWithSelf(this.setting, node); view.repairParentChkClassWithSelf(this.setting, node);
} }
@ -243,7 +277,13 @@
var checkedKey = setting.data.key.checked, var checkedKey = setting.data.key.checked,
r = { r = {
checked: node[checkedKey], checked: node[checkedKey],
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) half: node.halfCheck
? node.halfCheck
: setting.check.chkStyle == consts.radio.STYLE
? node.check_Child_State === 2
: node[checkedKey]
? node.check_Child_State > -1 && node.check_Child_State < 2
: node.check_Child_State > 0,
}; };
return r; return r;
}, },
@ -251,7 +291,10 @@
if (!nodes) return []; if (!nodes) return [];
var childKey = setting.data.key.children, var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked, checkedKey = setting.data.key.checked,
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); onlyOne =
checked &&
setting.check.chkStyle == consts.radio.STYLE &&
setting.check.radioType == consts.radio.TYPE_ALL;
results = !results ? [] : results; results = !results ? [] : results;
for (var i = 0, l = nodes.length; i < l; i++) { for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
@ -273,7 +316,11 @@
checkedKey = setting.data.key.checked; checkedKey = setting.data.key.checked;
results = !results ? [] : results; results = !results ? [] : results;
for (var i = 0, l = nodes.length; i < l; i++) { for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { if (
nodes[i].nocheck !== true &&
nodes[i].chkDisabled !== true &&
nodes[i][checkedKey] != nodes[i].checkedOld
) {
results.push(nodes[i]); results.push(nodes[i]);
} }
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
@ -311,9 +358,9 @@
} else if (cNode.halfCheck === true) { } else if (cNode.halfCheck === true) {
tmp = 1; tmp = 1;
} else if (cNode[checkedKey]) { } else if (cNode[checkedKey]) {
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; tmp = cNode.check_Child_State === -1 || cNode.check_Child_State === 2 ? 2 : 1;
} else { } else {
tmp = (cNode.check_Child_State > 0) ? 1 : 0; tmp = cNode.check_Child_State > 0 ? 1 : 0;
} }
if (tmp === 1) { if (tmp === 1) {
chkFlag = 1; chkFlag = 1;
@ -331,7 +378,7 @@
} }
} }
node.check_Child_State = chkFlag; node.check_Child_State = chkFlag;
} },
}, },
//method of event proxy //method of event proxy
_event = {}, _event = {},
@ -365,14 +412,16 @@
node.check_Focus = false; node.check_Focus = false;
view.setChkClass(setting, checkObj, node); view.setChkClass(setting, checkObj, node);
return true; return true;
} },
}, },
//method of tools for zTree //method of tools for zTree
_tools = {}, _tools = {},
//method of operate ztree dom //method of operate ztree dom
_view = { _view = {
checkNodeRelation: function (setting, node) { checkNodeRelation: function (setting, node) {
var pNode, i, l, var pNode,
i,
l,
childKey = setting.data.key.children, childKey = setting.data.key.children,
checkedKey = setting.data.key.checked, checkedKey = setting.data.key.checked,
r = consts.radio; r = consts.radio;
@ -394,7 +443,7 @@
} }
checkedList.push(node); checkedList.push(node);
} else { } else {
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); var parentNode = node.parentTId ? node.getParentNode() : data.getRoot(setting);
for (i = 0, l = parentNode[childKey].length; i < l; i++) { for (i = 0, l = parentNode[childKey].length; i < l; i++) {
pNode = parentNode[childKey][i]; pNode = parentNode[childKey][i];
if (pNode[checkedKey] && pNode != node) { if (pNode[checkedKey] && pNode != node) {
@ -411,12 +460,17 @@
} }
} }
} }
} else { } else {
if (node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { if (
node[checkedKey] &&
(!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)
) {
view.setSonNodeCheckBox(setting, node, true); view.setSonNodeCheckBox(setting, node, true);
} }
if (!node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)) { if (
!node[checkedKey] &&
(!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)
) {
view.setSonNodeCheckBox(setting, node, false); view.setSonNodeCheckBox(setting, node, false);
} }
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
@ -429,35 +483,42 @@
}, },
makeChkClass: function (setting, node) { makeChkClass: function (setting, node) {
var checkedKey = setting.data.key.checked, var checkedKey = setting.data.key.checked,
c = consts.checkbox, r = consts.radio, c = consts.checkbox,
r = consts.radio,
checkboxType = setting.check.chkboxType; checkboxType = setting.check.chkboxType;
var notEffectByOtherNode = (checkboxType.Y === "" && checkboxType.N === ""); var notEffectByOtherNode = checkboxType.Y === "" && checkboxType.N === "";
fullStyle = ""; fullStyle = "";
if (node.chkDisabled === true) { if (node.chkDisabled === true) {
fullStyle = c.DISABLED; fullStyle = c.DISABLED;
} else if (node.halfCheck) { } else if (node.halfCheck) {
fullStyle = c.PART; fullStyle = c.PART;
} else if (setting.check.chkStyle == r.STYLE) { } else if (setting.check.chkStyle == r.STYLE) {
fullStyle = (node.check_Child_State < 1) ? c.FULL : c.PART; fullStyle = node.check_Child_State < 1 ? c.FULL : c.PART;
} else { } else {
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) || notEffectByOtherNode ? c.FULL : c.PART) : ((node.check_Child_State < 1 || notEffectByOtherNode) ? c.FULL : c.PART); fullStyle = node[checkedKey]
? node.check_Child_State === 2 || node.check_Child_State === -1 || notEffectByOtherNode
? c.FULL
: c.PART
: node.check_Child_State < 1 || notEffectByOtherNode
? c.FULL
: c.PART;
} }
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; chkName = node.check_Focus && node.chkDisabled !== true ? chkName + "_" + c.FOCUS : chkName;
var chClass = consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; var chClass = consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
switch (chkName) { switch (chkName) {
case 'checkbox_true_part': case "checkbox_true_part":
case 'checkbox_true_part_focus': case "checkbox_true_part_focus":
chClass += ' bi-half-button bi-high-light-border'; chClass += " bi-half-button bi-high-light-border";
break; break;
case 'checkbox_true_full': case "checkbox_true_full":
case 'checkbox_true_full_focus': case "checkbox_true_full_focus":
chClass += ' bi-checkbox checkbox-content bi-high-light-background active'; chClass += " bi-checkbox checkbox-content bi-high-light-background active";
break; break;
case 'checkbox_false_full': case "checkbox_false_full":
case 'checkbox_false_full_focus': case "checkbox_false_full_focus":
default: default:
chClass += ' bi-checkbox checkbox-content'; chClass += " bi-checkbox checkbox-content";
break; break;
} }
return chClass + (node.disabled ? " disabled" : ""); return chClass + (node.disabled ? " disabled" : "");
@ -528,7 +589,7 @@
} else { } else {
obj.show(); obj.show();
} }
obj.attr('class', view.makeChkClass(setting, node)); obj.attr("class", view.makeChkClass(setting, node));
}, },
setParentNodeCheckBox: function (setting, node, value, srcNode) { setParentNodeCheckBox: function (setting, node, value, srcNode) {
var childKey = setting.data.key.children, var childKey = setting.data.key.children,
@ -548,8 +609,13 @@
if (!value) { if (!value) {
var pNodes = node.getParentNode()[childKey]; var pNodes = node.getParentNode()[childKey];
for (var i = 0, l = pNodes.length; i < l; i++) { for (var i = 0, l = pNodes.length; i < l; i++) {
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) if (
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { (pNodes[i].nocheck !== true &&
pNodes[i].chkDisabled !== true &&
pNodes[i][checkedKey]) ||
((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) &&
pNodes[i].check_Child_State > 0)
) {
pSign = false; pSign = false;
break; break;
} }
@ -582,24 +648,28 @@
} }
if (node.nocheck !== true && node.chkDisabled !== true) { if (node.nocheck !== true && node.chkDisabled !== true) {
node[checkedKey] = value; node[checkedKey] = value;
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; if (!hasDisable)
node.check_Child_State = node[childKey] && node[childKey].length > 0 ? (value ? 2 : 0) : -1;
} else { } else {
node.check_Child_State = -1; node.check_Child_State = -1;
} }
view.setChkClass(setting, checkObj, node); view.setChkClass(setting, checkObj, node);
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { if (
setting.check.autoCheckTrigger &&
node != srcNode &&
node.nocheck !== true &&
node.chkDisabled !== true
) {
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
} }
} }
}
}, },
},
_z = { _z = {
tools: _tools, tools: _tools,
view: _view, view: _view,
event: _event, event: _event,
data: _data data: _data,
}; };
$.extend(true, $.fn.zTree.consts, _consts); $.extend(true, $.fn.zTree.consts, _consts);
$.extend(true, $.fn.zTree._z, _z); $.extend(true, $.fn.zTree._z, _z);

12
src/case/ztree/list/listasynctree.js

@ -1,3 +1,6 @@
import { Listtreeview } from "./listtreeview";
import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core";
/** /**
* author: windy * author: windy
* 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点 * 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点
@ -6,9 +9,6 @@
* @extends TreeView * @extends TreeView
*/ */
import { Listtreeview } from "./listtreeview";
import { cjkEncodeDO, delay, isEmpty, shortcut, extend } from "@/core";
@shortcut() @shortcut()
export class Listasynctree extends Listtreeview { export class Listasynctree extends Listtreeview {
static xtype = "bi.list_async_tree"; static xtype = "bi.list_async_tree";
@ -72,7 +72,8 @@ export class Listasynctree extends Listtreeview {
// 展开节点 // 展开节点
_beforeExpandNode(treeId, treeNode) { _beforeExpandNode(treeId, treeNode) {
const self = this, o = this.options; const self = this,
o = this.options;
const parentValues = treeNode.parentValues || self._getParentValues(treeNode); const parentValues = treeNode.parentValues || self._getParentValues(treeNode);
const op = extend({}, o.paras, { const op = extend({}, o.paras, {
id: treeNode.id, id: treeNode.id,
@ -85,7 +86,7 @@ export class Listasynctree extends Listtreeview {
if (nodes.length > 0) { if (nodes.length > 0) {
callback(self._dealWidthNodes(nodes), !!d.hasNext); callback(self._dealWidthNodes(nodes), !!d.hasNext);
} }
}; }
let times = 1; let times = 1;
function callback(nodes, hasNext) { function callback(nodes, hasNext) {
@ -119,4 +120,3 @@ export class Listasynctree extends Listtreeview {
this._initTree(setting); this._initTree(setting);
} }
} }

21
src/case/ztree/list/listparttree.js

@ -1,3 +1,7 @@
import { Listasynctree } from "./listasynctree";
import { shortcut, extend, Events, delay } from "@/core";
import { TreeView } from "../treeview";
/** /**
* guy * guy
* 局部树两个请求树 第一个请求构造树第二个请求获取节点 * 局部树两个请求树 第一个请求构造树第二个请求获取节点
@ -5,24 +9,21 @@
* @extends Asynctree * @extends Asynctree
*/ */
import { Listasynctree } from "./listasynctree";
import { shortcut, extend, Events, delay } from "@/core";
import { TreeView } from "../treeview";
@shortcut() @shortcut()
export class ListPartTree extends Listasynctree { export class ListPartTree extends Listasynctree {
static xtype = "bi.list_part_tree"; static xtype = "bi.list_part_tree";
_loadMore() { _loadMore() {
const self = this, o = this.options; const self = this,
o = this.options;
const op = extend({}, o.paras, { const op = extend({}, o.paras, {
type: TreeView.REQ_TYPE_INIT_DATA, type: TreeView.REQ_TYPE_INIT_DATA,
times: ++this.times, times: ++this.times,
}); });
this.tip.setLoading(); this.tip.setLoading();
o.itemsCreator(op, d => { o.itemsCreator(op, d => {
const hasNext = !!d.hasNext, nodes = d.items || []; const hasNext = !!d.hasNext,
nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue; o.paras.lastSearchValue = d.lastSearchValue;
if (self._stop === true) { if (self._stop === true) {
return; return;
@ -39,7 +40,8 @@ export class ListPartTree extends Listasynctree {
} }
_initTree(setting, keyword) { _initTree(setting, keyword) {
const self = this, o = this.options; const self = this,
o = this.options;
this.times = 1; this.times = 1;
const tree = this.tree; const tree = this.tree;
tree.empty(); tree.empty();
@ -54,7 +56,8 @@ export class ListPartTree extends Listasynctree {
if (self._stop === true || keyword !== o.paras.keyword) { if (self._stop === true || keyword !== o.paras.keyword) {
return; return;
} }
const hasNext = !!d.hasNext, nodes = d.items || []; const hasNext = !!d.hasNext,
nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue; o.paras.lastSearchValue = d.lastSearchValue;
// 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的 // 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的
callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []); callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []);

6
src/case/ztree/list/listtreeview.js

@ -1,3 +1,6 @@
import { TreeView } from "../treeview";
import { extend, isNotNull, concat, each, shortcut } from "@/core";
/** /**
* author: windy * author: windy
* 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点 * 继承自treeView, 此树的父子节点的勾选状态互不影响, 此树不会有半选节点
@ -6,9 +9,6 @@
* @extends BI.TreeView * @extends BI.TreeView
*/ */
import { TreeView } from "../treeview";
import { extend, isNotNull, concat, each, shortcut } from "@/core";
@shortcut() @shortcut()
export class Listtreeview extends TreeView { export class Listtreeview extends TreeView {
static xtype = "bi.list_tree_view"; static xtype = "bi.list_tree_view";

40
src/case/ztree/parttree.js

@ -1,12 +1,13 @@
import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core";
import { Asynctree } from "./asynctree";
import { TreeView } from "./treeview";
/** /**
* guy * guy
* 局部树两个请求树 第一个请求构造树第二个请求获取节点 * 局部树两个请求树 第一个请求构造树第二个请求获取节点
* @class BI.PartTree * @class BI.PartTree
* @extends BI.AsyncTree * @extends BI.AsyncTree
*/ */
import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core";
import { Asynctree } from "./asynctree";
import { TreeView } from "./treeview";
@shortcut() @shortcut()
export class PartTree extends Asynctree { export class PartTree extends Asynctree {
@ -20,14 +21,16 @@ export class PartTree extends Asynctree {
} }
_loadMore() { _loadMore() {
const self = this, o = this.options; const self = this,
o = this.options;
const op = extend({}, o.paras, { const op = extend({}, o.paras, {
type: TreeView.REQ_TYPE_INIT_DATA, type: TreeView.REQ_TYPE_INIT_DATA,
times: ++this.times, times: ++this.times,
}); });
this.tip.setLoading(); this.tip.setLoading();
o.itemsCreator(op, d => { o.itemsCreator(op, d => {
const hasNext = !!d.hasNext, nodes = d.items || []; const hasNext = !!d.hasNext,
nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue; o.paras.lastSearchValue = d.lastSearchValue;
if (self._stop === true) { if (self._stop === true) {
return; return;
@ -44,7 +47,8 @@ export class PartTree extends Asynctree {
} }
_selectTreeNode(...args) { _selectTreeNode(...args) {
const self = this, o = this.options; const self = this,
o = this.options;
const [treeId, treeNode] = args; const [treeId, treeNode] = args;
const parentValues = deepClone(treeNode.parentValues || self._getParentValues(treeNode)); const parentValues = deepClone(treeNode.parentValues || self._getParentValues(treeNode));
const name = this._getNodeValue(treeNode); const name = this._getNodeValue(treeNode);
@ -52,14 +56,17 @@ export class PartTree extends Asynctree {
if (treeNode.checked === true) { if (treeNode.checked === true) {
this.options.paras.selectedValues = this._getUnionValue(); this.options.paras.selectedValues = this._getUnionValue();
// this._buildTree(self.options.paras.selectedValues, concat(parentValues, name)); // this._buildTree(self.options.paras.selectedValues, concat(parentValues, name));
o.itemsCreator(extend({}, o.paras, { o.itemsCreator(
extend({}, o.paras, {
type: TreeView.REQ_TYPE_ADJUST_DATA, type: TreeView.REQ_TYPE_ADJUST_DATA,
curSelectedValue: name, curSelectedValue: name,
parentValues, parentValues,
}), function (res) { }),
function (res) {
self.options.paras.selectedValues = res; self.options.paras.selectedValues = res;
this.seMethos(...args); this.seMethos(...args);
}); }
);
} else { } else {
// 如果选中的值中不存在该值不处理 // 如果选中的值中不存在该值不处理
// 因为反正是不选中,没必要管 // 因为反正是不选中,没必要管
@ -75,14 +82,17 @@ export class PartTree extends Asynctree {
break; break;
} }
} }
o.itemsCreator(extend({}, o.paras, { o.itemsCreator(
extend({}, o.paras, {
type: TreeView.REQ_TYPE_SELECT_DATA, type: TreeView.REQ_TYPE_SELECT_DATA,
notSelectedValue: name, notSelectedValue: name,
parentValues, parentValues,
}), new_values => { }),
new_values => {
self.options.paras.selectedValues = new_values; self.options.paras.selectedValues = new_values;
this.seMethos(...args); this.seMethos(...args);
}); }
);
} }
} }
@ -120,7 +130,8 @@ export class PartTree extends Asynctree {
} }
_initTree(setting, keyword) { _initTree(setting, keyword) {
const self = this, o = this.options; const self = this,
o = this.options;
this.times = 1; this.times = 1;
const tree = this.tree; const tree = this.tree;
tree.empty(); tree.empty();
@ -135,7 +146,8 @@ export class PartTree extends Asynctree {
if (self._stop === true || keyword !== o.paras.keyword) { if (self._stop === true || keyword !== o.paras.keyword) {
return; return;
} }
const hasNext = !!d.hasNext, nodes = d.items || []; const hasNext = !!d.hasNext,
nodes = d.items || [];
o.paras.lastSearchValue = d.lastSearchValue; o.paras.lastSearchValue = d.lastSearchValue;
// 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的 // 没有请求到数据也要初始化空树, 如果不初始化, 树就是上一次构造的树, 节点信息都是过期的
callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []); callback(nodes.length > 0 ? self._dealWidthNodes(nodes) : []);

10
src/case/ztree/tree.display.js

@ -1,3 +1,6 @@
import { extend } from "@/core";
import { TreeView } from "./treeview";
/** /**
* guy * guy
* 异步树 * 异步树
@ -5,9 +8,6 @@
* @extends BI.TreeView * @extends BI.TreeView
*/ */
import { extend } from "@/core";
import { TreeView } from "./treeview";
export class DisplayTree extends TreeView { export class DisplayTree extends TreeView {
static xtype = "bi.display_tree"; static xtype = "bi.display_tree";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
@ -53,7 +53,9 @@ export class DisplayTree extends TreeView {
node.isParent = node.isParent || node.parent; node.isParent = node.isParent || node.parent;
if (node.text == null) { if (node.text == null) {
if (node.count > 0) { if (node.count > 0) {
node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText("BI-Basic_Count")})`; node.text = `${node.value}(${BI.i18nText("BI-Basic_Altogether")}${node.count}${BI.i18nText(
"BI-Basic_Count"
)})`;
} }
} }
}); });

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save