diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index 72d92d65..074d4ec2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -1,6 +1,6 @@ name: '🐞 Bug Report' description: Report a bug -title: '[Bug] ' +title: '[Bug] {SCOPE} - ' labels: 'Type: bug' assignees: MGREMY diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml index f2d22640..378b739d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -1,6 +1,6 @@ name: '🚀 Feature Request' description: Suggest a feature -title: '[Feature] ' +title: '[Feature] {SCOPE} - ' labels: 'Type: enhancement' assignees: MGREMY diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae653028..8c303548 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: uses: ./.github/actions/setup - name: Release new version 🛠 - run: pnpm lib:release -- --ci --verbose --skip-nx-cache --dryRyn=${{ github.event.inputs.dryRun }} + run: pnpm lib:release -- --ci --verbose --skip-nx-cache --dryRun=${{ github.event.inputs.dryRun }} env: GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..0a4b97de --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1 @@ +npx --no -- commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index 73f8ac46..47d64bbb --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -pnpm all:lint +pnpm dlx lint-staged --concurrent false --relative \ No newline at end of file diff --git a/apps/docs/docs/components/accordion/_always-open.component.html b/apps/docs/docs/components/accordion/_always-open.component.html index 81dae317..34bb2fca 100644 --- a/apps/docs/docs/components/accordion/_always-open.component.html +++ b/apps/docs/docs/components/accordion/_always-open.component.html @@ -2,33 +2,37 @@ What is Flowbite ? -

- Flowbite is an open-source library of interactive components built on top of Tailwind CSS - including buttons, dropdowns, modals, navbars, and more. -

-

- Check out this guide to learn how to - - Get started - - and start developing websites even faster with components on top of Tailwind CSS. -

+ +

+ Flowbite is an open-source library of interactive components built on top of Tailwind CSS + including buttons, dropdowns, modals, navbars, and more. +

+

+ Check out this guide to learn how to + + Get started + + and start developing websites even faster with components on top of Tailwind CSS. +

+
Is there a Figma file available ? -

- Flowbite is first conceptualized and designed using the Figma software so everything you see - in the library has a design equivalent in our Figma file. -

-

- Check out the - Figma design system - based on the utility classes from Tailwind CSS and components from Flowbite. -

+ +

+ Flowbite is first conceptualized and designed using the Figma software so everything you + see in the library has a design equivalent in our Figma file. +

+

+ Check out the + Figma design system + based on the utility classes from Tailwind CSS and components from Flowbite. +

+
@@ -36,35 +40,37 @@ What are the differences between Flowbite and Tailwind UI ? -

- The main difference is that the core components from Flowbite are open source under the MIT - license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies - on smaller and standalone components, whereas Tailwind UI offers sections of pages. -

-

- However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as - there is no technical reason stopping you from using the best of two worlds. -

-

- Learn more about these technologies : -

- + +

+ The main difference is that the core components from Flowbite are open source under the + MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite + relies on smaller and standalone components, whereas Tailwind UI offers sections of pages. +

+

+ However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as + there is no technical reason stopping you from using the best of two worlds. +

+

+ Learn more about these technologies : +

+ +
diff --git a/apps/docs/docs/components/accordion/_color-option.component.html b/apps/docs/docs/components/accordion/_color-option.component.html index e189a1ce..70a8b5c4 100644 --- a/apps/docs/docs/components/accordion/_color-option.component.html +++ b/apps/docs/docs/components/accordion/_color-option.component.html @@ -2,33 +2,37 @@ What is Flowbite ? -

- Flowbite is an open-source library of interactive components built on top of Tailwind CSS - including buttons, dropdowns, modals, navbars, and more. -

-

- Check out this guide to learn how to - - Get started - - and start developing websites even faster with components on top of Tailwind CSS. -

+ +

+ Flowbite is an open-source library of interactive components built on top of Tailwind CSS + including buttons, dropdowns, modals, navbars, and more. +

