Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~zhenfei.li/fineui into es6

# Conflicts:
#	src/base/single/input/file.js
#	src/case/combo/textvaluecombo/combo.textvalue.js
#	src/core/platform/web/dom.js
#	src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
#	src/widget/multiselect/multiselect.loader.nobar.js
#	src/widget/multiselect/search/multiselect.search.insert.pane.js
#	src/widget/multiselect/search/multiselect.search.loader.js
#	src/widget/multiselectlist/multiselectlist.insert.nobar.js
#	src/widget/singleslider/singleslider.js
es6
Zhenfei.Li 2 years ago
parent
commit
79de417f3b
  1. 6
      package.json
  2. 4
      src/base/single/input/file.js
  3. 25
      src/case/combo/textvaluecombo/combo.textvalue.js
  4. 3
      src/core/utils/dom.js
  5. 17
      src/widget/dynamicdatetime/dynamicdatetime.timeselect.js
  6. 14
      src/widget/multiselect/multiselect.loader.nobar.js
  7. 2
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  8. 74
      src/widget/multiselect/search/multiselect.search.loader.js
  9. 4
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  10. 6
      src/widget/singleslider/singleslider.js
  11. 1
      typescript/case/combo/combo.textvalue.ts
  12. 2
      webpack/attachments.js

6
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",

4
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]}`);
}
});
};

25
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,

3
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,
};

17
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: [
@ -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,
}
],
}

14
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);

2
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);

74
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() {

4
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);

6
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;
}

1
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;

2
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([

Loading…
Cancel
Save