ngx-tethys 19.0.12 → 19.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/action/action.component.d.ts +2 -2
- package/alert/alert.component.d.ts +1 -1
- package/anchor/anchor-link.component.d.ts +8 -8
- package/anchor/anchor.component.d.ts +15 -21
- package/arrow-switcher/arrow-switcher.component.d.ts +15 -22
- package/autocomplete/autocomplete.component.d.ts +10 -17
- package/autocomplete/autocomplete.trigger.directive.d.ts +10 -18
- package/avatar/avatar-list/avatar-list.component.d.ts +1 -1
- package/avatar/avatar.component.d.ts +5 -5
- package/back-top/back-top.component.d.ts +9 -12
- package/badge/badge.component.d.ts +19 -59
- package/breadcrumb/breadcrumb.component.d.ts +15 -20
- package/button/button-icon.component.d.ts +3 -2
- package/button/button.component.d.ts +3 -2
- package/calendar/calendar-header.component.d.ts +9 -8
- package/calendar/calendar.component.d.ts +16 -16
- package/card/card.component.d.ts +5 -11
- package/card/content.component.d.ts +3 -8
- package/card/header.component.d.ts +7 -8
- package/carousel/carousel.component.d.ts +22 -27
- package/cascader/cascader-li.component.d.ts +13 -21
- package/cascader/cascader-search-option.component.d.ts +8 -16
- package/cascader/cascader.component.d.ts +58 -80
- package/checkbox/checkbox.component.d.ts +2 -5
- package/collapse/collapse-item.component.d.ts +12 -19
- package/collapse/collapse.component.d.ts +6 -12
- package/collapse/collapse.token.d.ts +3 -3
- package/color-picker/color-picker-custom-panel.component.d.ts +5 -5
- package/color-picker/color-picker-panel.component.d.ts +7 -11
- package/color-picker/color-picker.component.d.ts +19 -35
- package/color-picker/parts/alpha/alpha.component.d.ts +8 -8
- package/color-picker/parts/hue/hue.component.d.ts +6 -6
- package/color-picker/parts/indicator/indicator.component.d.ts +4 -3
- package/color-picker/parts/inputs/inputs.component.d.ts +9 -9
- package/color-picker/parts/saturation/saturation.component.d.ts +9 -9
- package/comment/comment.component.d.ts +4 -5
- package/copy/copy.directive.d.ts +8 -9
- package/date-picker/abstract-picker.component.d.ts +8 -7
- package/date-picker/lib/calendar/calendar-footer.component.d.ts +2 -1
- package/date-picker/lib/popups/inner-popup.component.d.ts +2 -1
- package/date-picker/picker.component.d.ts +2 -1
- package/date-range/date-range.component.d.ts +2 -2
- package/dialog/body/dialog-body.component.d.ts +2 -6
- package/dialog/confirm/confirm.component.d.ts +2 -2
- package/dialog/footer/dialog-footer.component.d.ts +6 -9
- package/dialog/header/dialog-header.component.d.ts +9 -11
- package/divider/divider.component.d.ts +12 -16
- package/dot/dot.component.d.ts +5 -13
- package/drag-drop/drag-handle.directive.d.ts +2 -1
- package/drag-drop/drag.directive.d.ts +2 -1
- package/drag-drop/drop-container.directive.d.ts +2 -1
- package/dropdown/dropdown-menu-item.directive.d.ts +3 -2
- package/dropdown/dropdown-menu.component.d.ts +2 -1
- package/dropdown/dropdown.directive.d.ts +2 -1
- package/empty/empty.component.d.ts +21 -27
- package/fesm2022/ngx-tethys-anchor.mjs +91 -118
- package/fesm2022/ngx-tethys-anchor.mjs.map +1 -1
- package/fesm2022/ngx-tethys-arrow-switcher.mjs +51 -77
- package/fesm2022/ngx-tethys-arrow-switcher.mjs.map +1 -1
- package/fesm2022/ngx-tethys-autocomplete.mjs +69 -103
- package/fesm2022/ngx-tethys-autocomplete.mjs.map +1 -1
- package/fesm2022/ngx-tethys-avatar.mjs.map +1 -1
- package/fesm2022/ngx-tethys-back-top.mjs +33 -46
- package/fesm2022/ngx-tethys-back-top.mjs.map +1 -1
- package/fesm2022/ngx-tethys-badge.mjs +104 -208
- package/fesm2022/ngx-tethys-badge.mjs.map +1 -1
- package/fesm2022/ngx-tethys-breadcrumb.mjs +66 -70
- package/fesm2022/ngx-tethys-breadcrumb.mjs.map +1 -1
- package/fesm2022/ngx-tethys-calendar.mjs +85 -87
- package/fesm2022/ngx-tethys-calendar.mjs.map +1 -1
- package/fesm2022/ngx-tethys-card.mjs +72 -77
- package/fesm2022/ngx-tethys-card.mjs.map +1 -1
- package/fesm2022/ngx-tethys-carousel.mjs +82 -99
- package/fesm2022/ngx-tethys-carousel.mjs.map +1 -1
- package/fesm2022/ngx-tethys-cascader.mjs +313 -468
- package/fesm2022/ngx-tethys-cascader.mjs.map +1 -1
- package/fesm2022/ngx-tethys-checkbox.mjs +10 -17
- package/fesm2022/ngx-tethys-checkbox.mjs.map +1 -1
- package/fesm2022/ngx-tethys-collapse.mjs +66 -71
- package/fesm2022/ngx-tethys-collapse.mjs.map +1 -1
- package/fesm2022/ngx-tethys-color-picker.mjs +187 -246
- package/fesm2022/ngx-tethys-color-picker.mjs.map +1 -1
- package/fesm2022/ngx-tethys-comment.mjs +16 -10
- package/fesm2022/ngx-tethys-comment.mjs.map +1 -1
- package/fesm2022/ngx-tethys-copy.mjs +25 -28
- package/fesm2022/ngx-tethys-copy.mjs.map +1 -1
- package/fesm2022/ngx-tethys-dialog.mjs +81 -82
- package/fesm2022/ngx-tethys-dialog.mjs.map +1 -1
- package/fesm2022/ngx-tethys-divider.mjs +49 -58
- package/fesm2022/ngx-tethys-divider.mjs.map +1 -1
- package/fesm2022/ngx-tethys-dot.mjs +45 -68
- package/fesm2022/ngx-tethys-dot.mjs.map +1 -1
- package/fesm2022/ngx-tethys-empty.mjs +107 -95
- package/fesm2022/ngx-tethys-empty.mjs.map +1 -1
- package/fesm2022/ngx-tethys-form.mjs +161 -200
- package/fesm2022/ngx-tethys-form.mjs.map +1 -1
- package/fesm2022/ngx-tethys-fullscreen.mjs +21 -23
- package/fesm2022/ngx-tethys-fullscreen.mjs.map +1 -1
- package/fesm2022/ngx-tethys-grid.mjs +160 -152
- package/fesm2022/ngx-tethys-grid.mjs.map +1 -1
- package/fesm2022/ngx-tethys-i18n.mjs +25 -25
- package/fesm2022/ngx-tethys-i18n.mjs.map +1 -1
- package/fesm2022/ngx-tethys-input-number.mjs +101 -114
- package/fesm2022/ngx-tethys-input-number.mjs.map +1 -1
- package/fesm2022/ngx-tethys-input.mjs +268 -271
- package/fesm2022/ngx-tethys-input.mjs.map +1 -1
- package/fesm2022/ngx-tethys-loading.mjs +17 -35
- package/fesm2022/ngx-tethys-loading.mjs.map +1 -1
- package/fesm2022/ngx-tethys-mention.mjs +3 -3
- package/fesm2022/ngx-tethys-mention.mjs.map +1 -1
- package/fesm2022/ngx-tethys-menu.mjs +106 -179
- package/fesm2022/ngx-tethys-menu.mjs.map +1 -1
- package/fesm2022/ngx-tethys-nav.mjs +169 -201
- package/fesm2022/ngx-tethys-nav.mjs.map +1 -1
- package/fesm2022/ngx-tethys-pagination.mjs +230 -294
- package/fesm2022/ngx-tethys-pagination.mjs.map +1 -1
- package/fesm2022/ngx-tethys-popover.mjs +67 -70
- package/fesm2022/ngx-tethys-popover.mjs.map +1 -1
- package/fesm2022/ngx-tethys-progress.mjs +196 -244
- package/fesm2022/ngx-tethys-progress.mjs.map +1 -1
- package/fesm2022/ngx-tethys-property.mjs +102 -105
- package/fesm2022/ngx-tethys-property.mjs.map +1 -1
- package/fesm2022/ngx-tethys-radio.mjs +34 -38
- package/fesm2022/ngx-tethys-radio.mjs.map +1 -1
- package/fesm2022/ngx-tethys-result.mjs +46 -28
- package/fesm2022/ngx-tethys-result.mjs.map +1 -1
- package/fesm2022/ngx-tethys-skeleton.mjs +339 -342
- package/fesm2022/ngx-tethys-skeleton.mjs.map +1 -1
- package/fesm2022/ngx-tethys-slider.mjs +75 -108
- package/fesm2022/ngx-tethys-slider.mjs.map +1 -1
- package/fesm2022/ngx-tethys-space.mjs +26 -46
- package/fesm2022/ngx-tethys-space.mjs.map +1 -1
- package/fesm2022/ngx-tethys-statistic.mjs +114 -151
- package/fesm2022/ngx-tethys-statistic.mjs.map +1 -1
- package/fesm2022/ngx-tethys-stepper.mjs +74 -107
- package/fesm2022/ngx-tethys-stepper.mjs.map +1 -1
- package/fesm2022/ngx-tethys-switch.mjs +80 -140
- package/fesm2022/ngx-tethys-switch.mjs.map +1 -1
- package/fesm2022/ngx-tethys-table.mjs +1 -1
- package/fesm2022/ngx-tethys-table.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tabs.mjs +69 -87
- package/fesm2022/ngx-tethys-tabs.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tag.mjs +42 -64
- package/fesm2022/ngx-tethys-tag.mjs.map +1 -1
- package/fesm2022/ngx-tethys-timeline.mjs +104 -129
- package/fesm2022/ngx-tethys-timeline.mjs.map +1 -1
- package/fesm2022/ngx-tethys-typography.mjs +36 -33
- package/fesm2022/ngx-tethys-typography.mjs.map +1 -1
- package/fesm2022/ngx-tethys-upload.mjs +91 -130
- package/fesm2022/ngx-tethys-upload.mjs.map +1 -1
- package/fesm2022/ngx-tethys-util.mjs.map +1 -1
- package/fesm2022/ngx-tethys-watermark.mjs +36 -40
- package/fesm2022/ngx-tethys-watermark.mjs.map +1 -1
- package/fesm2022/ngx-tethys.mjs +1 -1
- package/fesm2022/ngx-tethys.mjs.map +1 -1
- package/form/form-group-error/form-group-error.component.d.ts +2 -3
- package/form/form-group-label.directive.d.ts +2 -1
- package/form/form-group.component.d.ts +17 -24
- package/form/form-submit.directive.d.ts +2 -2
- package/form/form.directive.d.ts +6 -8
- package/form/from-group-footer/form-group-footer.component.d.ts +2 -2
- package/form/validator/confirm-validator.directive.d.ts +2 -2
- package/form/validator/unique-validator.directive.d.ts +2 -2
- package/fullscreen/fullscreen.component.d.ts +7 -7
- package/grid/flex.d.ts +14 -19
- package/grid/thy-col.directive.d.ts +6 -9
- package/grid/thy-grid-item.component.d.ts +3 -4
- package/grid/thy-grid.component.d.ts +11 -12
- package/grid/thy-row.directive.d.ts +12 -12
- package/icon/icon.component.d.ts +3 -2
- package/image/image.directive.d.ts +3 -2
- package/input/input-count.component.d.ts +4 -5
- package/input/input-group.component.d.ts +20 -20
- package/input/input-search.component.d.ts +15 -20
- package/input/input.component.d.ts +20 -21
- package/input/input.directive.d.ts +4 -6
- package/input-number/input-number.component.d.ts +21 -29
- package/layout/header.component.d.ts +4 -9
- package/layout/sidebar-header.component.d.ts +2 -1
- package/layout/sidebar.component.d.ts +8 -7
- package/list/list.component.d.ts +2 -1
- package/list/selection/selection-list.d.ts +4 -3
- package/loading/loading.component.d.ts +4 -10
- package/mention/mention.directive.d.ts +2 -2
- package/menu/group/menu-group.component.d.ts +16 -33
- package/menu/item/action/menu-item-action.component.d.ts +7 -8
- package/menu/item/icon/menu-item-icon.component.d.ts +2 -2
- package/menu/item/menu-item.component.d.ts +4 -4
- package/menu/item/name/menu-item-name.component.d.ts +2 -3
- package/menu/menu.component.d.ts +3 -7
- package/nav/icon-nav/icon-nav-link.directive.d.ts +3 -7
- package/nav/icon-nav/icon-nav.component.d.ts +3 -8
- package/nav/nav-ink-bar.directive.d.ts +4 -6
- package/nav/nav-item.directive.d.ts +7 -10
- package/nav/nav.component.d.ts +20 -48
- package/package.json +1 -1
- package/pagination/pagination.component.d.ts +48 -109
- package/popover/header/popover-header.component.d.ts +7 -6
- package/popover/popover.directive.d.ts +11 -18
- package/progress/progress-circle.component.d.ts +32 -21
- package/progress/progress-strip.component.d.ts +10 -14
- package/progress/progress.component.d.ts +15 -23
- package/property/examples/single/single.component.scss +6 -0
- package/property/properties.component.d.ts +6 -13
- package/property/property-item.component.d.ts +21 -26
- package/property/styles/properties.scss +124 -52
- package/property-operation/property-operation.component.d.ts +6 -5
- package/radio/button/radio-button.component.d.ts +2 -2
- package/radio/group/radio-group.component.d.ts +8 -7
- package/radio/radio.component.d.ts +2 -2
- package/radio/radio.token.d.ts +2 -2
- package/rate/rate-item.component.d.ts +2 -1
- package/rate/rate.component.d.ts +4 -3
- package/resizable/resizable.directive.d.ts +4 -9
- package/resizable/resize-handle.component.d.ts +2 -1
- package/resizable/resize-handles.component.d.ts +2 -1
- package/result/result.component.d.ts +9 -10
- package/schematics/version.d.ts +1 -1
- package/schematics/version.js +1 -1
- package/segment/segment-item.component.d.ts +2 -1
- package/segment/segment.component.d.ts +2 -1
- package/select/custom-select/custom-select.component.d.ts +11 -10
- package/select/native-select/native-select.component.d.ts +2 -1
- package/shared/base-form-check.component.d.ts +3 -2
- package/shared/directives/thy-autofocus.directive.d.ts +3 -2
- package/shared/directives/thy-scroll.directive.d.ts +2 -1
- package/shared/directives/thy-show.d.ts +2 -1
- package/shared/option/group/option-group.component.d.ts +2 -1
- package/shared/option/list-option/list-option.component.d.ts +2 -7
- package/shared/option/option.component.d.ts +2 -1
- package/shared/select/select-control/select-control.component.d.ts +7 -6
- package/skeleton/skeleton-circle.component.d.ts +16 -19
- package/skeleton/skeleton-rectangle.component.d.ts +20 -23
- package/skeleton/skeleton.component.d.ts +5 -6
- package/skeleton/stylized/bullet-list.component.d.ts +11 -13
- package/skeleton/stylized/list.component.d.ts +10 -12
- package/skeleton/stylized/paragraph.component.d.ts +12 -14
- package/slide/slide-body/slide-body-section.component.d.ts +2 -1
- package/slider/slider.component.d.ts +17 -24
- package/space/space.component.d.ts +8 -8
- package/statistic/statistic.component.d.ts +35 -40
- package/stepper/step-header.component.d.ts +6 -10
- package/stepper/step.component.d.ts +6 -6
- package/stepper/stepper.component.d.ts +15 -20
- package/switch/switch.component.d.ts +24 -35
- package/table/table-column.component.d.ts +6 -5
- package/table/table-skeleton.component.d.ts +3 -10
- package/table/table.component.d.ts +11 -10
- package/tabs/tab-content.component.d.ts +4 -4
- package/tabs/tab.component.d.ts +4 -5
- package/tabs/tabs.component.d.ts +13 -15
- package/tag/tag.component.d.ts +10 -16
- package/time-picker/time-picker-panel.component.d.ts +3 -2
- package/time-picker/time-picker.component.d.ts +6 -5
- package/timeline/timeline-item.component.d.ts +9 -13
- package/timeline/timeline.component.d.ts +13 -17
- package/tooltip/tooltip.directive.d.ts +3 -2
- package/tree/tree-node.component.d.ts +6 -15
- package/tree/tree.component.d.ts +8 -7
- package/tree-select/tree-select.component.d.ts +8 -7
- package/typography/bg-color.directive.d.ts +3 -3
- package/typography/text/text.component.d.ts +2 -2
- package/typography/text-color.directive.d.ts +3 -3
- package/upload/file-drop.directive.d.ts +9 -11
- package/upload/file-select-base.d.ts +6 -10
- package/upload/file-select.component.d.ts +10 -20
- package/util/helpers/helpers.d.ts +2 -1
- package/vote/vote.component.d.ts +4 -3
- package/watermark/watermark.directive.d.ts +7 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-tethys-back-top.mjs","sources":["../../../src/back-top/back-top.component.ts","../../../src/back-top/back-top.component.html","../../../src/back-top/back-top.module.ts","../../../src/back-top/ngx-tethys-back-top.ts"],"sourcesContent":["import {\n Component,\n OnInit,\n ChangeDetectionStrategy,\n ViewEncapsulation,\n Input,\n TemplateRef,\n EventEmitter,\n Output,\n HostBinding,\n NgZone,\n ChangeDetectorRef,\n OnDestroy,\n OnChanges,\n ViewChild,\n ElementRef,\n numberAttribute,\n inject\n} from '@angular/core';\nimport { Subject, fromEvent, BehaviorSubject, EMPTY, Observable } from 'rxjs';\nimport { Platform } from '@angular/cdk/platform';\nimport { throttleTime, takeUntil, switchMap } from 'rxjs/operators';\nimport { DOCUMENT, NgTemplateOutlet } from '@angular/common';\nimport { fadeMotion, ThyScrollService } from 'ngx-tethys/core';\nimport { ThyIcon } from 'ngx-tethys/icon';\n\n/**\n * 回到顶部组件\n * @name thy-back-top\n */\n@Component({\n selector: 'thy-back-top,[thyBackTop]',\n templateUrl: './back-top.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n animations: [fadeMotion],\n imports: [ThyIcon, NgTemplateOutlet]\n})\nexport class ThyBackTop implements OnInit, OnDestroy, OnChanges {\n private doc = inject(DOCUMENT);\n private thyScrollService = inject(ThyScrollService);\n private platform = inject(Platform);\n private cdr = inject(ChangeDetectorRef);\n private zone = inject(NgZone);\n\n @HostBinding('class.thy-back-top-container') classNames = true;\n\n /**\n * 自定义按钮显示模板\n */\n @Input() thyTemplate?: TemplateRef<void>;\n\n /**\n * 指定对哪个 DOM 元素返回顶部\n * @type string | HTMLElement\n * @default window\n */\n @Input() thyContainer?: string | HTMLElement;\n\n /**\n * 滚动高度达到此参数值才出现 thy-back-top\n * @type number\n */\n @Input({ transform: numberAttribute }) thyVisibilityHeight = 400;\n\n /**\n * 点击按钮的回调函数\n */\n @Output() readonly thyClick: EventEmitter<boolean> = new EventEmitter();\n\n /**\n * 监听按钮显示状态的回调函数\n */\n @Output() public visibleChange: EventEmitter<boolean> = new EventEmitter();\n\n /** The native `<div class=\"thy-back-top\"></div>` element. */\n @ViewChild('backTop', { static: false })\n set backTop(backTop: ElementRef<HTMLElement> | undefined) {\n this.backTop$.next(backTop);\n }\n\n public visible = false;\n\n /**\n * The subject used to store the native `<div class=\"thy-back-top\"></div>` since\n * it's located within the `ngIf` directive. It might be set asynchronously whenever the condition\n * is met. Having subject makes the code reactive and cancellable (e.g. event listeners will be\n * automatically removed and re-added through the `switchMap` below).\n */\n private backTop$ = new BehaviorSubject<ElementRef<HTMLElement> | undefined>(undefined);\n\n private destroy$ = new Subject<void>();\n private scrollListenerDestroy$ = new Subject<void>();\n\n private target: HTMLElement | null = null;\n\n constructor() {\n const zone = this.zone;\n\n this.backTop$\n .pipe(\n switchMap(backTop =>\n backTop\n ? new Observable(subscriber =>\n zone.runOutsideAngular(() => fromEvent(backTop.nativeElement, 'click').subscribe(subscriber))\n )\n : EMPTY\n ),\n takeUntil(this.destroy$)\n )\n .subscribe(() => {\n this.thyScrollService.scrollTo(this.getTarget(), 0);\n if (this.thyClick.observers.length) {\n zone.run(() => this.thyClick.emit(true));\n }\n });\n }\n\n ngOnInit(): void {\n this.registerScrollEvent();\n }\n\n private getTarget(): HTMLElement | Window {\n return this.target || window;\n }\n\n private handleScroll(): void {\n if (this.visible === this.thyScrollService.getScroll(this.getTarget()) > this.thyVisibilityHeight) {\n return;\n }\n this.visible = !this.visible;\n this.cdr.detectChanges();\n if (this.visibleChange.observers.length > 0) {\n this.zone.run(() => {\n this.visibleChange.emit(this.visible);\n });\n }\n }\n\n private registerScrollEvent(): void {\n if (!this.platform.isBrowser) {\n return;\n }\n this.scrollListenerDestroy$.next();\n this.handleScroll();\n this.zone.runOutsideAngular(() => {\n fromEvent(this.getTarget(), 'scroll', { passive: true })\n .pipe(throttleTime(50), takeUntil(this.scrollListenerDestroy$))\n .subscribe(() => this.handleScroll());\n });\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.scrollListenerDestroy$.next();\n }\n\n ngOnChanges(changes: any): void {\n const { thyContainer } = changes;\n if (thyContainer) {\n this.target = typeof this.thyContainer === 'string' ? this.doc.querySelector(this.thyContainer) : this.thyContainer;\n this.registerScrollEvent();\n }\n }\n}\n","@if (visible) {\n <div class=\"thy-back-top\" #backTop @fadeMotion>\n <ng-template #defaultContent>\n <div class=\"thy-back-top-content\">\n <thy-icon class=\"back-top-icon text-muted font-size-lg\" thyIconName=\"arrow-up\"></thy-icon>\n </div>\n </ng-template>\n <ng-template [ngTemplateOutlet]=\"thyTemplate || defaultContent\"></ng-template>\n </div>\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ThyIconModule } from 'ngx-tethys/icon';\nimport { ThyBackTop } from './back-top.component';\n\n@NgModule({\n imports: [CommonModule, ThyIconModule, ThyBackTop],\n exports: [ThyBackTop]\n})\nexport class ThyBackTopModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA0BA;;;AAGG;MASU,UAAU,CAAA;;IAsCnB,IACI,OAAO,CAAC,OAA4C,EAAA;AACpD,QAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;;AAkB/B,IAAA,WAAA,GAAA;AAzDQ,QAAA,IAAA,CAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC3C,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC3B,QAAA,IAAA,CAAA,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;A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AAE,aAAa,EAAE,UAAU,aACvC,UAAU,CAAA,EAAA,CAAA,CAAA;AAEX,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,EAHf,OAAA,EAAA,CAAA,YAAY,EAAE,aAAa,EAAE,UAAU,CAAA,EAAA,CAAA,CAAA;;2FAGxC,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;oBAClD,OAAO,EAAE,CAAC,UAAU;AACvB,iBAAA;;;ACRD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-tethys-back-top.mjs","sources":["../../../src/back-top/back-top.component.ts","../../../src/back-top/back-top.component.html","../../../src/back-top/back-top.module.ts","../../../src/back-top/ngx-tethys-back-top.ts"],"sourcesContent":["import {\n Component,\n OnInit,\n ChangeDetectionStrategy,\n ViewEncapsulation,\n TemplateRef,\n HostBinding,\n NgZone,\n ChangeDetectorRef,\n OnDestroy,\n OnChanges,\n ViewChild,\n ElementRef,\n numberAttribute,\n inject,\n input,\n output,\n effect,\n viewChild,\n Signal,\n computed\n} from '@angular/core';\nimport { Subject, fromEvent, BehaviorSubject, EMPTY, Observable } from 'rxjs';\nimport { Platform } from '@angular/cdk/platform';\nimport { throttleTime, takeUntil, switchMap } from 'rxjs/operators';\nimport { DOCUMENT, NgTemplateOutlet } from '@angular/common';\nimport { fadeMotion, ThyScrollService } from 'ngx-tethys/core';\nimport { ThyIcon } from 'ngx-tethys/icon';\n\n/**\n * 回到顶部组件\n * @name thy-back-top\n */\n@Component({\n selector: 'thy-back-top,[thyBackTop]',\n templateUrl: './back-top.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n animations: [fadeMotion],\n imports: [ThyIcon, NgTemplateOutlet]\n})\nexport class ThyBackTop implements OnInit, OnDestroy {\n private doc = inject(DOCUMENT);\n private thyScrollService = inject(ThyScrollService);\n private platform = inject(Platform);\n private cdr = inject(ChangeDetectorRef);\n private zone = inject(NgZone);\n\n @HostBinding('class.thy-back-top-container') classNames = true;\n\n /**\n * 自定义按钮显示模板\n */\n readonly thyTemplate = input<TemplateRef<void>>();\n\n /**\n * 指定对哪个 DOM 元素返回顶部\n * @type string | HTMLElement\n * @default window\n */\n readonly thyContainer = input<string | HTMLElement>();\n\n /**\n * 滚动高度达到此参数值才出现 thy-back-top\n * @type number\n */\n readonly thyVisibilityHeight = input(400, { transform: numberAttribute });\n\n /**\n * 点击按钮的回调函数\n */\n readonly thyClick = output<boolean>();\n\n /**\n * 监听按钮显示状态的回调函数\n */\n public readonly visibleChange = output<boolean>();\n\n /** The native `<div class=\"thy-back-top\"></div>` element. */\n readonly backTop = viewChild<ElementRef<HTMLElement>>('backTop');\n\n public visible = false;\n\n /**\n * The subject used to store the native `<div class=\"thy-back-top\"></div>` since\n * it's located within the `ngIf` directive. It might be set asynchronously whenever the condition\n * is met. Having subject makes the code reactive and cancellable (e.g. event listeners will be\n * automatically removed and re-added through the `switchMap` below).\n */\n private backTop$ = new BehaviorSubject<ElementRef<HTMLElement> | undefined>(undefined);\n\n private destroy$ = new Subject<void>();\n\n private scrollListenerDestroy$ = new Subject<void>();\n\n private target: Signal<Element | Window> = computed(() => {\n const thyContainerValue = this.thyContainer();\n const target = typeof thyContainerValue === 'string' ? this.doc.querySelector(thyContainerValue) : thyContainerValue;\n return target || window;\n });\n\n constructor() {\n const zone = this.zone;\n\n this.backTop$\n .pipe(\n switchMap(backTop =>\n backTop\n ? new Observable(subscriber =>\n zone.runOutsideAngular(() => fromEvent(backTop.nativeElement, 'click').subscribe(subscriber))\n )\n : EMPTY\n ),\n takeUntil(this.destroy$)\n )\n .subscribe(() => {\n this.thyScrollService.scrollTo(this.target(), 0);\n zone.run(() => this.thyClick.emit(true));\n });\n\n effect(() => {\n this.backTop$.next(this.backTop());\n });\n }\n\n ngOnInit(): void {\n this.registerScrollEvent();\n }\n\n private handleScroll(): void {\n if (this.visible === this.thyScrollService.getScroll(this.target()) > this.thyVisibilityHeight()) {\n return;\n }\n this.visible = !this.visible;\n this.cdr.detectChanges();\n this.zone.run(() => {\n this.visibleChange.emit(this.visible);\n });\n }\n\n private registerScrollEvent(): void {\n if (!this.platform.isBrowser) {\n return;\n }\n this.scrollListenerDestroy$.next();\n this.handleScroll();\n this.zone.runOutsideAngular(() => {\n fromEvent(this.target(), 'scroll', { passive: true })\n .pipe(throttleTime(50), takeUntil(this.scrollListenerDestroy$))\n .subscribe(() => this.handleScroll());\n });\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.scrollListenerDestroy$.next();\n }\n}\n","@if (visible) {\n <div class=\"thy-back-top\" #backTop @fadeMotion>\n <ng-template #defaultContent>\n <div class=\"thy-back-top-content\">\n <thy-icon class=\"back-top-icon text-muted font-size-lg\" thyIconName=\"arrow-up\"></thy-icon>\n </div>\n </ng-template>\n <ng-template [ngTemplateOutlet]=\"thyTemplate() || defaultContent\"></ng-template>\n </div>\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ThyIconModule } from 'ngx-tethys/icon';\nimport { ThyBackTop } from './back-top.component';\n\n@NgModule({\n imports: [CommonModule, ThyIconModule, ThyBackTop],\n exports: [ThyBackTop]\n})\nexport class ThyBackTopModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA6BA;;;AAGG;MASU,UAAU,CAAA;AA4DnB,IAAA,WAAA,GAAA;AA3DQ,QAAA,IAAA,CAAA,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;AACtB,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC3C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,aAAa,EAAE,UAAU,aACvC,UAAU,CAAA,EAAA,CAAA,CAAA;AAEX,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,EAHf,OAAA,EAAA,CAAA,YAAY,EAAE,aAAa,EAAE,UAAU,CAAA,EAAA,CAAA,CAAA;;2FAGxC,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;oBAClD,OAAO,EAAE,CAAC,UAAU;AACvB,iBAAA;;;ACRD;;AAEG;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef,
|
|
2
|
+
import { inject, ElementRef, computed, input, numberAttribute, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
4
|
import { isTextColor } from 'ngx-tethys/core';
|
|
5
|
-
import { coerceBooleanProperty } from 'ngx-tethys/util';
|
|
5
|
+
import { isUndefined, coerceBooleanProperty } from 'ngx-tethys/util';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 徽标组件,支持组件`thy-badge`和`thyBadge`指令两种使用方式
|
|
@@ -11,146 +11,109 @@ import { coerceBooleanProperty } from 'ngx-tethys/util';
|
|
|
11
11
|
class ThyBadge {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.elementRef = inject(ElementRef);
|
|
14
|
-
this.displayContent =
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
this.displayContent = computed(() => {
|
|
15
|
+
let content = this.value();
|
|
16
|
+
if (this.value() && !isUndefined(this.thyMaxCount()) && this.value() > this.thyMaxCount()) {
|
|
17
|
+
content = `${this.thyMaxCount()}+`;
|
|
18
|
+
}
|
|
19
|
+
return content;
|
|
20
|
+
});
|
|
21
|
+
this.badgeClassName = computed(() => {
|
|
22
|
+
const classes = [];
|
|
23
|
+
classes.push(`thy-badge-${this.thyType()}`);
|
|
24
|
+
if (this.thySize()) {
|
|
25
|
+
classes.push(`thy-badge-${this.thySize()}`);
|
|
26
|
+
}
|
|
27
|
+
if (this.thyIsDot()) {
|
|
28
|
+
classes.push(`thy-badge-dot`);
|
|
29
|
+
}
|
|
30
|
+
else if (this.thyIsHollow()) {
|
|
31
|
+
classes.push(`thy-badge-hollow`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
classes.push(`thy-badge-count`);
|
|
35
|
+
}
|
|
36
|
+
const builtInTextColorClass = isTextColor(this.thyTextColor()) ? `text-${this.thyTextColor()}` : null;
|
|
37
|
+
if (builtInTextColorClass) {
|
|
38
|
+
classes.push(builtInTextColorClass);
|
|
39
|
+
}
|
|
40
|
+
const builtInBackgroundColorClass = isTextColor(this.thyBackgroundColor()) ? `bg-${this.thyBackgroundColor()}` : null;
|
|
41
|
+
if (builtInBackgroundColorClass) {
|
|
42
|
+
classes.push(builtInBackgroundColorClass);
|
|
43
|
+
}
|
|
44
|
+
return classes.join(' ');
|
|
45
|
+
});
|
|
17
46
|
// 是否包裹在元素上
|
|
18
47
|
this.isWrapper = false;
|
|
19
|
-
this.isShowBadge =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
48
|
+
this.isShowBadge = computed(() => {
|
|
49
|
+
return !(!this.value() && !this.thyKeepShow() && !this.thyIsDot() && !this.thyIsHollow());
|
|
50
|
+
});
|
|
51
|
+
this.value = computed(() => {
|
|
52
|
+
return this.thyContent() || this.thyContext() || this.thyCount();
|
|
53
|
+
});
|
|
54
|
+
this.textColor = computed(() => {
|
|
55
|
+
return !isTextColor(this.thyTextColor()) ? this.thyTextColor() : null;
|
|
56
|
+
});
|
|
57
|
+
this.backgroundColor = computed(() => {
|
|
58
|
+
return !isTextColor(this.thyBackgroundColor()) ? this.thyBackgroundColor() : null;
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* 徽标类型
|
|
62
|
+
* @type default | primary | danger | warning | success
|
|
63
|
+
*/
|
|
64
|
+
this.thyType = input('danger', {
|
|
65
|
+
transform: (value) => value || 'danger'
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* 徽标内容数字
|
|
69
|
+
* @type number
|
|
70
|
+
*/
|
|
71
|
+
this.thyCount = input(undefined, { transform: numberAttribute });
|
|
72
|
+
/**
|
|
73
|
+
* 徽标内容文本
|
|
74
|
+
* @type string
|
|
75
|
+
*/
|
|
76
|
+
this.thyContent = input();
|
|
77
|
+
/**
|
|
78
|
+
* 已废弃,徽标内容文本,命名错误,请使用 thyContent
|
|
79
|
+
*/
|
|
80
|
+
this.thyContext = input();
|
|
81
|
+
/**
|
|
82
|
+
* 徽标显示的最大值, 与 thyCount 一起使用,thyCount 超过了 thyMaxCount 设置的值时,徽标内容为 thyMaxCount+
|
|
83
|
+
* @type number
|
|
84
|
+
*/
|
|
85
|
+
this.thyMaxCount = input(undefined, { transform: numberAttribute });
|
|
86
|
+
/**
|
|
87
|
+
* 徽标显示的大小
|
|
88
|
+
* @type md | sm | lg
|
|
89
|
+
*/
|
|
90
|
+
this.thySize = input('md', { transform: (value) => value || 'md' });
|
|
91
|
+
/**
|
|
92
|
+
* 已废弃,徽标是一个实心点,已经被废弃
|
|
93
|
+
* @deprecated
|
|
94
|
+
*/
|
|
95
|
+
this.thyIsDot = input(false, { transform: coerceBooleanProperty });
|
|
96
|
+
/**
|
|
97
|
+
* 已废弃,徽标是一个空心点
|
|
98
|
+
* @deprecated
|
|
99
|
+
*/
|
|
100
|
+
this.thyIsHollow = input(false, { transform: coerceBooleanProperty });
|
|
101
|
+
/**
|
|
102
|
+
* thyCount 为 0 时,强制显示数字 0,默认不显示
|
|
103
|
+
*/
|
|
104
|
+
this.thyKeepShow = input(false, { transform: coerceBooleanProperty });
|
|
105
|
+
/**
|
|
106
|
+
* 设置徽标字体的颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...
|
|
107
|
+
* @type string
|
|
108
|
+
*/
|
|
109
|
+
this.thyTextColor = input('');
|
|
110
|
+
/**
|
|
111
|
+
* 设置徽标的背景颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...
|
|
112
|
+
* @type string
|
|
113
|
+
*/
|
|
114
|
+
this.thyBackgroundColor = input('');
|
|
24
115
|
this.nativeElement = this.elementRef.nativeElement;
|
|
25
116
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 徽标类型
|
|
28
|
-
* @type default | primary | danger | warning | success
|
|
29
|
-
* @default danger
|
|
30
|
-
*/
|
|
31
|
-
set thyType(value) {
|
|
32
|
-
this.type = value;
|
|
33
|
-
if (this.initialized) {
|
|
34
|
-
this.combineBadgeClasses();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 徽标内容数字
|
|
39
|
-
* @type number
|
|
40
|
-
*/
|
|
41
|
-
set thyCount(value) {
|
|
42
|
-
this.value = value;
|
|
43
|
-
this.valueHasBeenSet = true;
|
|
44
|
-
if (this.initialized) {
|
|
45
|
-
this.combineBadgeDisplayContent();
|
|
46
|
-
this.combineBadgeClasses();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* 徽标内容文本
|
|
51
|
-
* @type string
|
|
52
|
-
*/
|
|
53
|
-
set thyContent(value) {
|
|
54
|
-
this.value = value;
|
|
55
|
-
this.valueHasBeenSet = true;
|
|
56
|
-
if (this.initialized) {
|
|
57
|
-
this.combineBadgeDisplayContent();
|
|
58
|
-
this.combineBadgeClasses();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 已废弃,徽标内容文本,命名错误,请使用 thyContent
|
|
63
|
-
* @deprecated
|
|
64
|
-
*/
|
|
65
|
-
set thyContext(value) {
|
|
66
|
-
this.thyContent = value;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 徽标显示的最大值, 与 thyCount 一起使用,thyCount 超过了 thyMaxCount 设置的值时,徽标内容为 thyMaxCount+
|
|
70
|
-
* @type number
|
|
71
|
-
*/
|
|
72
|
-
set thyMaxCount(value) {
|
|
73
|
-
this.maxCount = value;
|
|
74
|
-
if (this.initialized) {
|
|
75
|
-
this.combineBadgeDisplayContent();
|
|
76
|
-
this.combineBadgeClasses();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 徽标显示的大小
|
|
81
|
-
* @type md | sm | lg
|
|
82
|
-
* @default md
|
|
83
|
-
*/
|
|
84
|
-
set thySize(value) {
|
|
85
|
-
this.size = value;
|
|
86
|
-
if (this.initialized) {
|
|
87
|
-
this.combineBadgeClasses();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 已废弃,徽标是一个实心点,已经被废弃
|
|
92
|
-
* @deprecated
|
|
93
|
-
*/
|
|
94
|
-
set thyIsDot(value) {
|
|
95
|
-
this.isDot = value;
|
|
96
|
-
if (this.initialized) {
|
|
97
|
-
this.combineBadgeClasses();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 已废弃,徽标是一个空心点
|
|
102
|
-
* @deprecated
|
|
103
|
-
*/
|
|
104
|
-
set thyIsHollow(value) {
|
|
105
|
-
this.isHollow = value;
|
|
106
|
-
if (this.initialized) {
|
|
107
|
-
this.combineBadgeClasses();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* thyCount 为 0 时,强制显示数字 0,默认不显示
|
|
112
|
-
* @default false
|
|
113
|
-
*/
|
|
114
|
-
set thyKeepShow(value) {
|
|
115
|
-
this.keepShowValue = value;
|
|
116
|
-
if (this.initialized) {
|
|
117
|
-
this.combineBadgeDisplayContent();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* 设置徽标字体的颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...
|
|
122
|
-
* @type string
|
|
123
|
-
*/
|
|
124
|
-
set thyTextColor(value) {
|
|
125
|
-
if (isTextColor(value)) {
|
|
126
|
-
this.builtInTextColorClass = `text-${value}`;
|
|
127
|
-
this.textColor = null;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.textColor = value;
|
|
131
|
-
this.builtInTextColorClass = null;
|
|
132
|
-
}
|
|
133
|
-
if (this.initialized) {
|
|
134
|
-
this.combineBadgeClasses();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 设置徽标的背景颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...
|
|
139
|
-
* @type string
|
|
140
|
-
*/
|
|
141
|
-
set thyBackgroundColor(value) {
|
|
142
|
-
if (isTextColor(value)) {
|
|
143
|
-
this.builtInBackgroundColorClass = `bg-${value}`;
|
|
144
|
-
this.backgroundColor = null;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
this.backgroundColor = value;
|
|
148
|
-
this.builtInBackgroundColorClass = null;
|
|
149
|
-
}
|
|
150
|
-
if (this.initialized) {
|
|
151
|
-
this.combineBadgeClasses();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
117
|
ngOnInit() {
|
|
155
118
|
let childNodeCount = 0;
|
|
156
119
|
this.nativeElement.childNodes.forEach((n) => {
|
|
@@ -159,84 +122,17 @@ class ThyBadge {
|
|
|
159
122
|
}
|
|
160
123
|
});
|
|
161
124
|
this.isWrapper = childNodeCount > 0;
|
|
162
|
-
this.combineBadgeClasses();
|
|
163
|
-
if (this.valueHasBeenSet) {
|
|
164
|
-
this.combineBadgeDisplayContent();
|
|
165
|
-
}
|
|
166
|
-
this.initialized = true;
|
|
167
|
-
}
|
|
168
|
-
combineBadgeClasses() {
|
|
169
|
-
const classes = [];
|
|
170
|
-
classes.push(`thy-badge-${this.type || 'danger'}`);
|
|
171
|
-
if (this.size) {
|
|
172
|
-
classes.push(`thy-badge-${this.size}`);
|
|
173
|
-
}
|
|
174
|
-
if (this.isDot) {
|
|
175
|
-
classes.push(`thy-badge-dot`);
|
|
176
|
-
}
|
|
177
|
-
else if (this.isHollow) {
|
|
178
|
-
classes.push(`thy-badge-hollow`);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
classes.push(`thy-badge-count`);
|
|
182
|
-
}
|
|
183
|
-
if (this.builtInTextColorClass) {
|
|
184
|
-
classes.push(this.builtInTextColorClass);
|
|
185
|
-
}
|
|
186
|
-
if (this.builtInBackgroundColorClass) {
|
|
187
|
-
classes.push(this.builtInBackgroundColorClass);
|
|
188
|
-
}
|
|
189
|
-
this.badgeClassName = classes.join(' ');
|
|
190
|
-
}
|
|
191
|
-
combineBadgeDisplayContent() {
|
|
192
|
-
this.displayContent = this.value;
|
|
193
|
-
if (this.value && this.maxCount != undefined && this.value > this.maxCount) {
|
|
194
|
-
this.displayContent = `${this.maxCount}+`;
|
|
195
|
-
}
|
|
196
|
-
if (!this.value && !this.keepShowValue) {
|
|
197
|
-
this.isShowBadge = false;
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
this.isShowBadge = true;
|
|
201
|
-
}
|
|
202
125
|
}
|
|
203
126
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyBadge, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
204
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyBadge, isStandalone: true, selector: "thy-badge,[thyBadge]", inputs: { thyType: "thyType", thyCount:
|
|
127
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyBadge, isStandalone: true, selector: "thy-badge,[thyBadge]", inputs: { thyType: { classPropertyName: "thyType", publicName: "thyType", isSignal: true, isRequired: false, transformFunction: null }, thyCount: { classPropertyName: "thyCount", publicName: "thyCount", isSignal: true, isRequired: false, transformFunction: null }, thyContent: { classPropertyName: "thyContent", publicName: "thyContent", isSignal: true, isRequired: false, transformFunction: null }, thyContext: { classPropertyName: "thyContext", publicName: "thyContext", isSignal: true, isRequired: false, transformFunction: null }, thyMaxCount: { classPropertyName: "thyMaxCount", publicName: "thyMaxCount", isSignal: true, isRequired: false, transformFunction: null }, thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyIsDot: { classPropertyName: "thyIsDot", publicName: "thyIsDot", isSignal: true, isRequired: false, transformFunction: null }, thyIsHollow: { classPropertyName: "thyIsHollow", publicName: "thyIsHollow", isSignal: true, isRequired: false, transformFunction: null }, thyKeepShow: { classPropertyName: "thyKeepShow", publicName: "thyKeepShow", isSignal: true, isRequired: false, transformFunction: null }, thyTextColor: { classPropertyName: "thyTextColor", publicName: "thyTextColor", isSignal: true, isRequired: false, transformFunction: null }, thyBackgroundColor: { classPropertyName: "thyBackgroundColor", publicName: "thyBackgroundColor", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.thy-badge-wrapper": "isWrapper" }, classAttribute: "thy-badge-container" }, ngImport: i0, template: "@if (isShowBadge()) {\n <div class=\"thy-badge {{ badgeClassName() }}\" [style.color]=\"textColor()\" [style.backgroundColor]=\"backgroundColor()\">\n <span>{{ displayContent() }}</span>\n </div>\n}\n<ng-content></ng-content>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
205
128
|
}
|
|
206
129
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyBadge, decorators: [{
|
|
207
130
|
type: Component,
|
|
208
131
|
args: [{ selector: 'thy-badge,[thyBadge]', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
209
132
|
class: 'thy-badge-container',
|
|
210
133
|
'[class.thy-badge-wrapper]': 'isWrapper'
|
|
211
|
-
}, imports: [], template: "@if (isShowBadge) {\n <div class=\"thy-badge {{ badgeClassName }}\" [style.color]=\"textColor\" [style.backgroundColor]=\"backgroundColor\">\n <span>{{ displayContent }}</span>\n </div>\n}\n<ng-content></ng-content>\n" }]
|
|
212
|
-
}], ctorParameters: () => []
|
|
213
|
-
type: Input
|
|
214
|
-
}], thyCount: [{
|
|
215
|
-
type: Input,
|
|
216
|
-
args: [{ transform: numberAttribute }]
|
|
217
|
-
}], thyContent: [{
|
|
218
|
-
type: Input
|
|
219
|
-
}], thyContext: [{
|
|
220
|
-
type: Input
|
|
221
|
-
}], thyMaxCount: [{
|
|
222
|
-
type: Input,
|
|
223
|
-
args: [{ transform: numberAttribute }]
|
|
224
|
-
}], thySize: [{
|
|
225
|
-
type: Input
|
|
226
|
-
}], thyIsDot: [{
|
|
227
|
-
type: Input,
|
|
228
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
229
|
-
}], thyIsHollow: [{
|
|
230
|
-
type: Input,
|
|
231
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
232
|
-
}], thyKeepShow: [{
|
|
233
|
-
type: Input,
|
|
234
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
235
|
-
}], thyTextColor: [{
|
|
236
|
-
type: Input
|
|
237
|
-
}], thyBackgroundColor: [{
|
|
238
|
-
type: Input
|
|
239
|
-
}] } });
|
|
134
|
+
}, imports: [], template: "@if (isShowBadge()) {\n <div class=\"thy-badge {{ badgeClassName() }}\" [style.color]=\"textColor()\" [style.backgroundColor]=\"backgroundColor()\">\n <span>{{ displayContent() }}</span>\n </div>\n}\n<ng-content></ng-content>\n" }]
|
|
135
|
+
}], ctorParameters: () => [] });
|
|
240
136
|
|
|
241
137
|
class ThyBadgeModule {
|
|
242
138
|
constructor() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-tethys-badge.mjs","sources":["../../../src/badge/badge.component.ts","../../../src/badge/badge.component.html","../../../src/badge/badge.module.ts","../../../src/badge/ngx-tethys-badge.ts"],"sourcesContent":["import { isTextColor } from 'ngx-tethys/core';\n\nimport { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, numberAttribute, inject } from '@angular/core';\n\nimport { coerceBooleanProperty } from 'ngx-tethys/util';\n\nexport type ThyBadgeSize = 'md' | 'sm' | 'lg';\n\n/**\n * 徽标组件,支持组件`thy-badge`和`thyBadge`指令两种使用方式\n * @name thy-badge,[thyBadge]\n */\n@Component({\n selector: 'thy-badge,[thyBadge]',\n templateUrl: './badge.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'thy-badge-container',\n '[class.thy-badge-wrapper]': 'isWrapper'\n },\n imports: []\n})\nexport class ThyBadge implements OnInit {\n private elementRef = inject(ElementRef);\n\n displayContent = '';\n\n badgeClassName = '';\n\n private nativeElement: any;\n\n private initialized = false;\n\n // 是否包裹在元素上\n protected isWrapper = false;\n\n public isShowBadge = true;\n\n private keepShowValue = false;\n\n private value: number | string = '';\n\n private valueHasBeenSet = false;\n\n private maxCount: number;\n\n private type: string;\n\n private size: ThyBadgeSize;\n\n private isDot: boolean;\n\n private isHollow: boolean;\n\n protected textColor: string;\n\n protected builtInTextColorClass: string;\n\n protected backgroundColor: string;\n\n protected builtInBackgroundColorClass: string;\n\n protected supClasses: string[] = [];\n\n constructor() {\n this.nativeElement = this.elementRef.nativeElement;\n }\n\n /**\n * 徽标类型\n * @type default | primary | danger | warning | success\n * @default danger\n */\n @Input()\n set thyType(value: string) {\n this.type = value;\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 徽标内容数字\n * @type number\n */\n @Input({ transform: numberAttribute })\n set thyCount(value: number) {\n this.value = value;\n this.valueHasBeenSet = true;\n if (this.initialized) {\n this.combineBadgeDisplayContent();\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 徽标内容文本\n * @type string\n */\n @Input()\n set thyContent(value: string) {\n this.value = value;\n this.valueHasBeenSet = true;\n if (this.initialized) {\n this.combineBadgeDisplayContent();\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 已废弃,徽标内容文本,命名错误,请使用 thyContent\n * @deprecated\n */\n @Input()\n set thyContext(value: string) {\n this.thyContent = value;\n }\n\n /**\n * 徽标显示的最大值, 与 thyCount 一起使用,thyCount 超过了 thyMaxCount 设置的值时,徽标内容为 thyMaxCount+\n * @type number\n */\n @Input({ transform: numberAttribute })\n set thyMaxCount(value: number) {\n this.maxCount = value;\n if (this.initialized) {\n this.combineBadgeDisplayContent();\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 徽标显示的大小\n * @type md | sm | lg\n * @default md\n */\n @Input()\n set thySize(value: ThyBadgeSize) {\n this.size = value;\n\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 已废弃,徽标是一个实心点,已经被废弃\n * @deprecated\n */\n @Input({ transform: coerceBooleanProperty })\n set thyIsDot(value: boolean) {\n this.isDot = value;\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 已废弃,徽标是一个空心点\n * @deprecated\n */\n @Input({ transform: coerceBooleanProperty })\n set thyIsHollow(value: boolean) {\n this.isHollow = value;\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n /**\n * thyCount 为 0 时,强制显示数字 0,默认不显示\n * @default false\n */\n @Input({ transform: coerceBooleanProperty })\n set thyKeepShow(value: boolean) {\n this.keepShowValue = value;\n if (this.initialized) {\n this.combineBadgeDisplayContent();\n }\n }\n\n /**\n * 设置徽标字体的颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...\n * @type string\n */\n @Input()\n set thyTextColor(value: string) {\n if (isTextColor(value)) {\n this.builtInTextColorClass = `text-${value}`;\n this.textColor = null;\n } else {\n this.textColor = value;\n this.builtInTextColorClass = null;\n }\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n /**\n * 设置徽标的背景颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...\n * @type string\n */\n @Input()\n set thyBackgroundColor(value: string) {\n if (isTextColor(value)) {\n this.builtInBackgroundColorClass = `bg-${value}`;\n this.backgroundColor = null;\n } else {\n this.backgroundColor = value;\n this.builtInBackgroundColorClass = null;\n }\n if (this.initialized) {\n this.combineBadgeClasses();\n }\n }\n\n ngOnInit() {\n let childNodeCount = 0;\n this.nativeElement.childNodes.forEach((n: HTMLElement) => {\n if (['#comment'].indexOf(n.nodeName) < 0) {\n childNodeCount++;\n }\n });\n this.isWrapper = childNodeCount > 0;\n\n this.combineBadgeClasses();\n\n if (this.valueHasBeenSet) {\n this.combineBadgeDisplayContent();\n }\n\n this.initialized = true;\n }\n\n private combineBadgeClasses() {\n const classes: string[] = [];\n classes.push(`thy-badge-${this.type || 'danger'}`);\n if (this.size) {\n classes.push(`thy-badge-${this.size}`);\n }\n if (this.isDot) {\n classes.push(`thy-badge-dot`);\n } else if (this.isHollow) {\n classes.push(`thy-badge-hollow`);\n } else {\n classes.push(`thy-badge-count`);\n }\n\n if (this.builtInTextColorClass) {\n classes.push(this.builtInTextColorClass);\n }\n if (this.builtInBackgroundColorClass) {\n classes.push(this.builtInBackgroundColorClass);\n }\n this.badgeClassName = classes.join(' ');\n }\n\n private combineBadgeDisplayContent() {\n this.displayContent = this.value as string;\n if (this.value && this.maxCount != undefined && (this.value as number) > this.maxCount) {\n this.displayContent = `${this.maxCount}+`;\n }\n\n if (!this.value && !this.keepShowValue) {\n this.isShowBadge = false;\n } else {\n this.isShowBadge = true;\n }\n }\n}\n","@if (isShowBadge) {\n <div class=\"thy-badge {{ badgeClassName }}\" [style.color]=\"textColor\" [style.backgroundColor]=\"backgroundColor\">\n <span>{{ displayContent }}</span>\n </div>\n}\n<ng-content></ng-content>\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ThyBadge } from './badge.component';\n\n@NgModule({\n imports: [CommonModule, ThyBadge],\n exports: [ThyBadge]\n})\nexport class ThyBadgeModule {\n constructor() {}\n}\n","/**\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ge.module.ts","../../../src/badge/ngx-tethys-badge.ts"],"sourcesContent":["import { isTextColor } from 'ngx-tethys/core';\n\nimport { ChangeDetectionStrategy, Component, ElementRef, OnInit, Signal, computed, inject, input, numberAttribute } from '@angular/core';\n\nimport { coerceBooleanProperty, isUndefined } from 'ngx-tethys/util';\n\nexport type ThyBadgeSize = 'md' | 'sm' | 'lg';\n\n/**\n * 徽标组件,支持组件`thy-badge`和`thyBadge`指令两种使用方式\n * @name thy-badge,[thyBadge]\n */\n@Component({\n selector: 'thy-badge,[thyBadge]',\n templateUrl: './badge.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'thy-badge-container',\n '[class.thy-badge-wrapper]': 'isWrapper'\n },\n imports: []\n})\nexport class ThyBadge implements OnInit {\n private elementRef = inject(ElementRef);\n\n private nativeElement: any;\n\n readonly displayContent: Signal<string> = computed(() => {\n let content = this.value() as string;\n if (this.value() && !isUndefined(this.thyMaxCount()) && (this.value() as number) > this.thyMaxCount()) {\n content = `${this.thyMaxCount()}+`;\n }\n return content;\n });\n\n readonly badgeClassName: Signal<string> = computed(() => {\n const classes: string[] = [];\n classes.push(`thy-badge-${this.thyType()}`);\n if (this.thySize()) {\n classes.push(`thy-badge-${this.thySize()}`);\n }\n if (this.thyIsDot()) {\n classes.push(`thy-badge-dot`);\n } else if (this.thyIsHollow()) {\n classes.push(`thy-badge-hollow`);\n } else {\n classes.push(`thy-badge-count`);\n }\n const builtInTextColorClass = isTextColor(this.thyTextColor()) ? `text-${this.thyTextColor()}` : null;\n if (builtInTextColorClass) {\n classes.push(builtInTextColorClass);\n }\n const builtInBackgroundColorClass = isTextColor(this.thyBackgroundColor()) ? `bg-${this.thyBackgroundColor()}` : null;\n if (builtInBackgroundColorClass) {\n classes.push(builtInBackgroundColorClass);\n }\n return classes.join(' ');\n });\n\n // 是否包裹在元素上\n protected isWrapper = false;\n\n public readonly isShowBadge: Signal<boolean> = computed(() => {\n return !(!this.value() && !this.thyKeepShow() && !this.thyIsDot() && !this.thyIsHollow());\n });\n\n private readonly value: Signal<number | string> = computed(() => {\n return this.thyContent() || this.thyContext() || this.thyCount();\n });\n\n protected readonly textColor: Signal<string> = computed(() => {\n return !isTextColor(this.thyTextColor()) ? this.thyTextColor() : null;\n });\n\n protected readonly backgroundColor: Signal<string> = computed(() => {\n return !isTextColor(this.thyBackgroundColor()) ? this.thyBackgroundColor() : null;\n });\n\n constructor() {\n this.nativeElement = this.elementRef.nativeElement;\n }\n\n /**\n * 徽标类型\n * @type default | primary | danger | warning | success\n */\n readonly thyType = input<string, string>('danger', {\n transform: (value: string) => value || 'danger'\n });\n\n /**\n * 徽标内容数字\n * @type number\n */\n readonly thyCount = input<number, unknown>(undefined, { transform: numberAttribute });\n\n /**\n * 徽标内容文本\n * @type string\n */\n readonly thyContent = input<string>();\n\n /**\n * 已废弃,徽标内容文本,命名错误,请使用 thyContent\n */\n readonly thyContext = input<string>();\n\n /**\n * 徽标显示的最大值, 与 thyCount 一起使用,thyCount 超过了 thyMaxCount 设置的值时,徽标内容为 thyMaxCount+\n * @type number\n */\n readonly thyMaxCount = input<number, unknown>(undefined, { transform: numberAttribute });\n\n /**\n * 徽标显示的大小\n * @type md | sm | lg\n */\n readonly thySize = input<ThyBadgeSize, ThyBadgeSize>('md', { transform: (value: ThyBadgeSize) => value || 'md' });\n\n /**\n * 已废弃,徽标是一个实心点,已经被废弃\n * @deprecated\n */\n readonly thyIsDot = input(false, { transform: coerceBooleanProperty });\n\n /**\n * 已废弃,徽标是一个空心点\n * @deprecated\n */\n readonly thyIsHollow = input(false, { transform: coerceBooleanProperty });\n\n /**\n * thyCount 为 0 时,强制显示数字 0,默认不显示\n */\n readonly thyKeepShow = input(false, { transform: coerceBooleanProperty });\n\n /**\n * 设置徽标字体的颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...\n * @type string\n */\n readonly thyTextColor = input<string>('');\n\n /**\n * 设置徽标的背景颜色,支持内置颜色和自定义颜色 'primary' | '#87d068' | ...\n * @type string\n */\n readonly thyBackgroundColor = input<string>('');\n\n ngOnInit() {\n let childNodeCount = 0;\n this.nativeElement.childNodes.forEach((n: HTMLElement) => {\n if (['#comment'].indexOf(n.nodeName) < 0) {\n childNodeCount++;\n }\n });\n this.isWrapper = childNodeCount > 0;\n }\n}\n","@if (isShowBadge()) {\n <div class=\"thy-badge {{ badgeClassName() }}\" [style.color]=\"textColor()\" [style.backgroundColor]=\"backgroundColor()\">\n <span>{{ displayContent() }}</span>\n </div>\n}\n<ng-content></ng-content>\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ThyBadge } from './badge.component';\n\n@NgModule({\n imports: [CommonModule, ThyBadge],\n exports: [ThyBadge]\n})\nexport class ThyBadgeModule {\n constructor() {}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAQA;;;AAGG;MAWU,QAAQ,CAAA;AAwDjB,IAAA,WAAA,GAAA;AAvDQ,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAI9B,QAAA,IAAA,CAAA,cAAc,GAAmB,QAAQ,CAAC,MAAK;AACpD,YAAA,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,EAAY;YACpC,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAK,IAAI,CAAC,KAAK,EAAa,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE;AACnG,gBAAA,OAAO,GAAG,CAAG,EAAA,IAAI,CAAC,WAAW,EAAE,GAAG;;AAEtC,YAAA,OAAO,OAAO;AAClB,SAAC,CAAC;AAEO,QAAA,IAAA,CAAA,cAAc,GAAmB,QAAQ,CAAC,MAAK;YACpD,MAAM,OAAO,GAAa,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAa,UAAA,EAAA,IAAI,CAAC,OAAO,EAAE,CAAE,CAAA,CAAC;AAC3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