+

+ Check out this guide to learn how to + + Get started + + and start developing websites even faster with components on top of Tailwind CSS. +

+
Is there a Figma file available ? -

- Flowbite is first conceptualized and designed using the Figma software so everything you see - in the library has a design equivalent in our Figma file. -

-

- Check out the - Figma design system - based on the utility classes from Tailwind CSS and components from Flowbite. -

+ +

+ Flowbite is first conceptualized and designed using the Figma software so everything you + see in the library has a design equivalent in our Figma file. +

+

+ Check out the + Figma design system + based on the utility classes from Tailwind CSS and components from Flowbite. +

+
@@ -36,35 +40,37 @@ What are the differences between Flowbite and Tailwind UI ? -

- The main difference is that the core components from Flowbite are open source under the MIT - license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies - on smaller and standalone components, whereas Tailwind UI offers sections of pages. -

-

- However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as - there is no technical reason stopping you from using the best of two worlds. -

-

- Learn more about these technologies : -

- + +

+ The main difference is that the core components from Flowbite are open source under the + MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite + relies on smaller and standalone components, whereas Tailwind UI offers sections of pages. +

+

+ However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as + there is no technical reason stopping you from using the best of two worlds. +

+

+ Learn more about these technologies : +

+ +
diff --git a/apps/docs/docs/components/accordion/_default.component.html b/apps/docs/docs/components/accordion/_default.component.html index 5addbcf3..e8a49f73 100644 --- a/apps/docs/docs/components/accordion/_default.component.html +++ b/apps/docs/docs/components/accordion/_default.component.html @@ -2,33 +2,37 @@ What is Flowbite ? -

- Flowbite is an open-source library of interactive components built on top of Tailwind CSS - including buttons, dropdowns, modals, navbars, and more. -

-

- Check out this guide to learn how to - - Get started - - and start developing websites even faster with components on top of Tailwind CSS. -

+ +

+ Flowbite is an open-source library of interactive components built on top of Tailwind CSS + including buttons, dropdowns, modals, navbars, and more. +

+

+ Check out this guide to learn how to + + Get started + + and start developing websites even faster with components on top of Tailwind CSS. +

+
Is there a Figma file available ? -

- Flowbite is first conceptualized and designed using the Figma software so everything you see - in the library has a design equivalent in our Figma file. -

-

- Check out the - Figma design system - based on the utility classes from Tailwind CSS and components from Flowbite. -

+ +

+ Flowbite is first conceptualized and designed using the Figma software so everything you + see in the library has a design equivalent in our Figma file. +

+

+ Check out the + Figma design system + based on the utility classes from Tailwind CSS and components from Flowbite. +

+
@@ -36,35 +40,37 @@ What are the differences between Flowbite and Tailwind UI ? -

- The main difference is that the core components from Flowbite are open source under the MIT - license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies - on smaller and standalone components, whereas Tailwind UI offers sections of pages. -

-

- However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as - there is no technical reason stopping you from using the best of two worlds. -

-

- Learn more about these technologies : -

- + +

+ The main difference is that the core components from Flowbite are open source under the + MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite + relies on smaller and standalone components, whereas Tailwind UI offers sections of pages. +

+

+ However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as + there is no technical reason stopping you from using the best of two worlds. +

+

+ Learn more about these technologies : +

+ +
diff --git a/apps/docs/docs/components/accordion/_flush.component.html b/apps/docs/docs/components/accordion/_flush.component.html index d1ab051b..7fcac230 100644 --- a/apps/docs/docs/components/accordion/_flush.component.html +++ b/apps/docs/docs/components/accordion/_flush.component.html @@ -2,33 +2,37 @@ What is Flowbite ? -

- Flowbite is an open-source library of interactive components built on top of Tailwind CSS - including buttons, dropdowns, modals, navbars, and more. -

-

- Check out this guide to learn how to - - Get started - - and start developing websites even faster with components on top of Tailwind CSS. -

