From b15cea22ac53948c0eb6ffe9f0fa35c389d259ee Mon Sep 17 00:00:00 2001 From: Alexey Umanskiy Date: Thu, 17 Oct 2024 15:07:15 +0300 Subject: [PATCH 1/3] =?UTF-8?q?hotfix(typescript):=20some=20angular=20setu?= =?UTF-8?q?ps=20can't=20handle=20.forRoot()=20retur=E2=80=A6=20(#6689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hotfix(typescript): some angular setups can't handle .forRoot() returning just module * 18.1.1 * chore(version): version bumped --- apps/ngx-bootstrap-docs/src/assets/css/style.scss | 4 +++- .../src/assets/json/current-version.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/accordion/accordion.module.ts | 9 ++++++--- src/accordion/package.json | 2 +- src/alert/alert.module.ts | 9 ++++++--- src/alert/package.json | 2 +- src/buttons/buttons.module.ts | 9 ++++++--- src/buttons/package.json | 2 +- src/carousel/carousel.module.ts | 9 ++++++--- src/carousel/package.json | 2 +- src/chronos/package.json | 2 +- src/collapse/collapse.module.ts | 9 ++++++--- src/collapse/package.json | 2 +- src/component-loader/package.json | 2 +- src/datepicker/bs-datepicker.module.ts | 9 ++++++--- src/datepicker/package.json | 2 +- src/dropdown/bs-dropdown.module.ts | 9 ++++++--- src/dropdown/package.json | 2 +- src/focus-trap/focus-trap.module.ts | 9 ++++++--- src/focus-trap/package.json | 2 +- src/locale/package.json | 2 +- src/mini-ngrx/package.json | 2 +- src/modal/package.json | 2 +- src/pagination/package.json | 2 +- src/pagination/pagination.module.ts | 9 ++++++--- src/popover/package.json | 2 +- src/popover/popover.module.ts | 9 ++++++--- src/positioning/package.json | 2 +- src/progressbar/package.json | 2 +- src/progressbar/progressbar.module.ts | 9 ++++++--- src/rating/package.json | 2 +- src/rating/rating.module.ts | 9 ++++++--- src/root/package.json | 2 +- src/schematics/package.json | 2 +- .../src/utils/current_dependency_versions.json | 2 +- src/sortable/package.json | 2 +- src/sortable/sortable.module.ts | 9 ++++++--- src/tabs/package.json | 2 +- src/tabs/tabs.module.ts | 7 +++++-- src/timepicker/package.json | 2 +- src/timepicker/timepicker.module.ts | 9 ++++++--- src/tooltip/package.json | 2 +- src/tooltip/tooltip.module.ts | 9 ++++++--- src/typeahead/package.json | 2 +- src/typeahead/typeahead.module.ts | 9 ++++++--- src/utils/package.json | 2 +- 48 files changed, 135 insertions(+), 82 deletions(-) diff --git a/apps/ngx-bootstrap-docs/src/assets/css/style.scss b/apps/ngx-bootstrap-docs/src/assets/css/style.scss index 8020c1da36..3db1f2272a 100644 --- a/apps/ngx-bootstrap-docs/src/assets/css/style.scss +++ b/apps/ngx-bootstrap-docs/src/assets/css/style.scss @@ -2,7 +2,9 @@ @import "bs-datepicker"; /* HEADER */ - +.bs-datepicker-head { + width: 150px; +} header { padding: 10px 50px 10px 30px; height: $header-height; diff --git a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json index 468bce7d10..068131925c 100644 --- a/apps/ngx-bootstrap-docs/src/assets/json/current-version.json +++ b/apps/ngx-bootstrap-docs/src/assets/json/current-version.json @@ -1,3 +1,3 @@ { - "version": "18.1.0" + "version": "18.1.1" } diff --git a/package-lock.json b/package-lock.json index d64369dc7a..ed712ed5d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 65ed365e53..c1c0252f27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap-base", - "version": "18.1.0", + "version": "18.1.1", "license": "MIT", "author": "Dmitriy Shekhovtsov ", "schematics": "./schematics/src/collection.json", diff --git a/src/accordion/accordion.module.ts b/src/accordion/accordion.module.ts index 60a8a70db1..23541e2d23 100644 --- a/src/accordion/accordion.module.ts +++ b/src/accordion/accordion.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { AccordionComponent } from './accordion.component'; import { AccordionPanelComponent } from './accordion-group.component'; @@ -9,7 +9,10 @@ import { AccordionPanelComponent } from './accordion-group.component'; }) export class AccordionModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return AccordionModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: AccordionModule, + providers: [] + }; } } diff --git a/src/accordion/package.json b/src/accordion/package.json index 1f30f5dc8b..0dd7738830 100644 --- a/src/accordion/package.json +++ b/src/accordion/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/accordion", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/alert/alert.module.ts b/src/alert/alert.module.ts index d682d7cbce..2cfca0257a 100644 --- a/src/alert/alert.module.ts +++ b/src/alert/alert.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { AlertComponent } from './alert.component'; @NgModule({ @@ -7,7 +7,10 @@ import { AlertComponent } from './alert.component'; }) export class AlertModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return AlertModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: AlertModule, + providers: [] + }; } } diff --git a/src/alert/package.json b/src/alert/package.json index a1b343725d..6a35a023b9 100644 --- a/src/alert/package.json +++ b/src/alert/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/alert", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/buttons/buttons.module.ts b/src/buttons/buttons.module.ts index dd6ad1d660..f2a4854d52 100644 --- a/src/buttons/buttons.module.ts +++ b/src/buttons/buttons.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { ButtonCheckboxDirective } from './button-checkbox.directive'; import { ButtonRadioDirective } from './button-radio.directive'; @@ -10,7 +10,10 @@ import { ButtonRadioGroupDirective } from './button-radio-group.directive'; }) export class ButtonsModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return ButtonsModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: ButtonsModule, + providers: [] + }; } } diff --git a/src/buttons/package.json b/src/buttons/package.json index d37d360daa..c7d4807fc7 100644 --- a/src/buttons/package.json +++ b/src/buttons/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/buttons", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/carousel/carousel.module.ts b/src/carousel/carousel.module.ts index 177452e83c..4bf02720f8 100644 --- a/src/carousel/carousel.module.ts +++ b/src/carousel/carousel.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CarouselComponent } from './carousel.component'; import { SlideComponent } from './slide.component'; @@ -9,7 +9,10 @@ import { SlideComponent } from './slide.component'; }) export class CarouselModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return CarouselModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: CarouselModule, + providers: [] + }; } } diff --git a/src/carousel/package.json b/src/carousel/package.json index e1f4da7134..0cd2f05f2d 100644 --- a/src/carousel/package.json +++ b/src/carousel/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/carousel", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/chronos/package.json b/src/chronos/package.json index d6be16bbc2..cdf2cf8eca 100644 --- a/src/chronos/package.json +++ b/src/chronos/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/chronos", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/collapse/collapse.module.ts b/src/collapse/collapse.module.ts index 769cddbde2..611d9f5aa6 100644 --- a/src/collapse/collapse.module.ts +++ b/src/collapse/collapse.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CollapseDirective } from './collapse.directive'; @@ -8,7 +8,10 @@ import { CollapseDirective } from './collapse.directive'; }) export class CollapseModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return CollapseModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: CollapseModule, + providers: [] + }; } } diff --git a/src/collapse/package.json b/src/collapse/package.json index 994c31561c..6bb0c979f9 100644 --- a/src/collapse/package.json +++ b/src/collapse/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/collapse", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/component-loader/package.json b/src/component-loader/package.json index d0f479a3e9..5024032b46 100644 --- a/src/component-loader/package.json +++ b/src/component-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/component-loader", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/datepicker/bs-datepicker.module.ts b/src/datepicker/bs-datepicker.module.ts index 88abae332f..5677ba96cd 100644 --- a/src/datepicker/bs-datepicker.module.ts +++ b/src/datepicker/bs-datepicker.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TooltipModule } from 'ngx-bootstrap/tooltip'; import { TimepickerModule } from 'ngx-bootstrap/timepicker'; @@ -64,7 +64,10 @@ import { BsYearsCalendarViewComponent } from './themes/bs/bs-years-calendar-view }) export class BsDatepickerModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return BsDatepickerModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: BsDatepickerModule, + providers: [] + }; } } diff --git a/src/datepicker/package.json b/src/datepicker/package.json index 13b0b449e2..f50a853cd6 100644 --- a/src/datepicker/package.json +++ b/src/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/datepicker", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/dropdown/bs-dropdown.module.ts b/src/dropdown/bs-dropdown.module.ts index 5ab54af6fd..7f7624ea4c 100644 --- a/src/dropdown/bs-dropdown.module.ts +++ b/src/dropdown/bs-dropdown.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { BsDropdownContainerComponent } from './bs-dropdown-container.component'; import { BsDropdownMenuDirective } from './bs-dropdown-menu.directive'; @@ -21,7 +21,10 @@ import { BsDropdownDirective } from './bs-dropdown.directive'; }) export class BsDropdownModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return BsDropdownModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: BsDropdownModule, + providers: [] + }; } } diff --git a/src/dropdown/package.json b/src/dropdown/package.json index 1c22dd6f4b..08048953bf 100644 --- a/src/dropdown/package.json +++ b/src/dropdown/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/dropdown", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/focus-trap/focus-trap.module.ts b/src/focus-trap/focus-trap.module.ts index 60ecd48574..509b87439b 100644 --- a/src/focus-trap/focus-trap.module.ts +++ b/src/focus-trap/focus-trap.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FocusTrapDirective } from './focus-trap'; @@ -9,7 +9,10 @@ import { FocusTrapDirective } from './focus-trap'; }) export class FocusTrapModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return FocusTrapModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: FocusTrapModule, + providers: [] + }; } } diff --git a/src/focus-trap/package.json b/src/focus-trap/package.json index a68da03899..82b05ef148 100644 --- a/src/focus-trap/package.json +++ b/src/focus-trap/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/focus-trap", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/locale/package.json b/src/locale/package.json index fbe62dc60b..5eb51ee06d 100644 --- a/src/locale/package.json +++ b/src/locale/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/locale", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/mini-ngrx/package.json b/src/mini-ngrx/package.json index fb562980c5..9112c1fe30 100644 --- a/src/mini-ngrx/package.json +++ b/src/mini-ngrx/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/mini-ngrx", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/modal/package.json b/src/modal/package.json index 26ad72a93b..0a303c5f24 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/modal", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/package.json b/src/pagination/package.json index 91a730bb89..df20f24377 100644 --- a/src/pagination/package.json +++ b/src/pagination/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/pagination", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/pagination/pagination.module.ts b/src/pagination/pagination.module.ts index 0dc6fd8334..a7c377f4af 100644 --- a/src/pagination/pagination.module.ts +++ b/src/pagination/pagination.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { PagerComponent } from './pager.component'; import { PaginationComponent } from './pagination.component'; @@ -10,7 +10,10 @@ import { PaginationComponent } from './pagination.component'; }) export class PaginationModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return PaginationModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: PaginationModule, + providers: [] + }; } } diff --git a/src/popover/package.json b/src/popover/package.json index 7f533c3196..462b00b143 100644 --- a/src/popover/package.json +++ b/src/popover/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/popover", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/popover/popover.module.ts b/src/popover/popover.module.ts index d992626951..d69a1f8864 100644 --- a/src/popover/popover.module.ts +++ b/src/popover/popover.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PopoverDirective } from './popover.directive'; @@ -10,7 +10,10 @@ import { PopoverContainerComponent } from './popover-container.component'; }) export class PopoverModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return PopoverModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: PopoverModule, + providers: [] + }; } } diff --git a/src/positioning/package.json b/src/positioning/package.json index 6043faf3a7..17d421294f 100644 --- a/src/positioning/package.json +++ b/src/positioning/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/positioning", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/package.json b/src/progressbar/package.json index 2339be3541..c3c9f44ae8 100644 --- a/src/progressbar/package.json +++ b/src/progressbar/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/progressbar", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/progressbar/progressbar.module.ts b/src/progressbar/progressbar.module.ts index feb7ac4f90..27385314b9 100644 --- a/src/progressbar/progressbar.module.ts +++ b/src/progressbar/progressbar.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { BarComponent } from './bar.component'; import { ProgressbarComponent } from './progressbar.component'; @@ -9,7 +9,10 @@ import { ProgressbarComponent } from './progressbar.component'; }) export class ProgressbarModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return ProgressbarModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: ProgressbarModule, + providers: [] + }; } } diff --git a/src/rating/package.json b/src/rating/package.json index ee9399e5ab..7680095734 100644 --- a/src/rating/package.json +++ b/src/rating/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/rating", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/rating/rating.module.ts b/src/rating/rating.module.ts index 2b75fd726d..0c85ba15c6 100644 --- a/src/rating/rating.module.ts +++ b/src/rating/rating.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { RatingComponent } from './rating.component'; @@ -8,7 +8,10 @@ import { RatingComponent } from './rating.component'; }) export class RatingModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return RatingModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: RatingModule, + providers: [] + }; } } diff --git a/src/root/package.json b/src/root/package.json index cac63c15f4..7b6f69ccdf 100644 --- a/src/root/package.json +++ b/src/root/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap", - "version": "18.1.0", + "version": "18.1.1", "description": "Angular Bootstrap", "author": "Dmitriy Shekhovtsov ", "license": "MIT", diff --git a/src/schematics/package.json b/src/schematics/package.json index 845a97bd64..1bcc1fdd4a 100644 --- a/src/schematics/package.json +++ b/src/schematics/package.json @@ -1,6 +1,6 @@ { "name": "schematics", - "version": "18.1.0", + "version": "18.1.1", "schematics": "./collection.json", "author": "Dmitriy Shekhovtsov ", "license": "MIT" diff --git a/src/schematics/src/utils/current_dependency_versions.json b/src/schematics/src/utils/current_dependency_versions.json index 49465a7534..092ceceb24 100644 --- a/src/schematics/src/utils/current_dependency_versions.json +++ b/src/schematics/src/utils/current_dependency_versions.json @@ -1,4 +1,4 @@ { - "NGX_BOOTSTRAP_VERSION": "18.1.0", + "NGX_BOOTSTRAP_VERSION": "18.1.1", "BOOTSTRAP_VERSION": "^5.2.3" } diff --git a/src/sortable/package.json b/src/sortable/package.json index d41793f039..7595c8a7cd 100644 --- a/src/sortable/package.json +++ b/src/sortable/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/sortable", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/sortable/sortable.module.ts b/src/sortable/sortable.module.ts index 1bddcf40cc..29cda7c63c 100644 --- a/src/sortable/sortable.module.ts +++ b/src/sortable/sortable.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { SortableComponent } from './sortable.component'; @@ -8,7 +8,10 @@ import { SortableComponent } from './sortable.component'; }) export class SortableModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return SortableModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: SortableModule, + providers: [] + }; } } diff --git a/src/tabs/package.json b/src/tabs/package.json index 56770abf88..c15d73143f 100644 --- a/src/tabs/package.json +++ b/src/tabs/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tabs", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tabs/tabs.module.ts b/src/tabs/tabs.module.ts index 359d111fcc..ce779c96e1 100644 --- a/src/tabs/tabs.module.ts +++ b/src/tabs/tabs.module.ts @@ -20,7 +20,10 @@ import { TabsetComponent } from './tabset.component'; }) export class TabsModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TabsModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TabsModule, + providers: [] + }; } } diff --git a/src/timepicker/package.json b/src/timepicker/package.json index c8ead5ed52..cc2c357e5c 100644 --- a/src/timepicker/package.json +++ b/src/timepicker/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/timepicker", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/timepicker/timepicker.module.ts b/src/timepicker/timepicker.module.ts index 9b10a82df5..bdb8678a4a 100644 --- a/src/timepicker/timepicker.module.ts +++ b/src/timepicker/timepicker.module.ts @@ -1,4 +1,4 @@ -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TimepickerComponent } from './timepicker.component'; @@ -8,7 +8,10 @@ import { TimepickerComponent } from './timepicker.component'; }) export class TimepickerModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TimepickerModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TimepickerModule, + providers: [] + }; } } diff --git a/src/tooltip/package.json b/src/tooltip/package.json index 83552bf072..cfec702241 100644 --- a/src/tooltip/package.json +++ b/src/tooltip/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/tooltip", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/tooltip/tooltip.module.ts b/src/tooltip/tooltip.module.ts index 928ca7a217..6a390afbd8 100644 --- a/src/tooltip/tooltip.module.ts +++ b/src/tooltip/tooltip.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TooltipContainerComponent } from './tooltip-container.component'; import { TooltipDirective } from './tooltip.directive'; @@ -9,7 +9,10 @@ import { TooltipDirective } from './tooltip.directive'; }) export class TooltipModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TooltipModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TooltipModule, + providers: [] + }; } } diff --git a/src/typeahead/package.json b/src/typeahead/package.json index 86d148ddf8..deb804e7fb 100644 --- a/src/typeahead/package.json +++ b/src/typeahead/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/typeahead", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } diff --git a/src/typeahead/typeahead.module.ts b/src/typeahead/typeahead.module.ts index ccdd9d35dd..334b3df41c 100644 --- a/src/typeahead/typeahead.module.ts +++ b/src/typeahead/typeahead.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { ModuleWithProviders, NgModule } from '@angular/core'; import { TypeaheadContainerComponent } from './typeahead-container.component'; import { TypeaheadDirective } from './typeahead.directive'; @@ -10,7 +10,10 @@ import { TypeaheadDirective } from './typeahead.directive'; }) export class TypeaheadModule { // @deprecated method not required anymore, will be deleted in v19.0.0 - static forRoot() { - return TypeaheadModule; + static forRoot(): ModuleWithProviders { + return { + ngModule: TypeaheadModule, + providers: [] + }; } } diff --git a/src/utils/package.json b/src/utils/package.json index 52ada5e345..442f87287b 100644 --- a/src/utils/package.json +++ b/src/utils/package.json @@ -1,6 +1,6 @@ { "name": "ngx-bootstrap/utils", - "version": "18.1.0", + "version": "18.1.1", "author": "Dmitriy Shekhovtsov ", "license": "MIT" } From 9968df424425e1fb61c9aa7e027ee4557e97da22 Mon Sep 17 00:00:00 2001 From: Meysam Bahadori Date: Thu, 17 Oct 2024 15:47:52 +0330 Subject: [PATCH 2/3] Add persian locale (#6560) Co-authored-by: Alexey Umanskiy --- src/chronos/i18n/fa.ts | 138 +++++++++++++ src/chronos/public_api.ts | 1 + src/chronos/testing/locale/fa.Spec.ts | 269 ++++++++++++++++++++++++++ 3 files changed, 408 insertions(+) create mode 100644 src/chronos/i18n/fa.ts create mode 100644 src/chronos/testing/locale/fa.Spec.ts diff --git a/src/chronos/i18n/fa.ts b/src/chronos/i18n/fa.ts new file mode 100644 index 0000000000..d2a31df237 --- /dev/null +++ b/src/chronos/i18n/fa.ts @@ -0,0 +1,138 @@ +//! moment.js locale configuration +//! locale : Persian [fa] +//! author : Meysam Bahadori: https://github.com/MeysamBahadori + +import { LocaleData } from '../locale/locale.class'; + +const symbolMap: {[key: string]: string} = { + 1: '١', + 2: '٢', + 3: '٣', + 4: '٤', + 5: '٥', + 6: '٦', + 7: '٧', + 8: '٨', + 9: '٩', + 0: '٠' + }; + +const numberMap: {[key: string]: string} = { + '١': '1', + '٢': '2', + '٣': '3', + '٤': '4', + '٥': '5', + '٦': '6', + '٧': '7', + '٨': '8', + '٩': '9', + '٠': '0' +}; + +const pluralForm = function (num: number): number { + return num === 0 ? 0 : num === 1 ? 1 : num === 2 ? 2 : num % 100 >= 3 && num % 100 <= 10 ? 3 : num % 100 >= 11 ? 4 : 5; + }; + +var plurals : {[key: string]: [string, string, [string, string], string, string, string]} = { + s: ['کمتر از یک ثانیه', 'یک ثانیه', ['دو ثانیه', 'دو ثانیه'], '%d ثانیه', '%d ثانیه', '%d ثانیه'], + m: ['کمتر از یک دقیقه', 'یک دقیقه', ['دو دقیقه', 'دو دقیقه'], '%d دقیقه', '%d دقیقه', '%d دقیقه'], + h: ['کمتر از یک ساعت', 'یک ساعت', ['دو ساعت', 'دو ساعت'], '%d ساعت', '%d ساعت', '%d ساعت'], + d: ['کمتر از یک روز', 'یک روز', ['دو روز', 'دو روز'], '%d روز', '%d روز', '%d روز'], + M: ['کمتر از یک ماه', 'یک ماه', ['دو ماه', 'دو ماه'], '%d ماه', '%d ماه', '%d ماه'], + y: ['کمتر از یک سال', 'یک سال', ['دو سال', 'دو سال'], '%d سال', '%d سال', '%d سال'] +}; + +const pluralize = function (u: string) { + return function (num: number, withoutSuffix: boolean): string { + const f = pluralForm(num); + let str = plurals[u][pluralForm(num)]; + if (f === 2) { + str = str[withoutSuffix ? 0 : 1]; + } + + return (str as string).replace(/%d/i, num.toString()); + }; + }; + + const months: string[] = [ + 'ژانویه', + 'فوریه', + 'مارس', + 'آوریل', + 'می', + 'ژوئن', + 'جولای', + 'آگوست', + 'سپتامبر', + 'اکتبر', + 'نوامبر', + 'دسامبر' +]; + +export const faLocale: LocaleData = { + abbr: 'fa', + months: months, + monthsShort: months, + weekdays: 'یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه_شنبه'.split('_'), + weekdaysShort: 'یکشنبه_دو‌شنبه_سه‌شنبه_چهار‌شنبه_پنج‌شنبه_جمعه_شنبه'.split('_'), + weekdaysMin: 'ی_د_س_چ_پ_ج_ش'.split('_'), + weekdaysParseExact: true, + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'D/\u200FM/\u200FYYYY', + LL: 'D MMMM YYYY', + LLL: 'D MMMM YYYY HH:mm', + LLLL: 'dddd D MMMM YYYY HH:mm' + }, + meridiemParse: /ص|م/, + isPM(input) { + return 'م' === input; + }, + meridiem(hour, minute, isLower) { + if (hour < 12) { + return 'ص'; + } else { + return 'م'; + } + }, + calendar: { + sameDay: '[امروز در ساعت] LT', + nextDay: '[فردا در ساعت] LT', + nextWeek: 'dddd [در ساعت] LT', + lastDay: '[دیروز در ساعت] LT', + lastWeek: 'dddd [در ساعت] LT', + sameElse: 'L' + }, + relativeTime: { + future: 'بعد %s', + past: 'پیش %s', + s: pluralize('s'), + ss: pluralize('s'), + m: pluralize('m'), + mm: pluralize('m'), + h: pluralize('h'), + hh: pluralize('h'), + d: pluralize('d'), + dd: pluralize('d'), + M: pluralize('M'), + MM: pluralize('M'), + y: pluralize('y'), + yy: pluralize('y') + }, + preparse(str: string): string { + return str.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) { + return numberMap[match]; + }).replace(/،/g, ','); + }, + postformat(str: string) { + return str.replace(/\d/g, function (match) { + return symbolMap[match]; + }).replace(/,/g, '،'); + }, + week: { + dow: 6, // Saturday is the first day of the week. + doy: 80 // The week that contains March 21th is the first week of the year. + } +}; diff --git a/src/chronos/public_api.ts b/src/chronos/public_api.ts index 24c705c558..d5f67b54a7 100644 --- a/src/chronos/public_api.ts +++ b/src/chronos/public_api.ts @@ -80,3 +80,4 @@ export { trLocale } from './i18n/tr'; export { ukLocale } from './i18n/uk'; export { viLocale } from './i18n/vi'; export { zhCnLocale } from './i18n/zh-cn'; +export { faLocale } from './i18n/fa'; \ No newline at end of file diff --git a/src/chronos/testing/locale/fa.Spec.ts b/src/chronos/testing/locale/fa.Spec.ts new file mode 100644 index 0000000000..e0d4924448 --- /dev/null +++ b/src/chronos/testing/locale/fa.Spec.ts @@ -0,0 +1,269 @@ +// tslint:disable:max-line-length max-file-line-count prefer-const forin prefer-template one-variable-per-declaration newline-before-return +// tslint:disable:binary-expression-operand-order comment-format one-line no-var-keyword object-literal-shorthand +// tslint:disable:variable-name no-shadowed-variable + +import { assertEq, assertDeepEq } from '../test-helpers'; +import { moment } from '../chain'; +import { faLocale } from '../../i18n/fa'; + +// localeModule('fa'); + +var months = [ + 'ژانویه', + 'فوریه', + 'مارس', + 'آوریل', + 'می', + 'ژوئن', + 'جولای', + 'آگوست', + 'سپتامبر', + 'اکتبر', + 'نوامبر', + 'دسامبر' +]; +describe('locale: fa', () => { + beforeAll(() => { + moment.locale('fa', faLocale); + }); + + afterAll(() => { + moment.locale('en'); + }); + + it('parse', function () { + var tests = months, i; + + function equalit(input, mmm, i) { + assertEq(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1) + ' instead is month ' + moment(input, mmm).month()); + } + + for (i = 0; i < 12; i++) { + equalit(tests[i], 'MMM', i); + equalit(tests[i], 'MMM', i); + equalit(tests[i], 'MMMM', i); + equalit(tests[i], 'MMMM', i); + equalit(tests[i].toLocaleLowerCase(), 'MMMM', i); + equalit(tests[i].toLocaleLowerCase(), 'MMMM', i); + equalit(tests[i].toLocaleUpperCase(), 'MMMM', i); + equalit(tests[i].toLocaleUpperCase(), 'MMMM', i); + } + }); + + it('format', function () { + var a = [ + ['dddd, MMMM Do YYYY, h:mm:ss a', 'یکشنبه، فوریه ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'], + ['ddd, hA', 'یکشنبه، ٣م'], + ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فوریه فوریه'], + ['YYYY YY', '٢٠١٠ ١٠'], + ['D Do DD', '١٤ ١٤ ١٤'], + ['d do dddd ddd dd', '٠ ٠ یکشنبه یکشنبه ی'], + ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'], + ['w wo ww', '٨ ٨ ٠٨'], + ['h hh', '٣ ٠٣'], + ['H HH', '١٥ ١٥'], + ['m mm', '٢٥ ٢٥'], + ['s ss', '٥٠ ٥٠'], + ['a A', 'م م'], + ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'], + ['LT', '١٥:٢٥'], + ['LTS', '١٥:٢٥:٥٠'], + ['L', '١٤/\u200f٢/\u200f٢٠١٠'], + ['LL', '١٤ فوریه ٢٠١٠'], + ['LLL', '١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['LLLL', 'یکشنبه ١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['l', '١٤/\u200f٢/\u200f٢٠١٠'], + ['ll', '١٤ فوریه ٢٠١٠'], + ['lll', '١٤ فوریه ٢٠١٠ ١٥:٢٥'], + ['llll', 'یکشنبه ١٤ فوریه ٢٠١٠ ١٥:٢٥'] + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + assertEq(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } + }); + + it('format ordinal', function () { + assertEq(moment([2011, 0, 1]).format('DDDo'), '١', '1'); + assertEq(moment([2011, 0, 2]).format('DDDo'), '٢', '2'); + assertEq(moment([2011, 0, 3]).format('DDDo'), '٣', '3'); + assertEq(moment([2011, 0, 4]).format('DDDo'), '٤', '4'); + assertEq(moment([2011, 0, 5]).format('DDDo'), '٥', '5'); + assertEq(moment([2011, 0, 6]).format('DDDo'), '٦', '6'); + assertEq(moment([2011, 0, 7]).format('DDDo'), '٧', '7'); + assertEq(moment([2011, 0, 8]).format('DDDo'), '٨', '8'); + assertEq(moment([2011, 0, 9]).format('DDDo'), '٩', '9'); + assertEq(moment([2011, 0, 10]).format('DDDo'), '١٠', '10'); + + assertEq(moment([2011, 0, 11]).format('DDDo'), '١١', '11'); + assertEq(moment([2011, 0, 12]).format('DDDo'), '١٢', '12'); + assertEq(moment([2011, 0, 13]).format('DDDo'), '١٣', '13'); + assertEq(moment([2011, 0, 14]).format('DDDo'), '١٤', '14'); + assertEq(moment([2011, 0, 15]).format('DDDo'), '١٥', '15'); + assertEq(moment([2011, 0, 16]).format('DDDo'), '١٦', '16'); + assertEq(moment([2011, 0, 17]).format('DDDo'), '١٧', '17'); + assertEq(moment([2011, 0, 18]).format('DDDo'), '١٨', '18'); + assertEq(moment([2011, 0, 19]).format('DDDo'), '١٩', '19'); + assertEq(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20'); + + assertEq(moment([2011, 0, 21]).format('DDDo'), '٢١', '21'); + assertEq(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22'); + assertEq(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23'); + assertEq(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24'); + assertEq(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25'); + assertEq(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26'); + assertEq(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27'); + assertEq(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28'); + assertEq(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29'); + assertEq(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30'); + + assertEq(moment([2011, 0, 31]).format('DDDo'), '٣١', '31'); + }); + + it('format month', function () { + var expected = months, i; + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, i, 1]).format('MMMM'), expected[i], expected[i]); + assertEq(moment([2011, i, 1]).format('MMM'), expected[i], expected[i]); + } + }); + + it('format week', function () { + var expected = 'یکشنبه یکشنبه ی_دوشنبه دوشنبه د_سه‌شنبه سه‌شنبه س_چهارشنبه چهارشنبه چ_پنج‌شنبه پنج‌شنبه پ_جمعه جمعه ج_شنبه شنبه ش'.split('_'), + i; + for (i = 0; i < expected.length; i++) { + assertEq(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); + } + }); + + it('from', function () { + var start = moment([2007, 1, 28]); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 44 }), true), '٤٤ ثانیه', '44 seconds = a few seconds'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 45 }), true), 'یک دقیقه', '45 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 89 }), true), 'یک دقیقه', '89 seconds = a minute'); + assertEq(start.from(moment([2007, 1, 28]).add({ s: 90 }), true), 'دقیقه', '90 seconds = 2 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 44 }), true), '٤٤ دقیقه', '44 minutes = 44 minutes'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 45 }), true), 'یک ساعت', '45 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 89 }), true), 'یک ساعت', '89 minutes = an hour'); + assertEq(start.from(moment([2007, 1, 28]).add({ m: 90 }), true), 'ساعت', '90 minutes = 2 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 5 }), true), '٥ ساعت', '5 hours = 5 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 21 }), true), '٢١ ساعت', '21 hours = 21 hours'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 22 }), true), 'یک روز', '22 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 35 }), true), 'یک روز', '35 hours = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ h: 36 }), true), 'روز', '36 hours = 2 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 1 }), true), 'یک روز', '1 day = a day'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 5 }), true), '٥ روز', '5 days = 5 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 25 }), true), '٢٥ روز', '25 days = 25 days'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 26 }), true), 'یک ماه', '26 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 30 }), true), 'یک ماه', '30 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 43 }), true), 'یک ماه', '43 days = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 46 }), true), 'ماه', '46 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 74 }), true), 'ماه', '75 days = 2 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 76 }), true), '٣ ماه', '76 days = 3 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 1 }), true), 'یک ماه', '1 month = a month'); + assertEq(start.from(moment([2007, 1, 28]).add({ M: 5 }), true), '٥ ماه', '5 months = 5 months'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 345 }), true), 'یک سال', '345 days = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ d: 548 }), true), 'سال', '548 days = 2 years'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 1 }), true), 'سال', '1 year = a year'); + assertEq(start.from(moment([2007, 1, 28]).add({ y: 5 }), true), '٥ سال', '5 years = 5 years'); + }); + + it('suffix', function () { + assertEq(moment(30000).from(0), '٣٠ ثانیه بعد', 'prefix'); + assertEq(moment(0).from(30000), '٣٠ ثانیه پیش', 'suffix'); + }); + + it('now from now', function () { + assertEq(moment().fromNow(), 'یک ثانیه پیش', 'now from now should display as in the past'); + }); + + it('fromNow', function () { + assertEq(moment().add({ s: 30 }).fromNow(), '٣٠ ثانیه بعد', 'in a few seconds'); + assertEq(moment().add({ d: 5 }).fromNow(), '٥ روز بعد', 'in 5 days'); + }); + + it('calendar day', function () { + var a = moment().hours(12).minutes(0).seconds(0); + + assertEq(moment(a).calendar(), 'اليوم عند الساعة امروز ساعت ١٢:٠٠', 'today at the same time'); + assertEq(moment(a).add({ m: 25 }).calendar(), 'امروز ساعت ١٢:٢٥', 'Now plus 25 min'); + assertEq(moment(a).add({ h: 1 }).calendar(), 'امروز ساعت ١٣:٠٠', 'Now plus 1 hour'); + assertEq(moment(a).add({ d: 1 }).calendar(), 'فردا ساعت ١٢:٠٠', 'tomorrow at the same time'); + assertEq(moment(a).subtract({ h: 1 }).calendar(), 'امروز ساعت ١١:٠٠', 'Now minus 1 hour'); + assertEq(moment(a).subtract({ d: 1 }).calendar(), 'دیروز ساعت ١٢:٠٠', 'yesterday at the same time'); + }); + + it('calendar next week', function () { + var i, m; + for (i = 2; i < 7; i++) { + m = moment().add({ d: i }); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today + ' + i + ' days end of day'); + } + }); + + it('calendar last week', function () { + var i, m; + for (i = 2; i < 7; i++) { + m = moment().subtract({ d: i }); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days current time'); + m.hours(0).minutes(0).seconds(0).milliseconds(0); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days beginning of day'); + m.hours(23).minutes(59).seconds(59).milliseconds(999); + assertEq(m.calendar(), m.format('dddd [در ساعت] LT'), 'Today - ' + i + ' days end of day'); + } + }); + + it('calendar all else', function () { + var weeksAgo = moment().subtract({ w: 1 }), + weeksFromNow = moment().add({ w: 1 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '1 week ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 1 week'); + + weeksAgo = moment().subtract({ w: 2 }); + weeksFromNow = moment().add({ w: 2 }); + + assertEq(weeksAgo.calendar(), weeksAgo.format('L'), '2 weeks ago'); + assertEq(weeksFromNow.calendar(), weeksFromNow.format('L'), 'in 2 weeks'); + }); + + it('weeks year starting wednesday custom', function () { + assertEq(moment('2003 1 6', 'gggg w d').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002'); + assertEq(moment('2003 1 0', 'gggg w e').format('YYYY-MM-DD'), '٢٠٠٢-١٢-٢٨', 'Week 1 of 2003 should be Dec 28 2002'); + assertEq(moment('2003 1 6', 'gggg w d').format('gggg w d'), '٢٠٠٣ ١ ٦', 'Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6'); + assertEq(moment('2003 1 0', 'gggg w e').format('gggg w e'), '٢٠٠٣ ١ ٠', '1st day of week 1 of 2003 parsed should be formatted as 2003 1 0'); + }); + + it('weeks year starting sunday formatted', function () { + assertEq(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', 'Dec 31 2011 should be week 1'); + assertEq(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', 'Jan 6 2012 should be week 1'); + assertEq(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 7 2012 should be week 2'); + assertEq(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', 'Jan 13 2012 should be week 2'); + assertEq(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', 'Jan 14 2012 should be week 3'); + }); + + it('no leading zeros in long date formats', function () { + var i, j, longDateStr, shortDateStr; + for (i = 1; i <= 9; ++i) { + for (j = 1; j <= 9; ++j) { + longDateStr = moment([2014, i, j]).format('L'); + shortDateStr = moment([2014, i, j]).format('l'); + assertEq(longDateStr, shortDateStr, 'should not have leading zeros in month or day'); + } + } + }); + + // locale-specific + it('fa strict mode parsing works', function () { + var m, formattedDate; + m = moment().locale('fa'); + formattedDate = m.format('l'); + assertEq(moment.utc(formattedDate, 'l', 'fa', false).isValid(), true, 'Non-strict parsing works'); + assertEq(moment.utc(formattedDate, 'l', 'fa', true).isValid(), true, 'Strict parsing must work'); + }); +}); \ No newline at end of file From 83c3912c30876626f9075d89ef85595b0bb1d27e Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Thu, 17 Oct 2024 21:26:30 +0900 Subject: [PATCH 3/3] Add syntax highlighting to README (#6603) Co-authored-by: Dmitriy Shekhovtsov Co-authored-by: Alexey Umanskiy --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0230c075ff..8891c7de6a 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ npm install ngx-bootstrap --save Add wanted package to NgModule imports: -``` +```ts import { TooltipModule } from 'ngx-bootstrap/tooltip'; @NgModule({ @@ -113,7 +113,7 @@ import { TooltipModule } from 'ngx-bootstrap/tooltip'; Add component to your page: -``` +```html