@ikas/storefront 1.0.21 → 2.0.0-alpha.1
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/build/ikas +12055 -0
- package/package.json +22 -21
- package/src/.DS_Store +0 -0
- package/src/__generated__/global-types.ts +753 -0
- package/src/analytics/analytics.ts +497 -0
- package/src/analytics/events.ts +115 -0
- package/src/analytics/facebookPixel.ts +226 -0
- package/src/analytics/googleTagManager.ts +334 -0
- package/src/analytics/head/index.tsx +81 -0
- package/src/analytics/ikas.ts +545 -0
- package/{build/analytics/index.d.ts → src/analytics/index.ts} +2 -2
- package/src/api/.DS_Store +0 -0
- package/src/api/apollo.ts +91 -0
- package/src/api/back-in-stock-reminder/__generated__/listProductBackInStockRemind.ts +36 -0
- package/src/api/back-in-stock-reminder/__generated__/saveProductBackInStockRemind.ts +31 -0
- package/src/api/back-in-stock-reminder/index.ts +131 -0
- package/src/api/blog/__generated__/getBlog.ts +101 -0
- package/src/api/blog/__generated__/listBlog.ts +104 -0
- package/src/api/blog/__generated__/listBlogCategory.ts +52 -0
- package/src/api/blog/__generated__/listBlogMetaData.ts +42 -0
- package/src/api/blog/index.ts +415 -0
- package/src/api/brand/__generated__/listProductBrand.ts +63 -0
- package/src/api/brand/index.ts +127 -0
- package/src/api/cart/__generated__/getCart.ts +104 -0
- package/src/api/cart/__generated__/saveItemToCart.ts +91 -0
- package/src/api/cart/index.ts +213 -0
- package/src/api/category/__generated__/listCategory.ts +68 -0
- package/src/api/category/__generated__/listCategoryPaths.ts +37 -0
- package/src/api/category/index.ts +223 -0
- package/src/api/checkout/__generated__/addCouponCodeToCheckout.ts +22 -0
- package/src/api/checkout/__generated__/checkStocks.ts +31 -0
- package/src/api/checkout/__generated__/createSaleTransactionWithCheckout.ts +35 -0
- package/src/api/checkout/__generated__/getCheckoutByCartId.ts +21 -0
- package/src/api/checkout/__generated__/getCheckoutById.ts +270 -0
- package/src/api/checkout/__generated__/getOrder.ts +248 -0
- package/src/api/checkout/__generated__/listCheckoutSettings.ts +48 -0
- package/src/api/checkout/__generated__/listPaymentGateway.ts +57 -0
- package/src/api/checkout/__generated__/retrieveInstallmentInfo.ts +36 -0
- package/src/api/checkout/__generated__/saveCheckout.ts +23 -0
- package/src/api/checkout/index.ts +884 -0
- package/src/api/city/__generated__/listCity.ts +26 -0
- package/src/api/city/index.ts +56 -0
- package/src/api/contact-form/__generated__/sendContactFormToMerchant.ts +19 -0
- package/src/api/contact-form/index.ts +54 -0
- package/src/api/country/__generated__/getAvailableShippingCountries.ts +16 -0
- package/src/api/country/__generated__/getMyCountry.ts +12 -0
- package/src/api/country/__generated__/listCountry.ts +36 -0
- package/src/api/country/index.ts +129 -0
- package/src/api/customer/__generated__/checkCustomerEmail.ts +21 -0
- package/src/api/customer/__generated__/createCustomerEmailSubscription.ts +23 -0
- package/src/api/customer/__generated__/createOrderRefundRequest.ts +248 -0
- package/src/api/customer/__generated__/customerForgotPassword.ts +17 -0
- package/src/api/customer/__generated__/customerLogin.ts +88 -0
- package/src/api/customer/__generated__/customerRecoverPassword.ts +18 -0
- package/src/api/customer/__generated__/customerRefreshToken.ts +22 -0
- package/src/api/customer/__generated__/getCustomerOrders.ts +248 -0
- package/src/api/customer/__generated__/getLastViewedProducts.ts +27 -0
- package/src/api/customer/__generated__/getMyCustomer.ts +75 -0
- package/src/api/customer/__generated__/listOrderRefundSettings.ts +25 -0
- package/src/api/customer/__generated__/listOrderTransactions.ts +68 -0
- package/src/api/customer/__generated__/registerCustomer.ts +90 -0
- package/src/api/customer/__generated__/saveLastViewedProducts.ts +23 -0
- package/src/api/customer/__generated__/saveMyCustomer.ts +80 -0
- package/src/api/customer/index.ts +1147 -0
- package/src/api/customer-review/__generated__/createCustomerReview.ts +23 -0
- package/src/api/customer-review/__generated__/listCustomerReviews.ts +38 -0
- package/src/api/customer-review/index.ts +122 -0
- package/src/api/district/__generated__/listDistrict.ts +25 -0
- package/src/api/district/index.ts +59 -0
- package/src/api/favorite-product/__generated__/isFavoriteProduct.ts +16 -0
- package/src/api/favorite-product/__generated__/listFavoriteProducts.ts +22 -0
- package/src/api/favorite-product/__generated__/saveFavoriteProduct.ts +17 -0
- package/src/api/favorite-product/index.ts +100 -0
- package/src/api/html-meta-data/__generated__/listHTMLMetaData.ts +30 -0
- package/src/api/html-meta-data/index.ts +72 -0
- package/src/api/index.ts +23 -0
- package/src/api/merchant/__generated__/listMerchantSettings.ts +19 -0
- package/src/api/merchant/index.ts +43 -0
- package/src/api/product-attribute/__generated__/listProductAttribute.ts +54 -0
- package/src/api/product-attribute/index.ts +69 -0
- package/src/api/product-option-set/__generated__/ListProductOptionSet.ts +111 -0
- package/src/api/product-option-set/index.ts +114 -0
- package/src/api/product-search/__generated__/getProductFilterData.ts +69 -0
- package/src/api/product-search/__generated__/searchProducts.ts +40 -0
- package/src/api/product-search/index.ts +329 -0
- package/src/api/raffle/__generated__/getRafflesByCustomerId.ts +55 -0
- package/src/api/raffle/__generated__/listRaffle.ts +74 -0
- package/src/api/raffle/__generated__/listRaffleMetaData.ts +33 -0
- package/src/api/raffle/__generated__/saveRaffleParticipant.ts +43 -0
- package/src/api/raffle/index.ts +369 -0
- package/src/api/state/__generated__/listState.ts +25 -0
- package/src/api/state/index.ts +45 -0
- package/src/api/stock-location/__generated__/listStockLocation.ts +17 -0
- package/src/api/stock-location/index.ts +30 -0
- package/src/api/storefront/__generated__/getStorefront.ts +67 -0
- package/src/api/storefront/index.ts +76 -0
- package/src/api/variant-type/__generated__/listVariantType.ts +54 -0
- package/src/api/variant-type/index.ts +86 -0
- package/{build → src}/assets/translations/checkout/en.js +0 -0
- package/{build → src}/assets/translations/checkout/tr.js +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/checkout/components/address-form/index.tsx +360 -0
- package/src/components/checkout/components/address-form/model.ts +366 -0
- package/src/components/checkout/components/button/index.tsx +34 -0
- package/src/components/checkout/components/button/style.module.scss +103 -0
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +146 -0
- package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +107 -0
- package/src/components/checkout/components/cart-summary/index.tsx +458 -0
- package/src/components/checkout/components/cart-summary/style.module.scss +237 -0
- package/src/components/checkout/components/checkbox/check.tsx +23 -0
- package/src/components/checkout/components/checkbox/index.tsx +50 -0
- package/src/components/checkout/components/checkbox/style.module.scss +72 -0
- package/src/components/checkout/components/credit-card-form/index.tsx +121 -0
- package/src/components/checkout/components/credit-card-form/model.ts +56 -0
- package/src/components/checkout/components/credit-card-form/style.module.scss +6 -0
- package/src/components/checkout/components/credit-card-form/svg/amex.tsx +30 -0
- package/src/components/checkout/components/credit-card-form/svg/master-card.tsx +38 -0
- package/src/components/checkout/components/credit-card-form/svg/troy.tsx +54 -0
- package/src/components/checkout/components/credit-card-form/svg/visa.tsx +46 -0
- package/src/components/checkout/components/customer-addresses/index.tsx +167 -0
- package/src/components/checkout/components/customer-addresses/model.ts +126 -0
- package/src/components/checkout/components/customer-addresses/style.module.scss +20 -0
- package/src/components/checkout/components/error/customer-login-required-error/index.tsx +23 -0
- package/src/components/checkout/components/error/index.tsx +54 -0
- package/src/components/checkout/components/error/no-shipping-error/index.tsx +19 -0
- package/src/components/checkout/components/error/payment-error/index.tsx +21 -0
- package/src/components/checkout/components/error/stock-error/index.tsx +72 -0
- package/src/components/checkout/components/error/stock-error/style.module.scss +11 -0
- package/src/components/checkout/components/error/unknown-error/index.tsx +19 -0
- package/src/components/checkout/components/expandable-section/index.tsx +37 -0
- package/src/components/checkout/components/expandable-section/style.module.scss +29 -0
- package/src/components/checkout/components/form-item/caret-down.tsx +20 -0
- package/src/components/checkout/components/form-item/index.tsx +205 -0
- package/src/components/checkout/components/form-item/model.ts +131 -0
- package/src/components/checkout/components/form-item/style.module.scss +213 -0
- package/src/components/checkout/components/fullscreen-loading/index.tsx +10 -0
- package/src/components/checkout/components/fullscreen-loading/style.module.scss +56 -0
- package/src/components/checkout/components/input-with-button/index.tsx +53 -0
- package/src/components/checkout/components/input-with-button/style.module.scss +104 -0
- package/src/components/checkout/components/modal/index.tsx +50 -0
- package/src/components/checkout/components/modal/style.module.scss +68 -0
- package/src/components/checkout/components/notification-box/index.tsx +70 -0
- package/src/components/checkout/components/notification-box/style.module.scss +69 -0
- package/src/components/checkout/components/select-box/index.tsx +60 -0
- package/src/components/checkout/components/select-box/style.module.scss +55 -0
- package/src/components/checkout/components/step-container/index.tsx +107 -0
- package/src/components/checkout/components/step-container/style.module.scss +86 -0
- package/src/components/checkout/components/svg/arrow-down.tsx +23 -0
- package/src/components/checkout/components/svg/arrow-left.tsx +23 -0
- package/src/components/checkout/components/svg/arrow-right.tsx +23 -0
- package/src/components/checkout/components/svg/cross.tsx +23 -0
- package/src/components/checkout/components/svg/discount.tsx +34 -0
- package/src/components/checkout/components/svg/external.tsx +101 -0
- package/src/components/checkout/components/svg/gift.tsx +40 -0
- package/src/components/checkout/components/svg/ikas.tsx +39 -0
- package/src/components/checkout/components/svg/lock.tsx +23 -0
- package/src/components/checkout/components/svg/shopping-cart.tsx +23 -0
- package/src/components/checkout/components/svg/success-circle.tsx +26 -0
- package/src/components/checkout/components/svg/tag.tsx +23 -0
- package/src/components/checkout/components/svg/warning.tsx +30 -0
- package/src/components/checkout/components/toggle/index.tsx +51 -0
- package/src/components/checkout/components/toggle/style.module.scss +75 -0
- package/src/components/checkout/components/tooltip/index.tsx +27 -0
- package/src/components/checkout/components/tooltip/style.module.scss +86 -0
- package/src/components/checkout/index.tsx +476 -0
- package/src/components/checkout/model.ts +1007 -0
- package/src/components/checkout/steps/step-info/index.tsx +84 -0
- package/src/components/checkout/steps/step-payment/billing-address/index.tsx +40 -0
- package/src/components/checkout/steps/step-payment/index.tsx +105 -0
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +116 -0
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +51 -0
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/style.module.scss +50 -0
- package/src/components/checkout/steps/step-payment/payment-gateways/style.module.scss +15 -0
- package/src/components/checkout/steps/step-payment/style.module.scss +32 -0
- package/src/components/checkout/steps/step-shipping/index.tsx +127 -0
- package/src/components/checkout/steps/step-shipping/style.module.scss +44 -0
- package/src/components/checkout/steps/step-success/index.tsx +437 -0
- package/src/components/checkout/steps/step-success/style.module.scss +160 -0
- package/src/components/checkout/style.module.scss +358 -0
- package/src/components/checkout/styles/common.module.scss +59 -0
- package/src/components/checkout/styles/variables.scss +40 -0
- package/src/components/image/index.tsx +79 -0
- package/src/components/index.ts +4 -0
- package/src/components/page/ThemeComponent.tsx +89 -0
- package/src/components/page/head.tsx +294 -0
- package/src/components/page/index.tsx +216 -0
- package/src/components/page-editor/ThemeComponentEditor.tsx +236 -0
- package/src/components/page-editor/error/index.tsx +18 -0
- package/src/components/page-editor/index.tsx +70 -0
- package/src/components/page-editor/loader/index.tsx +10 -0
- package/src/components/page-editor/loader/style.module.scss +55 -0
- package/src/components/page-editor/model.ts +505 -0
- package/src/index.ts +8 -0
- package/src/models/.DS_Store +0 -0
- package/src/models/data/blog/index.ts +154 -0
- package/src/models/data/brand/index.ts +58 -0
- package/src/models/data/cart/index.ts +82 -0
- package/src/models/data/category/index.ts +130 -0
- package/src/models/data/checkout/index.ts +222 -0
- package/src/models/data/checkout-settings/index.ts +48 -0
- package/src/models/data/city/index.ts +4 -0
- package/src/models/data/contact-form/index.ts +17 -0
- package/src/models/data/country/index.ts +8 -0
- package/src/models/data/customer/address/index.tsx +135 -0
- package/src/models/data/customer/index.ts +65 -0
- package/src/models/data/customer-review/index.ts +43 -0
- package/src/models/data/customer-review-settings/index.ts +4 -0
- package/src/models/data/district/index.ts +4 -0
- package/src/models/data/favorite-product/index.ts +15 -0
- package/src/models/data/html-meta-data/index.ts +56 -0
- package/src/models/data/image/index.ts +34 -0
- package/src/models/data/index.ts +55 -0
- package/src/models/data/installment-info/index.ts +34 -0
- package/src/models/data/merchant-settings/index.ts +14 -0
- package/src/models/data/order/address/index.ts +138 -0
- package/src/models/data/order/adjustment/index.ts +17 -0
- package/src/models/data/order/gift-line/index.ts +4 -0
- package/src/models/data/order/index.ts +289 -0
- package/src/models/data/order/line-item/discount/index.ts +15 -0
- package/src/models/data/order/line-item/index.ts +123 -0
- package/src/models/data/order/line-item/options/index.ts +18 -0
- package/src/models/data/order/line-item/options/options-value/index.ts +11 -0
- package/src/models/data/order/line-item/variant/index.ts +75 -0
- package/src/models/data/order/refund/index.ts +18 -0
- package/src/models/data/order/refund/refund-line-item/index.ts +13 -0
- package/src/models/data/order/refund/settings.ts +15 -0
- package/src/models/data/order/shipping-line/index.ts +7 -0
- package/src/models/data/order-transaction/index.ts +105 -0
- package/src/models/data/payment-gateway/index.ts +150 -0
- package/src/models/data/product/attribute-value/index.ts +42 -0
- package/src/models/data/product/index.ts +95 -0
- package/src/models/data/product/variant/index.ts +93 -0
- package/src/models/data/product/variant/price/index.ts +38 -0
- package/src/models/data/product/variant-type/index.ts +24 -0
- package/src/models/data/product-attribute/index.ts +75 -0
- package/src/models/data/product-attribute/product-attribute-option/index.ts +13 -0
- package/src/models/data/product-attribute/product-attribute-table-cell/index.ts +13 -0
- package/src/models/data/product-attribute/product-attribute-table-template/index.ts +18 -0
- package/src/models/data/product-back-in-stock-settings/index.ts +3 -0
- package/src/models/data/product-cart-item-options/index.ts +15 -0
- package/src/models/data/product-filter/index.ts +412 -0
- package/src/models/data/product-option-set/index.ts +392 -0
- package/src/models/data/product-tag/index.ts +13 -0
- package/src/models/data/raffle/index.ts +159 -0
- package/src/models/data/sales-channel/index.ts +41 -0
- package/src/models/data/simple-product/index.ts +154 -0
- package/src/models/data/state/index.ts +5 -0
- package/src/models/data/storefront/domain/index.ts +19 -0
- package/src/models/data/storefront/index.ts +56 -0
- package/src/models/data/storefront/localization/index.tsx +13 -0
- package/src/models/data/storefront/routing/index.tsx +17 -0
- package/src/models/data/storefront/theme/index.tsx +22 -0
- package/src/models/data/storefront/theme-localization/index.tsx +26 -0
- package/src/models/data/variant-type/index.ts +77 -0
- package/src/models/data/variant-type/variant-value/index.ts +29 -0
- package/src/models/index.ts +3 -0
- package/src/models/theme/component/index.ts +24 -0
- package/src/models/theme/component/prop/index.ts +56 -0
- package/src/models/theme/custom-data/index.ts +71 -0
- package/{build/models/theme/index.d.ts → src/models/theme/index.ts} +26 -18
- package/src/models/theme/page/component/index.ts +21 -0
- package/src/models/theme/page/component/prop-value/attribute-list.ts +18 -0
- package/src/models/theme/page/component/prop-value/attribute.ts +18 -0
- package/src/models/theme/page/component/prop-value/blog-category-list.ts +19 -0
- package/src/models/theme/page/component/prop-value/blog-category.ts +15 -0
- package/src/models/theme/page/component/prop-value/blog-list.ts +25 -0
- package/src/models/theme/page/component/prop-value/blog.ts +15 -0
- package/src/models/theme/page/component/prop-value/brand-list.ts +26 -0
- package/src/models/theme/page/component/prop-value/brand.ts +15 -0
- package/src/models/theme/page/component/prop-value/category-list.ts +26 -0
- package/src/models/theme/page/component/prop-value/category.ts +15 -0
- package/src/models/theme/page/component/prop-value/link.ts +38 -0
- package/src/models/theme/page/component/prop-value/product-detail.ts +17 -0
- package/src/models/theme/page/component/prop-value/product-list.ts +41 -0
- package/src/models/theme/page/component/prop-value/raffle-list.ts +16 -0
- package/src/models/theme/page/component/prop-value/raffle.ts +15 -0
- package/src/models/theme/page/index.ts +71 -0
- package/src/models/theme/settings/.DS_Store +0 -0
- package/src/models/theme/settings/index.ts +27 -0
- package/src/models/theme/settings/prop/color/index.ts +18 -0
- package/src/models/theme/settings/prop/favicon/index.ts +11 -0
- package/src/models/theme/theme.ts +202 -0
- package/src/models/ui/blog-category-list/index.ts +199 -0
- package/src/models/ui/blog-list/index.ts +202 -0
- package/src/models/ui/brand-list/index.ts +239 -0
- package/src/models/ui/category-list/index.ts +239 -0
- package/src/models/ui/component-renderer/index.ts +9 -0
- package/src/models/ui/customer-review-list/index.ts +171 -0
- package/src/models/ui/index.ts +41 -0
- package/src/models/ui/navigation-link/index.ts +22 -0
- package/src/models/ui/product-attribute-detail/index.ts +29 -0
- package/src/models/ui/product-attribute-list/index.ts +53 -0
- package/src/models/ui/product-detail/index.ts +269 -0
- package/src/models/ui/product-list/index.ts +959 -0
- package/src/models/ui/raffle-list/index.ts +208 -0
- package/src/models/ui/validator/form/account-info.ts +155 -0
- package/src/models/ui/validator/form/address.ts +436 -0
- package/src/models/ui/validator/form/contact-form.ts +180 -0
- package/src/models/ui/validator/form/customer-review.ts +134 -0
- package/src/models/ui/validator/form/forgot-password.ts +98 -0
- package/src/models/ui/validator/form/login.ts +130 -0
- package/src/models/ui/validator/form/raffle-form.ts +271 -0
- package/src/models/ui/validator/form/recover-password.ts +150 -0
- package/src/models/ui/validator/form/register.ts +200 -0
- package/src/models/ui/validator/index.ts +121 -0
- package/src/models/ui/validator/rules/index.ts +309 -0
- package/src/pages/.DS_Store +0 -0
- package/src/pages/404.tsx +29 -0
- package/src/pages/[slug]/index.tsx +28 -0
- package/src/pages/account/addresses.tsx +20 -0
- package/src/pages/account/favorite-products.tsx +20 -0
- package/src/pages/account/forgot-password.tsx +20 -0
- package/src/pages/account/index.tsx +20 -0
- package/src/pages/account/login.tsx +20 -0
- package/src/pages/account/orders/[id].tsx +20 -0
- package/src/pages/account/orders/index.tsx +20 -0
- package/src/pages/account/raffles.tsx +20 -0
- package/src/pages/account/recover-password.tsx +20 -0
- package/src/pages/account/register.tsx +20 -0
- package/src/pages/api/getComponentDirs.ts +39 -0
- package/src/pages/api/getTheme.ts +22 -0
- package/src/pages/api/index.ts +14 -0
- package/src/pages/api/middleware.ts +24 -0
- package/src/pages/api/updateTheme.ts +31 -0
- package/src/pages/api/uploadTheme.ts +276 -0
- package/src/pages/blog/[slug].tsx +27 -0
- package/src/pages/blog/index.tsx +20 -0
- package/src/pages/cart.tsx +20 -0
- package/src/pages/checkout.tsx +172 -0
- package/src/pages/editor.tsx +40 -0
- package/src/pages/home.tsx +20 -0
- package/src/pages/index.ts +22 -0
- package/src/pages/pages/[slug].tsx +82 -0
- package/src/pages/raffle/[slug].tsx +27 -0
- package/src/pages/raffle/index.tsx +20 -0
- package/src/pages/search.tsx +20 -0
- package/src/providers/helpers/raffles.ts +68 -0
- package/src/providers/page-data-get.ts +569 -0
- package/src/providers/page-data-init.ts +956 -0
- package/src/providers/page-data-next.ts +422 -0
- package/src/providers/placeholders.ts +39 -0
- package/src/providers/prop-value/attribute-list.ts +73 -0
- package/src/providers/prop-value/attribute.ts +73 -0
- package/src/providers/prop-value/blog-category-list.ts +25 -0
- package/src/providers/prop-value/blog-category.ts +40 -0
- package/src/providers/prop-value/blog-list.ts +56 -0
- package/src/providers/prop-value/blog.ts +37 -0
- package/src/providers/prop-value/boolean.ts +14 -0
- package/src/providers/prop-value/brand-list.ts +21 -0
- package/src/providers/prop-value/brand.ts +47 -0
- package/src/providers/prop-value/category-list.ts +21 -0
- package/src/providers/prop-value/category.ts +47 -0
- package/src/providers/prop-value/color.ts +14 -0
- package/src/providers/prop-value/custom.ts +548 -0
- package/src/providers/prop-value/image-list.ts +15 -0
- package/src/providers/prop-value/image.ts +15 -0
- package/{build/providers/prop-value/index.d.ts → src/providers/prop-value/index.ts} +3 -3
- package/src/providers/prop-value/link.ts +214 -0
- package/src/providers/prop-value/product-detail.ts +87 -0
- package/src/providers/prop-value/product-list.ts +69 -0
- package/src/providers/prop-value/raffle-list.ts +14 -0
- package/src/providers/prop-value/raffle.ts +43 -0
- package/src/providers/prop-value/rich-text.ts +14 -0
- package/src/providers/prop-value/text.ts +14 -0
- package/src/scripts/generators/api/index.ts +24 -0
- package/src/scripts/generators/api/info.ts +47 -0
- package/src/scripts/generators/components/index.ts +235 -0
- package/src/scripts/generators/config/content.ts +125 -0
- package/src/scripts/generators/config/index.ts +93 -0
- package/src/scripts/generators/pages/index.ts +95 -0
- package/src/scripts/generators/pages/info.ts +156 -0
- package/src/scripts/generators/store/content.ts +14 -0
- package/src/scripts/generators/store/index.ts +22 -0
- package/src/scripts/generators/theme/index.ts +37 -0
- package/src/scripts/ikas.ts +47 -0
- package/src/store/base.ts +143 -0
- package/src/store/cart.ts +311 -0
- package/src/store/customer.ts +510 -0
- package/{build/store/index.d.ts → src/store/index.ts} +1 -1
- package/src/storefront/index.ts +96 -0
- package/src/typings/global.d.ts +7 -0
- package/src/utils/currency.ts +229 -0
- package/src/utils/fs.ts +84 -0
- package/src/utils/helper.ts +133 -0
- package/src/utils/i18n.ts +204 -0
- package/{build/utils/index.d.ts → src/utils/index.ts} +3 -3
- package/build/__generated__/global-types.d.ts +0 -632
- package/build/analytics/analytics.d.ts +0 -37
- package/build/analytics/events.d.ts +0 -36
- package/build/analytics/facebookPixel.d.ts +0 -15
- package/build/analytics/googleTagManager.d.ts +0 -201
- package/build/analytics/head/index.d.ts +0 -7
- package/build/analytics/ikas.d.ts +0 -133
- package/build/api/apollo.d.ts +0 -10
- package/build/api/back-in-stock-reminder/__generated__/listProductBackInStockRemind.d.ts +0 -24
- package/build/api/back-in-stock-reminder/__generated__/saveProductBackInStockRemind.d.ts +0 -19
- package/build/api/back-in-stock-reminder/index.d.ts +0 -23
- package/build/api/blog/__generated__/getBlog.d.ts +0 -106
- package/build/api/blog/__generated__/listBlog.d.ts +0 -109
- package/build/api/blog/__generated__/listBlogCategory.d.ts +0 -61
- package/build/api/blog/__generated__/listBlogMetaData.d.ts +0 -53
- package/build/api/blog/index.d.ts +0 -32
- package/build/api/brand/__generated__/listProductBrand.d.ts +0 -88
- package/build/api/brand/index.d.ts +0 -16
- package/build/api/cart/__generated__/getCart.d.ts +0 -176
- package/build/api/cart/__generated__/saveItemToCart.d.ts +0 -185
- package/build/api/cart/index.d.ts +0 -5
- package/build/api/category/__generated__/listCategory.d.ts +0 -99
- package/build/api/category/__generated__/listCategoryPaths.d.ts +0 -32
- package/build/api/category/index.d.ts +0 -18
- package/build/api/checkout/__generated__/addCouponCodeToCheckout.d.ts +0 -11
- package/build/api/checkout/__generated__/checkStocks.d.ts +0 -18
- package/build/api/checkout/__generated__/createSaleTransactionWithCheckout.d.ts +0 -22
- package/build/api/checkout/__generated__/getCheckoutByCartId.d.ts +0 -10
- package/build/api/checkout/__generated__/getCheckoutById.d.ts +0 -572
- package/build/api/checkout/__generated__/getOrder.d.ts +0 -614
- package/build/api/checkout/__generated__/listCheckoutSettings.d.ts +0 -34
- package/build/api/checkout/__generated__/listPaymentGateway.d.ts +0 -42
- package/build/api/checkout/__generated__/retrieveInstallmentInfo.d.ts +0 -23
- package/build/api/checkout/__generated__/saveCheckout.d.ts +0 -11
- package/build/api/checkout/index.d.ts +0 -29
- package/build/api/city/__generated__/listCity.d.ts +0 -20
- package/build/api/city/index.d.ts +0 -4
- package/build/api/contact-form/__generated__/sendContactFormToMerchant.d.ts +0 -9
- package/build/api/contact-form/index.d.ts +0 -10
- package/build/api/country/__generated__/getAvailableShippingCountries.d.ts +0 -6
- package/build/api/country/__generated__/getMyCountry.d.ts +0 -3
- package/build/api/country/__generated__/listCountry.d.ts +0 -41
- package/build/api/country/index.d.ts +0 -6
- package/build/api/customer/__generated__/checkCustomerEmail.d.ts +0 -10
- package/build/api/customer/__generated__/createCustomerEmailSubscription.d.ts +0 -11
- package/build/api/customer/__generated__/createOrderRefundRequest.d.ts +0 -584
- package/build/api/customer/__generated__/customerForgotPassword.d.ts +0 -7
- package/build/api/customer/__generated__/customerLogin.d.ts +0 -162
- package/build/api/customer/__generated__/customerRecoverPassword.d.ts +0 -8
- package/build/api/customer/__generated__/customerRefreshToken.d.ts +0 -11
- package/build/api/customer/__generated__/customerSocialLogin.d.ts +0 -161
- package/build/api/customer/__generated__/getCustomerOrders.d.ts +0 -614
- package/build/api/customer/__generated__/getLastViewedProducts.d.ts +0 -15
- package/build/api/customer/__generated__/getMyCustomer.d.ts +0 -140
- package/build/api/customer/__generated__/listOrderRefundSettings.d.ts +0 -13
- package/build/api/customer/__generated__/listOrderTransactions.d.ts +0 -53
- package/build/api/customer/__generated__/registerCustomer.d.ts +0 -158
- package/build/api/customer/__generated__/saveLastViewedProducts.d.ts +0 -11
- package/build/api/customer/__generated__/saveMyCustomer.d.ts +0 -155
- package/build/api/customer/index.d.ts +0 -49
- package/build/api/customer-review/__generated__/createCustomerReview.d.ts +0 -11
- package/build/api/customer-review/__generated__/listCustomerReviews.d.ts +0 -48
- package/build/api/customer-review/index.d.ts +0 -24
- package/build/api/district/__generated__/listDistrict.d.ts +0 -16
- package/build/api/district/index.d.ts +0 -4
- package/build/api/favorite-product/__generated__/isFavoriteProduct.d.ts +0 -6
- package/build/api/favorite-product/__generated__/listFavoriteProducts.d.ts +0 -12
- package/build/api/favorite-product/__generated__/saveFavoriteProduct.d.ts +0 -7
- package/build/api/favorite-product/index.d.ts +0 -6
- package/build/api/html-meta-data/__generated__/listHTMLMetaData.d.ts +0 -28
- package/build/api/html-meta-data/index.d.ts +0 -4
- package/build/api/index.d.ts +0 -21
- package/build/api/merchant/__generated__/listMerchantSettings.d.ts +0 -9
- package/build/api/merchant/index.d.ts +0 -4
- package/build/api/product-attribute/__generated__/listProductAttribute.d.ts +0 -72
- package/build/api/product-attribute/index.d.ts +0 -4
- package/build/api/product-option-set/__generated__/ListProductOptionSet.d.ts +0 -90
- package/build/api/product-option-set/index.d.ts +0 -6
- package/build/api/product-search/__generated__/getProductFilterData.d.ts +0 -61
- package/build/api/product-search/__generated__/searchProducts.d.ts +0 -26
- package/build/api/product-search/index.d.ts +0 -20
- package/build/api/state/__generated__/listState.d.ts +0 -19
- package/build/api/state/index.d.ts +0 -4
- package/build/api/stock-location/__generated__/listStockLocation.d.ts +0 -7
- package/build/api/stock-location/index.d.ts +0 -4
- package/build/api/storefront/__generated__/getStorefront.d.ts +0 -52
- package/build/api/storefront/index.d.ts +0 -4
- package/build/api/variant-type/__generated__/listVariantType.d.ts +0 -72
- package/build/api/variant-type/index.d.ts +0 -4
- package/build/components/checkout/components/address-form/index.d.ts +0 -3
- package/build/components/checkout/components/address-form/model.d.ts +0 -131
- package/build/components/checkout/components/button/index.d.ts +0 -12
- package/build/components/checkout/components/cart-summary/cart-item/index.d.ts +0 -10
- package/build/components/checkout/components/cart-summary/index.d.ts +0 -8
- package/build/components/checkout/components/checkbox/check.d.ts +0 -6
- package/build/components/checkout/components/checkbox/index.d.ts +0 -10
- package/build/components/checkout/components/credit-card-form/index.d.ts +0 -7
- package/build/components/checkout/components/credit-card-form/model.d.ts +0 -26
- package/build/components/checkout/components/credit-card-form/svg/amex.d.ts +0 -6
- package/build/components/checkout/components/credit-card-form/svg/master-card.d.ts +0 -6
- package/build/components/checkout/components/credit-card-form/svg/troy.d.ts +0 -6
- package/build/components/checkout/components/credit-card-form/svg/visa.d.ts +0 -6
- package/build/components/checkout/components/customer-addresses/index.d.ts +0 -15
- package/build/components/checkout/components/customer-addresses/model.d.ts +0 -21
- package/build/components/checkout/components/error/customer-login-required-error/index.d.ts +0 -8
- package/build/components/checkout/components/error/index.d.ts +0 -7
- package/build/components/checkout/components/error/no-shipping-error/index.d.ts +0 -6
- package/build/components/checkout/components/error/payment-error/index.d.ts +0 -8
- package/build/components/checkout/components/error/stock-error/index.d.ts +0 -8
- package/build/components/checkout/components/error/unknown-error/index.d.ts +0 -6
- package/build/components/checkout/components/expandable-section/index.d.ts +0 -6
- package/build/components/checkout/components/form-item/caret-down.d.ts +0 -6
- package/build/components/checkout/components/form-item/index.d.ts +0 -3
- package/build/components/checkout/components/form-item/model.d.ts +0 -59
- package/build/components/checkout/components/fullscreen-loading/index.d.ts +0 -2
- package/build/components/checkout/components/input-with-button/index.d.ts +0 -11
- package/build/components/checkout/components/modal/index.d.ts +0 -8
- package/build/components/checkout/components/notification-box/index.d.ts +0 -9
- package/build/components/checkout/components/select-box/index.d.ts +0 -13
- package/build/components/checkout/components/step-container/index.d.ts +0 -15
- package/build/components/checkout/components/svg/arrow-down.d.ts +0 -6
- package/build/components/checkout/components/svg/arrow-left.d.ts +0 -6
- package/build/components/checkout/components/svg/arrow-right.d.ts +0 -6
- package/build/components/checkout/components/svg/cross.d.ts +0 -6
- package/build/components/checkout/components/svg/discount.d.ts +0 -6
- package/build/components/checkout/components/svg/external.d.ts +0 -6
- package/build/components/checkout/components/svg/gift.d.ts +0 -7
- package/build/components/checkout/components/svg/ikas.d.ts +0 -6
- package/build/components/checkout/components/svg/lock.d.ts +0 -6
- package/build/components/checkout/components/svg/shopping-cart.d.ts +0 -6
- package/build/components/checkout/components/svg/success-circle.d.ts +0 -6
- package/build/components/checkout/components/svg/tag.d.ts +0 -6
- package/build/components/checkout/components/svg/warning.d.ts +0 -6
- package/build/components/checkout/components/toggle/index.d.ts +0 -10
- package/build/components/checkout/components/tooltip/index.d.ts +0 -8
- package/build/components/checkout/index.d.ts +0 -32
- package/build/components/checkout/model.d.ts +0 -122
- package/build/components/checkout/steps/step-info/index.d.ts +0 -7
- package/build/components/checkout/steps/step-payment/billing-address/index.d.ts +0 -7
- package/build/components/checkout/steps/step-payment/index.d.ts +0 -7
- package/build/components/checkout/steps/step-payment/payment-gateways/index.d.ts +0 -7
- package/build/components/checkout/steps/step-payment/payment-gateways/installments/index.d.ts +0 -7
- package/build/components/checkout/steps/step-shipping/index.d.ts +0 -7
- package/build/components/checkout/steps/step-success/index.d.ts +0 -7
- package/build/components/error/index.d.ts +0 -5
- package/build/components/image/index.d.ts +0 -36
- package/build/components/index.d.ts +0 -4
- package/build/components/page/ThemeComponent.d.ts +0 -10
- package/build/components/page/head.d.ts +0 -12
- package/build/components/page/index.d.ts +0 -17
- package/build/components/page-editor/ThemeComponentEditor.d.ts +0 -9
- package/build/components/page-editor/index.d.ts +0 -2
- package/build/components/page-editor/model.d.ts +0 -65
- package/build/index.css +0 -1521
- package/build/index.d.ts +0 -8
- package/build/index.es.css +0 -1521
- package/build/index.es.js +0 -74627
- package/build/index.js +0 -74756
- package/build/models/data/blog/index.d.ts +0 -67
- package/build/models/data/brand/index.d.ts +0 -21
- package/build/models/data/cart/index.d.ts +0 -47
- package/build/models/data/category/index.d.ts +0 -52
- package/build/models/data/checkout/index.d.ts +0 -103
- package/build/models/data/checkout-settings/index.d.ts +0 -25
- package/build/models/data/city/index.d.ts +0 -4
- package/build/models/data/contact-form/index.d.ts +0 -7
- package/build/models/data/country/index.d.ts +0 -8
- package/build/models/data/customer/address/index.d.ts +0 -52
- package/build/models/data/customer/index.d.ts +0 -33
- package/build/models/data/customer-review/index.d.ts +0 -23
- package/build/models/data/customer-review-settings/index.d.ts +0 -4
- package/build/models/data/district/index.d.ts +0 -4
- package/build/models/data/favorite-product/index.d.ts +0 -6
- package/build/models/data/html-meta-data/index.d.ts +0 -23
- package/build/models/data/image/index.d.ts +0 -8
- package/build/models/data/index.d.ts +0 -33
- package/build/models/data/installment-info/index.d.ts +0 -30
- package/build/models/data/merchant-settings/index.d.ts +0 -8
- package/build/models/data/order/address/index.d.ts +0 -51
- package/build/models/data/order/adjustment/index.d.ts +0 -16
- package/build/models/data/order/gift-line/index.d.ts +0 -4
- package/build/models/data/order/index.d.ts +0 -146
- package/build/models/data/order/line-item/discount/index.d.ts +0 -11
- package/build/models/data/order/line-item/index.d.ts +0 -43
- package/build/models/data/order/line-item/options/index.d.ts +0 -10
- package/build/models/data/order/line-item/options/options-value/index.d.ts +0 -6
- package/build/models/data/order/line-item/variant/index.d.ts +0 -25
- package/build/models/data/order/refund/index.d.ts +0 -6
- package/build/models/data/order/refund/refund-line-item/index.d.ts +0 -5
- package/build/models/data/order/refund/settings.d.ts +0 -6
- package/build/models/data/order/shipping-line/index.d.ts +0 -7
- package/build/models/data/order-transaction/index.d.ts +0 -74
- package/build/models/data/payment-gateway/index.d.ts +0 -61
- package/build/models/data/product/attribute-value/index.d.ts +0 -20
- package/build/models/data/product/index.d.ts +0 -35
- package/build/models/data/product/variant/index.d.ts +0 -24
- package/build/models/data/product/variant/price/index.d.ts +0 -11
- package/build/models/data/product/variant-type/index.d.ts +0 -6
- package/build/models/data/product-attribute/index.d.ts +0 -34
- package/build/models/data/product-attribute/product-attribute-option/index.d.ts +0 -5
- package/build/models/data/product-attribute/product-attribute-table-cell/index.d.ts +0 -5
- package/build/models/data/product-attribute/product-attribute-table-template/index.d.ts +0 -6
- package/build/models/data/product-back-in-stock-settings/index.d.ts +0 -3
- package/build/models/data/product-cart-item-options/index.d.ts +0 -6
- package/build/models/data/product-filter/index.d.ts +0 -109
- package/build/models/data/product-option-set/index.d.ts +0 -104
- package/build/models/data/product-tag/index.d.ts +0 -5
- package/build/models/data/sales-channel/index.d.ts +0 -18
- package/build/models/data/simple-product/index.d.ts +0 -136
- package/build/models/data/state/index.d.ts +0 -5
- package/build/models/data/storefront/domain/index.d.ts +0 -8
- package/build/models/data/storefront/index.d.ts +0 -23
- package/build/models/data/storefront/localization/index.d.ts +0 -7
- package/build/models/data/storefront/routing/index.d.ts +0 -9
- package/build/models/data/storefront/theme/index.d.ts +0 -13
- package/build/models/data/storefront/theme-localization/index.d.ts +0 -12
- package/build/models/data/variant-type/index.d.ts +0 -26
- package/build/models/data/variant-type/variant-value/index.d.ts +0 -11
- package/build/models/index.d.ts +0 -3
- package/build/models/theme/component/index.d.ts +0 -10
- package/build/models/theme/component/prop/index.d.ts +0 -40
- package/build/models/theme/custom-data/index.d.ts +0 -24
- package/build/models/theme/page/component/index.d.ts +0 -6
- package/build/models/theme/page/component/prop-value/attribute-list.d.ts +0 -7
- package/build/models/theme/page/component/prop-value/attribute.d.ts +0 -7
- package/build/models/theme/page/component/prop-value/blog-category-list.d.ts +0 -7
- package/build/models/theme/page/component/prop-value/blog-category.d.ts +0 -5
- package/build/models/theme/page/component/prop-value/blog-list.d.ts +0 -9
- package/build/models/theme/page/component/prop-value/blog.d.ts +0 -5
- package/build/models/theme/page/component/prop-value/brand-list.d.ts +0 -9
- package/build/models/theme/page/component/prop-value/brand.d.ts +0 -5
- package/build/models/theme/page/component/prop-value/category-list.d.ts +0 -9
- package/build/models/theme/page/component/prop-value/category.d.ts +0 -5
- package/build/models/theme/page/component/prop-value/link.d.ts +0 -19
- package/build/models/theme/page/component/prop-value/product-detail.d.ts +0 -6
- package/build/models/theme/page/component/prop-value/product-list.d.ts +0 -17
- package/build/models/theme/page/index.d.ts +0 -40
- package/build/models/theme/settings/index.d.ts +0 -13
- package/build/models/theme/settings/prop/color/index.d.ts +0 -7
- package/build/models/theme/settings/prop/favicon/index.d.ts +0 -4
- package/build/models/theme/theme.d.ts +0 -16
- package/build/models/ui/blog-category-list/index.d.ts +0 -52
- package/build/models/ui/blog-list/index.d.ts +0 -56
- package/build/models/ui/brand-list/index.d.ts +0 -61
- package/build/models/ui/category-list/index.d.ts +0 -61
- package/build/models/ui/component-renderer/index.d.ts +0 -7
- package/build/models/ui/customer-review-list/index.d.ts +0 -43
- package/build/models/ui/index.d.ts +0 -22
- package/build/models/ui/navigation-link/index.d.ts +0 -8
- package/build/models/ui/product-attribute-detail/index.d.ts +0 -8
- package/build/models/ui/product-attribute-list/index.d.ts +0 -9
- package/build/models/ui/product-detail/index.d.ts +0 -28
- package/build/models/ui/product-list/index.d.ts +0 -132
- package/build/models/ui/validator/form/account-info.d.ts +0 -40
- package/build/models/ui/validator/form/address.d.ts +0 -75
- package/build/models/ui/validator/form/contact-form.d.ts +0 -45
- package/build/models/ui/validator/form/customer-review.d.ts +0 -37
- package/build/models/ui/validator/form/forgot-password.d.ts +0 -29
- package/build/models/ui/validator/form/login.d.ts +0 -35
- package/build/models/ui/validator/form/recover-password.d.ts +0 -36
- package/build/models/ui/validator/form/register.d.ts +0 -48
- package/build/models/ui/validator/index.d.ts +0 -27
- package/build/models/ui/validator/rules/index.d.ts +0 -87
- package/build/pages/404.d.ts +0 -6
- package/build/pages/[slug]/index.d.ts +0 -7
- package/build/pages/account/addresses.d.ts +0 -6
- package/build/pages/account/favorite-products.d.ts +0 -6
- package/build/pages/account/forgot-password.d.ts +0 -6
- package/build/pages/account/index.d.ts +0 -6
- package/build/pages/account/login.d.ts +0 -6
- package/build/pages/account/orders/[id].d.ts +0 -6
- package/build/pages/account/orders/index.d.ts +0 -6
- package/build/pages/account/recover-password.d.ts +0 -6
- package/build/pages/account/register.d.ts +0 -6
- package/build/pages/blog/[slug].d.ts +0 -7
- package/build/pages/blog/index.d.ts +0 -6
- package/build/pages/cart.d.ts +0 -6
- package/build/pages/checkout.d.ts +0 -18
- package/build/pages/editor.d.ts +0 -8
- package/build/pages/home.d.ts +0 -6
- package/build/pages/index.d.ts +0 -20
- package/build/pages/pages/[slug].d.ts +0 -7
- package/build/pages/search.d.ts +0 -6
- package/build/providers/page-data-get.d.ts +0 -61
- package/build/providers/page-data-init.d.ts +0 -58
- package/build/providers/page-data-next.d.ts +0 -243
- package/build/providers/placeholders.d.ts +0 -6
- package/build/providers/prop-value/attribute-list.d.ts +0 -12
- package/build/providers/prop-value/attribute.d.ts +0 -12
- package/build/providers/prop-value/blog-category-list.d.ts +0 -7
- package/build/providers/prop-value/blog-category.d.ts +0 -11
- package/build/providers/prop-value/blog-list.d.ts +0 -9
- package/build/providers/prop-value/blog.d.ts +0 -11
- package/build/providers/prop-value/boolean.d.ts +0 -6
- package/build/providers/prop-value/brand-list.d.ts +0 -7
- package/build/providers/prop-value/brand.d.ts +0 -11
- package/build/providers/prop-value/category-list.d.ts +0 -7
- package/build/providers/prop-value/category.d.ts +0 -11
- package/build/providers/prop-value/checkout.d.ts +0 -4
- package/build/providers/prop-value/color.d.ts +0 -6
- package/build/providers/prop-value/custom.d.ts +0 -42
- package/build/providers/prop-value/image-list.d.ts +0 -7
- package/build/providers/prop-value/image.d.ts +0 -7
- package/build/providers/prop-value/link.d.ts +0 -16
- package/build/providers/prop-value/product-detail.d.ts +0 -11
- package/build/providers/prop-value/product-list.d.ts +0 -9
- package/build/providers/prop-value/rich-text.d.ts +0 -6
- package/build/providers/prop-value/text.d.ts +0 -6
- package/build/store/base.d.ts +0 -25
- package/build/store/cart.d.ts +0 -30
- package/build/store/customer.d.ts +0 -91
- package/build/storefront/index.d.ts +0 -55
- package/build/utils/currency.d.ts +0 -7
- package/build/utils/helper.d.ts +0 -8
- package/build/utils/i18n.d.ts +0 -20
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { IkasStorefrontConfig } from "../storefront";
|
|
2
|
+
|
|
3
|
+
const format = (p: number, n: number, x: number, s: string, c: string) => {
|
|
4
|
+
const re = "\\d(?=(\\d{" + (x || 3) + "})+" + (n > 0 ? "\\D" : "$") + ")",
|
|
5
|
+
num = p.toFixed(Math.max(0, ~~n));
|
|
6
|
+
|
|
7
|
+
return (c ? num.replace(".", c) : num).replace(
|
|
8
|
+
new RegExp(re, "g"),
|
|
9
|
+
"$&" + (s || ",")
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param price Price to format
|
|
16
|
+
* @param currency Code for the currency, USD, EUR, TRY, etc..
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const formatMoney = (price: number, currency: string) => {
|
|
20
|
+
try {
|
|
21
|
+
const symbol = getCurrencySymbol(currency);
|
|
22
|
+
const decimalSeperator = ".";
|
|
23
|
+
const sectionSeperator = ",";
|
|
24
|
+
const decimalLength = 2;
|
|
25
|
+
const sectionLength = 3;
|
|
26
|
+
|
|
27
|
+
const formattedNumber = format(
|
|
28
|
+
price,
|
|
29
|
+
decimalLength,
|
|
30
|
+
sectionLength,
|
|
31
|
+
sectionSeperator,
|
|
32
|
+
decimalSeperator
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return symbol + " " + formattedNumber;
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(err);
|
|
38
|
+
|
|
39
|
+
// Fallback
|
|
40
|
+
const formatter = new Intl.NumberFormat(
|
|
41
|
+
IkasStorefrontConfig.getCurrentLocale(),
|
|
42
|
+
{
|
|
43
|
+
style: "currency",
|
|
44
|
+
currency: currency || "TRY",
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return formatter.format(price);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function getCurrencySymbol(currencyCode: string) {
|
|
53
|
+
return CURRENCIES[currencyCode] || currencyCode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const CURRENCIES: Record<string, string> = {
|
|
57
|
+
TRY: "₺",
|
|
58
|
+
USD: "$",
|
|
59
|
+
EUR: "€",
|
|
60
|
+
AZN: "₼",
|
|
61
|
+
AED: "د.إ.",
|
|
62
|
+
AFN: "؋",
|
|
63
|
+
ALL: "L",
|
|
64
|
+
AMD: "դր",
|
|
65
|
+
ANG: "ƒ",
|
|
66
|
+
AOA: "Kz",
|
|
67
|
+
ARS: "$",
|
|
68
|
+
AUD: "$",
|
|
69
|
+
AWG: "ƒ",
|
|
70
|
+
BAM: "КМ",
|
|
71
|
+
BBD: "$",
|
|
72
|
+
BDT: "৳",
|
|
73
|
+
BGN: "лв.",
|
|
74
|
+
BHD: "د.ب.",
|
|
75
|
+
BIF: "FBu",
|
|
76
|
+
BMD: "$",
|
|
77
|
+
BND: "$",
|
|
78
|
+
BOB: "Bs.",
|
|
79
|
+
BRL: "R$",
|
|
80
|
+
BSD: "$",
|
|
81
|
+
BTN: "Nu.",
|
|
82
|
+
BWP: "P",
|
|
83
|
+
BYN: "руб.",
|
|
84
|
+
BZD: "$",
|
|
85
|
+
CAD: "$",
|
|
86
|
+
CDF: "₣",
|
|
87
|
+
CHF: "₣",
|
|
88
|
+
CKD: "$",
|
|
89
|
+
CLP: "$",
|
|
90
|
+
CNY: "¥元",
|
|
91
|
+
COP: "$",
|
|
92
|
+
CRC: "₡",
|
|
93
|
+
CUC: "$",
|
|
94
|
+
CUP: "₱",
|
|
95
|
+
CVE: "$",
|
|
96
|
+
CZK: "Kč",
|
|
97
|
+
DJF: "ف.ج.",
|
|
98
|
+
DKK: "kr.",
|
|
99
|
+
DOP: "$",
|
|
100
|
+
DZD: "د.ج.",
|
|
101
|
+
EGP: "ج.م.",
|
|
102
|
+
EHP: "Ptas.",
|
|
103
|
+
ERN: "ناكفا",
|
|
104
|
+
ETB: "ብር",
|
|
105
|
+
FJD: "$",
|
|
106
|
+
FKP: "£",
|
|
107
|
+
FOK: "kr",
|
|
108
|
+
GBP: "£",
|
|
109
|
+
GEL: "₾",
|
|
110
|
+
GGP: "£",
|
|
111
|
+
GHS: "₵",
|
|
112
|
+
GIP: "£",
|
|
113
|
+
GMD: "D",
|
|
114
|
+
GNF: "FG",
|
|
115
|
+
GTQ: "$",
|
|
116
|
+
GYD: "$",
|
|
117
|
+
HKD: "$",
|
|
118
|
+
HNL: "L",
|
|
119
|
+
HRK: "kn",
|
|
120
|
+
HTG: "G",
|
|
121
|
+
HUF: "Ft",
|
|
122
|
+
IDR: "Rp",
|
|
123
|
+
ILS: "₪",
|
|
124
|
+
IMP: "£",
|
|
125
|
+
INR: "₹",
|
|
126
|
+
IQD: "د.ع.",
|
|
127
|
+
IRR: "﷼",
|
|
128
|
+
ISK: "kr",
|
|
129
|
+
JEP: "£",
|
|
130
|
+
JMD: "$",
|
|
131
|
+
JOD: "د.أ.",
|
|
132
|
+
JPY: "¥",
|
|
133
|
+
KES: "KSh",
|
|
134
|
+
KGS: "с",
|
|
135
|
+
KHR: "៛",
|
|
136
|
+
KID: "$",
|
|
137
|
+
KMF: "CF",
|
|
138
|
+
KPW: "₩",
|
|
139
|
+
KRW: "₩",
|
|
140
|
+
KWD: "د.ك.",
|
|
141
|
+
KYD: "$",
|
|
142
|
+
KZT: "₸",
|
|
143
|
+
LAK: "₭",
|
|
144
|
+
LBP: "ل.ل.",
|
|
145
|
+
LKR: "රු or ரூ",
|
|
146
|
+
LRD: "$",
|
|
147
|
+
LSL: "L",
|
|
148
|
+
LYD: "ل.د.",
|
|
149
|
+
MAD: "د.م.",
|
|
150
|
+
MDL: "L",
|
|
151
|
+
MGA: "Ar",
|
|
152
|
+
MKD: "ден",
|
|
153
|
+
MMK: "Ks",
|
|
154
|
+
MNT: "₮",
|
|
155
|
+
MOP: "MOP$",
|
|
156
|
+
MRU: "أ.م.",
|
|
157
|
+
MUR: "रु ",
|
|
158
|
+
MVR: ".ރ",
|
|
159
|
+
MWK: "MK",
|
|
160
|
+
MXN: "$",
|
|
161
|
+
MYR: "RM",
|
|
162
|
+
MZN: "MT",
|
|
163
|
+
NAD: "$",
|
|
164
|
+
NGN: "₦",
|
|
165
|
+
NIO: "C$",
|
|
166
|
+
NOK: "kr",
|
|
167
|
+
NPR: "रू",
|
|
168
|
+
NZD: "$",
|
|
169
|
+
OMR: "ر.ع.",
|
|
170
|
+
PAB: "B/.",
|
|
171
|
+
PEN: "S/.",
|
|
172
|
+
PGK: "K",
|
|
173
|
+
PHP: "₱",
|
|
174
|
+
PKR: "Rs",
|
|
175
|
+
PLN: "zł",
|
|
176
|
+
PND: "$",
|
|
177
|
+
PRB: "р.",
|
|
178
|
+
PYG: "₲",
|
|
179
|
+
QAR: "ر.ق.",
|
|
180
|
+
RON: "L",
|
|
181
|
+
RSD: "дин",
|
|
182
|
+
RUB: "₽",
|
|
183
|
+
RWF: "R₣",
|
|
184
|
+
SAR: "ر.س.",
|
|
185
|
+
SBD: "$",
|
|
186
|
+
SCR: "Rs",
|
|
187
|
+
SDG: "ج.س.",
|
|
188
|
+
SEK: "kr",
|
|
189
|
+
SGD: "$",
|
|
190
|
+
SHP: "£",
|
|
191
|
+
SLL: "Le",
|
|
192
|
+
SLS: "Sl",
|
|
193
|
+
SOS: "Ssh",
|
|
194
|
+
SRD: "$",
|
|
195
|
+
SSP: "SS£",
|
|
196
|
+
STN: "Db",
|
|
197
|
+
SVC: "₡",
|
|
198
|
+
SYP: "ل.س.",
|
|
199
|
+
SZL: "L",
|
|
200
|
+
THB: "฿",
|
|
201
|
+
TJS: "SM",
|
|
202
|
+
TMT: "T",
|
|
203
|
+
TND: "د.ت.",
|
|
204
|
+
TOP: "PT",
|
|
205
|
+
TTD: "$",
|
|
206
|
+
TVD: "$",
|
|
207
|
+
TWD: "圓",
|
|
208
|
+
TZS: "TSh",
|
|
209
|
+
UAH: "грн",
|
|
210
|
+
UGX: "Sh",
|
|
211
|
+
UYU: "$",
|
|
212
|
+
UZS: "сум",
|
|
213
|
+
VED: "Bs.",
|
|
214
|
+
VES: "Bs.F",
|
|
215
|
+
VND: "₫",
|
|
216
|
+
VUV: "VT",
|
|
217
|
+
WST: "ST",
|
|
218
|
+
XAF: "Fr.",
|
|
219
|
+
XCD: "$",
|
|
220
|
+
XOF: "₣",
|
|
221
|
+
XPF: "₣",
|
|
222
|
+
YER: "ر.ي.",
|
|
223
|
+
ZAR: "R",
|
|
224
|
+
ZMW: "ZK",
|
|
225
|
+
ZWB: "",
|
|
226
|
+
ZWL: "$",
|
|
227
|
+
Abkhazia: "",
|
|
228
|
+
Artsakh: "դր.",
|
|
229
|
+
};
|
package/src/utils/fs.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Divides the given filePath string into directory part and fileName part
|
|
6
|
+
* @param path Path for the file
|
|
7
|
+
*/
|
|
8
|
+
export function getFilePathParts(path: string) {
|
|
9
|
+
const componentFilePathParts = path.split("/");
|
|
10
|
+
|
|
11
|
+
if (componentFilePathParts.length > 1) {
|
|
12
|
+
const dirParts = componentFilePathParts.slice(
|
|
13
|
+
0,
|
|
14
|
+
componentFilePathParts.length - 1
|
|
15
|
+
);
|
|
16
|
+
const filePart = componentFilePathParts[componentFilePathParts.length - 1];
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
dirParts,
|
|
20
|
+
filePart,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
filePart: path,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Deletes the contents of the given directory, exluding the ignoreFiles
|
|
31
|
+
* @param dirPath Path for the directory
|
|
32
|
+
* @param ignoreFiles List of files to keep in directory. Does not accept recursive paths, only first level files
|
|
33
|
+
*
|
|
34
|
+
* @returns true for successfull operation, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
export function deleteDirContent(dirPath: string, ignoreFiles?: string[]) {
|
|
37
|
+
try {
|
|
38
|
+
const files = fs.readdirSync(dirPath);
|
|
39
|
+
|
|
40
|
+
files.forEach((file) => {
|
|
41
|
+
if (!ignoreFiles?.includes(file)) {
|
|
42
|
+
fs.removeSync(path.join(dirPath, file));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates the given file and directories for the filePath
|
|
54
|
+
* @param basePath Base directory path for the file
|
|
55
|
+
* @param fileSubPath Filename or the sub directory path for the file to write
|
|
56
|
+
* @param fileStr File contents
|
|
57
|
+
*
|
|
58
|
+
* @returns true for successfull operation, false otherwise
|
|
59
|
+
*/
|
|
60
|
+
export function createFile(
|
|
61
|
+
basePath: string,
|
|
62
|
+
fileSubPath: string,
|
|
63
|
+
fileStr: string
|
|
64
|
+
) {
|
|
65
|
+
try {
|
|
66
|
+
let generatedFolderPath = basePath;
|
|
67
|
+
|
|
68
|
+
const pageFilePathParts = getFilePathParts(fileSubPath);
|
|
69
|
+
if (pageFilePathParts.dirParts?.length) {
|
|
70
|
+
generatedFolderPath = path.join(
|
|
71
|
+
generatedFolderPath,
|
|
72
|
+
...pageFilePathParts.dirParts
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const filePath = path.join(generatedFolderPath, pageFilePathParts.filePart);
|
|
77
|
+
fs.outputFileSync(filePath, fileStr);
|
|
78
|
+
|
|
79
|
+
return true;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(err);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { IkasStorefrontConfig } from "../storefront";
|
|
2
|
+
import _forEach from "lodash/forEach";
|
|
3
|
+
|
|
4
|
+
export const stringToSlug = (str: string) => {
|
|
5
|
+
str = str.replace(/^\s+|\s+$/g, ""); // trim
|
|
6
|
+
str = str.toLocaleLowerCase("tr-TR");
|
|
7
|
+
|
|
8
|
+
// remove accents, swap ñ for n, etc
|
|
9
|
+
const from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
|
|
10
|
+
const to = "aaaaeeeeiiiiioooouuuuncsg------";
|
|
11
|
+
for (let i = 0, l = from.length; i < l; i++) {
|
|
12
|
+
str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
str = str
|
|
16
|
+
.replace(/[^a-z0-9 -]/g, "") // remove invalid chars
|
|
17
|
+
.replace(/\s+/g, "-") // collapse whitespace and replace by -
|
|
18
|
+
.replace(/-+/g, "-"); // collapse dashes
|
|
19
|
+
|
|
20
|
+
return str;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const validatePhoneNumber = (str: string) => {
|
|
24
|
+
const regex = /^\+?\d+$/;
|
|
25
|
+
return regex.test(str);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const pascalCase = (str: string) => {
|
|
29
|
+
const lower = str.toLocaleLowerCase("tr-TR");
|
|
30
|
+
return lower.charAt(0).toLocaleUpperCase("tr-TR") + lower.slice(1);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const decodeBase64 = (base64: string) => {
|
|
34
|
+
const buffer = Buffer.from(base64, "base64");
|
|
35
|
+
return buffer.toString("ascii");
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function stringSorter(atitle: string, btitle: string): number {
|
|
39
|
+
const alphabet =
|
|
40
|
+
"0123456789AaBbCcÇçDdEeFfGgĞğHhIıİiJjKkLlMmNnOoÖöPpQqRrSsŞşTtUuÜüVvWwXxYyZz";
|
|
41
|
+
|
|
42
|
+
const _atitle = atitle || "";
|
|
43
|
+
const _btitle = btitle || "";
|
|
44
|
+
|
|
45
|
+
if (_atitle.length === 0 || _btitle.length === 0) {
|
|
46
|
+
return _atitle.length - _btitle.length;
|
|
47
|
+
}
|
|
48
|
+
for (let i = 0; i < _atitle.length && i < _btitle.length; i++) {
|
|
49
|
+
const ai = alphabet.indexOf(_atitle[i].toUpperCase());
|
|
50
|
+
const bi = alphabet.indexOf(_btitle[i].toUpperCase());
|
|
51
|
+
if (ai !== bi) {
|
|
52
|
+
return ai - bi;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function findAllIndexes(str: string, pattern: string) {
|
|
59
|
+
const indexes: number[] = [];
|
|
60
|
+
if (!str || !pattern) return [];
|
|
61
|
+
|
|
62
|
+
let index = 0;
|
|
63
|
+
while (index < str.length) {
|
|
64
|
+
const patternIndex = str.indexOf(pattern, index);
|
|
65
|
+
|
|
66
|
+
if (patternIndex === -1) break;
|
|
67
|
+
index = patternIndex + 1;
|
|
68
|
+
indexes.push(patternIndex);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return indexes;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function is12Hour(locale: string) {
|
|
75
|
+
return !!new Intl.DateTimeFormat(locale, { hour: "numeric" })
|
|
76
|
+
.format(0)
|
|
77
|
+
.match(/\s/);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function formatDate(date: Date) {
|
|
81
|
+
const options: any = {
|
|
82
|
+
year: "numeric",
|
|
83
|
+
month: "long",
|
|
84
|
+
day: "numeric",
|
|
85
|
+
hour: "numeric",
|
|
86
|
+
minute: "numeric",
|
|
87
|
+
hour12: false,
|
|
88
|
+
};
|
|
89
|
+
const locale = IkasStorefrontConfig.getCurrentLocale();
|
|
90
|
+
|
|
91
|
+
if (typeof navigator !== "undefined") {
|
|
92
|
+
options.hour12 = is12Hour(navigator.language);
|
|
93
|
+
} else {
|
|
94
|
+
options.hour12 = is12Hour(locale);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function tryForEach(
|
|
101
|
+
items: Array<any>,
|
|
102
|
+
callback: (item: any, index: number) => void,
|
|
103
|
+
printErrors = false
|
|
104
|
+
) {
|
|
105
|
+
_forEach(items, (value, index) => {
|
|
106
|
+
try {
|
|
107
|
+
callback(value, index);
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (printErrors) console.error(err);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function findAllByKey(obj: Record<string, any>, keyToFind: string): any {
|
|
115
|
+
return Object.entries(obj || {}).reduce(
|
|
116
|
+
(acc, [key, value]) =>
|
|
117
|
+
key === keyToFind
|
|
118
|
+
? acc.concat(value)
|
|
119
|
+
: typeof value === "object"
|
|
120
|
+
? acc.concat(findAllByKey(value, keyToFind))
|
|
121
|
+
: acc,
|
|
122
|
+
[]
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function sortObject(obj: Record<string, any>) {
|
|
127
|
+
return Object.keys(obj)
|
|
128
|
+
.sort()
|
|
129
|
+
.reduce((sortedObj: Record<string, any>, key) => {
|
|
130
|
+
sortedObj[key] = obj[key];
|
|
131
|
+
return sortedObj;
|
|
132
|
+
}, {});
|
|
133
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import _get from "lodash/get";
|
|
4
|
+
import { IkasStorefrontConfig } from "../storefront";
|
|
5
|
+
import { findAllIndexes } from "./helper";
|
|
6
|
+
|
|
7
|
+
export const CHECKOUT_TRANSLATION_NAMESPACE = "checkout-page";
|
|
8
|
+
export type TFunction = (
|
|
9
|
+
pathString: string,
|
|
10
|
+
params?: Record<string, any>
|
|
11
|
+
) => string;
|
|
12
|
+
|
|
13
|
+
export class I18NFileReader {
|
|
14
|
+
locale: string;
|
|
15
|
+
namespaces: string[];
|
|
16
|
+
localePath?: string;
|
|
17
|
+
|
|
18
|
+
constructor(locale: string, namespaces: string[], localePath?: string) {
|
|
19
|
+
this.locale = locale;
|
|
20
|
+
this.namespaces = namespaces;
|
|
21
|
+
this.localePath = localePath;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async read(): Promise<Record<string, any>> {
|
|
25
|
+
const translations: Record<string, any> = {};
|
|
26
|
+
|
|
27
|
+
for (const namespace of this.namespaces) {
|
|
28
|
+
try {
|
|
29
|
+
const filePath = this.localePath
|
|
30
|
+
? path.join(this.localePath, this.locale, namespace + ".json")
|
|
31
|
+
: path.join(
|
|
32
|
+
process.cwd(),
|
|
33
|
+
"public",
|
|
34
|
+
"locales",
|
|
35
|
+
this.locale,
|
|
36
|
+
namespace + ".json"
|
|
37
|
+
);
|
|
38
|
+
const fileExists = fs.existsSync(filePath);
|
|
39
|
+
|
|
40
|
+
if (fileExists) {
|
|
41
|
+
const localeTranslation = await this.readLocaleFile(filePath);
|
|
42
|
+
translations[namespace] = localeTranslation;
|
|
43
|
+
} else if (namespace === CHECKOUT_TRANSLATION_NAMESPACE) {
|
|
44
|
+
let checkoutTranslation: Record<string, any> = {};
|
|
45
|
+
|
|
46
|
+
if (this.locale === "tr") {
|
|
47
|
+
const imported = await import(
|
|
48
|
+
//@ts-ignore
|
|
49
|
+
"../assets/translations/checkout/tr.js"
|
|
50
|
+
);
|
|
51
|
+
checkoutTranslation = imported.default;
|
|
52
|
+
} else {
|
|
53
|
+
const imported = await import(
|
|
54
|
+
//@ts-ignore
|
|
55
|
+
"../assets/translations/checkout/en.js"
|
|
56
|
+
);
|
|
57
|
+
checkoutTranslation = imported.default;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
translations[namespace] = checkoutTranslation;
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error(err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return translations;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private async readLocaleFile(filePath: string): Promise<Record<string, any>> {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
fs.readFile(
|
|
73
|
+
filePath,
|
|
74
|
+
{
|
|
75
|
+
flag: "r",
|
|
76
|
+
},
|
|
77
|
+
function (err, file) {
|
|
78
|
+
if (err) {
|
|
79
|
+
return reject(err);
|
|
80
|
+
}
|
|
81
|
+
const result = file.length ? JSON.parse(file.toString()) : {};
|
|
82
|
+
resolve(result);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function t(pathString: string, params?: Record<string, any>): string {
|
|
90
|
+
let namespace = "common";
|
|
91
|
+
let path = "";
|
|
92
|
+
const parts = pathString.split(":");
|
|
93
|
+
|
|
94
|
+
if (parts.length > 2) {
|
|
95
|
+
return pathString;
|
|
96
|
+
} else if (parts.length === 2) {
|
|
97
|
+
namespace = parts[0];
|
|
98
|
+
path = parts[1];
|
|
99
|
+
} else {
|
|
100
|
+
path = parts[0];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const namespaceTranslations = IkasStorefrontConfig.translations[namespace];
|
|
104
|
+
if (!namespaceTranslations) return pathString;
|
|
105
|
+
|
|
106
|
+
const str = _get(namespaceTranslations, path);
|
|
107
|
+
if (str) {
|
|
108
|
+
if (params) {
|
|
109
|
+
const allInputData = createTranslationInputData(str);
|
|
110
|
+
let newStr = "";
|
|
111
|
+
|
|
112
|
+
for (const inputData of allInputData) {
|
|
113
|
+
if (inputData.isVariable) {
|
|
114
|
+
const variableName = inputData.value
|
|
115
|
+
.replace("{{", "")
|
|
116
|
+
.replace("}}", "")
|
|
117
|
+
.trim();
|
|
118
|
+
|
|
119
|
+
if (params[variableName]) {
|
|
120
|
+
newStr += params[variableName];
|
|
121
|
+
} else {
|
|
122
|
+
newStr += inputData.value;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
newStr += inputData.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return newStr;
|
|
130
|
+
} else return str;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return pathString;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function useTranslation(namespace?: string | string[]) {
|
|
137
|
+
return {
|
|
138
|
+
t,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function createTranslationInputData(value: string) {
|
|
143
|
+
const currentData: InputData[] = [];
|
|
144
|
+
if (!value) return currentData;
|
|
145
|
+
|
|
146
|
+
const variableStartIndexes = findAllIndexes(value, "{{");
|
|
147
|
+
const variableEndIndexes = findAllIndexes(value, "}}");
|
|
148
|
+
|
|
149
|
+
const variableIndexPairs = variableStartIndexes.map((startIndex, index) => {
|
|
150
|
+
const endIndex = variableEndIndexes[index] + 1;
|
|
151
|
+
return {
|
|
152
|
+
start: startIndex,
|
|
153
|
+
end: endIndex,
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const isVariableIndex = (index: number) =>
|
|
158
|
+
variableIndexPairs.some((pair) => pair.start <= index && pair.end >= index);
|
|
159
|
+
|
|
160
|
+
let currentValue = "";
|
|
161
|
+
let isVariable = false;
|
|
162
|
+
|
|
163
|
+
for (let i = 0; i < value.length; i++) {
|
|
164
|
+
const currentChar = value.charAt(i);
|
|
165
|
+
|
|
166
|
+
if (isVariable) {
|
|
167
|
+
if (isVariableIndex(i)) {
|
|
168
|
+
currentValue += currentChar;
|
|
169
|
+
} else {
|
|
170
|
+
currentData.push({
|
|
171
|
+
isVariable: true,
|
|
172
|
+
value: currentValue,
|
|
173
|
+
});
|
|
174
|
+
currentValue = currentChar;
|
|
175
|
+
isVariable = false;
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
if (isVariableIndex(i)) {
|
|
179
|
+
currentData.push({
|
|
180
|
+
isVariable: false,
|
|
181
|
+
value: currentValue,
|
|
182
|
+
});
|
|
183
|
+
currentValue = currentChar;
|
|
184
|
+
isVariable = true;
|
|
185
|
+
} else {
|
|
186
|
+
currentValue += currentChar;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (i === value.length - 1) {
|
|
191
|
+
currentData.push({
|
|
192
|
+
isVariable,
|
|
193
|
+
value: currentValue,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return currentData;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
type InputData = {
|
|
202
|
+
value: string;
|
|
203
|
+
isVariable: boolean;
|
|
204
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./helper";
|
|
2
|
-
export * from "./currency";
|
|
3
|
-
export { useTranslation, createTranslationInputData } from "./i18n";
|
|
1
|
+
export * from "./helper";
|
|
2
|
+
export * from "./currency";
|
|
3
|
+
export { useTranslation, createTranslationInputData } from "./i18n";
|