diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 15df83c54..4f8c4a92e 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -8,19 +8,21 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { render: function () { var combo1, combo2; - var items = [{ - text: "MVC-1", - iconCls: "date-font", - value: 1 - }, { - text: "MVC-2", - iconCls: "search-font", - value: 2 - }, { - text: "MVC-3", - iconCls: "pull-right-font", - value: 3 - }]; + var items = [ + { + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + } + ]; // 创建下拉框各种场景用例 return { @@ -195,6 +197,31 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { allowClear: true, defaultText: "请选择", chooseType: BI.Selection.Multi, + value: [1], + // allowSelectAll: false, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + } + ] + }), + this.createCombo("支持复选,不要全选功能", { + type: "bi.vertical", + items: [ + { + type: "bi.text_value_combo", + width: 300, + items: items, + allowClear: true, + defaultText: "请选择", + chooseType: BI.Selection.Multi, + value: [1], + allowSelectAll: false, listeners: [ { eventName: BI.TextValueCombo.EVENT_CHANGE, diff --git a/package.json b/package.json index b54ae8401..cd175efdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20221121190600", + "version": "2.0.20221202174010", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 1128f4ed8..02642da1a 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -16,7 +16,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { el: {}, allowClear: false, status: "success", // success | warning | error, - title: null + title: null, + allowSelectAll: true, }); }, @@ -78,6 +79,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { ref: ref => this.popup = ref, chooseType: o.chooseType, items: o.items, + allowSelectAll: o.allowSelectAll, listeners: [ { eventName: BI.TextValueComboPopup.EVENT_CHANGE, diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js index 3f50089af..3411793a4 100644 --- a/src/case/combo/textvaluecombo/popup.textvalue.js +++ b/src/case/combo/textvaluecombo/popup.textvalue.js @@ -2,92 +2,132 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { _defaultConfig: function () { return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-text-icon-popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + allowSelectAll: true, }); }, - render () { + render() { var o = this.options, self = this; if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return { type: "bi.vertical", vgap: 5, - items: [{ - type: "bi.button_group", - ref: (_ref) => { - this.popup = _ref; - }, - items: this._formatItems(o.items), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }], - value: o.value, - listeners: [{ - eventName: BI.Controller.EVENT_CHANGE, - action: function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); + items: [ + { + type: "bi.button_group", + ref: (_ref) => { + this.popup = _ref; + }, + items: this._formatItems(o.items), + chooseType: o.chooseType, + layouts: [ + { + type: "bi.vertical" } - } - }] - }] + ], + value: o.value, + listeners: [ + { + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + } + ] + } + ] }; } return { type: "bi.vertical", verticalAlign: BI.VerticalAlign.Stretch, - rowSize: ["fill", ""], - items: [{ - type: "bi.select_list", - logic: { - dynamic: true, - innerVgap: 5, - rowSize: ["", "fill"], - verticalAlign: BI.VerticalAlign.Stretch - }, - ref: (_ref) => { - this.popup = _ref; - }, - el: { + items: o.allowSelectAll ? [ + { + type: "bi.select_list", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch + }, + ref: (_ref) => { + this.popup = _ref; + }, el: { - chooseType: o.chooseType - } - }, - items: this._formatItems(o.items), - value: { - type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - value: o.value - }, - listeners: [{ - eventName: BI.SelectList.EVENT_CHANGE, - action: function (val) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); - } - }] - }, { - type: "bi.center", - cls: "list-view-toolbar bi-high-light bi-split-top", - height: 24, - items: BI.createItems([{ - type: "bi.text_button", - text: BI.i18nText("BI-Basic_Clears"), - handler: function () { - self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); - } + el: { + chooseType: o.chooseType, + } + }, + items: this._formatItems(o.items), + value: { + type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + value: o.value + }, + height: "fill", + listeners: [ + { + eventName: BI.SelectList.EVENT_CHANGE, + action: function (val) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); + } + } + ] }, { - type: "bi.text_button", - text: BI.i18nText("BI-Basic_OK"), - handler: function () { - self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); - } - }], { - once: false, - shadow: true, - isShadowShowingOnSelected: true - }) - }] + type: "bi.center", + cls: "list-view-toolbar bi-high-light bi-split-top", + height: 24, + items: BI.createItems([ + { + type: "bi.text_button", + text: BI.i18nText("BI-Basic_Clears"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); + } + }, { + type: "bi.text_button", + text: BI.i18nText("BI-Basic_OK"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); + } + } + ], { + once: false, + shadow: true, + isShadowShowingOnSelected: true + }) + } + ] : [ + { + type: "bi.list_pane", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch + }, + ref: (_ref) => { + this.popup = _ref; + }, + el: { + chooseType: o.chooseType, + }, + items: this._formatItems(o.items), + value: o.value, + height: "fill", + listeners: [ + { + eventName: BI.ListPane.EVENT_CHANGE, + action: function (val) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); + } + } + ] + } + ], }; }, @@ -117,6 +157,9 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { return this.popup.getValue(); } var val = this.popup.getValue(); + if (!this.options.allowSelectAll) { + return val; + } if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return val.value; } else { @@ -128,6 +171,10 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return this.popup.setValue(v); } + if (!this.options.allowSelectAll) { + this.popup.setValue(v); + return; + } this.popup.setValue({ type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, value: v diff --git a/src/core/platform/web/function.js b/src/core/platform/web/function.js index 1c74836e2..152933882 100644 --- a/src/core/platform/web/function.js +++ b/src/core/platform/web/function.js @@ -137,5 +137,14 @@ BI._.extend(BI, { return version[1] * 1; } return 0; + }, + + getMinimumFontSize: function () { + const el = document.createElement('div'); + el.style.fontSize = "0px"; + document.body.appendChild(el); + const size = getComputedStyle(el).fontSize; + el.remove(); + return parseInt(size); } }); diff --git a/src/less/widget/multiselect/trigger/button.checkselected.less b/src/less/widget/multiselect/trigger/button.checkselected.less index 4a36315b0..ded0da5eb 100644 --- a/src/less/widget/multiselect/trigger/button.checkselected.less +++ b/src/less/widget/multiselect/trigger/button.checkselected.less @@ -2,7 +2,7 @@ .bi-multi-select-check-selected-button { z-index: 1; - .border-radius(50%); + .border-radius(99999px); &:active { color: @color-bi-text-highlight; diff --git a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less index 5393d7b24..dd7fe2527 100644 --- a/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less +++ b/src/less/widget/multitree/trigger/multi.tree.button.checkselected.less @@ -6,11 +6,11 @@ z-index: 1; } .trigger-check-text { - .border-radius(8px); - .border-radius(calc(var(--css-scale, 1) * 8px)); + .border-radius(99999px); z-index: 1; + &:active { background-color: @color-bi-background-multi-select-trigger-check-selected; } } -} \ No newline at end of file +} diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index 8b9aa4c0c..10c39bfbf 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/src/widget/downlist/combo.downlist.js @@ -44,7 +44,8 @@ popup: {}, minWidth: 140, maxHeight: 1000, - destroyWhenHide: false + destroyWhenHide: false, + isDefaultInit: true, }); }, @@ -57,7 +58,7 @@ type: "bi.combo", trigger: o.trigger, isNeedAdjustWidth: false, - isDefaultInit: true, + isDefaultInit: o.isDefaultInit, container: o.container, adjustLength: o.adjustLength, direction: o.direction, diff --git a/typescript/case/combo/combo.textvalue.ts b/typescript/case/combo/combo.textvalue.ts index 0a50d2342..128ec03b6 100644 --- a/typescript/case/combo/combo.textvalue.ts +++ b/typescript/case/combo/combo.textvalue.ts @@ -5,5 +5,10 @@ export declare class TextValueCombo extends Widget { static EVENT_CHANGE: string; - populate(items: any): void; + clear(): void; + setText(text: string): void; + setValue(value: any): void; + setStatus(status: "success" | "warning" | "error"): void; + getValue(): any[]; + populate(items: any[]): void; } diff --git a/typescript/case/combo/popup.textvalue.ts b/typescript/case/combo/popup.textvalue.ts new file mode 100644 index 000000000..a3fe1b0d1 --- /dev/null +++ b/typescript/case/combo/popup.textvalue.ts @@ -0,0 +1,13 @@ +import { Pane } from "../../base/pane"; + +export declare class TextValueComboPopup extends Pane { + static xtype: string; + + static EVENT_CHANGE: string; + static EVENT_CLEAR: string; + static EVENT_CONFIRM: string; + + populate(items: any[]): void; + getValue(): any; + setValue(value: any): void; +} diff --git a/typescript/core/base.ts b/typescript/core/base.ts index 6182a0833..4d6550f4f 100644 --- a/typescript/core/base.ts +++ b/typescript/core/base.ts @@ -38,7 +38,9 @@ export interface _base { size: (collection: any) => number; - each: (collection: T[] | object | string, callback?: ((index: number, value: T) => void) | object | string, thisArg?: any) => any; + each(collection: ArrayLike, iteratee?: (index: number, value: T) => void, thisArg?: any): ArrayLike; + each(collection: T, iteratee?: (index: K, value: T[K]) => void, thisArg?: any): T; + each(collection: T, iteratee?: any, thisArg?: any): T; map: (collection: T[] | object | string | null | undefined, callback?: ((index: number, value: T) => U) | object | string, thisArg?: any) => U[]; diff --git a/typescript/core/widget.ts b/typescript/core/widget.ts index 4c1fc9d2f..5992ce01c 100644 --- a/typescript/core/widget.ts +++ b/typescript/core/widget.ts @@ -69,11 +69,6 @@ export interface _Widget extends _OB { */ _manualSetValid: boolean; - /** - * 渲染引擎 - */ - _renderEngine: RenderEngine; - _store(): void; // 生命周期函数 @@ -418,6 +413,11 @@ export declare class Widget extends OB { */ static registerRenderEngine(engine: RenderEngine): void; + /** + * 渲染引擎 + */ + static _renderEngine: RenderEngine; + /** * 出现loading的锁 */ @@ -476,11 +476,6 @@ export declare class Widget extends OB { */ _manualSetValid: boolean; - /** - * 渲染引擎 - */ - _renderEngine: RenderEngine; - _store(): void; // 生命周期函数 diff --git a/typescript/index.ts b/typescript/index.ts index a1b9831c9..cf63c604d 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -20,6 +20,7 @@ import { IconChangeButton } from "./case/button/icon/icon.change"; import { MultiSelectItem } from "./case/button/item.multiselect"; import { BubbleCombo } from "./case/combo/bubblecombo/combo.bubble"; import { TextValueCombo } from "./case/combo/combo.textvalue"; +import { TextValueComboPopup } from "./case/combo/popup.textvalue"; import { SmallTextValueCombo } from "./case/combo/combo.textvaluesmall"; import { SearchTextValueCombo } from "./case/combo/searchtextvaluecombo/combo.searchtextvalue"; import { SignEditor } from "./case/editor/editor.sign"; @@ -226,6 +227,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { ButtonGroup: typeof ButtonGroup; Combo: typeof Combo; TextValueCombo: typeof TextValueCombo; + TextValueComboPopup: typeof TextValueComboPopup; SmallTextValueCombo: typeof SmallTextValueCombo; BubbleCombo: typeof BubbleCombo; AllValueMultiTextValueCombo: typeof AllValueMultiTextValueCombo; @@ -464,6 +466,7 @@ export { MultiSelectBar, SelectList, TextValueCombo, + TextValueComboPopup, SmallTextValueCombo, Editor, IconLabel,