simp-select 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { ISimpleSelectLocale, ISimpleSelectOptions } from '../types/simpleSelect.types';
2
+ export declare const simpleSelectLocale: ISimpleSelectLocale;
3
+ export declare const simpleSelectionOptions: ISimpleSelectOptions;
4
+ export declare const nameSelect = "SimSel";
5
+ export declare const nameMark = "simple-select-init";
6
+ export declare const initClass = "SimpleSel";
@@ -0,0 +1,40 @@
1
+ import { ISimpleSelectOptions, ISimpleSelectProps } from './types/simpleSelect.types';
2
+ import { selectorType } from './types/item.types';
3
+ import { SimpleSelectItem } from './simpleSelectItem';
4
+ import './style.css';
5
+ export default class SimpleSelect {
6
+ callCount: number;
7
+ countInit: number;
8
+ $selects: SimpleSelectItem[];
9
+ options: ISimpleSelectOptions;
10
+ nameMarkTransform: string;
11
+ dataNameMark: string;
12
+ isNative: boolean;
13
+ constructor(selector: selectorType, options?: ISimpleSelectProps);
14
+ detectMobile(): void;
15
+ private init;
16
+ createMethods(select: SimpleSelectItem): {
17
+ getInstance: () => HTMLSelectElement;
18
+ reload(): void;
19
+ update(): void;
20
+ detach(): void;
21
+ };
22
+ setMethods(select: SimpleSelectItem): void;
23
+ setMethodsClear(select: SimpleSelectItem): void;
24
+ private build;
25
+ private detach;
26
+ rebuild(selectsItems: SimpleSelectItem): void;
27
+ getSelects(): SimpleSelectItem[];
28
+ getSelectFirst(): {
29
+ getInstance: () => HTMLSelectElement;
30
+ reload(): void;
31
+ update(): void;
32
+ detach(): void;
33
+ };
34
+ getSelectById(id: string): {
35
+ getInstance: () => HTMLSelectElement;
36
+ reload(): void;
37
+ update(): void;
38
+ detach(): void;
39
+ } | null;
40
+ }
@@ -0,0 +1,49 @@
1
+ /// <reference types="node" />
2
+ import { IItemLocalOptions, ISimpleSelectOptions } from './types/simpleSelect.types';
3
+ import { SimpleSelectItemDOM } from './simpleSelectItemDOM';
4
+ export declare class SimpleSelectItem extends SimpleSelectItemDOM {
5
+ closeOutsideHandler: (e: MouseEvent) => void;
6
+ closeEscHandler: (e: KeyboardEvent) => void;
7
+ changeListener: (e: Event) => void;
8
+ searchHandler: (e: Event) => void;
9
+ clickToggleOpen: (e: MouseEvent | KeyboardEvent) => void;
10
+ triggerSetup: (e: MouseEvent) => void;
11
+ confirmOkHandler: (e: MouseEvent) => void;
12
+ confirmNoHandler: (e: MouseEvent) => void;
13
+ selectAllHandler: (e: MouseEvent) => void;
14
+ resetAllHandler: (e: MouseEvent) => void;
15
+ closeHandler: (e: MouseEvent) => void;
16
+ handleResize: (e: MediaQueryList | null) => void;
17
+ mql: MediaQueryList | null;
18
+ countOpen: number;
19
+ multiDebounceTime: number;
20
+ timeoutDebounceId: NodeJS.Timeout | null;
21
+ constructor(select: HTMLSelectElement, options: ISimpleSelectOptions, localOptions: IItemLocalOptions);
22
+ init(): void;
23
+ private handleResizeInit;
24
+ private initAfterDom;
25
+ debounce<T extends (...args: never[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
26
+ confirmOkHandlerInit(e: MouseEvent): void;
27
+ confirmOkBuild(): void;
28
+ confirmNoHandlerInit(e: MouseEvent): void;
29
+ closeHandlerInit(e: MouseEvent): void;
30
+ selectAllHandlerInit(e: MouseEvent): void;
31
+ resetAllHandlerInit(e: MouseEvent): void;
32
+ triggerSetupInit(e: MouseEvent): void;
33
+ changeClickItem(item: HTMLLIElement): void;
34
+ multiDebounceChange(): void;
35
+ triggerInit(): void;
36
+ clickToggleOpenInit(e: MouseEvent | KeyboardEvent): void;
37
+ closeOutsideHandlerInit(e: MouseEvent): void;
38
+ closeEscHandlerInit(e: KeyboardEvent): void;
39
+ keyBoardChangeChecked(isDown: boolean): void;
40
+ searchHandlerInit(e: Event): void;
41
+ toggleOpenHandler(): void;
42
+ private changeListenerInit;
43
+ getSelect(): HTMLSelectElement;
44
+ protected handlerChangeChecked(): void;
45
+ protected createList(isCompare?: boolean): void;
46
+ private filterList;
47
+ inputSearchHandler(): void;
48
+ detachItem(): void;
49
+ }
@@ -0,0 +1,57 @@
1
+ import { IItemLocalOptions, ISimpleSelectOptions } from './types/simpleSelect.types';
2
+ import { IOptionItem } from './types/item.types';
3
+ export declare class SimpleSelectItemDOM {
4
+ options: ISimpleSelectOptions;
5
+ $select: HTMLSelectElement;
6
+ id: string;
7
+ titlePlaceholder: string;
8
+ isDisabled: boolean;
9
+ isMulti: boolean;
10
+ state: {
11
+ getState: (k?: string | undefined) => any;
12
+ setState: (k: string, val: any) => void;
13
+ subscribe(k: string, cb: any): () => void;
14
+ subscribeAll(cb: any): () => void;
15
+ unSubscribe(k: string, cb: any): void;
16
+ };
17
+ classSelectInit: string;
18
+ isNative: boolean;
19
+ elemWrap: HTMLDivElement;
20
+ elemTop: HTMLDivElement;
21
+ elemTopBody: HTMLDivElement;
22
+ elemDropDown: HTMLDivElement | null;
23
+ elemDropDownClose: HTMLButtonElement | null;
24
+ elemListBody: HTMLUListElement | null;
25
+ elemInputSearch: HTMLInputElement | null;
26
+ elemTitle: HTMLDivElement;
27
+ confirmOk: HTMLButtonElement | null;
28
+ confirmNo: HTMLButtonElement | null;
29
+ elemControl: HTMLDivElement | null;
30
+ elemSelectAll: HTMLButtonElement | null;
31
+ elemResetAll: HTMLButtonElement | null;
32
+ cloneClasses: string;
33
+ isShowCheckbox: boolean;
34
+ bodyLiHTMLBeforeFromSelect: null | string;
35
+ bodyLiHTMLAfterFromSelect: null | string;
36
+ isFloatWidth: boolean;
37
+ bodyOpenClass: string;
38
+ constructor(select: HTMLSelectElement, options: ISimpleSelectOptions, localOptions: IItemLocalOptions);
39
+ optionOverride(): void;
40
+ initDom(): void;
41
+ toggleTabIndex(isOpen: boolean): void;
42
+ updateHTML(): void;
43
+ private createHTML;
44
+ private createControlHTML;
45
+ private createIcon;
46
+ private createDropDown;
47
+ private createIsConfirmInMultiHTML;
48
+ private createTitleHTML;
49
+ protected createListHTML(): void;
50
+ private createInputHTML;
51
+ getChecked(): IOptionItem[];
52
+ private createLi;
53
+ private createLiBody;
54
+ protected handlerChangeChecked(): void;
55
+ protected createList(_isCompare: boolean): void;
56
+ protected inputSearchHandler(): void;
57
+ }
@@ -0,0 +1,24 @@
1
+ export interface IOptionItem {
2
+ id: string;
3
+ title: string;
4
+ value: string | null;
5
+ checked: boolean;
6
+ disabled: boolean;
7
+ position: number;
8
+ isShowFilter: boolean;
9
+ }
10
+ export interface IOptionItems {
11
+ idGroup: string;
12
+ isGroup: boolean;
13
+ titleGroup?: string;
14
+ isDisabledGroup?: boolean;
15
+ items: IOptionItem[];
16
+ isShowFilter: boolean;
17
+ }
18
+ export interface ICreateLiReturn {
19
+ result: string;
20
+ countShow: number;
21
+ countChecked: number;
22
+ countCheckedFull: number;
23
+ }
24
+ export type selectorType = string | HTMLSelectElement | NodeListOf<HTMLSelectElement> | HTMLSelectElement[];
@@ -0,0 +1,44 @@
1
+ import { SimpleSelectItem } from '../simpleSelectItem';
2
+ export interface ISimpleSelectLocale {
3
+ noSearch: string;
4
+ searchText: string;
5
+ title: string;
6
+ selected: string;
7
+ all: string;
8
+ ok: string;
9
+ cansel: string;
10
+ resetAll: string;
11
+ selectAll: string;
12
+ }
13
+ export interface ISimpleSelectOptions {
14
+ countShowSelected: number;
15
+ isConfirmInMulti: boolean;
16
+ isConfirmInMultiOkClickOutside: boolean;
17
+ isSearch: boolean;
18
+ isSearchInDropdown: boolean;
19
+ nativeOnDevice: string[];
20
+ locale: ISimpleSelectLocale;
21
+ debounceTime?: number;
22
+ floatWidth?: number;
23
+ sepChars: string;
24
+ selectAll: boolean;
25
+ selectAllAfterClose: boolean;
26
+ resetAll: boolean;
27
+ resetAllAfterClose: boolean;
28
+ isCloneClass: boolean;
29
+ isUp: boolean;
30
+ detectNative?: () => boolean;
31
+ callbackInitialization?: (item: SimpleSelectItem) => void;
32
+ callbackInitialized?: (item: SimpleSelectItem) => void;
33
+ callbackOpen?: (item: SimpleSelectItem) => void;
34
+ callbackClose?: (item: SimpleSelectItem) => void;
35
+ callbackDestroyInit?: (item: SimpleSelectItem) => void;
36
+ callbackDestroy?: (item: SimpleSelectItem) => void;
37
+ callbackChangeSelect?: (e: Event, item: SimpleSelectItem) => void;
38
+ changeBodyLi?: (liBody: HTMLDivElement, option: HTMLOptionElement) => HTMLElement | string;
39
+ }
40
+ export interface IItemLocalOptions {
41
+ id: string;
42
+ isNative: boolean;
43
+ }
44
+ export type ISimpleSelectProps = Partial<ISimpleSelectOptions>;
@@ -0,0 +1,10 @@
1
+ import { IOptionItems } from '../types/item.types';
2
+ export declare const toCamelCase: (input: string) => string;
3
+ export declare const createDataAttr: (name: string) => string;
4
+ export declare const ifTrueDataAttr: (attr: string | null) => boolean;
5
+ export declare function triggerInputEvent(element: HTMLElement, type?: string): void;
6
+ export declare const getCreateListItem: (item: HTMLSelectElement | HTMLOptGroupElement, idGroup: string, isGroup: boolean) => IOptionItems;
7
+ export declare const getClass: (cls: string, mod?: boolean, classInit?: string) => string;
8
+ export declare const compareObj: <T1, T2>(obj1: T1, obj2: T2) => boolean;
9
+ export declare const cloneObj: <T>(obj: T) => T;
10
+ export declare const createButton: () => HTMLButtonElement;
@@ -0,0 +1,7 @@
1
+ export declare function store<T>(obj: T): {
2
+ getState: (k?: string) => any;
3
+ setState: (k: string, val: any) => void;
4
+ subscribe(k: string, cb: any): () => void;
5
+ subscribeAll(cb: any): () => void;
6
+ unSubscribe(k: string, cb: any): void;
7
+ };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "simp-select",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "simp-select - this plugin replaces the select",
5
5
  "main": "dist/simpleSelect.js",
6
- "types": "src/types/simpleSelect.types.ts",
6
+ "types": "dist/simpleSelect.d.ts",
7
7
  "module": "dist/simpleSelect.js",
8
8
  "prepublish": "npm run build",
9
9
  "scripts": {
package/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "target": "ESNext",
4
4
  "module": "CommonJS",
5
5
  "lib": ["ESNext", "dom"],
6
- // "declaration": true,
6
+ "declaration": true,
7
7
  "outDir": "dist",
8
8
  "strict": true,
9
9
  "esModuleInterop": true