diff --git a/package.json b/package.json index 1878b8ae7..3235a2151 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "dev:demo": "pnpm --dir packages/demo dev", "dev:fineui": "pnpm --dir packages/fineui dev", "build": "pnpm --dir packages/fineui build", - "build:demo": "pnpm --dir packages/demo build" + "build:demo": "pnpm --dir packages/demo build", + "tsc": "pnpm --dir packages/fineui tsc" }, "devDependencies": { "@babel/cli": "^7.21.0", diff --git a/packages/fineui/package.json b/packages/fineui/package.json index 9623a14a2..d075c41e1 100644 --- a/packages/fineui/package.json +++ b/packages/fineui/package.json @@ -1,6 +1,6 @@ { "name": "@fui/core", - "version": "3.0.20230606133653", + "version": "3.0.20230615140705", "description": "fineui", "main": "dist/fineui.min.js", "module": "dist/lib/index.js", diff --git a/packages/fineui/src/base/combination/searcher.js b/packages/fineui/src/base/combination/searcher.js index 9cf9f17c0..bd161c7ef 100644 --- a/packages/fineui/src/base/combination/searcher.js +++ b/packages/fineui/src/base/combination/searcher.js @@ -17,7 +17,8 @@ import { BlankSplitChar, Events, EVENT_RESPONSE_TIME, - Func + Func, + isFunction, } from "@/core"; import { ButtonGroup } from "./group.button"; import { Maskers } from "@/base/0.base"; @@ -127,7 +128,8 @@ export class Searcher extends Widget { } _assertPopupView() { - const { masker, popup, chooseType, isAutoSync, adapter } = this.options; + const { masker, popup, chooseType, isAutoSync } = this.options; + const adapter = isFunction(this.options.adapter) ? this.options.adapter() : this.options.adapter; if ((masker && !Maskers.has(this.getName())) || (masker === false && !this.popupView)) { this.popupView = createWidget(popup, { type: SearcherView.xtype, @@ -213,7 +215,8 @@ export class Searcher extends Widget { } _search() { - const { isAutoSearch, adapter, isAutoSync, onSearch } = this.options; + const { isAutoSearch, isAutoSync, onSearch } = this.options; + const adapter = isFunction(this.options.adapter) ? this.options.adapter() : this.options.adapter; const keyword = this.editor.getValue(); if (keyword === "" || this._stop) { return; @@ -333,7 +336,8 @@ export class Searcher extends Widget { } getValue() { - const { isAutoSync, adapter, popup } = this.options; + const { isAutoSync, popup } = this.options; + const adapter = isFunction(this.options.adapter) ? this.options.adapter() : this.options.adapter; if (isAutoSync && adapter && adapter.getValue) { return adapter.getValue(); } @@ -350,7 +354,8 @@ export class Searcher extends Widget { } populate(result, searchResult, keyword) { - const { isAutoSync, adapter } = this.options; + const { isAutoSync } = this.options; + const adapter = isFunction(this.options.adapter) ? this.options.adapter() : this.options.adapter; this._assertPopupView(); this.popupView.populate(...arguments); if (isAutoSync && adapter && adapter.getValue) { diff --git a/packages/fineui/src/base/combination/switcher.js b/packages/fineui/src/base/combination/switcher.js index 518690ca0..85e4a8083 100644 --- a/packages/fineui/src/base/combination/switcher.js +++ b/packages/fineui/src/base/combination/switcher.js @@ -11,7 +11,7 @@ import { isNull, Events, Direction, - EVENT_RESPONSE_TIME + EVENT_RESPONSE_TIME, isFunction } from "@/core"; import { ButtonGroup } from "./group.button"; import { Maskers } from "@/base/0.base"; @@ -188,7 +188,8 @@ export class Switcher extends Widget { } _assertPopupView() { - const { popup, adapter, masker, value, direction } = this.options; + const { popup, masker, value, direction } = this.options; + const adapter = isFunction(this.options.adapter) ? this.options.adapter() : this.options.adapter; if (!this._created) { this.popupView = createWidget( popup, diff --git a/packages/fineui/src/core/2.base.js b/packages/fineui/src/core/2.base.js index 0c8e5f61c..23fc68095 100644 --- a/packages/fineui/src/core/2.base.js +++ b/packages/fineui/src/core/2.base.js @@ -1227,19 +1227,19 @@ export function checkDateVoid(YY, MM, DD, minDate, maxDate) { } else if (YY > maxDate[0]) { back = ["y", 1]; } else if (YY >= minDate[0] && YY <= maxDate[0]) { - if (YY === minDate[0]) { + if (YY == minDate[0]) { if (MM < minDate[1]) { back = ["m"]; - } else if (MM === minDate[1]) { + } else if (MM == minDate[1]) { if (DD < minDate[2]) { back = ["d"]; } } } - if (YY === maxDate[0]) { + if (YY == maxDate[0]) { if (MM > maxDate[1]) { back = ["m", 1]; - } else if (MM === maxDate[1]) { + } else if (MM == maxDate[1]) { if (DD > maxDate[2]) { back = ["d", 1]; } diff --git a/packages/fineui/src/core/constant/writable.var.js b/packages/fineui/src/core/constant/writable.var.js index 1de6b3a79..3bca927e5 100644 --- a/packages/fineui/src/core/constant/writable.var.js +++ b/packages/fineui/src/core/constant/writable.var.js @@ -130,7 +130,7 @@ const getCacheItem = key => { export let EVENT_BLUR = _global.localStorage ? getCacheItem("event.blur") : true; export const setEventBlur = v => { EVENT_BLUR = v; - Cache.setItem("event.blur", newVal); + Cache.setItem("event.blur", v); }; PropertyDescriptors["EVENT_BLUR"] = { enumerable: true, diff --git a/packages/fineui/src/core/func/alias.js b/packages/fineui/src/core/func/alias.js index c334caf00..c2ddbb28f 100644 --- a/packages/fineui/src/core/func/alias.js +++ b/packages/fineui/src/core/func/alias.js @@ -456,7 +456,7 @@ export const htmlDecode = function(text) { export const cjkEncodeDO = function(o) { if (isPlainObject(o)) { const result = {}; - each(o, (v, k) => { + each(o, (k, v) => { if (!(typeof v === "string")) { v = jsonEncode(v); } diff --git a/packages/fineui/src/widget/multiselect/multiselect.combo.js b/packages/fineui/src/widget/multiselect/multiselect.combo.js index 2c807beac..c4b2445cf 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.combo.js +++ b/packages/fineui/src/widget/multiselect/multiselect.combo.js @@ -99,13 +99,8 @@ export class MultiSelectCombo extends Single { height: toPix(o.height, o.simple ? 1 : 2), text: o.text, defaultText: o.defaultText, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemFormatter: o.itemFormatter, @@ -185,8 +180,6 @@ export class MultiSelectCombo extends Single { type: MultiSelectPopupView.xtype, ref() { self.popup = this; - self.trigger.setAdapter(this); - self.numberCounter.setAdapter(this); }, listeners: [ { @@ -269,13 +262,8 @@ export class MultiSelectCombo extends Single { this.numberCounter = createWidget({ type: MultiSelectCheckSelectedSwitcher.xtype, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), diff --git a/packages/fineui/src/widget/multiselect/multiselect.combo.nobar.js b/packages/fineui/src/widget/multiselect/multiselect.combo.nobar.js index cc1a1196a..3c9bb5689 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.combo.nobar.js +++ b/packages/fineui/src/widget/multiselect/multiselect.combo.nobar.js @@ -97,13 +97,8 @@ export class MultiSelectNoBarCombo extends Single { height: toPix(o.height, o.simple ? 1 : 2), text: o.text, defaultText: o.defaultText, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), @@ -185,8 +180,6 @@ export class MultiSelectNoBarCombo extends Single { type: MultiSelectNoBarPopupView.xtype, ref() { self.popup = this; - self.trigger.setAdapter(this); - self.numberCounter.setAdapter(this); }, listeners: [ { @@ -272,13 +265,8 @@ export class MultiSelectNoBarCombo extends Single { this.numberCounter = createWidget({ type: MultiSelectCheckSelectedSwitcher.xtype, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), diff --git a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js index 008d1039b..8a9ef9546 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js +++ b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js @@ -99,14 +99,8 @@ export class MultiSelectInsertCombo extends Single { text: o.text, watermark: o.watermark, defaultText: o.defaultText, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), @@ -151,7 +145,7 @@ export class MultiSelectInsertCombo extends Single { self._dataChange = true; }); this.getSearcher().getKeywordsLength() > 2000 && - Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); + Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); } self.fireEvent(MultiSelectInsertCombo.EVENT_SEARCHING); }); @@ -192,8 +186,6 @@ export class MultiSelectInsertCombo extends Single { type: MultiSelectPopupView.xtype, ref() { self.popup = this; - self.trigger.setAdapter(this); - self.numberCounter.setAdapter(this); }, listeners: [ { @@ -276,13 +268,8 @@ export class MultiSelectInsertCombo extends Single { this.numberCounter = createWidget({ type: MultiSelectCheckSelectedSwitcher.xtype, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), diff --git a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.nobar.js b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.nobar.js index 0110bc518..4a20ef6fd 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -93,14 +93,8 @@ export class MultiSelectInsertNoBarCombo extends Single { type: MultiSelectInsertTrigger.xtype, height: toPix(o.height, o.simple ? 1 : 2), text: o.text, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), @@ -140,7 +134,7 @@ export class MultiSelectInsertNoBarCombo extends Single { self._dataChange = true; }); this.getSearcher().getKeywordsLength() > 2000 && - Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); + Msg.alert(i18nText("BI-Basic_Prompt"), i18nText("BI-Basic_Too_Much_Value_Get_Two_Thousand")); } }); @@ -178,8 +172,6 @@ export class MultiSelectInsertNoBarCombo extends Single { type: MultiSelectNoBarPopupView.xtype, ref() { self.popup = this; - self.trigger.setAdapter(this); - self.numberCounter.setAdapter(this); }, listeners: [ { @@ -263,13 +255,8 @@ export class MultiSelectInsertNoBarCombo extends Single { this.numberCounter = createWidget({ type: MultiSelectCheckSelectedSwitcher.xtype, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: SIZE_CONSANTS.LIST_ITEM_HEIGHT + 1, - }, + adapter: () => { + return this.popup.getView(); }, valueFormatter: o.valueFormatter, itemsCreator: bind(this._itemsCreator4Trigger, this), diff --git a/packages/fineui/src/widget/multiselect/multiselect.popup.view.js b/packages/fineui/src/widget/multiselect/multiselect.popup.view.js index 2a833446e..84e3faf58 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.popup.view.js +++ b/packages/fineui/src/widget/multiselect/multiselect.popup.view.js @@ -98,4 +98,8 @@ export class MultiSelectPopupView extends Widget { setDirection(direction, position) { this.popupView.setDirection(direction, position); } + + getView() { + return this.popupView.getView(); + } } diff --git a/packages/fineui/src/widget/multiselect/multiselect.popup.view.nobar.js b/packages/fineui/src/widget/multiselect/multiselect.popup.view.nobar.js index 1ba871201..728ccf50c 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.popup.view.nobar.js +++ b/packages/fineui/src/widget/multiselect/multiselect.popup.view.nobar.js @@ -93,4 +93,8 @@ export class MultiSelectNoBarPopupView extends Widget { setDirection(direction, position) { this.popupView.setDirection(direction, position); } + + getView() { + return this.popupView.getView(); + } } diff --git a/packages/fineui/src/widget/multitree/multi.tree.combo.js b/packages/fineui/src/widget/multitree/multi.tree.combo.js index 198aa591f..7d61b6e9d 100644 --- a/packages/fineui/src/widget/multitree/multi.tree.combo.js +++ b/packages/fineui/src/widget/multitree/multi.tree.combo.js @@ -101,7 +101,7 @@ export class MultiTreeCombo extends Single { el: this.trigger, adjustLength: 1, popup: { - type: "bi.multi_tree_popup_view", + type: MultiTreePopup.xtype, ref() { self.popup = this; self.trigger.setAdapter(this); diff --git a/packages/fineui/typescript/base/base.ts b/packages/fineui/typescript/base/base.ts index 98fa0e790..0a89024d6 100644 --- a/packages/fineui/typescript/base/base.ts +++ b/packages/fineui/typescript/base/base.ts @@ -3,9 +3,12 @@ import { BroadcastController } from "../core/controller/controller.broadcast"; import { StyleLoaderManager } from "../core/loader/loader.style"; import { BubblesController } from "../core/controller/controller.bubbles"; import { PopoverController } from "../core/controller/controller.popovers"; +import { MaskersController } from "../core/controller/controller.masker"; export const Layers = new LayerController(); +export const Maskers = new MaskersController(); + export const Bubbles = new BubblesController(); export const Broadcasts = new BroadcastController(); diff --git a/packages/fineui/typescript/core/base.ts b/packages/fineui/typescript/core/base.ts index be506f32c..e347747cf 100644 --- a/packages/fineui/typescript/core/base.ts +++ b/packages/fineui/typescript/core/base.ts @@ -400,6 +400,8 @@ export declare function getDate(...args: (number | string)[]): Date; export declare function getTime(...args: any[]): number; +export declare function clamp(number: number, lower: number, upper: number): number; + /** * 判断一个对象是不是promise * @param obj 对象 diff --git a/packages/fineui/typescript/core/controller/controller.masker.ts b/packages/fineui/typescript/core/controller/controller.masker.ts new file mode 100644 index 000000000..dfed62baa --- /dev/null +++ b/packages/fineui/typescript/core/controller/controller.masker.ts @@ -0,0 +1,5 @@ +import { LayerController } from "./controller.layer"; + +export declare class MaskersController extends LayerController { + +} diff --git a/packages/fineui/typescript/core/func/alias.ts b/packages/fineui/typescript/core/func/alias.ts index 08035c6ff..36f865eb9 100644 --- a/packages/fineui/typescript/core/func/alias.ts +++ b/packages/fineui/typescript/core/func/alias.ts @@ -1,3 +1,17 @@ export declare function jsonDecode(text: string): any; export declare function jsonEncode(json: any): any; + +export declare function contentFormat(cv: any, fmt: string): string; + +export declare function htmlDecode(text: string): string; + +export declare function htmlEncode(text: string): string; + +export declare function getEncodeURL(urlTemplate: string, param: any): string; + +export declare function encodeURIComponent(url: string): string; + +export declare function decodeURIComponent(url: string): string; + + diff --git a/packages/fineui/typescript/core/platform/web/index.ts b/packages/fineui/typescript/core/platform/web/index.ts index 2aadb120a..f9146475b 100644 --- a/packages/fineui/typescript/core/platform/web/index.ts +++ b/packages/fineui/typescript/core/platform/web/index.ts @@ -3,3 +3,4 @@ export * as EventListener from "./eventListener"; export * as ResizeDetector from "./detectElementResize"; export * from "./load"; export * as DOM from "./dom"; +export declare var $: any; diff --git a/packages/fineui/typescript/router/router.ts b/packages/fineui/typescript/router/router.ts index 5db2af9ee..1ac76c266 100644 --- a/packages/fineui/typescript/router/router.ts +++ b/packages/fineui/typescript/router/router.ts @@ -1,3 +1,5 @@ +import { Widget } from '../core/widget'; + type Component = any type Dictionary = { [key: string]: T } type ErrorHandler = (err: Error) => void @@ -244,6 +246,6 @@ export declare class RouterWidget { static xtype: string; } -export declare class RouterView { +export declare class RouterView extends Widget { static xtype: string; }