From dcf14ed0a042ec92adec62c8d364dd465341afe8 Mon Sep 17 00:00:00 2001 From: "Zhenfei.Li" Date: Tue, 17 Jan 2023 10:40:46 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-14124=20refactor:=20=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A5=BD=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/group.button.js | 31 +++--- src/base/index.js | 32 ++----- src/bundle.js | 4 + src/case/index.js | 40 +------- src/component/index.js | 32 +++---- src/core/5.inject.js | 2 + src/core/behavior/behavior.highlight.js | 2 +- src/core/behavior/behavior.redmark.js | 2 +- src/core/index.js | 71 ++++---------- .../responsive/responsive.flex.horizontal.js | 34 +++---- .../responsive.flex.wrapper.horizontal.js | 36 +++---- .../layout/responsive/responsive.inline.js | 32 +++---- src/index.js | 5 + src/widget/index.js | 94 +++---------------- webpack/attachments.js | 17 ++-- 15 files changed, 142 insertions(+), 292 deletions(-) create mode 100644 src/bundle.js create mode 100644 src/index.js diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 5dca70655..99437247c 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -1,4 +1,5 @@ import { + Selection, CenterLayout, shortcut, Widget, @@ -24,14 +25,16 @@ import { removeAt, deepContains, has, - any + any, + BehaviorFactory, + Events } from "@/core"; import { TextButton } from "../single"; /** * Created by GUY on 2015/6/26. - * @class BI.ButtonGroup - * @extends BI.Widget + * @class ButtonGroup + * @extends Widget */ @shortcut() @@ -39,6 +42,12 @@ export class ButtonGroup extends Widget { static xtype = "bi.button_group"; static EVENT_CHANGE = "EVENT_CHANGE"; + + static CHOOSE_TYPE_SINGLE = Selection.Single; + static CHOOSE_TYPE_MULTI = Selection.Multi; + static CHOOSE_TYPE_ALL = Selection.All; + static CHOOSE_TYPE_NONE = Selection.None; + static CHOOSE_TYPE_DEFAULT = Selection.Default; _defaultConfig() { return extend(super._defaultConfig(...arguments), { @@ -46,7 +55,7 @@ export class ButtonGroup extends Widget { behaviors: {}, items: [], value: "", - chooseType: BI.Selection.Single, + chooseType: Selection.Single, layouts: [ { type: CenterLayout.xtype, @@ -61,7 +70,7 @@ export class ButtonGroup extends Widget { const { behaviors: optionsBehaviors, items: optionsItems, value } = this.options; const behaviors = {}; each(optionsBehaviors, (key, rule) => { - behaviors[key] = BI.BehaviorFactory.createBehavior(key, { + behaviors[key] = BehaviorFactory.createBehavior(key, { rule, }); }); @@ -107,7 +116,7 @@ export class ButtonGroup extends Widget { each(buttons, (i, btn) => { btn.on(Controller.EVENT_CHANGE, (...arg) => { const [type, value, obj] = arg; - if (type === BI.Events.CLICK) { + if (type === Events.CLICK) { switch (chooseType) { case ButtonGroup.CHOOSE_TYPE_SINGLE: this.setValue(btn.getValue()); @@ -124,7 +133,7 @@ export class ButtonGroup extends Widget { this.fireEvent(Controller.EVENT_CHANGE, ...arg); } }); - btn.on(BI.Events.DESTROY, () => { + btn.on(Events.DESTROY, () => { remove(this.buttons, btn); }); }); @@ -418,11 +427,3 @@ export class ButtonGroup extends Widget { this.options.items = []; } } - -extend(ButtonGroup, { - CHOOSE_TYPE_SINGLE: BI.Selection.Single, - CHOOSE_TYPE_MULTI: BI.Selection.Multi, - CHOOSE_TYPE_ALL: BI.Selection.All, - CHOOSE_TYPE_NONE: BI.Selection.None, - CHOOSE_TYPE_DEFAULT: BI.Selection.Default, -}); diff --git a/src/base/index.js b/src/base/index.js index 1dc04c850..1edd6b127 100644 --- a/src/base/index.js +++ b/src/base/index.js @@ -1,32 +1,12 @@ -import { Pane } from "./1.pane"; -import * as single from "./single"; -import * as layer from "./layer"; -import * as list from "./list"; -import { GridView } from "./grid/grid"; -import { Pager } from "./pager/pager"; -import * as combination from "./combination"; -import { Msg } from "./foundation/message"; -import * as base from "./0.base"; -import { CollectionView } from "./collection/collection"; -import { CustomTree } from "./tree/customtree"; - -Object.assign(BI, { - Pane, - ...layer, - ...list, - ...single, - GridView, - Pager, - ...combination, - Msg, - ...base, - CollectionView, - CustomTree, -}); +export { Pane } from "./1.pane"; +export { GridView } from "./grid/grid"; +export { Pager } from "./pager/pager"; +export { Msg } from "./foundation/message"; +export { CollectionView } from "./collection/collection"; +export { CustomTree } from "./tree/customtree"; export * from "./0.base"; export * from "./combination"; export * from "./layer"; export * from "./list"; export * from "./single"; -export { Pane, GridView, Pager, Msg, CollectionView, CustomTree }; diff --git a/src/bundle.js b/src/bundle.js new file mode 100644 index 000000000..75b93152f --- /dev/null +++ b/src/bundle.js @@ -0,0 +1,4 @@ +import * as fineui from "./index"; +import { shortcut, provider } from "@/core/5.inject"; + +Object.assign(BI, fineui, { shortcut, provider }); diff --git a/src/case/index.js b/src/case/index.js index bc43a3dff..4e025e7de 100644 --- a/src/case/index.js +++ b/src/case/index.js @@ -1,36 +1,5 @@ -import * as button from "./button"; -import * as calendarItem from "./calendar"; -import * as pager from "./pager"; -import * as editor from "./editor"; -import * as tree from "./tree"; -import * as ztree from "./ztree"; -import * as trigger from "./trigger"; -import * as loader from "./loader"; -import * as segment from "./segment"; -import { MultiSelectBar } from "./toolbar/toolbar.multiselect"; -import * as layer from "./layer"; -import * as linearSegment from "./linearsegment"; -import * as colorchooser from "./colorchooser"; -import { SelectList } from "./list/list.select"; -import * as combo from "./combo"; - -Object.assign(BI, { - ...combo, - ...button, - ...calendarItem, - ...pager, - ...editor, - ...ztree, - ...tree, - ...trigger, - ...loader, - ...segment, - MultiSelectBar, - ...layer, - ...linearSegment, - ...colorchooser, - SelectList, -}); +export { MultiSelectBar } from "./toolbar/toolbar.multiselect"; +export { SelectList } from "./list/list.select"; export * from "./combo"; export * from "./button"; @@ -39,7 +8,6 @@ export * from "./pager"; export * from "./editor"; export * from "./tree"; export * from "./ztree"; - export * from "./trigger"; export * from "./loader"; export * from "./segment"; @@ -47,8 +15,4 @@ export * from "./layer"; export * from "./linearsegment"; export * from "./checkbox"; export * from "./colorchooser"; -export { - MultiSelectBar, - SelectList -}; diff --git a/src/component/index.js b/src/component/index.js index acd7babbc..6a57959bf 100644 --- a/src/component/index.js +++ b/src/component/index.js @@ -1,18 +1,18 @@ -import * as allvaluechooser from "./allvaluechooser"; -import * as form from "./form"; -import * as valueChooser from "./valuechooser"; -import { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; +export * as allvaluechooser from "./allvaluechooser"; +export * as form from "./form"; +export * as valueChooser from "./valuechooser"; +export { AllValueMultiTextValueCombo } from "./allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; -Object.assign(BI, { - ...allvaluechooser, - ...form, - ...valueChooser, - AllValueMultiTextValueCombo, -}); +// Object.assign(BI, { +// ...allvaluechooser, +// ...form, +// ...valueChooser, +// AllValueMultiTextValueCombo, +// }); -export * from "./allvaluechooser"; -export * from "./form"; -export * from "./valuechooser"; -export { - AllValueMultiTextValueCombo -}; +// export * from "./allvaluechooser"; +// export * from "./form"; +// export * from "./valuechooser"; +// export { +// AllValueMultiTextValueCombo +// }; diff --git a/src/core/5.inject.js b/src/core/5.inject.js index 8a54bbeb7..2b04a435f 100644 --- a/src/core/5.inject.js +++ b/src/core/5.inject.js @@ -401,6 +401,8 @@ export function shortcut(xtype, cls) { kv[xtype] = cls; } +export const component = shortcut; + // 根据配置属性生成widget const createRealWidget = (config, context, lazy) => { const Cls = isFunction(config.type) ? config.type : kv[config.type]; diff --git a/src/core/behavior/behavior.highlight.js b/src/core/behavior/behavior.highlight.js index f66355c65..2b10c012f 100644 --- a/src/core/behavior/behavior.highlight.js +++ b/src/core/behavior/behavior.highlight.js @@ -3,7 +3,7 @@ */ import { Behavior } from "./0.behavior"; import { isFunction, each } from "../2.base"; -import { Single } from "../../base"; +import { Single } from "@/base/single/0.single"; export class HighlightBehavior extends Behavior { doBehavior(items) { diff --git a/src/core/behavior/behavior.redmark.js b/src/core/behavior/behavior.redmark.js index 7ca2b9df2..1158757a7 100644 --- a/src/core/behavior/behavior.redmark.js +++ b/src/core/behavior/behavior.redmark.js @@ -4,7 +4,7 @@ */ import { Behavior } from "./0.behavior"; import { each } from "../2.base"; -import { Single } from "../../base"; +import { Single } from "@/base/single/0.single"; export class RedMarkBehavior extends Behavior { doBehavior(items) { diff --git a/src/core/index.js b/src/core/index.js index d3a64ffc7..89b01230c 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -1,32 +1,29 @@ -import * as base from "./2.base"; -import * as ob from "./3.ob"; -import * as widget from "./4.widget"; -import * as inject from "./5.inject"; -import { Plugin } from "./6.plugin"; -import * as h from "./h"; -import * as action from "./action"; -import * as behavior from "./behavior"; -import * as controllers from "./controller"; -import * as func from "./func"; -import * as structure from "./structure"; -import { StyleLoaderManager } from "./loader/loader.style"; -import { ShowListener } from "./listener/listener.show"; -import { useInWorker } from "./worker"; -import * as constant from "./constant"; -import * as logic from "./logic"; -import { Element } from "./element"; -import * as utils from "./utils"; -import * as wrapper from "./wrapper"; -import * as platform from "./platform/web"; +export { Plugin } from "./6.plugin"; +export { StyleLoaderManager } from "./loader/loader.style"; +export { ShowListener } from "./listener/listener.show"; +export { useInWorker } from "./worker"; +export { Element } from "./element"; + +export { Controller } from "./controller/0.controller"; +export { BroadcastController } from "./controller/controller.broadcast"; +export { BubblesController } from "./controller/controller.bubbles"; +export { DrawerController } from "./controller/controller.drawer"; +export { LayerController } from "./controller/controller.layer"; +export { MaskersController } from "./controller/controller.masker"; +export { PopoverController } from "./controller/controller.popover"; +export { ResizeController } from "./controller/controller.resizer"; +export { TooltipsController } from "./controller/controller.tooltips"; export * from "./decorator"; export * from "./2.base"; export * from "./3.ob"; export * from "./4.widget"; export * from "./5.inject"; +export * from "./6.plugin"; +export * from "./system"; export * from "./action"; export * from "./behavior"; -export * from "./controller"; +// export * from "./controller"; export * from "./func"; export * from "./structure"; export * from "./h"; @@ -35,35 +32,3 @@ export * from "./logic"; export * from "./wrapper"; export * from "./platform/web"; export * from "./utils"; - -export { - StyleLoaderManager, - ShowListener, - Plugin, - useInWorker, - Element -}; - -Object.assign(BI, { - ...base, - ...ob, - ...widget, - ...inject, - Plugin, - ...behavior, - ...constant, - component: inject.shortcut, - ...action, - ...controllers, - Element, - ...func, - StyleLoaderManager, - ShowListener, - ...logic, - ...structure, - useInWorker, - ...h, - ...utils, - ...wrapper, - ...platform, -}); diff --git a/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js b/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js index 7cfceede4..d52acb6c5 100644 --- a/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js +++ b/src/core/wrapper/layout/responsive/responsive.flex.horizontal.js @@ -1,7 +1,7 @@ import { shortcut } from "@/core/decorator"; import { each } from "@/core/2.base"; import { HorizontalAlign } from "@/core/constant"; -import { Resizers } from "@/base"; +// import { Resizers } from "@/base/0.base"; import { FlexHorizontalLayout } from "../flex"; /** @@ -34,22 +34,22 @@ export class ResponsiveFlexHorizontalLayout extends FlexHorizontalLayout { } } }; - const resize = () => { - defaultResize(); - if (o.scrollable !== true && o.scrollx !== true) { - const clientWidth = document.body.clientWidth; - if (this.element.width() > 2 / 3 * clientWidth) { - if (clientWidth > 768) { - each(this._children, (i, child) => { - this._clearGap(child); - }); - this.resize(); - this.element.css("flex-direction", "row"); - } - } - } - }; - this.unResize = Resizers.add(this.getName(), resize); + // const resize = () => { + // defaultResize(); + // if (o.scrollable !== true && o.scrollx !== true) { + // const clientWidth = document.body.clientWidth; + // if (this.element.width() > 2 / 3 * clientWidth) { + // if (clientWidth > 768) { + // each(this._children, (i, child) => { + // this._clearGap(child); + // }); + // this.resize(); + // this.element.css("flex-direction", "row"); + // } + // } + // } + // }; + // this.unResize = Resizers.add(this.getName(), resize); defaultResize(); } diff --git a/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js b/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js index 90677598a..52389036a 100644 --- a/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/responsive/responsive.flex.wrapper.horizontal.js @@ -1,7 +1,7 @@ import { shortcut } from "@/core/decorator"; import { each } from "@/core/2.base"; import { HorizontalAlign } from "@/core/constant"; -import { Resizers } from "@/base"; +// import { Resizers } from "@/base/0.base"; import { FlexWrapperHorizontalLayout } from "../flex"; /** @@ -35,23 +35,23 @@ export class ResponsiveFlexWrapperHorizontalLayout extends FlexWrapperHorizontal } } }; - const resize = () => { - defaultResize(); - if (o.scrollable !== true && o.scrollx !== true) { - const clientWidth = document.body.clientWidth; - if (this.element.width() > 2 / 3 * clientWidth) { - if (clientWidth > 768) { - each(this._children, (i, child) => { - this._clearGap(child); - }); - this.resize(); - this.element.css("flex-direction", "row"); - this.$wrapper.element.css("flex-direction", "row"); - } - } - } - }; - this.unResize = Resizers.add(this.getName(), resize); + // const resize = () => { + // defaultResize(); + // if (o.scrollable !== true && o.scrollx !== true) { + // const clientWidth = document.body.clientWidth; + // if (this.element.width() > 2 / 3 * clientWidth) { + // if (clientWidth > 768) { + // each(this._children, (i, child) => { + // this._clearGap(child); + // }); + // this.resize(); + // this.element.css("flex-direction", "row"); + // this.$wrapper.element.css("flex-direction", "row"); + // } + // } + // } + // }; + // this.unResize = Resizers.add(this.getName(), resize); defaultResize(); } diff --git a/src/core/wrapper/layout/responsive/responsive.inline.js b/src/core/wrapper/layout/responsive/responsive.inline.js index 747a9d9cf..b0d23c09a 100644 --- a/src/core/wrapper/layout/responsive/responsive.inline.js +++ b/src/core/wrapper/layout/responsive/responsive.inline.js @@ -1,7 +1,7 @@ import { shortcut } from "@/core/decorator"; import { each } from "@/core/2.base"; import { HorizontalAlign } from "@/core/constant"; -import { Resizers } from "@/base"; +// import { Resizers } from "@/base/0.base"; import { InlineLayout } from "../layout.inline"; /** @@ -34,21 +34,21 @@ export class ResponsiveInlineLayout extends InlineLayout { } } }; - const resize = () => { - defaultResize(); - if (o.scrollable !== true && o.scrollx !== true) { - const clientWidth = document.body.clientWidth; - if (this.element.width() > 2 / 3 * clientWidth) { - if (clientWidth > 768) { - each(this._children, (i, child) => { - this._clearGap(child); - }); - this.resize(); - } - } - } - }; - this.unResize = Resizers.add(this.getName(), resize); + // const resize = () => { + // defaultResize(); + // if (o.scrollable !== true && o.scrollx !== true) { + // const clientWidth = document.body.clientWidth; + // if (this.element.width() > 2 / 3 * clientWidth) { + // if (clientWidth > 768) { + // each(this._children, (i, child) => { + // this._clearGap(child); + // }); + // this.resize(); + // } + // } + // } + // }; + // this.unResize = Resizers.add(this.getName(), resize); defaultResize(); } diff --git a/src/index.js b/src/index.js new file mode 100644 index 000000000..2f3f17564 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +export * from "./core"; +export * from "./base"; +export * from "./case"; +export * from "./widget"; +export * from "./component"; diff --git a/src/widget/index.js b/src/widget/index.js index af799dc06..cc74ecb27 100644 --- a/src/widget/index.js +++ b/src/widget/index.js @@ -1,72 +1,14 @@ -import { Collapse } from "./collapse/collapse"; -import * as calendar from "./date/calendar"; -import * as dynamicdate from "./dynamicdate"; -import * as datepane from "./datepane"; -import * as datetime from "./datetime"; -import * as datetimepane from "./datetimepane"; -import * as dynamicdatetime from "./dynamicdatetime"; -import * as time from "./time"; -import * as editor from "./editor"; -import * as downList from "./downlist"; -import * as singleSliderItem from "./singleslider"; -import * as intervalSliderItem from "./intervalslider"; -import * as yearQuarter from "./yearquarter"; -import { SelectTreeCombo } from "./selecttree/selecttree.combo"; -import { SingleTreeCombo } from "./singletree/singletree.combo"; -import { MultiTreeCombo } from "./multitree/multi.tree.combo"; -import { MultiTreeInsertCombo } from "./multitree/multi.tree.insert.combo"; -import { MultiTreeListCombo } from "./multitree/multi.tree.list.combo"; -import { NumberEditor } from "./numbereditor/number.editor"; -import { NumberInterval } from "./numberinterval/numberinterval"; -import { YearMonthInterval } from "./yearmonthinterval/yearmonthinterval"; -import { YearQuarterInterval } from "./yearquarterinterval/yearquarterinterval"; -import * as yearmonth from "./yearmonth"; -import * as multiselect from "./multiselect"; -import * as multiselectlist from "./multiselectlist"; -import * as multilayerselectree from "./multilayerselecttree"; -import * as year from "./year"; -import { YearInterval } from "./yearinterval/yearinterval"; -import * as singleselect from "./singleselect"; -import * as multilayerdownlist from "./multilayerdownlist"; -import * as multilayersingletree from "./multilayersingletree"; -import * as textvaluedownlistcombo from "./textvaluedownlistcombo"; -import * as searchmultitextvaluecombo from "./searchmultitextvaluecombo"; - -Object.assign(BI, { - Collapse, - ...calendar, - ...dynamicdate, - ...datepane, - ...datetime, - ...datetimepane, - ...dynamicdatetime, - ...time, - ...year, - ...editor, - ...downList, - ...singleSliderItem, - ...intervalSliderItem, - ...yearQuarter, - SelectTreeCombo, - SingleTreeCombo, - MultiTreeCombo, - MultiTreeInsertCombo, - MultiTreeListCombo, - NumberEditor, - NumberInterval, - YearInterval, - YearMonthInterval, - YearQuarterInterval, - ...yearmonth, - ...multiselect, - ...multiselectlist, - ...multilayerselectree, - ...singleselect, - ...multilayerdownlist, - ...multilayersingletree, - ...textvaluedownlistcombo, - ...searchmultitextvaluecombo, -}); +export { Collapse } from "./collapse/collapse"; +export { SelectTreeCombo } from "./selecttree/selecttree.combo"; +export { SingleTreeCombo } from "./singletree/singletree.combo"; +export { MultiTreeCombo } from "./multitree/multi.tree.combo"; +export { MultiTreeInsertCombo } from "./multitree/multi.tree.insert.combo"; +export { MultiTreeListCombo } from "./multitree/multi.tree.list.combo"; +export { NumberEditor } from "./numbereditor/number.editor"; +export { NumberInterval } from "./numberinterval/numberinterval"; +export { YearMonthInterval } from "./yearmonthinterval/yearmonthinterval"; +export { YearQuarterInterval } from "./yearquarterinterval/yearquarterinterval"; +export { YearInterval } from "./yearinterval/yearinterval"; export * from "./date/calendar"; export * from "./dynamicdate"; @@ -91,17 +33,3 @@ export * from "./multilayerdownlist"; export * from "./yearquarter"; export * from "./textvaluedownlistcombo"; export * from "./searchmultitextvaluecombo"; - -export { - Collapse, - NumberEditor, - NumberInterval, - SelectTreeCombo, - SingleTreeCombo, - MultiTreeCombo, - MultiTreeInsertCombo, - MultiTreeListCombo, - YearInterval, - YearMonthInterval, - YearQuarterInterval -}; diff --git a/webpack/attachments.js b/webpack/attachments.js index acb30ad2a..f04bf8ed7 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -19,25 +19,25 @@ const basicAttachmentMap = { "src/less/theme/**/*.less", lodashJs, jqueryJs, - "src/core/**/*.js", - "src/data/**/*.js", + // "src/core/**/*.js", + // "src/data/**/*.js", ]), // 最基础的控件 base: sync([ "src/less/base/**/*.less", - "src/third/**/*.js", - "src/base/**/*.js", + // "src/third/**/*.js", + // "src/base/**/*.js", ]), // 实现好的一些基础实例 - case: sync([ - "src/case/**/*.js", + "case": sync([ + // "src/case/**/*.js", "src/less/case/**/*.less", ]), widget: sync([ "src/less/widget/**/*.less", "src/less/component/**/*.less", - "src/widget/**/*.js", - "src/component/**/*.js", + // "src/widget/**/*.js", + // "src/component/**/*.js", ]), router: sync([ "src/router/**/*.js", @@ -238,6 +238,7 @@ const demo = [].concat( basicAttachmentMap.core, basicAttachmentMap.fix, basicAttachmentMap.config, + sync(["src/bundle.js"]), basicAttachmentMap.base, basicAttachmentMap.case, basicAttachmentMap.widget,