simp-select 1.0.0

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,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
+ }
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ :root{--simpS_bg:#fff;--simpS_pad_hor:15px;--simpS_height_top:40px;--simpS_color:#27272a;--simpS_color_light:#eae9e9;--simpS_color_cheked:#d9d7d7;--simpS_color_yes:green;--simpS_color_no:red;--simpS_color_placeholder:#5d5c5c;--simpS_color_dis:#8b8b8b;--simpS_radius:4px;--simpS_f_size:16px;--simpS_f_shadow:0 0 3px 0 var(--simpS_color);--simpS_size_check:20px;--simpS_li_h:36px;--simpS_btn_h:34px;--simpS_btn_bg:#f9f9f9;--simpS_btn_bg_reverse:#eeecec}.SimpleSel{-webkit-box-sizing:border-box;box-sizing:border-box;color:#27272a;color:var(--simpS_color);font-size:16px;font-size:var(--simpS_f_size);position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.SimpleSel--disabled{color:#8b8b8b;color:var(--simpS_color_dis);opacity:.8}.SimpleSel *,.SimpleSel :after,.SimpleSel :before,.SimpleSel__select_init{-webkit-box-sizing:border-box;box-sizing:border-box}.SimpleSel__select_init{height:100%;opacity:0;position:absolute;right:0;top:0;width:100%}.SimpleSel__select_init--native{z-index:5}.SimpleSel__bottom_control,.SimpleSel__control{-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-ms-flex-line-pack:center;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-content:center;align-items:center;-webkit-appearance:none;background-color:#f9f9f9;background-color:var(--simpS_btn_bg);border:none;border-radius:0;color:inherit;cursor:pointer;display:-webkit-box;display:-ms-flexbox;display:flex;font:inherit;height:34px;height:var(--simpS_btn_h);justify-content:center;line-height:normal;margin:0;outline:none;overflow:visible;padding:1px 10px;text-align:center;width:auto}.SimpleSel__bottom_control:hover,.SimpleSel__control:hover{background-color:#eeecec;background-color:var(--simpS_btn_bg_reverse)}.SimpleSel__list_item_icon,.SimpleSel__reset_all__icon,.SimpleSel__select_all__icon{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;border:1px solid;border-radius:4px;border-radius:var(--simpS_radius);display:-webkit-box;display:-ms-flexbox;display:flex;height:20px;height:var(--simpS_size_check);justify-content:center;margin-right:7px;position:relative;width:20px;width:var(--simpS_size_check)}.SimpleSel__list_item_icon:before,.SimpleSel__select_all__icon:before{border:solid;border-width:0 2px 2px 0;content:"";display:block;height:11px;height:calc(var(--simpS_size_check)/2 + 1px);left:4px;top:1px;-webkit-transform:rotate(45deg) translate(-17%,-10%);transform:rotate(45deg) translate(-17%,-10%);-webkit-transition:all .25s;transition:all .25s;width:6.66667px;width:calc(var(--simpS_size_check)/3)}.SimpleSel__top{position:relative}.SimpleSel__top_body{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:justify;-ms-flex-pack:justify;align-items:center;background-color:#fff;background-color:var(--simpS_bg);border:2px solid;border-radius:4px;border-radius:var(--simpS_radius);color:currentColor;cursor:pointer;display:-webkit-box;display:-ms-flexbox;display:flex;height:40px;height:var(--simpS_height_top);justify-content:space-between;padding:5px 0 5px 15px;padding:5px 0 5px var(--simpS_pad_hor);position:relative}.SimpleSel--disabled .SimpleSel__top_body{cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.SimpleSel__top_body:focus-visible{-webkit-box-shadow:0 0 3px 0 #27272a;box-shadow:0 0 3px 0 #27272a;-webkit-box-shadow:var(--simpS_f_shadow);box-shadow:var(--simpS_f_shadow)}.SimpleSel__title{-webkit-box-flex:1;-ms-flex:1;flex:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.SimpleSel__icon{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:40px;height:var(--simpS_height_top);justify-content:center;position:relative;width:40px;width:var(--simpS_height_top)}.SimpleSel__icon:after{border-bottom:2px solid;border-right:2px solid;content:"";display:inline;height:.5em;left:50%;position:absolute;top:calc(50% - 2px);-webkit-transform:rotate(45deg) translate(-50%,-50%);transform:rotate(45deg) translate(-50%,-50%);-webkit-transform-origin:left top;transform-origin:left top;-webkit-transition:transform .25s,top .25s;transition:transform .25s,top .25s;width:.5em}.SimpleSel--open .SimpleSel__icon:after{top:calc(50% + 2px);-webkit-transform:rotate(225deg) translate(-50%,-50%);transform:rotate(225deg) translate(-50%,-50%)}.SimpleSel--single[data-count-checked-full="0"] .SimpleSel__title,.SimpleSel__list_item--not_value,.SimpleSel__title--placeholder{color:#5d5c5c;color:var(--simpS_color_placeholder)}.SimpleSel__body{background-color:#fff;background-color:var(--simpS_bg);border:1px solid;border-radius:4px;border-radius:var(--simpS_radius);max-height:0;opacity:0;overflow:hidden;overflow-y:auto;position:absolute;-webkit-transition:max-height .25s,opacity .1s;transition:max-height .25s,opacity .1s;width:100%;z-index:3}.SimpleSel:not(.SimpleSel--up) .SimpleSel--multi{margin-top:2px;top:100%}.SimpleSel--up:not(.SimpleSel--float) .SimpleSel__body{bottom:100%;margin-bottom:2px}.SimpleSel--open .SimpleSel__body{max-height:230px;opacity:1}.SimpleSel__search{border-radius:4px;border-radius:var(--simpS_radius);padding:2px 15px;padding:2px var(--simpS_pad_hor);width:100%}.SimpleSel__search--top{display:none;height:100%;left:0;opacity:0;position:absolute;top:0}.SimpleSel--open .SimpleSel__search--top{display:block;opacity:1}.SimpleSel__search--dropdown{border:none;border-bottom:1px solid;border-radius:0;height:34px;height:var(--simpS_btn_h)}.SimpleSel__controls{border-bottom:1px solid;display:-webkit-box;display:-ms-flexbox;display:flex}.SimpleSel__control{-webkit-box-flex:1;-ms-flex:1;flex:1}.SimpleSel__control+.SimpleSel__control{border-left:1px solid}.SimpleSel__select_all__icon{border-color:green;border-color:var(--simpS_color_yes);border-radius:50%;color:#d9d7d7;color:var(--simpS_color_cheked)}.SimpleSel[data-count-checked-full="0"] .SimpleSel__select_all__icon{color:#eae9e9;color:var(--simpS_color_light)}.SimpleSel[data-check-all-multi=yes] .SimpleSel__select_all__icon{color:green;color:var(--simpS_color_yes)}.SimpleSel__reset_all__icon{border-radius:50%;color:red;color:var(--simpS_color_no);position:relative}.SimpleSel__reset_all__icon:after,.SimpleSel__reset_all__icon:before{background-color:currentColor;content:" ";height:60%;left:8px;left:calc(var(--simpS_f_size)/2);position:absolute;width:2px}.SimpleSel__reset_all__icon:before{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.SimpleSel__reset_all__icon:after{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.SimpleSel__bottom_controls{border-top:1px solid;bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:5px;position:sticky}.SimpleSel__bottom_control--hide{display:none}.SimpleSel__bottom_control{-webkit-box-flex:1;-ms-flex:1;flex:1}.SimpleSel__bottom_control--ok{text-transform:uppercase}.SimpleSel__bottom_control+.SimpleSel__bottom_control{border-left:1px solid}.SimpleSel__list{list-style-type:none;margin:0;padding:0}.SimpleSel__group_items:not(:first-child){margin-top:5px}.SimpleSel__group_title{background-color:#eae9e9;background-color:var(--simpS_color_light);display:block;font-size:1.02em;font-weight:700;margin-bottom:2px;padding:6px 10px}.SimpleSel__group{list-style-type:none;margin:0;padding:0}.SimpleSel__list_item{cursor:pointer}.SimpleSel__list_item:not(:last-child){border-bottom:1px solid #eae9e9;border-bottom:1px solid var(--simpS_color_light)}.SimpleSel__list_item--disabled{cursor:default;opacity:.5}.SimpleSel__list_item_body{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;min-height:36px;min-height:var(--simpS_li_h);padding:5px 15px;padding:5px var(--simpS_pad_hor)}.SimpleSel__list_item_body:hover{background-color:#eae9e9;background-color:var(--simpS_color_light)}.SimpleSel--single .SimpleSel__list_item--checked{background-color:#d9d7d7;background-color:var(--simpS_color_cheked)}.SimpleSel__list_item:not(.SimpleSel__list_item--checked) .SimpleSel__list_item_icon:before{height:0;opacity:0;width:0}.SimpleSel__close{display:none}.SimpleSel--body_open{overflow:hidden;position:relative}.SimpleSel--float .SimpleSel__body{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:none;-ms-flex-direction:column;flex-direction:column;left:50%;max-height:90%;max-width:90%;overflow:hidden;overflow-y:auto;position:fixed;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.SimpleSel--open{z-index:7}.SimpleSel--float .SimpleSel__bottom_control--hide,.SimpleSel--float.SimpleSel--open .SimpleSel__body{display:-webkit-box;display:-ms-flexbox;display:flex}.SimpleSel--float .SimpleSel__list{-webkit-box-flex:1;-ms-flex:1;flex:1}
@@ -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 ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "simp-select",
3
+ "version": "1.0.0",
4
+ "description": "simp-select - this plugin replaces the select",
5
+ "main": "dist/simpleSelect.js",
6
+ "types": "dist/simpleSelect.d.ts",
7
+ "module": "dist/simpleSelect.js",
8
+ "prepublish": "npm run build",
9
+ "scripts": {
10
+ "dev": "webpack --env development --watch",
11
+ "build": "webpack --env production"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/yura-brd/SimpSelect"
16
+ },
17
+ "keywords": [
18
+ "webpack",
19
+ "js",
20
+ "javascript",
21
+ "library",
22
+ "es6",
23
+ "commonjs",
24
+ "BrooonS/timezz.git",
25
+ "plugin",
26
+ "typescript",
27
+ "ui"
28
+ ],
29
+ "author": "Yurii Kopot <yura.brd@gmail.com> (https://yu-k.site/)",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/yura-brd/SimpSelect/issues"
33
+ },
34
+ "homepage": "https://github.com/yura-brd/SimpSelect#readme",
35
+ "devDependencies": {
36
+ "@babel/core": "^7.22.20",
37
+ "@babel/preset-env": "^7.22.20",
38
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
39
+ "@typescript-eslint/parser": "^6.7.0",
40
+ "babel-loader": "^9.1.3",
41
+ "css-loader": "^6.8.1",
42
+ "css-minimizer-webpack-plugin": "^5.0.1",
43
+ "eslint": "^8.49.0",
44
+ "eslint-config-airbnb-base": "^15.0.0",
45
+ "eslint-config-airbnb-typescript": "^17.1.0",
46
+ "eslint-plugin-import": "^2.28.1",
47
+ "eslint-plugin-jsx-a11y": "^6.7.1",
48
+ "eslint-webpack-plugin": "^4.0.1",
49
+ "html-webpack-plugin": "^5.5.3",
50
+ "mini-css-extract-plugin": "^2.7.6",
51
+ "postcss-loader": "^7.3.3",
52
+ "postcss-preset-env": "^9.1.3",
53
+ "ts-loader": "^9.4.4",
54
+ "typescript": "^5.2.2",
55
+ "webpack": "^5.88.2",
56
+ "webpack-cli": "^5.1.4"
57
+ }
58
+ }
@@ -0,0 +1,42 @@
1
+ import { ISimpleSelectLocale, ISimpleSelectOptions } from '../types/simpleSelect.types';
2
+
3
+ export const simpleSelectLocale: ISimpleSelectLocale = {
4
+ noSearch: 'No matches for',
5
+ searchText: 'Search',
6
+ title: 'Select',
7
+ selected: 'Selected:',
8
+ all: 'all',
9
+ ok: 'Ok',
10
+ cansel: 'Cansel',
11
+
12
+ selectAll: 'Select all',
13
+ resetAll: 'Reset all',
14
+ };
15
+ export const simpleSelectionOptions: ISimpleSelectOptions = {
16
+ isSearch: true,
17
+ isSearchInDropdown: false,
18
+
19
+ countShowSelected: 2,
20
+ isConfirmInMulti: false,
21
+ isConfirmInMultiOkClickOutside: false,
22
+
23
+ nativeOnDevice: ['Android', 'BlackBerry', 'iPhone', 'iPad', 'iPod', 'Opera Mini', 'IEMobile', 'Silk'],
24
+ locale: simpleSelectLocale,
25
+
26
+ sepChars: ',',
27
+ isUp: false,
28
+
29
+ floatWidth: 767,
30
+ isCloneClass: true,
31
+ selectAll: false,
32
+ selectAllAfterClose: true,
33
+ resetAll: false,
34
+ resetAllAfterClose: true,
35
+
36
+ };
37
+
38
+ export const nameSelect = 'SimSel';
39
+ const markPrefix = 'simple-select-';
40
+ export const nameMark = `${markPrefix}init`;
41
+
42
+ export const initClass = 'SimpleSel';
@@ -0,0 +1,256 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport"
6
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
+ <title>Document</title>
9
+
10
+ <link rel="stylesheet" href="../style.css" />
11
+
12
+ <script src="../simpleSelect.js"></script>
13
+
14
+ </head>
15
+
16
+ <style>
17
+
18
+ #app {
19
+ /* temp*/
20
+ width: 250px;
21
+ margin: 0 auto;
22
+ }
23
+
24
+ #app {
25
+ margin-bottom: 30px;
26
+ border-bottom: 1px solid;
27
+ text-align: center;
28
+ padding-bottom: 10px;
29
+ }
30
+
31
+ .items {
32
+ display: flex;
33
+ flex-wrap: wrap;
34
+ justify-content: center;
35
+ gap: 10px;
36
+ margin: 20px auto;
37
+ max-width: 600px;
38
+ }
39
+ .item {
40
+ width: 250px;
41
+ }
42
+ </style>
43
+ <body>
44
+ <div id="app"></div>
45
+
46
+ <div class="items">
47
+ <div class="item">
48
+ <select id="select_first"
49
+ disabled
50
+ multiple>
51
+ <option value="a1">a 1</option>
52
+ <option value="a2">a 2</option>
53
+ <option value="a3">a 3</option>
54
+ <option value="a4">a 4</option>
55
+ <option value="a5">a 5</option>
56
+ </select>
57
+ </div>
58
+ <div class="item">
59
+ <select multiple
60
+ data-simple-placeholder="custom placeholder"
61
+ data-simple-is-confirm="true"
62
+ data-simple-count-shows-selected="3">
63
+ <option value="a1"
64
+ data-simple-html-before="<span>|before| </span>"
65
+ data-simple-html-after="<span> |after|</div>"
66
+ >b 1</option>
67
+ <option value="a22" disabled="disabled">b 2 dis</option>
68
+ <option value="a3">b 3</option>
69
+ <option value="a4">b 4</option>
70
+ <option value="a5">b 5</option>
71
+ </select>
72
+ </div>
73
+ <div class="item" >
74
+ <select id="select_second"
75
+ data-simple-is-confirm="false"
76
+
77
+ data-simple-reset-all="false"
78
+ data-simple-select-all="true"
79
+ data-simple-item-html-before="<span>before</span>"
80
+ multiple data-simple-debounce-time="1000">
81
+ <optgroup label="Группа 1">
82
+ <option value="1.1">multiple Опция 1.1</option>
83
+ </optgroup>
84
+ <optgroup label="Группа 2">
85
+ <option value="2.1">multiple Опция 2.1</option>
86
+ <option value="2.2">multiple Опция 2.2</option>
87
+ </optgroup>
88
+ <optgroup label="Группа 3" disabled>
89
+ <option value="3.1">multiple Опция 3.1</option>
90
+ <option value="3.2">multiple Опция 3.2</option>
91
+ <option value="3.3">multiple Опция 3.3</option>
92
+ </optgroup>
93
+ </select>
94
+ </div>
95
+
96
+ <div class="item">
97
+ <select
98
+ data-simple-show-checkbox="true"
99
+ class="color_red"
100
+ data-simple-add-classes="class1"
101
+
102
+ data-simple-select-search="false"
103
+ >
104
+ <optgroup label="Группа 1">
105
+ <option value="1">Опция 1.1</option>
106
+ </optgroup>
107
+ <optgroup label="Группа 2">
108
+ <option value="1">Опция 2.1</option>
109
+ <option value="1">Опция 2.2</option>
110
+ </optgroup>
111
+ <optgroup label="Группа 3" disabled>
112
+ <option value="1">Опция 3.1</option>
113
+ <option value="1">Опция 3.2</option>
114
+ <option value="1">Опция 3.3</option>
115
+ </optgroup>
116
+ </select>
117
+ </div>
118
+
119
+ <select
120
+ data-simple-add-classes="class1 class2"
121
+ data-simple-item-html-before="<div>before</div>"
122
+ data-simple-item-html-after="<div>after</div>"
123
+ data-simple-select-search-dropdown="true"
124
+ data-simple-up="true"
125
+ >
126
+ <option>Опция 5.1</option>
127
+ <option>Опция 5.2</option>
128
+ </select>
129
+
130
+ <!--
131
+
132
+ <select
133
+ data-simple-select-search
134
+ data-simple-select-search-dropdown
135
+ data-simple-count-shows-selected="3"
136
+ data-simple-is-confirm="true" // only multiselect
137
+ data-simple-debounce-time // only multiselect
138
+ data-simple-placeholder="text"
139
+ data-simple-reset-all="true" // only multiselect
140
+ data-simple-select-all="true" // only multiselect
141
+ data-simple-show-checkbox="true" // only not multiselect
142
+
143
+ data-simple-item-html-before="<div>before</div>"
144
+ data-simple-item-html-after="<div>after</div>"
145
+ data-simple-add-classes="class1 class2"
146
+
147
+ data-simple-float-width="1000"
148
+ data-simple-up="true"
149
+
150
+ ></select>
151
+ -->
152
+ <!--
153
+ <div class="wrapper">
154
+ <select></select>
155
+ <div class="wrapper__top">
156
+ <div class="wrapper__top_body"></div>
157
+ *? <div class="wrapper__search"></div>
158
+ </div>
159
+ * <div class="wrapper__body">
160
+ ? <div class="wrapper__search"></div>
161
+ ? <div class="wrapper__setting"></div>
162
+ <div class="wrapper__list_items">
163
+ тут или список или группа списков
164
+ </div>
165
+ ? <div class="wrapper__setting_bottom"></div>
166
+ </div>
167
+ </div>
168
+ -->
169
+ </div>
170
+
171
+ <script>
172
+
173
+ const sel = new SimpleSelect('select', {
174
+ callbackOpen: (item) => {
175
+ console.log('open', item);
176
+ },
177
+ callbackClose: (item) => {
178
+ console.log('close', item);
179
+ },
180
+ callbackDestroy: (item) => {
181
+ console.log('callbackDestroy', item);
182
+ },
183
+ // detectNative: () => {
184
+ // return false;
185
+ // },
186
+ callbackChangeSelect: (e, that) => {
187
+ console.group();
188
+ console.log(e);
189
+ console.log(that);
190
+ console.groupEnd();
191
+ },
192
+
193
+ // isUp: true,
194
+ // sepChars: ',',
195
+ // // changeBodyLi: (liBody:HTMLDivElement, option: HTMLOptionElement) => {
196
+ // return liBody
197
+ // }
198
+ // debounceTime: 2000
199
+ })
200
+ // @ts-ignore
201
+ window['sel'] = sel;
202
+
203
+ setTimeout(() => {
204
+ console.log('first', sel.getSelectFirst());
205
+
206
+ const second = document.getElementById('select_second');
207
+
208
+ const id = second.getAttribute('data-simple-select-init');
209
+
210
+ console.log('by id', sel.getSelectById(id));
211
+ }, 1500)
212
+
213
+ const app = document.querySelector('#app')
214
+ const select = document.createElement('select');
215
+ select.innerHTML = '<option value="1">1</option><option value="2">2</option>'
216
+ app.innerHTML = `
217
+ <div>
218
+ <select class="addSelect">
219
+ <option selected>new option 0</option>
220
+ <option value='1'>new option</option>
221
+ <option value='2'>new option2</option>
222
+ <option value='3'>new option3</option>
223
+ <select>
224
+ </div>
225
+ `
226
+ app.append(select);
227
+ const sel3 = new SimpleSelect(select)
228
+ window['sel3'] = sel3;
229
+
230
+ setTimeout(() => {
231
+ const sel2 = new SimpleSelect('.addSelect', {
232
+ locale: {
233
+ noSearch: 'Не найдено: ',
234
+ searchText: 'Поиск',
235
+ title: 'Выбрать',
236
+ selected: 'Выбрано:',
237
+ all: 'все',
238
+ cansel: 'Отмена',
239
+ ok: 'OK',
240
+ resetAll: 'reset all',
241
+ selectAll: 'select all'
242
+ }
243
+ })
244
+ window['sel2'] = sel2;
245
+ }, 500)
246
+
247
+ // setupCounter(document.querySelector<HTMLButtonElement>('#counter')!)
248
+
249
+ </script>
250
+
251
+
252
+
253
+
254
+
255
+ </body>
256
+ </html>