Debuging and repare code

This commit is contained in:
2023-01-17 20:21:43 +03:00
parent bf9dc01ad5
commit 8897e12464
10 changed files with 306 additions and 100 deletions

View File

@ -230,10 +230,11 @@ export class CGSelect implements ICgSelect {
this.items = [];
if (!this.items && this.url) {
if (this.url && !items) {
this.renderUrl();
return;
}
createSelected;
items.forEach((dataItem: any, index: number) => {
@ -373,12 +374,9 @@ export class CGSelect implements ICgSelect {
* @description Рендер елементов в селекте переданных с URL и их настойка
*/
private async renderUrl() {
if (this.items || !this.url) {
return;
}
const response = await fetch(this.url);
const response = await fetch(this.url!);
const dataUrl = await response.json();
console.log(dataUrl);
const nativeSelect = createNativeSelect();
@ -554,7 +552,10 @@ export class CGSelect implements ICgSelect {
const select: HTMLElement | null | undefined = this.element?.querySelector('.selected');
const nativeOption = this.element!.querySelectorAll('.nativeSelect__nativeOption');
let selectedItemsClear: ISelectedItems;
let selectedItemsClear: ISelectedItems = {
placeholder: this.placeholder!,
selected: this.selected!,
};
const ulMultipul = document.createElement('ul');

View File

@ -1,4 +1,4 @@
import { nativeOptionMultiple } from '../utils/utilsTs';
import { customStylesFormat, nativeOptionMultiple } from '../utils/utilsTs';
import { ICreateBreadCrumb } from './create-element.interface';
/**
@ -63,8 +63,8 @@ export function createBreadCrumb(
liChip.appendChild(svgIcon);
if (styles) {
// const { chips } = styles;
// customStylesFormat(chips, liChip);
const { chips } = styles;
customStylesFormat(chips!, liChip);
}
svgIcon.addEventListener('click', (event) => {

View File

@ -48,6 +48,7 @@ export function getSelectText(
} else {
select!.innerText = 'Select...';
}
return select!;
}
@ -116,7 +117,7 @@ export function clearSelect(select: HTMLElement, element: Element, dataSelectTex
svgIcon.appendChild(path1);
svgIcon.appendChild(path2);
if (multiselectTag) {
if (multiselectTag && multiselectTag == true) {
return;
}
@ -162,7 +163,7 @@ export function clearSelect(select: HTMLElement, element: Element, dataSelectTex
* @param {NodeList} element NodeList нативного селекта
* @param {any} item выбранный элемент в кастомном селекте
*/
export function nativeOptionOrdinary(element: NodeListOf<Element> | undefined, item: any) {
export function nativeOptionOrdinary(element: NodeListOf<Element> | undefined, item: string) {
element!.forEach((option) => {
option.removeAttribute('selected');
if (option.textContent === item) {

View File

@ -128,4 +128,9 @@ export interface IStyle {
* @type {object}
*/
search?: object;
/**
* Кастомизация чипсов с выбранными элементами
* @type {object}
*/
chips?: object;
}