ngx-tethys 19.1.0-next.0 → 19.1.0-next.2

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +0 -1
  3. package/action/action.component.d.ts +7 -8
  4. package/affix/affix.component.d.ts +3 -4
  5. package/arrow-switcher/arrow-switcher.component.d.ts +5 -1
  6. package/button/button-group.component.d.ts +5 -12
  7. package/button/button-icon.component.d.ts +14 -28
  8. package/button/button.component.d.ts +17 -27
  9. package/date-picker/styles/calendar.scss +1 -1
  10. package/date-picker/styles/range-picker.scss +1 -0
  11. package/date-picker/styles/week-picker.scss +1 -0
  12. package/dropdown/dropdown-active.directive.d.ts +4 -5
  13. package/dropdown/dropdown-menu-item.directive.d.ts +7 -15
  14. package/dropdown/dropdown-menu.component.d.ts +6 -13
  15. package/dropdown/dropdown-submenu.component.d.ts +2 -4
  16. package/dropdown/dropdown.directive.d.ts +14 -25
  17. package/fesm2022/ngx-tethys-action.mjs +15 -16
  18. package/fesm2022/ngx-tethys-action.mjs.map +1 -1
  19. package/fesm2022/ngx-tethys-affix.mjs +14 -18
  20. package/fesm2022/ngx-tethys-affix.mjs.map +1 -1
  21. package/fesm2022/ngx-tethys-arrow-switcher.mjs +15 -3
  22. package/fesm2022/ngx-tethys-arrow-switcher.mjs.map +1 -1
  23. package/fesm2022/ngx-tethys-button.mjs +225 -322
  24. package/fesm2022/ngx-tethys-button.mjs.map +1 -1
  25. package/fesm2022/ngx-tethys-carousel.mjs +1 -0
  26. package/fesm2022/ngx-tethys-carousel.mjs.map +1 -1
  27. package/fesm2022/ngx-tethys-collapse.mjs +2 -2
  28. package/fesm2022/ngx-tethys-collapse.mjs.map +1 -1
  29. package/fesm2022/ngx-tethys-date-picker.mjs +6 -6
  30. package/fesm2022/ngx-tethys-date-picker.mjs.map +1 -1
  31. package/fesm2022/ngx-tethys-dropdown.mjs +155 -203
  32. package/fesm2022/ngx-tethys-dropdown.mjs.map +1 -1
  33. package/fesm2022/ngx-tethys-flexible-text.mjs +67 -86
  34. package/fesm2022/ngx-tethys-flexible-text.mjs.map +1 -1
  35. package/fesm2022/ngx-tethys-grid.mjs +10 -15
  36. package/fesm2022/ngx-tethys-grid.mjs.map +1 -1
  37. package/fesm2022/ngx-tethys-icon.mjs +44 -59
  38. package/fesm2022/ngx-tethys-icon.mjs.map +1 -1
  39. package/fesm2022/ngx-tethys-image.mjs +40 -36
  40. package/fesm2022/ngx-tethys-image.mjs.map +1 -1
  41. package/fesm2022/ngx-tethys-input-number.mjs.map +1 -1
  42. package/fesm2022/ngx-tethys-progress.mjs +7 -11
  43. package/fesm2022/ngx-tethys-progress.mjs.map +1 -1
  44. package/fesm2022/ngx-tethys-property.mjs +8 -19
  45. package/fesm2022/ngx-tethys-property.mjs.map +1 -1
  46. package/fesm2022/ngx-tethys-radio.mjs +42 -54
  47. package/fesm2022/ngx-tethys-radio.mjs.map +1 -1
  48. package/fesm2022/ngx-tethys-rate.mjs +115 -157
  49. package/fesm2022/ngx-tethys-rate.mjs.map +1 -1
  50. package/fesm2022/ngx-tethys-resizable.mjs +111 -157
  51. package/fesm2022/ngx-tethys-resizable.mjs.map +1 -1
  52. package/fesm2022/ngx-tethys-segment.mjs +84 -103
  53. package/fesm2022/ngx-tethys-segment.mjs.map +1 -1
  54. package/fesm2022/ngx-tethys-shared.mjs +2 -1
  55. package/fesm2022/ngx-tethys-shared.mjs.map +1 -1
  56. package/fesm2022/ngx-tethys-slide.mjs +37 -56
  57. package/fesm2022/ngx-tethys-slide.mjs.map +1 -1
  58. package/fesm2022/ngx-tethys-slider.mjs.map +1 -1
  59. package/fesm2022/ngx-tethys-space.mjs +2 -8
  60. package/fesm2022/ngx-tethys-space.mjs.map +1 -1
  61. package/fesm2022/ngx-tethys-strength.mjs +52 -66
  62. package/fesm2022/ngx-tethys-strength.mjs.map +1 -1
  63. package/fesm2022/ngx-tethys-transfer.mjs +98 -119
  64. package/fesm2022/ngx-tethys-transfer.mjs.map +1 -1
  65. package/fesm2022/ngx-tethys-tree-select.mjs +2 -4
  66. package/fesm2022/ngx-tethys-tree-select.mjs.map +1 -1
  67. package/fesm2022/ngx-tethys-tree.mjs +281 -401
  68. package/fesm2022/ngx-tethys-tree.mjs.map +1 -1
  69. package/fesm2022/ngx-tethys-upload.mjs +2 -2
  70. package/fesm2022/ngx-tethys-upload.mjs.map +1 -1
  71. package/fesm2022/ngx-tethys-vote.mjs +53 -99
  72. package/fesm2022/ngx-tethys-vote.mjs.map +1 -1
  73. package/fesm2022/ngx-tethys.mjs +1 -1
  74. package/fesm2022/ngx-tethys.mjs.map +1 -1
  75. package/flexible-text/flexible-text.component.d.ts +9 -15
  76. package/grid/flex.d.ts +1 -3
  77. package/grid/thy-row.directive.d.ts +1 -4
  78. package/icon/icon.component.d.ts +10 -18
  79. package/image/image.directive.d.ts +10 -13
  80. package/image/image.token.d.ts +5 -5
  81. package/input-number/input-number.component.d.ts +1 -1
  82. package/package.json +1 -1
  83. package/progress/progress-circle.component.d.ts +3 -5
  84. package/progress/progress.component.d.ts +2 -4
  85. package/property/properties.component.d.ts +0 -2
  86. package/property/property-item.component.d.ts +3 -10
  87. package/radio/group/radio-group.component.d.ts +5 -9
  88. package/rate/rate-item.component.d.ts +8 -11
  89. package/rate/rate.component.d.ts +18 -29
  90. package/resizable/resizable.directive.d.ts +18 -31
  91. package/resizable/resize-handle.component.d.ts +6 -7
  92. package/resizable/resize-handles.component.d.ts +5 -9
  93. package/schematics/version.d.ts +1 -1
  94. package/schematics/version.js +1 -1
  95. package/segment/segment-item.component.d.ts +9 -15
  96. package/segment/segment.component.d.ts +11 -15
  97. package/segment/segment.token.d.ts +4 -3
  98. package/slide/slide-body/slide-body-section.component.d.ts +2 -6
  99. package/slide/slide-header/slide-header.component.d.ts +6 -9
  100. package/space/space.component.d.ts +5 -11
  101. package/strength/strength.component.d.ts +8 -13
  102. package/transfer/transfer-list.component.d.ts +15 -15
  103. package/transfer/transfer.component.d.ts +20 -23
  104. package/tree/tree-abstract.d.ts +5 -5
  105. package/tree/tree-node.component.d.ts +24 -37
  106. package/tree/tree.class.d.ts +4 -4
  107. package/tree/tree.component.d.ts +47 -75
  108. package/tree/tree.service.d.ts +3 -4
  109. package/tree-select/tree-select.component.d.ts +2 -2
  110. package/vote/vote.component.d.ts +13 -33