+ +

+ Flowbite is an open-source library of interactive components built on top of Tailwind CSS + including buttons, dropdowns, modals, navbars, and more. +

+

+ Check out this guide to learn how to + + Get started + + and start developing websites even faster with components on top of Tailwind CSS. +

+
Is there a Figma file available ? -

- Flowbite is first conceptualized and designed using the Figma software so everything you see - in the library has a design equivalent in our Figma file. -

-

- Check out the - Figma design system - based on the utility classes from Tailwind CSS and components from Flowbite. -

+ +

+ Flowbite is first conceptualized and designed using the Figma software so everything you + see in the library has a design equivalent in our Figma file. +

+

+ Check out the + Figma design system + based on the utility classes from Tailwind CSS and components from Flowbite. +

+
@@ -36,35 +40,37 @@ What are the differences between Flowbite and Tailwind UI ? -

- The main difference is that the core components from Flowbite are open source under the MIT - license, whereas Tailwind UI is a paid product. Another difference is that Flowbite relies - on smaller and standalone components, whereas Tailwind UI offers sections of pages. -

-

- However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as - there is no technical reason stopping you from using the best of two worlds. -

-

- Learn more about these technologies : -

- + +

+ The main difference is that the core components from Flowbite are open source under the + MIT license, whereas Tailwind UI is a paid product. Another difference is that Flowbite + relies on smaller and standalone components, whereas Tailwind UI offers sections of pages. +

+

+ However, we actually recommend using both Flowbite, Flowbite Pro, and even Tailwind UI as + there is no technical reason stopping you from using the best of two worlds. +

+

+ Learn more about these technologies : +

