The constructor takes an object and renders the select.
+ +options = {
selector: 'Unique selector',
selected: 'Selected item',
placeholder: '...',
lable: '...'
items: [string|number|object],
darkTheme: true/false,
searchMode: true/false,
closeOnSelect: true/false,
nativeSelectMode: true/false,
listDisplayMode: true/false,
language: 'ru/en',
styles: {
head: {
background: '...',
},
list: {...},
chips: {...},
caret: {...},
placeholder: {...},
lable: {..},
},
event: '...',
url: 'http/...',
multiselect: true/false,
multiselectTag: true/false,
}
+
+Object accepting select settings.
+Private
Optional
btnButton, to control the select.
+Private
caretVariable for carriage control.
+Private
Optional
categoryTransferred categories.
+Optional
closeAn optional parameter that is responsible for the behavior of the select when opening, if closeOnSelect: false, +then when an element is selected in the selector, closing does not occur, +and you can select another element by default, closeOnSelect:true.
+Optional
darkAn optional parameter that is responsible for enabling a light / dark theme by default, the dark theme is set (darkTheme == true).
+Private
elementCreated HTML element.
+Optional
eventAn optional parameter that is responsible for the behavior of the select, passing to this parameter an event of the 'mouseenter' type, +select will open on hover.
+Private
indexesArray of indexes of selected elements.
+Optional
items*Required parameter (if no other way to get data (url) is specified), this is an array of elements, + which will be displayed in the select when selected.
+Optional
lableAn optional parameter that adds a lable before the select.
+Optional
languageOptional parameter responsible for the localization of some text elements.
+Private
listCreated list(ul), with class list.
+Optional
listAn optional parameter that is responsible for the behavior of the select when opening.
+Optional
multiselectAn optional parameter, which is responsible for the behavior of the select, adds the ability to select multiple elements. +Selected elements are rendered as plain text, separated by commas.
+Optional
multiselectAn optional parameter that is responsible for the behavior of the select, +for him, *** works only in a place with a multiselect connection.
+Optional
nativeAn optional parameter that is responsible for the behavior of the select when opened on mobile devices.
+Private
optionsSelect settings passed when creating an instance of the class.
+Optional
placeholderPlaceholder optional parameter to which the text of the select placeholder is passed.
+Private
randomUnique Id for elements.
+Optional
searchAn optional parameter that adds a live search on the select elements.
+Optional
selectedAn optional parameter, which is passed the element that will be selected initially in the select.
+Private
selectedSelected or an array of selected items from a list.
+Optional
selectorUnique selector - *mandatory parameter (indicator) that is set when creating a select.
+Optional
stylesAn optional parameter that is responsible for customizing the select elements, +objects with CSS properties for customizable elements are passed to it.
+Optional
urlRequired parameter (if no other way to get data (items) is specified), +data that comes from the backend in the format { id: "", title: "", value: ""}.
+Returns the indices of the selected element(s) as an array / empty array.
+ +A getter that returns the indexes of the selected element(s) of the select.
+Returns the selected element(s) as an array / element / null.
+ +Getter returning the selected element(s) of the select.
+adds the given element to the end of the list and redraws the list. Cannot be used when passing elements with categories.
+ +addItem
+added element.
+a method that allows you to change the placeholder in the search and the text that is displayed if there is no result.
+ +addLanguage
+the object in which the fields for connecting the language are located has two mandatory fields placeholder, textInListSearch, selectPlaceholder.
+Private
addPrivate
checkPrivate
closePrivate
closePrivate
displayPrivate
+Changes the display of a sheet with a selection as a modal window.
+ +displayMode
+parameter responsible for displaying the selection in the form of a modal window.
+Private
initPrivate
+Private method for initializing an instance of the ICgSelect class.
+ +init
+ +Private method. General initialization of the select. Obtaining tinctures and converting select elements.
+ +{
selector: '.cg-dropdown_one',
placeholder: 'Choose a car',
items: [
'BMW',
{
id: '213sade',
title: 'Opel',
value: 1,
},
'Mersedes',
'MAN',
'max',
],
darkTheme: true,
multiselect: true,
multiselectTag: true,
}
+
+passed select settings.
+Private
initPrivate
initPrivate
openPrivate
renderPrivate
renderPrivate
searchPrivate
selectGenerated using TypeDoc
Generated using TypeDoc
Creating a clear select button, with a single selection.
+place in the select that will be reassigned to ''.
+class instance CgSelect.
+the text that is rendered in the select.
+Generated using TypeDoc
Creating an Item Selector Button.
+instantiated class CgSelect.
+Optional
content: stringplaceholer passed from select settings.
+Optional
styles: IStyleoptional parameter. The object in which the settings for customizing parts of the select are located.
+Generated using TypeDoc
Finding and styling elements derived from the styles instance CgSelect
+instantiated class CgSelect.
+object in which there are settings for customizing parts of the select.
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Insert initial select text (before selection)
+ +returns the generated select element.
+the object in which the title of the select is located.
+select element where title will be inserted.
+Generated using TypeDoc
The behavior of the native (Multiple) select when choosing in a custom one.
+NodeList of native select.
+selected element in custom select.
+a special flag that adds / removes attributes from the native select.
+Generated using TypeDoc
Behavior of a native (single) select when choosing a custom one.
+NodeList native select.
+selected element in custom select.
+Generated using TypeDoc
The method that creates and is responsible for the behavior of the chips.
+ +returns the generated HTMLElement chips item.
+an object that contains settings and select elements.
+the name of the selected element to draw chips.
+index of the selected item to draw chips.
+unique id of the selected element.
+Generated using TypeDoc
The method that creates a search for elements in the select.
+ +Returns the rendered input element.
+unique value for input element.
+text in specific language passed from language.ts file
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
+ This component allows you to create a custom select. It offers more flexible + customization and use of select. Customization, multi-selection and live search by + elements are available. +
+ + +npm i cg-select
+
+
+
+ <button class="cg-dropdown"></button>
+
+ <button class="cg-dropdown cg-dropdown_categories"></button>
+
+ import { CGSelect } from 'cg-select';
const dropdown = new CGSelect({
selector: '.cg-dropdown_selector',
placeholder: 'Выберите авто',
items: [
'BMW',
{
id: '213sade',
title: 'Opel',
value: 1,
},
'Mersedes',
'MAN',
'Ferari',
],
});
+
+
+
+ + Same working example -- + https://cg-select.itguild.info/ +
++ + + + +
++ All documentation on CG-SELECT is located in the folder of the same name. The + documentation describes all methods and variables, there are also examples of passing + settings to select. You can also open it on the page with an example, or follow the link + below. +
+ + +git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Application Compatibility | +JS | +React | +Angular | +Vue | +
---|---|---|---|---|
CG-SELECT | ++ + | ++ + + | ++ + | ++ + | +
Comment | +Tested in Js applications and it worksуспешно. | +
+ Works only with a crutch in the form setTimeout()
+ |
+ not yet available | +not yet available | +
+ 16.12.2022 - release version 0.1.0!
+ 00.00.2023 - upgrade to version 0.2.1
+
Generated using TypeDoc
+cSettings for creating chips.
+A specific instance of a class.
+Array of indexes of selected elements.
+Select settings.
+Array with selected elements.
+Generated using TypeDoc
Receive Item Settings.
+The value of the passed element.
+Optional
categoryOptional parameter. Item group category.
+Optional
categoryOptional parameter. Array with elements.
+Generated using TypeDoc
Settings for select text, etc.
+Optional
darkAn optional parameter that is responsible for enabling a light/dark theme by default, the dark theme is set.
+Optional
indexesArray of indexes of selected elements.
+Optional
multiselectAn optional parameter that is responsible for the behavior of the select, +for him, *** works only in a place with a multiselect connection.
+Optional
placeholderPlaceholder optional parameter to which the text of the select placeholder is passed.
+Optional
selectedAn optional parameter, which is passed the element that will be selected initially in the select.
+Optional
selectedArray of selected items from the list.
+Generated using TypeDoc
Select settings.
+Optional
closeAn optional parameter that is responsible for the behavior of the select when opening, if closeOnSelect: false, +then when an element is selected in the selector, closing does not occur, +and you can select another element by default, closeOnSelect:true.
+Optional
darkAn optional parameter that is responsible for enabling a light / dark theme by default, the dark theme is set (darkTheme == true).
+Optional
eventAn optional parameter that is responsible for the behavior of the select, passing to this parameter an event of the 'mouseenter' type, +select will open on hover.
+Optional
items*Required parameter (if no other way to get data (url) is specified), this is an array of elements, + which will be displayed in the select when selected.
+Optional
lableAn optional parameter that adds a lable before the select.
+Optional
languageOptional parameter responsible for the localization of some text elements.
+Optional
listAn optional parameter that is responsible for the behavior of the select when opening.
+Optional
multiselectAn optional parameter, which is responsible for the behavior of the select, adds the ability to select multiple elements. +Selected elements are rendered as plain text, separated by commas.
+Optional
multiselectAn optional parameter that is responsible for the behavior of the select, +for him, *** works only in a place with a multiselect connection.
+Optional
nativeAn optional parameter that is responsible for the behavior of the select when opened on mobile devices.
+Optional
placeholderPlaceholder optional parameter to which the text of the select placeholder is passed.
+Optional
searchAn optional parameter that adds a live search on the select elements.
+Optional
selectedAn optional parameter, which is passed the element that will be selected initially in the select.
+Optional
selectorUnique selector - *mandatory parameter (indicator) that is set when creating a select.
+Optional
stylesAn optional parameter that is responsible for customizing the select elements, +objects with CSS properties for customizable elements are passed to it.
+Optional
urlRequired parameter (if no other way to get data (items) is specified), +data that comes from the backend in the format { id: "", title: "", value: ""}.
+Generated using TypeDoc
Style Settings.
+Optional
caretCarriage customization.
+Optional
chipsChips customization with selected elements.
+Optional
headSelect button customization.
+Optional
lableLable select customization.
+Optional
listSheet customization with a selection of elements.
+Optional
placeholderCustomization placeholder.
+Optional
searchSearch customization.
+Generated using TypeDoc
Generated using TypeDoc
Settings for adding languages.
+Search text.
+Default Select Text if no placeholder or selected element is specified.
+Text if no match.
+Generated using TypeDoc
Generated using TypeDoc
Utils module
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Const
Generated using TypeDoc
Const
Generated using TypeDoc
Description
This class implements the functionality of a custom select, with customization capabilities.
+ +Author
Ovsyanikov Maxim
+