diff --git a/package.json b/package.json index 5289f3a76..992970812 100644 --- a/package.json +++ b/package.json @@ -41,17 +41,17 @@ "less-loader": "^11.1.0", "mini-css-extract-plugin": "^2.7.5", "npm-run-all": "^4.1.5", - "prettier": "^3.0.0", "postcss": "^8.4.21", "postcss-loader": "^7.1.0", + "prettier": "^3.0.0", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.3.7", "ts-node": "^10.9.1", "typescript": "^4.9.5", "webpack": "^5.75.0", "webpack-bundle-analyzer": "^4.8.0", - "webpack-cli": "^5.0.1", - "webpack-dev-server": "^4.11.1", - "webpack-merge": "^5.8.0" + "webpack-cli": "^5.1.4", + "webpack-dev-server": "^4.15.1", + "webpack-merge": "^5.9.0" } } diff --git a/packages/fineui/dist/font/iconfont.eot b/packages/fineui/dist/font/iconfont.eot index 6a0f685a2..73d30f4d0 100644 Binary files a/packages/fineui/dist/font/iconfont.eot and b/packages/fineui/dist/font/iconfont.eot differ diff --git a/packages/fineui/dist/font/iconfont.svg b/packages/fineui/dist/font/iconfont.svg index 32deecda8..584d0a98b 100644 --- a/packages/fineui/dist/font/iconfont.svg +++ b/packages/fineui/dist/font/iconfont.svg @@ -14,6 +14,18 @@ /> + + + + + + + + + + + + @@ -24,7 +36,7 @@ - + @@ -96,8 +108,6 @@ - - diff --git a/packages/fineui/dist/font/iconfont.ttf b/packages/fineui/dist/font/iconfont.ttf index 85e450f3a..e897d6818 100644 Binary files a/packages/fineui/dist/font/iconfont.ttf and b/packages/fineui/dist/font/iconfont.ttf differ diff --git a/packages/fineui/dist/font/iconfont.woff b/packages/fineui/dist/font/iconfont.woff index 9c12cac44..9e3f9e3c0 100644 Binary files a/packages/fineui/dist/font/iconfont.woff and b/packages/fineui/dist/font/iconfont.woff differ diff --git a/packages/fineui/dist/font/iconfont.woff2 b/packages/fineui/dist/font/iconfont.woff2 index 497bc683b..0416823ae 100644 Binary files a/packages/fineui/dist/font/iconfont.woff2 and b/packages/fineui/dist/font/iconfont.woff2 differ diff --git a/packages/fineui/package.json b/packages/fineui/package.json index 5feec08ae..0bd7ddf2e 100644 --- a/packages/fineui/package.json +++ b/packages/fineui/package.json @@ -28,7 +28,9 @@ "prepublishToPrivate": "npm run build && node ./lib/prepublish.js", "publishToPrivate": "npm publish", "tsc": "tsc", - "link": "pnpm link --global" + "link": "pnpm link --global", + "build:biCss": "cross-env LESS_CONFIG_PATH=bi.lessconfig.json LESS_FILE_NAME=bi npm run webpack:css", + "build:jsyCss": "cross-env LESS_CONFIG_PATH=jsy.lessconfig.json LESS_FILE_NAME=jsy npm run webpack:css" }, "files": [ "dist", diff --git a/packages/fineui/src/base/combination/group.virtual.js b/packages/fineui/src/base/combination/group.virtual.js index 5b7cd7e32..b7e8ce938 100644 --- a/packages/fineui/src/base/combination/group.virtual.js +++ b/packages/fineui/src/base/combination/group.virtual.js @@ -56,7 +56,7 @@ export class VirtualGroup extends Widget { _packageBtns(items) { const o = this.options; - const map = (this.buttonMap = {}); + const btMap = (this.buttonMap = {}); const layouts = isArray(o.layouts) ? o.layouts : [o.layouts]; for (let i = layouts.length - 1; i > 0; i--) { items = map(items, (k, it) => { @@ -68,8 +68,8 @@ export class VirtualGroup extends Widget { el: extend( { ref: _ref => { - if (isKey(map[el.value])) { - map[el.value] = _ref; + if (isKey(btMap[el.value])) { + btMap[el.value] = _ref; } }, }, diff --git a/packages/fineui/src/base/combination/loader.js b/packages/fineui/src/base/combination/loader.js index 4706d4c2a..1d0711158 100644 --- a/packages/fineui/src/base/combination/loader.js +++ b/packages/fineui/src/base/combination/loader.js @@ -204,7 +204,7 @@ export class Loader extends Widget { { times: this.times, count: this.count, - } + }, this.options ]); } @@ -218,7 +218,7 @@ export class Loader extends Widget { { times: this.times, count: this.count, - } + }, this.options ]); } diff --git a/packages/fineui/src/base/tree/customtree.js b/packages/fineui/src/base/tree/customtree.js index 491fbc96b..349ae0912 100644 --- a/packages/fineui/src/base/tree/customtree.js +++ b/packages/fineui/src/base/tree/customtree.js @@ -105,6 +105,7 @@ export class CustomTree extends Widget { return itemsCreator.apply(this, args); }; isNull(item.popup.el) && (item.popup.el = deepClone(this.options.el)); + item.popup.el.node = item.el; items.push(item); } else { items.push(node); @@ -122,9 +123,8 @@ export class CustomTree extends Widget { itemsCreator: (op, callback) => { itemsCreator.apply(this, [ op, - items => { - const args = Array.prototype.slice.call(arguments, 0); - args[0] = this._formatItems(items); + (...args) => { + args[0] = this._formatItems(args[0]); callback(...args); } ]); diff --git a/packages/fineui/src/case/pager/pager.direction.js b/packages/fineui/src/case/pager/pager.direction.js index 53cc51b82..b07f6749c 100644 --- a/packages/fineui/src/case/pager/pager.direction.js +++ b/packages/fineui/src/case/pager/pager.direction.js @@ -40,6 +40,11 @@ export class DirectionPager extends Widget { } _init() { super._init(...arguments); + + this.ITEM_GAP = 0; + this.ITEM_WIDTH = this.options.height - 2 * this.ITEM_GAP; + this.MIDDLE_GAP = 16; + this._createVPager(); this._createHPager(); this.layout = createWidget({ @@ -49,23 +54,23 @@ export class DirectionPager extends Widget { items: [ { el: this.vpager, - top: 0, - right: 86, + top: this.ITEM_GAP, + right: this.ITEM_WIDTH * 3 + this.MIDDLE_GAP, }, { el: this.vlabel, - top: 0, - right: 110, + top: this.ITEM_GAP, + right: this.ITEM_WIDTH * 4 + this.MIDDLE_GAP, }, { el: this.hpager, - top: 0, + top: this.ITEM_GAP, right: 0, }, { el: this.hlabel, - top: 0, - right: 24, + top: this.ITEM_GAP, + right: this.ITEM_WIDTH, } ], }); @@ -75,20 +80,20 @@ export class DirectionPager extends Widget { const v = this.options.vertical; this.vlabel = createWidget({ type: Label.xtype, - width: 24, - height: 24, + width: this.ITEM_WIDTH, + height: this.ITEM_WIDTH, value: v.curr, title: v.curr, invisible: true, }); this.vpager = createWidget({ type: Pager.xtype, - width: 72, + width: this.ITEM_WIDTH * 3, layouts: [ { type: HorizontalLayout.xtype, scrollx: false, - rgap: 24, + rgap: this.ITEM_WIDTH, } ], invisible: true, @@ -105,8 +110,8 @@ export class DirectionPager extends Widget { value: "prev", title: i18nText("BI-Up_Page"), warningTitle: i18nText("BI-Current_Is_First_Page"), - height: 22, - width: 22, + height: this.ITEM_WIDTH - 2, + width: this.ITEM_WIDTH - 2, cls: "bi-border bi-border-radius direction-pager-prev column-pre-page-h-font bi-list-item-select2", }, next: { @@ -114,8 +119,8 @@ export class DirectionPager extends Widget { value: "next", title: i18nText("BI-Down_Page"), warningTitle: i18nText("BI-Current_Is_Last_Page"), - height: 22, - width: 22, + height: this.ITEM_WIDTH - 2, + width: this.ITEM_WIDTH - 2, cls: "bi-border bi-border-radius direction-pager-next column-next-page-h-font bi-list-item-select2", }, @@ -137,20 +142,20 @@ export class DirectionPager extends Widget { const h = this.options.horizontal; this.hlabel = createWidget({ type: Label.xtype, - width: 24, - height: 24, + width: this.ITEM_WIDTH, + height: this.ITEM_WIDTH, value: h.curr, title: h.curr, invisible: true, }); this.hpager = createWidget({ type: Pager.xtype, - width: 72, + width: this.ITEM_WIDTH * 3, layouts: [ { type: HorizontalLayout.xtype, scrollx: false, - rgap: 24, + rgap: this.ITEM_WIDTH, } ], invisible: true, @@ -167,8 +172,8 @@ export class DirectionPager extends Widget { value: "prev", title: i18nText("BI-Left_Page"), warningTitle: i18nText("BI-Current_Is_First_Page"), - height: 22, - width: 22, + height: this.ITEM_WIDTH - 2, + width: this.ITEM_WIDTH - 2, cls: "bi-border bi-border-radius direction-pager-prev row-pre-page-h-font bi-list-item-select2", }, next: { @@ -176,8 +181,8 @@ export class DirectionPager extends Widget { value: "next", title: i18nText("BI-Right_Page"), warningTitle: i18nText("BI-Current_Is_Last_Page"), - height: 22, - width: 22, + height: this.ITEM_WIDTH - 2, + width: this.ITEM_WIDTH - 2, cls: "bi-border bi-border-radius direction-pager-next row-next-page-h-font bi-list-item-select2", }, @@ -260,7 +265,7 @@ export class DirectionPager extends Widget { vShow = true; } this.setVisible(hShow || vShow); - const num = [86, 110, 0, 24]; + const num = [this.ITEM_WIDTH * 3 + this.MIDDLE_GAP, this.ITEM_WIDTH * 4 + this.MIDDLE_GAP, 0, this.ITEM_WIDTH]; const items = this.layout.attr("items"); if (vShow === true && hShow === true) { diff --git a/packages/fineui/src/core/5.inject.js b/packages/fineui/src/core/5.inject.js index 0246f2497..f9aeacd07 100644 --- a/packages/fineui/src/core/5.inject.js +++ b/packages/fineui/src/core/5.inject.js @@ -601,3 +601,12 @@ export function getResource(type, config) { } throw new Error("unknown type: [" + type + "] undefined"); } + +/** + * 根据 xtype 获取已被注册的类 + * @param {string} xtype + * @returns + */ +export function getClass(xtype) { + return kv[xtype] || serviceInjection[xtype]; +} \ No newline at end of file diff --git a/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js b/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js deleted file mode 100644 index d7fb59e75..000000000 --- a/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 用于 jquery 在 worker 环境或者 V8 引擎的 polyfill - */ -// import { _global } from "@/core/0.foundation"; - -const _global = globalThis; - -const document = {}; -const fakeElement = Object.create(document); - -Object.assign(document, { - parentNode: null, - nodeType: 9, - head: fakeElement, - body: fakeElement, - ownerDocument: document, - documentElement: document, - toString() { - return "FakeDocument"; - }, - appendChild(child) { - return child; - }, - implementation: { - createHTMLDocument() { - return { - body: { - childNodes: [], - }, - }; - }, - createDocumentFragment() { - return this; - }, - }, - getElementById() { - return fakeElement; - }, - createElement() { - return fakeElement; - }, - createDocumentFragment() { - return this; - }, - cloneNode() { - return this; - }, - getElementsByTagName() { - return [fakeElement]; - }, - getElementsByClassName() { - return [fakeElement]; - }, - setAttribute() { - return null; - }, - getAttribute() { - return null; - }, - removeChild() { - return null; - }, - addEventListener() { - return null; - }, - removeEventListener() { - return null; - }, -}); - -Object.assign(fakeElement, { - nodeType: 1, - style: {}, - ownerDocument: document, - parentNod: fakeElement, - firstChild: fakeElement, - lastChild: fakeElement, - toString() { - return "FakeElement"; - }, -}); - -function polyfillProps(key, obj) { - _global[key] = _global[key] || obj; - if (typeof obj === "object") { - try { - Object.assign(_global[key], obj); - } catch(err) { - // _global[key] 可能只有 get 方法 - } - } -} - -_global.window = _global; -polyfillProps("XMLHttpRequest", function () {}); -polyfillProps("document", document); diff --git a/packages/fineui/src/core/utils/color.js b/packages/fineui/src/core/utils/color.js index 718a9e74b..45bd4f1b7 100644 --- a/packages/fineui/src/core/utils/color.js +++ b/packages/fineui/src/core/utils/color.js @@ -42,7 +42,7 @@ export function getContrastColor(color) { return "#FFFFFF"; } - return "#3D4D66"; + return "#091e40"; } export function rgb2hex(rgbColour) { diff --git a/packages/fineui/src/core/utils/dom.js b/packages/fineui/src/core/utils/dom.js index fee24904f..df573a746 100644 --- a/packages/fineui/src/core/utils/dom.js +++ b/packages/fineui/src/core/utils/dom.js @@ -803,5 +803,6 @@ export function getOuterBody() { // body = parentWindow.document.body; // } catch (e) {} // return body; + return document.body; } diff --git a/packages/fineui/src/core/wrapper/layout/flex/flex.horizontal.js b/packages/fineui/src/core/wrapper/layout/flex/flex.horizontal.js index 7489d30a7..04801dd0e 100644 --- a/packages/fineui/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/packages/fineui/src/core/wrapper/layout/flex/flex.horizontal.js @@ -51,7 +51,7 @@ export class FlexHorizontalLayout extends Layout { if (o.columnSize.length > 0) { return o.columnSize.indexOf("fill") >= 0 || o.columnSize.indexOf("auto") >= 0; } - + return some(o.items, (i, item) => { if (item.width === "fill" || item.width === "auto") { return true; @@ -87,7 +87,7 @@ export class FlexHorizontalLayout extends Layout { } } if (columnSize > 0) { - w.element.width(this._optimiseGap(columnSize)); + w.element.css({ width: this._optimiseGap(columnSize) }); } if (columnSize === "fill") { w.element.addClass("f-f"); @@ -103,7 +103,7 @@ export class FlexHorizontalLayout extends Layout { w.element.addClass("l-c"); } this._handleGap(w, item, i); - + return w; } diff --git a/packages/fineui/src/router/router.js b/packages/fineui/src/router/router.js index f58c8402b..8f19a7591 100644 --- a/packages/fineui/src/router/router.js +++ b/packages/fineui/src/router/router.js @@ -1,4 +1,4 @@ -import { nextTick, shortcut, Widget, isNotNull, each } from '@/core'; +import {nextTick, shortcut, Widget, isNotNull, each, any, isEqual} from '@/core'; import { Tab } from '@/base'; import { Router } from './0.router'; import { Fix } from '../fix'; @@ -3134,6 +3134,14 @@ export class RouterView extends Widget { }; } + removeTab(path) { + this.tab.removeTab(path); + } + + setSelect(path) { + this.tab.setSelect(path); + } + destroyed() { // BI.remove方法会把第二个参数当迭代器执行导致方法多执行一遍 cbs.splice(cbs.indexOf(this._callbackListener), 1); diff --git a/packages/fineui/src/without_Jquery_Polyfill.js b/packages/fineui/src/without_Jquery_Polyfill.js new file mode 100644 index 000000000..369bc3a7f --- /dev/null +++ b/packages/fineui/src/without_Jquery_Polyfill.js @@ -0,0 +1,14 @@ +export * from './worker.js'; + +// "!src/base/single/input/file.js", +// "!src/case/ztree/**/*.js", +import * as _case from './case'; +import * as _widget from './widget'; +import { _global } from "@/core/0.foundation"; + +const fuiExport = { + ..._case, + ..._widget +}; + +Object.assign(_global.BI, fuiExport); diff --git a/packages/fineui/webpack/attachments.js b/packages/fineui/webpack/attachments.js index 7f4cfa185..afe2b8a04 100644 --- a/packages/fineui/webpack/attachments.js +++ b/packages/fineui/webpack/attachments.js @@ -1,6 +1,5 @@ const { sync, uniq } = require("./utils"); -const jqueryPolyfill = "./src/core/platform/web/jquery/jquery.polyfill.js"; const configJS = "./src/core/platform/web/config.js"; const runtimePolyfill = ["core-js/stable"]; @@ -8,7 +7,7 @@ const runtimePolyfill = ["core-js/stable"]; const basicAttachmentMap = { polyfill: sync(["src/polyfill/**/*.js"]).concat(runtimePolyfill), resource: sync(["src/less/resource/**/*.less"]), - font: sync(["public/less/font.less"]), + font: sync(["ui/less/font.less"]), ts: ["./typescript/bundle.ts"], ui: sync(["ui/less/app.less", "ui/less/**/*.less",]), less: sync([ @@ -21,6 +20,7 @@ const basicAttachmentMap = { ]), js_bundle: sync(["src/bundle.js"]), js_worker: sync(["src/worker.js"]), + js_without_Jquery_polyfill: sync(["src/without_Jquery_Polyfill.js"]), }; const bundleCss = uniq([].concat(basicAttachmentMap.less, basicAttachmentMap.ui, sync(["public/less/app.less", "public/less/**/*.less"]))); @@ -38,8 +38,17 @@ const fineuiForWorker = [].concat( basicAttachmentMap.ts ); +const fineuiWithout_Jquery_Polyfill = [].concat( + bundleCss, + basicAttachmentMap.polyfill, + basicAttachmentMap.js_bundle, + basicAttachmentMap.ts +); + module.exports = { fineui: uniq(fineui), fineuiForWorker: uniq(fineuiForWorker), + fineuiWithout_Jquery_Polyfill: uniq(fineuiWithout_Jquery_Polyfill), bundleCss, + font: uniq(basicAttachmentMap.font) }; diff --git a/packages/fineui/webpack/webpack.common.js b/packages/fineui/webpack/webpack.common.js index 530372b1a..1e7ce36b4 100644 --- a/packages/fineui/webpack/webpack.common.js +++ b/packages/fineui/webpack/webpack.common.js @@ -25,6 +25,8 @@ function git(command) { module.exports = { entry: { fineui: attachments.fineui, + "fineui.worker": attachments.fineuiForWorker, + "fineui_without_jquery_polyfill": attachments.fineuiWithout_Jquery_Polyfill, }, externals: { lodash: "_", diff --git a/packages/fineui/webpack/webpack.dev.js b/packages/fineui/webpack/webpack.dev.js index e858e890b..3b795e02d 100644 --- a/packages/fineui/webpack/webpack.dev.js +++ b/packages/fineui/webpack/webpack.dev.js @@ -16,5 +16,12 @@ module.exports = merge(common, { devServer: { port: 9001, // liveReload: true, + client: { + logging: 'error', + overlay: { + errors: true, + warnings: false, + }, + }, } }); diff --git a/packages/fineui/webpack/webpack.prod.js b/packages/fineui/webpack/webpack.prod.js index d1d7b9ffc..d012aeaef 100644 --- a/packages/fineui/webpack/webpack.prod.js +++ b/packages/fineui/webpack/webpack.prod.js @@ -1,24 +1,24 @@ -const common = require("./webpack.common.js"); -const { merge } = require("webpack-merge"); -const dirs = require("./dirs"); -const attachments = require("./attachments"); - -module.exports = merge(common, { - mode: "production", - target: ["web", "es5"], - - entry: { - "fineui.min": attachments.fineui, - "fineui.worker.min": attachments.fineuiForWorker, - "fineui.worker": attachments.fineuiForWorker, - "fineui_without_jquery_polyfill.min":attachments.fineuiForWorker, - }, - - output: { - path: dirs.DEST, - filename: "[name].js", - publicPath: "" - }, - - devtool: "hidden-source-map" -}); +const common = require("./webpack.common.js"); +const { merge } = require("webpack-merge"); +const dirs = require("./dirs"); +const attachments = require("./attachments"); + +module.exports = merge(common, { + mode: "production", + target: ["web", "es5"], + + entry: { + "fineui.min": attachments.fineui, + "fineui.worker.min": attachments.fineuiForWorker, + "fineui_without_jquery_polyfill.min": attachments.fineuiWithout_Jquery_Polyfill, + "font": attachments.font + }, + + output: { + path: dirs.DEST, + filename: "[name].js", + publicPath: "" + }, + + devtool: "hidden-source-map" +});