diff --git a/src/mode/base-mode.ts b/src/mode/base-mode.ts index 25e40c9..da714f4 100644 --- a/src/mode/base-mode.ts +++ b/src/mode/base-mode.ts @@ -91,18 +91,20 @@ export abstract class BaseMode< */ get addable() { const data = this.getData(); - const { multiple } = this.options; + const { multiple, maxCount } = this.options; const drawItem = data.find((item) => item.properties.isDraw); if (!this.enabled) { return false; } - if (multiple || drawItem) { + if ((multiple && maxCount <= 0) || drawItem) { return true; } if (!multiple && this.addCount >= 1) { return false; } - + if (maxCount > 0 && data.length >= maxCount) { + return false; + } return true; } @@ -443,6 +445,7 @@ export abstract class BaseMode< keyboard: cloneDeep(DEFAULT_KEYBOARD_CONFIG), popup: true, helper: {}, + maxCount: -1, } as IBaseModeOptions; } diff --git a/src/typings/drawer.ts b/src/typings/drawer.ts index f9d2120..29f5238 100644 --- a/src/typings/drawer.ts +++ b/src/typings/drawer.ts @@ -37,6 +37,7 @@ export interface IBaseModeOptions { autoActive: boolean; multiple: boolean; helper: any | boolean; + maxCount: number; popup: PopupOptions | boolean; history: HistoryConfig | false; keyboard: KeyBoardConfig | false;