allaw-ui 0.0.333 → 0.0.335
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.
|
@@ -46,9 +46,9 @@ var OAuthProviderButton = function (_a) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
var updateLabel = function () {
|
|
49
|
-
var _a;
|
|
50
|
-
var
|
|
51
|
-
var maxWidth = ((_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth)
|
|
49
|
+
var _a, _b;
|
|
50
|
+
var _c = getLabels(), labels = _c.labels, shortLabels = _c.shortLabels;
|
|
51
|
+
var maxWidth = (_b = (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) !== null && _b !== void 0 ? _b : 0;
|
|
52
52
|
var thresholdWidth = getThresholdWidth(size);
|
|
53
53
|
var newLabel = maxWidth < thresholdWidth
|
|
54
54
|
? shortLabels[provider]
|
|
@@ -56,15 +56,23 @@ var OAuthProviderButton = function (_a) {
|
|
|
56
56
|
setLabel(newLabel);
|
|
57
57
|
};
|
|
58
58
|
useEffect(function () {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
var resizeObserver = new ResizeObserver(function () {
|
|
60
|
+
updateLabel();
|
|
61
|
+
});
|
|
62
|
+
if (buttonRef.current) {
|
|
63
|
+
resizeObserver.observe(buttonRef.current);
|
|
64
|
+
}
|
|
61
65
|
return function () {
|
|
62
|
-
|
|
66
|
+
if (buttonRef.current) {
|
|
67
|
+
resizeObserver.unobserve(buttonRef.current);
|
|
68
|
+
}
|
|
63
69
|
};
|
|
64
70
|
}, [provider, type, size]);
|
|
65
71
|
// Force an update after the first render to ensure the correct label is set
|
|
66
72
|
useEffect(function () {
|
|
67
|
-
|
|
73
|
+
if (buttonRef.current) {
|
|
74
|
+
updateLabel();
|
|
75
|
+
}
|
|
68
76
|
}, []);
|
|
69
77
|
var renderIcon = function () {
|
|
70
78
|
var iconSizes = {
|