ng-prime-tools 1.0.74 → 1.0.76
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.
|
@@ -1427,52 +1427,117 @@ class PTButtonComponent {
|
|
|
1427
1427
|
JSON.stringify({ ...prev, disabled: undefined }) ===
|
|
1428
1428
|
JSON.stringify({ ...curr, disabled: undefined });
|
|
1429
1429
|
if (onlyDisabledChanged) {
|
|
1430
|
-
this.updateDisabledStyles(curr.disabled ?? false);
|
|
1430
|
+
setTimeout(() => this.updateDisabledStyles(curr.disabled ?? false));
|
|
1431
1431
|
}
|
|
1432
1432
|
else {
|
|
1433
|
-
this.applyButtonStyles();
|
|
1433
|
+
setTimeout(() => this.applyButtonStyles());
|
|
1434
1434
|
}
|
|
1435
1435
|
}
|
|
1436
1436
|
else {
|
|
1437
1437
|
// If no previous value (first load), apply full styles
|
|
1438
|
-
this.applyButtonStyles();
|
|
1438
|
+
setTimeout(() => this.applyButtonStyles());
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
1442
|
ngAfterViewInit() {
|
|
1443
|
-
this.applyButtonStyles();
|
|
1443
|
+
setTimeout(() => this.applyButtonStyles());
|
|
1444
1444
|
}
|
|
1445
1445
|
getIconPos() {
|
|
1446
|
-
return this.buttonConfig
|
|
1446
|
+
return this.buttonConfig?.iconPos === 'right' ? 'right' : 'left';
|
|
1447
1447
|
}
|
|
1448
1448
|
getType() {
|
|
1449
|
-
return this.buttonConfig
|
|
1449
|
+
return this.buttonConfig?.type || 'button';
|
|
1450
|
+
}
|
|
1451
|
+
hasCustomColors() {
|
|
1452
|
+
return !!(this.buttonConfig?.backgroundColor ||
|
|
1453
|
+
this.buttonConfig?.borderColor ||
|
|
1454
|
+
this.buttonConfig?.fontColor);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* When custom colors are provided, do not pass PrimeNG severity.
|
|
1458
|
+
* Otherwise PrimeNG theme classes can override the custom colors.
|
|
1459
|
+
*/
|
|
1460
|
+
getSeverity() {
|
|
1461
|
+
return this.hasCustomColors() ? undefined : this.buttonConfig?.severity;
|
|
1462
|
+
}
|
|
1463
|
+
getStyleClass() {
|
|
1464
|
+
const classes = [];
|
|
1465
|
+
if (this.buttonConfig?.styleClass) {
|
|
1466
|
+
classes.push(this.buttonConfig.styleClass);
|
|
1467
|
+
}
|
|
1468
|
+
if (this.hasCustomColors()) {
|
|
1469
|
+
classes.push('pt-custom-colored-button');
|
|
1470
|
+
}
|
|
1471
|
+
return classes.join(' ');
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Direct style binding for PrimeNG p-button.
|
|
1475
|
+
* This is the reliable fallback for PrimeNG v21 themes.
|
|
1476
|
+
*/
|
|
1477
|
+
getButtonStyle() {
|
|
1478
|
+
const baseStyle = {
|
|
1479
|
+
width: this.buttonConfig?.width || 'auto',
|
|
1480
|
+
height: this.buttonConfig?.height || 'auto',
|
|
1481
|
+
};
|
|
1482
|
+
if (!this.hasCustomColors()) {
|
|
1483
|
+
return baseStyle;
|
|
1484
|
+
}
|
|
1485
|
+
if (this.buttonConfig?.disabled) {
|
|
1486
|
+
return {
|
|
1487
|
+
...baseStyle,
|
|
1488
|
+
color: '#999999',
|
|
1489
|
+
background: '#e0e0e0',
|
|
1490
|
+
'background-color': '#e0e0e0',
|
|
1491
|
+
'border-color': '#bdbdbd',
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
const backgroundColor = this.buttonConfig.backgroundColor || 'transparent';
|
|
1495
|
+
const borderColor = this.buttonConfig.borderColor ||
|
|
1496
|
+
this.buttonConfig.backgroundColor ||
|
|
1497
|
+
'transparent';
|
|
1498
|
+
return {
|
|
1499
|
+
...baseStyle,
|
|
1500
|
+
color: this.buttonConfig.fontColor || '#ffffff',
|
|
1501
|
+
background: backgroundColor,
|
|
1502
|
+
'background-color': backgroundColor,
|
|
1503
|
+
'border-color': borderColor,
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
getButtonElement() {
|
|
1507
|
+
return (this.el.nativeElement.querySelector('button.p-button') ||
|
|
1508
|
+
this.el.nativeElement.querySelector('button.p-element') ||
|
|
1509
|
+
this.el.nativeElement.querySelector('.p-button') ||
|
|
1510
|
+
this.el.nativeElement.querySelector('button'));
|
|
1450
1511
|
}
|
|
1451
1512
|
updateDisabledStyles(isDisabled) {
|
|
1452
|
-
const buttonElement = this.
|
|
1453
|
-
if (buttonElement) {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1513
|
+
const buttonElement = this.getButtonElement();
|
|
1514
|
+
if (!buttonElement || !this.buttonConfig) {
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
if (!this.hasCustomColors()) {
|
|
1518
|
+
return;
|
|
1457
1519
|
}
|
|
1520
|
+
this.renderer.setStyle(buttonElement, 'color', isDisabled ? '#999' : this.buttonConfig.fontColor || '#ffffff');
|
|
1521
|
+
this.renderer.setStyle(buttonElement, 'background', isDisabled
|
|
1522
|
+
? '#e0e0e0'
|
|
1523
|
+
: this.buttonConfig.backgroundColor || 'transparent');
|
|
1524
|
+
this.renderer.setStyle(buttonElement, 'background-color', isDisabled
|
|
1525
|
+
? '#e0e0e0'
|
|
1526
|
+
: this.buttonConfig.backgroundColor || 'transparent');
|
|
1527
|
+
this.renderer.setStyle(buttonElement, 'border-color', isDisabled
|
|
1528
|
+
? '#bdbdbd'
|
|
1529
|
+
: this.buttonConfig.borderColor ||
|
|
1530
|
+
this.buttonConfig.backgroundColor ||
|
|
1531
|
+
'transparent');
|
|
1458
1532
|
}
|
|
1459
1533
|
/**
|
|
1460
|
-
* We delegate colors to PrimeNG theme when
|
|
1461
|
-
* - outlined = true
|
|
1462
|
-
* - and no manual color is provided (no backgroundColor, borderColor, fontColor)
|
|
1534
|
+
* We delegate colors to PrimeNG theme when no manual color is provided.
|
|
1463
1535
|
*/
|
|
1464
1536
|
shouldUseThemeColors() {
|
|
1465
|
-
|
|
1466
|
-
return false;
|
|
1467
|
-
}
|
|
1468
|
-
const outlined = !!this.buttonConfig.outlined; // ✅ coerce to boolean
|
|
1469
|
-
return (outlined &&
|
|
1470
|
-
!this.buttonConfig.backgroundColor &&
|
|
1471
|
-
!this.buttonConfig.borderColor &&
|
|
1472
|
-
!this.buttonConfig.fontColor);
|
|
1537
|
+
return !this.hasCustomColors();
|
|
1473
1538
|
}
|
|
1474
1539
|
applyButtonStyles() {
|
|
1475
|
-
const buttonElement = this.
|
|
1540
|
+
const buttonElement = this.getButtonElement();
|
|
1476
1541
|
if (!buttonElement || !this.buttonConfig) {
|
|
1477
1542
|
return;
|
|
1478
1543
|
}
|
|
@@ -1481,25 +1546,35 @@ class PTButtonComponent {
|
|
|
1481
1546
|
// Width / height always applied
|
|
1482
1547
|
this.renderer.setStyle(buttonElement, 'width', this.buttonConfig.width || 'auto');
|
|
1483
1548
|
this.renderer.setStyle(buttonElement, 'height', this.buttonConfig.height || 'auto');
|
|
1484
|
-
//
|
|
1549
|
+
// Only override colors when custom colors are provided
|
|
1485
1550
|
if (!useThemeColors) {
|
|
1486
|
-
this.renderer.setStyle(buttonElement, 'color', isDisabled ? '#999' : this.buttonConfig.fontColor);
|
|
1487
|
-
this.renderer.setStyle(buttonElement, 'background
|
|
1488
|
-
|
|
1551
|
+
this.renderer.setStyle(buttonElement, 'color', isDisabled ? '#999' : this.buttonConfig.fontColor || '#ffffff');
|
|
1552
|
+
this.renderer.setStyle(buttonElement, 'background', isDisabled
|
|
1553
|
+
? '#e0e0e0'
|
|
1554
|
+
: this.buttonConfig.backgroundColor || 'transparent');
|
|
1555
|
+
this.renderer.setStyle(buttonElement, 'background-color', isDisabled
|
|
1556
|
+
? '#e0e0e0'
|
|
1557
|
+
: this.buttonConfig.backgroundColor || 'transparent');
|
|
1558
|
+
this.renderer.setStyle(buttonElement, 'border-color', isDisabled
|
|
1559
|
+
? '#bdbdbd'
|
|
1560
|
+
: this.buttonConfig.borderColor ||
|
|
1561
|
+
this.buttonConfig.backgroundColor ||
|
|
1562
|
+
'transparent');
|
|
1489
1563
|
}
|
|
1490
1564
|
else {
|
|
1491
1565
|
// If we delegate to theme, clear any inline overrides
|
|
1492
1566
|
this.renderer.removeStyle(buttonElement, 'color');
|
|
1567
|
+
this.renderer.removeStyle(buttonElement, 'background');
|
|
1493
1568
|
this.renderer.removeStyle(buttonElement, 'background-color');
|
|
1494
1569
|
this.renderer.removeStyle(buttonElement, 'border-color');
|
|
1495
1570
|
}
|
|
1496
1571
|
}
|
|
1497
1572
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: PTButtonComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1498
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: PTButtonComponent, isStandalone: false, selector: "pt-button", inputs: { buttonConfig: "buttonConfig" }, usesOnChanges: true, ngImport: i0, template: "<p-button\n [label]=\"buttonConfig.label\"\n [icon]=\"buttonConfig.icon || ''\"\n [iconPos]=\"getIconPos()\"\n [disabled]=\"buttonConfig.disabled\"\n [loading]=\"buttonConfig.loading\"\n [
|
|
1573
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.14", type: PTButtonComponent, isStandalone: false, selector: "pt-button", inputs: { buttonConfig: "buttonConfig" }, usesOnChanges: true, ngImport: i0, template: "<p-button\n [label]=\"buttonConfig.label\"\n [icon]=\"buttonConfig.icon || ''\"\n [iconPos]=\"getIconPos()\"\n [disabled]=\"buttonConfig.disabled\"\n [loading]=\"buttonConfig.loading\"\n [styleClass]=\"getStyleClass()\"\n [style]=\"getButtonStyle()\"\n [type]=\"getType()\"\n [severity]=\"getSeverity()\"\n [outlined]=\"buttonConfig.outlined\"\n></p-button>\n", styles: [":host{display:inline-block}:host ::ng-deep p-button{display:block}:host ::ng-deep .pt-custom-colored-button.p-button{box-shadow:none}:host ::ng-deep .pt-custom-colored-button.p-button:hover:not(:disabled){filter:brightness(.95)}:host ::ng-deep .pt-custom-colored-button.p-button:disabled{filter:none;cursor:not-allowed}\n"], dependencies: [{ kind: "component", type: i6.Button, selector: "p-button", inputs: ["hostName", "type", "badge", "disabled", "raised", "rounded", "text", "plain", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "iconPos", "icon", "label", "loading", "loadingIcon", "severity", "buttonProps", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }] }); }
|
|
1499
1574
|
}
|
|
1500
1575
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: PTButtonComponent, decorators: [{
|
|
1501
1576
|
type: Component,
|
|
1502
|
-
args: [{ selector: 'pt-button', standalone: false, template: "<p-button\n [label]=\"buttonConfig.label\"\n [icon]=\"buttonConfig.icon || ''\"\n [iconPos]=\"getIconPos()\"\n [disabled]=\"buttonConfig.disabled\"\n [loading]=\"buttonConfig.loading\"\n [
|
|
1577
|
+
args: [{ selector: 'pt-button', standalone: false, template: "<p-button\n [label]=\"buttonConfig.label\"\n [icon]=\"buttonConfig.icon || ''\"\n [iconPos]=\"getIconPos()\"\n [disabled]=\"buttonConfig.disabled\"\n [loading]=\"buttonConfig.loading\"\n [styleClass]=\"getStyleClass()\"\n [style]=\"getButtonStyle()\"\n [type]=\"getType()\"\n [severity]=\"getSeverity()\"\n [outlined]=\"buttonConfig.outlined\"\n></p-button>\n", styles: [":host{display:inline-block}:host ::ng-deep p-button{display:block}:host ::ng-deep .pt-custom-colored-button.p-button{box-shadow:none}:host ::ng-deep .pt-custom-colored-button.p-button:hover:not(:disabled){filter:brightness(.95)}:host ::ng-deep .pt-custom-colored-button.p-button:disabled{filter:none;cursor:not-allowed}\n"] }]
|
|
1503
1578
|
}], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }], propDecorators: { buttonConfig: [{
|
|
1504
1579
|
type: Input
|
|
1505
1580
|
}] } });
|