sync
This commit is contained in:
1 parent
5cb14ffd44
commit
05ce7035dd
15 files changed
+946
-460
No files matched your search
+11
-24
@@ -1,12 +1,12 @@
|
||||
import './css/dropdown.scss';
|
||||
import { r as lang } from "../utility/lgres";
|
||||
import { contains, nullOrEmpty } from "../utility/strings";
|
||||
import { mergeOptions, global, isPositive, throttle } from "../utility";
|
||||
import { createElement } from "../functions";
|
||||
import { global, isPositive, throttle } from "../utility";
|
||||
import { createElement, mergeOptions } from "../functions";
|
||||
import { createCheckbox } from "./checkbox";
|
||||
import { createIcon } from "./icon"
|
||||
|
||||
/** @import { DropdownOptions } from './dropdown.types' */
|
||||
/** @import { DropdownOptions, DropdownItem, Dropdown as IDropdown, MarkRequired } from '../types' */
|
||||
|
||||
/** @satisfies {Partial<DropdownOptions>} */
|
||||
const DEFAULT_OPTIONS = {
|
||||
@@ -17,7 +17,7 @@ const DEFAULT_OPTIONS = {
|
||||
maxLength: 500
|
||||
};
|
||||
|
||||
/** @typedef {import('../types').MarkRequired<DropdownOptions, keyof typeof DEFAULT_OPTIONS>} ResolvedDropdownOptions */
|
||||
/** @typedef {MarkRequired<DropdownOptions, keyof typeof DEFAULT_OPTIONS>} ResolvedDropdownOptions */
|
||||
|
||||
const SymbolDropdown = Symbol.for('ui-dropdown');
|
||||
const DropdownItemHeight = 30;
|
||||
@@ -142,19 +142,8 @@ function getValue(it, valuekey, textkey) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据项基础类型
|
||||
* @typedef DropdownItemBase
|
||||
* @property {0 | 1 | 2 | undefined} [__checked] 是否选中
|
||||
* @property {string} [__p] 父节点 Id
|
||||
* @property {number} [__level] 层级
|
||||
* @interface
|
||||
* @implements {IDropdown}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 数据项类型
|
||||
* @typedef {DropdownItemBase & Object.<string, any>} DropdownItem
|
||||
*/
|
||||
|
||||
export class Dropdown {
|
||||
_var = {
|
||||
/** @type {ResolvedDropdownOptions} */
|
||||
@@ -180,24 +169,22 @@ export class Dropdown {
|
||||
dropHeight: 0
|
||||
};
|
||||
|
||||
/** @type {(() => DropdownItem[]) | undefined} */
|
||||
/** @type {((this: IDropdown) => DropdownItem[]) | undefined} */
|
||||
sourceFilter;
|
||||
/** @type {((list: DropdownItem[]) => void) | undefined} */
|
||||
/** @type {((this: IDropdown, list: DropdownItem[]) => void) | undefined} */
|
||||
onSelectedList;
|
||||
/** @type {((it: DropdownItem | undefined) => void) | undefined} */
|
||||
/** @type {((this: IDropdown, it: DropdownItem | undefined) => void) | undefined} */
|
||||
onSelected;
|
||||
/** @type {((this: Dropdown) => void) | undefined} */
|
||||
/** @type {((this: IDropdown) => void) | undefined} */
|
||||
onExpanded;
|
||||
/** @type {((this: Dropdown) => void) | undefined} */
|
||||
/** @type {((this: IDropdown) => void) | undefined} */
|
||||
onCollapsed;
|
||||
|
||||
/**
|
||||
* @param {DropdownOptions} [options]
|
||||
*/
|
||||
constructor(options) {
|
||||
if (options != null) {
|
||||
this._var.options = mergeOptions(DEFAULT_OPTIONS, options);
|
||||
}
|
||||
this._var.options = mergeOptions(DEFAULT_OPTIONS, options);
|
||||
const opts = this._var.options;
|
||||
const getText = opts.getText;
|
||||
if (typeof getText === 'function') {
|
||||
|
||||
Reference in new issue
Block a user