raise-common-lib 0.0.205 → 0.0.206
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/bundles/raise-common-lib.umd.js +204 -10
- package/bundles/raise-common-lib.umd.js.map +1 -1
- package/bundles/raise-common-lib.umd.min.js +1 -1
- package/bundles/raise-common-lib.umd.min.js.map +1 -1
- package/esm2015/lib/layout/rs-stepper/index.component.js +175 -9
- package/esm5/lib/layout/rs-stepper/index.component.js +206 -12
- package/fesm2015/raise-common-lib.js +173 -7
- package/fesm2015/raise-common-lib.js.map +1 -1
- package/fesm5/raise-common-lib.js +204 -10
- package/fesm5/raise-common-lib.js.map +1 -1
- package/lib/layout/rs-stepper/index.component.d.ts +17 -4
- package/package.json +1 -1
- package/raise-common-lib.metadata.json +1 -1
|
@@ -21027,15 +21027,19 @@ if (false) {
|
|
|
21027
21027
|
class RSStepperComponent {
|
|
21028
21028
|
/**
|
|
21029
21029
|
* @param {?} cf
|
|
21030
|
+
* @param {?} ref
|
|
21030
21031
|
*/
|
|
21031
|
-
constructor(cf) {
|
|
21032
|
+
constructor(cf, ref) {
|
|
21032
21033
|
this.cf = cf;
|
|
21034
|
+
this.ref = ref;
|
|
21033
21035
|
this.steps = [];
|
|
21034
21036
|
this.currentStep = 0;
|
|
21035
21037
|
this.stepClick = new EventEmitter();
|
|
21036
21038
|
this.unlockedStep = 0; //已解锁的最大步骤
|
|
21039
|
+
this.showBtn = false;
|
|
21040
|
+
this.isAtStart = true;
|
|
21041
|
+
this.isAtEnd = false;
|
|
21037
21042
|
}
|
|
21038
|
-
//已解锁的最大步骤
|
|
21039
21043
|
/**
|
|
21040
21044
|
* @return {?}
|
|
21041
21045
|
*/
|
|
@@ -21049,6 +21053,15 @@ class RSStepperComponent {
|
|
|
21049
21053
|
}));
|
|
21050
21054
|
this.syncUnlockedStep();
|
|
21051
21055
|
}
|
|
21056
|
+
/**
|
|
21057
|
+
* @return {?}
|
|
21058
|
+
*/
|
|
21059
|
+
ngAfterViewInit() {
|
|
21060
|
+
setTimeout((/**
|
|
21061
|
+
* @return {?}
|
|
21062
|
+
*/
|
|
21063
|
+
() => this.checkBtnShow(true)));
|
|
21064
|
+
}
|
|
21052
21065
|
/**
|
|
21053
21066
|
* @param {?} changes
|
|
21054
21067
|
* @return {?}
|
|
@@ -21056,6 +21069,18 @@ class RSStepperComponent {
|
|
|
21056
21069
|
ngOnChanges(changes) {
|
|
21057
21070
|
if (changes["currentStep"] && !changes["currentStep"].firstChange) {
|
|
21058
21071
|
this.syncUnlockedStep();
|
|
21072
|
+
// 当外部传入的 currentStep 变化时,滚动到对应步骤
|
|
21073
|
+
setTimeout((/**
|
|
21074
|
+
* @return {?}
|
|
21075
|
+
*/
|
|
21076
|
+
() => this.scrollToStep()));
|
|
21077
|
+
}
|
|
21078
|
+
if ((changes["steps"] && changes["steps"].currentValue) ||
|
|
21079
|
+
changes["currentStep"]) {
|
|
21080
|
+
setTimeout((/**
|
|
21081
|
+
* @return {?}
|
|
21082
|
+
*/
|
|
21083
|
+
() => this.checkBtnShow()));
|
|
21059
21084
|
}
|
|
21060
21085
|
}
|
|
21061
21086
|
// 同步unlockedStep的最大值
|
|
@@ -21070,33 +21095,161 @@ class RSStepperComponent {
|
|
|
21070
21095
|
}
|
|
21071
21096
|
/**
|
|
21072
21097
|
* @param {?} step
|
|
21098
|
+
* @param {?=} index
|
|
21073
21099
|
* @return {?}
|
|
21074
21100
|
*/
|
|
21075
|
-
onStepClick(step) {
|
|
21101
|
+
onStepClick(step, index) {
|
|
21076
21102
|
if (step.step <= this.unlockedStep) {
|
|
21077
21103
|
this.currentStep = step.step;
|
|
21078
21104
|
this.stepClick.emit(step);
|
|
21105
|
+
setTimeout((/**
|
|
21106
|
+
* @return {?}
|
|
21107
|
+
*/
|
|
21108
|
+
() => this.scrollToStep(index)));
|
|
21109
|
+
}
|
|
21110
|
+
}
|
|
21111
|
+
/**
|
|
21112
|
+
* @private
|
|
21113
|
+
* @param {?=} index
|
|
21114
|
+
* @return {?}
|
|
21115
|
+
*/
|
|
21116
|
+
scrollToStep(index) {
|
|
21117
|
+
if (!this.menu || !this.menu.nativeElement)
|
|
21118
|
+
return;
|
|
21119
|
+
/** @type {?} */
|
|
21120
|
+
const menuEl = this.menu.nativeElement;
|
|
21121
|
+
/** @type {?} */
|
|
21122
|
+
const items = menuEl.querySelectorAll(".step");
|
|
21123
|
+
/** @type {?} */
|
|
21124
|
+
const targetIndex = typeof index === "number"
|
|
21125
|
+
? index
|
|
21126
|
+
: this.steps.findIndex((/**
|
|
21127
|
+
* @param {?} s
|
|
21128
|
+
* @return {?}
|
|
21129
|
+
*/
|
|
21130
|
+
(s) => s.step === this.currentStep));
|
|
21131
|
+
if (targetIndex < 0 || targetIndex >= items.length)
|
|
21132
|
+
return;
|
|
21133
|
+
/** @type {?} */
|
|
21134
|
+
const targetEl = (/** @type {?} */ (items[targetIndex]));
|
|
21135
|
+
//获取相对位置
|
|
21136
|
+
/** @type {?} */
|
|
21137
|
+
const containerRect = menuEl.getBoundingClientRect();
|
|
21138
|
+
/** @type {?} */
|
|
21139
|
+
const elementRect = targetEl.getBoundingClientRect();
|
|
21140
|
+
// 计算元素相对于容器的位置
|
|
21141
|
+
/** @type {?} */
|
|
21142
|
+
const elementRelativeLeft = elementRect.left - containerRect.left + menuEl.scrollLeft;
|
|
21143
|
+
/** @type {?} */
|
|
21144
|
+
const elementWidth = elementRect.width;
|
|
21145
|
+
/** @type {?} */
|
|
21146
|
+
const containerWidth = menuEl.clientWidth;
|
|
21147
|
+
// 计算元素中心点相对于容器的位置
|
|
21148
|
+
/** @type {?} */
|
|
21149
|
+
const elementCenter = elementRelativeLeft + elementWidth / 2;
|
|
21150
|
+
// 目标滚动位置:让元素中心出现在可视区域中心
|
|
21151
|
+
/** @type {?} */
|
|
21152
|
+
const scrollTarget = elementCenter - containerWidth / 2;
|
|
21153
|
+
// 限制在有效滚动范围内
|
|
21154
|
+
/** @type {?} */
|
|
21155
|
+
const maxScroll = Math.max(0, menuEl.scrollWidth - containerWidth);
|
|
21156
|
+
/** @type {?} */
|
|
21157
|
+
const finalTarget = Math.max(0, Math.min(scrollTarget, maxScroll));
|
|
21158
|
+
menuEl.scrollTo({ left: finalTarget, behavior: "smooth" });
|
|
21159
|
+
this.onScroll();
|
|
21160
|
+
}
|
|
21161
|
+
/**
|
|
21162
|
+
* @param {?} event
|
|
21163
|
+
* @return {?}
|
|
21164
|
+
*/
|
|
21165
|
+
onResize(event) {
|
|
21166
|
+
this.checkBtnShow();
|
|
21167
|
+
}
|
|
21168
|
+
/**
|
|
21169
|
+
* @param {?=} init
|
|
21170
|
+
* @return {?}
|
|
21171
|
+
*/
|
|
21172
|
+
checkBtnShow(init) {
|
|
21173
|
+
if (!this.menu || !this.menu.nativeElement)
|
|
21174
|
+
return;
|
|
21175
|
+
/** @type {?} */
|
|
21176
|
+
const menuEl = this.menu.nativeElement;
|
|
21177
|
+
const { scrollWidth, clientWidth } = menuEl;
|
|
21178
|
+
// 判断是否需要显示滚动按钮
|
|
21179
|
+
/** @type {?} */
|
|
21180
|
+
let threshold = clientWidth;
|
|
21181
|
+
if (this.containerRefId) {
|
|
21182
|
+
/** @type {?} */
|
|
21183
|
+
const containerRef = document.getElementById(this.containerRefId);
|
|
21184
|
+
if (containerRef) {
|
|
21185
|
+
threshold = Math.max(containerRef.offsetWidth * 0.8, 400);
|
|
21186
|
+
}
|
|
21079
21187
|
}
|
|
21188
|
+
this.showBtn = scrollWidth > threshold;
|
|
21189
|
+
// 初始化时滚动到当前步骤
|
|
21190
|
+
if (init) {
|
|
21191
|
+
setTimeout((/**
|
|
21192
|
+
* @return {?}
|
|
21193
|
+
*/
|
|
21194
|
+
() => this.scrollToStep()), 0);
|
|
21195
|
+
}
|
|
21196
|
+
this.onScroll();
|
|
21197
|
+
this.ref.markForCheck();
|
|
21198
|
+
}
|
|
21199
|
+
/**
|
|
21200
|
+
* @return {?}
|
|
21201
|
+
*/
|
|
21202
|
+
scrollLeft() {
|
|
21203
|
+
const { scrollLeft } = this.menu.nativeElement;
|
|
21204
|
+
/** @type {?} */
|
|
21205
|
+
const dis = scrollLeft / 100 < 2 ? scrollLeft + 10 : 100;
|
|
21206
|
+
this.menu.nativeElement.scrollBy({ left: -dis, behavior: "smooth" });
|
|
21207
|
+
}
|
|
21208
|
+
/**
|
|
21209
|
+
* @return {?}
|
|
21210
|
+
*/
|
|
21211
|
+
scrollRight() {
|
|
21212
|
+
const { scrollLeft, scrollWidth, clientWidth } = this.menu.nativeElement;
|
|
21213
|
+
/** @type {?} */
|
|
21214
|
+
const rest = scrollWidth - clientWidth - scrollLeft;
|
|
21215
|
+
/** @type {?} */
|
|
21216
|
+
const dis = rest / 100 < 2 ? rest + 10 : 100;
|
|
21217
|
+
this.menu.nativeElement.scrollBy({ left: dis, behavior: "smooth" });
|
|
21218
|
+
}
|
|
21219
|
+
/**
|
|
21220
|
+
* @return {?}
|
|
21221
|
+
*/
|
|
21222
|
+
onScroll() {
|
|
21223
|
+
const { scrollLeft, scrollWidth, clientWidth } = this.menu.nativeElement;
|
|
21224
|
+
this.isAtStart = scrollLeft <= 1;
|
|
21225
|
+
this.isAtEnd = scrollLeft + clientWidth >= scrollWidth - 1;
|
|
21226
|
+
this.ref.markForCheck();
|
|
21080
21227
|
}
|
|
21081
21228
|
}
|
|
21082
21229
|
RSStepperComponent.decorators = [
|
|
21083
21230
|
{ type: Component, args: [{
|
|
21084
21231
|
selector: "rs-stepper",
|
|
21085
|
-
template: "<div class=\"rs-stepper\">\r\n <div class=\"steps-wrap\">\r\n <ng-container *ngFor=\"let item of steps; let i = index\">\r\n
|
|
21086
|
-
styles: [".rs-stepper{font-family:Arial;width:100%;border-bottom:1px solid var(--rs-border-color)}.rs-stepper .steps-wrap{display:flex;align-items:center;justify-content:
|
|
21232
|
+
template: "<div class=\"rs-stepper\">\r\n <div class=\"steps-wrap\">\r\n <div\r\n class=\"row-btn\"\r\n [class.hidden]=\"isAtStart || !showBtn\"\r\n (click)=\"scrollLeft()\"\r\n >\r\n <div class=\"hover\">\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n width=\"17\"\r\n height=\"16\"\r\n viewBox=\"0 0 17 16\"\r\n fill=\"none\"\r\n >\r\n <path\r\n d=\"M10.4995 3.99955L7.24219 8.24219L10.4995 12.4848\"\r\n stroke=\"#1F7BFF\"\r\n />\r\n </svg>\r\n </div>\r\n <div class=\"normal\">\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n width=\"17\"\r\n height=\"16\"\r\n viewBox=\"0 0 17 16\"\r\n fill=\"none\"\r\n >\r\n <path\r\n d=\"M10.4995 3.99955L7.24219 8.24219L10.4995 12.4848\"\r\n stroke=\"#6B6B6B\"\r\n />\r\n </svg>\r\n </div>\r\n </div>\r\n <div\r\n class=\"steps-content\"\r\n [ngClass]=\"{\r\n leftMask: showBtn && !isAtStart,\r\n rightMask: showBtn && !isAtEnd,\r\n bothMask: showBtn && !isAtStart && showBtn && !isAtEnd\r\n }\"\r\n #menu\r\n (scroll)=\"onScroll()\"\r\n >\r\n <ng-container *ngFor=\"let item of steps; let i = index\">\r\n <div\r\n class=\"step\"\r\n [ngClass]=\"{\r\n done: item.step <= unlockedStep,\r\n active: item.step === currentStep\r\n }\"\r\n (click)=\"onStepClick(item, i)\"\r\n >\r\n <div\r\n class=\"step-label\"\r\n [matTooltip]=\"item.label !== item.displayTitle ? item.label : ''\"\r\n matTooltipPosition=\"above\"\r\n >\r\n {{ item.displayTitle }}\r\n </div>\r\n </div>\r\n <div class=\"step-arrow\" *ngIf=\"i < steps.length - 1\">\r\n <img src=\"/assets/img/step-arrow.svg\" />\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div\r\n class=\"row-btn\"\r\n [class.hidden]=\"isAtEnd || !showBtn\"\r\n (click)=\"scrollRight()\"\r\n >\r\n <div class=\"hover\">\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n width=\"17\"\r\n height=\"16\"\r\n viewBox=\"0 0 17 16\"\r\n fill=\"none\"\r\n >\r\n <path\r\n d=\"M7.50045 3.99955L10.7578 8.24219L7.50045 12.4848\"\r\n stroke=\"#1F7BFF\"\r\n />\r\n </svg>\r\n </div>\r\n <div class=\"normal\">\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n width=\"17\"\r\n height=\"16\"\r\n viewBox=\"0 0 17 16\"\r\n fill=\"none\"\r\n >\r\n <path\r\n d=\"M7.50045 3.99955L10.7578 8.24219L7.50045 12.4848\"\r\n stroke=\"#6B6B6B\"\r\n />\r\n </svg>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n",
|
|
21233
|
+
styles: [".rs-stepper{font-family:Arial;width:100%;border-bottom:1px solid var(--rs-border-color)}.rs-stepper .steps-wrap{display:flex;align-items:center;justify-content:center;gap:12px;margin:0 auto}.rs-stepper .steps-wrap .steps-content{display:flex;align-items:center;flex-wrap:nowrap;min-width:0;overflow-x:auto;overflow-y:hidden;gap:8px}.rs-stepper .steps-wrap .steps-content.leftMask{-webkit-mask-image:linear-gradient(90deg,transparent,#fff 10%,#d8d3d3 100%);mask-image:linear-gradient(90deg,transparent,#fff 10%,#d8d3d3 100%)}.rs-stepper .steps-wrap .steps-content.rightMask{-webkit-mask-image:linear-gradient(90deg,#fff 0,#fff 90%,transparent);mask-image:linear-gradient(90deg,#fff 0,#fff 90%,transparent)}.rs-stepper .steps-wrap .steps-content.bothMask{-webkit-mask-image:linear-gradient(90deg,transparent,#fff 10%,#fff 90%,transparent)!important;mask-image:linear-gradient(90deg,transparent,#fff 10%,#fff 90%,transparent)!important}.rs-stepper .steps-wrap .steps-content::-webkit-scrollbar{width:0;height:0}.rs-stepper .steps-wrap .step{flex:0 0 auto}.rs-stepper .steps-wrap .step .step-label{color:var(--rs-labels-color);font-size:12px;font-weight:400;line-height:22px;text-align:center;white-space:nowrap;padding:0 12px 12px;display:flex;align-items:center}.rs-stepper .steps-wrap .step.done{cursor:pointer}.rs-stepper .steps-wrap .step.done .step-label{color:var(--rs-active-labels-color)}.rs-stepper .steps-wrap .step.active .step-label{color:var(--rs-active-labels-color);font-weight:700;border-bottom:1px solid var(--rs-active-labels-color)}.rs-stepper .steps-wrap .step-arrow{flex:0 0 auto;padding:0 12px 12px;display:flex;align-items:center}.rs-stepper .row-btn{margin-bottom:12px;display:flex;width:20px;height:20px;align-items:center;justify-content:center;border-radius:4px;border:1px solid #bdc4ca;flex-shrink:0;cursor:pointer;visibility:visible}.rs-stepper .row-btn .hover{display:none}.rs-stepper .row-btn .normal{display:flex}.rs-stepper .row-btn:hover{background-color:rgba(31,123,255,.04)}.rs-stepper .row-btn:hover .normal{display:none}.rs-stepper .row-btn:hover .hover{display:flex}.rs-stepper .row-btn.hidden{visibility:hidden}"]
|
|
21087
21234
|
}] }
|
|
21088
21235
|
];
|
|
21089
21236
|
/** @nocollapse */
|
|
21090
21237
|
RSStepperComponent.ctorParameters = () => [
|
|
21091
|
-
{ type: CommonFunctionService }
|
|
21238
|
+
{ type: CommonFunctionService },
|
|
21239
|
+
{ type: ChangeDetectorRef }
|
|
21092
21240
|
];
|
|
21093
21241
|
RSStepperComponent.propDecorators = {
|
|
21242
|
+
menu: [{ type: ViewChild, args: ["menu", { static: false },] }],
|
|
21094
21243
|
steps: [{ type: Input }],
|
|
21095
21244
|
currentStep: [{ type: Input }],
|
|
21096
21245
|
stepClick: [{ type: Output }],
|
|
21097
|
-
unlockedStep: [{ type: Input }]
|
|
21246
|
+
unlockedStep: [{ type: Input }],
|
|
21247
|
+
containerRefId: [{ type: Input }],
|
|
21248
|
+
onResize: [{ type: HostListener, args: ["window:resize", ["$event"],] }]
|
|
21098
21249
|
};
|
|
21099
21250
|
if (false) {
|
|
21251
|
+
/** @type {?} */
|
|
21252
|
+
RSStepperComponent.prototype.menu;
|
|
21100
21253
|
/** @type {?} */
|
|
21101
21254
|
RSStepperComponent.prototype.steps;
|
|
21102
21255
|
/** @type {?} */
|
|
@@ -21106,7 +21259,20 @@ if (false) {
|
|
|
21106
21259
|
/** @type {?} */
|
|
21107
21260
|
RSStepperComponent.prototype.unlockedStep;
|
|
21108
21261
|
/** @type {?} */
|
|
21262
|
+
RSStepperComponent.prototype.containerRefId;
|
|
21263
|
+
/** @type {?} */
|
|
21264
|
+
RSStepperComponent.prototype.showBtn;
|
|
21265
|
+
/** @type {?} */
|
|
21266
|
+
RSStepperComponent.prototype.isAtStart;
|
|
21267
|
+
/** @type {?} */
|
|
21268
|
+
RSStepperComponent.prototype.isAtEnd;
|
|
21269
|
+
/** @type {?} */
|
|
21109
21270
|
RSStepperComponent.prototype.cf;
|
|
21271
|
+
/**
|
|
21272
|
+
* @type {?}
|
|
21273
|
+
* @private
|
|
21274
|
+
*/
|
|
21275
|
+
RSStepperComponent.prototype.ref;
|
|
21110
21276
|
}
|
|
21111
21277
|
|
|
21112
21278
|
/**
|