+ +
diff --git a/apps/docs/src/app/app.component.html b/apps/docs/src/app/app.component.html index 805d7dc2..61c470da 100644 --- a/apps/docs/src/app/app.component.html +++ b/apps/docs/src/app/app.component.html @@ -4,19 +4,17 @@ [footerContent]="footerContent"> + [isFixed]="true">
- - - + @if (!isLandingPage) { + + + + } @@ -31,7 +29,7 @@
-
- + - +
+ +
diff --git a/apps/docs/src/app/app.component.ts b/apps/docs/src/app/app.component.ts index 57cab91a..2ab231c0 100644 --- a/apps/docs/src/app/app.component.ts +++ b/apps/docs/src/app/app.component.ts @@ -15,7 +15,7 @@ import { import { FlowbiteRouterLinkDirective } from 'flowbite-angular/router-link'; import { FlowbiteRouterLinkActiveDirective } from 'flowbite-angular/router-link-active'; -import { Location, NgIf } from '@angular/common'; +import { Location } from '@angular/common'; import { Component, computed, inject } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import { @@ -30,7 +30,6 @@ import { standalone: true, imports: [ RouterOutlet, - NgIf, NgDocRootComponent, NgDocSidebarComponent, NgDocThemeToggleComponent, diff --git a/libs/flowbite-angular/accordion/accordion-content.component.ts b/libs/flowbite-angular/accordion/accordion-content.component.ts index 0b3bb71a..27551e22 100644 --- a/libs/flowbite-angular/accordion/accordion-content.component.ts +++ b/libs/flowbite-angular/accordion/accordion-content.component.ts @@ -6,7 +6,7 @@ import type { AccordionColors } from './accordion.theme'; import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; import type { DeepPartial } from 'flowbite-angular'; -import { NgClass, NgIf } from '@angular/common'; +import { animate, state, style, transition, trigger } from '@angular/animations'; import { ChangeDetectionStrategy, Component, @@ -20,13 +20,18 @@ import { */ @Component({ standalone: true, - imports: [NgIf, NgClass], selector: 'flowbite-accordion-content', - template: ` - - - - `, + template: ``, + host: { + '[@isOpenAnimation]': 'accordionPanelComponent.isOpen()', + }, + animations: [ + trigger('isOpenAnimation', [ + state('true', style({ height: '*' })), + state('false', style({ height: '0px' })), + transition('true <=> false', animate('300ms')), + ]), + ], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) @@ -57,7 +62,6 @@ export class AccordionContentComponent extends BaseComponent; } @@ -20,7 +19,6 @@ export interface AccordionContentTheme { root: { base: string; color: AccordionColors; - isOpen: FlowbiteBoolean; isFlush: FlowbiteBoolean; }; } @@ -30,7 +28,7 @@ export interface AccordionContentTheme { */ export const accordionContentTheme: AccordionContentTheme = createTheme({ root: { - base: 'flex flex-col', + base: 'flex flex-col overflow-hidden', color: { primary: 'border-primary-200 dark:border-primary-700', light: 'border-gray-200 dark:border-gray-700', @@ -39,10 +37,6 @@ export const accordionContentTheme: AccordionContentTheme = createTheme({ green: 'border-green-200 dark:border-green-700', yellow: 'border-yellow-200 dark:border-yellow-700', }, - isOpen: { - enabled: 'p-5', - disabled: '', - }, isFlush: { enabled: '', disabled: 'border-x border-t group-last:border-b', diff --git a/libs/flowbite-angular/accordion/accordion-panel.component.ts b/libs/flowbite-angular/accordion/accordion-panel.component.ts index 519d1dbd..5630f6fa 100644 --- a/libs/flowbite-angular/accordion/accordion-panel.component.ts +++ b/libs/flowbite-angular/accordion/accordion-panel.component.ts @@ -24,7 +24,6 @@ import { */ @Component({ standalone: true, - imports: [], selector: 'flowbite-accordion-panel', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/accordion/accordion-title.component.ts b/libs/flowbite-angular/accordion/accordion-title.component.ts index 6038cee9..88963e64 100644 --- a/libs/flowbite-angular/accordion/accordion-title.component.ts +++ b/libs/flowbite-angular/accordion/accordion-title.component.ts @@ -8,7 +8,6 @@ import type { DeepPartial } from 'flowbite-angular'; import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { CHEVRON_DOWN_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass } from '@angular/common'; import type { OnInit } from '@angular/core'; import { ChangeDetectionStrategy, @@ -24,10 +23,10 @@ import { DomSanitizer } from '@angular/platform-browser'; */ @Component({ standalone: true, - imports: [NgClass, IconComponent], + imports: [IconComponent], selector: 'flowbite-accordion-title', template: ` -

+

`, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/alert/alert.component.ts b/libs/flowbite-angular/alert/alert.component.ts index 048020b7..38e65995 100644 --- a/libs/flowbite-angular/alert/alert.component.ts +++ b/libs/flowbite-angular/alert/alert.component.ts @@ -3,11 +3,11 @@ import { AlertThemeService } from './alert.theme.service'; import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; import type { DeepPartial } from 'flowbite-angular'; -import { ButtonComponent } from 'flowbite-angular/button'; import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { CLOSE_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common'; +import { animate, style, transition, trigger } from '@angular/animations'; +import { NgTemplateOutlet } from '@angular/common'; import type { OnInit, TemplateRef } from '@angular/core'; import { ChangeDetectionStrategy, @@ -23,7 +23,7 @@ import { DomSanitizer } from '@angular/platform-browser'; */ @Component({ standalone: true, - imports: [NgIf, NgClass, NgTemplateOutlet, IconComponent, ButtonComponent], + imports: [NgTemplateOutlet, IconComponent], selector: 'flowbite-alert', template: `
@@ -31,23 +31,31 @@ import { DomSanitizer } from '@angular/platform-browser';
- + @if (isDismissable()) { + + }
`, host: { '[attr.role]': 'alert', + '[@onDestroyAnimation]': '', }, + animations: [ + trigger('onDestroyAnimation', [ + transition(':enter', [style({ opacity: 0 }), animate('300ms', style({ opacity: 1 }))]), + transition(':leave', [animate('300ms', style({ opacity: 0 }))]), + ]), + ], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) diff --git a/libs/flowbite-angular/badge/badge.component.ts b/libs/flowbite-angular/badge/badge.component.ts index 06069cb2..9198783f 100644 --- a/libs/flowbite-angular/badge/badge.component.ts +++ b/libs/flowbite-angular/badge/badge.component.ts @@ -5,7 +5,6 @@ import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; import { FlowbiteRouterLinkDirective } from 'flowbite-angular/router-link'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -19,7 +18,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-badge', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/breadcrumb/breadcrumb-item.component.ts b/libs/flowbite-angular/breadcrumb/breadcrumb-item.component.ts index 17b97369..dbfb8337 100644 --- a/libs/flowbite-angular/breadcrumb/breadcrumb-item.component.ts +++ b/libs/flowbite-angular/breadcrumb/breadcrumb-item.component.ts @@ -9,7 +9,6 @@ import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { FlowbiteRouterLinkDirective } from 'flowbite-angular/router-link'; import { CHEVRON_RIGHT_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common'; import type { OnInit } from '@angular/core'; import { ChangeDetectionStrategy, @@ -25,11 +24,11 @@ import { DomSanitizer } from '@angular/platform-browser'; */ @Component({ standalone: true, - imports: [NgIf, NgClass, NgTemplateOutlet, IconComponent], + imports: [IconComponent], selector: 'flowbite-breadcrumb-item', template: ` `, diff --git a/libs/flowbite-angular/breadcrumb/breadcrumb.component.ts b/libs/flowbite-angular/breadcrumb/breadcrumb.component.ts index f5a8c4d7..5f997c05 100644 --- a/libs/flowbite-angular/breadcrumb/breadcrumb.component.ts +++ b/libs/flowbite-angular/breadcrumb/breadcrumb.component.ts @@ -5,7 +5,6 @@ import { BreadcrumbThemeService } from './breadcrumb.theme.service'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent } from 'flowbite-angular'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -20,7 +19,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-breadcrumb', template: ``, host: { diff --git a/libs/flowbite-angular/button/button.component.ts b/libs/flowbite-angular/button/button.component.ts index 0c63ff75..834fc6b0 100644 --- a/libs/flowbite-angular/button/button.component.ts +++ b/libs/flowbite-angular/button/button.component.ts @@ -12,7 +12,7 @@ import { ButtonThemeService } from './button.theme.service'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; -import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common'; +import { NgTemplateOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -26,20 +26,18 @@ import { */ @Component({ standalone: true, - imports: [NgIf, NgClass, NgTemplateOutlet], + imports: [NgTemplateOutlet], selector: 'flowbite-button', template: ` - - - + @if (gradientDuoTone() && fill() === 'outline') { + + + + } @else { + + } - - - - - + `, diff --git a/libs/flowbite-angular/dark-theme-toggle/dark-theme-toggle.component.ts b/libs/flowbite-angular/dark-theme-toggle/dark-theme-toggle.component.ts index c52e1825..32400c52 100644 --- a/libs/flowbite-angular/dark-theme-toggle/dark-theme-toggle.component.ts +++ b/libs/flowbite-angular/dark-theme-toggle/dark-theme-toggle.component.ts @@ -6,7 +6,6 @@ import { BaseComponent } from 'flowbite-angular'; import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { MOON_SVG_ICON, SUN_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass, NgIf } from '@angular/common'; import { afterNextRender, ChangeDetectionStrategy, @@ -22,7 +21,7 @@ import { DomSanitizer } from '@angular/platform-browser'; */ @Component({ standalone: true, - imports: [NgIf, NgClass, IconComponent], + imports: [IconComponent], selector: 'flowbite-dark-theme-toggle', template: ` +
diff --git a/libs/flowbite-angular/dropdown/dropdown-item.component.ts b/libs/flowbite-angular/dropdown/dropdown-item.component.ts index 48b1ba5a..ec9d0314 100644 --- a/libs/flowbite-angular/dropdown/dropdown-item.component.ts +++ b/libs/flowbite-angular/dropdown/dropdown-item.component.ts @@ -5,7 +5,6 @@ import { DropdownComponent } from './dropdown.component'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent } from 'flowbite-angular'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -19,7 +18,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-dropdown-item', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/dropdown/dropdown.component.ts b/libs/flowbite-angular/dropdown/dropdown.component.ts index 907d6a0d..9df1cda4 100644 --- a/libs/flowbite-angular/dropdown/dropdown.component.ts +++ b/libs/flowbite-angular/dropdown/dropdown.component.ts @@ -9,36 +9,32 @@ import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { CHEVRON_DOWN_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass } from '@angular/common'; -import type { AfterViewInit } from '@angular/core'; +import type { ElementRef } from '@angular/core'; import { ChangeDetectionStrategy, Component, contentChildren, - ElementRef, inject, model, - ViewChild, + viewChild, ViewEncapsulation, } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; -import type { Placement } from '@floating-ui/dom'; -import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/dom'; /** * @see https://flowbite.com/docs/components/dropdowns/ */ @Component({ standalone: true, - imports: [NgClass, IconComponent], + imports: [IconComponent], selector: 'flowbite-dropdown', template: `
-
-
    + [style.display]="isOpen() ? 'block' : 'none'" + [style.minWidth.px]="button.clientWidth"> +
    +
    @@ -62,9 +59,9 @@ import { autoUpdate, computePosition, flip, offset, shift } from '@floating-ui/d encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, }) -export class DropdownComponent extends BaseComponent implements AfterViewInit { - @ViewChild('dropdown') dropdown!: ElementRef; - @ViewChild('button') button!: ElementRef; +export class DropdownComponent extends BaseComponent { + dropdown = viewChild.required('dropdown'); + button = viewChild.required('button'); /** * Service injected used to generate class @@ -141,10 +138,6 @@ export class DropdownComponent extends BaseComponent implements A } //#endregion - x = 0; - y = 0; - width = 0; - /** * Toggle dropdown isOpen */ @@ -152,47 +145,14 @@ export class DropdownComponent extends BaseComponent implements A this.isOpen.set(!this.isOpen()); } - calculatePosition() { - computePosition(this.button.nativeElement, this.dropdown.nativeElement, { - placement: this.convertPosition(this.position()), - middleware: [offset(8), flip(), shift()], - }).then(({ x, y }: { x: number; y: number }) => { - this.dropdown.nativeElement.style.left = x + 'px'; - this.dropdown.nativeElement.style.top = y + 'px'; - this.width = this.button.nativeElement.offsetWidth; - }); - } - - ngAfterViewInit() { - // todo : Fix ERROR ReferenceError: ResizeObserver is not defined - // Append when runing command 'pnpm lib:build' - autoUpdate(this.button.nativeElement, this.dropdown.nativeElement, () => { - if (!this.isOpen()) return; - this.calculatePosition(); - }); - } - // Onclick outside the dropdown, close it clickout(event: Event) { if ( - !this.dropdown.nativeElement.contains(event.target) && + !this.dropdown().nativeElement.contains(event.target) && this.isOpen() && - !this.button.nativeElement.contains(event.target) + !this.button().nativeElement.contains(event.target) ) { this.isOpen.set(false); } } - - convertPosition(pos: keyof DropdownPositions): Placement { - switch (pos) { - case 'top-center': - return 'top'; - case 'bottom-center': - return 'bottom'; - case 'left-center': - return 'left'; - case 'right-center': - return 'right'; - } - } } diff --git a/libs/flowbite-angular/dropdown/dropdown.theme.ts b/libs/flowbite-angular/dropdown/dropdown.theme.ts index 5e4b49a1..e50e88e2 100644 --- a/libs/flowbite-angular/dropdown/dropdown.theme.ts +++ b/libs/flowbite-angular/dropdown/dropdown.theme.ts @@ -57,7 +57,7 @@ export interface DropdownTheme { */ export const dropdownTheme: DropdownTheme = createTheme({ root: { - base: '', + base: 'relative inline w-fit', }, dropdown: { base: 'text-white bg-blue-700 border border-transparent hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 disabled:hover:bg-blue-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 dark:disabled:hover:bg-blue-600 group flex h-min items-center justify-center p-0.5 text-center font-medium focus:z-10 rounded-lg', @@ -72,10 +72,10 @@ export const dropdownTheme: DropdownTheme = createTheme({ disabled: 'hidden', }, placement: { - 'top-center': '', - 'bottom-center': '', - 'left-center': '', - 'right-center': '', + 'top-center': 'bottom-full mb-2.5 left-1/2 -translate-x-1/2', + 'bottom-center': 'top-full mt-2.5 left-1/2 -translate-x-1/2', + 'left-center': 'left-full ml-2.5 top-1/2 -translate-y-1/2', + 'right-center': 'right-full mr-2.5 top-1/2 -translate-y-1/2', }, }, content: { diff --git a/libs/flowbite-angular/indicator/indicators.component.ts b/libs/flowbite-angular/indicator/indicators.component.ts index 96d2bf67..fd73888e 100644 --- a/libs/flowbite-angular/indicator/indicators.component.ts +++ b/libs/flowbite-angular/indicator/indicators.component.ts @@ -10,7 +10,6 @@ import { IndicatorThemeService } from './indicators.theme.service'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent, booleanToFlowbiteBoolean } from 'flowbite-angular'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -24,7 +23,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-indicator', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/modal/modal-body.component.ts b/libs/flowbite-angular/modal/modal-body.component.ts index 34ed5565..e36c7ef3 100644 --- a/libs/flowbite-angular/modal/modal-body.component.ts +++ b/libs/flowbite-angular/modal/modal-body.component.ts @@ -5,7 +5,6 @@ import { ModalComponent } from './modal.component'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent } from 'flowbite-angular'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -19,7 +18,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-modal-body', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/modal/modal-footer.component.ts b/libs/flowbite-angular/modal/modal-footer.component.ts index f2ab9abb..8ff9f2f0 100644 --- a/libs/flowbite-angular/modal/modal-footer.component.ts +++ b/libs/flowbite-angular/modal/modal-footer.component.ts @@ -5,7 +5,6 @@ import { ModalComponent } from './modal.component'; import type { DeepPartial } from 'flowbite-angular'; import { BaseComponent } from 'flowbite-angular'; -import { NgClass } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -19,7 +18,6 @@ import { */ @Component({ standalone: true, - imports: [NgClass], selector: 'flowbite-modal-footer', template: ``, encapsulation: ViewEncapsulation.None, diff --git a/libs/flowbite-angular/modal/modal-header.component.ts b/libs/flowbite-angular/modal/modal-header.component.ts index 6107b89d..4055f397 100644 --- a/libs/flowbite-angular/modal/modal-header.component.ts +++ b/libs/flowbite-angular/modal/modal-header.component.ts @@ -7,7 +7,6 @@ import { BaseComponent } from 'flowbite-angular'; import { IconComponent, IconRegistry } from 'flowbite-angular/icon'; import { CLOSE_SVG_ICON } from 'flowbite-angular/utils'; -import { NgClass } from '@angular/common'; import type { OnInit } from '@angular/core'; import { ChangeDetectionStrategy, @@ -23,15 +22,15 @@ import { DomSanitizer } from '@angular/platform-browser'; */ @Component({ standalone: true, - imports: [NgClass, IconComponent], + imports: [IconComponent], selector: 'flowbite-modal-header', template: ` -

    +