ngx-tethys 19.0.16 → 19.1.0-next.1
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 +31 -11
- package/README.md +0 -1
- package/action/action.component.d.ts +14 -23
- package/action/actions.component.d.ts +5 -7
- package/affix/affix.component.d.ts +9 -13
- 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 +8 -14
- package/avatar/avatar.component.d.ts +25 -39
- 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-group.component.d.ts +5 -12
- package/button/button-icon.component.d.ts +14 -27
- package/button/button.component.d.ts +17 -26
- 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-active.directive.d.ts +4 -5
- package/dropdown/dropdown-menu-item.directive.d.ts +7 -14
- package/dropdown/dropdown-menu.component.d.ts +6 -12
- package/dropdown/dropdown-submenu.component.d.ts +2 -4
- package/dropdown/dropdown.directive.d.ts +14 -24
- package/empty/empty.component.d.ts +21 -27
- package/fesm2022/ngx-tethys-action.mjs +63 -101
- package/fesm2022/ngx-tethys-action.mjs.map +1 -1
- package/fesm2022/ngx-tethys-affix.mjs +40 -41
- package/fesm2022/ngx-tethys-affix.mjs.map +1 -1
- 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 +117 -162
- 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-button.mjs +225 -322
- package/fesm2022/ngx-tethys-button.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 +83 -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-dropdown.mjs +155 -203
- package/fesm2022/ngx-tethys-dropdown.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-flexible-text.mjs +67 -86
- package/fesm2022/ngx-tethys-flexible-text.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 +161 -158
- 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-icon.mjs +44 -59
- package/fesm2022/ngx-tethys-icon.mjs.map +1 -1
- package/fesm2022/ngx-tethys-image.mjs +40 -36
- package/fesm2022/ngx-tethys-image.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-list.mjs +1 -1
- package/fesm2022/ngx-tethys-list.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 +52 -74
- 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 +194 -246
- package/fesm2022/ngx-tethys-progress.mjs.map +1 -1
- package/fesm2022/ngx-tethys-property.mjs +99 -113
- package/fesm2022/ngx-tethys-property.mjs.map +1 -1
- package/fesm2022/ngx-tethys-radio.mjs +60 -76
- package/fesm2022/ngx-tethys-radio.mjs.map +1 -1
- package/fesm2022/ngx-tethys-rate.mjs +115 -157
- package/fesm2022/ngx-tethys-rate.mjs.map +1 -1
- package/fesm2022/ngx-tethys-resizable.mjs +111 -157
- package/fesm2022/ngx-tethys-resizable.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-segment.mjs +84 -103
- package/fesm2022/ngx-tethys-segment.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-slide.mjs +37 -56
- package/fesm2022/ngx-tethys-slide.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 +25 -51
- 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-strength.mjs +52 -66
- package/fesm2022/ngx-tethys-strength.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-transfer.mjs +98 -119
- package/fesm2022/ngx-tethys-transfer.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tree-select.mjs +2 -4
- package/fesm2022/ngx-tethys-tree-select.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tree.mjs +281 -401
- package/fesm2022/ngx-tethys-tree.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 +93 -132
- package/fesm2022/ngx-tethys-upload.mjs.map +1 -1
- package/fesm2022/ngx-tethys-util.mjs.map +1 -1
- package/fesm2022/ngx-tethys-vote.mjs +53 -99
- package/fesm2022/ngx-tethys-vote.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/flexible-text/flexible-text.component.d.ts +9 -15
- 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 +13 -20
- 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 +11 -14
- package/icon/icon.component.d.ts +10 -17
- package/image/image.directive.d.ts +10 -12
- package/image/image.token.d.ts +5 -5
- 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 +6 -7
- package/mention/suggestions/suggestions.component.d.ts +8 -9
- 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 +35 -26
- package/progress/progress-strip.component.d.ts +10 -14
- package/progress/progress.component.d.ts +16 -26
- package/property/examples/single/single.component.scss +6 -0
- package/property/properties.component.d.ts +6 -15
- package/property/property-item.component.d.ts +22 -34
- 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 +13 -16
- package/radio/radio.component.d.ts +2 -2
- package/radio/radio.token.d.ts +2 -2
- package/rate/rate-item.component.d.ts +8 -10
- package/rate/rate.component.d.ts +20 -30
- package/resizable/resizable.directive.d.ts +18 -36
- package/resizable/resize-handle.component.d.ts +6 -6
- package/resizable/resize-handles.component.d.ts +5 -8
- 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 +9 -14
- package/segment/segment.component.d.ts +11 -14
- package/segment/segment.token.d.ts +4 -3
- 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 -5
- package/slide/slide-header/slide-header.component.d.ts +6 -9
- package/slider/slider.component.d.ts +17 -24
- package/space/space.component.d.ts +10 -16
- 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/strength/strength.component.d.ts +8 -13
- 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/transfer/transfer-list.component.d.ts +15 -15
- package/transfer/transfer.component.d.ts +20 -23
- package/tree/tree-abstract.d.ts +5 -5
- package/tree/tree-node.component.d.ts +24 -46
- package/tree/tree.class.d.ts +4 -4
- package/tree/tree.component.d.ts +47 -74
- package/tree/tree.service.d.ts +3 -4
- package/tree-select/tree-select.component.d.ts +10 -9
- 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 +13 -32
- package/watermark/watermark.directive.d.ts +7 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NgTemplateOutlet, CommonModule } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { input, contentChild, effect, Component, NgModule } from '@angular/core';
|
|
4
4
|
import { ThySharedModule } from 'ngx-tethys/shared';
|
|
5
5
|
import { useHostRenderer } from '@tethys/cdk/dom';
|
|
6
6
|
import { ThyIcon, ThyIconModule } from 'ngx-tethys/icon';
|
|
@@ -12,123 +12,77 @@ import { coerceBooleanProperty } from 'ngx-tethys/util';
|
|
|
12
12
|
* @order 10
|
|
13
13
|
*/
|
|
14
14
|
class ThyVote {
|
|
15
|
-
/**
|
|
16
|
-
* 大小,thyLayout="vertical" 时,支持: sm | default
|
|
17
|
-
* @default default
|
|
18
|
-
*/
|
|
19
|
-
set thySize(value) {
|
|
20
|
-
this._size = value;
|
|
21
|
-
if (this._initialized) {
|
|
22
|
-
this._setClassesByType();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 标签类型: primary | success | primary-weak | success-weak
|
|
27
|
-
* @default primary
|
|
28
|
-
*/
|
|
29
|
-
set thyVote(value) {
|
|
30
|
-
this._type = value;
|
|
31
|
-
if (this._initialized) {
|
|
32
|
-
this._setClassesByType();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 布局: horizontal | vertical
|
|
37
|
-
* @default horizontal
|
|
38
|
-
*/
|
|
39
|
-
set thyLayout(value) {
|
|
40
|
-
this._layout = value;
|
|
41
|
-
if (this._initialized) {
|
|
42
|
-
this._setClassesByType();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 是否赞同
|
|
47
|
-
* @type boolean
|
|
48
|
-
* @default false
|
|
49
|
-
*/
|
|
50
|
-
set thyHasVoted(value) {
|
|
51
|
-
this._hasVoted = value;
|
|
52
|
-
if (this._initialized) {
|
|
53
|
-
this._setClassesByType();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
15
|
constructor() {
|
|
57
|
-
this._initialized = false;
|
|
58
16
|
this.hostRenderer = useHostRenderer();
|
|
59
|
-
|
|
60
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 大小,thyLayout="vertical" 时,支持: sm | default
|
|
19
|
+
*/
|
|
20
|
+
this.thySize = input('default', {
|
|
21
|
+
transform: (value) => value || 'default'
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* 标签类型: primary | success | primary-weak | success-weak
|
|
25
|
+
*/
|
|
26
|
+
this.thyVote = input('primary', {
|
|
27
|
+
transform: (value) => value || 'primary'
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* 是否是偏圆型
|
|
31
|
+
*/
|
|
32
|
+
this.thyRound = input(false, { transform: coerceBooleanProperty });
|
|
33
|
+
/**
|
|
34
|
+
* 布局: horizontal | vertical
|
|
35
|
+
*/
|
|
36
|
+
this.thyLayout = input('horizontal', {
|
|
37
|
+
transform: (value) => value || 'horizontal'
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* 赞同的数量
|
|
41
|
+
*/
|
|
42
|
+
this.thyVoteCount = input();
|
|
61
43
|
/**
|
|
62
44
|
* 图标
|
|
63
|
-
* @type string
|
|
64
45
|
*/
|
|
65
|
-
this.thyIcon = 'thumb-up'
|
|
46
|
+
this.thyIcon = input('thumb-up', {
|
|
47
|
+
transform: (value) => value || 'thumb-up'
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* 是否赞同
|
|
51
|
+
*/
|
|
52
|
+
this.thyHasVoted = input(false, { transform: coerceBooleanProperty });
|
|
66
53
|
/**
|
|
67
54
|
* 是否禁用
|
|
68
|
-
* @type boolean
|
|
69
55
|
*/
|
|
70
|
-
this.thyDisabled = false;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.
|
|
56
|
+
this.thyDisabled = input(false, { transform: coerceBooleanProperty });
|
|
57
|
+
/**
|
|
58
|
+
* 自定义Icon模板
|
|
59
|
+
*/
|
|
60
|
+
this.voteIcon = contentChild('voteIcon');
|
|
61
|
+
effect(() => {
|
|
62
|
+
this.setClassesByType();
|
|
63
|
+
});
|
|
75
64
|
}
|
|
76
|
-
|
|
65
|
+
setClassesByType() {
|
|
77
66
|
const classNames = [];
|
|
78
|
-
if (
|
|
79
|
-
this._type = 'primary';
|
|
80
|
-
}
|
|
81
|
-
if (!this._layout) {
|
|
82
|
-
this._layout = 'horizontal';
|
|
83
|
-
}
|
|
84
|
-
if (!this._size) {
|
|
85
|
-
this._size = 'default';
|
|
86
|
-
}
|
|
87
|
-
if (this.thyRound) {
|
|
67
|
+
if (this.thyRound()) {
|
|
88
68
|
classNames.push('thy-vote-round');
|
|
89
69
|
}
|
|
90
|
-
classNames.push(`thy-vote-${this.
|
|
91
|
-
classNames.push(`thy-vote-${this.
|
|
92
|
-
classNames.push(`thy-vote-${this.
|
|
70
|
+
classNames.push(`thy-vote-${this.thyVote()}`);
|
|
71
|
+
classNames.push(`thy-vote-${this.thyLayout()}`);
|
|
72
|
+
classNames.push(`thy-vote-${this.thyLayout()}-size-${this.thySize()}`);
|
|
93
73
|
this.hostRenderer.updateClass(classNames);
|
|
94
74
|
}
|
|
95
75
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyVote, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
96
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyVote, isStandalone: true, selector: "thy-vote,[thyVote]", inputs: { thySize: "thySize", thyVote: "thyVote", thyRound:
|
|
76
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyVote, isStandalone: true, selector: "thy-vote,[thyVote]", inputs: { thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyVote: { classPropertyName: "thyVote", publicName: "thyVote", isSignal: true, isRequired: false, transformFunction: null }, thyRound: { classPropertyName: "thyRound", publicName: "thyRound", isSignal: true, isRequired: false, transformFunction: null }, thyLayout: { classPropertyName: "thyLayout", publicName: "thyLayout", isSignal: true, isRequired: false, transformFunction: null }, thyVoteCount: { classPropertyName: "thyVoteCount", publicName: "thyVoteCount", isSignal: true, isRequired: false, transformFunction: null }, thyIcon: { classPropertyName: "thyIcon", publicName: "thyIcon", isSignal: true, isRequired: false, transformFunction: null }, thyHasVoted: { classPropertyName: "thyHasVoted", publicName: "thyHasVoted", isSignal: true, isRequired: false, transformFunction: null }, thyDisabled: { classPropertyName: "thyDisabled", publicName: "thyDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.has-voted": "thyHasVoted()", "class.thy-vote-disabled": "thyDisabled()" }, classAttribute: "thy-vote" }, queries: [{ propertyName: "voteIcon", first: true, predicate: ["voteIcon"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (voteIcon()) {\n <ng-container [ngTemplateOutlet]=\"voteIcon()\"></ng-container>\n} @else {\n <thy-icon [thyIconName]=\"thyIcon()\" [thyIconType]=\"thyHasVoted() ? 'fill' : ''\"></thy-icon>\n}\n<div>{{ thyVoteCount() }}</div>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
97
77
|
}
|
|
98
78
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyVote, decorators: [{
|
|
99
79
|
type: Component,
|
|
100
80
|
args: [{ selector: 'thy-vote,[thyVote]', host: {
|
|
101
|
-
'
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}], _hasVoted: [{
|
|
107
|
-
type: HostBinding,
|
|
108
|
-
args: [`class.has-voted`]
|
|
109
|
-
}], thySize: [{
|
|
110
|
-
type: Input
|
|
111
|
-
}], thyVote: [{
|
|
112
|
-
type: Input
|
|
113
|
-
}], thyRound: [{
|
|
114
|
-
type: Input,
|
|
115
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
116
|
-
}], thyLayout: [{
|
|
117
|
-
type: Input
|
|
118
|
-
}], thyVoteCount: [{
|
|
119
|
-
type: Input
|
|
120
|
-
}], thyIcon: [{
|
|
121
|
-
type: Input
|
|
122
|
-
}], thyHasVoted: [{
|
|
123
|
-
type: Input,
|
|
124
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
125
|
-
}], thyDisabled: [{
|
|
126
|
-
type: Input,
|
|
127
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
128
|
-
}], voteIcon: [{
|
|
129
|
-
type: ContentChild,
|
|
130
|
-
args: ['voteIcon']
|
|
131
|
-
}] } });
|
|
81
|
+
class: 'thy-vote',
|
|
82
|
+
'[class.has-voted]': 'thyHasVoted()',
|
|
83
|
+
'[class.thy-vote-disabled]': `thyDisabled()`
|
|
84
|
+
}, imports: [ThyIcon, NgTemplateOutlet], template: "@if (voteIcon()) {\n <ng-container [ngTemplateOutlet]=\"voteIcon()\"></ng-container>\n} @else {\n <thy-icon [thyIconName]=\"thyIcon()\" [thyIconType]=\"thyHasVoted() ? 'fill' : ''\"></thy-icon>\n}\n<div>{{ thyVoteCount() }}</div>\n" }]
|
|
85
|
+
}], ctorParameters: () => [] });
|
|
132
86
|
|
|
133
87
|
class ThyVoteModule {
|
|
134
88
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyVoteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-tethys-vote.mjs","sources":["../../../src/vote/vote.component.ts","../../../src/vote/vote.component.html","../../../src/vote/vote.module.ts","../../../src/vote/ngx-tethys-vote.ts"],"sourcesContent":["import { useHostRenderer } from '@tethys/cdk/dom';\
|
|
1
|
+
{"version":3,"file":"ngx-tethys-vote.mjs","sources":["../../../src/vote/vote.component.ts","../../../src/vote/vote.component.html","../../../src/vote/vote.module.ts","../../../src/vote/ngx-tethys-vote.ts"],"sourcesContent":["import { useHostRenderer } from '@tethys/cdk/dom';\nimport { Component, contentChild, effect, input, TemplateRef } from '@angular/core';\nimport { ThyIcon } from 'ngx-tethys/icon';\nimport { NgTemplateOutlet } from '@angular/common';\nimport { coerceBooleanProperty } from 'ngx-tethys/util';\n\nexport type ThyVoteSizes = 'default' | 'sm';\n\nexport type ThyVoteType = 'primary' | 'success' | 'primary-weak' | 'success-weak';\n\nexport type ThyVoteLayout = 'vertical' | 'horizontal';\n\n/**\n * 投票组件\n * @name thy-vote,[thyVote]\n * @order 10\n */\n@Component({\n selector: 'thy-vote,[thyVote]',\n templateUrl: './vote.component.html',\n host: {\n class: 'thy-vote',\n '[class.has-voted]': 'thyHasVoted()',\n '[class.thy-vote-disabled]': `thyDisabled()`\n },\n imports: [ThyIcon, NgTemplateOutlet]\n})\nexport class ThyVote {\n private hostRenderer = useHostRenderer();\n\n /**\n * 大小,thyLayout=\"vertical\" 时,支持: sm | default\n */\n readonly thySize = input<ThyVoteSizes, ThyVoteSizes>('default', {\n transform: (value: ThyVoteSizes) => value || 'default'\n });\n\n /**\n * 标签类型: primary | success | primary-weak | success-weak\n */\n readonly thyVote = input<ThyVoteType, ThyVoteType>('primary', {\n transform: (value: ThyVoteType) => value || 'primary'\n });\n\n /**\n * 是否是偏圆型\n */\n readonly thyRound = input(false, { transform: coerceBooleanProperty });\n\n /**\n * 布局: horizontal | vertical\n */\n readonly thyLayout = input<ThyVoteLayout, ThyVoteLayout>('horizontal', {\n transform: (value: ThyVoteLayout) => value || 'horizontal'\n });\n\n /**\n * 赞同的数量\n */\n readonly thyVoteCount = input<number | string>();\n\n /**\n * 图标\n */\n readonly thyIcon = input<string, string>('thumb-up', {\n transform: (value: string) => value || 'thumb-up'\n });\n\n /**\n * 是否赞同\n */\n readonly thyHasVoted = input(false, { transform: coerceBooleanProperty });\n\n /**\n * 是否禁用\n */\n readonly thyDisabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * 自定义Icon模板\n */\n readonly voteIcon = contentChild<TemplateRef<any>>('voteIcon');\n\n constructor() {\n effect(() => {\n this.setClassesByType();\n });\n }\n\n private setClassesByType() {\n const classNames = [];\n\n if (this.thyRound()) {\n classNames.push('thy-vote-round');\n }\n classNames.push(`thy-vote-${this.thyVote()}`);\n classNames.push(`thy-vote-${this.thyLayout()}`);\n classNames.push(`thy-vote-${this.thyLayout()}-size-${this.thySize()}`);\n this.hostRenderer.updateClass(classNames);\n }\n}\n","@if (voteIcon()) {\n <ng-container [ngTemplateOutlet]=\"voteIcon()\"></ng-container>\n} @else {\n <thy-icon [thyIconName]=\"thyIcon()\" [thyIconType]=\"thyHasVoted() ? 'fill' : ''\"></thy-icon>\n}\n<div>{{ thyVoteCount() }}</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ThySharedModule } from 'ngx-tethys/shared';\nimport { ThyVote } from './vote.component';\nimport { ThyIconModule } from 'ngx-tethys/icon';\n@NgModule({\n imports: [CommonModule, ThySharedModule, ThyIconModule, ThyVote],\n exports: [ThyVote],\n providers: []\n})\nexport class ThyVoteModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAYA;;;;AAIG;MAWU,OAAO,CAAA;AAwDhB,IAAA,WAAA,GAAA;QAvDQ,IAAY,CAAA,YAAA,GAAG,eAAe,EAAE;AAExC;;AAEG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAA6B,SAAS,EAAE;YAC5D,SAAS,EAAE,CAAC,KAAmB,KAAK,KAAK,IAAI;AAChD,SAAA,CAAC;AAEF;;AAEG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAA2B,SAAS,EAAE;YAC1D,SAAS,EAAE,CAAC,KAAkB,KAAK,KAAK,IAAI;AAC/C,SAAA,CAAC;AAEF;;AAEG;QACM,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC;AAEtE;;AAEG;AACM,QAAA,IAAA,CAAA,SAAS,GAAG,KAAK,CAA+B,YAAY,EAAE;YACnE,SAAS,EAAE,CAAC,KAAoB,KAAK,KAAK,IAAI;AACjD,SAAA,CAAC;AAEF;;AAEG;QACM,IAAY,CAAA,YAAA,GAAG,KAAK,EAAmB;AAEhD;;AAEG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAiB,UAAU,EAAE;YACjD,SAAS,EAAE,CAAC,KAAa,KAAK,K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A,EAAA,EAAA,IAAA,EAAA,aAAa,YAJZ,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,CAAA,EAAA,CAAA,CAAA;;2FAItD,aAAa,EAAA,UAAA,EAAA,CAAA;kBALzB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACN,OAAO,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,CAAC;oBAChE,OAAO,EAAE,CAAC,OAAO,CAAC;AAClB,oBAAA,SAAS,EAAE;AACd,iBAAA;;;ACTD;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, DestroyRef, effect,
|
|
2
|
+
import { inject, ElementRef, input, computed, DestroyRef, effect, Directive, NgModule } from '@angular/core';
|
|
3
3
|
import { Subject, Observable } from 'rxjs';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { MutationObserverFactory } from '@angular/cdk/observers';
|
|
@@ -33,30 +33,50 @@ const DEFAULT_CANVAS_CONFIG = {
|
|
|
33
33
|
* @name thyWatermark
|
|
34
34
|
*/
|
|
35
35
|
class ThyWatermarkDirective {
|
|
36
|
-
/**
|
|
37
|
-
* 水印内容
|
|
38
|
-
*/
|
|
39
|
-
set thyWatermark(value) {
|
|
40
|
-
value = value?.replace(/^\"|\"$/g, '');
|
|
41
|
-
this.content = !!value ? value : '';
|
|
42
|
-
}
|
|
43
36
|
constructor() {
|
|
44
37
|
this.el = inject(ElementRef);
|
|
45
38
|
/**
|
|
46
39
|
* 是否禁用,默认为 false
|
|
47
40
|
*/
|
|
48
|
-
this.thyDisabled = false;
|
|
41
|
+
this.thyDisabled = input(false, { transform: coerceBooleanProperty });
|
|
42
|
+
/**
|
|
43
|
+
* 水印内容
|
|
44
|
+
*/
|
|
45
|
+
this.thyWatermark = input(undefined);
|
|
46
|
+
/**
|
|
47
|
+
* 水印样式配置
|
|
48
|
+
*/
|
|
49
|
+
this.thyCanvasConfig = input(undefined);
|
|
50
|
+
this.content = computed(() => {
|
|
51
|
+
const value = this.thyWatermark()?.replace(/^\"|\"$/g, '');
|
|
52
|
+
return value || '';
|
|
53
|
+
});
|
|
49
54
|
this.createWatermark$ = new Subject();
|
|
50
55
|
this.destroyRef = inject(DestroyRef);
|
|
51
56
|
this.thyThemeStore = inject(ThyThemeStore);
|
|
52
57
|
effect(() => {
|
|
53
|
-
if (!this.thyDisabled && this.thyThemeStore.theme()) {
|
|
58
|
+
if (!this.thyDisabled() && this.thyThemeStore.theme()) {
|
|
59
|
+
this.refreshWatermark();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
effect(() => {
|
|
63
|
+
const thyWatermark = this.thyWatermark();
|
|
64
|
+
if (thyWatermark) {
|
|
65
|
+
this.refreshWatermark();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
effect(() => {
|
|
69
|
+
const thyDisabled = this.thyDisabled();
|
|
70
|
+
if (thyDisabled) {
|
|
71
|
+
this.removeWatermark();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
54
74
|
this.refreshWatermark();
|
|
55
75
|
}
|
|
56
76
|
});
|
|
57
77
|
}
|
|
58
78
|
ngOnInit() {
|
|
59
|
-
if (!this.thyDisabled) {
|
|
79
|
+
if (!this.thyDisabled()) {
|
|
60
80
|
this.createWatermark$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
61
81
|
this.observeAttributes()
|
|
62
82
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
@@ -65,23 +85,6 @@ class ThyWatermarkDirective {
|
|
|
65
85
|
this.createWatermark();
|
|
66
86
|
}
|
|
67
87
|
}
|
|
68
|
-
ngOnChanges(changes) {
|
|
69
|
-
const { thyWatermark, thyDisabled } = changes;
|
|
70
|
-
const thyWatermarkChange = () => {
|
|
71
|
-
if (thyWatermark.firstChange)
|
|
72
|
-
return;
|
|
73
|
-
if (thyWatermark.currentValue) {
|
|
74
|
-
this.refreshWatermark();
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const thyDisabledChange = () => {
|
|
78
|
-
if (thyDisabled.firstChange)
|
|
79
|
-
return;
|
|
80
|
-
thyDisabled?.currentValue ? this.removeWatermark() : this.refreshWatermark();
|
|
81
|
-
};
|
|
82
|
-
thyWatermark && thyWatermarkChange();
|
|
83
|
-
thyDisabled && thyDisabledChange();
|
|
84
|
-
}
|
|
85
88
|
refreshWatermark() {
|
|
86
89
|
this.removeWatermark();
|
|
87
90
|
this.createWatermark();
|
|
@@ -95,7 +98,7 @@ class ThyWatermarkDirective {
|
|
|
95
98
|
createCanvas() {
|
|
96
99
|
let { gutter, fontSize, color, degree, textLineHeight } = {
|
|
97
100
|
...DEFAULT_CANVAS_CONFIG,
|
|
98
|
-
...(this.thyCanvasConfig || {})
|
|
101
|
+
...(this.thyCanvasConfig() || {})
|
|
99
102
|
};
|
|
100
103
|
color = this.thyThemeStore.normalizeColor(color);
|
|
101
104
|
const [xGutter, yGutter] = gutter;
|
|
@@ -115,7 +118,7 @@ class ThyWatermarkDirective {
|
|
|
115
118
|
};
|
|
116
119
|
const styleStr = Object.keys(fakeBoxStyle).reduce((pre, next) => ((pre += `${next}:${fakeBoxStyle[next]};`), pre), '');
|
|
117
120
|
fakeBox.setAttribute('style', styleStr);
|
|
118
|
-
fakeBox.innerHTML = this.content.replace(/(\\n)/gm, '</br>');
|
|
121
|
+
fakeBox.innerHTML = this.content().replace(/(\\n)/gm, '</br>');
|
|
119
122
|
document.querySelector('body').insertBefore(fakeBox, document.querySelector('body').firstChild);
|
|
120
123
|
const { width, height } = fakeBox.getBoundingClientRect();
|
|
121
124
|
fakeBox.remove();
|
|
@@ -123,7 +126,7 @@ class ThyWatermarkDirective {
|
|
|
123
126
|
};
|
|
124
127
|
const { width: fakeBoxWidth, height: fakeBoxHeight } = getFakeSize();
|
|
125
128
|
const angle = (degree * Math.PI) / 180;
|
|
126
|
-
const contentArr = this.content.split('\\n');
|
|
129
|
+
const contentArr = this.content().split('\\n');
|
|
127
130
|
const canvasHeight = Math.sin(angle) * fakeBoxWidth + fakeBoxHeight;
|
|
128
131
|
let start = Math.ceil(Math.sin(angle) * fakeBoxWidth * Math.sin(angle));
|
|
129
132
|
const canvasWidth = start + fakeBoxWidth;
|
|
@@ -181,21 +184,14 @@ class ThyWatermarkDirective {
|
|
|
181
184
|
});
|
|
182
185
|
}
|
|
183
186
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyWatermarkDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
184
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
187
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.8", type: ThyWatermarkDirective, isStandalone: true, selector: "[thyWatermark]", inputs: { thyDisabled: { classPropertyName: "thyDisabled", publicName: "thyDisabled", isSignal: true, isRequired: false, transformFunction: null }, thyWatermark: { classPropertyName: "thyWatermark", publicName: "thyWatermark", isSignal: true, isRequired: false, transformFunction: null }, thyCanvasConfig: { classPropertyName: "thyCanvasConfig", publicName: "thyCanvasConfig", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
185
188
|
}
|
|
186
189
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyWatermarkDirective, decorators: [{
|
|
187
190
|
type: Directive,
|
|
188
191
|
args: [{
|
|
189
192
|
selector: '[thyWatermark]'
|
|
190
193
|
}]
|
|
191
|
-
}], ctorParameters: () => []
|
|
192
|
-
type: Input,
|
|
193
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
194
|
-
}], thyWatermark: [{
|
|
195
|
-
type: Input
|
|
196
|
-
}], thyCanvasConfig: [{
|
|
197
|
-
type: Input
|
|
198
|
-
}] } });
|
|
194
|
+
}], ctorParameters: () => [] });
|
|
199
195
|
|
|
200
196
|
class ThyWatermarkModule {
|
|
201
197
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyWatermarkModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-tethys-watermark.mjs","sources":["../../../src/watermark/config.ts","../../../src/watermark/watermark.directive.ts","../../../src/watermark/watermark.module.ts","../../../src/watermark/ngx-tethys-watermark.ts"],"sourcesContent":["export const DEFAULT_WATERMARK_CONFIG = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n opacity: '0.8',\n 'background-repeat': 'repeat',\n 'pointer-events': 'none',\n 'z-index': 2147483647,\n 'background-image': ''\n};\n\nexport const DEFAULT_CANVAS_CONFIG = {\n degree: 15,\n color: ['rgba(51, 51, 51, 0.12)', 'rgb(60, 65, 74)'],\n fontSize: 12,\n textLineHeight: 20,\n gutter: [250, 200]\n};\n","import { Directive, Input, ElementRef, OnInit, SimpleChanges, OnChanges, inject, DestroyRef, effect } from '@angular/core';\nimport { Subject, Observable } from 'rxjs';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { DEFAULT_WATERMARK_CONFIG, DEFAULT_CANVAS_CONFIG } from './config';\nimport { MutationObserverFactory } from '@angular/cdk/observers';\nimport { coerceBooleanProperty } from 'ngx-tethys/util';\nimport { ThyThemeStore } from 'ngx-tethys/core';\n\n/**\n * @public\n * 水印样式配置\n */\nexport interface ThyCanvasConfigType {\n /**\n * 偏移角度\n */\n degree?: number;\n /**\n * 字体颜色。如果传的是数组,第一个为默认主题的字体颜色,第二个为黑暗主题的字体颜色\n */\n color?: string | string[];\n /**\n * 字体大小\n */\n fontSize?: number | string;\n /**\n * 文本行高\n */\n textLineHeight?: number;\n /**\n * 横纵间距\n */\n gutter?: number[];\n}\n\n/**\n * 水印指令\n * @name thyWatermark\n */\n@Directive({\n selector: '[thyWatermark]'\n})\nexport class ThyWatermarkDirective implements OnInit, OnChanges {\n private el = inject(ElementRef);\n\n /**\n * 是否禁用,默认为 false\n */\n @Input({ transform: coerceBooleanProperty })\n thyDisabled: boolean = false;\n\n content: string;\n /**\n * 水印内容\n */\n @Input()\n set thyWatermark(value: string) {\n value = value?.replace(/^\\\"|\\\"$/g, '');\n this.content = !!value ? value : '';\n }\n\n /**\n * 水印样式配置\n */\n @Input() thyCanvasConfig: ThyCanvasConfigType;\n\n private createWatermark$ = new Subject<string>();\n\n private observer: MutationObserver;\n\n private canvas: HTMLCanvasElement;\n\n private wmDiv: HTMLElement;\n\n private readonly destroyRef = inject(DestroyRef);\n\n private thyThemeStore = inject(ThyThemeStore);\n\n constructor() {\n effect(() => {\n if (!this.thyDisabled && this.thyThemeStore.theme()) {\n this.refreshWatermark();\n }\n });\n }\n\n ngOnInit() {\n if (!this.thyDisabled) {\n this.createWatermark$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.observeAttributes()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => {});\n });\n\n this.createWatermark();\n }\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n const { thyWatermark, thyDisabled } = changes;\n const thyWatermarkChange = () => {\n if (thyWatermark.firstChange) return;\n if (thyWatermark.currentValue) {\n this.refreshWatermark();\n }\n };\n const thyDisabledChange = () => {\n if (thyDisabled.firstChange) return;\n thyDisabled?.currentValue ? this.removeWatermark() : this.refreshWatermark();\n };\n thyWatermark && thyWatermarkChange();\n thyDisabled && thyDisabledChange();\n }\n\n private refreshWatermark() {\n this.removeWatermark();\n this.createWatermark();\n }\n\n private removeWatermark() {\n if (this.wmDiv) {\n this.wmDiv.remove();\n this.wmDiv = null;\n }\n }\n\n createCanvas() {\n let { gutter, fontSize, color, degree, textLineHeight } = {\n ...DEFAULT_CANVAS_CONFIG,\n ...(this.thyCanvasConfig || {})\n };\n color = this.thyThemeStore.normalizeColor(color);\n\n const [xGutter, yGutter] = gutter;\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n\n const getFakeSize = () => {\n const fakeBox = document.createElement('div');\n const fakeBoxStyle = {\n position: 'absolute',\n top: 0,\n left: 0,\n display: 'inline-block',\n 'font-size': `${parseFloat('' + fontSize)}px`,\n 'word-wrap': 'break-word',\n 'font-family': 'inherit',\n 'white-space': 'pre-line'\n };\n const styleStr = Object.keys(fakeBoxStyle).reduce((pre, next) => ((pre += `${next}:${fakeBoxStyle[next]};`), pre), '');\n fakeBox.setAttribute('style', styleStr);\n\n fakeBox.innerHTML = this.content.replace(/(\\\\n)/gm, '</br>');\n document.querySelector('body').insertBefore(fakeBox, document.querySelector('body').firstChild);\n const { width, height } = fakeBox.getBoundingClientRect();\n fakeBox.remove();\n return { width, height };\n };\n const { width: fakeBoxWidth, height: fakeBoxHeight } = getFakeSize();\n\n const angle = (degree * Math.PI) / 180;\n const contentArr = this.content.split('\\\\n');\n const canvasHeight = Math.sin(angle) * fakeBoxWidth + fakeBoxHeight;\n\n let start = Math.ceil(Math.sin(angle) * fakeBoxWidth * Math.sin(angle));\n const canvasWidth = start + fakeBoxWidth;\n canvas.setAttribute('width', '' + (canvasWidth + xGutter));\n canvas.setAttribute('height', '' + (canvasHeight + yGutter));\n\n ctx.font = `${parseFloat('' + fontSize)}px microsoft yahei`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'top';\n ctx.fillStyle = color;\n ctx.rotate(0 - (degree * Math.PI) / 180);\n contentArr.map((k, i) => {\n ctx.fillText(k, -start + Math.ceil(canvasWidth / 2), Math.sin(angle) * canvasWidth + textLineHeight * i);\n start += Math.sin(angle) * textLineHeight;\n });\n this.canvas = canvas;\n return canvas;\n }\n\n private createWatermark(isRefresh = true) {\n const watermarkDiv = this.wmDiv || document.createElement('div');\n\n const background = !isRefresh ? this.canvas.toDataURL() : this.createCanvas().toDataURL();\n const watermarkStyle = {\n ...DEFAULT_WATERMARK_CONFIG,\n 'background-image': `url(${background})`\n };\n\n const styleStr = Object.keys(watermarkStyle).reduce((pre, next) => ((pre += `${next}:${watermarkStyle[next]};`), pre), '');\n watermarkDiv.setAttribute('style', styleStr);\n\n if (!this.wmDiv) {\n const parentNode = this.el.nativeElement;\n watermarkDiv.classList.add(`_vm`);\n this.wmDiv = watermarkDiv;\n parentNode.insertBefore(watermarkDiv, parentNode.firstChild);\n }\n this.createWatermark$.next('');\n }\n\n private observeAttributes() {\n this.observer?.disconnect();\n return new Observable(observe => {\n const stream = new Subject<MutationRecord[]>();\n this.observer = new MutationObserverFactory().create(mutations => stream.next(mutations));\n if (this.observer) {\n this.observer.observe(this.wmDiv, {\n attributes: true\n });\n }\n stream.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n if (this.wmDiv) {\n this?.observer?.disconnect();\n this.createWatermark(false);\n }\n });\n observe.next(stream);\n return () => {\n this.observer?.disconnect();\n };\n });\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ThySharedModule } from 'ngx-tethys/shared';\nimport { ThyWatermarkDirective } from './watermark.directive';\n\n@NgModule({\n imports: [CommonModule, ThySharedModule, ThyWatermarkDirective],\n exports: [ThyWatermarkDirective],\n providers: []\n})\nexport class ThyWatermarkModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAO,MAAM,wBAAwB,GAAG;AACpC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,GAAG,EAAE,CAAC;AACN,IAAA,IAAI,EAAE,CAAC;AACP,IAAA,KAAK,EAAE,MAAM;AACb,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,mBAAmB,EAAE,QAAQ;AAC7B,IAAA,gBAAgB,EAAE,MAAM;AACxB,IAAA,SAAS,EAAE,UAAU;AACrB,IAAA,kBAAkB,EAAE;CACvB;AAEM,MAAM,qBAAqB,GAAG;AACjC,IAAA,MAAM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kBAHjC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACP,oBAAA,QAAQ,EAAE;AACb,iBAAA;wDAQG,WAAW,EAAA,CAAA;sBADV,KAAK;uBAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE;gBAQvC,YAAY,EAAA,CAAA;sBADf;gBASQ,eAAe,EAAA,CAAA;sBAAvB;;;MCtDQ,kBAAkB,CAAA;8GAAlB,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAlB,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,kBAAkB,YAJjB,YAAY,EAAE,eAAe,EAAE,qBAAqB,aACpD,qBAAqB,CAAA,EAAA,CAAA,CAAA;+GAGtB,kBAAkB,EAAA,OAAA,EAAA,CAJjB,YAAY,EAAE,eAAe,CAAA,EAAA,CAAA,CAAA;;2FAI9B,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,qBAAqB,CAAC;oBAC/D,OAAO,EAAE,CAAC,qBAAqB,CAAC;AAChC,oBAAA,SAAS,EAAE;AACd,iBAAA;;;ACTD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-tethys-watermark.mjs","sources":["../../../src/watermark/config.ts","../../../src/watermark/watermark.directive.ts","../../../src/watermark/watermark.module.ts","../../../src/watermark/ngx-tethys-watermark.ts"],"sourcesContent":["export const DEFAULT_WATERMARK_CONFIG = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n opacity: '0.8',\n 'background-repeat': 'repeat',\n 'pointer-events': 'none',\n 'z-index': 2147483647,\n 'background-image': ''\n};\n\nexport const DEFAULT_CANVAS_CONFIG = {\n degree: 15,\n color: ['rgba(51, 51, 51, 0.12)', 'rgb(60, 65, 74)'],\n fontSize: 12,\n textLineHeight: 20,\n gutter: [250, 200]\n};\n","import { Directive, ElementRef, OnInit, inject, DestroyRef, effect, input, computed } from '@angular/core';\nimport { Subject, Observable } from 'rxjs';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { DEFAULT_WATERMARK_CONFIG, DEFAULT_CANVAS_CONFIG } from './config';\nimport { MutationObserverFactory } from '@angular/cdk/observers';\nimport { coerceBooleanProperty, ThyBooleanInput } from 'ngx-tethys/util';\nimport { ThyThemeStore } from 'ngx-tethys/core';\n\n/**\n * @public\n * 水印样式配置\n */\nexport interface ThyCanvasConfigType {\n /**\n * 偏移角度\n */\n degree?: number;\n /**\n * 字体颜色。如果传的是数组,第一个为默认主题的字体颜色,第二个为黑暗主题的字体颜色\n */\n color?: string | string[];\n /**\n * 字体大小\n */\n fontSize?: number | string;\n /**\n * 文本行高\n */\n textLineHeight?: number;\n /**\n * 横纵间距\n */\n gutter?: number[];\n}\n\n/**\n * 水印指令\n * @name thyWatermark\n */\n@Directive({\n selector: '[thyWatermark]'\n})\nexport class ThyWatermarkDirective implements OnInit {\n private el = inject(ElementRef);\n\n /**\n * 是否禁用,默认为 false\n */\n readonly thyDisabled = input<boolean, ThyBooleanInput>(false, { transform: coerceBooleanProperty });\n\n /**\n * 水印内容\n */\n readonly thyWatermark = input<string>(undefined);\n\n /**\n * 水印样式配置\n */\n readonly thyCanvasConfig = input<ThyCanvasConfigType>(undefined);\n\n readonly content = computed(() => {\n const value = this.thyWatermark()?.replace(/^\\\"|\\\"$/g, '');\n return value || '';\n });\n\n private createWatermark$ = new Subject<string>();\n\n private observer: MutationObserver;\n\n private canvas: HTMLCanvasElement;\n\n private wmDiv: HTMLElement;\n\n private readonly destroyRef = inject(DestroyRef);\n\n private thyThemeStore = inject(ThyThemeStore);\n\n constructor() {\n effect(() => {\n if (!this.thyDisabled() && this.thyThemeStore.theme()) {\n this.refreshWatermark();\n }\n });\n\n effect(() => {\n const thyWatermark = this.thyWatermark();\n if (thyWatermark) {\n this.refreshWatermark();\n }\n });\n\n effect(() => {\n const thyDisabled = this.thyDisabled();\n if (thyDisabled) {\n this.removeWatermark();\n } else {\n this.refreshWatermark();\n }\n });\n }\n\n ngOnInit() {\n if (!this.thyDisabled()) {\n this.createWatermark$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n this.observeAttributes()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => {});\n });\n\n this.createWatermark();\n }\n }\n\n private refreshWatermark() {\n this.removeWatermark();\n this.createWatermark();\n }\n\n private removeWatermark() {\n if (this.wmDiv) {\n this.wmDiv.remove();\n this.wmDiv = null;\n }\n }\n\n createCanvas() {\n let { gutter, fontSize, color, degree, textLineHeight } = {\n ...DEFAULT_CANVAS_CONFIG,\n ...(this.thyCanvasConfig() || {})\n };\n color = this.thyThemeStore.normalizeColor(color);\n\n const [xGutter, yGutter] = gutter;\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n\n const getFakeSize = () => {\n const fakeBox = document.createElement('div');\n const fakeBoxStyle: Record<string, string | number> = {\n position: 'absolute',\n top: 0,\n left: 0,\n display: 'inline-block',\n 'font-size': `${parseFloat('' + fontSize)}px`,\n 'word-wrap': 'break-word',\n 'font-family': 'inherit',\n 'white-space': 'pre-line'\n };\n const styleStr = Object.keys(fakeBoxStyle).reduce((pre, next) => ((pre += `${next}:${fakeBoxStyle[next]};`), pre), '');\n fakeBox.setAttribute('style', styleStr);\n\n fakeBox.innerHTML = this.content().replace(/(\\\\n)/gm, '</br>');\n document.querySelector('body').insertBefore(fakeBox, document.querySelector('body').firstChild);\n const { width, height } = fakeBox.getBoundingClientRect();\n fakeBox.remove();\n return { width, height };\n };\n const { width: fakeBoxWidth, height: fakeBoxHeight } = getFakeSize();\n\n const angle = (degree * Math.PI) / 180;\n const contentArr = this.content().split('\\\\n');\n const canvasHeight = Math.sin(angle) * fakeBoxWidth + fakeBoxHeight;\n\n let start = Math.ceil(Math.sin(angle) * fakeBoxWidth * Math.sin(angle));\n const canvasWidth = start + fakeBoxWidth;\n canvas.setAttribute('width', '' + (canvasWidth + xGutter));\n canvas.setAttribute('height', '' + (canvasHeight + yGutter));\n\n ctx.font = `${parseFloat('' + fontSize)}px microsoft yahei`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'top';\n ctx.fillStyle = color;\n ctx.rotate(0 - (degree * Math.PI) / 180);\n contentArr.map((k, i) => {\n ctx.fillText(k, -start + Math.ceil(canvasWidth / 2), Math.sin(angle) * canvasWidth + textLineHeight * i);\n start += Math.sin(angle) * textLineHeight;\n });\n this.canvas = canvas;\n return canvas;\n }\n\n private createWatermark(isRefresh = true) {\n const watermarkDiv = this.wmDiv || document.createElement('div');\n\n const background = !isRefresh ? this.canvas.toDataURL() : this.createCanvas().toDataURL();\n const watermarkStyle: Record<string, string | number> = {\n ...DEFAULT_WATERMARK_CONFIG,\n 'background-image': `url(${background})`\n };\n\n const styleStr = Object.keys(watermarkStyle).reduce((pre, next) => ((pre += `${next}:${watermarkStyle[next]};`), pre), '');\n watermarkDiv.setAttribute('style', styleStr);\n\n if (!this.wmDiv) {\n const parentNode = this.el.nativeElement;\n watermarkDiv.classList.add(`_vm`);\n this.wmDiv = watermarkDiv;\n parentNode.insertBefore(watermarkDiv, parentNode.firstChild);\n }\n this.createWatermark$.next('');\n }\n\n private observeAttributes() {\n this.observer?.disconnect();\n return new Observable(observe => {\n const stream = new Subject<MutationRecord[]>();\n this.observer = new MutationObserverFactory().create(mutations => stream.next(mutations));\n if (this.observer) {\n this.observer.observe(this.wmDiv, {\n attributes: true\n });\n }\n stream.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {\n if (this.wmDiv) {\n this?.observer?.disconnect();\n this.createWatermark(false);\n }\n });\n observe.next(stream);\n return () => {\n this.observer?.disconnect();\n };\n });\n }\n}\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { ThySharedModule } from 'ngx-tethys/shared';\nimport { ThyWatermarkDirective } from './watermark.directive';\n\n@NgModule({\n imports: [CommonModule, ThySharedModule, ThyWatermarkDirective],\n exports: [ThyWatermarkDirective],\n providers: []\n})\nexport class ThyWatermarkModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAO,MAAM,wBAAwB,GAAG;AACpC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,GAAG,EAAE,CAAC;AACN,IAAA,IAAI,EAAE,CAAC;AACP,IAAA,KAAK,EAAE,MAAM;AACb,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,mBAAmB,EAAE,QAAQ;AAC7B,IAAA,gBAAgB,EAAE,MAAM;AACxB,IAAA,SAAS,EAAE,UAAU;AACrB,IAAA,kBAAkB,EAAE;CACvB;AAEM,MAAM,qBAAqB,GAAG;AACjC,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,CAAC,wBAAwB,EAAE,iBAAiB,CAAC;AACpD,IAAA,QAAQ,EAAE,EAAE;AACZ,IAAA,cAAc,EAAE,EAAE;AAClB,IAAA,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG;CACpB;;ACgBD;;;AAGG;MAIU,qBAAqB,CAAA;AAmC9B,IAAA,WAAA,GAAA;AAlCQ,QAAA,IAAA,CAAA,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;AAE/B;;AAEG;QACM,IAAW,CAAA,WAAA,GAAG,KAAK,CAA2B,KAAK,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC;AAEnG;;AAEG;AACM,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAS,SAAS,CAAC;AAEhD;;AAEG;AACM,QAAA,IAAA,CAAA,eAAe,GAAG,KAAK,CAAsB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CAAA,QAAA,EAAA,CAAA,CAAA;AAAlB,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,kBAAkB,YAJjB,YAAY,EAAE,eAAe,EAAE,qBAAqB,aACpD,qBAAqB,CAAA,EAAA,CAAA,CAAA;+GAGtB,kBAAkB,EAAA,OAAA,EAAA,CAJjB,YAAY,EAAE,eAAe,CAAA,EAAA,CAAA,CAAA;;2FAI9B,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,qBAAqB,CAAC;oBAC/D,OAAO,EAAE,CAAC,qBAAqB,CAAC;AAChC,oBAAA,SAAS,EAAE;AACd,iBAAA;;;ACTD;;AAEG;;;;"}
|
package/fesm2022/ngx-tethys.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-tethys.mjs","sources":["../../../src/version.ts","../../../src/ngx-tethys.ts"],"sourcesContent":["import { Version } from '@angular/core';\n\nexport const VERSION = new Version('19.0.
|
|
1
|
+
{"version":3,"file":"ngx-tethys.mjs","sources":["../../../src/version.ts","../../../src/ngx-tethys.ts"],"sourcesContent":["import { Version } from '@angular/core';\n\nexport const VERSION = new Version('19.1.0-next.1');\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;MAEa,OAAO,GAAG,IAAI,OAAO,CAAC,eAAe;;ACFlD;;AAEG;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterContentInit, OnDestroy,
|
|
1
|
+
import { AfterContentInit, OnDestroy, TemplateRef } from '@angular/core';
|
|
2
2
|
import { ThyPlacement } from 'ngx-tethys/core';
|
|
3
3
|
import { ThyTooltipDirective } from 'ngx-tethys/tooltip';
|
|
4
4
|
import { Observable, Subscription } from 'rxjs';
|
|
@@ -8,52 +8,46 @@ import * as i1 from "ngx-tethys/tooltip";
|
|
|
8
8
|
* 文本提示组件,支持组件 thy-flexible-text 和指令 [thyFlexibleText] 两种方式
|
|
9
9
|
* @name thy-flexible-text,[thyFlexibleText]
|
|
10
10
|
*/
|
|
11
|
-
export declare class ThyFlexibleText implements
|
|
11
|
+
export declare class ThyFlexibleText implements AfterContentInit, OnDestroy {
|
|
12
12
|
private elementRef;
|
|
13
13
|
private contentObserver;
|
|
14
14
|
private ngZone;
|
|
15
15
|
tooltipDirective: ThyTooltipDirective;
|
|
16
16
|
isOverflow: boolean;
|
|
17
|
-
content: string | TemplateRef<HTMLElement>;
|
|
18
|
-
placement: ThyPlacement;
|
|
19
|
-
containerClass: string;
|
|
20
17
|
subscription: Subscription | null;
|
|
21
|
-
offset: number;
|
|
22
18
|
/**
|
|
23
19
|
* 触发提示方式
|
|
24
20
|
* @type hover | focus | click
|
|
25
21
|
* @default hover
|
|
26
22
|
*/
|
|
27
|
-
trigger:
|
|
23
|
+
readonly trigger: import("@angular/core").InputSignal<"focus" | "hover" | "click">;
|
|
28
24
|
/**
|
|
29
25
|
* 自定义class类,如果不设置默认会包含 `flexible-text-container`
|
|
30
26
|
*/
|
|
31
|
-
|
|
32
|
-
get thyContainerClass(): string;
|
|
27
|
+
readonly thyContainerClass: import("@angular/core").InputSignal<string>;
|
|
33
28
|
/**
|
|
34
29
|
* 需要展示的全部内容
|
|
35
30
|
* @type string | TemplateRef<HTMLElement>
|
|
36
31
|
*/
|
|
37
|
-
|
|
32
|
+
readonly thyTooltipContent: import("@angular/core").InputSignal<string | TemplateRef<HTMLElement>>;
|
|
38
33
|
/**
|
|
39
34
|
* tooltip 的提示位置
|
|
40
35
|
* @type top | bottom | left | right
|
|
41
36
|
* @default top
|
|
42
37
|
*/
|
|
43
|
-
|
|
38
|
+
readonly thyTooltipPlacement: import("@angular/core").InputSignal<ThyPlacement>;
|
|
44
39
|
/**
|
|
45
40
|
* tooltip 偏移量
|
|
46
41
|
*/
|
|
47
|
-
|
|
42
|
+
readonly thyTooltipOffset: import("@angular/core").InputSignalWithTransform<number, unknown>;
|
|
48
43
|
private destroy$;
|
|
49
44
|
private hostRenderer;
|
|
50
45
|
static createResizeObserver(element: HTMLElement): Observable<unknown>;
|
|
51
|
-
|
|
46
|
+
constructor();
|
|
52
47
|
ngAfterContentInit(): void;
|
|
53
48
|
ngOnDestroy(): void;
|
|
54
49
|
applyOverflow(): void;
|
|
55
50
|
updateContainerClass(): void;
|
|
56
51
|
static ɵfac: i0.ɵɵFactoryDeclaration<ThyFlexibleText, never>;
|
|
57
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ThyFlexibleText, "thy-flexible-text,[thyFlexibleText]", ["thyFlexibleText"], { "trigger": { "alias": "thyTooltipTrigger"; "required": false; }; "thyContainerClass": { "alias": "thyContainerClass"; "required": false; }; "
|
|
58
|
-
static ngAcceptInputType_thyOffset: unknown;
|
|
52
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ThyFlexibleText, "thy-flexible-text,[thyFlexibleText]", ["thyFlexibleText"], { "trigger": { "alias": "thyTooltipTrigger"; "required": false; "isSignal": true; }; "thyContainerClass": { "alias": "thyContainerClass"; "required": false; "isSignal": true; }; "thyTooltipContent": { "alias": "thyTooltipContent"; "required": false; "isSignal": true; }; "thyTooltipPlacement": { "alias": "thyTooltipPlacement"; "required": false; "isSignal": true; }; "thyTooltipOffset": { "alias": "thyTooltipOffset"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, [{ directive: typeof i1.ThyTooltipDirective; inputs: {}; outputs: {}; }]>;
|
|
59
53
|
}
|
|
@@ -7,7 +7,7 @@ import * as i0 from "@angular/core";
|
|
|
7
7
|
export declare class ThyFormGroupError implements OnInit {
|
|
8
8
|
private thyParentForm;
|
|
9
9
|
errors: string[];
|
|
10
|
-
thyShowFirst: boolean
|
|
10
|
+
readonly thyShowFirst: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
11
11
|
/**
|
|
12
12
|
* @type string[]
|
|
13
13
|
*/
|
|
@@ -17,6 +17,5 @@ export declare class ThyFormGroupError implements OnInit {
|
|
|
17
17
|
isHorizontal: boolean;
|
|
18
18
|
ngOnInit(): void;
|
|
19
19
|
static ɵfac: i0.ɵɵFactoryDeclaration<ThyFormGroupError, never>;
|
|
20
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ThyFormGroupError, "thy-form-group-error", never, { "thyShowFirst": { "alias": "thyShowFirst"; "required": false; }; "thyErrors": { "alias": "thyErrors"; "required": false; }; }, {}, never, never, true, never>;
|
|
21
|
-
static ngAcceptInputType_thyShowFirst: boolean | string | number;
|
|
20
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ThyFormGroupError, "thy-form-group-error", never, { "thyShowFirst": { "alias": "thyShowFirst"; "required": false; "isSignal": true; }; "thyErrors": { "alias": "thyErrors"; "required": false; }; }, {}, never, never, true, never>;
|
|
22
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "ngx-tethys/util";
|
|
2
3
|
/**
|
|
3
4
|
* @name thyFormGroupLabel
|
|
4
5
|
* @order 45
|
|
@@ -13,5 +14,5 @@ export declare class ThyFormGroupLabelDirective {
|
|
|
13
14
|
set thyLabelRequired(value: boolean);
|
|
14
15
|
static ɵfac: i0.ɵɵFactoryDeclaration<ThyFormGroupLabelDirective, never>;
|
|
15
16
|
static ɵdir: i0.ɵɵDirectiveDeclaration<ThyFormGroupLabelDirective, "[thyFormGroupLabel]", never, { "thyLabelText": { "alias": "thyLabelText"; "required": false; }; "thyLabelTranslateKey": { "alias": "thyLabelTranslateKey"; "required": false; }; "thyLabelRequired": { "alias": "thyLabelRequired"; "required": false; }; }, {}, never, never, true, never>;
|
|
16
|
-
static ngAcceptInputType_thyLabelRequired:
|
|
17
|
+
static ngAcceptInputType_thyLabelRequired: i1.ThyBooleanInput;
|
|
17
18
|
}
|