@@ -1,6 +1,6 @@
1
1
  import { NgClass, CommonModule } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { HostBinding, Input, ViewEncapsulation, Component, ChangeDetectionStrategy, inject, ElementRef, Renderer2, NgModule } from '@angular/core';
3
+ import { input, effect, ViewEncapsulation, Component, computed, ChangeDetectionStrategy, inject, ElementRef, Renderer2, afterNextRender, NgModule } from '@angular/core';
4
4
  import { ThyIcon, ThyIconModule } from 'ngx-tethys/icon';
5
5
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
6
6
  import { useHostRenderer } from '@tethys/cdk/dom';
@@ -18,78 +18,56 @@ const buttonGroupSizeMap = {
18
18
  * @order 30
19
19
  */
20
20
  class ThyButtonGroup {
21
- /**
22
- * 大小
23
- * @type xs | sm | md | lg
24
- * @default md
25
- */
26
- set thySize(size) {
27
- this.size = size;
28
- if (this.initialized) {
29
- this.setClasses();
30
- }
31
- }
32
- /**
33
- * 类型
34
- * @type outline-default | outline-primary
35
- * @default outline-default
36
- */
37
- set thyType(type) {
38
- this.type = type;
39
- if (this.initialized) {
40
- this.setClasses();
41
- }
42
- }
43
- /**
44
- * 是否需要最小宽度,默认按钮最小宽度为80px
45
- * @default false
46
- */
47
- set thyClearMinWidth(value) {
48
- this.thyClearMinWidthClassName = coerceBooleanProperty(value);
49
- }
50
21
  constructor() {
51
- this.initialized = false;
52
22
  this.hostRenderer = useHostRenderer();
53
- this._isButtonGroup = true;
54
- this.thyClearMinWidthClassName = false;
55
- }
56
- ngOnInit() {
57
- this.setClasses();
58
- this.initialized = true;
23
+ /**
24
+ * 大小
25
+ * @type xs | sm | md | lg
26
+ * @default md
27
+ */
28
+ this.thySize = input();
29
+ /**
30
+ * 类型
31
+ * @type outline-default | outline-primary
32
+ * @default outline-default
33
+ */
34
+ this.thyType = input();
35
+ /**
36
+ * 是否需要最小宽度,默认按钮最小宽度为80px
37
+ * @default false
38
+ */
39
+ this.thyClearMinWidth = input(false, { transform: coerceBooleanProperty });
40
+ effect(() => {
41
+ this.setClasses();
42
+ });
59
43
  }
60
44
  setClasses() {
45
+ const type = this.thyType();
46
+ const size = this.thySize();
61
47
  let classNames = [];
62
- if (this.type) {
63
- classNames.push(`btn-group-${this.type}`);
48
+ if (type) {
49
+ classNames.push(`btn-group-${type}`);
64
50
  }
65
- if (buttonGroupSizeMap[this.size]) {
66
- classNames.push(buttonGroupSizeMap[this.size]);
51
+ if (buttonGroupSizeMap[size]) {
52
+ classNames = classNames.concat(...buttonGroupSizeMap[size]);
67
53
  }
68
54
  this.hostRenderer.updateClass(classNames);
69
55
  }
70
56
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButtonGroup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
71
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: ThyButtonGroup, isStandalone: true, selector: "thy-button-group", inputs: { thySize: "thySize", thyType: "thyType", thyClearMinWidth: "thyClearMinWidth" }, host: { properties: { "class.btn-group": "this._isButtonGroup", "class.btn-group-clear-min-width": "this.thyClearMinWidthClassName" } }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, encapsulation: i0.ViewEncapsulation.None }); }
57
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.8", type: ThyButtonGroup, isStandalone: true, selector: "thy-button-group", inputs: { thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyType: { classPropertyName: "thyType", publicName: "thyType", isSignal: true, isRequired: false, transformFunction: null }, thyClearMinWidth: { classPropertyName: "thyClearMinWidth", publicName: "thyClearMinWidth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.btn-group-clear-min-width": "thyClearMinWidth()" }, classAttribute: "btn-group" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, encapsulation: i0.ViewEncapsulation.None }); }
72
58
  }
