@akinon/projectzero 2.0.0-beta.9 → 2.0.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/CHANGELOG.md +191 -17
- package/app-template/.env.example +3 -0
- package/app-template/.github/instructions/account.instructions.md +749 -0
- package/app-template/.github/instructions/checkout.instructions.md +678 -0
- package/app-template/.github/instructions/default.instructions.md +279 -0
- package/app-template/.github/instructions/edge-cases.instructions.md +73 -0
- package/app-template/.github/instructions/routing.instructions.md +603 -0
- package/app-template/.github/instructions/settings.instructions.md +338 -0
- package/app-template/.gitignore +3 -0
- package/app-template/AGENTS.md +7 -0
- package/app-template/CHANGELOG.md +2065 -232
- package/app-template/Procfile +1 -1
- package/app-template/akinon.json +1 -4
- package/app-template/build.sh +10 -0
- package/app-template/docs/advanced-usage.md +111 -0
- package/app-template/docs/plugins.md +60 -25
- package/app-template/docs/sentry-usage.md +35 -0
- package/app-template/jest.config.ts +2 -2
- package/app-template/next-env.d.ts +1 -0
- package/app-template/{next.config.ts → next.config.mjs} +6 -7
- package/app-template/package.json +58 -50
- package/app-template/postcss.config.mjs +1 -4
- package/app-template/public/amex.svg +12 -0
- package/app-template/public/apple-pay.svg +16 -0
- package/app-template/public/assets/images/product-placeholder-1.jpg +0 -0
- package/app-template/public/assets/images/product-placeholder-2.jpg +0 -0
- package/app-template/public/assets/images/product-placeholder-3.jpg +0 -0
- package/app-template/public/assets/images/product-placeholder-4.jpg +0 -0
- package/app-template/public/google-pay.svg +16 -0
- package/app-template/public/locales/en/account.json +9 -4
- package/app-template/public/locales/en/auth.json +6 -7
- package/app-template/public/locales/en/basket.json +6 -6
- package/app-template/public/locales/en/blog.json +7 -0
- package/app-template/public/locales/en/category.json +3 -1
- package/app-template/public/locales/en/checkout.json +17 -4
- package/app-template/public/locales/en/common.json +61 -3
- package/app-template/public/locales/en/forgot_password.json +6 -7
- package/app-template/public/locales/en/product.json +84 -4
- package/app-template/public/locales/tr/account.json +9 -4
- package/app-template/public/locales/tr/auth.json +16 -17
- package/app-template/public/locales/tr/basket.json +4 -4
- package/app-template/public/locales/tr/blog.json +7 -0
- package/app-template/public/locales/tr/category.json +3 -1
- package/app-template/public/locales/tr/checkout.json +48 -36
- package/app-template/public/locales/tr/common.json +60 -2
- package/app-template/public/locales/tr/forgot_password.json +12 -13
- package/app-template/public/locales/tr/product.json +82 -0
- package/app-template/public/logo.svg +3 -27
- package/app-template/public/mastercard.svg +14 -0
- package/app-template/public/masterpass-javascript-sdk-web.min.js +1 -0
- package/app-template/public/promotion-banner.jpg +0 -0
- package/app-template/public/shop-pay.svg +12 -0
- package/app-template/public/visa.svg +12 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/[...prettyurl]/page.tsx +11 -11
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/layout.tsx +4 -3
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/cancellation/page.tsx +13 -10
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/page.tsx +73 -51
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/page.tsx +1 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/profile/page.tsx +2 -2
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/address/stores/page.tsx +2 -2
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/auth/page.tsx +1 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/basket/page.tsx +2 -2
- package/app-template/src/app/[pz]/blog/[slug]/page.tsx +120 -0
- package/app-template/src/app/[pz]/category/[pk]/page.tsx +37 -0
- package/app-template/src/app/[pz]/flat-page/[pk]/page.tsx +23 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/forms/[pk]/generate/page.tsx +2 -3
- package/app-template/src/app/[pz]/group-product/[pk]/page.tsx +93 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/landing-page/[pk]/page.tsx +2 -4
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/layout.tsx +6 -11
- package/app-template/src/app/[pz]/list/page.tsx +26 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/not-found.tsx +5 -7
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/completed/[token]/page.tsx +6 -4
- package/app-template/src/app/[pz]/page.tsx +28 -0
- package/app-template/src/app/[pz]/pages/[slug]/page.tsx +19 -0
- package/app-template/src/app/[pz]/product/[pk]/page.tsx +102 -0
- package/app-template/src/app/[pz]/special-page/[pk]/page.tsx +35 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/email-set-primary/[[...id]]/page.tsx +3 -4
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/registration/account-confirm-email/[[...id]]/page.tsx +3 -3
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/reset/[[...id]]/page.tsx +41 -5
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/xml-sitemap/[node]/route.ts +8 -6
- package/app-template/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/app-template/src/app/api/barcode-search/route.ts +1 -0
- package/app-template/src/app/api/cache/route.ts +1 -1
- package/app-template/src/app/api/form/[...id]/route.ts +1 -7
- package/app-template/src/app/api/image-proxy/route.ts +1 -0
- package/app-template/src/app/api/logout/route.ts +1 -1
- package/app-template/src/app/api/product-categories/route.ts +1 -0
- package/app-template/src/app/api/similar-product-list/route.ts +1 -0
- package/app-template/src/app/api/similar-products/route.ts +1 -0
- package/app-template/src/app/api/theme-settings/route.ts +12 -0
- package/app-template/src/app/api/virtual-try-on/limited-categories/route.ts +1 -0
- package/app-template/src/app/api/virtual-try-on/route.ts +1 -0
- package/app-template/src/app/api/web-vitals/route.ts +1 -1
- package/app-template/src/assets/fonts/pz-icon.css +211 -49
- package/app-template/src/assets/fonts/pz-icon.eot +0 -0
- package/app-template/src/assets/fonts/pz-icon.html +486 -0
- package/app-template/src/assets/fonts/pz-icon.scss +373 -49
- package/app-template/src/assets/fonts/pz-icon.svg +215 -53
- package/app-template/src/assets/fonts/pz-icon.ttf +0 -0
- package/app-template/src/assets/fonts/pz-icon.woff +0 -0
- package/app-template/src/assets/fonts/pz-icon.woff2 +0 -0
- package/app-template/src/assets/globals.scss +8 -133
- package/app-template/src/assets/icons/arrow-right.svg +3 -0
- package/app-template/src/assets/icons/cart.svg +4 -12
- package/app-template/src/assets/icons/check.svg +2 -18
- package/app-template/src/assets/icons/chevron-down.svg +2 -7
- package/app-template/src/assets/icons/delete.svg +3 -0
- package/app-template/src/assets/icons/facebook.svg +2 -8
- package/app-template/src/assets/icons/fav-off.svg +5 -0
- package/app-template/src/assets/icons/fav-on.svg +5 -0
- package/app-template/src/assets/icons/filter-and-sort.svg +3 -0
- package/app-template/src/assets/icons/heart.svg +3 -0
- package/app-template/src/assets/icons/instagram.svg +2 -13
- package/app-template/src/assets/icons/materials.svg +3 -0
- package/app-template/src/assets/icons/person.svg +4 -0
- package/app-template/src/assets/icons/pinterest.svg +5 -11
- package/app-template/src/assets/icons/ruler.svg +3 -0
- package/app-template/src/assets/icons/search.svg +8 -11
- package/app-template/src/assets/icons/share.svg +2 -9
- package/app-template/src/assets/icons/snapchat.svg +3 -0
- package/app-template/src/assets/icons/tiktok.svg +3 -0
- package/app-template/src/assets/icons/tumblr.svg +6 -0
- package/app-template/src/assets/icons/twitter.svg +2 -10
- package/app-template/src/assets/icons/vimeo.svg +3 -0
- package/app-template/src/assets/icons/youtube.svg +3 -0
- package/app-template/src/assets/icons/zoom.svg +8 -0
- package/app-template/src/auth.ts +3 -0
- package/app-template/src/components/__tests__/badge.test.tsx +2 -2
- package/app-template/src/components/__tests__/link.test.tsx +2 -0
- package/app-template/src/components/accordion.tsx +48 -23
- package/app-template/src/components/action-tooltip.tsx +160 -0
- package/app-template/src/components/button.tsx +1 -1
- package/app-template/src/components/carousel-core.tsx +4 -11
- package/app-template/src/components/checkbox.tsx +2 -1
- package/app-template/src/components/currency-select.tsx +150 -4
- package/app-template/src/components/file-input.tsx +27 -7
- package/app-template/src/components/generate-form-fields.tsx +49 -10
- package/app-template/src/components/icon.tsx +5 -6
- package/app-template/src/components/index.ts +4 -1
- package/app-template/src/components/input.tsx +11 -5
- package/app-template/src/components/language-select.tsx +88 -2
- package/app-template/src/components/modal.tsx +34 -16
- package/app-template/src/components/pagination.tsx +133 -20
- package/app-template/src/components/price.tsx +1 -1
- package/app-template/src/components/pwa-tags.tsx +1 -0
- package/app-template/src/components/quantity-input.tsx +63 -0
- package/app-template/src/components/quantity-selector.tsx +215 -0
- package/app-template/src/components/route-handler.tsx +50 -0
- package/app-template/src/components/select.tsx +86 -54
- package/app-template/src/components/shimmer.tsx +1 -1
- package/app-template/src/components/types/index.ts +51 -1
- package/app-template/src/components/widget-content.tsx +323 -0
- package/app-template/src/data/server/theme.ts +70 -0
- package/app-template/src/hooks/use-fav-button.tsx +9 -10
- package/app-template/src/hooks/use-product-cart.ts +80 -0
- package/app-template/src/hooks/use-stock-alert.ts +74 -0
- package/app-template/src/hooks/use-theme-settings.ts +42 -0
- package/app-template/src/lib/fonts.ts +149 -0
- package/app-template/src/plugins.js +12 -2
- package/app-template/src/{middleware.ts → proxy.ts} +3 -3
- package/app-template/src/redux/middlewares/category.ts +5 -4
- package/app-template/src/redux/store.ts +21 -1
- package/app-template/src/routes/index.ts +8 -7
- package/app-template/src/settings.js +6 -3
- package/app-template/src/types/hookform-resolvers-yup.d.ts +28 -0
- package/app-template/src/types/index.ts +74 -3
- package/app-template/src/types/next-auth.d.ts +2 -2
- package/app-template/src/types/widget.ts +169 -0
- package/app-template/src/utils/__tests__/theme-page-context.test.ts +145 -0
- package/app-template/src/utils/formatDate.ts +48 -0
- package/app-template/src/utils/styles.ts +71 -0
- package/app-template/src/utils/theme-page-context.ts +309 -0
- package/app-template/src/utils/variant-validation.ts +41 -0
- package/app-template/src/views/account/address-form.tsx +8 -4
- package/app-template/src/views/account/contact-form.tsx +148 -131
- package/app-template/src/views/account/content-header.tsx +4 -3
- package/app-template/src/views/account/faq/faq-tabs.tsx +8 -2
- package/app-template/src/views/account/favorite-item.tsx +1 -1
- package/app-template/src/views/account/order.tsx +11 -9
- package/app-template/src/views/account/orders/order-cancellation-item.tsx +1 -1
- package/app-template/src/views/account/orders/order-detail-header.tsx +1 -1
- package/app-template/src/views/anonymous-tracking/order-detail/index.tsx +45 -38
- package/app-template/src/views/basket/basket-item.tsx +6 -1
- package/app-template/src/views/basket/summary.tsx +16 -0
- package/app-template/src/views/breadcrumb.tsx +2 -2
- package/app-template/src/views/category/category-banner.tsx +4 -23
- package/app-template/src/views/category/category-info.tsx +2 -1
- package/app-template/src/views/category/filters/filter-item.tsx +138 -42
- package/app-template/src/views/category/filters/index.tsx +1 -1
- package/app-template/src/views/category/layout.tsx +1 -0
- package/app-template/src/views/checkout/auth.tsx +64 -40
- package/app-template/src/views/checkout/layout/header.tsx +10 -6
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +22 -6
- package/app-template/src/views/checkout/steps/payment/options/funds-transfer.tsx +25 -5
- package/app-template/src/views/checkout/steps/payment/options/loyalty.tsx +21 -2
- package/app-template/src/views/checkout/steps/payment/options/redirection.tsx +27 -5
- package/app-template/src/views/checkout/steps/payment/options/store-credit.tsx +464 -0
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +4 -4
- package/app-template/src/views/checkout/steps/shipping/address-box.tsx +33 -20
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +2 -2
- package/app-template/src/views/checkout/summary.tsx +12 -2
- package/app-template/src/views/find-in-store/index.tsx +2 -2
- package/app-template/src/views/guest-login/index.tsx +62 -58
- package/app-template/src/views/header/action-menu.tsx +1 -1
- package/app-template/src/views/header/band.tsx +2 -2
- package/app-template/src/views/header/index.tsx +1 -1
- package/app-template/src/views/header/mini-basket.tsx +3 -3
- package/app-template/src/views/header/mobile-hamburger-button.tsx +5 -8
- package/app-template/src/views/header/mobile-menu.tsx +18 -6
- package/app-template/src/views/header/navbar.tsx +1 -1
- package/app-template/src/views/header/pwa-back-button.tsx +1 -1
- package/app-template/src/views/header/search/index.tsx +13 -3
- package/app-template/src/views/header/search/results.tsx +1 -1
- package/app-template/src/views/header/user-menu.tsx +1 -3
- package/app-template/src/views/login/index.tsx +66 -57
- package/app-template/src/views/otp-login/index.tsx +11 -6
- package/app-template/src/views/product/index.ts +1 -0
- package/app-template/src/views/product/layout.tsx +26 -6
- package/app-template/src/views/product/price-wrapper.tsx +3 -24
- package/app-template/src/views/product/product-actions.tsx +165 -0
- package/app-template/src/views/product/product-info.tsx +76 -238
- package/app-template/src/views/product/product-share.tsx +58 -0
- package/app-template/src/views/product/product-variants.tsx +26 -0
- package/app-template/src/views/product/slider.tsx +22 -1
- package/app-template/src/views/product/variant.tsx +69 -41
- package/app-template/src/views/product-pointer-banner-item.tsx +1 -1
- package/app-template/src/views/register/index.tsx +31 -46
- package/app-template/src/views/sales-contract-modal/index.tsx +17 -17
- package/app-template/src/views/share/index.tsx +9 -6
- package/app-template/src/views/widgets/home-hero-slider-content.tsx +41 -39
- package/app-template/src/widgets/flatpages/about-us/index.tsx +78 -0
- package/app-template/src/widgets/flatpages/blog-list/index.tsx +129 -0
- package/app-template/src/widgets/footer-info.tsx +1 -1
- package/app-template/src/widgets/footer-menu.tsx +7 -3
- package/app-template/src/widgets/footer-subscription/footer-subscription-form.tsx +17 -14
- package/app-template/src/widgets/footer-subscription/index.tsx +1 -1
- package/app-template/src/widgets/home-stories-eng.tsx +43 -35
- package/app-template/src/widgets/index.ts +7 -0
- package/app-template/src/widgets/schemas/about-us.json +46 -0
- package/app-template/src/widgets/schemas/blog-list.json +37 -0
- package/app-template/src/widgets/schemas/blog.json +29 -0
- package/app-template/tailwind.config.js +155 -7
- package/app-template/tsconfig.json +29 -11
- package/codemods/migrate-auth-v5/index.js +339 -0
- package/codemods/migrate-auth-v5/transform.js +86 -0
- package/codemods/migrate-segments/index.js +591 -0
- package/codemods/update-tailwind-config/index.js +30 -0
- package/codemods/update-tailwind-config/transform.js +102 -0
- package/codemods/upgrade-to-2/index.js +549 -0
- package/commands/codemod.ts +0 -1
- package/commands/plugins.ts +111 -46
- package/dist/commands/codemod.js +0 -1
- package/dist/commands/plugins.js +104 -36
- package/package.json +3 -2
- package/app-template/src/app/[commerce]/[locale]/[currency]/category/[pk]/page.tsx +0 -22
- package/app-template/src/app/[commerce]/[locale]/[currency]/flat-page/[pk]/page.tsx +0 -20
- package/app-template/src/app/[commerce]/[locale]/[currency]/group-product/[pk]/page.tsx +0 -74
- package/app-template/src/app/[commerce]/[locale]/[currency]/list/page.tsx +0 -18
- package/app-template/src/app/[commerce]/[locale]/[currency]/page.tsx +0 -50
- package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/page.tsx +0 -84
- package/app-template/src/app/[commerce]/[locale]/[currency]/special-page/[pk]/page.tsx +0 -27
- package/app-template/src/pages/api/auth/[...nextauth].ts +0 -3
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/address/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/change-email/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/change-password/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/contact/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/coupons/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/email-verification/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/faq/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/favourite-products/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/my-quotations/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/layout.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/anonymous-tracking/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/auth/oauth-login/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/basket-b2b/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/category/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/client-root.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/contact-us/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/error.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/flat-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/group-product/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/landing-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/list/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/checkout/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/completed/[token]/layout.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/special-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/template.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/password/reset/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/xml-sitemap/route.ts +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button, Icon, LoaderSpinner, Select } from '@theme/components';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
type QuantityDisplayType = 'buttons' | 'dropdown';
|
|
8
|
+
|
|
9
|
+
type QuantityStyles = {
|
|
10
|
+
width?: string;
|
|
11
|
+
height?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
'background-color'?: string;
|
|
14
|
+
'border-color'?: string;
|
|
15
|
+
'border-width'?: string;
|
|
16
|
+
'border-radius'?: string;
|
|
17
|
+
'font-size'?: string;
|
|
18
|
+
'font-weight'?: string | number;
|
|
19
|
+
'button-color'?: string;
|
|
20
|
+
'button-hover-color'?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface QuantitySelectorProps {
|
|
24
|
+
quantity: number;
|
|
25
|
+
onChange?: (newQuantity: number) => void;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
isLoading?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
className?: string;
|
|
31
|
+
displayType?: QuantityDisplayType;
|
|
32
|
+
maxDropdownOptions?: number;
|
|
33
|
+
styles?: QuantityStyles;
|
|
34
|
+
isSelected?: boolean;
|
|
35
|
+
onDesignerClick?: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* QuantitySelector Component
|
|
40
|
+
*
|
|
41
|
+
* Supports two display modes:
|
|
42
|
+
* - 'buttons': Plus/minus buttons with number display (default)
|
|
43
|
+
* - 'dropdown': Select dropdown with quantity options
|
|
44
|
+
*
|
|
45
|
+
* Styles can be customized via Theme Editor through the styles prop.
|
|
46
|
+
*/
|
|
47
|
+
export const QuantitySelector = ({
|
|
48
|
+
quantity,
|
|
49
|
+
onChange,
|
|
50
|
+
min = 1,
|
|
51
|
+
max = 999,
|
|
52
|
+
isLoading = false,
|
|
53
|
+
disabled = false,
|
|
54
|
+
className = '',
|
|
55
|
+
displayType = 'buttons',
|
|
56
|
+
maxDropdownOptions = 10,
|
|
57
|
+
styles = {},
|
|
58
|
+
isSelected = false,
|
|
59
|
+
onDesignerClick
|
|
60
|
+
}: QuantitySelectorProps) => {
|
|
61
|
+
const handleDecrease = () => {
|
|
62
|
+
if (quantity > min && onChange) {
|
|
63
|
+
onChange(quantity - 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleIncrease = () => {
|
|
68
|
+
if (quantity < max && onChange) {
|
|
69
|
+
onChange(quantity + 1);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleDropdownChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
74
|
+
const newQuantity = parseInt(e.target.value, 10);
|
|
75
|
+
if (!isNaN(newQuantity) && onChange) {
|
|
76
|
+
onChange(newQuantity);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Generate dropdown options
|
|
81
|
+
const dropdownOptions = useMemo(() => {
|
|
82
|
+
const optionCount = Math.min(max - min + 1, maxDropdownOptions);
|
|
83
|
+
return Array.from({ length: optionCount }, (_, i) => ({
|
|
84
|
+
value: String(min + i),
|
|
85
|
+
label: String(min + i)
|
|
86
|
+
}));
|
|
87
|
+
}, [min, max, maxDropdownOptions]);
|
|
88
|
+
|
|
89
|
+
// Handle designer click for section selection
|
|
90
|
+
const handleContainerClick = (e: React.MouseEvent) => {
|
|
91
|
+
if (onDesignerClick) {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
onDesignerClick();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (displayType === 'dropdown') {
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className={clsx(
|
|
102
|
+
isSelected && 'ring-2 ring-blue-500 ring-offset-2',
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
onClick={handleContainerClick}
|
|
106
|
+
>
|
|
107
|
+
{isLoading ? (
|
|
108
|
+
<div
|
|
109
|
+
className="flex items-center justify-center border"
|
|
110
|
+
style={{
|
|
111
|
+
width: styles.width || '138px',
|
|
112
|
+
height: styles.height || '44px'
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<LoaderSpinner className="w-4 h-4" />
|
|
116
|
+
</div>
|
|
117
|
+
) : (
|
|
118
|
+
<Select
|
|
119
|
+
value={String(quantity)}
|
|
120
|
+
onChange={handleDropdownChange}
|
|
121
|
+
options={dropdownOptions}
|
|
122
|
+
disabled={disabled}
|
|
123
|
+
labelClassName="inline-block"
|
|
124
|
+
className="cursor-pointer w-full"
|
|
125
|
+
style={{
|
|
126
|
+
width: styles.width || '138px',
|
|
127
|
+
height: styles.height || '44px',
|
|
128
|
+
backgroundColor: styles['background-color'],
|
|
129
|
+
borderColor: styles['border-color'],
|
|
130
|
+
borderWidth: styles['border-width'],
|
|
131
|
+
borderRadius: styles['border-radius'],
|
|
132
|
+
fontSize: styles['font-size'],
|
|
133
|
+
fontWeight: styles['font-weight'],
|
|
134
|
+
color: styles.color
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Default: Buttons mode
|
|
143
|
+
return (
|
|
144
|
+
<div
|
|
145
|
+
className={clsx(
|
|
146
|
+
'quantity-selector flex items-center justify-between border p-4',
|
|
147
|
+
isSelected && 'ring-2 ring-blue-500 ring-offset-2',
|
|
148
|
+
className
|
|
149
|
+
)}
|
|
150
|
+
style={
|
|
151
|
+
{
|
|
152
|
+
width: styles.width || '138px',
|
|
153
|
+
height: styles.height || '44px',
|
|
154
|
+
backgroundColor: styles['background-color'],
|
|
155
|
+
borderColor: styles['border-color'],
|
|
156
|
+
borderWidth: styles['border-width'],
|
|
157
|
+
borderRadius: styles['border-radius'],
|
|
158
|
+
borderStyle: styles['border-width'] ? 'solid' : undefined,
|
|
159
|
+
'--quantity-button-color': styles['button-color'],
|
|
160
|
+
'--quantity-button-hover-color': styles['button-hover-color']
|
|
161
|
+
} as React.CSSProperties
|
|
162
|
+
}
|
|
163
|
+
onClick={handleContainerClick}
|
|
164
|
+
>
|
|
165
|
+
<Button
|
|
166
|
+
className={clsx(
|
|
167
|
+
'quantity-btn h-auto p-0 hover:bg-transparent',
|
|
168
|
+
styles['button-color'] ? '' : 'hover:text-black'
|
|
169
|
+
)}
|
|
170
|
+
style={{
|
|
171
|
+
color: styles['button-color'] || undefined
|
|
172
|
+
}}
|
|
173
|
+
appearance="ghost"
|
|
174
|
+
onClick={disabled ? undefined : handleDecrease}
|
|
175
|
+
disabled={disabled || isLoading || quantity <= min}
|
|
176
|
+
>
|
|
177
|
+
<Icon name="minus" size={12} />
|
|
178
|
+
</Button>
|
|
179
|
+
<div
|
|
180
|
+
style={{
|
|
181
|
+
color: styles.color,
|
|
182
|
+
fontSize: styles['font-size'],
|
|
183
|
+
fontWeight: styles['font-weight']
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
{isLoading ? (
|
|
187
|
+
<LoaderSpinner className="w-4 h-4" />
|
|
188
|
+
) : (
|
|
189
|
+
<span>{quantity}</span>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
<Button
|
|
193
|
+
className={clsx(
|
|
194
|
+
'quantity-btn h-auto p-0 hover:bg-transparent',
|
|
195
|
+
styles['button-color'] ? '' : 'hover:text-black'
|
|
196
|
+
)}
|
|
197
|
+
style={{
|
|
198
|
+
color: styles['button-color'] || undefined
|
|
199
|
+
}}
|
|
200
|
+
appearance="ghost"
|
|
201
|
+
onClick={disabled ? undefined : handleIncrease}
|
|
202
|
+
disabled={disabled || isLoading || quantity >= max}
|
|
203
|
+
>
|
|
204
|
+
<Icon name="plus" size={12} />
|
|
205
|
+
</Button>
|
|
206
|
+
|
|
207
|
+
{/* Inline style for hover states */}
|
|
208
|
+
<style jsx>{`
|
|
209
|
+
.quantity-selector .quantity-btn:hover:not(:disabled) {
|
|
210
|
+
color: var(--quantity-button-hover-color, inherit) !important;
|
|
211
|
+
}
|
|
212
|
+
`}</style>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
usePathname,
|
|
6
|
+
useSearchParams,
|
|
7
|
+
useSelectedLayoutSegment
|
|
8
|
+
} from 'next/navigation';
|
|
9
|
+
|
|
10
|
+
const RouteHandler = () => {
|
|
11
|
+
const pathname = usePathname();
|
|
12
|
+
const searchParams = useSearchParams();
|
|
13
|
+
const layoutSegment = useSelectedLayoutSegment();
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
window.parent.postMessage(
|
|
17
|
+
{
|
|
18
|
+
type: 'ROUTE_CHANGE_COMPLETE',
|
|
19
|
+
url: `${pathname}?${searchParams}`,
|
|
20
|
+
layoutSegment: layoutSegment === null ? 'home' : layoutSegment
|
|
21
|
+
},
|
|
22
|
+
'*'
|
|
23
|
+
);
|
|
24
|
+
}, [pathname, searchParams]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleClick = (e: MouseEvent) => {
|
|
28
|
+
const target = e.target as HTMLElement;
|
|
29
|
+
const anchor = target.closest('a[href]');
|
|
30
|
+
|
|
31
|
+
if (anchor) {
|
|
32
|
+
const isMenuToggle =
|
|
33
|
+
anchor.getAttribute('data-is-menu-toggle') === 'true';
|
|
34
|
+
if (!isMenuToggle) {
|
|
35
|
+
window.parent.postMessage(
|
|
36
|
+
{ type: 'ROUTE_CHANGE_START', url: anchor.getAttribute('href') },
|
|
37
|
+
'*'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
document.addEventListener('click', handleClick);
|
|
44
|
+
return () => document.removeEventListener('click', handleClick);
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default RouteHandler;
|
|
@@ -4,66 +4,98 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { Icon } from './icon';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
borderless = false,
|
|
12
|
-
icon,
|
|
13
|
-
iconSize,
|
|
14
|
-
error,
|
|
15
|
-
label,
|
|
16
|
-
required = false,
|
|
17
|
-
...rest
|
|
18
|
-
} = props;
|
|
7
|
+
interface ExtendedSelectProps extends SelectProps {
|
|
8
|
+
/** Custom SVG icon content */
|
|
9
|
+
customIcon?: string;
|
|
10
|
+
}
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
const Select = forwardRef<HTMLSelectElement, ExtendedSelectProps>(
|
|
13
|
+
(props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
className,
|
|
16
|
+
options,
|
|
17
|
+
borderless = false,
|
|
18
|
+
icon,
|
|
19
|
+
iconSize,
|
|
20
|
+
customIcon,
|
|
21
|
+
error,
|
|
22
|
+
label,
|
|
23
|
+
required = false,
|
|
24
|
+
labelClassName,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
// Check if customIcon is SVG content
|
|
29
|
+
const hasCustomSvgIcon =
|
|
30
|
+
customIcon &&
|
|
31
|
+
typeof customIcon === 'string' &&
|
|
32
|
+
customIcon.includes('<svg');
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<label
|
|
42
36
|
className={twMerge(
|
|
43
|
-
clsx(
|
|
44
|
-
'
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
),
|
|
48
|
-
className
|
|
37
|
+
clsx('flex flex-col relative text-xs text-gray-800', {
|
|
38
|
+
'pl-7': icon || hasCustomSvgIcon
|
|
39
|
+
}),
|
|
40
|
+
labelClassName
|
|
49
41
|
)}
|
|
50
42
|
>
|
|
51
|
-
{
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
{hasCustomSvgIcon ? (
|
|
44
|
+
<div
|
|
45
|
+
className="absolute left-0 top-1/2 transform -translate-y-1/2 flex items-center justify-center"
|
|
46
|
+
style={{ width: iconSize ?? 20, height: iconSize ?? 20 }}
|
|
47
|
+
dangerouslySetInnerHTML={{ __html: customIcon }}
|
|
48
|
+
/>
|
|
49
|
+
) : icon ? (
|
|
50
|
+
<Icon
|
|
51
|
+
name={icon}
|
|
52
|
+
size={iconSize ?? 20}
|
|
53
|
+
className="absolute left-0 top-1/2 transform -translate-y-1/2"
|
|
54
|
+
/>
|
|
55
|
+
) : null}
|
|
56
|
+
|
|
57
|
+
{label && (
|
|
58
|
+
<span className={twMerge('mb-1', labelClassName)}>
|
|
59
|
+
{label} {required && <span className="text-secondary">*</span>}
|
|
60
|
+
</span>
|
|
61
|
+
)}
|
|
62
|
+
<div className="relative">
|
|
63
|
+
<select
|
|
64
|
+
{...rest}
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={twMerge(
|
|
67
|
+
clsx(
|
|
68
|
+
'cursor-pointer truncate h-10 w-40 px-2.5 shrink-0 outline-none',
|
|
69
|
+
!borderless &&
|
|
70
|
+
'border border-gray-200 transition-all duration-150 hover:border-primary focus:border-primary',
|
|
71
|
+
'appearance-none bg-transparent'
|
|
72
|
+
),
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
56
75
|
>
|
|
57
|
-
{option
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
{options?.map((option) => (
|
|
77
|
+
<option
|
|
78
|
+
key={option.value}
|
|
79
|
+
value={option.value}
|
|
80
|
+
className={option.class}
|
|
81
|
+
>
|
|
82
|
+
{option.label}
|
|
83
|
+
</option>
|
|
84
|
+
))}
|
|
85
|
+
</select>
|
|
86
|
+
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
|
|
87
|
+
<svg className="h-4 w-4 fill-current" viewBox="0 0 20 20">
|
|
88
|
+
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
|
|
89
|
+
</svg>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
{error && (
|
|
93
|
+
<span className="mt-1 text-sm text-error">{error.message}</span>
|
|
94
|
+
)}
|
|
95
|
+
</label>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
67
99
|
|
|
68
100
|
Select.displayName = 'Select';
|
|
69
101
|
|
|
@@ -12,7 +12,7 @@ export const Shimmer: React.FC<ShimmerProps> = ({ className }) => {
|
|
|
12
12
|
>
|
|
13
13
|
<div
|
|
14
14
|
className={twMerge(
|
|
15
|
-
'w-full h-full bg-black
|
|
15
|
+
'w-full h-full bg-black bg-opacity-20 shadow-[0 0 30px 30px rgba(255,255,255,0.2)]',
|
|
16
16
|
className
|
|
17
17
|
)}
|
|
18
18
|
></div>
|
|
@@ -27,9 +27,38 @@ export interface PaginationProps {
|
|
|
27
27
|
onPageChange?: (page: number) => void;
|
|
28
28
|
direction?: 'next' | 'prev';
|
|
29
29
|
isLoading?: boolean;
|
|
30
|
+
customStyles?: {
|
|
31
|
+
marginTop?: string;
|
|
32
|
+
marginBottom?: string;
|
|
33
|
+
pageFontSize?: string;
|
|
34
|
+
pageColor?: string;
|
|
35
|
+
pageActiveColor?: string;
|
|
36
|
+
pageActiveFontWeight?: string;
|
|
37
|
+
pageGap?: string;
|
|
38
|
+
pageBgColor?: string;
|
|
39
|
+
pageActiveBgColor?: string;
|
|
40
|
+
pagePaddingX?: string;
|
|
41
|
+
pagePaddingY?: string;
|
|
42
|
+
pageBorderRadius?: string;
|
|
43
|
+
pageBorderWidth?: string;
|
|
44
|
+
pageBorderColor?: string;
|
|
45
|
+
pageActiveBorderColor?: string;
|
|
46
|
+
arrowColor?: string;
|
|
47
|
+
buttonBgColor?: string;
|
|
48
|
+
buttonTextColor?: string;
|
|
49
|
+
buttonBorderRadius?: string;
|
|
50
|
+
buttonPaddingX?: string;
|
|
51
|
+
buttonPaddingY?: string;
|
|
52
|
+
};
|
|
30
53
|
}
|
|
31
54
|
|
|
32
|
-
export
|
|
55
|
+
export interface FileInputProps extends React.HTMLProps<HTMLInputElement> {
|
|
56
|
+
fileClassName?: string;
|
|
57
|
+
fileNameWrapperClassName?: string;
|
|
58
|
+
fileInputClassName?: string;
|
|
59
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
60
|
+
buttonClassName?: string;
|
|
61
|
+
}
|
|
33
62
|
|
|
34
63
|
export type RadioProps = React.HTMLProps<HTMLInputElement>;
|
|
35
64
|
|
|
@@ -58,6 +87,7 @@ export interface SelectProps extends React.HTMLProps<HTMLSelectElement> {
|
|
|
58
87
|
iconSize?: number;
|
|
59
88
|
error?: FieldError | undefined;
|
|
60
89
|
required?: boolean;
|
|
90
|
+
labelClassName?: string;
|
|
61
91
|
}
|
|
62
92
|
export interface IconProps extends React.ComponentPropsWithRef<'i'> {
|
|
63
93
|
name: string;
|
|
@@ -91,3 +121,23 @@ export interface BadgeProps {
|
|
|
91
121
|
children: ReactNode;
|
|
92
122
|
className?: string;
|
|
93
123
|
}
|
|
124
|
+
|
|
125
|
+
export type AccordionProps = {
|
|
126
|
+
isCollapse?: boolean;
|
|
127
|
+
collapseClassName?: string;
|
|
128
|
+
title?: string;
|
|
129
|
+
subTitle?: string;
|
|
130
|
+
icons?: string[];
|
|
131
|
+
iconSize?: number;
|
|
132
|
+
iconColor?: string;
|
|
133
|
+
children?: ReactNode;
|
|
134
|
+
headerClassName?: string;
|
|
135
|
+
className?: string;
|
|
136
|
+
titleClassName?: string;
|
|
137
|
+
subTitleClassName?: string;
|
|
138
|
+
dataTestId?: string;
|
|
139
|
+
contentClassName?: string;
|
|
140
|
+
leftIcon?: string;
|
|
141
|
+
leftIconSize?: number;
|
|
142
|
+
leftIconClassName?: string;
|
|
143
|
+
};
|