diff --git a/package.json b/package.json index a66b93c94..e73b6000d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20230109200447", + "version": "2.0.20230208163847", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", @@ -9,8 +9,7 @@ }, "devDependencies": { "@babel/core": "^7.17.4", - "@babel/polyfill": "7.6.0", - "@fui/babel-preset-fineui": "^2.0.0", + "@fui/babel-preset-fineui": "^3.0.0", "@fui/eslint-plugin": "^1.0.19", "@juggle/resize-observer": "^3.4.0", "@types/node": "15.6.1", @@ -19,7 +18,6 @@ "autoprefixer": "9.6.1", "babel-loader": "8.0.6", "chai": "4.2.0", - "cnpm": "6.1.1", "concat": "1.0.3", "core-js": "3.3.2", "cross-env": "6.0.0", diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index d7ef6a707..0b1bb059e 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -459,11 +459,11 @@ const fileTypeValidate = (fileName, fileType) => { let matches; matches = mime.match(r1); if (matches) { - return fileName.toLowerCase().indexOf(matches[1]) > -1; + return fileName.toLowerCase().endsWith(matches[0]); } matches = mime.match(r2); if (matches) { - return matches[1] === "*" ? true : fileName.toLowerCase().indexOf(matches[1]) > -1; + return matches[1] === "*" ? true : fileName.toLowerCase().endsWith(`.${matches[1]}`); } }); }; diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index d6b307026..407abdb8b 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -22,6 +22,7 @@ export class TextValueCombo extends Widget { static xtype = "bi.text_value_combo"; static EVENT_CHANGE = "EVENT_CHANGE"; + static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; _defaultConfig(config) { return extend(super._defaultConfig(...arguments), { @@ -43,13 +44,13 @@ export class TextValueCombo extends Widget { const o = this.options; o.value = isFunction(o.value) ? this.__watch(o.value, (context, newValue) => { - this.setValue(newValue); - }) + this.setValue(newValue); + }) : o.value; o.items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { - this.populate(newValue); - }) + this.populate(newValue); + }) : o.items; super._init(...arguments); } @@ -75,7 +76,7 @@ export class TextValueCombo extends Widget { const trigger = { type: SelectTextTrigger.xtype, - ref: (ref) => (this.trigger = ref), + ref: ref => (this.trigger = ref), cls: "text-value-trigger", items: o.items, height: toPix(o.height, o.simple ? 1 : 2), @@ -91,14 +92,14 @@ export class TextValueCombo extends Widget { this._clear(); this.fireEvent(TextValueCombo.EVENT_CHANGE); }, - }, + } ], ...o.el, }; let changeTag = false; const popup = { type: TextValueComboPopup.xtype, - ref: (ref) => (this.popup = ref), + ref: ref => (this.popup = ref), chooseType: o.chooseType, items: o.items, allowSelectAll: o.allowSelectAll, @@ -137,7 +138,7 @@ export class TextValueCombo extends Widget { action: (...args) => { this.combo.hideView(); }, - }, + } ], }; @@ -145,7 +146,7 @@ export class TextValueCombo extends Widget { type: Combo.xtype, height: toPix(o.height, 2), width: toPix(o.width, 2), - ref: (ref) => (this.combo = ref), + ref: ref => (this.combo = ref), container: o.container, direction: o.direction, adjustLength: 2, @@ -155,16 +156,16 @@ export class TextValueCombo extends Widget { eventName: Combo.EVENT_BEFORE_POPUPVIEW, action: () => { changeTag = false; + this.fireEvent(BI.TextValueCombo.EVENT_BEFORE_POPUPVIEW); }, - }, - { + }, { eventName: Combo.EVENT_AFTER_HIDEVIEW, action: (...args) => { if (o.chooseType !== ButtonGroup.CHOOSE_TYPE_SINGLE && changeTag) { this.fireEvent(TextValueCombo.EVENT_CHANGE, ...args); } }, - }, + } ], popup: { el: popup, diff --git a/src/core/utils/dom.js b/src/core/utils/dom.js index 4b5096a8f..a60a097ad 100644 --- a/src/core/utils/dom.js +++ b/src/core/utils/dom.js @@ -776,9 +776,10 @@ export function getPositionRelativeContainingBlock(element) { export function getPositionRelativeContainingBlockRect(element) { const positionRelativeElement = getPositionRelativeContainingBlock(element); const rect = positionRelativeElement.getBoundingClientRect(); + const { top, right, bottom, left, width, height, x, y } = positionRelativeElement.getBoundingClientRect(); return { - ...rect.toJSON(), + top, right, bottom, left, width, height, x, y, scaleX: rect.width / positionRelativeElement.offsetWidth, scaleY: rect.height / positionRelativeElement.offsetHeight, }; diff --git a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js index c75d3827c..f7d46437d 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js @@ -25,11 +25,16 @@ export class DynamicDateTimeSelect extends Widget { static EVENT_CONFIRM = "EVENT_CONFIRM"; - props = { - baseCls: "bi-date-time-select", - }; + props () { + return { + baseCls: "bi-date-time-select", + height: SIZE_CONSANTS.LIST_ITEM_HEIGHT, + }; + } render() { + const { height } = this.options; + return { type: CenterAdaptLayout.xtype, items: [ @@ -49,7 +54,7 @@ export class DynamicDateTimeSelect extends Widget { if (isNumeric(v)) { return i18nText("BI-Basic_Input_From_To_Number", "\"00-23\""); } - + return i18nText("BI-Numerical_Interval_Input_Data"); }, listeners: [ @@ -74,7 +79,7 @@ export class DynamicDateTimeSelect extends Widget { } ], width: 60, - height: SIZE_CONSANTS.LIST_ITEM_HEIGHT, + height, }, }, { @@ -119,7 +124,7 @@ export class DynamicDateTimeSelect extends Widget { } ], width: 60, - height: SIZE_CONSANTS.LIST_ITEM_HEIGHT, + height, }, { type: Label.xtype, @@ -153,7 +158,7 @@ export class DynamicDateTimeSelect extends Widget { } ], width: 60, - height: SIZE_CONSANTS.LIST_ITEM_HEIGHT, + height, } ], } diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index d5d69c82c..b278b42d9 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -15,7 +15,9 @@ import { toPix, Selection, pushDistinct, - SIZE_CONSANTS + SIZE_CONSANTS, + LogicFactory, + Direction } from "@/core"; import { ButtonGroup, Loader } from "@/base"; import { SelectList, ListPane, MultiSelectItem } from "@/case"; @@ -133,12 +135,14 @@ export class MultiSelectNoBarLoader extends Widget { ) ); - createWidget({ - type: VerticalLayout.xtype, + createWidget(extend({ element: this, - items: [this.button_group], + }, LogicFactory.createLogic(LogicFactory.createLogicTypeByDirection(Direction.Top), extend({ + scrolly: true, vgap: 5, - }); + }, opts.logic, { + items: LogicFactory.createLogicItemsByDirection(Direction.Top, this.button_group), + })))); this.button_group.on(Controller.EVENT_CHANGE, function () { self.fireEvent(Controller.EVENT_CHANGE, arguments); diff --git a/src/widget/multiselect/search/multiselect.search.insert.pane.js b/src/widget/multiselect/search/multiselect.search.insert.pane.js index 93ee0c7fa..3d136e1b4 100644 --- a/src/widget/multiselect/search/multiselect.search.insert.pane.js +++ b/src/widget/multiselect/search/multiselect.search.insert.pane.js @@ -16,6 +16,7 @@ export class MultiSelectSearchInsertPane extends Widget { itemsCreator: emptyFn, valueFormatter: emptyFn, keywordGetter: emptyFn, + allowSelectAll: true, itemHeight: 24, }); } @@ -49,6 +50,7 @@ export class MultiSelectSearchInsertPane extends Widget { }, itemHeight: o.itemHeight, value: o.value, + allowSelectAll: o.allowSelectAll, }); this.loader.on(Controller.EVENT_CHANGE, function () { self.fireEvent(Controller.EVENT_CHANGE, arguments); diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js index 92da5257f..223d96b75 100644 --- a/src/widget/multiselect/search/multiselect.search.loader.js +++ b/src/widget/multiselect/search/multiselect.search.loader.js @@ -14,7 +14,7 @@ import { SIZE_CONSANTS } from "@/core"; import { ButtonGroup, Loader } from "@/base"; -import { SelectList, MultiSelectBar, MultiSelectItem } from "@/case"; +import { SelectList, MultiSelectBar, MultiSelectItem, ListPane } from "@/case"; @shortcut() export class MultiSelectSearchLoader extends Widget { @@ -29,18 +29,18 @@ export class MultiSelectSearchLoader extends Widget { keywordGetter: emptyFn, valueFormatter: emptyFn, itemFormatter: emptyFn, + allowSelectAll: true, itemHeight: 24, }); } _init() { super._init(...arguments); - const self = this, opts = this.options; let hasNext = false; this.storeValue = deepClone(opts.value); - this.button_group = createWidget({ + this.button_group = createWidget(opts.allowSelectAll ? { type: SelectList.xtype, toolbar: { type: MultiSelectBar.xtype, @@ -101,11 +101,58 @@ export class MultiSelectSearchLoader extends Widget { hasNext() { return hasNext; }, + } : { + type: "bi.list_pane", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch, + }, + element: this, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark () { + return true; + }, + }, + layouts: [ + { + type: "bi.vertical", + } + ], + }, + itemsCreator (op, callback) { + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: self.storeValue.value, + })); + opts.itemsCreator(op, ob => { + const keyword = ob.keyword = opts.keywordGetter(); + hasNext = ob.hasNext; + let firstItems = []; + if (op.times === 1 && self.storeValue) { + const json = self._filterValues(self.storeValue); + firstItems = self._createItems(json); + } + const context = { + tipText: ob.tipText, + }; + callback(firstItems.concat(self._createItems(ob.items)), keyword, context); + if (op.times === 1 && self.storeValue) { + self.setValue(self.storeValue); + } + }); + }, + value: opts.value, + height: "fill", }); this.button_group.on(Controller.EVENT_CHANGE, function () { self.fireEvent(Controller.EVENT_CHANGE, arguments); }); - this.button_group.on(SelectList.EVENT_CHANGE, function () { + + const searchLoaderEventChangeName = opts.allowSelectAll ? SelectList.EVENT_CHANGE : ListPane.EVENT_CHANGE; + this.button_group.on(searchLoaderEventChangeName, function () { self.fireEvent(MultiSelectSearchLoader.EVENT_CHANGE, arguments); }); } @@ -131,7 +178,9 @@ export class MultiSelectSearchLoader extends Widget { } isAllSelected() { - return this.button_group.isAllSelected(); + const o = this.options; + + return o.allowSelectAll ? this.button_group.isAllSelected() : false; } _filterValues(src) { @@ -161,13 +210,24 @@ export class MultiSelectSearchLoader extends Widget { } setValue(v) { + v || (v = {}); + const o = this.options; // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 this.storeValue = deepClone(v); - this.button_group.setValue(v); + o.allowSelectAll ? (this.button_group.setValue(v)) : (this.button_group.setValue(v.value)); } getValue() { - return this.button_group.getValue(); + const o = this.options; + if (o.allowSelectAll) { + return this.button_group.getValue(); + } + + return { + type: ButtonGroup.CHOOSE_TYPE_MULTI, + value: this.button_group.getValue(), + assist: this.button_group.getNotSelectedValue(), + }; } getAllButtons() { diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js index 62373d33e..1bca0a442 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js +++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js @@ -27,7 +27,8 @@ import { contains, isNull, VTapeLayout, - BlankSplitChar + BlankSplitChar, + SIZE_CONSANTS } from "@/core"; import { Single, Searcher, Msg } from "@/base"; import { MultiSelectBar } from "@/case"; @@ -108,6 +109,7 @@ export class MultiSelectInsertNoBarList extends Single { o.itemsCreator(op, callback); } }, + allowSelectAll: false, }); this.searcherPane.setVisible(false); diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js index 3a8f38623..727077bc5 100644 --- a/src/widget/singleslider/singleslider.js +++ b/src/widget/singleslider/singleslider.js @@ -374,9 +374,9 @@ export class SingleSlider extends Single { } setMinAndMax(v) { - const minNumber = parseFloat(v.min); - const maxNumber = parseFloat(v.max); - if (!isNaN(minNumber) && !isNaN(maxNumber) && maxNumber > minNumber) { + const minNumber = this.options.min = parseFloat(v.min); + const maxNumber = this.options.max = parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) { this.min = minNumber; this.max = maxNumber; } diff --git a/typescript/case/combo/combo.textvalue.ts b/typescript/case/combo/combo.textvalue.ts index 128ec03b6..f2a080ba5 100644 --- a/typescript/case/combo/combo.textvalue.ts +++ b/typescript/case/combo/combo.textvalue.ts @@ -4,6 +4,7 @@ export declare class TextValueCombo extends Widget { static xtype: string; static EVENT_CHANGE: string; + static EVENT_BEFORE_POPUPVIEW: string; clear(): void; setText(text: string): void; diff --git a/webpack/attachments.js b/webpack/attachments.js index 0a2e3f62d..b8463c5b3 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -8,7 +8,7 @@ const lodashJs = "src/core/1.lodash.js"; const jqueryJs = "src/core/platform/web/jquery/_jquery.js"; const popperJs = "src/core/controller/popper.js"; -const runtimePolyfill = ["@babel/polyfill", "es6-promise/auto"]; +const runtimePolyfill = ["core-js/stable"]; const basicAttachmentMap = { polyfill: sync([