73
59
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButtonGroup, decorators: [{
74
60
  type: Component,
75
61
  args: [{
76
62
  selector: 'thy-button-group',
77
63
  template: '<ng-content></ng-content>',
64
+ host: {
65
+ class: 'btn-group',
66
+ '[class.btn-group-clear-min-width]': 'thyClearMinWidth()'
67
+ },
78
68
  encapsulation: ViewEncapsulation.None
79
69
  }]
80
- }], ctorParameters: () => [], propDecorators: { thySize: [{
81
- type: Input
82
- }], thyType: [{
83
- type: Input
84
- }], thyClearMinWidth: [{
85
- type: Input
86
- }], _isButtonGroup: [{
87
- type: HostBinding,
88
- args: ['class.btn-group']
89
- }], thyClearMinWidthClassName: [{
90
- type: HostBinding,
91
- args: [`class.btn-group-clear-min-width`]
92
- }] } });
70
+ }], ctorParameters: () => [] });
93
71
 
94
72
  const sizeClassesMap = {
95
73
  lg: ['btn-icon-lg'],
@@ -113,143 +91,97 @@ const themeClassesMap = {
113
91
  * @order 20
114
92
  */
115
93
  class ThyButtonIcon {
116
- /**
117
- * 大小
118
- * @type xs | sm | md | lg
119
- * @default 36px
120
- */
121
- set thySize(size) {
122
- this.size = size;
123
- this.setClasses();
124
- }
125
- /**
126
- * 图标, 和`thyButtonIcon`相同,当使用`thy-button-icon`时,只能使用 thyIcon 设置图标
127
- */
128
- set thyIcon(icon) {
129
- this.setIconClass(icon);
130
- }
131
- /**
132
- * 图标按钮的图标
133
- */
134
- set thyButtonIcon(icon) {
135
- this.setIconClass(icon);
136
- }
137
- /**
138
- * 展示的形状,默认只显示字体图标图标,circle-dashed, circle-solid 展示成虚线,实线边框圆形图标, circle-thick-dashed, circle-thick-solid 边框加粗
139
- */
140
- set thyShape(value) {
141
- this.shape = value;
142
- this.setClasses();
143
- }
144
- /**
145
- * 亮色,颜色更浅,适合左侧导航顶部的按钮
146
- * @default false
147
- */
148
- set thyLight(value) {
149
- this._isLighted = value;
150
- }
151
- /**
152
- * 设置为选中状态
153
- * @default false
154
- */
155
- set thyActive(value) {
156
- this._isActive = value;
157
- }
158
- /**
159
- * 按钮展示类型,默认图标移上去显示主色, danger-weak 鼠标移上去显示 danger 红色
160
- */
161
- set thyTheme(value) {
162
- this.theme = value;
163
- this.setClasses();
164
- }
165
94
  constructor() {
166
- this.initialized = false;
95
+ /**
96
+ * 大小
97
+ * @type xs | sm | md | lg
98
+ * @default 36px
99
+ */
100
+ this.thySize = input();
101
+ /**
102
+ * 图标, 和`thyButtonIcon`相同,当使用`thy-button-icon`时,只能使用 thyIcon 设置图标
103
+ */
104
+ this.thyIcon = input();
105
+ /**
106
+ * 图标按钮的图标
107
+ */
108
+ this.thyButtonIcon = input();
109
+ /**
110
+ * 展示的形状,默认只显示字体图标图标,circle-dashed, circle-solid 展示成虚线,实线边框圆形图标, circle-thick-dashed, circle-thick-solid 边框加粗
111
+ */
112
+ this.thyShape = input();
113
+ /**
114
+ * 亮色,颜色更浅,适合左侧导航顶部的按钮
115
+ * @default false
116
+ */
117
+ this.thyLight = input(false, { transform: coerceBooleanProperty$1 });
118
+ /**
119
+ * 设置为选中状态
120
+ * @default false
121
+ */
122
+ this.thyActive = input(false, { transform: coerceBooleanProperty$1 });
123
+ /**
124
+ * 按钮展示类型,默认图标移上去显示主色, danger-weak 鼠标移上去显示 danger 红色
125
+ */
126
+ this.thyTheme = input();
127
+ this.thyColor = input();
167
128
  this.hostRenderer = useHostRenderer();
168
- this.iconPrefix = 'wtf';
169
- this._isBtn = true;
170
- this._isBtnIcon = true;
171
- this._isLighted = false;
172
- this._isActive = false;
173
- }
174
- setIconClass(icon) {
175
- if (icon) {
176
- if (icon.includes('wtf')) {
129
+ this.icon = computed(() => {
130
+ return this.thyButtonIcon() || this.thyIcon();
131
+ });
132
+ this.isWtfIcon = computed(() => {
133
+ const icon = this.icon();
134
+ return icon && icon.includes('wtf');
135
+ });
136
+ this.svgIconName = computed(() => {
137
+ if (!this.isWtfIcon()) {
138
+ return this.icon();
139
+ }
140
+ return null;
141
+ });
142
+ this.iconClasses = computed(() => {
143
+ const icon = this.icon();
144
+ if (this.isWtfIcon()) {
177
145
  const classes = icon.split(' ');
178
146
  if (classes.length === 1) {
179
147
  classes.unshift('wtf');
180
148
  }
181
- this.iconClasses = classes;
182
- this.svgIconName = null;
183
- }
184
- else {
185
- this.svgIconName = icon;
149
+ return classes;
186
150
  }
187
- }
188
- else {
189
- this.iconClasses = null;
190
- this.svgIconName = null;
191
- }
151
+ return null;
152
+ });
153
+ effect(() => {
154
+ this.setClasses();
155
+ });
192
156
  }
193
- setClasses(first = false) {
194
- // 设置样式判断是否已经初始化,未初始化直接返回,除非是初次调用
195
- // 只有 ngOnInit 调用会传入 first = true
196
- if (!first && !this.initialized) {
197
- return;
198
- }
199
- const classes = sizeClassesMap[this.size] ? [...sizeClassesMap[this.size]] : [];
200
- if (this.shape && shapeClassesMap[this.shape]) {
201
- shapeClassesMap[this.shape].forEach((className) => {
157
+ setClasses() {
158
+ const size = this.thySize();
159
+ const shape = this.thyShape();
160
+ const theme = this.thyTheme();
161
+ const classes = sizeClassesMap[size] ? [...sizeClassesMap[size]] : [];
162
+ if (shape && shapeClassesMap[shape]) {
163
+ shapeClassesMap[shape].forEach((className) => {
202
164
  classes.push(className);
203
165
  });
204
166
  }
205
- if (this.theme && themeClassesMap[this.theme]) {
206
- themeClassesMap[this.theme].forEach((className) => {
167
+ if (theme && themeClassesMap[theme]) {
168
+ themeClassesMap[theme].forEach((className) => {
207
169
  classes.push(className);
208
170
  });
209
171
  }
210
172
  this.hostRenderer.updateClass(classes);
211
173
  }
212
- ngOnInit() {
213
- this.setClasses(true);
214
- this.initialized = true;
215
- }
216
174
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButtonIcon, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
217
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyButtonIcon, isStandalone: true, selector: "thy-button-icon,[thy-button-icon],[thyButtonIcon]", inputs: { thySize: "thySize", thyIcon: "thyIcon", thyButtonIcon: "thyButtonIcon", thyShape: "thyShape", thyLight: ["thyLight", "thyLight", coerceBooleanProperty$1], thyActive: ["thyActive", "thyActive", coerceBooleanProperty$1], thyTheme: "thyTheme", thyColor: "thyColor" }, host: { properties: { "class.btn": "this._isBtn", "class.btn-icon": "this._isBtnIcon", "class.btn-icon-light": "this._isLighted", "class.btn-icon-active": "this._isActive" } }, ngImport: i0, template: "@if (svgIconName) {\n <thy-icon [thyIconName]=\"svgIconName\" [style.color]=\"thyColor\" [style.borderColor]=\"thyColor\"></thy-icon>\n} @else {\n @if (iconClasses) {\n <i [ngClass]=\"iconClasses\" [style.color]=\"thyColor\" [style.borderColor]=\"thyColor\"></i>\n }\n}\n<ng-content></ng-content>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
175
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyButtonIcon, isStandalone: true, selector: "thy-button-icon,[thy-button-icon],[thyButtonIcon]", inputs: { thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyIcon: { classPropertyName: "thyIcon", publicName: "thyIcon", isSignal: true, isRequired: false, transformFunction: null }, thyButtonIcon: { classPropertyName: "thyButtonIcon", publicName: "thyButtonIcon", isSignal: true, isRequired: false, transformFunction: null }, thyShape: { classPropertyName: "thyShape", publicName: "thyShape", isSignal: true, isRequired: false, transformFunction: null }, thyLight: { classPropertyName: "thyLight", publicName: "thyLight", isSignal: true, isRequired: false, transformFunction: null }, thyActive: { classPropertyName: "thyActive", publicName: "thyActive", isSignal: true, isRequired: false, transformFunction: null }, thyTheme: { classPropertyName: "thyTheme", publicName: "thyTheme", isSignal: true, isRequired: false, transformFunction: null }, thyColor: { classPropertyName: "thyColor", publicName: "thyColor", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.btn-icon-light": "thyLight()", "class.btn-icon-active": "thyActive()" }, classAttribute: "btn btn-icon" }, ngImport: i0, template: "@if (svgIconName()) {\n <thy-icon [thyIconName]=\"svgIconName()\" [style.color]=\"thyColor()\" [style.borderColor]=\"thyColor()\"></thy-icon>\n} @else {\n @if (iconClasses()) {\n <i [ngClass]=\"iconClasses()\" [style.color]=\"thyColor()\" [style.borderColor]=\"thyColor()\"></i>\n }\n}\n<ng-content></ng-content>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
218
176
  }
219
177
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButtonIcon, decorators: [{
220
178
  type: Component,
221
- args: [{ selector: 'thy-button-icon,[thy-button-icon],[thyButtonIcon]', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ThyIcon, NgClass], template: "@if (svgIconName) {\n <thy-icon [thyIconName]=\"svgIconName\" [style.color]=\"thyColor\" [style.borderColor]=\"thyColor\"></thy-icon>\n} @else {\n @if (iconClasses) {\n <i [ngClass]=\"iconClasses\" [style.color]=\"thyColor\" [style.borderColor]=\"thyColor\"></i>\n }\n}\n<ng-content></ng-content>\n" }]
222
- }], ctorParameters: () => [], propDecorators: { thySize: [{
223
- type: Input
224
- }], thyIcon: [{
225
- type: Input
226
- }], thyButtonIcon: [{
227
- type: Input
228
- }], thyShape: [{
229
- type: Input
230
- }], thyLight: [{
231
- type: Input,
232
- args: [{ transform: coerceBooleanProperty$1 }]
233
- }], thyActive: [{
234
- type: Input,
235
- args: [{ transform: coerceBooleanProperty$1 }]
236
- }], thyTheme: [{
237
- type: Input
238
- }], _isBtn: [{
239
- type: HostBinding,
240
- args: ['class.btn']
241
- }], _isBtnIcon: [{
242
- type: HostBinding,
243
- args: ['class.btn-icon']
244
- }], _isLighted: [{
245
- type: HostBinding,
246
- args: ['class.btn-icon-light']
247
- }], _isActive: [{
248
- type: HostBinding,
249
- args: ['class.btn-icon-active']
250
- }], thyColor: [{
251
- type: Input
252
- }] } });
179
+ args: [{ selector: 'thy-button-icon,[thy-button-icon],[thyButtonIcon]', encapsulation: ViewEncapsulation.None, host: {
180
+ class: 'btn btn-icon',
181
+ '[class.btn-icon-light]': 'thyLight()',
182
+ '[class.btn-icon-active]': 'thyActive()'
183
+ }, changeDetection: ChangeDetectionStrategy.OnPush, imports: [ThyIcon, NgClass], template: "@if (svgIconName()) {\n <thy-icon [thyIconName]=\"svgIconName()\" [style.color]=\"thyColor()\" [style.borderColor]=\"thyColor()\"></thy-icon>\n} @else {\n @if (iconClasses()) {\n <i [ngClass]=\"iconClasses()\" [style.color]=\"thyColor()\" [style.borderColor]=\"thyColor()\"></i>\n }\n}\n<ng-content></ng-content>\n" }]
184
+ }], ctorParameters: () => [] });
253
185
 
254
186
  const btnTypeClassesMap = {
255
187
  primary: ['btn-primary'],
@@ -273,153 +205,142 @@ const iconOnlyClass = 'thy-btn-icon-only';
273
205
  * @order 10
274
206
  */
275
207
  class ThyButton {
276
- constructor() {
277
- this.elementRef = inject(ElementRef);
278
- this.renderer = inject(Renderer2);
279
- this._initialized = false;
280
- // 圆角方形
281
- this._isRadiusSquare = false;
282
- this.hostRenderer = useHostRenderer();
283
- }
284
208
  get nativeElement() {
285
209
  return this.elementRef.nativeElement;
286
210
  }
287
- /**
288
- * 按钮类型,支持添加前缀`outline-`实现线框按钮,支持添加前缀`link-`实现按钮链接
289
- * @type primary | info | warning | danger | success
290
- * @default primary
291
- */
292
- set thyButton(value) {
293
- this.setBtnType(value);
294
- }
295
- /**
296
- * 和`thyButton`参数一样,一般使用`thyButton`,为了减少参数输入, 当通过`thy-button`使用时,只能使用该参数控制类型
297
- * @default primary
298
- */
299
- set thyType(value) {
300
- this.setBtnType(value);
301
- }
302
- /**
303
- * 加载状态
304
- * @default false
305
- */
306
- set thyLoading(value) {
307
- if (!this._loading && value) {
308
- this._loading = value;
309
- const textElement = this.nativeElement.querySelector('span');
310
- this._originalText = textElement ? textElement.innerText : '';
311
- this.setLoadingStatus();
312
- }
313
- else {
314
- this._loading = value;
315
- this.setLoadingStatus();
316
- }
317
- }
318
- /**
319
- * 加载状态时显示的文案
320
- */
321
- set thyLoadingText(value) {
322
- if (this._loadingText !== value) {
323
- this._loadingText = value;
324
- if (this._loading) {
325
- this.setLoadingText(this._loadingText);
326
- }
327
- }
328
- }
329
- /**
330
- * 按钮大小
331
- * @type xs | sm | md | default | lg
332
- * @default default
333
- */
334
- set thySize(size) {
335
- this._size = size;
336
- if (this._initialized) {
337
- this.updateClasses();
338
- }
339
- }
340
- /**
341
- * 按钮中显示的图标,支持SVG图标名称,比如`angle-left`,也支持传之前的 wtf 字体,比如: wtf-plus
342
- */
343
- set thyIcon(icon) {
344
- this._icon = icon;
345
- if (this._icon) {
346
- if (icon.includes('wtf')) {
347
- const classes = this._icon.split(' ');
348
- if (classes.length === 1) {
349
- classes.unshift('wtf');
350
- }
351
- this.iconClass = classes;
352
- this.svgIconName = null;
353
- }
354
- else {
355
- this.svgIconName = icon;
356
- }
357
- }
358
- else {
359
- this.iconClass = null;
360
- this.svgIconName = null;
361
- }
362
- }
363
- setBtnType(value) {
364
- if (value) {
365
- if (value.includes('-square')) {
366
- this._type = value.replace('-square', '');
367
- this._isRadiusSquare = true;
368
- }
369
- else {
370
- this._type = value;
371
- }
372
- if (this._initialized) {
373
- this.updateClasses();
374
- }
375
- }
376
- }
377
- setLoadingText(text) {
211
+ setButtonText() {
212
+ const text = this.thyLoading() ? this.thyLoadingText() : this._originalText;
378
213
  const spanElement = this.nativeElement.querySelector('span');
379
- if (spanElement) {
214
+ if (spanElement && text) {
380
215
  this.renderer.setProperty(spanElement, 'innerText', text);
381
216
  }
382
217
  }
383
- setLoadingStatus() {
384
- const innerText = this._loading ? this._loadingText : this._originalText;
385
- this.updateClasses();
386
- if (innerText) {
387
- this.setLoadingText(innerText);
388
- }
389
- }
390
218
  updateClasses() {
219
+ const type = this.type();
220
+ if (!type) {
221
+ return;
222
+ }
391
223
  let classNames = [];
392
- if (btnTypeClassesMap[this._type]) {
393
- classNames = [...btnTypeClassesMap[this._type]];
224
+ if (btnTypeClassesMap[type]) {
225
+ classNames = [...btnTypeClassesMap[type]];
394
226
  }
395
227
  else {
396
- if (this._type) {
397
- classNames.push(`btn-${this._type}`);
228
+ if (type) {
229
+ classNames.push(`btn-${type}`);
398
230
  }
399
231
  }
400
- if (this._size) {
401
- classNames.push(`btn-${this._size}`);
232
+ const size = this.thySize();
233
+ if (size) {
234
+ classNames.push(`btn-${size}`);
402
235
  }
403
- if (this._isRadiusSquare) {
236
+ if (this.isRadiusSquare()) {
404
237
  classNames.push('btn-square');
405
238
  }
406
- if (this._loading) {
239
+ const loading = this.thyLoading();
240
+ if (loading) {
407
241
  classNames.push('loading');
408
242
  }
409
243
  this.hostRenderer.updateClass(classNames);
410
244
  }
411
- ngOnInit() {
412
- this.updateClasses();
413
- this._initialized = true;
414
- }
415
- ngAfterViewInit() {
416
- if (assertIconOnly(this.nativeElement)) {
417
- this.hostRenderer.addClass(iconOnlyClass);
418
- }
419
- else {
420
- this.hostRenderer.removeClass(iconOnlyClass);
421
- }
422
- this.wrapSpanForText(this.nativeElement.childNodes);
245
+ constructor() {
246
+ this.elementRef = inject(ElementRef);
247
+ this.renderer = inject(Renderer2);
248
+ this.hostRenderer = useHostRenderer();
249
+ /**
250
+ * 按钮类型,支持添加前缀`outline-`实现线框按钮,支持添加前缀`link-`实现按钮链接
251
+ * @type primary | info | warning | danger | success
252
+ * @default primary
253
+ */
254
+ this.thyButton = input();
255
+ /**
256
+ * 和`thyButton`参数一样,一般使用`thyButton`,为了减少参数输入, 当通过`thy-button`使用时,只能使用该参数控制类型
257
+ * @default primary
258
+ */
259
+ this.thyType = input();
260
+ /**
261
+ * 加载状态
262
+ * @default false
263
+ */
264
+ this.thyLoading = input(false, {
265
+ transform: value => {
266
+ if (!this.thyLoading() && value) {
267
+ const textElement = this.nativeElement?.querySelector('span');
268
+ this._originalText = textElement ? textElement.innerText : '';
269
+ }
270
+ return coerceBooleanProperty$1(value);
271
+ }
272
+ });
273
+ /**
274
+ * 加载状态时显示的文案
275
+ */
276
+ this.thyLoadingText = input();
277
+ /**
278
+ * 按钮大小
279
+ * @type xs | sm | md | default | lg
280
+ * @default default
281
+ */
282
+ this.thySize = input();
283
+ /**
284
+ * 按钮中显示的图标,支持SVG图标名称,比如`angle-left`,也支持传之前的 wtf 字体,比如: wtf-plus
285
+ */
286
+ this.thyIcon = input();
287
+ /**
288
+ * 按钮整块展示
289
+ * @default false
290
+ */
291
+ this.thyBlock = input(false, { transform: coerceBooleanProperty$1 });
292
+ this.isWtfIcon = computed(() => {
293
+ const icon = this.thyIcon();
294
+ return icon && icon.includes('wtf');
295
+ });
296
+ this.svgIconName = computed(() => {
297
+ if (!this.isWtfIcon()) {
298
+ return this.thyIcon();
299
+ }
300
+ return null;
301
+ });
302
+ this.iconClass = computed(() => {
303
+ const icon = this.thyIcon();
304
+ if (this.isWtfIcon()) {
305
+ const classes = icon.split(' ');
306
+ if (classes.length === 1) {
307
+ classes.unshift('wtf');
308
+ }
309
+ return classes;
310
+ }
311
+ return null;
312
+ });
313
+ this.buttonType = computed(() => {
314
+ return this.thyButton() || this.thyType();
315
+ });
316
+ this.isRadiusSquare = computed(() => {
317
+ const type = this.buttonType();
318
+ return !!type?.includes('-square');
319
+ });
320
+ this.type = computed(() => {
321
+ const type = this.buttonType();
322
+ if (this.isRadiusSquare()) {
323
+ return type.replace('-square', '');
324
+ }
325
+ else {
326
+ return type;
327
+ }
328
+ });
329
+ effect(() => {
330
+ this.updateClasses();
331
+ });
332
+ effect(() => {
333
+ this.setButtonText();
334
+ });
335
+ afterNextRender(() => {
336
+ if (assertIconOnly(this.nativeElement)) {
337
+ this.hostRenderer.addClass(iconOnlyClass);
338
+ }
339
+ else {
340
+ this.hostRenderer.removeClass(iconOnlyClass);
341
+ }
342
+ this.wrapSpanForText(this.nativeElement.childNodes);
343
+ });
423
344
  }
424
345
  wrapSpanForText(nodes) {
425
346
  nodes.forEach(node => {
@@ -433,33 +354,15 @@ class ThyButton {
433
354
  });
434
355
  }
435
356
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButton, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
436
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyButton, isStandalone: true, selector: "thy-button,[thy-button],[thyButton]", inputs: { thyButton: "thyButton", thyType: "thyType", thyLoading: ["thyLoading", "thyLoading", coerceBooleanProperty$1], thyLoadingText: "thyLoadingText", thySize: "thySize", thyIcon: "thyIcon", thyBlock: ["thyBlock", "thyBlock", coerceBooleanProperty$1] }, host: { properties: { "class.btn-block": "this.thyBlock" }, classAttribute: "thy-btn btn" }, ngImport: i0, template: "@if (svgIconName) {\n <thy-icon [thyIconName]=\"svgIconName\"></thy-icon>\n} @else {\n @if (iconClass) {\n <i [ngClass]=\"iconClass\"></i>\n }\n}\n<ng-content></ng-content>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
357
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyButton, isStandalone: true, selector: "thy-button,[thy-button],[thyButton]", inputs: { thyButton: { classPropertyName: "thyButton", publicName: "thyButton", isSignal: true, isRequired: false, transformFunction: null }, thyType: { classPropertyName: "thyType", publicName: "thyType", isSignal: true, isRequired: false, transformFunction: null }, thyLoading: { classPropertyName: "thyLoading", publicName: "thyLoading", isSignal: true, isRequired: false, transformFunction: null }, thyLoadingText: { classPropertyName: "thyLoadingText", publicName: "thyLoadingText", isSignal: true, isRequired: false, transformFunction: null }, thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyIcon: { classPropertyName: "thyIcon", publicName: "thyIcon", isSignal: true, isRequired: false, transformFunction: null }, thyBlock: { classPropertyName: "thyBlock", publicName: "thyBlock", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.btn-block": "thyBlock()" }, classAttribute: "thy-btn btn" }, ngImport: i0, template: "@if (svgIconName()) {\n <thy-icon [thyIconName]=\"svgIconName()\"></thy-icon>\n} @else {\n @if (iconClass()) {\n <i [ngClass]=\"iconClass()\"></i>\n }\n}\n<ng-content></ng-content>\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
437
358
  }
438
359
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButton, decorators: [{
439
360
  type: Component,
440
361
  args: [{ selector: 'thy-button,[thy-button],[thyButton]', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
441
- class: 'thy-btn btn'
442
- }, imports: [ThyIcon, NgClass], template: "@if (svgIconName) {\n <thy-icon [thyIconName]=\"svgIconName\"></thy-icon>\n} @else {\n @if (iconClass) {\n <i [ngClass]=\"iconClass\"></i>\n }\n}\n<ng-content></ng-content>\n" }]
443
- }], propDecorators: { thyButton: [{
444
- type: Input
445
- }], thyType: [{
446
- type: Input
447
- }], thyLoading: [{
448
- type: Input,
449
- args: [{ transform: coerceBooleanProperty$1 }]
450
- }], thyLoadingText: [{
451
- type: Input
452
- }], thySize: [{
453
- type: Input
454
- }], thyIcon: [{
455
- type: Input
456
- }], thyBlock: [{
457
- type: HostBinding,
458
- args: [`class.btn-block`]
459
- }, {
460
- type: Input,
461
- args: [{ transform: coerceBooleanProperty$1 }]
462
- }] } });
362
+ class: 'thy-btn btn',
363
+ '[class.btn-block]': 'thyBlock()'
364
+ }, imports: [ThyIcon, NgClass], template: "@if (svgIconName()) {\n <thy-icon [thyIconName]=\"svgIconName()\"></thy-icon>\n} @else {\n @if (iconClass()) {\n <i [ngClass]=\"iconClass()\"></i>\n }\n}\n<ng-content></ng-content>\n" }]
365
+ }], ctorParameters: () => [] });
463
366
 
464
367
  class ThyButtonModule {
465
368
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }