@weareconceptstudio/account 2.1.12 → 2.1.14
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/cli/init-config.js +221 -0
- package/cli/postinstall.js +31 -0
- package/cli/test-user-integration.mjs +150 -0
- package/dist/AccountProvider.d.ts.map +1 -1
- package/dist/AccountProvider.js +14 -11
- package/dist/AccountProvider.js.map +1 -1
- package/dist/components/AccountButton/index.d.ts.map +1 -1
- package/dist/components/AccountButton/index.js +33 -5
- package/dist/components/AccountButton/index.js.map +1 -1
- package/dist/components/AccountButton/style.d.ts +2 -0
- package/dist/components/AccountButton/style.d.ts.map +1 -1
- package/dist/components/AccountButton/style.js +74 -0
- package/dist/components/AccountButton/style.js.map +1 -1
- package/dist/components/CartPageDetector.d.ts.map +1 -1
- package/dist/components/CartPageDetector.js +13 -0
- package/dist/components/CartPageDetector.js.map +1 -1
- package/dist/components/CustomCheckbox/index.d.ts +1 -1
- package/dist/components/CustomCheckbox/index.d.ts.map +1 -1
- package/dist/components/CustomCheckbox/index.js +4 -3
- package/dist/components/CustomCheckbox/index.js.map +1 -1
- package/dist/components/LineItemAttributes/index.d.ts +7 -0
- package/dist/components/LineItemAttributes/index.d.ts.map +1 -0
- package/dist/components/LineItemAttributes/index.js +24 -0
- package/dist/components/LineItemAttributes/index.js.map +1 -0
- package/dist/components/LineItemProductInfo/index.d.ts +14 -0
- package/dist/components/LineItemProductInfo/index.d.ts.map +1 -0
- package/dist/components/LineItemProductInfo/index.js +24 -0
- package/dist/components/LineItemProductInfo/index.js.map +1 -0
- package/dist/components/TotalCheckout/index.js +1 -1
- package/dist/components/TotalCheckout/index.js.map +1 -1
- package/dist/components/WarningMessageForPopup/index.js +3 -3
- package/dist/components/WarningMessageForPopup/index.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/account/AccountSettingsTemplate/AccountInfo/index.js +1 -1
- package/dist/modules/account/AccountSettingsTemplate/AccountInfo/index.js.map +1 -1
- package/dist/modules/account/AccountSettingsTemplate/AccountPassword/index.js +1 -1
- package/dist/modules/account/AccountSettingsTemplate/AccountPassword/index.js.map +1 -1
- package/dist/modules/account/AccountSettingsTemplate/Subscription/index.js +1 -1
- package/dist/modules/account/AccountSettingsTemplate/Subscription/index.js.map +1 -1
- package/dist/modules/address/AddressForm/index.d.ts.map +1 -1
- package/dist/modules/address/AddressForm/index.js +14 -11
- package/dist/modules/address/AddressForm/index.js.map +1 -1
- package/dist/modules/address/AddressForm/style.d.ts.map +1 -1
- package/dist/modules/address/AddressForm/style.js +71 -0
- package/dist/modules/address/AddressForm/style.js.map +1 -1
- package/dist/modules/address/AddressProvider.d.ts +2 -1
- package/dist/modules/address/AddressProvider.d.ts.map +1 -1
- package/dist/modules/address/AddressProvider.js +3 -2
- package/dist/modules/address/AddressProvider.js.map +1 -1
- package/dist/modules/address/SelectAddressPopup/index.js +1 -1
- package/dist/modules/address/SelectAddressPopup/index.js.map +1 -1
- package/dist/modules/address/ShippingBillingInfo/index.d.ts.map +1 -1
- package/dist/modules/address/ShippingBillingInfo/index.js +4 -33
- package/dist/modules/address/ShippingBillingInfo/index.js.map +1 -1
- package/dist/modules/auth/ForgotPasswordTemplate/index.js +1 -1
- package/dist/modules/auth/ForgotPasswordTemplate/index.js.map +1 -1
- package/dist/modules/auth/ResetPasswordTemplate/index.js +2 -2
- package/dist/modules/auth/ResetPasswordTemplate/index.js.map +1 -1
- package/dist/modules/auth/SignInTemplate/index.js +2 -2
- package/dist/modules/auth/SignInTemplate/index.js.map +1 -1
- package/dist/modules/auth/SignUpTemplate/index.d.ts.map +1 -1
- package/dist/modules/auth/SignUpTemplate/index.js +5 -5
- package/dist/modules/auth/SignUpTemplate/index.js.map +1 -1
- package/dist/modules/auth/SignUpTemplate/style.d.ts.map +1 -1
- package/dist/modules/auth/SignUpTemplate/style.js +6 -0
- package/dist/modules/auth/SignUpTemplate/style.js.map +1 -1
- package/dist/modules/auth/VerifyEmailAddressTemplate/index.js +1 -1
- package/dist/modules/auth/VerifyEmailAddressTemplate/index.js.map +1 -1
- package/dist/modules/cart/CartModificationWarningPopup/index.d.ts +6 -0
- package/dist/modules/cart/CartModificationWarningPopup/index.d.ts.map +1 -0
- package/dist/modules/cart/CartModificationWarningPopup/index.js +17 -0
- package/dist/modules/cart/CartModificationWarningPopup/index.js.map +1 -0
- package/dist/modules/cart/CartModificationWarningPopup/style.d.ts +3 -0
- package/dist/modules/cart/CartModificationWarningPopup/style.d.ts.map +1 -0
- package/dist/modules/cart/CartModificationWarningPopup/style.js +77 -0
- package/dist/modules/cart/CartModificationWarningPopup/style.js.map +1 -0
- package/dist/modules/cart/CartTemplate/index.d.ts +2 -1
- package/dist/modules/cart/CartTemplate/index.d.ts.map +1 -1
- package/dist/modules/cart/CartTemplate/index.js +2 -2
- package/dist/modules/cart/CartTemplate/index.js.map +1 -1
- package/dist/modules/cart/EmptyCart/index.d.ts.map +1 -1
- package/dist/modules/cart/EmptyCart/index.js +7 -3
- package/dist/modules/cart/EmptyCart/index.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/EditButton.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/EditButton.js +0 -1
- package/dist/modules/cart/components/CartItems/Item/EditButton.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemActions.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemActions.js +0 -1
- package/dist/modules/cart/components/CartItems/Item/ItemActions.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemAttributes.d.ts +3 -1
- package/dist/modules/cart/components/CartItems/Item/ItemAttributes.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemAttributes.js +11 -34
- package/dist/modules/cart/components/CartItems/Item/ItemAttributes.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemImage.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/ItemImage.js +0 -1
- package/dist/modules/cart/components/CartItems/Item/ItemImage.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/QuantitySelector.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/QuantitySelector.js +3 -12
- package/dist/modules/cart/components/CartItems/Item/QuantitySelector.js.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/index.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/Item/index.js +2 -5
- package/dist/modules/cart/components/CartItems/Item/index.js.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemActions.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemActions.js +0 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemActions.js.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemAttributes.d.ts +3 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemAttributes.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemAttributes.js +11 -34
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemAttributes.js.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemImage.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemImage.js +0 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemImage.js.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemQuantity.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemQuantity.js +3 -12
- package/dist/modules/cart/components/CartItems/ItemMobile/MobileItemQuantity.js.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/index.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/ItemMobile/index.js +2 -5
- package/dist/modules/cart/components/CartItems/ItemMobile/index.js.map +1 -1
- package/dist/modules/cart/components/CartItems/index.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/index.js +0 -1
- package/dist/modules/cart/components/CartItems/index.js.map +1 -1
- package/dist/modules/cart/components/CartItems/style.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/style.js +6 -3
- package/dist/modules/cart/components/CartItems/style.js.map +1 -1
- package/dist/modules/cart/components/CartItems/util.d.ts.map +1 -1
- package/dist/modules/cart/components/CartItems/util.js +1 -2
- package/dist/modules/cart/components/CartItems/util.js.map +1 -1
- package/dist/modules/cart/index.d.ts +1 -0
- package/dist/modules/cart/index.d.ts.map +1 -1
- package/dist/modules/cart/index.js +1 -0
- package/dist/modules/cart/index.js.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.d.ts.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js +2 -6
- package/dist/modules/checkout/CheckoutTemplate/StepReview/index.js.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/index.d.ts +2 -1
- package/dist/modules/checkout/CheckoutTemplate/index.d.ts.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/index.js +12 -6
- package/dist/modules/checkout/CheckoutTemplate/index.js.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/style.d.ts.map +1 -1
- package/dist/modules/checkout/CheckoutTemplate/style.js +6 -1
- package/dist/modules/checkout/CheckoutTemplate/style.js.map +1 -1
- package/dist/modules/checkout/PaymentFailedTemplate/index.d.ts.map +1 -1
- package/dist/modules/checkout/PaymentFailedTemplate/index.js +3 -0
- package/dist/modules/checkout/PaymentFailedTemplate/index.js.map +1 -1
- package/dist/modules/checkout/ThankYouTemplate/index.d.ts.map +1 -1
- package/dist/modules/checkout/ThankYouTemplate/index.js +3 -0
- package/dist/modules/checkout/ThankYouTemplate/index.js.map +1 -1
- package/dist/modules/delivery/DeliveryOptions/index.d.ts.map +1 -1
- package/dist/modules/delivery/DeliveryOptions/index.js +11 -212
- package/dist/modules/delivery/DeliveryOptions/index.js.map +1 -1
- package/dist/modules/index.d.ts +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/order/OrderDetails/index.d.ts.map +1 -1
- package/dist/modules/order/OrderDetails/index.js +0 -1
- package/dist/modules/order/OrderDetails/index.js.map +1 -1
- package/dist/modules/order/OrderIndividualTemplate/index.d.ts.map +1 -1
- package/dist/modules/order/OrderIndividualTemplate/index.js +2 -10
- package/dist/modules/order/OrderIndividualTemplate/index.js.map +1 -1
- package/dist/modules/order/OrderedItems/Item/index.d.ts.map +1 -1
- package/dist/modules/order/OrderedItems/Item/index.js +2 -30
- package/dist/modules/order/OrderedItems/Item/index.js.map +1 -1
- package/dist/modules/order/OrderedItems/ItemMobile/index.d.ts.map +1 -1
- package/dist/modules/order/OrderedItems/ItemMobile/index.js +2 -28
- package/dist/modules/order/OrderedItems/ItemMobile/index.js.map +1 -1
- package/dist/modules/order/OrderedItems/Review/Popup/style.js +1 -1
- package/dist/modules/order/OrderedItems/Review/index.js +1 -1
- package/dist/modules/order/OrderedItems/Review/index.js.map +1 -1
- package/dist/modules/order/OrderedItems/index.d.ts.map +1 -1
- package/dist/modules/order/OrderedItems/index.js +0 -1
- package/dist/modules/order/OrderedItems/index.js.map +1 -1
- package/dist/modules/order/OrderedItems/style.d.ts.map +1 -1
- package/dist/modules/order/OrderedItems/style.js +8 -3
- package/dist/modules/order/OrderedItems/style.js.map +1 -1
- package/dist/modules/order/OrdersList/Item/index.d.ts.map +1 -1
- package/dist/modules/order/OrdersList/Item/index.js +0 -1
- package/dist/modules/order/OrdersList/Item/index.js.map +1 -1
- package/dist/modules/order/OrdersList/ItemMobile/index.d.ts.map +1 -1
- package/dist/modules/order/OrdersList/ItemMobile/index.js +0 -1
- package/dist/modules/order/OrdersList/ItemMobile/index.js.map +1 -1
- package/dist/modules/order/OrdersList/index.d.ts.map +1 -1
- package/dist/modules/order/OrdersList/index.js +0 -1
- package/dist/modules/order/OrdersList/index.js.map +1 -1
- package/dist/modules/order/OrdersList/style.d.ts.map +1 -1
- package/dist/modules/order/OrdersList/style.js +0 -1
- package/dist/modules/order/OrdersList/style.js.map +1 -1
- package/dist/modules/payment/PaymentMethodIcon/index.d.ts +8 -0
- package/dist/modules/payment/PaymentMethodIcon/index.d.ts.map +1 -0
- package/dist/modules/payment/PaymentMethodIcon/index.js +17 -0
- package/dist/modules/payment/PaymentMethodIcon/index.js.map +1 -0
- package/dist/modules/payment/PaymentMethodIcon/style.d.ts +3 -0
- package/dist/modules/payment/PaymentMethodIcon/style.d.ts.map +1 -0
- package/dist/modules/payment/PaymentMethodIcon/style.js +25 -0
- package/dist/modules/payment/PaymentMethodIcon/style.js.map +1 -0
- package/dist/modules/payment/PaymentMethodItem/index.d.ts.map +1 -1
- package/dist/modules/payment/PaymentMethodItem/index.js +2 -13
- package/dist/modules/payment/PaymentMethodItem/index.js.map +1 -1
- package/dist/modules/payment/SelectPaymentMethodPopup/index.js +1 -1
- package/dist/modules/payment/SelectPaymentMethodPopup/index.js.map +1 -1
- package/dist/modules/payment/icons.d.ts +2 -0
- package/dist/modules/payment/icons.d.ts.map +1 -1
- package/dist/modules/payment/icons.js +35 -27
- package/dist/modules/payment/icons.js.map +1 -1
- package/dist/modules/payment/index.d.ts +1 -0
- package/dist/modules/payment/index.d.ts.map +1 -1
- package/dist/modules/payment/index.js +1 -0
- package/dist/modules/payment/index.js.map +1 -1
- package/dist/modules/payment/paymentIconMap.d.ts +12 -0
- package/dist/modules/payment/paymentIconMap.d.ts.map +1 -0
- package/dist/modules/payment/paymentIconMap.js +31 -0
- package/dist/modules/payment/paymentIconMap.js.map +1 -0
- package/dist/modules/unsubscribe/UnsubscribeMessage.js +1 -1
- package/dist/modules/unsubscribe/UnsubscribeMessage.js.map +1 -1
- package/dist/modules/unsubscribe/UnsubscribeTemplate.js +1 -1
- package/dist/modules/unsubscribe/UnsubscribeTemplate.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +5 -0
- package/dist/server.js.map +1 -0
- package/dist/stores/orderStore.d.ts.map +1 -1
- package/dist/stores/orderStore.js.map +1 -1
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +5 -0
- package/dist/styles/theme.js.map +1 -1
- package/dist/styles/variables.d.ts.map +1 -1
- package/dist/styles/variables.js +4 -0
- package/dist/styles/variables.js.map +1 -1
- package/dist/translations/en.d.ts +20 -7
- package/dist/translations/en.d.ts.map +1 -1
- package/dist/translations/en.js +21 -8
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/hy.d.ts +2 -7
- package/dist/translations/hy.d.ts.map +1 -1
- package/dist/translations/hy.js +3 -8
- package/dist/translations/hy.js.map +1 -1
- package/dist/translations/index.d.ts +26 -28
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/translations/it.d.ts +2 -7
- package/dist/translations/it.d.ts.map +1 -1
- package/dist/translations/it.js +3 -8
- package/dist/translations/it.js.map +1 -1
- package/dist/translations/ru.d.ts +2 -7
- package/dist/translations/ru.d.ts.map +1 -1
- package/dist/translations/ru.js +3 -8
- package/dist/translations/ru.js.map +1 -1
- package/dist/user/UserProvider.d.ts +6 -0
- package/dist/user/UserProvider.d.ts.map +1 -0
- package/dist/user/UserProvider.js +128 -0
- package/dist/user/UserProvider.js.map +1 -0
- package/dist/user/checkUserRedirection.d.ts +21 -0
- package/dist/user/checkUserRedirection.d.ts.map +1 -0
- package/dist/user/checkUserRedirection.js +62 -0
- package/dist/user/checkUserRedirection.js.map +1 -0
- package/dist/user/createUserMethods.d.ts +21 -0
- package/dist/user/createUserMethods.d.ts.map +1 -0
- package/dist/user/createUserMethods.js +162 -0
- package/dist/user/createUserMethods.js.map +1 -0
- package/dist/user/getUser.d.ts +14 -0
- package/dist/user/getUser.d.ts.map +1 -0
- package/dist/user/getUser.js +60 -0
- package/dist/user/getUser.js.map +1 -0
- package/dist/user/index.d.ts +6 -0
- package/dist/user/index.d.ts.map +1 -0
- package/dist/user/index.js +6 -0
- package/dist/user/index.js.map +1 -0
- package/dist/user/langPath.d.ts +3 -0
- package/dist/user/langPath.d.ts.map +1 -0
- package/dist/user/langPath.js +23 -0
- package/dist/user/langPath.js.map +1 -0
- package/dist/user/types.d.ts +139 -0
- package/dist/user/types.d.ts.map +1 -0
- package/dist/user/types.js +2 -0
- package/dist/user/types.js.map +1 -0
- package/dist/user/userConfig.d.ts +23 -0
- package/dist/user/userConfig.d.ts.map +1 -0
- package/dist/user/userConfig.js +24 -0
- package/dist/user/userConfig.js.map +1 -0
- package/dist/utils/buttonClassNames.d.ts +9 -0
- package/dist/utils/buttonClassNames.d.ts.map +1 -0
- package/dist/utils/buttonClassNames.js +10 -0
- package/dist/utils/buttonClassNames.js.map +1 -0
- package/dist/utils/buttonTypes.d.ts +12 -0
- package/dist/utils/buttonTypes.d.ts.map +1 -0
- package/dist/utils/buttonTypes.js +18 -0
- package/dist/utils/buttonTypes.js.map +1 -0
- package/dist/utils/config.d.ts +14 -7
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +35 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/createAccountButtonEntry.d.ts +5 -0
- package/dist/utils/createAccountButtonEntry.d.ts.map +1 -0
- package/dist/utils/createAccountButtonEntry.js +33 -0
- package/dist/utils/createAccountButtonEntry.js.map +1 -0
- package/dist/utils/lineItemDisplay.d.ts +11 -0
- package/dist/utils/lineItemDisplay.d.ts.map +1 -0
- package/dist/utils/lineItemDisplay.js +165 -0
- package/dist/utils/lineItemDisplay.js.map +1 -0
- package/dist/utils/payment.d.ts +56 -11
- package/dist/utils/payment.d.ts.map +1 -1
- package/dist/utils/payment.js +43 -5
- package/dist/utils/payment.js.map +1 -1
- package/package.json +30 -7
- package/templates/README.md +41 -0
- package/templates/account.config.example.ts +77 -0
- package/templates/address.config.example.ts +55 -0
- package/templates/index.example.ts +24 -0
- package/templates/integrations.config.example.ts +28 -0
- package/templates/routes.config.example.ts +56 -0
- package/templates/user.config.example.ts +45 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
8
|
+
const TEMPLATES_DIR = path.join(PACKAGE_ROOT, 'templates');
|
|
9
|
+
|
|
10
|
+
const TEMPLATE_MAP = {
|
|
11
|
+
routes: 'routes.config.example.ts',
|
|
12
|
+
integrations: 'integrations.config.example.ts',
|
|
13
|
+
user: 'user.config.example.ts',
|
|
14
|
+
account: 'account.config.example.ts',
|
|
15
|
+
address: 'address.config.example.ts',
|
|
16
|
+
index: 'index.example.ts',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ALL_KEYS = Object.keys(TEMPLATE_MAP);
|
|
20
|
+
|
|
21
|
+
const parseArgs = (argv) => {
|
|
22
|
+
const args = {
|
|
23
|
+
out: 'account-config',
|
|
24
|
+
only: null,
|
|
25
|
+
all: false,
|
|
26
|
+
force: false,
|
|
27
|
+
yes: false,
|
|
28
|
+
help: false,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
32
|
+
const arg = argv[i];
|
|
33
|
+
|
|
34
|
+
if (arg === '--help' || arg === '-h') {
|
|
35
|
+
args.help = true;
|
|
36
|
+
} else if (arg === '--all') {
|
|
37
|
+
args.all = true;
|
|
38
|
+
} else if (arg === '--force') {
|
|
39
|
+
args.force = true;
|
|
40
|
+
} else if (arg === '--yes' || arg === '-y') {
|
|
41
|
+
args.yes = true;
|
|
42
|
+
} else if (arg.startsWith('--out=')) {
|
|
43
|
+
args.out = arg.slice('--out='.length);
|
|
44
|
+
} else if (arg === '--out') {
|
|
45
|
+
args.out = argv[i + 1] || args.out;
|
|
46
|
+
i += 1;
|
|
47
|
+
} else if (arg.startsWith('--only=')) {
|
|
48
|
+
args.only = arg
|
|
49
|
+
.slice('--only='.length)
|
|
50
|
+
.split(',')
|
|
51
|
+
.map((key) => key.trim())
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
} else if (arg === '--only') {
|
|
54
|
+
args.only = (argv[i + 1] || '')
|
|
55
|
+
.split(',')
|
|
56
|
+
.map((key) => key.trim())
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
i += 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return args;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const printHelp = () => {
|
|
66
|
+
console.log(`
|
|
67
|
+
@weareconceptstudio/account — publish config examples
|
|
68
|
+
|
|
69
|
+
Usage:
|
|
70
|
+
npx account-init [options]
|
|
71
|
+
|
|
72
|
+
Options:
|
|
73
|
+
--out <dir> Output directory (default: ./account-config)
|
|
74
|
+
--all Publish all config files
|
|
75
|
+
--only <a,b,c> Publish subset: routes, integrations, user, account, address, index
|
|
76
|
+
--force Overwrite existing files
|
|
77
|
+
--yes, -y Skip confirmation prompts
|
|
78
|
+
--help, -h Show this help
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
npx account-init --all --out src/config/account
|
|
82
|
+
npx account-init --only routes,integrations,user --out src/config/account
|
|
83
|
+
|
|
84
|
+
Opt-in on install (non-interactive, for scripts/CI):
|
|
85
|
+
ACCOUNT_PUBLISH_CONFIG=1 npm install @weareconceptstudio/account
|
|
86
|
+
`);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const ask = (question) => {
|
|
90
|
+
const rl = readline.createInterface({
|
|
91
|
+
input: process.stdin,
|
|
92
|
+
output: process.stdout,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return new Promise((resolve) => {
|
|
96
|
+
rl.question(question, (answer) => {
|
|
97
|
+
rl.close();
|
|
98
|
+
resolve(answer.trim().toLowerCase());
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const askMulti = async () => {
|
|
104
|
+
console.log('\nWhich configs should be published?');
|
|
105
|
+
ALL_KEYS.forEach((key, index) => {
|
|
106
|
+
console.log(` ${index + 1}. ${key}`);
|
|
107
|
+
});
|
|
108
|
+
console.log(` ${ALL_KEYS.length + 1}. all`);
|
|
109
|
+
|
|
110
|
+
const answer = await ask('\nEnter numbers (e.g. 1,2,3) or "all" [all]: ');
|
|
111
|
+
|
|
112
|
+
if (!answer || answer === 'all') {
|
|
113
|
+
return ALL_KEYS;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const indexes = answer
|
|
117
|
+
.split(',')
|
|
118
|
+
.map((part) => Number(part.trim()))
|
|
119
|
+
.filter((num) => !Number.isNaN(num));
|
|
120
|
+
|
|
121
|
+
if (indexes.includes(ALL_KEYS.length + 1)) {
|
|
122
|
+
return ALL_KEYS;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return indexes.map((index) => ALL_KEYS[index - 1]).filter(Boolean);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const toOutputFilename = (templateFile) => {
|
|
129
|
+
return templateFile.replace('.example.ts', '.ts');
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const publishConfigs = async ({ out, keys, force, yes }) => {
|
|
133
|
+
const outputDir = path.resolve(process.cwd(), out);
|
|
134
|
+
|
|
135
|
+
if (!fs.existsSync(outputDir)) {
|
|
136
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const readmeSrc = path.join(TEMPLATES_DIR, 'README.md');
|
|
140
|
+
const readmeDest = path.join(outputDir, 'README.md');
|
|
141
|
+
|
|
142
|
+
if (fs.existsSync(readmeSrc)) {
|
|
143
|
+
if (!fs.existsSync(readmeDest) || force) {
|
|
144
|
+
fs.copyFileSync(readmeSrc, readmeDest);
|
|
145
|
+
console.log(` ✓ README.md`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (const key of keys) {
|
|
150
|
+
const templateFile = TEMPLATE_MAP[key];
|
|
151
|
+
|
|
152
|
+
if (!templateFile) {
|
|
153
|
+
console.warn(` ⚠ Unknown config key: ${key}`);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const src = path.join(TEMPLATES_DIR, templateFile);
|
|
158
|
+
const dest = path.join(outputDir, toOutputFilename(templateFile));
|
|
159
|
+
|
|
160
|
+
if (!fs.existsSync(src)) {
|
|
161
|
+
console.warn(` ⚠ Template missing: ${templateFile}`);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(dest) && !force) {
|
|
166
|
+
if (!yes) {
|
|
167
|
+
const overwrite = await ask(` ${path.basename(dest)} exists. Overwrite? (y/N): `);
|
|
168
|
+
|
|
169
|
+
if (overwrite !== 'y' && overwrite !== 'yes') {
|
|
170
|
+
console.log(` ↷ Skipped ${path.basename(dest)}`);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
console.log(` ↷ Skipped ${path.basename(dest)} (already exists, use --force)`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fs.copyFileSync(src, dest);
|
|
180
|
+
console.log(` ✓ ${path.basename(dest)}`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
console.log(`\nDone. Config examples published to: ${outputDir}`);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const run = async () => {
|
|
187
|
+
const args = parseArgs(process.argv.slice(2));
|
|
188
|
+
|
|
189
|
+
if (args.help) {
|
|
190
|
+
printHelp();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let keys = args.only;
|
|
195
|
+
|
|
196
|
+
if (args.all || !keys || keys.length === 0) {
|
|
197
|
+
if (args.yes || args.all) {
|
|
198
|
+
keys = ALL_KEYS;
|
|
199
|
+
} else if (process.stdin.isTTY) {
|
|
200
|
+
keys = await askMulti();
|
|
201
|
+
} else {
|
|
202
|
+
keys = ALL_KEYS;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
keys = [...new Set(keys)];
|
|
207
|
+
|
|
208
|
+
console.log(`\nPublishing account config examples to: ${path.resolve(process.cwd(), args.out)}\n`);
|
|
209
|
+
|
|
210
|
+
await publishConfigs({
|
|
211
|
+
out: args.out,
|
|
212
|
+
keys,
|
|
213
|
+
force: args.force,
|
|
214
|
+
yes: args.yes,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
run().catch((error) => {
|
|
219
|
+
console.error(error);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opt-in config publish on install.
|
|
5
|
+
*
|
|
6
|
+
* Enable explicitly (never prompts during a normal npm install):
|
|
7
|
+
* ACCOUNT_PUBLISH_CONFIG=1 npm install @weareconceptstudio/account
|
|
8
|
+
*
|
|
9
|
+
* Optional env:
|
|
10
|
+
* ACCOUNT_CONFIG_OUT=src/config/account
|
|
11
|
+
*/
|
|
12
|
+
if (process.env.ACCOUNT_PUBLISH_CONFIG !== '1') {
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { spawnSync } = require('child_process');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
const initScript = path.join(__dirname, 'init-config.js');
|
|
20
|
+
const outDir = process.env.ACCOUNT_CONFIG_OUT || 'account-config';
|
|
21
|
+
|
|
22
|
+
const result = spawnSync(
|
|
23
|
+
process.execPath,
|
|
24
|
+
[initScript, '--all', '--out', outDir, '--yes'],
|
|
25
|
+
{
|
|
26
|
+
stdio: 'inherit',
|
|
27
|
+
cwd: process.cwd(),
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
process.exit(result.status ?? 0);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Sanity checks for user integration helpers (run: npm run test:user-integration)
|
|
4
|
+
*/
|
|
5
|
+
import { resolveLocalizedPath, stripLocaleFromPathname } from '../dist/user/langPath.js';
|
|
6
|
+
|
|
7
|
+
const routes = {
|
|
8
|
+
signIn: { path: '/sign-in/' },
|
|
9
|
+
signUp: { path: '/sign-up/' },
|
|
10
|
+
forgotPassword: { path: '/forgot-password/' },
|
|
11
|
+
resetPassword: { path: '/reset-password/' },
|
|
12
|
+
account: { path: '/account/', private: true },
|
|
13
|
+
checkout: { path: '/checkout/', private: true },
|
|
14
|
+
home: { path: '/' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let passed = 0;
|
|
18
|
+
let failed = 0;
|
|
19
|
+
|
|
20
|
+
const assert = (name, condition) => {
|
|
21
|
+
if (condition) {
|
|
22
|
+
passed += 1;
|
|
23
|
+
console.log(` ✓ ${name}`);
|
|
24
|
+
} else {
|
|
25
|
+
failed += 1;
|
|
26
|
+
console.error(` ✗ ${name}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getRouteObjFromConfig = ({ pathname, lang, routes, defaultLocale }) => {
|
|
31
|
+
const privateRoutes = Object.values(routes || {}).filter((route) => route?.private === true);
|
|
32
|
+
const pathWithoutLang = stripLocaleFromPathname(pathname, lang, defaultLocale);
|
|
33
|
+
|
|
34
|
+
return privateRoutes.find((route) => {
|
|
35
|
+
const cleanRoute = route.path.replace(/\/$/, '');
|
|
36
|
+
const basePath = cleanRoute.split('/:')[0];
|
|
37
|
+
|
|
38
|
+
return pathWithoutLang === cleanRoute || pathWithoutLang?.startsWith(basePath);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const checkUserRedirection = ({
|
|
43
|
+
user,
|
|
44
|
+
pathname,
|
|
45
|
+
accessToken,
|
|
46
|
+
lang,
|
|
47
|
+
routes,
|
|
48
|
+
userIntegration = {},
|
|
49
|
+
}) => {
|
|
50
|
+
const {
|
|
51
|
+
authRouteKeys = ['signIn', 'signUp', 'forgotPassword', 'resetPassword'],
|
|
52
|
+
authenticatedAuthRedirectRouteKey = 'account',
|
|
53
|
+
defaultLocale,
|
|
54
|
+
} = userIntegration;
|
|
55
|
+
|
|
56
|
+
const locale = defaultLocale || 'en';
|
|
57
|
+
const authPaths = authRouteKeys.map((key) => routes?.[key]?.path).filter(Boolean);
|
|
58
|
+
const privateRoute = getRouteObjFromConfig({ pathname, lang, routes, defaultLocale: locale });
|
|
59
|
+
let redirectUrl;
|
|
60
|
+
|
|
61
|
+
const isAuthPage = (url) => authPaths.some((path) => url?.includes(path));
|
|
62
|
+
const hasUser = Boolean(user && (typeof user !== 'object' || Object.keys(user).length > 0));
|
|
63
|
+
|
|
64
|
+
if ((!hasUser && privateRoute) || (hasUser && !accessToken)) {
|
|
65
|
+
const signInPath = routes?.signIn?.path;
|
|
66
|
+
|
|
67
|
+
if (privateRoute && signInPath) {
|
|
68
|
+
const returnPath = resolveLocalizedPath(lang, privateRoute.path, locale);
|
|
69
|
+
const signInUrl = resolveLocalizedPath(lang, signInPath, locale);
|
|
70
|
+
|
|
71
|
+
redirectUrl = `${signInUrl}?r=${encodeURIComponent(returnPath)}`;
|
|
72
|
+
} else if (signInPath) {
|
|
73
|
+
redirectUrl = resolveLocalizedPath(lang, signInPath, locale);
|
|
74
|
+
}
|
|
75
|
+
} else if (hasUser && pathname && isAuthPage(pathname)) {
|
|
76
|
+
const accountPath = routes?.[authenticatedAuthRedirectRouteKey]?.path || routes?.account?.path;
|
|
77
|
+
|
|
78
|
+
if (accountPath) {
|
|
79
|
+
redirectUrl = resolveLocalizedPath(lang, accountPath, locale);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return redirectUrl;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
console.log('\nresolveLocalizedPath');
|
|
87
|
+
assert('en default → /sign-in/', resolveLocalizedPath('en', '/sign-in/', 'en') === '/sign-in/');
|
|
88
|
+
assert('ru → /ru/sign-in/', resolveLocalizedPath('ru', '/sign-in/', 'en') === '/ru/sign-in/');
|
|
89
|
+
assert('hy default → /account/', resolveLocalizedPath('hy', '/account/', 'hy') === '/account/');
|
|
90
|
+
|
|
91
|
+
console.log('\nstripLocaleFromPathname');
|
|
92
|
+
assert('as-needed /account/', stripLocaleFromPathname('/account/', 'en', 'en') === '/account');
|
|
93
|
+
assert('prefixed /en/account/', stripLocaleFromPathname('/en/account/', 'en', 'en') === '/account');
|
|
94
|
+
assert('ru /ru/account/', stripLocaleFromPathname('/ru/account/', 'ru', 'en') === '/account');
|
|
95
|
+
|
|
96
|
+
console.log('\ngetRouteObjFromConfig');
|
|
97
|
+
assert(
|
|
98
|
+
'private /account/',
|
|
99
|
+
getRouteObjFromConfig({ pathname: '/account/', lang: 'en', routes, defaultLocale: 'en' })?.path === '/account/'
|
|
100
|
+
);
|
|
101
|
+
assert(
|
|
102
|
+
'private /en/account/',
|
|
103
|
+
getRouteObjFromConfig({ pathname: '/en/account/', lang: 'en', routes, defaultLocale: 'en' })?.path === '/account/'
|
|
104
|
+
);
|
|
105
|
+
assert(
|
|
106
|
+
'private /ru/account/',
|
|
107
|
+
getRouteObjFromConfig({ pathname: '/ru/account/', lang: 'ru', routes, defaultLocale: 'en' })?.path === '/account/'
|
|
108
|
+
);
|
|
109
|
+
assert(
|
|
110
|
+
'public /tours/',
|
|
111
|
+
!getRouteObjFromConfig({ pathname: '/tours/', lang: 'en', routes, defaultLocale: 'en' })
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
console.log('\ncheckUserRedirection');
|
|
115
|
+
assert(
|
|
116
|
+
'guest on private → sign-in with return url',
|
|
117
|
+
checkUserRedirection({
|
|
118
|
+
user: null,
|
|
119
|
+
pathname: '/account/',
|
|
120
|
+
accessToken: null,
|
|
121
|
+
lang: 'en',
|
|
122
|
+
routes,
|
|
123
|
+
userIntegration: { defaultLocale: 'en' },
|
|
124
|
+
}) === '/sign-in/?r=%2Faccount%2F'
|
|
125
|
+
);
|
|
126
|
+
assert(
|
|
127
|
+
'logged-in on auth → account',
|
|
128
|
+
checkUserRedirection({
|
|
129
|
+
user: { id: 1 },
|
|
130
|
+
pathname: '/sign-in/',
|
|
131
|
+
accessToken: 'token',
|
|
132
|
+
lang: 'en',
|
|
133
|
+
routes,
|
|
134
|
+
userIntegration: { defaultLocale: 'en' },
|
|
135
|
+
}) === '/account/'
|
|
136
|
+
);
|
|
137
|
+
assert(
|
|
138
|
+
'ru private route',
|
|
139
|
+
checkUserRedirection({
|
|
140
|
+
user: null,
|
|
141
|
+
pathname: '/ru/checkout/',
|
|
142
|
+
accessToken: null,
|
|
143
|
+
lang: 'ru',
|
|
144
|
+
routes,
|
|
145
|
+
userIntegration: { defaultLocale: 'en' },
|
|
146
|
+
}) === '/ru/sign-in/?r=%2Fru%2Fcheckout%2F'
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
console.log(`\n${passed} passed, ${failed} failed\n`);
|
|
150
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProvider.d.ts","sourceRoot":"","sources":["../src/AccountProvider.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccountProvider.d.ts","sourceRoot":"","sources":["../src/AccountProvider.js"],"names":[],"mappings":"AA6BO,yCAIN;AAEM;;;sBA4HN;kBA/JiF,OAAO"}
|
package/dist/AccountProvider.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useEffect, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { registerPackageTranslationsModule, useMergedConfig, usePackageTranslations, useTranslation, useUi, } from '@weareconceptstudio/core';
|
|
3
3
|
import { ThemeProvider } from 'styled-components';
|
|
4
4
|
import { AddressProvider } from './modules/address/AddressProvider';
|
|
5
5
|
import { initCartStore } from '@weareconceptstudio/cart';
|
|
6
6
|
import { CartPageDetector } from './components/CartPageDetector';
|
|
7
7
|
import { initOrderStore } from './stores/orderStore';
|
|
8
|
-
|
|
8
|
+
import { useUser as packageUseUser } from './user/UserProvider';
|
|
9
9
|
import translations from './translations';
|
|
10
10
|
//* Config
|
|
11
11
|
import { accountConfig } from './utils/config';
|
|
@@ -14,17 +14,19 @@ import theme from './styles/theme';
|
|
|
14
14
|
import AccountHelperClass from './styles/helperClass';
|
|
15
15
|
import AccountVariables from './styles/variables';
|
|
16
16
|
import AccountTypography from './styles/typography';
|
|
17
|
+
registerPackageTranslationsModule(translations, 'prepend');
|
|
17
18
|
const AccountContext = createContext(null);
|
|
18
19
|
export const useAccountContext = () => {
|
|
19
20
|
const context = useContext(AccountContext);
|
|
20
21
|
return context;
|
|
21
22
|
};
|
|
22
|
-
// TODO: NEW VERSIONS
|
|
23
23
|
export const AccountProvider = ({ children, ...props }) => {
|
|
24
|
-
const {
|
|
24
|
+
const { selectedLang } = useTranslation();
|
|
25
25
|
const { openPopup } = useUi();
|
|
26
|
-
|
|
27
|
-
const
|
|
26
|
+
usePackageTranslations(translations, 'prepend');
|
|
27
|
+
const contextValue = useMergedConfig(accountConfig, props);
|
|
28
|
+
const useUserFn = contextValue.useUser || packageUseUser;
|
|
29
|
+
const { isLoggedIn, user } = useUserFn();
|
|
28
30
|
// Initialize order store endpoints
|
|
29
31
|
useEffect(() => {
|
|
30
32
|
if (contextValue.orderIntegration) {
|
|
@@ -40,6 +42,7 @@ export const AccountProvider = ({ children, ...props }) => {
|
|
|
40
42
|
supportsGuestCart,
|
|
41
43
|
hasGifts,
|
|
42
44
|
hasUtensils,
|
|
45
|
+
abandonPaymentEndpoint: contextValue.checkout?.abandonPaymentEndpoint || null,
|
|
43
46
|
}, isLoggedIn, selectedLang, user);
|
|
44
47
|
const isCartOrCheckoutPage = typeof window !== 'undefined' &&
|
|
45
48
|
(window.location.href.includes('cart') || window.location.href.includes('checkout'));
|
|
@@ -67,9 +70,6 @@ export const AccountProvider = ({ children, ...props }) => {
|
|
|
67
70
|
}
|
|
68
71
|
});
|
|
69
72
|
}, [contextValue.globalSettings.hasVariants, isLoggedIn, selectedLang, user]);
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
addTranslation(translations, 'prepend');
|
|
72
|
-
}, []);
|
|
73
73
|
const handleProductClick = useCallback((product, clickMode = 'url') => {
|
|
74
74
|
if (contextValue.productUrlPrefix && typeof window !== 'undefined' && clickMode === 'url') {
|
|
75
75
|
const slugCandidate = product?.slug ?? product?.handle ?? product?.url_key ?? product?.productSlug;
|
|
@@ -88,9 +88,12 @@ export const AccountProvider = ({ children, ...props }) => {
|
|
|
88
88
|
const isDeliveryEnabled = useMemo(() => {
|
|
89
89
|
return contextValue.delivery?.enabled !== false;
|
|
90
90
|
}, [contextValue]);
|
|
91
|
-
|
|
91
|
+
const isFulfillmentEnabled = useMemo(() => {
|
|
92
|
+
return Boolean(contextValue.fulfillment);
|
|
93
|
+
}, [contextValue]);
|
|
94
|
+
return (React.createElement(AccountContext.Provider, { value: { ...contextValue, useUser: useUserFn, handleProductClick, isDeliveryEnabled, isFulfillmentEnabled } },
|
|
92
95
|
React.createElement(CartPageDetector, null),
|
|
93
|
-
React.createElement(AddressProvider, { useUser:
|
|
96
|
+
React.createElement(AddressProvider, { useUser: useUserFn, hasAddresses: contextValue.globalSettings.hasAddresses, addressType: contextValue.globalSettings.hasAddressType, addressFormFields: contextValue.addressFormFields, addressFormFieldsShipping: contextValue.addressFormFieldsShipping, addressFormFieldsBilling: contextValue.addressFormFieldsBilling, addressFormSidePanel: contextValue.addressFormSidePanel },
|
|
94
97
|
React.createElement(ThemeProvider, { theme: theme },
|
|
95
98
|
React.createElement(AccountVariables, { fontFamily: contextValue.fontFamily }),
|
|
96
99
|
React.createElement(AccountHelperClass, null),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountProvider.js","sourceRoot":"","sources":["../src/AccountProvider.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1F,OAAO,
|
|
1
|
+
{"version":3,"file":"AccountProvider.js","sourceRoot":"","sources":["../src/AccountProvider.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1F,OAAO,EACN,iCAAiC,EACjC,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,KAAK,GACL,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,UAAU;AACV,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,UAAU;AACV,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,iCAAiC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE3D,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAA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BAAiB,EAAE,oBAAoB,EAAE;QAC3G,oBAAC,gBAAgB,OAAG;QACpB,oBAAC,eAAe,IACf,OAAO,EAAE,SAAS,EAClB,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,YAAY,EACtD,WAAW,EAAE,YAAY,CAAC,cAAc,CAAC,cAAc,EACvD,iBAAiB,EAAE,YAAY,CAAC,iBAAiB,EACjD,yBAAyB,EAAE,YAAY,CAAC,yBAAyB,EACjE,wBAAwB,EAAE,YAAY,CAAC,wBAAwB,EAC/D,oBAAoB,EAAE,YAAY,CAAC,oBAAoB;YACvD,oBAAC,aAAa,IAAC,KAAK,EAAE,KAAK;gBAC1B,oBAAC,gBAAgB,IAAC,UAAU,EAAE,YAAY,CAAC,UAAU,GAAI;gBACzD,oBAAC,kBAAkB,OAAG;gBACtB,oBAAC,iBAAiB,OAAG;gBAEpB,QAAQ,CACM,CACC,CACO,CAC1B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AccountButton/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AccountButton/index.js"],"names":[],"mappings":";AAeA,8DA2GC;kBA1H2C,OAAO"}
|
|
@@ -2,11 +2,19 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Link, useTranslation } from '@weareconceptstudio/core';
|
|
4
4
|
import { googleIcon } from './icons';
|
|
5
|
-
import AccountButtonStyle from './style';
|
|
5
|
+
import AccountButtonStyle, { AccountButtonCustomWrap } from './style';
|
|
6
6
|
import { accountConfig } from '../../utils/config';
|
|
7
|
+
import { useAccountContext } from '../../AccountProvider';
|
|
8
|
+
import { ACCOUNT_BUTTON_TYPES, getAccountButtonLayout } from '../../utils/buttonTypes';
|
|
9
|
+
/** Legacy wrapper classes so existing `.btn-wrap.full-width` CSS keeps working in other projects */
|
|
10
|
+
const LEGACY_WRAPPER_ALIASES = {
|
|
11
|
+
[ACCOUNT_BUTTON_TYPES.AUTH]: ACCOUNT_BUTTON_TYPES.FULL_WIDTH,
|
|
12
|
+
[ACCOUNT_BUTTON_TYPES.CHECKOUT]: ACCOUNT_BUTTON_TYPES.FULL_WIDTH,
|
|
13
|
+
};
|
|
7
14
|
const AccountButton = (props) => {
|
|
8
15
|
const { btnType, text, className, onClick, children, url, customLinkProps, target, type = 'button', disabled = false, svg_icon, loading = false, isGoogleAuth = false, } = props;
|
|
9
16
|
const { translate } = useTranslation();
|
|
17
|
+
const { button: buttonConfig = accountConfig.button } = useAccountContext() || {};
|
|
10
18
|
const Component = useMemo(() => (url ? Link : 'button'), [url]);
|
|
11
19
|
const customProps = useMemo(() => (url ? { ...customLinkProps, url, target } : { type, disabled }), [url, type, disabled]);
|
|
12
20
|
const classString = classNames('btn-wrap', {
|
|
@@ -19,10 +27,30 @@ const AccountButton = (props) => {
|
|
|
19
27
|
const handleClick = useCallback(() => {
|
|
20
28
|
return !disabled && onClick?.();
|
|
21
29
|
}, [onClick, disabled]);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
30
|
+
const customEntry = buttonConfig[btnType];
|
|
31
|
+
if (customEntry?.component) {
|
|
32
|
+
const accountButtonLayout = getAccountButtonLayout(btnType);
|
|
33
|
+
const componentProps = {
|
|
34
|
+
children,
|
|
35
|
+
text: translate(text),
|
|
36
|
+
loading,
|
|
37
|
+
disabled,
|
|
38
|
+
onClick: handleClick,
|
|
39
|
+
accountButtonLayout,
|
|
40
|
+
};
|
|
41
|
+
const ComponentOutside = customEntry.component;
|
|
42
|
+
const { className: configClassName, ...configProps } = customEntry.props || {};
|
|
43
|
+
const wrapperClass = classNames('btn-wrap', btnType, customEntry.wrapperClassName, customEntry.legacyBtnType ?? LEGACY_WRAPPER_ALIASES[btnType], className, {
|
|
44
|
+
loading,
|
|
45
|
+
disabled,
|
|
46
|
+
'account-google-btn': isGoogleAuth,
|
|
47
|
+
});
|
|
48
|
+
const buttonClass = classNames(configClassName, {
|
|
49
|
+
loading,
|
|
50
|
+
disabled,
|
|
51
|
+
});
|
|
52
|
+
return (React.createElement(AccountButtonCustomWrap, { className: wrapperClass, "data-account-button-layout": accountButtonLayout },
|
|
53
|
+
React.createElement(ComponentOutside, { ...customProps, ...componentProps, ...configProps, className: buttonClass })));
|
|
26
54
|
}
|
|
27
55
|
return (React.createElement(AccountButtonStyle, { onClick: handleClick, className: `${classString}` },
|
|
28
56
|
React.createElement(Component, { ...customProps },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AccountButton/index.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,kBAAkB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AccountButton/index.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,kBAAkB,EAAE,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,sBAAs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ACpB,SAAS,EAAE,GAAG,WAAW,EAAE;QAC3B,oBAAC,SAAS,OAAK,WAAW;YACxB,OAAO,CAAC,CAAC,CAAC,CACV,6BAAK,SAAS,EAAC,wBAAwB;gBACtC,6BAAK,SAAS,EAAC,QAAQ,GAAO,CACzB,CACN,CAAC,CAAC,CAAC,IAAI;YAER,6BAAK,SAAS,EAAE,kBAAkB,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,IAC1D,YAAY,CAAC,CAAC,CAAC,CACf,6BAAK,SAAS,EAAE,sBAAsB;gBACpC,UAAU;gBACX,8BAAM,SAAS,EAAE,aAAa,aAAe,CACxC,CACN,CAAC,CAAC,CAAC,CACH,QAAQ,IAAI,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CACvC,CACI,CACK,CACQ,CACrB,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Wrapper when a project provides a custom button component via accountConfig.button */
|
|
2
|
+
export const AccountButtonCustomWrap: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
1
3
|
export default AccountButtonStyle;
|
|
2
4
|
declare const AccountButtonStyle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
3
5
|
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/components/AccountButton/style.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/components/AccountButton/style.js"],"names":[],"mappings":"AAMA,yFAAyF;AACzF,qPAmDE;;AAEF,iPAieE"}
|