First version AI Search
This commit is contained in:
@@ -96,6 +96,7 @@ export function createDefaultListingCriteria(): ListingCriteria {
|
||||
title: '',
|
||||
category: 'broker',
|
||||
name: '',
|
||||
prompt: '',
|
||||
};
|
||||
}
|
||||
export function createLogger(name: string, level: number = INFO, options: any = {}) {
|
||||
@@ -179,3 +180,58 @@ export function getDialogWidth(dimensions): string {
|
||||
}
|
||||
return dialogWidth;
|
||||
}
|
||||
|
||||
import { initFlowbite } from 'flowbite';
|
||||
import { Subject, concatMap, delay, of } from 'rxjs';
|
||||
|
||||
const flowbiteQueue = new Subject<() => void>();
|
||||
|
||||
flowbiteQueue.pipe(concatMap(item => of(item).pipe(delay(100)))).subscribe(x => {
|
||||
x();
|
||||
});
|
||||
|
||||
export function Flowbite() {
|
||||
return function (target: any) {
|
||||
const originalOnInit = target.prototype.ngOnInit;
|
||||
target.prototype.ngOnInit = function () {
|
||||
if (originalOnInit) {
|
||||
originalOnInit.apply(this);
|
||||
}
|
||||
initFlowbiteFix();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function initFlowbiteFix() {
|
||||
flowbiteQueue.next(() => {
|
||||
const elements = Array.from(document.querySelectorAll('*'));
|
||||
const flowbiteElements: Element[] = [];
|
||||
const initializedElements = Array.from(document.querySelectorAll('[flowbite-initialized]'));
|
||||
|
||||
for (const element of elements) {
|
||||
const attributes = Array.from(element.attributes);
|
||||
|
||||
for (const attribute of attributes) {
|
||||
if (attribute.name.startsWith('data-') && !initializedElements.includes(element)) {
|
||||
flowbiteElements.push(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of flowbiteElements) {
|
||||
element.setAttribute('flowbite-initialized', '');
|
||||
}
|
||||
initFlowbite();
|
||||
|
||||
for (const element of flowbiteElements) {
|
||||
const attributes: { name: string; value: string }[] = Array.from(element.attributes);
|
||||
const dataAttributes = attributes.filter(attribute => attribute.name.startsWith('data-'));
|
||||
|
||||
for (const attribute of dataAttributes) {
|
||||
element.setAttribute(attribute.name.replace('data-', 'fb-'), attribute.value);
|
||||
element.removeAttribute(attribute.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user