@paypal/checkout-components 5.0.426-alpha-ea5d1e6.0 → 5.0.427
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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +8 -8
- package/src/connect/component.jsx +1 -1
- package/src/connect/component.test.js +2 -2
- package/src/funding/card/config.jsx +3 -3
- package/src/funding/card/config.test.jsx +10 -10
- package/src/funding/funding.js +6 -6
- package/src/funding/funding.test.js +3 -3
- package/src/funding/paylater/config.jsx +2 -2
- package/src/funding/paypal/template.jsx +8 -8
- package/src/funding/util.js +2 -2
- package/src/funding/util.test.js +16 -16
- package/src/hosted-buttons/index.test.js +9 -9
- package/src/hosted-buttons/types.js +3 -3
- package/src/hosted-buttons/utils.js +8 -8
- package/src/hosted-buttons/utils.test.js +43 -43
- package/src/lib/api.js +2 -2
- package/src/lib/appSwitchResume.js +1 -1
- package/src/lib/perceived-latency-instrumentation.js +1 -1
- package/src/lib/security.js +1 -1
- package/src/marks/component.jsx +4 -4
- package/src/marks/templateRebrand.test.jsx +1 -1
- package/src/shopper-insights/shopperSession.js +13 -13
- package/src/shopper-insights/shopperSession.test.js +25 -25
- package/src/three-domain-secure/api.js +1 -1
- package/src/three-domain-secure/api.test.js +4 -4
- package/src/three-domain-secure/component.jsx +3 -3
- package/src/three-domain-secure/component.test.js +14 -14
- package/src/ui/buttons/buttons.jsx +2 -2
- package/src/ui/buttons/buttons.test.js +4 -4
- package/src/ui/buttons/config.js +1 -1
- package/src/ui/buttons/poweredBy.jsx +1 -1
- package/src/ui/buttons/props.bnpl.test.js +1 -1
- package/src/ui/buttons/props.js +43 -43
- package/src/ui/buttons/props.test.js +8 -8
- package/src/ui/buttons/script.jsx +10 -10
- package/src/ui/buttons/styles/button.js +2 -2
- package/src/ui/buttons/styles/disableMaxHeightConfig.test.js +1 -1
- package/src/ui/buttons/styles/labelContainerHeight.test.js +5 -5
- package/src/ui/buttons/styles/labels.js +7 -7
- package/src/ui/buttons/styles/page.js +1 -1
- package/src/ui/buttons/styles/responsive.js +137 -137
- package/src/ui/buttons/styles/styleUtils.js +14 -12
- package/src/ui/buttons/styles/styleUtils.test.constants.js +731 -0
- package/src/ui/buttons/styles/styleUtils.test.js +198 -610
- package/src/ui/buttons/util.js +4 -4
- package/src/ui/overlay/paypal-app-switch/style.jsx +1 -1
- package/src/ui/overlay/three-domain-secure/overlay.jsx +1 -1
- package/src/ui/overlay/three-domain-secure/style.jsx +1 -1
- package/src/ui/saved-payment-methods/template.jsx +1 -1
- package/src/ui/text/text.jsx +1 -1
- package/src/zoid/buttons/component.jsx +13 -13
- package/src/zoid/buttons/container.jsx +2 -2
- package/src/zoid/buttons/prerender.jsx +3 -3
- package/src/zoid/buttons/util.js +10 -10
- package/src/zoid/buttons/util.test.js +2 -2
- package/src/zoid/card-fields/component.jsx +8 -9
- package/src/zoid/card-form/component.js +3 -3
- package/src/zoid/checkout/component.jsx +2 -2
- package/src/zoid/payment-fields/component.jsx +1 -1
- package/src/zoid/qr-code/container.test.jsx +2 -2
- package/src/zoid/qr-code/prerender.test.jsx +1 -1
- package/src/zoid/saved-payment-methods/component.jsx +8 -8
- package/src/zoid/saved-payment-methods/util.js +2 -2
- package/src/zoid/saved-payment-methods/util.test.js +14 -14
- package/src/zoid/wallet/component.jsx +1 -1
package/src/ui/buttons/props.js
CHANGED
|
@@ -68,7 +68,7 @@ export type CreateOrderActions = {|
|
|
|
68
68
|
|
|
69
69
|
export type CreateOrder = (
|
|
70
70
|
CreateOrderData,
|
|
71
|
-
CreateOrderActions
|
|
71
|
+
CreateOrderActions,
|
|
72
72
|
) => ZalgoPromise<string> | string;
|
|
73
73
|
|
|
74
74
|
export type OnApproveData = {|
|
|
@@ -96,7 +96,7 @@ export type CreateSubscriptionActions = {|
|
|
|
96
96
|
|
|
97
97
|
export type CreateSubscription = (
|
|
98
98
|
CreateSubscriptionData,
|
|
99
|
-
CreateSubscriptionActions
|
|
99
|
+
CreateSubscriptionActions,
|
|
100
100
|
) => ZalgoPromise<string> | string;
|
|
101
101
|
|
|
102
102
|
export type OnApproveActions = {|
|
|
@@ -118,11 +118,11 @@ export type OnCompleteActions = {|
|
|
|
118
118
|
|
|
119
119
|
export type OnApprove = (
|
|
120
120
|
data: OnApproveData,
|
|
121
|
-
actions: OnApproveActions
|
|
121
|
+
actions: OnApproveActions,
|
|
122
122
|
) => ZalgoPromise<void> | void;
|
|
123
123
|
export type OnComplete = (
|
|
124
124
|
data: OnCompleteData,
|
|
125
|
-
actions: OnCompleteActions
|
|
125
|
+
actions: OnCompleteActions,
|
|
126
126
|
) => ZalgoPromise<void> | void;
|
|
127
127
|
|
|
128
128
|
type OnShippingChangeAddress = {|
|
|
@@ -244,7 +244,7 @@ export type OnShippingChangeActions = {|
|
|
|
244
244
|
|
|
245
245
|
export type OnShippingChange = (
|
|
246
246
|
data: OnShippingChangeData,
|
|
247
|
-
actions: OnShippingChangeActions
|
|
247
|
+
actions: OnShippingChangeActions,
|
|
248
248
|
) => ZalgoPromise<void> | void;
|
|
249
249
|
|
|
250
250
|
export type OnShippingAddressChangeData = {|
|
|
@@ -270,7 +270,7 @@ export type OnShippingAddressChangeActions = {|
|
|
|
270
270
|
|
|
271
271
|
export type OnShippingAddressChange = (
|
|
272
272
|
data: OnShippingAddressChangeData,
|
|
273
|
-
actions: OnShippingAddressChangeActions
|
|
273
|
+
actions: OnShippingAddressChangeActions,
|
|
274
274
|
) => ZalgoPromise<void> | void;
|
|
275
275
|
|
|
276
276
|
export type OnShippingOptionsChangeData = {|
|
|
@@ -293,7 +293,7 @@ export type OnShippingOptionsChangeActions = {|
|
|
|
293
293
|
|
|
294
294
|
export type OnShippingOptionsChange = (
|
|
295
295
|
data: OnShippingOptionsChangeData,
|
|
296
|
-
actions: OnShippingOptionsChangeActions
|
|
296
|
+
actions: OnShippingOptionsChangeActions,
|
|
297
297
|
) => ZalgoPromise<void> | void;
|
|
298
298
|
|
|
299
299
|
export type OnCancelData = {|
|
|
@@ -307,7 +307,7 @@ export type OnCancelActions = {|
|
|
|
307
307
|
|
|
308
308
|
export type OnCancel = (
|
|
309
309
|
OnCancelData,
|
|
310
|
-
OnCancelActions
|
|
310
|
+
OnCancelActions,
|
|
311
311
|
) => ZalgoPromise<void> | void;
|
|
312
312
|
|
|
313
313
|
export type OnClickData = {|
|
|
@@ -429,20 +429,20 @@ export type ApplePaySessionConfig = {|
|
|
|
429
429
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
430
430
|
completeMerchantValidation: (validatedSession: any) => void,
|
|
431
431
|
completeShippingMethodSelection: (
|
|
432
|
-
update: ApplePayShippingMethodUpdate | {||}
|
|
432
|
+
update: ApplePayShippingMethodUpdate | {||},
|
|
433
433
|
) => void,
|
|
434
434
|
completeShippingContactSelection: (
|
|
435
|
-
update: ApplePayShippingContactUpdate | {||}
|
|
435
|
+
update: ApplePayShippingContactUpdate | {||},
|
|
436
436
|
) => void,
|
|
437
437
|
completePaymentMethodSelection: (
|
|
438
|
-
update: ApplePayPaymentMethodUpdate | {||}
|
|
438
|
+
update: ApplePayPaymentMethodUpdate | {||},
|
|
439
439
|
) => void,
|
|
440
440
|
completePayment: (result: ApplePayPaymentAuthorizationResult) => void,
|
|
441
441
|
|};
|
|
442
442
|
|
|
443
443
|
export type ApplePaySessionConfigRequest = (
|
|
444
444
|
version: number,
|
|
445
|
-
request: Object
|
|
445
|
+
request: Object,
|
|
446
446
|
) => ApplePaySessionConfig;
|
|
447
447
|
|
|
448
448
|
export type ButtonMessage = {|
|
|
@@ -741,7 +741,7 @@ export const DEFAULT_PROPS = {
|
|
|
741
741
|
};
|
|
742
742
|
|
|
743
743
|
export function getColorABTestFromStorage(
|
|
744
|
-
storageState: StateGetSet
|
|
744
|
+
storageState: StateGetSet,
|
|
745
745
|
): ?ColorABTestStorage {
|
|
746
746
|
const sessionState = storageState.get("colorABTest");
|
|
747
747
|
|
|
@@ -753,7 +753,7 @@ export function getColorABTestFromStorage(
|
|
|
753
753
|
}
|
|
754
754
|
|
|
755
755
|
export function getBNPLLabelABTestFromStorage(
|
|
756
|
-
storageState: StateGetSet
|
|
756
|
+
storageState: StateGetSet,
|
|
757
757
|
): ?BNPLLabelABTestStorage {
|
|
758
758
|
const sessionState = storageState.get("bnplLabelABTest");
|
|
759
759
|
|
|
@@ -841,7 +841,7 @@ export function throwErrorForInvalidButtonColor({
|
|
|
841
841
|
throw new Error(
|
|
842
842
|
`Unexpected style.color for ${
|
|
843
843
|
fundingSource || FUNDING.PAYPAL
|
|
844
|
-
} button: ${invalidButtonColor}, expected ${fundingSourceColors.join(", ")}
|
|
844
|
+
} button: ${invalidButtonColor}, expected ${fundingSourceColors.join(", ")}`,
|
|
845
845
|
);
|
|
846
846
|
}
|
|
847
847
|
|
|
@@ -1030,11 +1030,11 @@ export function getCobrandedBNPLLabelFlags(props: ?ButtonPropsInputs): {|
|
|
|
1030
1030
|
|
|
1031
1031
|
const isPayNowOrLaterLabelEligible = Boolean(
|
|
1032
1032
|
isPaylaterCobrandedLabelEnabled &&
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1033
|
+
isCobrandedEligibleFundingSource &&
|
|
1034
|
+
isPaylaterEligible &&
|
|
1035
|
+
isLabelEligible &&
|
|
1036
|
+
isEnLang &&
|
|
1037
|
+
isPurchaseFlow,
|
|
1038
1038
|
);
|
|
1039
1039
|
|
|
1040
1040
|
const isPaylaterCobrandedLabelRandomizationEnabled =
|
|
@@ -1080,7 +1080,7 @@ const getDefaultButtonPropsInput = (): ButtonPropsInputs => {
|
|
|
1080
1080
|
|
|
1081
1081
|
export function normalizeButtonStyle(
|
|
1082
1082
|
props: ?ButtonPropsInputs,
|
|
1083
|
-
style: ButtonStyleInputs
|
|
1083
|
+
style: ButtonStyleInputs,
|
|
1084
1084
|
): ButtonStyle {
|
|
1085
1085
|
if (!style) {
|
|
1086
1086
|
throw new Error(`Expected props.style to be set`);
|
|
@@ -1102,7 +1102,7 @@ export function normalizeButtonStyle(
|
|
|
1102
1102
|
|
|
1103
1103
|
if (!fundingConfig) {
|
|
1104
1104
|
throw new Error(
|
|
1105
|
-
`Expected ${fundingSource || FUNDING.PAYPAL} to be eligible
|
|
1105
|
+
`Expected ${fundingSource || FUNDING.PAYPAL} to be eligible`,
|
|
1106
1106
|
);
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
@@ -1145,7 +1145,7 @@ export function normalizeButtonStyle(
|
|
|
1145
1145
|
throw new Error(
|
|
1146
1146
|
`Unexpected style.color for ${fundingSource || FUNDING.PAYPAL} button: ${
|
|
1147
1147
|
requestedButtonColor || color
|
|
1148
|
-
}, expected ${validColors.join(", ")}
|
|
1148
|
+
}, expected ${validColors.join(", ")}`,
|
|
1149
1149
|
);
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
@@ -1153,14 +1153,14 @@ export function normalizeButtonStyle(
|
|
|
1153
1153
|
throw new Error(
|
|
1154
1154
|
`Unexpected style.shape for ${
|
|
1155
1155
|
fundingSource || FUNDING.PAYPAL
|
|
1156
|
-
} button: ${shape}, expected ${fundingConfig.shapes.join(", ")}
|
|
1156
|
+
} button: ${shape}, expected ${fundingConfig.shapes.join(", ")}`,
|
|
1157
1157
|
);
|
|
1158
1158
|
}
|
|
1159
1159
|
|
|
1160
1160
|
if (height !== undefined) {
|
|
1161
1161
|
if (typeof height !== "number") {
|
|
1162
1162
|
throw new TypeError(
|
|
1163
|
-
`Expected style.height to be a number, got: ${height}
|
|
1163
|
+
`Expected style.height to be a number, got: ${height}`,
|
|
1164
1164
|
);
|
|
1165
1165
|
}
|
|
1166
1166
|
|
|
@@ -1171,13 +1171,13 @@ export function normalizeButtonStyle(
|
|
|
1171
1171
|
|
|
1172
1172
|
if (disableMaxHeight === true) {
|
|
1173
1173
|
throw new TypeError(
|
|
1174
|
-
`Unexpected style.height for style.disableMaxHeight: got: ${height}, expected undefined
|
|
1174
|
+
`Unexpected style.height for style.disableMaxHeight: got: ${height}, expected undefined.`,
|
|
1175
1175
|
);
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
1178
|
if (height < minHeight || height > maxHeight) {
|
|
1179
1179
|
throw new Error(
|
|
1180
|
-
`Expected style.height to be between ${minHeight}px and ${maxHeight}px - got ${height}px
|
|
1180
|
+
`Expected style.height to be between ${minHeight}px and ${maxHeight}px - got ${height}px`,
|
|
1181
1181
|
);
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
@@ -1185,21 +1185,21 @@ export function normalizeButtonStyle(
|
|
|
1185
1185
|
if (disableMaxHeight !== undefined) {
|
|
1186
1186
|
if (typeof disableMaxHeight !== "boolean") {
|
|
1187
1187
|
throw new TypeError(
|
|
1188
|
-
`Expected style.disableMaxHeight to be a boolean, got: ${disableMaxHeight}
|
|
1188
|
+
`Expected style.disableMaxHeight to be a boolean, got: ${disableMaxHeight}`,
|
|
1189
1189
|
);
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
1192
|
const disableMaxHeightInvalidFundingSources = [FUNDING.CARD, undefined];
|
|
1193
1193
|
const disableMaxHeightValidFundingSources = Object.values(FUNDING).filter(
|
|
1194
1194
|
(fundingSourceId) =>
|
|
1195
|
-
!disableMaxHeightInvalidFundingSources.includes(fundingSourceId)
|
|
1195
|
+
!disableMaxHeightInvalidFundingSources.includes(fundingSourceId),
|
|
1196
1196
|
);
|
|
1197
1197
|
|
|
1198
1198
|
if (disableMaxHeightInvalidFundingSources.includes(fundingSource)) {
|
|
1199
1199
|
throw new TypeError(
|
|
1200
1200
|
`Unexpected fundingSource for style.disableMaxHeight: got: ${
|
|
1201
1201
|
fundingSource ? fundingSource : "Smart Stack"
|
|
1202
|
-
}, expected ${disableMaxHeightValidFundingSources.join(", ")}
|
|
1202
|
+
}, expected ${disableMaxHeightValidFundingSources.join(", ")}.`,
|
|
1203
1203
|
);
|
|
1204
1204
|
}
|
|
1205
1205
|
}
|
|
@@ -1207,13 +1207,13 @@ export function normalizeButtonStyle(
|
|
|
1207
1207
|
if (borderRadius !== undefined) {
|
|
1208
1208
|
if (!isBorderRadiusNumber(borderRadius)) {
|
|
1209
1209
|
throw new TypeError(
|
|
1210
|
-
`Expected style.borderRadius to be a number, got: ${borderRadius}
|
|
1210
|
+
`Expected style.borderRadius to be a number, got: ${borderRadius}`,
|
|
1211
1211
|
);
|
|
1212
1212
|
}
|
|
1213
1213
|
|
|
1214
1214
|
if (borderRadius < 0) {
|
|
1215
1215
|
throw new Error(
|
|
1216
|
-
`Expected style.borderRadius to be greater than or equal to 0, got: ${borderRadius}
|
|
1216
|
+
`Expected style.borderRadius to be greater than or equal to 0, got: ${borderRadius}`,
|
|
1217
1217
|
);
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
@@ -1221,7 +1221,7 @@ export function normalizeButtonStyle(
|
|
|
1221
1221
|
if (layout === BUTTON_LAYOUT.VERTICAL) {
|
|
1222
1222
|
if (tagline) {
|
|
1223
1223
|
throw new Error(
|
|
1224
|
-
`style.tagline is not allowed for ${BUTTON_LAYOUT.VERTICAL} layout
|
|
1224
|
+
`style.tagline is not allowed for ${BUTTON_LAYOUT.VERTICAL} layout`,
|
|
1225
1225
|
);
|
|
1226
1226
|
}
|
|
1227
1227
|
}
|
|
@@ -1253,7 +1253,7 @@ export function normalizeButtonStyle(
|
|
|
1253
1253
|
export function normalizeButtonMessage(
|
|
1254
1254
|
message: ButtonMessageInputs,
|
|
1255
1255
|
layout: $Values<typeof BUTTON_LAYOUT>,
|
|
1256
|
-
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING
|
|
1256
|
+
fundingSources: $ReadOnlyArray<$Values<typeof FUNDING>>,
|
|
1257
1257
|
): ButtonMessage {
|
|
1258
1258
|
const {
|
|
1259
1259
|
color = MESSAGE_COLOR.BLACK,
|
|
@@ -1269,12 +1269,12 @@ export function normalizeButtonMessage(
|
|
|
1269
1269
|
}
|
|
1270
1270
|
if (typeof amount !== "number" || isNaN(amount)) {
|
|
1271
1271
|
throw new TypeError(
|
|
1272
|
-
`Expected message.amount to be a number, got: ${amount}
|
|
1272
|
+
`Expected message.amount to be a number, got: ${amount}`,
|
|
1273
1273
|
);
|
|
1274
1274
|
}
|
|
1275
1275
|
if (amount < 0) {
|
|
1276
1276
|
throw new Error(
|
|
1277
|
-
`Expected message.amount to be a positive number, got: ${amount}
|
|
1277
|
+
`Expected message.amount to be a positive number, got: ${amount}`,
|
|
1278
1278
|
);
|
|
1279
1279
|
}
|
|
1280
1280
|
}
|
|
@@ -1286,12 +1286,12 @@ export function normalizeButtonMessage(
|
|
|
1286
1286
|
if (!Array.isArray(offer)) {
|
|
1287
1287
|
throw new TypeError(
|
|
1288
1288
|
`Expected message.offer to be an array of strings, got: ${String(
|
|
1289
|
-
offer
|
|
1290
|
-
)}
|
|
1289
|
+
offer,
|
|
1290
|
+
)}`,
|
|
1291
1291
|
);
|
|
1292
1292
|
}
|
|
1293
1293
|
const invalidOffers = offer.filter(
|
|
1294
|
-
(o) => !values(MESSAGE_OFFER).includes(o)
|
|
1294
|
+
(o) => !values(MESSAGE_OFFER).includes(o),
|
|
1295
1295
|
);
|
|
1296
1296
|
if (invalidOffers.length > 0) {
|
|
1297
1297
|
throw new Error(`Invalid offer(s): ${invalidOffers.join(",")}`);
|
|
@@ -1339,7 +1339,7 @@ const getDefaultExperiment = (): Experiment => {
|
|
|
1339
1339
|
};
|
|
1340
1340
|
|
|
1341
1341
|
export function normalizeButtonProps(
|
|
1342
|
-
props: ?ButtonPropsInputs
|
|
1342
|
+
props: ?ButtonPropsInputs,
|
|
1343
1343
|
): RenderButtonProps {
|
|
1344
1344
|
if (!props) {
|
|
1345
1345
|
throw new Error(`Expected props`);
|
|
@@ -1347,8 +1347,8 @@ export function normalizeButtonProps(
|
|
|
1347
1347
|
|
|
1348
1348
|
const defaultHasShippingCallback = Boolean(
|
|
1349
1349
|
props.onShippingChange ||
|
|
1350
|
-
|
|
1351
|
-
|
|
1350
|
+
props.onShippingAddressChange ||
|
|
1351
|
+
props.onShippingOptionsChange,
|
|
1352
1352
|
);
|
|
1353
1353
|
|
|
1354
1354
|
let {
|
|
@@ -1408,7 +1408,7 @@ export function normalizeButtonProps(
|
|
|
1408
1408
|
|
|
1409
1409
|
if (remembered.some((source) => FUNDING_SOURCES.indexOf(source) === -1)) {
|
|
1410
1410
|
throw new Error(
|
|
1411
|
-
`Expected valid funding sources, got ${JSON.stringify(remembered)}
|
|
1411
|
+
`Expected valid funding sources, got ${JSON.stringify(remembered)}`,
|
|
1412
1412
|
);
|
|
1413
1413
|
}
|
|
1414
1414
|
|
|
@@ -377,7 +377,7 @@ describe("getColorForABTest", () => {
|
|
|
377
377
|
expect.objectContaining({
|
|
378
378
|
color: expect.any(String),
|
|
379
379
|
shouldApplyRebrandedStyles: expect.any(Boolean),
|
|
380
|
-
})
|
|
380
|
+
}),
|
|
381
381
|
);
|
|
382
382
|
expect(storageState.get).toHaveBeenCalledWith("colorABTest");
|
|
383
383
|
expect(storageState.set).toHaveBeenCalledWith("colorABTest", {
|
|
@@ -405,7 +405,7 @@ describe("getColorForABTest", () => {
|
|
|
405
405
|
expect.objectContaining({
|
|
406
406
|
color: expect.any(String),
|
|
407
407
|
shouldApplyRebrandedStyles: expect.any(Boolean),
|
|
408
|
-
})
|
|
408
|
+
}),
|
|
409
409
|
);
|
|
410
410
|
expect(storageState.get).toHaveBeenCalledWith("colorABTest");
|
|
411
411
|
expect(storageState.set).toHaveBeenCalledWith("colorABTest", {
|
|
@@ -432,7 +432,7 @@ describe("getColorForABTest", () => {
|
|
|
432
432
|
expect.objectContaining({
|
|
433
433
|
color: expect.any(String),
|
|
434
434
|
shouldApplyRebrandedStyles: expect.any(Boolean),
|
|
435
|
-
})
|
|
435
|
+
}),
|
|
436
436
|
);
|
|
437
437
|
expect(storageState.get).toHaveBeenCalledWith("colorABTest");
|
|
438
438
|
expect(storageState.set).toHaveBeenCalledWith("colorABTest", {
|
|
@@ -516,7 +516,7 @@ describe("getColorForFullRedesign", () => {
|
|
|
516
516
|
expect.objectContaining({
|
|
517
517
|
color: expect.any(String),
|
|
518
518
|
shouldApplyRebrandedStyles: true,
|
|
519
|
-
})
|
|
519
|
+
}),
|
|
520
520
|
);
|
|
521
521
|
});
|
|
522
522
|
|
|
@@ -530,7 +530,7 @@ describe("getColorForFullRedesign", () => {
|
|
|
530
530
|
expect.objectContaining({
|
|
531
531
|
color: expect.any(String),
|
|
532
532
|
shouldApplyRebrandedStyles: true,
|
|
533
|
-
})
|
|
533
|
+
}),
|
|
534
534
|
);
|
|
535
535
|
});
|
|
536
536
|
|
|
@@ -738,7 +738,7 @@ describe("getButtonColor", () => {
|
|
|
738
738
|
expect(result).toEqual(
|
|
739
739
|
expect.objectContaining({
|
|
740
740
|
isButtonColorABTestMerchant: true,
|
|
741
|
-
})
|
|
741
|
+
}),
|
|
742
742
|
);
|
|
743
743
|
});
|
|
744
744
|
|
|
@@ -851,7 +851,7 @@ describe("normalizeButtonStyle requestedButtonColor", () => {
|
|
|
851
851
|
},
|
|
852
852
|
},
|
|
853
853
|
// $FlowFixMe
|
|
854
|
-
{ color: BUTTON_COLOR.GOLD }
|
|
854
|
+
{ color: BUTTON_COLOR.GOLD },
|
|
855
855
|
);
|
|
856
856
|
|
|
857
857
|
// Merchant configured gold — rebrand maps it to blue
|
|
@@ -874,7 +874,7 @@ describe("normalizeButtonStyle requestedButtonColor", () => {
|
|
|
874
874
|
},
|
|
875
875
|
},
|
|
876
876
|
// $FlowFixMe
|
|
877
|
-
{ color: BUTTON_COLOR.SILVER }
|
|
877
|
+
{ color: BUTTON_COLOR.SILVER },
|
|
878
878
|
);
|
|
879
879
|
|
|
880
880
|
// Merchant configured silver — rebrand maps it to white
|
|
@@ -53,7 +53,7 @@ export function getComponentScript(): () => void {
|
|
|
53
53
|
elements:
|
|
54
54
|
| HTMLCollection<HTMLElement>
|
|
55
55
|
| NodeList<HTMLElement>
|
|
56
|
-
| $ReadOnlyArray<HTMLElement
|
|
56
|
+
| $ReadOnlyArray<HTMLElement>,
|
|
57
57
|
): $ReadOnlyArray<HTMLElement> {
|
|
58
58
|
return toArray(elements).filter((el) => {
|
|
59
59
|
return el.tagName.toLowerCase() !== TAG.STYLE;
|
|
@@ -107,16 +107,16 @@ export function getComponentScript(): () => void {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function getElementsTotalWidth(
|
|
110
|
-
elements: $ReadOnlyArray<HTMLElement
|
|
110
|
+
elements: $ReadOnlyArray<HTMLElement>,
|
|
111
111
|
): number {
|
|
112
112
|
return sum(
|
|
113
|
-
elements.map((child) => Math.ceil(child.getBoundingClientRect().width))
|
|
113
|
+
elements.map((child) => Math.ceil(child.getBoundingClientRect().width)),
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function calculateGap(optionalParent: HTMLElement): number {
|
|
118
118
|
const isTagline = optionalParent?.classList.contains(
|
|
119
|
-
"paypal-button-tagline" || false
|
|
119
|
+
"paypal-button-tagline" || false,
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
if (isTagline) {
|
|
@@ -142,17 +142,17 @@ export function getComponentScript(): () => void {
|
|
|
142
142
|
|
|
143
143
|
function getOptionalParents(): $ReadOnlyArray<HTMLElement> {
|
|
144
144
|
return unique(
|
|
145
|
-
getElements(SELECTOR.OPTIONAL).map(getParent).filter(Boolean)
|
|
145
|
+
getElements(SELECTOR.OPTIONAL).map(getParent).filter(Boolean),
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
function getOptionalChildren(
|
|
150
|
-
parent: HTMLElement
|
|
150
|
+
parent: HTMLElement,
|
|
151
151
|
): $ReadOnlyArray<HTMLElement> {
|
|
152
152
|
return toArray(getElements(SELECTOR.OPTIONAL, parent)).sort(
|
|
153
153
|
(first, second) => {
|
|
154
154
|
return getOptionalIndex(first) - getOptionalIndex(second);
|
|
155
|
-
}
|
|
155
|
+
},
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -189,11 +189,11 @@ export function getComponentScript(): () => void {
|
|
|
189
189
|
|
|
190
190
|
if (usedWidth > parentWidth) {
|
|
191
191
|
optionalChildren.forEach((optionalChild) =>
|
|
192
|
-
hideElement(optionalChild)
|
|
192
|
+
hideElement(optionalChild),
|
|
193
193
|
);
|
|
194
194
|
} else {
|
|
195
195
|
optionalChildren.forEach((optionalChild) =>
|
|
196
|
-
showElement(optionalChild)
|
|
196
|
+
showElement(optionalChild),
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -210,7 +210,7 @@ export function getComponentScript(): () => void {
|
|
|
210
210
|
if (document.body) {
|
|
211
211
|
document.body.classList.add(CLASS.DOM_READY);
|
|
212
212
|
}
|
|
213
|
-
})
|
|
213
|
+
}),
|
|
214
214
|
);
|
|
215
215
|
|
|
216
216
|
const load = () => {
|
|
@@ -147,8 +147,8 @@ export const buttonStyle = `
|
|
|
147
147
|
|
|
148
148
|
@media only screen and (max-width: ${MIN_VAULT_BUTTON_WIDTH - 1}px) {
|
|
149
149
|
.${CLASS.CONTAINER} .${CLASS.BUTTON_ROW}.${CLASS.WALLET}.${
|
|
150
|
-
|
|
151
|
-
} .${CLASS.BUTTON} {
|
|
150
|
+
CLASS.WALLET_MENU
|
|
151
|
+
} .${CLASS.BUTTON} {
|
|
152
152
|
border-top-right-radius: 4px;
|
|
153
153
|
border-bottom-right-radius: 4px;
|
|
154
154
|
width: 100%;
|
|
@@ -34,7 +34,7 @@ describe("getLabelContainerHeight", () => {
|
|
|
34
34
|
"returns $expected for buttonHeight=$buttonHeight fontSize=$fontSize",
|
|
35
35
|
({ buttonHeight, fontSize, expected }) => {
|
|
36
36
|
expect(getLabelContainerHeight(buttonHeight, fontSize)).toBe(expected);
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -81,7 +81,7 @@ describe("generateLabelHeightContainerStyles", () => {
|
|
|
81
81
|
(minH, maxH, labelHeight) => {
|
|
82
82
|
calls.push({ minH, maxH, labelHeight });
|
|
83
83
|
return "";
|
|
84
|
-
}
|
|
84
|
+
},
|
|
85
85
|
);
|
|
86
86
|
expect(calls).toEqual([{ minH: 75, maxH: 75, labelHeight: 38 }]);
|
|
87
87
|
});
|
|
@@ -93,7 +93,7 @@ describe("generateDisableMaxHeightLabelContainerStyles", () => {
|
|
|
93
93
|
expect(result).toContain("min-height:");
|
|
94
94
|
expect(result).toContain("max-height:");
|
|
95
95
|
expect(result).toContain(
|
|
96
|
-
".paypal-button-rebrand > .paypal-button-label-container"
|
|
96
|
+
".paypal-button-rebrand > .paypal-button-label-container",
|
|
97
97
|
);
|
|
98
98
|
expect(result).toContain("height:");
|
|
99
99
|
});
|
|
@@ -103,7 +103,7 @@ describe("generateDisableMaxHeightLabelContainerStyles", () => {
|
|
|
103
103
|
// XXXL bucket has maxHeight: 75, so catch-all starts at 76px
|
|
104
104
|
expect(result).toContain("@container (min-height: 76px)");
|
|
105
105
|
expect(result).not.toMatch(
|
|
106
|
-
/@container \(min-height: 76px\) and \(max-height
|
|
106
|
+
/@container \(min-height: 76px\) and \(max-height:/,
|
|
107
107
|
);
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ describe("generateDisableMaxHeightLabelContainerStyles", () => {
|
|
|
112
112
|
// XXXL: maxHeight=75, fontSize=26 → getLabelContainerHeight(75, 26) = 38
|
|
113
113
|
const catchAllHeight = getLabelContainerHeight(75, 26);
|
|
114
114
|
expect(result).toContain(
|
|
115
|
-
`@container (min-height: 76px) {\n .paypal-button-rebrand > .paypal-button-label-container {\n height: ${catchAllHeight}px
|
|
115
|
+
`@container (min-height: 76px) {\n .paypal-button-rebrand > .paypal-button-label-container {\n height: ${catchAllHeight}px;`,
|
|
116
116
|
);
|
|
117
117
|
});
|
|
118
118
|
|
|
@@ -29,8 +29,8 @@ export const labelStyle = `
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
.${CLASS.BUTTON} .${CLASS.TEXT}.${CLASS.IMMEDIATE}:not(.${
|
|
32
|
-
|
|
33
|
-
}):not(.${CLASS.HIDDEN}) {
|
|
32
|
+
CLASS.PERSONALIZATION_TEXT
|
|
33
|
+
}):not(.${CLASS.HIDDEN}) {
|
|
34
34
|
${VISIBLE}
|
|
35
35
|
${EXPANDED}
|
|
36
36
|
}
|
|
@@ -43,8 +43,8 @@ export const labelStyle = `
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
.${CLASS.DOM_READY} .${CLASS.BUTTON} .${CLASS.TEXT}:not(.${
|
|
46
|
-
|
|
47
|
-
}):not(.${CLASS.PERSONALIZATION_TEXT}):not(.${CLASS.HIDDEN}) {
|
|
46
|
+
CLASS.IMMEDIATE
|
|
47
|
+
}):not(.${CLASS.PERSONALIZATION_TEXT}):not(.${CLASS.HIDDEN}) {
|
|
48
48
|
${VISIBLE}
|
|
49
49
|
${COMPRESSED}
|
|
50
50
|
animation: show-text ${__TEST__ ? "0" : "1"}s 0s forwards;
|
|
@@ -61,15 +61,15 @@ export const labelStyle = `
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.${CLASS.BUTTON_REBRAND} .${CLASS.BUTTON_LABEL} {
|
|
64
|
-
font-family:
|
|
64
|
+
font-family: PayPalOpen-Regular, system-ui, -apple-system, Roboto, "Segoe UI", Helvetica-Neue, Helvetica, Arial, sans-serif;
|
|
65
65
|
font-weight: 400;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
.${CLASS.BUTTON_REBRAND}[data-funding-source=paypal] .${CLASS.BUTTON_LABEL},
|
|
69
69
|
.${CLASS.BUTTON_REBRAND}[data-funding-source=credit] .${CLASS.BUTTON_LABEL},
|
|
70
70
|
.${CLASS.BUTTON_REBRAND}[data-funding-source=paylater] .${
|
|
71
|
-
|
|
72
|
-
} {
|
|
71
|
+
CLASS.BUTTON_LABEL
|
|
72
|
+
} {
|
|
73
73
|
font-family: PayPal Pro Book, system-ui, -apple-system, Roboto, "Segoe UI", Helvetica-Neue, Helvetica, Arial, sans-serif;
|
|
74
74
|
font-weight: 500;
|
|
75
75
|
}
|
|
@@ -4,7 +4,7 @@ import { CLASS } from "../../../constants";
|
|
|
4
4
|
|
|
5
5
|
export const pageStyle = `
|
|
6
6
|
html, body {
|
|
7
|
-
font-family:
|
|
7
|
+
font-family: PayPalOpen-Regular, system-ui, -apple-system, Roboto, "Segoe UI", Helvetica-Neue, Helvetica, Arial, sans-serif;
|
|
8
8
|
padding: 0;
|
|
9
9
|
margin: 0;
|
|
10
10
|
width: 100%;
|