@edm-sdui/sdui 1.0.24 → 1.0.26
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/esm2022/lib/components/uicomponent/profile-button/profile-button.component.mjs +49 -3
- package/esm2022/lib/core/uitheme/enums/uiasset.mjs +2 -1
- package/esm2022/lib/core/uitheme/mapping/asset-mapping.mjs +2 -1
- package/fesm2022/edm-sdui-sdui.mjs +50 -2
- package/fesm2022/edm-sdui-sdui.mjs.map +1 -1
- package/lib/components/uicomponent/profile-button/profile-button.component.d.ts +1 -0
- package/lib/components/uicomponent/profile-button/profile-button.component.d.ts.map +1 -1
- package/lib/core/uitheme/enums/uiasset.d.ts +1 -0
- package/lib/core/uitheme/enums/uiasset.d.ts.map +1 -1
- package/lib/core/uitheme/mapping/asset-mapping.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -918,6 +918,7 @@ var UIAsset;
|
|
|
918
918
|
UIAsset["IC_DOWNLOAD_PROFILE"] = "ic_download_profile";
|
|
919
919
|
UIAsset["IC_HOUR_PROFILE"] = "ic_hour_profile";
|
|
920
920
|
UIAsset["IC_LINK_GENERIC_PROFILE"] = "ic_link_generic_profile";
|
|
921
|
+
UIAsset["IC_MY_POST_MY_APP"] = "ic_my_post_my_app";
|
|
921
922
|
UIAsset["IC_NOTIFICATION_PROFILE_OFF"] = "ic_notification_profile_off";
|
|
922
923
|
UIAsset["IC_NOTIFICATION_PROFILE_ON"] = "ic_notification_profile_on";
|
|
923
924
|
UIAsset["IC_POST_SAVE_MY_APP"] = "ic_post_save_my_app";
|
|
@@ -1287,6 +1288,7 @@ const assetMapping = {
|
|
|
1287
1288
|
[UIAsset.IC_DOWNLOAD_PROFILE]: 'assets/images/ic-download-profile.svg',
|
|
1288
1289
|
[UIAsset.IC_HOUR_PROFILE]: 'assets/images/ic-hour-profile.svg',
|
|
1289
1290
|
[UIAsset.IC_LINK_GENERIC_PROFILE]: 'assets/images/ic-link-generic-profile.svg',
|
|
1291
|
+
[UIAsset.IC_MY_POST_MY_APP]: 'assets/images/ic-my-post-my-app.svg',
|
|
1290
1292
|
[UIAsset.IC_NOTIFICATION_PROFILE_OFF]: 'assets/images/ic-notification-profile-off.svg',
|
|
1291
1293
|
[UIAsset.IC_NOTIFICATION_PROFILE_ON]: 'assets/images/ic-notification-profile-on.svg',
|
|
1292
1294
|
[UIAsset.IC_POST_SAVE_MY_APP]: 'assets/images/ic-post-save-my-app.svg',
|
|
@@ -3145,6 +3147,8 @@ class ProfileButtonComponent {
|
|
|
3145
3147
|
ngAfterViewInit() {
|
|
3146
3148
|
if (this.uiComponent.element) {
|
|
3147
3149
|
this.applyElement(this.uiComponent.element);
|
|
3150
|
+
// esperar o layout para medir o texto já com estilos aplicados
|
|
3151
|
+
setTimeout(() => this.fitLabelToTwoLines(), 0);
|
|
3148
3152
|
}
|
|
3149
3153
|
}
|
|
3150
3154
|
applyElement(element) {
|
|
@@ -3160,15 +3164,59 @@ class ProfileButtonComponent {
|
|
|
3160
3164
|
this.renderer.setStyle(this.profileButtonLabelElementRef.nativeElement, 'font-size', this.fontSizeMappingService.getMapping()[UITextStyle.CAPTION_2]);
|
|
3161
3165
|
this.renderer.setStyle(this.profileButtonLabelElementRef.nativeElement, 'color', colorMapping[UIColor.MAIN1]);
|
|
3162
3166
|
}
|
|
3167
|
+
fitLabelToTwoLines(maxLines = 2, minFontSizePx = 10) {
|
|
3168
|
+
if (typeof window === 'undefined') {
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const labelElement = this.profileButtonLabelElementRef?.nativeElement;
|
|
3172
|
+
if (!labelElement) {
|
|
3173
|
+
return;
|
|
3174
|
+
}
|
|
3175
|
+
const computedStyles = window.getComputedStyle(labelElement);
|
|
3176
|
+
let fontSize = parseFloat(computedStyles.fontSize);
|
|
3177
|
+
if (!Number.isFinite(fontSize)) {
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
const lineHeight = computedStyles.lineHeight === 'normal'
|
|
3181
|
+
? fontSize * 1.2
|
|
3182
|
+
: parseFloat(computedStyles.lineHeight);
|
|
3183
|
+
if (!Number.isFinite(lineHeight) || lineHeight <= 0) {
|
|
3184
|
+
return;
|
|
3185
|
+
}
|
|
3186
|
+
const lineHeightRatio = lineHeight / fontSize;
|
|
3187
|
+
const updateMetrics = (forceHeight) => {
|
|
3188
|
+
const targetHeight = lineHeightRatio * fontSize * maxLines;
|
|
3189
|
+
this.renderer.setStyle(labelElement, 'line-height', `${lineHeightRatio * fontSize}px`);
|
|
3190
|
+
this.renderer.setStyle(labelElement, 'max-height', `${targetHeight}px`);
|
|
3191
|
+
if (forceHeight) {
|
|
3192
|
+
this.renderer.setStyle(labelElement, 'height', `${targetHeight}px`);
|
|
3193
|
+
}
|
|
3194
|
+
else {
|
|
3195
|
+
this.renderer.removeStyle(labelElement, 'height');
|
|
3196
|
+
}
|
|
3197
|
+
return targetHeight;
|
|
3198
|
+
};
|
|
3199
|
+
let targetHeight = updateMetrics(false);
|
|
3200
|
+
let constrained = false;
|
|
3201
|
+
while (labelElement.scrollHeight > targetHeight && fontSize > minFontSizePx) {
|
|
3202
|
+
fontSize -= 1;
|
|
3203
|
+
this.renderer.setStyle(labelElement, 'font-size', `${fontSize}px`);
|
|
3204
|
+
targetHeight = updateMetrics(true);
|
|
3205
|
+
constrained = true;
|
|
3206
|
+
}
|
|
3207
|
+
if (!constrained) {
|
|
3208
|
+
this.renderer.removeStyle(labelElement, 'height');
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3163
3211
|
getAssetPath(asset) {
|
|
3164
3212
|
return assetMapping[asset];
|
|
3165
3213
|
}
|
|
3166
3214
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ProfileButtonComponent, deps: [{ token: 'uiComponent' }, { token: i0.Renderer2 }, { token: FontSizeMappingService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3167
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: ProfileButtonComponent, isStandalone: false, selector: "edm-sdui-profile-button", viewQueries: [{ propertyName: "profileButtonElementRef", first: true, predicate: ["profileButtonElement"], descendants: true }, { propertyName: "profileButtonLabelElementRef", first: true, predicate: ["profileButtonLabelElement"], descendants: true }, { propertyName: "profileButtonImageElementRef", first: true, predicate: ["profileButtonImageElement"], descendants: true }], ngImport: i0, template: "<button #profileButtonElement [edmSduiView]=\"uiComponent.element\" class=\"profile-button\" *ngIf=\"uiComponent\">\n <img #profileButtonImageElement *ngIf=\"uiComponent.element.asset\" [src]=\"getAssetPath(uiComponent.element.asset)\" alt=\"Profile\" class=\"profile-image\">\n <span #profileButtonLabelElement class=\"profile-label\">{{ uiComponent.element.label }}</span>\n</button>\n", styles: [":host{display:contents}.profile-button{display:flex;padding:16px 16px 0;border-radius:20px;background-color:var(--bt-profile);border:none;cursor:pointer;flex-direction:column;height:108px;width:108px;align-items:start;justify-content:start;gap:24px}.profile-button:hover{background-color:#0000000d;cursor:pointer}.profile-button .profile-image{width:24px;height:24px}.profile-button .profile-label{white-space:normal;word-break:
|
|
3215
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: ProfileButtonComponent, isStandalone: false, selector: "edm-sdui-profile-button", viewQueries: [{ propertyName: "profileButtonElementRef", first: true, predicate: ["profileButtonElement"], descendants: true }, { propertyName: "profileButtonLabelElementRef", first: true, predicate: ["profileButtonLabelElement"], descendants: true }, { propertyName: "profileButtonImageElementRef", first: true, predicate: ["profileButtonImageElement"], descendants: true }], ngImport: i0, template: "<button #profileButtonElement [edmSduiView]=\"uiComponent.element\" class=\"profile-button\" *ngIf=\"uiComponent\">\n <img #profileButtonImageElement *ngIf=\"uiComponent.element.asset\" [src]=\"getAssetPath(uiComponent.element.asset)\" alt=\"Profile\" class=\"profile-image\">\n <span #profileButtonLabelElement class=\"profile-label\">{{ uiComponent.element.label }}</span>\n</button>\n", styles: [":host{display:contents}.profile-button{display:flex;padding:16px 16px 0;border-radius:20px;background-color:var(--bt-profile);border:none;cursor:pointer;flex-direction:column;height:108px;width:108px;align-items:start;justify-content:start;gap:24px}.profile-button:hover{background-color:#0000000d;cursor:pointer}.profile-button .profile-image{width:24px;height:24px}.profile-button .profile-label{max-width:100%;white-space:normal;word-break:keep-all;overflow-wrap:normal;text-align:left;line-height:1.25;max-height:2.5em;overflow:hidden;text-overflow:ellipsis;display:block;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;-webkit-hyphens:none;hyphens:none}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: UIViewDirective, selector: "[edmSduiView]", inputs: ["edmSduiView", "disableClick"] }] }); }
|
|
3168
3216
|
}
|
|
3169
3217
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: ProfileButtonComponent, decorators: [{
|
|
3170
3218
|
type: Component,
|
|
3171
|
-
args: [{ selector: 'edm-sdui-profile-button', standalone: false, template: "<button #profileButtonElement [edmSduiView]=\"uiComponent.element\" class=\"profile-button\" *ngIf=\"uiComponent\">\n <img #profileButtonImageElement *ngIf=\"uiComponent.element.asset\" [src]=\"getAssetPath(uiComponent.element.asset)\" alt=\"Profile\" class=\"profile-image\">\n <span #profileButtonLabelElement class=\"profile-label\">{{ uiComponent.element.label }}</span>\n</button>\n", styles: [":host{display:contents}.profile-button{display:flex;padding:16px 16px 0;border-radius:20px;background-color:var(--bt-profile);border:none;cursor:pointer;flex-direction:column;height:108px;width:108px;align-items:start;justify-content:start;gap:24px}.profile-button:hover{background-color:#0000000d;cursor:pointer}.profile-button .profile-image{width:24px;height:24px}.profile-button .profile-label{white-space:normal;word-break:
|
|
3219
|
+
args: [{ selector: 'edm-sdui-profile-button', standalone: false, template: "<button #profileButtonElement [edmSduiView]=\"uiComponent.element\" class=\"profile-button\" *ngIf=\"uiComponent\">\n <img #profileButtonImageElement *ngIf=\"uiComponent.element.asset\" [src]=\"getAssetPath(uiComponent.element.asset)\" alt=\"Profile\" class=\"profile-image\">\n <span #profileButtonLabelElement class=\"profile-label\">{{ uiComponent.element.label }}</span>\n</button>\n", styles: [":host{display:contents}.profile-button{display:flex;padding:16px 16px 0;border-radius:20px;background-color:var(--bt-profile);border:none;cursor:pointer;flex-direction:column;height:108px;width:108px;align-items:start;justify-content:start;gap:24px}.profile-button:hover{background-color:#0000000d;cursor:pointer}.profile-button .profile-image{width:24px;height:24px}.profile-button .profile-label{max-width:100%;white-space:normal;word-break:keep-all;overflow-wrap:normal;text-align:left;line-height:1.25;max-height:2.5em;overflow:hidden;text-overflow:ellipsis;display:block;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;-webkit-hyphens:none;hyphens:none}\n"] }]
|
|
3172
3220
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3173
3221
|
type: Inject,
|
|
3174
3222
|
args: ['uiComponent']
|