cloudcommerce 0.0.126 → 0.0.128
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/.vscode/settings.json +3 -0
- package/CHANGELOG.md +50 -0
- package/action.yml +50 -10
- package/ecomplus-stores/monocard/README.md +0 -15
- package/ecomplus-stores/monocard/README.pt-BR.md +0 -15
- package/ecomplus-stores/monocard/functions/core/package.json +1 -1
- package/ecomplus-stores/monocard/functions/events/package.json +2 -2
- package/ecomplus-stores/monocard/functions/modules/package.json +2 -2
- package/ecomplus-stores/monocard/functions/passport/package.json +2 -2
- package/ecomplus-stores/monocard/functions/ssr/package.json +8 -8
- package/ecomplus-stores/monocard/functions/ssr/tailwind.config.cjs +1 -3
- package/ecomplus-stores/monocard/functions/ssr/{uno.config.ts → uno.config.cjs} +1 -1
- package/ecomplus-stores/monocard/package.json +1 -1
- package/ecomplus-stores/tia-sonia/README.md +0 -15
- package/ecomplus-stores/tia-sonia/README.pt-BR.md +0 -15
- package/ecomplus-stores/tia-sonia/functions/core/package.json +1 -1
- package/ecomplus-stores/tia-sonia/functions/events/package.json +2 -2
- package/ecomplus-stores/tia-sonia/functions/modules/package.json +2 -2
- package/ecomplus-stores/tia-sonia/functions/passport/package.json +2 -2
- package/ecomplus-stores/tia-sonia/functions/ssr/package.json +7 -7
- package/ecomplus-stores/tia-sonia/functions/ssr/tailwind.config.cjs +1 -3
- package/ecomplus-stores/tia-sonia/functions/ssr/{uno.config.ts → uno.config.cjs} +1 -1
- package/ecomplus-stores/tia-sonia/package.json +1 -1
- package/package.json +14 -14
- package/packages/api/lib/api.d.ts +4 -4
- package/packages/api/lib/types.d.ts +41 -41
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +2 -2
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/discounts/lib-mjs/apply-discount.mjs +94 -20
- package/packages/apps/discounts/package.json +2 -2
- package/packages/apps/emails/CHANGELOG.md +1 -0
- package/packages/apps/emails/README.md +1 -0
- package/packages/apps/emails/lib/events-to-app-emails.js +19 -0
- package/packages/apps/emails/lib/events-to-app-emails.js.map +1 -0
- package/packages/apps/emails/lib/firebase.js +19 -0
- package/packages/apps/emails/lib/firebase.js.map +1 -0
- package/packages/apps/emails/lib/functios-lib/abandoned-carts.js +86 -0
- package/packages/apps/emails/lib/functios-lib/abandoned-carts.js.map +1 -0
- package/packages/apps/emails/lib/functios-lib/handle-orders.js +174 -0
- package/packages/apps/emails/lib/functios-lib/handle-orders.js.map +1 -0
- package/packages/apps/emails/lib/functios-lib/trigger-actions.js +178 -0
- package/packages/apps/emails/lib/functios-lib/trigger-actions.js.map +1 -0
- package/packages/apps/emails/lib/functios-lib/utils.js +33 -0
- package/packages/apps/emails/lib/functios-lib/utils.js.map +1 -0
- package/packages/apps/emails/lib/index.js +2 -0
- package/packages/apps/emails/lib/index.js.map +1 -0
- package/packages/apps/emails/package.json +33 -0
- package/packages/apps/emails/src/events-to-app-emails.ts +27 -0
- package/packages/apps/emails/src/firebase.ts +25 -0
- package/packages/apps/emails/src/functios-lib/abandoned-carts.ts +100 -0
- package/packages/apps/emails/src/functios-lib/handle-orders.ts +232 -0
- package/packages/apps/emails/src/functios-lib/trigger-actions.ts +177 -0
- package/packages/apps/emails/src/functios-lib/utils.ts +44 -0
- package/packages/apps/emails/src/index.ts +1 -0
- package/packages/apps/emails/tsconfig.json +3 -0
- package/packages/apps/frenet/package.json +2 -2
- package/packages/apps/infinitepay/CHANGELOG.md +1 -0
- package/packages/apps/infinitepay/README.md +1 -0
- package/packages/apps/infinitepay/assets/onload-expression.js +57 -0
- package/packages/apps/infinitepay/lib/functions-lib/add-installments.d.ts +55 -0
- package/packages/apps/infinitepay/lib/functions-lib/add-installments.js +63 -0
- package/packages/apps/infinitepay/lib/functions-lib/add-installments.js.map +1 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-access.d.ts +14 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-access.js +63 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-access.js.map +1 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-axios.d.ts +2 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-axios.js +19 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/create-axios.js.map +1 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/oauth.d.ts +2 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/oauth.js +25 -0
- package/packages/apps/infinitepay/lib/functions-lib/ip-auth/oauth.js.map +1 -0
- package/packages/apps/infinitepay/lib/functions-lib/utils.d.ts +8 -0
- package/packages/apps/infinitepay/lib/functions-lib/utils.js +17 -0
- package/packages/apps/infinitepay/lib/functions-lib/utils.js.map +1 -0
- package/packages/apps/infinitepay/lib/index.d.ts +1 -0
- package/packages/apps/infinitepay/lib/index.js +3 -0
- package/packages/apps/infinitepay/lib/index.js.map +1 -0
- package/packages/apps/infinitepay/lib/infinitepay.d.ts +76 -0
- package/packages/apps/infinitepay/lib/infinitepay.js +13 -0
- package/packages/apps/infinitepay/lib/infinitepay.js.map +1 -0
- package/packages/apps/infinitepay/lib/ip-create-transaction.d.ts +72 -0
- package/packages/apps/infinitepay/lib/ip-create-transaction.js +305 -0
- package/packages/apps/infinitepay/lib/ip-create-transaction.js.map +1 -0
- package/packages/apps/infinitepay/lib/ip-list-payments.d.ts +8 -0
- package/packages/apps/infinitepay/lib/ip-list-payments.js +130 -0
- package/packages/apps/infinitepay/lib/ip-list-payments.js.map +1 -0
- package/packages/apps/infinitepay/lib/ip-webhook.d.ts +5 -0
- package/packages/apps/infinitepay/lib/ip-webhook.js +152 -0
- package/packages/apps/infinitepay/lib/ip-webhook.js.map +1 -0
- package/packages/apps/infinitepay/package.json +38 -0
- package/packages/apps/infinitepay/scripts/build.sh +5 -0
- package/packages/apps/infinitepay/src/functions-lib/add-installments.ts +78 -0
- package/packages/apps/infinitepay/src/functions-lib/ip-auth/create-access.ts +85 -0
- package/packages/apps/infinitepay/src/functions-lib/ip-auth/create-axios.ts +20 -0
- package/packages/apps/infinitepay/src/functions-lib/ip-auth/oauth.ts +30 -0
- package/packages/apps/infinitepay/src/functions-lib/utils.ts +23 -0
- package/packages/apps/infinitepay/src/index.ts +2 -0
- package/packages/apps/infinitepay/src/infinitepay.ts +13 -0
- package/packages/apps/infinitepay/src/ip-create-transaction.ts +418 -0
- package/packages/apps/infinitepay/src/ip-list-payments.ts +158 -0
- package/packages/apps/infinitepay/src/ip-webhook.ts +184 -0
- package/packages/apps/infinitepay/tsconfig.json +6 -0
- package/packages/apps/infinitepay/webhook.js +1 -0
- package/packages/apps/mercadopago/lib/mp-create-transaction.js +1 -1
- package/packages/apps/mercadopago/lib/mp-create-transaction.js.map +1 -1
- package/packages/apps/mercadopago/lib/mp-webhook.js +1 -1
- package/packages/apps/mercadopago/lib/mp-webhook.js.map +1 -1
- package/packages/apps/mercadopago/package.json +4 -4
- package/packages/apps/mercadopago/src/mp-create-transaction.ts +1 -1
- package/packages/apps/mercadopago/src/mp-webhook.ts +1 -1
- package/packages/apps/pagarme/CHANGELOG.md +1 -0
- package/packages/apps/pagarme/README.md +1 -0
- package/packages/apps/pagarme/assets/onload-expression.js +18 -0
- package/packages/apps/pagarme/lib/functions-lib/add-installments.d.ts +55 -0
- package/packages/apps/pagarme/lib/functions-lib/add-installments.js +48 -0
- package/packages/apps/pagarme/lib/functions-lib/add-installments.js.map +1 -0
- package/packages/apps/pagarme/lib/functions-lib/parse-status-to-ecom.d.ts +2 -0
- package/packages/apps/pagarme/lib/functions-lib/parse-status-to-ecom.js +24 -0
- package/packages/apps/pagarme/lib/functions-lib/parse-status-to-ecom.js.map +1 -0
- package/packages/apps/pagarme/lib/index.d.ts +1 -0
- package/packages/apps/pagarme/lib/index.js +3 -0
- package/packages/apps/pagarme/lib/index.js.map +1 -0
- package/packages/apps/pagarme/lib/pagarme-create-transaction.d.ts +82 -0
- package/packages/apps/pagarme/lib/pagarme-create-transaction.js +275 -0
- package/packages/apps/pagarme/lib/pagarme-create-transaction.js.map +1 -0
- package/packages/apps/pagarme/lib/pagarme-list-payments.d.ts +7 -0
- package/packages/apps/pagarme/lib/pagarme-list-payments.js +139 -0
- package/packages/apps/pagarme/lib/pagarme-list-payments.js.map +1 -0
- package/packages/apps/pagarme/lib/pagarme-webhook.d.ts +4 -0
- package/packages/apps/pagarme/lib/pagarme-webhook.js +80 -0
- package/packages/apps/pagarme/lib/pagarme-webhook.js.map +1 -0
- package/packages/apps/pagarme/lib/pagarme.d.ts +86 -0
- package/packages/apps/pagarme/lib/pagarme.js +12 -0
- package/packages/apps/pagarme/lib/pagarme.js.map +1 -0
- package/packages/apps/pagarme/package.json +38 -0
- package/packages/apps/pagarme/scripts/build.sh +5 -0
- package/packages/apps/pagarme/src/functions-lib/add-installments.ts +59 -0
- package/packages/apps/pagarme/src/functions-lib/parse-status-to-ecom.ts +23 -0
- package/packages/apps/pagarme/src/index.ts +2 -0
- package/packages/apps/pagarme/src/pagarme-create-transaction.ts +307 -0
- package/packages/apps/pagarme/src/pagarme-list-payments.ts +158 -0
- package/packages/apps/pagarme/src/pagarme-webhook.ts +88 -0
- package/packages/apps/pagarme/src/pagarme.ts +12 -0
- package/packages/apps/pagarme/tsconfig.json +6 -0
- package/packages/apps/pagarme/webhook.js +1 -0
- package/packages/apps/pix/CHANGELOG.md +1 -0
- package/packages/apps/pix/README.md +1 -0
- package/packages/apps/pix/lib/functions-lib/get-certificate.d.ts +2 -0
- package/packages/apps/pix/lib/functions-lib/get-certificate.js +21 -0
- package/packages/apps/pix/lib/functions-lib/get-certificate.js.map +1 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/construtor.d.ts +15 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/construtor.js +65 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/construtor.js.map +1 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/create-axios.d.ts +6 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/create-axios.js +20 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/create-axios.js.map +1 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/oauth.d.ts +12 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/oauth.js +36 -0
- package/packages/apps/pix/lib/functions-lib/pix-auth/oauth.js.map +1 -0
- package/packages/apps/pix/lib/index.d.ts +1 -0
- package/packages/apps/pix/lib/index.js +3 -0
- package/packages/apps/pix/lib/index.js.map +1 -0
- package/packages/apps/pix/lib/pix-create-transaction.d.ts +73 -0
- package/packages/apps/pix/lib/pix-create-transaction.js +221 -0
- package/packages/apps/pix/lib/pix-create-transaction.js.map +1 -0
- package/packages/apps/pix/lib/pix-list-payments.d.ts +14 -0
- package/packages/apps/pix/lib/pix-list-payments.js +80 -0
- package/packages/apps/pix/lib/pix-list-payments.js.map +1 -0
- package/packages/apps/pix/lib/pix-webhook.d.ts +5 -0
- package/packages/apps/pix/lib/pix-webhook.js +146 -0
- package/packages/apps/pix/lib/pix-webhook.js.map +1 -0
- package/packages/apps/pix/lib/pix.d.ts +77 -0
- package/packages/apps/pix/lib/pix.js +13 -0
- package/packages/apps/pix/lib/pix.js.map +1 -0
- package/packages/apps/pix/package.json +36 -0
- package/packages/apps/pix/src/functions-lib/get-certificate.ts +24 -0
- package/packages/apps/pix/src/functions-lib/pix-auth/construtor.ts +87 -0
- package/packages/apps/pix/src/functions-lib/pix-auth/create-axios.ts +24 -0
- package/packages/apps/pix/src/functions-lib/pix-auth/oauth.ts +50 -0
- package/packages/apps/pix/src/index.ts +2 -0
- package/packages/apps/pix/src/pix-create-transaction.ts +261 -0
- package/packages/apps/pix/src/pix-list-payments.ts +93 -0
- package/packages/apps/pix/src/pix-webhook.ts +171 -0
- package/packages/apps/pix/src/pix.ts +13 -0
- package/packages/apps/pix/tsconfig.json +6 -0
- package/packages/apps/pix/webhook.js +1 -0
- package/packages/apps/tiny-erp/package.json +5 -5
- package/packages/cli/bin/run.mjs +1 -1
- package/packages/cli/lib/build.js +14 -7
- package/packages/cli/lib/{index.js → cli.js} +2 -2
- package/packages/cli/lib/setup-gcloud.js +1 -1
- package/packages/cli/package.json +3 -3
- package/packages/cli/src/build.ts +17 -10
- package/packages/cli/src/{index.ts → cli.ts} +2 -2
- package/packages/cli/src/setup-gcloud.ts +1 -1
- package/packages/config/lib/config.d.ts +4 -2
- package/packages/config/lib/config.js +11 -4
- package/packages/config/lib/config.js.map +1 -1
- package/packages/config/lib/env.d.ts +1 -1
- package/packages/config/package.json +2 -2
- package/packages/config/src/config.ts +14 -5
- package/packages/emails/CHANGELOG.md +1 -0
- package/packages/emails/README.md +1 -0
- package/packages/emails/lib/index.d.ts +56 -0
- package/packages/emails/lib/index.js +83 -0
- package/packages/emails/lib/index.js.map +1 -0
- package/packages/emails/lib/parse-template-to-html.d.ts +3 -0
- package/packages/emails/lib/parse-template-to-html.js +16 -0
- package/packages/emails/lib/parse-template-to-html.js.map +1 -0
- package/packages/emails/lib/providers/sendgrid/index.d.ts +8 -0
- package/packages/emails/lib/providers/sendgrid/index.js +54 -0
- package/packages/emails/lib/providers/sendgrid/index.js.map +1 -0
- package/packages/emails/lib/providers/sendgrid/parse-to-data.d.ts +5 -0
- package/packages/emails/lib/providers/sendgrid/parse-to-data.js +55 -0
- package/packages/emails/lib/providers/sendgrid/parse-to-data.js.map +1 -0
- package/packages/emails/lib/providers/smtp/index.d.ts +13 -0
- package/packages/emails/lib/providers/smtp/index.js +79 -0
- package/packages/emails/lib/providers/smtp/index.js.map +1 -0
- package/packages/emails/package.json +35 -0
- package/packages/emails/src/index.ts +144 -0
- package/packages/emails/src/parse-template-to-html.ts +19 -0
- package/packages/emails/src/providers/sendgrid/index.ts +78 -0
- package/packages/emails/src/providers/sendgrid/parse-to-data.ts +92 -0
- package/packages/emails/src/providers/smtp/index.ts +115 -0
- package/packages/emails/tests/assets/customer.json +68 -0
- package/packages/emails/tests/assets/order.json +190 -0
- package/packages/emails/tests/assets/store.json +25 -0
- package/packages/emails/tests/ex.config-sendgrid.json +19 -0
- package/packages/emails/tests/ex.config-smtp.json +21 -0
- package/packages/emails/tests/sendgrid.test.ts +156 -0
- package/packages/emails/tests/smtp.test.ts +147 -0
- package/packages/emails/tests/templates/new-order.ejs +37 -0
- package/packages/emails/tsconfig.json +6 -0
- package/packages/emails/types/index.d.ts +84 -0
- package/packages/emails/types/sendgrid.d.ts +28 -0
- package/packages/events/lib/firebase.js +8 -0
- package/packages/events/lib/firebase.js.map +1 -1
- package/packages/events/package.json +7 -3
- package/packages/events/src/firebase.ts +8 -0
- package/packages/firebase/lib/config.d.ts +15 -1
- package/packages/firebase/lib/config.js +28 -1
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/lib/helpers/pubsub.d.ts +2 -2
- package/packages/firebase/package.json +5 -5
- package/packages/firebase/src/config.ts +31 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/lib/firebase/call-app-module.js +36 -0
- package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
- package/packages/modules/package.json +9 -6
- package/packages/modules/schemas/apply_discount.cjs +47 -0
- package/packages/modules/src/firebase/call-app-module.ts +36 -0
- package/packages/passport/lib/firebase/authenticate-customer.js +1 -1
- package/packages/passport/lib/firebase/authenticate-customer.js.map +1 -1
- package/packages/passport/package.json +3 -3
- package/packages/passport/src/firebase/authenticate-customer.ts +2 -2
- package/packages/ssr/package.json +8 -8
- package/packages/storefront/.eslintrc.cjs +4 -0
- package/packages/storefront/astro.config.mjs +12 -6
- package/packages/storefront/dist/client/HeaderButtons.bc4a5c97.js +1 -0
- package/packages/storefront/dist/client/assets/_...slug_.acb18581.css +1 -0
- package/packages/storefront/dist/client/chunks/HeaderButtons.861af799.js +1 -0
- package/packages/storefront/dist/client/chunks/{LoginForm.0c5ba697.js → LoginForm.7e9c481c.js} +4 -4
- package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.1b578f5a.js +1 -0
- package/packages/storefront/dist/client/{client.69fdbd1b.js → client.75c18572.js} +1 -1
- package/packages/storefront/dist/client/manifest.webmanifest +1 -1
- package/packages/storefront/dist/client/page.5a6f3db5.js +1 -0
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/{avif → chunks/avif}/avif_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/{avif → chunks/avif}/avif_node_enc.wasm +0 -0
- package/packages/storefront/dist/server/chunks/image-pool.f66f99fb.mjs +10791 -0
- package/packages/storefront/dist/server/{mozjpeg → chunks/mozjpeg}/mozjpeg_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/{mozjpeg → chunks/mozjpeg}/mozjpeg_node_enc.wasm +0 -0
- package/packages/storefront/dist/server/{png → chunks/png}/squoosh_oxipng_bg.wasm +0 -0
- package/packages/storefront/dist/server/{png → chunks/png}/squoosh_png_bg.wasm +0 -0
- package/packages/storefront/dist/server/{resize → chunks/resize}/squoosh_resize_bg.wasm +0 -0
- package/packages/storefront/dist/server/{rotate → chunks/rotate}/rotate.wasm +0 -0
- package/packages/storefront/dist/server/{webp → chunks/webp}/webp_node_dec.wasm +0 -0
- package/packages/storefront/dist/server/{webp → chunks/webp}/webp_node_enc.wasm +0 -0
- package/packages/storefront/dist/server/entry.mjs +10832 -13568
- package/packages/storefront/dist/server/manifest.webmanifest +1 -1
- package/packages/storefront/package.json +22 -18
- package/packages/storefront/src/lib/assets/base.css +110 -0
- package/packages/storefront/src/lib/assets/dark.css +92 -0
- package/packages/storefront/src/lib/assets/forms.css +0 -0
- package/packages/storefront/src/lib/assets/pico.css +29 -130
- package/packages/storefront/src/lib/assets/preflight.css +362 -0
- package/packages/storefront/src/lib/assets/typography.css +15 -0
- package/packages/storefront/src/lib/components/ADrawer.vue +11 -11
- package/packages/storefront/src/lib/components/LoginDrawer.vue +1 -1
- package/packages/storefront/src/lib/layouts/BaseBody.astro +2 -1
- package/packages/storefront/src/lib/layouts/BaseHead.astro +13 -3
- package/packages/storefront/src/lib/layouts/BaseStateJson.astro +3 -12
- package/packages/storefront/src/lib/ssr/image.ts +11 -5
- package/packages/storefront/src/lib/ssr-context.ts +3 -3
- package/packages/storefront/src/lib/state/shopping-cart/add-cart-item.ts +37 -57
- package/packages/storefront/src/lib/state/shopping-cart/parse-product.ts +36 -0
- package/packages/storefront/src/lib/state/shopping-cart.ts +32 -1
- package/packages/storefront/src/lib/types/cms-settings.d.ts +3 -1
- package/packages/storefront/storefront.cms.cjs +41 -0
- package/packages/storefront/storefront.cms.mjs +7 -2
- package/packages/storefront/storefront.config.mjs +1 -0
- package/packages/storefront/tailwind.config.cjs +142 -113
- package/packages/storefront/uno.config.cjs +126 -0
- package/packages/types/index.ts +21 -0
- package/packages/types/modules/apply_discount:response.d.ts +32 -0
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/HeaderButtons.b5b4a939.js +0 -1
- package/packages/storefront/dist/client/assets/_...slug_.8d138f36.css +0 -4
- package/packages/storefront/dist/client/chunks/HeaderButtons.308edb4d.js +0 -1
- package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.f00ab3bd.js +0 -1
- package/packages/storefront/dist/client/page.33c44e88.js +0 -1
- package/packages/storefront/uno.config.ts +0 -167
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/*
|
|
2
|
+
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
|
3
|
+
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
*,
|
|
7
|
+
::before,
|
|
8
|
+
::after {
|
|
9
|
+
box-sizing: border-box; /* 1 */
|
|
10
|
+
border-width: 0; /* 2 */
|
|
11
|
+
border-style: solid; /* 2 */
|
|
12
|
+
border-color: var(--c-border); /* 2 */
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
1. Use a consistent sensible line-height in all browsers.
|
|
17
|
+
2. Prevent adjustments of font size after orientation changes in iOS.
|
|
18
|
+
3. Use a more readable tab size.
|
|
19
|
+
4. Use the user's configured `sans` font-family by default.
|
|
20
|
+
5. Use the user's configured `sans` font-feature-settings by default.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
html {
|
|
24
|
+
line-height: 1.5; /* 1 */
|
|
25
|
+
-webkit-text-size-adjust: 100%; /* 2 */
|
|
26
|
+
-moz-tab-size: 4; /* 3 */
|
|
27
|
+
tab-size: 4; /* 3 */
|
|
28
|
+
font-family: var(--font-family); /* 4 */
|
|
29
|
+
font-feature-settings: normal; /* 5 */
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
1. Remove the margin in all browsers.
|
|
34
|
+
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
body {
|
|
38
|
+
margin: 0; /* 1 */
|
|
39
|
+
line-height: inherit; /* 2 */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
1. Add the correct height in Firefox.
|
|
44
|
+
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
|
45
|
+
3. Ensure horizontal rules are visible by default.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
hr {
|
|
49
|
+
height: 0; /* 1 */
|
|
50
|
+
color: inherit; /* 2 */
|
|
51
|
+
border-top-width: 1px; /* 3 */
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
Add the correct text decoration in Chrome, Edge, and Safari.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
abbr:where([title]) {
|
|
59
|
+
text-decoration: underline dotted;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
Remove the default font size and weight for headings.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
h1,
|
|
67
|
+
h2,
|
|
68
|
+
h3,
|
|
69
|
+
h4,
|
|
70
|
+
h5,
|
|
71
|
+
h6 {
|
|
72
|
+
font-size: inherit;
|
|
73
|
+
font-weight: inherit;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
Reset links to optimize for opt-in styling instead of opt-out.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
a {
|
|
81
|
+
color: inherit;
|
|
82
|
+
text-decoration: inherit;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
Add the correct font weight in Edge and Safari.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
b,
|
|
90
|
+
strong {
|
|
91
|
+
font-weight: bolder;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
1. Use the user's configured `mono` font family by default.
|
|
96
|
+
2. Correct the odd `em` font sizing in all browsers.
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
code,
|
|
100
|
+
kbd,
|
|
101
|
+
samp,
|
|
102
|
+
pre {
|
|
103
|
+
font-family: var(--font-mono); /* 1 */
|
|
104
|
+
font-size: 1em; /* 2 */
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
Add the correct font size in all browsers.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
small {
|
|
112
|
+
font-size: 80%;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
sub,
|
|
120
|
+
sup {
|
|
121
|
+
font-size: 75%;
|
|
122
|
+
line-height: 0;
|
|
123
|
+
position: relative;
|
|
124
|
+
vertical-align: baseline;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
sub {
|
|
128
|
+
bottom: -0.25em;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
sup {
|
|
132
|
+
top: -0.5em;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
|
137
|
+
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
|
138
|
+
3. Remove gaps between table borders by default.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
table {
|
|
142
|
+
text-indent: 0; /* 1 */
|
|
143
|
+
border-color: inherit; /* 2 */
|
|
144
|
+
border-collapse: collapse; /* 3 */
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
1. Change the font styles in all browsers.
|
|
149
|
+
2. Remove the margin in Firefox and Safari.
|
|
150
|
+
3. Remove default padding in all browsers.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
button,
|
|
154
|
+
input,
|
|
155
|
+
optgroup,
|
|
156
|
+
select,
|
|
157
|
+
textarea {
|
|
158
|
+
font-family: inherit; /* 1 */
|
|
159
|
+
font-size: 100%; /* 1 */
|
|
160
|
+
font-weight: inherit; /* 1 */
|
|
161
|
+
line-height: inherit; /* 1 */
|
|
162
|
+
color: inherit; /* 1 */
|
|
163
|
+
margin: 0; /* 2 */
|
|
164
|
+
padding: 0; /* 3 */
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
Remove the inheritance of text transform in Edge and Firefox.
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
button,
|
|
172
|
+
select {
|
|
173
|
+
text-transform: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
1. Correct the inability to style clickable types in iOS and Safari.
|
|
178
|
+
2. Remove default button styles.
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
button,
|
|
182
|
+
[type='button'],
|
|
183
|
+
[type='reset'],
|
|
184
|
+
[type='submit'] {
|
|
185
|
+
-webkit-appearance: button; /* 1 */
|
|
186
|
+
background-color: transparent; /* 2 */
|
|
187
|
+
background-image: none; /* 2 */
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
Use the modern Firefox focus style for all focusable elements.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
:-moz-focusring {
|
|
195
|
+
outline: auto;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/*
|
|
199
|
+
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
:-moz-ui-invalid {
|
|
203
|
+
box-shadow: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/*
|
|
207
|
+
Add the correct vertical alignment in Chrome and Firefox.
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
progress {
|
|
211
|
+
vertical-align: baseline;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/*
|
|
215
|
+
Correct the cursor style of increment and decrement buttons in Safari.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
::-webkit-inner-spin-button,
|
|
219
|
+
::-webkit-outer-spin-button {
|
|
220
|
+
height: auto;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/*
|
|
224
|
+
1. Correct the odd appearance in Chrome and Safari.
|
|
225
|
+
2. Correct the outline style in Safari.
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
[type='search'] {
|
|
229
|
+
-webkit-appearance: textfield; /* 1 */
|
|
230
|
+
outline-offset: -2px; /* 2 */
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/*
|
|
234
|
+
Remove the inner padding in Chrome and Safari on macOS.
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
::-webkit-search-decoration {
|
|
238
|
+
-webkit-appearance: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/*
|
|
242
|
+
1. Correct the inability to style clickable types in iOS and Safari.
|
|
243
|
+
2. Change font properties to `inherit` in Safari.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
::-webkit-file-upload-button {
|
|
247
|
+
-webkit-appearance: button; /* 1 */
|
|
248
|
+
font: inherit; /* 2 */
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
Add the correct display in Chrome and Safari.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
summary {
|
|
256
|
+
display: list-item;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/*
|
|
260
|
+
Removes the default spacing and border for appropriate elements.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
blockquote,
|
|
264
|
+
dl,
|
|
265
|
+
dd,
|
|
266
|
+
h1,
|
|
267
|
+
h2,
|
|
268
|
+
h3,
|
|
269
|
+
h4,
|
|
270
|
+
h5,
|
|
271
|
+
h6,
|
|
272
|
+
hr,
|
|
273
|
+
figure,
|
|
274
|
+
p,
|
|
275
|
+
pre {
|
|
276
|
+
margin: 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
fieldset {
|
|
280
|
+
margin: 0;
|
|
281
|
+
padding: 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
legend {
|
|
285
|
+
padding: 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
ol,
|
|
289
|
+
ul,
|
|
290
|
+
menu {
|
|
291
|
+
list-style: none;
|
|
292
|
+
margin: 0;
|
|
293
|
+
padding: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/*
|
|
297
|
+
Prevent resizing textareas horizontally by default.
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
textarea {
|
|
301
|
+
resize: vertical;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/*
|
|
305
|
+
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
|
|
306
|
+
2. Set the default placeholder color to the user's configured gray 400 color.
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
input::placeholder,
|
|
310
|
+
textarea::placeholder {
|
|
311
|
+
opacity: 1; /* 1 */
|
|
312
|
+
color: var(--c-text-muted); /* 2 */
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/*
|
|
316
|
+
Set the default cursor for buttons.
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
button,
|
|
320
|
+
[role="button"] {
|
|
321
|
+
cursor: pointer;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/*
|
|
325
|
+
Make sure disabled buttons don't get the pointer cursor.
|
|
326
|
+
*/
|
|
327
|
+
:disabled {
|
|
328
|
+
cursor: default;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/*
|
|
332
|
+
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
333
|
+
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
|
334
|
+
This can trigger a poorly considered lint error in some tools but is included by design.
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
img,
|
|
338
|
+
svg,
|
|
339
|
+
video,
|
|
340
|
+
canvas,
|
|
341
|
+
audio,
|
|
342
|
+
iframe,
|
|
343
|
+
embed,
|
|
344
|
+
object {
|
|
345
|
+
display: block; /* 1 */
|
|
346
|
+
vertical-align: middle; /* 2 */
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/*
|
|
350
|
+
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
img,
|
|
354
|
+
video {
|
|
355
|
+
max-width: 100%;
|
|
356
|
+
height: auto;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* Make elements with the HTML hidden attribute stay hidden by default */
|
|
360
|
+
[hidden] {
|
|
361
|
+
display: none;
|
|
362
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.prose :is(a, [role=link]) {
|
|
2
|
+
color: var(--c-link);
|
|
3
|
+
text-decoration: underline;
|
|
4
|
+
transition: color var(--transition), text-decoration var(--transition);
|
|
5
|
+
}
|
|
6
|
+
.prose a:hover {
|
|
7
|
+
color: var(--c-link-hover);
|
|
8
|
+
}
|
|
9
|
+
.prose a:visited,
|
|
10
|
+
.prose a:active {
|
|
11
|
+
color: var(--c-link-visited);
|
|
12
|
+
}
|
|
13
|
+
.prose a:active {
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
}
|
|
@@ -62,13 +62,13 @@ const transition3dTx = computed(() => {
|
|
|
62
62
|
<Transition>
|
|
63
63
|
<dialog
|
|
64
64
|
v-if="modelValue"
|
|
65
|
-
class="
|
|
65
|
+
class="drawer p-0"
|
|
66
66
|
:class="placement === 'end' ? 'justify-end' : 'justify-start'"
|
|
67
67
|
:open="modelValue"
|
|
68
68
|
>
|
|
69
69
|
<article
|
|
70
70
|
ref="article"
|
|
71
|
-
class="rounded-none h-full max-h-screen m-0"
|
|
71
|
+
class="card rounded-none h-full max-h-screen m-0"
|
|
72
72
|
>
|
|
73
73
|
<a
|
|
74
74
|
href="#close"
|
|
@@ -85,26 +85,26 @@ const transition3dTx = computed(() => {
|
|
|
85
85
|
</template>
|
|
86
86
|
|
|
87
87
|
<style>
|
|
88
|
-
.
|
|
89
|
-
.
|
|
88
|
+
.drawer.v-enter-active,
|
|
89
|
+
.drawer.v-leave-active {
|
|
90
90
|
transition: opacity 0.15s linear;
|
|
91
91
|
}
|
|
92
|
-
.
|
|
93
|
-
.
|
|
92
|
+
.drawer.v-enter-from,
|
|
93
|
+
.drawer.v-leave-to {
|
|
94
94
|
opacity: 0;
|
|
95
95
|
}
|
|
96
|
-
.
|
|
97
|
-
.
|
|
96
|
+
.drawer.v-enter-active article,
|
|
97
|
+
.drawer.v-leave-active article {
|
|
98
98
|
transition: transform 0.25s ease-in-out;
|
|
99
99
|
}
|
|
100
|
-
.
|
|
101
|
-
.
|
|
100
|
+
.drawer.v-enter-from article,
|
|
101
|
+
.drawer.v-leave-to article {
|
|
102
102
|
transform: translate3d(var(--transition-3d-tx), 0, 0);
|
|
103
103
|
}
|
|
104
104
|
</style>
|
|
105
105
|
|
|
106
106
|
<style scoped>
|
|
107
|
-
.
|
|
107
|
+
.drawer {
|
|
108
108
|
--transition-3d-tx: v-bind(transition3dTx);
|
|
109
109
|
}
|
|
110
110
|
</style>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type CmsSocial from '@@storefront/types/cms-social';
|
|
3
|
+
import { img as getImg } from '@ecomplus/utils';
|
|
3
4
|
import type { PageContext } from '@@storefront/ssr-context';
|
|
4
|
-
import
|
|
5
|
+
import { getImage as transformImage } from '@@storefront/ssr/image';
|
|
5
6
|
|
|
6
7
|
export interface Props {
|
|
7
8
|
pageContext: PageContext;
|
|
@@ -21,12 +22,21 @@ const {
|
|
|
21
22
|
const state = apiDoc || cmsContent || {};
|
|
22
23
|
const title = state.meta_title || state.name || state.title || Astro.props.title || settings.name;
|
|
23
24
|
const description = state.meta_description || state.short_description || settings.description;
|
|
25
|
+
const favicon = settings.icon
|
|
26
|
+
? (await transformImage({
|
|
27
|
+
src: settings.icon,
|
|
28
|
+
width: 32,
|
|
29
|
+
height: 32,
|
|
30
|
+
format: 'png',
|
|
31
|
+
isLowResolution: true,
|
|
32
|
+
})).src
|
|
33
|
+
: '/favicon.ico';
|
|
24
34
|
const canonicalUrl = new URL(Astro.url.pathname, Astro.site || `https://${domain}`);
|
|
25
35
|
const cmsSocial = cms('social') as CmsSocial;
|
|
26
36
|
const ogLocale = lang.length === 2 ? lang : lang.substring(0, 2) + lang.slice(3).toUpperCase();
|
|
27
37
|
let ogImage: string | undefined;
|
|
28
38
|
if (apiDoc) {
|
|
29
|
-
const picture =
|
|
39
|
+
const picture = getImg(state, null, 'zoom');
|
|
30
40
|
ogImage = picture && picture.url;
|
|
31
41
|
}
|
|
32
42
|
if (!ogImage) {
|
|
@@ -42,7 +52,7 @@ if (!ogImage) {
|
|
|
42
52
|
<meta charset="UTF-8">
|
|
43
53
|
<meta name="viewport" content="width=device-width">
|
|
44
54
|
<meta name="theme-color" content={primaryColor}>
|
|
45
|
-
<link rel="icon" href={
|
|
55
|
+
<link rel="icon" href={favicon} />
|
|
46
56
|
{import.meta.env.PROD && <link rel="manifest" href="/manifest.webmanifest" />}
|
|
47
57
|
<title>{title}</title>
|
|
48
58
|
<meta name="description" content={description}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { PageContext } from '@@storefront/ssr-context';
|
|
3
|
-
import
|
|
3
|
+
import { price as getPrice } from '@ecomplus/utils';
|
|
4
4
|
|
|
5
5
|
export interface Props {
|
|
6
6
|
pageContext: PageContext;
|
|
@@ -26,19 +26,10 @@ window.ECOM_LANG = '${lang}';
|
|
|
26
26
|
window.ECOM_CURRENCY = '${currency}';
|
|
27
27
|
window.ECOM_CURRENCY_SYMBOL = '${currencySymbol}';
|
|
28
28
|
window.ECOM_COUNTRY_CODE = '${countryCode}';
|
|
29
|
-
window.storefront = ${JSON.stringify({
|
|
30
|
-
settings: {
|
|
31
|
-
...settings,
|
|
32
|
-
store_id: storeId,
|
|
33
|
-
lang,
|
|
34
|
-
country_code: countryCode,
|
|
35
|
-
currency,
|
|
36
|
-
currency_symbol: currencySymbol,
|
|
37
|
-
},
|
|
38
|
-
})};`;
|
|
29
|
+
window.storefront = ${JSON.stringify({ settings })};`;
|
|
39
30
|
if (apiDoc) {
|
|
40
31
|
if (typeof apiDoc.price === 'number') {
|
|
41
|
-
apiDoc.price =
|
|
32
|
+
apiDoc.price = getPrice(apiDoc);
|
|
42
33
|
}
|
|
43
34
|
const slimDocRegex = globalThis.storefront_slim_doc_regex
|
|
44
35
|
|| /body|meta|records|description|i18n/;
|
|
@@ -15,11 +15,17 @@ const tryImageSize = (src: string) => {
|
|
|
15
15
|
return dimensions;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
type TransformOptions = Parameters<typeof _getImage>[0] & {
|
|
19
|
+
isLowResolution?: boolean,
|
|
20
|
+
};
|
|
21
|
+
const getImage = async (options: TransformOptions) => {
|
|
22
|
+
if (!options.isLowResolution) {
|
|
23
|
+
if (options.width) {
|
|
24
|
+
options.width *= 2;
|
|
25
|
+
}
|
|
26
|
+
if (options.height) {
|
|
27
|
+
options.height *= 2;
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
if (
|
|
25
31
|
typeof options.src === 'string'
|
|
@@ -37,7 +37,7 @@ const setResponseCache = (Astro: AstroGlobal, maxAge: number, sMaxAge?: number)
|
|
|
37
37
|
const headerName = import.meta.env.PROD ? 'Cache-Control' : 'X-Cache-Control';
|
|
38
38
|
let cacheControl = `public, max-age=${maxAge}, must-revalidate`;
|
|
39
39
|
if (sMaxAge) {
|
|
40
|
-
cacheControl += `, s-maxage=${sMaxAge}, stale-while-revalidate
|
|
40
|
+
cacheControl += `, s-maxage=${sMaxAge}, stale-while-revalidate=604800`;
|
|
41
41
|
}
|
|
42
42
|
Astro.response.headers.set(headerName, cacheControl);
|
|
43
43
|
};
|
|
@@ -113,9 +113,9 @@ const loadPageContext = async (Astro: AstroGlobal, {
|
|
|
113
113
|
if (urlPath === '/fallback') {
|
|
114
114
|
setResponseCache(Astro, 3600, 86400);
|
|
115
115
|
} else if (urlPath === '/') {
|
|
116
|
-
setResponseCache(Astro, 180,
|
|
116
|
+
setResponseCache(Astro, 180, 300);
|
|
117
117
|
} else {
|
|
118
|
-
setResponseCache(Astro, 120,
|
|
118
|
+
setResponseCache(Astro, 120, 300);
|
|
119
119
|
}
|
|
120
120
|
return {
|
|
121
121
|
...config,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CartSet } from '@cloudcommerce/api/types';
|
|
2
2
|
import { randomObjectId } from '@ecomplus/utils';
|
|
3
|
-
import fixItemQuantity from './../lib/fix-item-quantity'
|
|
4
|
-
import fixItemFinalPrice from './../lib/fix-item-final-price'
|
|
5
|
-
import fixSubtotal from './../lib/fix-subtotal'
|
|
6
3
|
|
|
7
|
-
type CartItem =
|
|
4
|
+
type CartItem = CartSet['items'][0];
|
|
8
5
|
|
|
9
|
-
const
|
|
6
|
+
const matchItemsFlags = (item: CartItem, newItem: CartItem) => {
|
|
10
7
|
if (!item.flags && !newItem.flags) {
|
|
11
8
|
return true;
|
|
12
9
|
}
|
|
@@ -20,70 +17,53 @@ const checkItems = (item: CartItem, newItem: CartItem) => {
|
|
|
20
17
|
return item.flags.every((flag) => newItem.flags.includes(flag));
|
|
21
18
|
};
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
const addCartItem = (cart: CartSet, newItem: CartItem): null | CartItem => {
|
|
24
21
|
if (
|
|
25
|
-
typeof newItem.product_id !== 'string'
|
|
26
|
-
typeof newItem.quantity !== 'number' || !(newItem.quantity >= 0)
|
|
27
|
-
typeof newItem.price !== 'number' || !(newItem.price >= 0)
|
|
22
|
+
typeof newItem.product_id !== 'string'
|
|
23
|
+
|| typeof newItem.quantity !== 'number' || !(newItem.quantity >= 0)
|
|
24
|
+
|| typeof newItem.price !== 'number' || !(newItem.price >= 0)
|
|
28
25
|
) {
|
|
29
|
-
return null
|
|
26
|
+
return null;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
let fixedItem
|
|
28
|
+
const { items } = cart;
|
|
33
29
|
if (!newItem.kit_product) {
|
|
34
|
-
for (let i = 0; i <
|
|
35
|
-
const item =
|
|
30
|
+
for (let i = 0; i < items.length; i++) {
|
|
31
|
+
const item = items[i];
|
|
36
32
|
if (
|
|
37
|
-
!item.kit_product
|
|
38
|
-
|
|
39
|
-
item.
|
|
40
|
-
item.
|
|
41
|
-
(
|
|
42
|
-
checkFlags(item, newItem)
|
|
33
|
+
!item.kit_product
|
|
34
|
+
&& item.product_id === newItem.product_id
|
|
35
|
+
&& item.variation_id === newItem.variation_id
|
|
36
|
+
&& (!item.customizations || !item.customizations.length)
|
|
37
|
+
&& matchItemsFlags(item, newItem)
|
|
43
38
|
) {
|
|
44
|
-
item.quantity += newItem.quantity
|
|
39
|
+
item.quantity += newItem.quantity;
|
|
45
40
|
if (newItem.price) {
|
|
46
|
-
item.price = newItem.price
|
|
41
|
+
item.price = newItem.price;
|
|
47
42
|
}
|
|
48
43
|
if (newItem.final_price) {
|
|
49
|
-
item.final_price = newItem.final_price
|
|
44
|
+
item.final_price = newItem.final_price;
|
|
50
45
|
}
|
|
51
|
-
|
|
46
|
+
return item;
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
itemCopy.customizations[i] = Object.assign({}, customization)
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
data.items.push(itemCopy)
|
|
71
|
-
fixedItem = fixItemQuantity(itemCopy)
|
|
72
|
-
fixItemFinalPrice(fixedItem)
|
|
50
|
+
const itemCopy = { ...newItem };
|
|
51
|
+
if (
|
|
52
|
+
!newItem._id
|
|
53
|
+
|| newItem._id === newItem.variation_id
|
|
54
|
+
|| items.find(({ _id }) => _id === newItem._id)
|
|
55
|
+
) {
|
|
56
|
+
itemCopy._id = randomObjectId();
|
|
57
|
+
}
|
|
58
|
+
if (newItem.customizations) {
|
|
59
|
+
newItem.customizations.forEach((customization, i) => {
|
|
60
|
+
itemCopy.customizations[i] = { ...customization };
|
|
61
|
+
});
|
|
73
62
|
}
|
|
74
|
-
|
|
63
|
+
items.push(itemCopy);
|
|
64
|
+
return itemCopy;
|
|
65
|
+
};
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
* @event EcomCart#addItem
|
|
78
|
-
* @type {object}
|
|
79
|
-
* @property {object} data - Shopping cart data
|
|
80
|
-
* @property {object} item - Item added to cart
|
|
81
|
-
* @example ecomCart.on('addItem', ({ data, item }) => { console.log(data, item) })
|
|
82
|
-
*/
|
|
83
|
-
emitter.emit('addItem', { data, item: fixedItem })
|
|
67
|
+
export default addCartItem;
|
|
84
68
|
|
|
85
|
-
|
|
86
|
-
save(false)
|
|
87
|
-
}
|
|
88
|
-
return fixedItem
|
|
89
|
-
}
|
|
69
|
+
export { matchItemsFlags, addCartItem };
|