@gfed-medusa/sf-lib-common 3.3.5 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/breadcrumbs/index.d.ts +2 -2
- package/dist/components/breadcrumbs/index.js +2 -6
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/cart-mismatch-banner/index.d.ts +2 -2
- package/dist/components/cart-mismatch-banner/index.d.ts.map +1 -1
- package/dist/components/cart-mismatch-banner/index.js +3 -8
- package/dist/components/cart-mismatch-banner/index.js.map +1 -1
- package/dist/components/country-select/index.js +1 -3
- package/dist/components/country-select/index.js.map +1 -1
- package/dist/components/delete-button/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts.map +1 -1
- package/dist/components/error-message/index.js +1 -3
- package/dist/components/error-message/index.js.map +1 -1
- package/dist/components/free-shipping-price-nudge/index.d.ts +2 -2
- package/dist/components/free-shipping-price-nudge/index.js +47 -64
- package/dist/components/free-shipping-price-nudge/index.js.map +1 -1
- package/dist/components/interactive-link/index.d.ts +2 -2
- package/dist/components/line-item-options/index.d.ts +2 -2
- package/dist/components/line-item-price/index.d.ts +2 -2
- package/dist/components/line-item-price/index.d.ts.map +1 -1
- package/dist/components/localized-client-link/index.d.ts +2 -2
- package/dist/components/localized-client-link/index.js +6 -10
- package/dist/components/localized-client-link/index.js.map +1 -1
- package/dist/components/modal/index.d.ts +2 -2
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/modal/index.js +6 -8
- package/dist/components/modal/index.js.map +1 -1
- package/dist/components/preview-price/index.d.ts +2 -2
- package/dist/components/preview-price/index.d.ts.map +1 -1
- package/dist/components/preview-price/index.js +1 -3
- package/dist/components/preview-price/index.js.map +1 -1
- package/dist/components/product-card/index.d.ts +2 -2
- package/dist/components/product-card/index.d.ts.map +1 -1
- package/dist/components/product-card/index.js +2 -2
- package/dist/components/product-card/index.js.map +1 -1
- package/dist/components/product-preview/index.d.ts +5 -4
- package/dist/components/product-preview/index.d.ts.map +1 -1
- package/dist/components/product-preview/index.js.map +1 -1
- package/dist/components/submit-button/index.d.ts +2 -2
- package/dist/lib/config/medusa.js +2 -3
- package/dist/lib/config/medusa.js.map +1 -1
- package/dist/lib/context/apollo-context.d.ts +2 -2
- package/dist/lib/context/apollo-context.d.ts.map +1 -1
- package/dist/lib/context/apollo-context.js +1 -2
- package/dist/lib/context/apollo-context.js.map +1 -1
- package/dist/lib/context/modal-context.d.ts +2 -2
- package/dist/lib/context/modal-context.js +1 -3
- package/dist/lib/context/modal-context.js.map +1 -1
- package/dist/lib/data/cart.js +17 -35
- package/dist/lib/data/cart.js.map +1 -1
- package/dist/lib/data/categories.d.ts +4 -15
- package/dist/lib/data/categories.d.ts.map +1 -1
- package/dist/lib/data/categories.js +5 -3
- package/dist/lib/data/categories.js.map +1 -1
- package/dist/lib/data/client-actions.js +2 -7
- package/dist/lib/data/client-actions.js.map +1 -1
- package/dist/lib/data/collections.js +4 -7
- package/dist/lib/data/collections.js.map +1 -1
- package/dist/lib/data/context.d.ts +2 -2
- package/dist/lib/data/context.d.ts.map +1 -1
- package/dist/lib/data/context.js +1 -3
- package/dist/lib/data/context.js.map +1 -1
- package/dist/lib/data/cookies-actions.d.ts.map +1 -1
- package/dist/lib/data/cookies-actions.js +14 -20
- package/dist/lib/data/cookies-actions.js.map +1 -1
- package/dist/lib/data/cookies-utils.js +3 -9
- package/dist/lib/data/cookies-utils.js.map +1 -1
- package/dist/lib/data/customer.js +10 -19
- package/dist/lib/data/customer.js.map +1 -1
- package/dist/lib/data/footer.js +1 -2
- package/dist/lib/data/footer.js.map +1 -1
- package/dist/lib/data/home-banner.d.ts +7 -0
- package/dist/lib/data/home-banner.d.ts.map +1 -0
- package/dist/lib/data/home-banner.js +16 -0
- package/dist/lib/data/home-banner.js.map +1 -0
- package/dist/lib/data/orders.js +2 -3
- package/dist/lib/data/orders.js.map +1 -1
- package/dist/lib/data/regions.js +6 -9
- package/dist/lib/data/regions.js.map +1 -1
- package/dist/lib/globals/expose-globals.js +1 -1
- package/dist/lib/gql/apollo-client.js +7 -12
- package/dist/lib/gql/apollo-client.js.map +1 -1
- package/dist/lib/gql/fragments/cart.d.ts +9 -9
- package/dist/lib/gql/fragments/cart.d.ts.map +1 -1
- package/dist/lib/gql/fragments/customer.d.ts +3 -3
- package/dist/lib/gql/fragments/customer.d.ts.map +1 -1
- package/dist/lib/gql/fragments/product.d.ts +8 -8
- package/dist/lib/gql/fragments/product.d.ts.map +1 -1
- package/dist/lib/gql/mutations/cart.d.ts +6 -6
- package/dist/lib/gql/queries/cart.d.ts +2 -2
- package/dist/lib/gql/queries/cart.d.ts.map +1 -1
- package/dist/lib/gql/queries/collections.d.ts +3 -3
- package/dist/lib/gql/queries/collections.d.ts.map +1 -1
- package/dist/lib/gql/queries/customer.d.ts +2 -2
- package/dist/lib/gql/queries/customer.d.ts.map +1 -1
- package/dist/lib/gql/queries/footer.d.ts +3 -3
- package/dist/lib/gql/queries/home-banner.d.ts +7 -0
- package/dist/lib/gql/queries/home-banner.d.ts.map +1 -0
- package/dist/lib/gql/queries/home-banner.js +46 -0
- package/dist/lib/gql/queries/home-banner.js.map +1 -0
- package/dist/lib/gql/queries/order.d.ts +4 -4
- package/dist/lib/gql/queries/product.d.ts +2 -2
- package/dist/lib/gql/queries/product.d.ts.map +1 -1
- package/dist/lib/gql/queries/product.js +3 -12
- package/dist/lib/gql/queries/product.js.map +1 -1
- package/dist/lib/gql/queries/regions.d.ts +3 -3
- package/dist/lib/gql/queries/shipping.d.ts +3 -3
- package/dist/lib/hooks/use-apollo.d.ts +2 -2
- package/dist/lib/hooks/use-apollo.js +1 -2
- package/dist/lib/hooks/use-apollo.js.map +1 -1
- package/dist/lib/hooks/use-cart.js +1 -3
- package/dist/lib/hooks/use-cart.js.map +1 -1
- package/dist/lib/hooks/use-customer.js +1 -3
- package/dist/lib/hooks/use-customer.js.map +1 -1
- package/dist/lib/utils/data-types.js +1 -1
- package/dist/lib/utils/data-types.js.map +1 -1
- package/dist/lib/utils/get-percentage-diff.js +1 -3
- package/dist/lib/utils/get-percentage-diff.js.map +1 -1
- package/dist/lib/utils/get-product-price.d.ts +3 -2
- package/dist/lib/utils/get-product-price.d.ts.map +1 -1
- package/dist/lib/utils/get-product-price.js +5 -15
- package/dist/lib/utils/get-product-price.js.map +1 -1
- package/dist/lib/utils/imagekit.d.ts.map +1 -1
- package/dist/lib/utils/imagekit.js +4 -6
- package/dist/lib/utils/imagekit.js.map +1 -1
- package/dist/lib/utils/medusa-error.js +2 -5
- package/dist/lib/utils/medusa-error.js.map +1 -1
- package/dist/types/cms.d.ts +27 -1
- package/dist/types/cms.d.ts.map +1 -1
- package/dist/types/graphql.d.ts +121 -12
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/graphql.js +258 -87
- package/dist/types/graphql.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/breadcrumbs/index.d.ts
|
|
4
4
|
declare const SEPARATOR_ICONS: Record<string, React.ComponentType<{
|
|
@@ -14,7 +14,7 @@ declare function Breadcrumbs({
|
|
|
14
14
|
iconClassName,
|
|
15
15
|
iconSize,
|
|
16
16
|
separatorIcon
|
|
17
|
-
}: BreadcrumbsProps):
|
|
17
|
+
}: BreadcrumbsProps): react_jsx_runtime0.JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { Breadcrumbs };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -22,15 +22,11 @@ const createBreadcrumbItems = (segments) => [{
|
|
|
22
22
|
const isLocaleCode = (segment) => /^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/.test(segment);
|
|
23
23
|
const getPathSegments = (pathname) => {
|
|
24
24
|
const segments = pathname.split("/").filter(Boolean);
|
|
25
|
-
if (segments.length > 0 && isLocaleCode(segments[0] ?? ""))
|
|
26
|
-
segments.shift();
|
|
27
|
-
}
|
|
25
|
+
if (segments.length > 0 && isLocaleCode(segments[0] ?? "")) segments.shift();
|
|
28
26
|
return segments;
|
|
29
27
|
};
|
|
30
28
|
function Breadcrumbs({ iconClassName, iconSize, separatorIcon }) {
|
|
31
|
-
const
|
|
32
|
-
const pathSegments = getPathSegments(pathname);
|
|
33
|
-
const breadcrumbItems = createBreadcrumbItems(pathSegments);
|
|
29
|
+
const breadcrumbItems = createBreadcrumbItems(getPathSegments(usePathname()));
|
|
34
30
|
const SeparatorIcon = separatorIcon ? SEPARATOR_ICONS[separatorIcon] : null;
|
|
35
31
|
return /* @__PURE__ */ jsx(Breadcrumb, {
|
|
36
32
|
className: "mt-3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["SEPARATOR_ICONS: Record<\n string,\n React.ComponentType<{ size?: number; className?: string }>\n>","segments: string[]"],"sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":["'use client';\n\nimport { Fragment } from 'react';\n\nimport { usePathname } from 'next/navigation';\n\nimport { SlashIcon, Tally1 } from 'lucide-react';\n\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from '@gfed-medusa/sf-lib-ui/components/breadcrumb';\n\nconst SEPARATOR_ICONS: Record<\n string,\n React.ComponentType<{ size?: number; className?: string }>\n> = {\n verticalLine: Tally1,\n slash: SlashIcon,\n};\n\ninterface BreadcrumbsProps {\n separatorIcon?: keyof typeof SEPARATOR_ICONS;\n iconSize?: number;\n iconClassName?: string;\n}\n\nconst formatSegmentLabel = (segment: string): string =>\n segment.charAt(0).toUpperCase() + segment.slice(1).replace(/-/g, ' ');\n\nconst createBreadcrumbItems = (segments: string[]) => [\n { label: 'Home', href: '/' },\n ...segments.map((segment, index) => ({\n href: '/' + segments.slice(0, index + 1).join('/'),\n label: formatSegmentLabel(segment),\n })),\n];\n\n// Helper function to check if a string is a locale code (e.g., 'en', 'en-US')\nconst isLocaleCode = (segment: string): boolean =>\n /^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/.test(segment);\n\nconst getPathSegments = (pathname: string): string[] => {\n const segments: string[] = pathname.split('/').filter(Boolean);\n\n if (segments.length > 0 && isLocaleCode(segments[0] ?? '')) {\n segments.shift();\n }\n\n return segments;\n};\n\nfunction Breadcrumbs({\n iconClassName,\n iconSize,\n separatorIcon,\n}: BreadcrumbsProps) {\n const pathname = usePathname();\n const pathSegments = getPathSegments(pathname);\n const breadcrumbItems = createBreadcrumbItems(pathSegments);\n const SeparatorIcon = separatorIcon ? SEPARATOR_ICONS[separatorIcon] : null;\n\n return (\n <Breadcrumb className=\"mt-3\">\n <BreadcrumbList className=\"lg:gap-6\">\n {breadcrumbItems.map((item, index) => {\n const isLast = index === breadcrumbItems.length - 1;\n\n return (\n <Fragment key={item.href}>\n <BreadcrumbItem className=\"text-sm\">\n {isLast ? (\n <BreadcrumbPage>{item.label}</BreadcrumbPage>\n ) : (\n <BreadcrumbLink href={item.href}>{item.label}</BreadcrumbLink>\n )}\n </BreadcrumbItem>\n {!isLast && (\n <BreadcrumbSeparator>\n {SeparatorIcon && (\n <SeparatorIcon size={iconSize} className={iconClassName} />\n )}\n </BreadcrumbSeparator>\n )}\n </Fragment>\n );\n })}\n </BreadcrumbList>\n </Breadcrumb>\n );\n}\n\nexport { Breadcrumbs };\n"],"mappings":";;;;;;;;;AAiBA,MAAMA,kBAGF;CACF,cAAc;CACd,OAAO;CACR;AAQD,MAAM,sBAAsB,YAC1B,QAAQ,OAAO,EAAE,CAAC,aAAa,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,MAAM,IAAI;AAEvE,MAAM,yBAAyB,aAAuB,CACpD;CAAE,OAAO;CAAQ,MAAM;CAAK,EAC5B,GAAG,SAAS,KAAK,SAAS,WAAW;CACnC,MAAM,MAAM,SAAS,MAAM,GAAG,QAAQ,EAAE,CAAC,KAAK,IAAI;CAClD,OAAO,mBAAmB,QAAQ;CACnC,EAAE,CACJ;AAGD,MAAM,gBAAgB,YACpB,+BAA+B,KAAK,QAAQ;AAE9C,MAAM,mBAAmB,aAA+B;CACtD,MAAMC,WAAqB,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ;AAE9D,KAAI,SAAS,SAAS,KAAK,aAAa,SAAS,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","names":["SEPARATOR_ICONS: Record<\n string,\n React.ComponentType<{ size?: number; className?: string }>\n>","segments: string[]"],"sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":["'use client';\n\nimport { Fragment } from 'react';\n\nimport { usePathname } from 'next/navigation';\n\nimport { SlashIcon, Tally1 } from 'lucide-react';\n\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from '@gfed-medusa/sf-lib-ui/components/breadcrumb';\n\nconst SEPARATOR_ICONS: Record<\n string,\n React.ComponentType<{ size?: number; className?: string }>\n> = {\n verticalLine: Tally1,\n slash: SlashIcon,\n};\n\ninterface BreadcrumbsProps {\n separatorIcon?: keyof typeof SEPARATOR_ICONS;\n iconSize?: number;\n iconClassName?: string;\n}\n\nconst formatSegmentLabel = (segment: string): string =>\n segment.charAt(0).toUpperCase() + segment.slice(1).replace(/-/g, ' ');\n\nconst createBreadcrumbItems = (segments: string[]) => [\n { label: 'Home', href: '/' },\n ...segments.map((segment, index) => ({\n href: '/' + segments.slice(0, index + 1).join('/'),\n label: formatSegmentLabel(segment),\n })),\n];\n\n// Helper function to check if a string is a locale code (e.g., 'en', 'en-US')\nconst isLocaleCode = (segment: string): boolean =>\n /^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/.test(segment);\n\nconst getPathSegments = (pathname: string): string[] => {\n const segments: string[] = pathname.split('/').filter(Boolean);\n\n if (segments.length > 0 && isLocaleCode(segments[0] ?? '')) {\n segments.shift();\n }\n\n return segments;\n};\n\nfunction Breadcrumbs({\n iconClassName,\n iconSize,\n separatorIcon,\n}: BreadcrumbsProps) {\n const pathname = usePathname();\n const pathSegments = getPathSegments(pathname);\n const breadcrumbItems = createBreadcrumbItems(pathSegments);\n const SeparatorIcon = separatorIcon ? SEPARATOR_ICONS[separatorIcon] : null;\n\n return (\n <Breadcrumb className=\"mt-3\">\n <BreadcrumbList className=\"lg:gap-6\">\n {breadcrumbItems.map((item, index) => {\n const isLast = index === breadcrumbItems.length - 1;\n\n return (\n <Fragment key={item.href}>\n <BreadcrumbItem className=\"text-sm\">\n {isLast ? (\n <BreadcrumbPage>{item.label}</BreadcrumbPage>\n ) : (\n <BreadcrumbLink href={item.href}>{item.label}</BreadcrumbLink>\n )}\n </BreadcrumbItem>\n {!isLast && (\n <BreadcrumbSeparator>\n {SeparatorIcon && (\n <SeparatorIcon size={iconSize} className={iconClassName} />\n )}\n </BreadcrumbSeparator>\n )}\n </Fragment>\n );\n })}\n </BreadcrumbList>\n </Breadcrumb>\n );\n}\n\nexport { Breadcrumbs };\n"],"mappings":";;;;;;;;;AAiBA,MAAMA,kBAGF;CACF,cAAc;CACd,OAAO;CACR;AAQD,MAAM,sBAAsB,YAC1B,QAAQ,OAAO,EAAE,CAAC,aAAa,GAAG,QAAQ,MAAM,EAAE,CAAC,QAAQ,MAAM,IAAI;AAEvE,MAAM,yBAAyB,aAAuB,CACpD;CAAE,OAAO;CAAQ,MAAM;CAAK,EAC5B,GAAG,SAAS,KAAK,SAAS,WAAW;CACnC,MAAM,MAAM,SAAS,MAAM,GAAG,QAAQ,EAAE,CAAC,KAAK,IAAI;CAClD,OAAO,mBAAmB,QAAQ;CACnC,EAAE,CACJ;AAGD,MAAM,gBAAgB,YACpB,+BAA+B,KAAK,QAAQ;AAE9C,MAAM,mBAAmB,aAA+B;CACtD,MAAMC,WAAqB,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ;AAE9D,KAAI,SAAS,SAAS,KAAK,aAAa,SAAS,MAAM,GAAG,CACxD,UAAS,OAAO;AAGlB,QAAO;;AAGT,SAAS,YAAY,EACnB,eACA,UACA,iBACmB;CAGnB,MAAM,kBAAkB,sBADH,gBADJ,aAAa,CACgB,CACa;CAC3D,MAAM,gBAAgB,gBAAgB,gBAAgB,iBAAiB;AAEvE,QACE,oBAAC;EAAW,WAAU;YACpB,oBAAC;GAAe,WAAU;aACvB,gBAAgB,KAAK,MAAM,UAAU;IACpC,MAAM,SAAS,UAAU,gBAAgB,SAAS;AAElD,WACE,qBAAC,uBACC,oBAAC;KAAe,WAAU;eACvB,SACC,oBAAC,4BAAgB,KAAK,QAAuB,GAE7C,oBAAC;MAAe,MAAM,KAAK;gBAAO,KAAK;OAAuB;MAEjD,EAChB,CAAC,UACA,oBAAC,iCACE,iBACC,oBAAC;KAAc,MAAM;KAAU,WAAW;MAAiB,GAEzC,KAbX,KAAK,KAeT;KAEb;IACa;GACN"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Cart, Customer } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/cart-mismatch-banner/index.d.ts
|
|
5
5
|
declare function CartMismatchBanner(props: {
|
|
6
6
|
customer: Customer;
|
|
7
7
|
cart: Cart;
|
|
8
|
-
}):
|
|
8
|
+
}): react_jsx_runtime0.JSX.Element | undefined;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CartMismatchBanner };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAYS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAYS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAtB,SAAA"}
|
|
@@ -14,20 +14,15 @@ function CartMismatchBanner(props) {
|
|
|
14
14
|
const [actionText, setActionText] = useState("Run transfer again");
|
|
15
15
|
const [transferComplete, setTransferComplete] = useState(false);
|
|
16
16
|
const ctx = useStorefrontContext();
|
|
17
|
-
if (!customer || !!cart.customerId || transferComplete)
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
17
|
+
if (!customer || !!cart.customerId || transferComplete) return;
|
|
20
18
|
const handleSubmit = async () => {
|
|
21
19
|
try {
|
|
22
20
|
setIsPending(true);
|
|
23
21
|
setActionText("Transferring..");
|
|
24
22
|
const result = await transferCart(ctx);
|
|
25
23
|
setIsPending(false);
|
|
26
|
-
if (result?.customerId)
|
|
27
|
-
|
|
28
|
-
} else {
|
|
29
|
-
setActionText("Run transfer again");
|
|
30
|
-
}
|
|
24
|
+
if (result?.customerId) setTransferComplete(true);
|
|
25
|
+
else setActionText("Run transfer again");
|
|
31
26
|
} catch {
|
|
32
27
|
setActionText("Run transfer again");
|
|
33
28
|
setIsPending(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { ExclamationCircleSolid } from '@medusajs/icons';\nimport { Button } from '@medusajs/ui';\n\nimport { useStorefrontContext } from '@/lib/data/context';\nimport { transferCart } from '@/lib/data/customer';\nimport { Customer } from '@/types/graphql';\nimport { Cart } from '@/types/graphql';\n\nfunction CartMismatchBanner(props: { customer: Customer; cart: Cart }) {\n const { customer, cart } = props;\n const [isPending, setIsPending] = useState(false);\n const [actionText, setActionText] = useState('Run transfer again');\n const [transferComplete, setTransferComplete] = useState(false);\n const ctx = useStorefrontContext();\n\n if (!customer || !!cart.customerId || transferComplete) {\n return;\n }\n\n const handleSubmit = async () => {\n try {\n setIsPending(true);\n setActionText('Transferring..');\n\n const result = await transferCart(ctx);\n\n setIsPending(false);\n if (result?.customerId) {\n setTransferComplete(true);\n } else {\n setActionText('Run transfer again');\n }\n } catch {\n setActionText('Run transfer again');\n setIsPending(false);\n }\n };\n\n return (\n <div className=\"small:gap-2 small:p-4 mt-2 flex items-center justify-center gap-1 bg-orange-300 p-2 text-center text-sm text-orange-800\">\n <div className=\"small:flex-row small:gap-2 flex flex-col items-center gap-1\">\n <span className=\"flex items-center gap-1\">\n <ExclamationCircleSolid className=\"inline\" />\n Something went wrong when we tried to transfer your cart\n </span>\n\n <span>·</span>\n\n <Button\n variant=\"transparent\"\n className=\"bg-transparent p-0 text-orange-950 hover:bg-transparent focus:bg-transparent active:bg-transparent disabled:text-orange-500\"\n size=\"base\"\n disabled={isPending}\n onClick={handleSubmit}\n >\n {actionText}\n </Button>\n </div>\n </div>\n );\n}\n\nexport { CartMismatchBanner };\n"],"mappings":";;;;;;;;;;AAYA,SAAS,mBAAmB,OAA2C;CACrE,MAAM,EAAE,UAAU,SAAS;CAC3B,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,YAAY,iBAAiB,SAAS,qBAAqB;CAClE,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,MAAM;CAC/D,MAAM,MAAM,sBAAsB;AAElC,KAAI,CAAC,YAAY,CAAC,CAAC,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { ExclamationCircleSolid } from '@medusajs/icons';\nimport { Button } from '@medusajs/ui';\n\nimport { useStorefrontContext } from '@/lib/data/context';\nimport { transferCart } from '@/lib/data/customer';\nimport { Customer } from '@/types/graphql';\nimport { Cart } from '@/types/graphql';\n\nfunction CartMismatchBanner(props: { customer: Customer; cart: Cart }) {\n const { customer, cart } = props;\n const [isPending, setIsPending] = useState(false);\n const [actionText, setActionText] = useState('Run transfer again');\n const [transferComplete, setTransferComplete] = useState(false);\n const ctx = useStorefrontContext();\n\n if (!customer || !!cart.customerId || transferComplete) {\n return;\n }\n\n const handleSubmit = async () => {\n try {\n setIsPending(true);\n setActionText('Transferring..');\n\n const result = await transferCart(ctx);\n\n setIsPending(false);\n if (result?.customerId) {\n setTransferComplete(true);\n } else {\n setActionText('Run transfer again');\n }\n } catch {\n setActionText('Run transfer again');\n setIsPending(false);\n }\n };\n\n return (\n <div className=\"small:gap-2 small:p-4 mt-2 flex items-center justify-center gap-1 bg-orange-300 p-2 text-center text-sm text-orange-800\">\n <div className=\"small:flex-row small:gap-2 flex flex-col items-center gap-1\">\n <span className=\"flex items-center gap-1\">\n <ExclamationCircleSolid className=\"inline\" />\n Something went wrong when we tried to transfer your cart\n </span>\n\n <span>·</span>\n\n <Button\n variant=\"transparent\"\n className=\"bg-transparent p-0 text-orange-950 hover:bg-transparent focus:bg-transparent active:bg-transparent disabled:text-orange-500\"\n size=\"base\"\n disabled={isPending}\n onClick={handleSubmit}\n >\n {actionText}\n </Button>\n </div>\n </div>\n );\n}\n\nexport { CartMismatchBanner };\n"],"mappings":";;;;;;;;;;AAYA,SAAS,mBAAmB,OAA2C;CACrE,MAAM,EAAE,UAAU,SAAS;CAC3B,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,YAAY,iBAAiB,SAAS,qBAAqB;CAClE,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,MAAM;CAC/D,MAAM,MAAM,sBAAsB;AAElC,KAAI,CAAC,YAAY,CAAC,CAAC,KAAK,cAAc,iBACpC;CAGF,MAAM,eAAe,YAAY;AAC/B,MAAI;AACF,gBAAa,KAAK;AAClB,iBAAc,iBAAiB;GAE/B,MAAM,SAAS,MAAM,aAAa,IAAI;AAEtC,gBAAa,MAAM;AACnB,OAAI,QAAQ,WACV,qBAAoB,KAAK;OAEzB,eAAc,qBAAqB;UAE/B;AACN,iBAAc,qBAAqB;AACnC,gBAAa,MAAM;;;AAIvB,QACE,oBAAC;EAAI,WAAU;YACb,qBAAC;GAAI,WAAU;;IACb,qBAAC;KAAK,WAAU;gBACd,oBAAC,0BAAuB,WAAU,WAAW;MAExC;IAEP,oBAAC,oBAAK,MAAQ;IAEd,oBAAC;KACC,SAAQ;KACR,WAAU;KACV,MAAK;KACL,UAAU;KACV,SAAS;eAER;MACM;;IACL;GACF"}
|
|
@@ -7,9 +7,7 @@ const CountrySelect = React.forwardRef(({ placeholder = "Country", region, defau
|
|
|
7
7
|
const innerRef = useRef(null);
|
|
8
8
|
useImperativeHandle(ref, () => innerRef.current);
|
|
9
9
|
const countryOptions = useMemo(() => {
|
|
10
|
-
if (!region)
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
10
|
+
if (!region) return [];
|
|
13
11
|
return region.countries?.map((country) => ({
|
|
14
12
|
value: country?.iso2,
|
|
15
13
|
label: country?.displayName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/country-select/index.tsx"],"sourcesContent":["import React, { useImperativeHandle, useMemo, useRef } from 'react';\n\nimport NativeSelect, {\n NativeSelectProps,\n} from '@gfed-medusa/sf-lib-ui/components/native-select';\n\nimport { Region } from '@/types/graphql';\n\nconst CountrySelect = React.forwardRef<\n HTMLSelectElement,\n NativeSelectProps & {\n region?: Region | null;\n }\n>(({ placeholder = 'Country', region, defaultValue, ...props }, ref) => {\n const innerRef = useRef<HTMLSelectElement>(null);\n\n useImperativeHandle<HTMLSelectElement | null, HTMLSelectElement | null>(\n ref,\n () => innerRef.current\n );\n\n const countryOptions = useMemo(() => {\n if (!region) {\n return [];\n }\n\n return region.countries?.map((country) => ({\n value: country?.iso2,\n label: country?.displayName,\n }));\n }, [region]);\n\n return (\n <NativeSelect\n ref={innerRef}\n placeholder={placeholder}\n defaultValue={defaultValue}\n {...props}\n >\n {countryOptions?.map(({ value, label }, index) => (\n <option key={index} value={value ?? ''}>\n {label}\n </option>\n ))}\n </NativeSelect>\n );\n});\n\nCountrySelect.displayName = 'CountrySelect';\n\nexport { CountrySelect };\n"],"mappings":";;;;;AAQA,MAAM,gBAAgB,MAAM,YAKzB,EAAE,cAAc,WAAW,QAAQ,cAAc,GAAG,SAAS,QAAQ;CACtE,MAAM,WAAW,OAA0B,KAAK;AAEhD,qBACE,WACM,SAAS,QAChB;CAED,MAAM,iBAAiB,cAAc;AACnC,MAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/country-select/index.tsx"],"sourcesContent":["import React, { useImperativeHandle, useMemo, useRef } from 'react';\n\nimport NativeSelect, {\n NativeSelectProps,\n} from '@gfed-medusa/sf-lib-ui/components/native-select';\n\nimport { Region } from '@/types/graphql';\n\nconst CountrySelect = React.forwardRef<\n HTMLSelectElement,\n NativeSelectProps & {\n region?: Region | null;\n }\n>(({ placeholder = 'Country', region, defaultValue, ...props }, ref) => {\n const innerRef = useRef<HTMLSelectElement>(null);\n\n useImperativeHandle<HTMLSelectElement | null, HTMLSelectElement | null>(\n ref,\n () => innerRef.current\n );\n\n const countryOptions = useMemo(() => {\n if (!region) {\n return [];\n }\n\n return region.countries?.map((country) => ({\n value: country?.iso2,\n label: country?.displayName,\n }));\n }, [region]);\n\n return (\n <NativeSelect\n ref={innerRef}\n placeholder={placeholder}\n defaultValue={defaultValue}\n {...props}\n >\n {countryOptions?.map(({ value, label }, index) => (\n <option key={index} value={value ?? ''}>\n {label}\n </option>\n ))}\n </NativeSelect>\n );\n});\n\nCountrySelect.displayName = 'CountrySelect';\n\nexport { CountrySelect };\n"],"mappings":";;;;;AAQA,MAAM,gBAAgB,MAAM,YAKzB,EAAE,cAAc,WAAW,QAAQ,cAAc,GAAG,SAAS,QAAQ;CACtE,MAAM,WAAW,OAA0B,KAAK;AAEhD,qBACE,WACM,SAAS,QAChB;CAED,MAAM,iBAAiB,cAAc;AACnC,MAAI,CAAC,OACH,QAAO,EAAE;AAGX,SAAO,OAAO,WAAW,KAAK,aAAa;GACzC,OAAO,SAAS;GAChB,OAAO,SAAS;GACjB,EAAE;IACF,CAAC,OAAO,CAAC;AAEZ,QACE,oBAAC;EACC,KAAK;EACQ;EACC;EACd,GAAI;YAEH,gBAAgB,KAAK,EAAE,OAAO,SAAS,UACtC,oBAAC;GAAmB,OAAO,SAAS;aACjC;KADU,MAEJ,CACT;GACW;EAEjB;AAEF,cAAc,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/delete-button/index.d.ts
|
|
4
4
|
declare const DeleteButton: ({
|
|
@@ -9,7 +9,7 @@ declare const DeleteButton: ({
|
|
|
9
9
|
id: string;
|
|
10
10
|
children?: React.ReactNode;
|
|
11
11
|
className?: string;
|
|
12
|
-
}) =>
|
|
12
|
+
}) => react_jsx_runtime1.JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { DeleteButton };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/error-message/index.d.ts
|
|
4
4
|
declare const ErrorMessage: ({
|
|
@@ -7,7 +7,7 @@ declare const ErrorMessage: ({
|
|
|
7
7
|
}: {
|
|
8
8
|
error?: string | null;
|
|
9
9
|
"data-testid"?: string;
|
|
10
|
-
}) =>
|
|
10
|
+
}) => react_jsx_runtime2.JSX.Element | null;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { ErrorMessage };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,kBAAA,CAAA,GAAA,CAAA,OAAA,GAaA,IAAA"}
|
|
@@ -2,9 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
|
|
3
3
|
//#region src/components/error-message/index.tsx
|
|
4
4
|
const ErrorMessage = ({ error, "data-testid": dataTestid }) => {
|
|
5
|
-
if (!error)
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
5
|
+
if (!error) return null;
|
|
8
6
|
return /* @__PURE__ */ jsx("div", {
|
|
9
7
|
className: "text-small-regular pt-2 text-rose-600",
|
|
10
8
|
"data-testid": dataTestid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":["const ErrorMessage = ({\n error,\n 'data-testid': dataTestid,\n}: {\n error?: string | null;\n 'data-testid'?: string;\n}) => {\n if (!error) {\n return null;\n }\n\n return (\n <div\n className=\"text-small-regular pt-2 text-rose-600\"\n data-testid={dataTestid}\n >\n <span>{error}</span>\n </div>\n );\n};\n\nexport { ErrorMessage };\n"],"mappings":";;;AAAA,MAAM,gBAAgB,EACpB,OACA,eAAe,iBAIX;AACJ,KAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":["const ErrorMessage = ({\n error,\n 'data-testid': dataTestid,\n}: {\n error?: string | null;\n 'data-testid'?: string;\n}) => {\n if (!error) {\n return null;\n }\n\n return (\n <div\n className=\"text-small-regular pt-2 text-rose-600\"\n data-testid={dataTestid}\n >\n <span>{error}</span>\n </div>\n );\n};\n\nexport { ErrorMessage };\n"],"mappings":";;;AAAA,MAAM,gBAAgB,EACpB,OACA,eAAe,iBAIX;AACJ,KAAI,CAAC,MACH,QAAO;AAGT,QACE,oBAAC;EACC,WAAU;EACV,eAAa;YAEb,oBAAC,oBAAM,QAAa;GAChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cart, ShippingOption } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/free-shipping-price-nudge/index.d.ts
|
|
5
5
|
declare function ShippingPriceNudge({
|
|
@@ -10,7 +10,7 @@ declare function ShippingPriceNudge({
|
|
|
10
10
|
variant?: 'popup' | 'inline';
|
|
11
11
|
cart: Cart;
|
|
12
12
|
shippingOptions: ShippingOption[];
|
|
13
|
-
}):
|
|
13
|
+
}): react_jsx_runtime3.JSX.Element | undefined;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ShippingPriceNudge };
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,59 +12,47 @@ const computeTarget = (cart, price) => {
|
|
|
12
12
|
const priceRule = (price.priceRules || []).find((pr) => pr?.attribute === "item_total");
|
|
13
13
|
const currentAmount = cart.itemTotal;
|
|
14
14
|
const targetAmount = parseFloat(priceRule.value);
|
|
15
|
-
if (priceRule.operator === "gt") {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
target_amount: targetAmount,
|
|
51
|
-
target_reached: currentAmount === targetAmount,
|
|
52
|
-
target_remaining: targetAmount > currentAmount ? 0 : targetAmount - currentAmount,
|
|
53
|
-
remaining_percentage: currentAmount / targetAmount * 100
|
|
54
|
-
};
|
|
55
|
-
}
|
|
15
|
+
if (priceRule.operator === "gt") return {
|
|
16
|
+
current_amount: currentAmount,
|
|
17
|
+
target_amount: targetAmount,
|
|
18
|
+
target_reached: currentAmount > targetAmount,
|
|
19
|
+
target_remaining: currentAmount > targetAmount ? 0 : targetAmount + 1 - currentAmount,
|
|
20
|
+
remaining_percentage: currentAmount / targetAmount * 100
|
|
21
|
+
};
|
|
22
|
+
else if (priceRule.operator === "gte") return {
|
|
23
|
+
current_amount: currentAmount,
|
|
24
|
+
target_amount: targetAmount,
|
|
25
|
+
target_reached: currentAmount > targetAmount,
|
|
26
|
+
target_remaining: currentAmount > targetAmount ? 0 : targetAmount - currentAmount,
|
|
27
|
+
remaining_percentage: currentAmount / targetAmount * 100
|
|
28
|
+
};
|
|
29
|
+
else if (priceRule.operator === "lt") return {
|
|
30
|
+
current_amount: currentAmount,
|
|
31
|
+
target_amount: targetAmount,
|
|
32
|
+
target_reached: targetAmount > currentAmount,
|
|
33
|
+
target_remaining: targetAmount > currentAmount ? 0 : currentAmount + 1 - targetAmount,
|
|
34
|
+
remaining_percentage: currentAmount / targetAmount * 100
|
|
35
|
+
};
|
|
36
|
+
else if (priceRule.operator === "lte") return {
|
|
37
|
+
current_amount: currentAmount,
|
|
38
|
+
target_amount: targetAmount,
|
|
39
|
+
target_reached: targetAmount > currentAmount,
|
|
40
|
+
target_remaining: targetAmount > currentAmount ? 0 : currentAmount - targetAmount,
|
|
41
|
+
remaining_percentage: currentAmount / targetAmount * 100
|
|
42
|
+
};
|
|
43
|
+
else return {
|
|
44
|
+
current_amount: currentAmount,
|
|
45
|
+
target_amount: targetAmount,
|
|
46
|
+
target_reached: currentAmount === targetAmount,
|
|
47
|
+
target_remaining: targetAmount > currentAmount ? 0 : targetAmount - currentAmount,
|
|
48
|
+
remaining_percentage: currentAmount / targetAmount * 100
|
|
49
|
+
};
|
|
56
50
|
};
|
|
57
51
|
function ShippingPriceNudge({ variant = "inline", cart, shippingOptions }) {
|
|
58
|
-
if (!cart || !shippingOptions?.length)
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
52
|
+
if (!cart || !shippingOptions?.length) return;
|
|
61
53
|
const freeShippingPrice = shippingOptions.map((shippingOption) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const validCurrencyPrices = (shippingOption.prices ?? []).filter((price) => price !== null && price !== undefined && price.currencyCode === cart.currencyCode && (price.priceRules || []).some((priceRule) => priceRule?.attribute === "item_total"));
|
|
67
|
-
return validCurrencyPrices.map((price) => {
|
|
54
|
+
if (!shippingOption.calculatedPrice) return;
|
|
55
|
+
return (shippingOption.prices ?? []).filter((price) => price !== null && price !== void 0 && price.currencyCode === cart.currencyCode && (price.priceRules || []).some((priceRule) => priceRule?.attribute === "item_total")).map((price) => {
|
|
68
56
|
return {
|
|
69
57
|
...price,
|
|
70
58
|
shipping_option_id: shippingOption.id,
|
|
@@ -72,20 +60,15 @@ function ShippingPriceNudge({ variant = "inline", cart, shippingOptions }) {
|
|
|
72
60
|
};
|
|
73
61
|
});
|
|
74
62
|
}).flat(1).filter(Boolean).find((price) => price?.amount === 0);
|
|
75
|
-
if (!freeShippingPrice)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return /* @__PURE__ */ jsx(FreeShippingInline, {
|
|
85
|
-
cart,
|
|
86
|
-
price: freeShippingPrice
|
|
87
|
-
});
|
|
88
|
-
}
|
|
63
|
+
if (!freeShippingPrice) return;
|
|
64
|
+
if (variant === "popup") return /* @__PURE__ */ jsx(FreeShippingPopup, {
|
|
65
|
+
cart,
|
|
66
|
+
price: freeShippingPrice
|
|
67
|
+
});
|
|
68
|
+
else return /* @__PURE__ */ jsx(FreeShippingInline, {
|
|
69
|
+
cart,
|
|
70
|
+
price: freeShippingPrice
|
|
71
|
+
});
|
|
89
72
|
}
|
|
90
73
|
function FreeShippingInline({ cart, price }) {
|
|
91
74
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { CheckCircleSolid, XMark } from '@medusajs/icons';\nimport { Button, clx } from '@medusajs/ui';\n\nimport { convertToLocale } from '@/lib/utils/money';\nimport { Cart, ShippingOption, ShippingOptionPrice } from '@/types/graphql';\nimport { StoreFreeShippingPrice } from '@/types/prices';\n\nimport { LocalizedClientLink } from '../localized-client-link';\n\nconst computeTarget = (cart: Cart, price: ShippingOptionPrice) => {\n const priceRule = (price.priceRules || []).find(\n (pr) => pr?.attribute === 'item_total'\n )!;\n\n const currentAmount = cart.itemTotal;\n const targetAmount = parseFloat(priceRule.value);\n\n if (priceRule.operator === 'gt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount + 1 - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'gte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount + 1 - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount === targetAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n }\n};\n\nfunction ShippingPriceNudge({\n variant = 'inline',\n cart,\n shippingOptions,\n}: {\n variant?: 'popup' | 'inline';\n cart: Cart;\n shippingOptions: ShippingOption[];\n}) {\n if (!cart || !shippingOptions?.length) {\n return;\n }\n\n // Check if any shipping options have a conditional price based on item_total\n const freeShippingPrice = shippingOptions\n .map((shippingOption) => {\n const calculatedPrice = shippingOption.calculatedPrice;\n\n if (!calculatedPrice) {\n return;\n }\n\n // Get all prices that are:\n // 1. Currency code is same as the cart's\n // 2. Have a rule that is set on item_total\n const validCurrencyPrices = (shippingOption.prices ?? []).filter(\n (price): price is NonNullable<typeof price> =>\n price !== null &&\n price !== undefined &&\n price.currencyCode === cart.currencyCode &&\n (price.priceRules || []).some(\n (priceRule) => priceRule?.attribute === 'item_total'\n )\n );\n\n return validCurrencyPrices.map((price) => {\n return {\n ...price,\n shipping_option_id: shippingOption.id,\n ...computeTarget(cart, price),\n };\n });\n })\n .flat(1)\n .filter(Boolean)\n // We focus here entirely on free shipping, but this can be edited to handle multiple layers\n // of reduced shipping prices.\n .find((price) => price?.amount === 0);\n\n if (!freeShippingPrice) {\n return;\n }\n\n if (variant === 'popup') {\n return <FreeShippingPopup cart={cart} price={freeShippingPrice} />;\n } else {\n return <FreeShippingInline cart={cart} price={freeShippingPrice} />;\n }\n}\n\nfunction FreeShippingInline({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n return (\n <div className=\"rounded-lg border bg-neutral-100 p-2\">\n <div className=\"space-y-1.5\">\n <div className=\"flex justify-between text-xs text-neutral-600\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-neutral-950\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1 w-fit flex-grow rounded-full bg-neutral-300\"></div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction FreeShippingPopup({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n const [isClosed, setIsClosed] = useState(false);\n\n return (\n <div\n className={clx(\n 'fixed bottom-5 right-5 z-10 flex flex-col items-end gap-2 transition-all duration-500 ease-in-out',\n {\n 'invisible opacity-0 delay-1000': price.target_reached,\n 'invisible opacity-0': isClosed,\n 'visible opacity-100': !price.target_reached && !isClosed,\n }\n )}\n >\n <div>\n <Button\n className=\"rounded-full border-none bg-neutral-900 p-2 text-[15px] shadow-none outline-none\"\n onClick={() => setIsClosed(true)}\n >\n <XMark />\n </Button>\n </div>\n\n <div className=\"w-[400px] rounded-lg bg-black p-6 text-white\">\n <div className=\"pb-4\">\n <div className=\"space-y-3\">\n <div className=\"flex justify-between text-[15px] text-neutral-400\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-white\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1.5 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1.5 w-fit flex-grow rounded-full bg-zinc-600\"></div>\n </div>\n </div>\n </div>\n\n <div className=\"flex gap-3\">\n <LocalizedClientLink\n className=\"rounded-2xl border-[1px] border-white bg-transparent px-4 py-2.5 text-[15px] shadow-none outline-none\"\n href=\"/cart\"\n >\n View cart\n </LocalizedClientLink>\n\n <LocalizedClientLink\n className=\"flex-grow rounded-2xl border-[1px] border-white bg-white px-4 py-2.5 text-center text-[15px] text-neutral-950 shadow-none outline-none\"\n href=\"/store\"\n >\n View products\n </LocalizedClientLink>\n </div>\n </div>\n </div>\n );\n}\n\nexport { ShippingPriceNudge };\n"],"mappings":";;;;;;;;;;AAaA,MAAM,iBAAiB,MAAY,UAA+B;CAChE,MAAM,aAAa,MAAM,cAAc,EAAE,EAAE,MACxC,OAAO,IAAI,cAAc,aAC3B;CAED,MAAM,gBAAgB,KAAK;CAC3B,MAAM,eAAe,WAAW,UAAU,MAAM;AAEhD,KAAI,UAAU,aAAa,MAAM;AAC/B,SAAO;GACL,gBAAgB;GAChB,eAAe;GACf,gBAAgB,gBAAgB;GAChC,kBACE,gBAAgB,eAAe,IAAI,eAAe,IAAI;GACxD,sBAAuB,gBAAgB,eAAgB;GACxD;YACQ,UAAU,aAAa,OAAO;AACvC,SAAO;GACL,gBAAgB;GAChB,eAAe;GACf,gBAAg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AM,gBAC9B,CAAC;;QACH;QACM;QACL,oBAAC;SAAK,WAAU;mBACb,gBAAgB;UACf,QAAQ,MAAM;UACd,eAAe,KAAK;UACrB,CAAC;UACG;QAAC;QAAI;;QAER;OACF,EACN,qBAAC;MAAI,WAAU;iBACb,oBAAC;OACC,WAAW,IACT,qGACA,EACE,+BAA+B,MAAM,gBACtC,CACF;OACD,OAAO,EAAE,OAAO,GAAG,MAAM,qBAAqB,IAAI;QAC7C,EACP,oBAAC,SAAI,WAAU,mDAAuD;OAClE;MACF;KACF,EAEN,qBAAC;IAAI,WAAU;eACb,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB,EAEtB,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB;KAClB;IACF;GACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { CheckCircleSolid, XMark } from '@medusajs/icons';\nimport { Button, clx } from '@medusajs/ui';\n\nimport { convertToLocale } from '@/lib/utils/money';\nimport { Cart, ShippingOption, ShippingOptionPrice } from '@/types/graphql';\nimport { StoreFreeShippingPrice } from '@/types/prices';\n\nimport { LocalizedClientLink } from '../localized-client-link';\n\nconst computeTarget = (cart: Cart, price: ShippingOptionPrice) => {\n const priceRule = (price.priceRules || []).find(\n (pr) => pr?.attribute === 'item_total'\n )!;\n\n const currentAmount = cart.itemTotal;\n const targetAmount = parseFloat(priceRule.value);\n\n if (priceRule.operator === 'gt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount + 1 - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'gte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount + 1 - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount === targetAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n }\n};\n\nfunction ShippingPriceNudge({\n variant = 'inline',\n cart,\n shippingOptions,\n}: {\n variant?: 'popup' | 'inline';\n cart: Cart;\n shippingOptions: ShippingOption[];\n}) {\n if (!cart || !shippingOptions?.length) {\n return;\n }\n\n // Check if any shipping options have a conditional price based on item_total\n const freeShippingPrice = shippingOptions\n .map((shippingOption) => {\n const calculatedPrice = shippingOption.calculatedPrice;\n\n if (!calculatedPrice) {\n return;\n }\n\n // Get all prices that are:\n // 1. Currency code is same as the cart's\n // 2. Have a rule that is set on item_total\n const validCurrencyPrices = (shippingOption.prices ?? []).filter(\n (price): price is NonNullable<typeof price> =>\n price !== null &&\n price !== undefined &&\n price.currencyCode === cart.currencyCode &&\n (price.priceRules || []).some(\n (priceRule) => priceRule?.attribute === 'item_total'\n )\n );\n\n return validCurrencyPrices.map((price) => {\n return {\n ...price,\n shipping_option_id: shippingOption.id,\n ...computeTarget(cart, price),\n };\n });\n })\n .flat(1)\n .filter(Boolean)\n // We focus here entirely on free shipping, but this can be edited to handle multiple layers\n // of reduced shipping prices.\n .find((price) => price?.amount === 0);\n\n if (!freeShippingPrice) {\n return;\n }\n\n if (variant === 'popup') {\n return <FreeShippingPopup cart={cart} price={freeShippingPrice} />;\n } else {\n return <FreeShippingInline cart={cart} price={freeShippingPrice} />;\n }\n}\n\nfunction FreeShippingInline({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n return (\n <div className=\"rounded-lg border bg-neutral-100 p-2\">\n <div className=\"space-y-1.5\">\n <div className=\"flex justify-between text-xs text-neutral-600\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-neutral-950\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1 w-fit flex-grow rounded-full bg-neutral-300\"></div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction FreeShippingPopup({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n const [isClosed, setIsClosed] = useState(false);\n\n return (\n <div\n className={clx(\n 'fixed bottom-5 right-5 z-10 flex flex-col items-end gap-2 transition-all duration-500 ease-in-out',\n {\n 'invisible opacity-0 delay-1000': price.target_reached,\n 'invisible opacity-0': isClosed,\n 'visible opacity-100': !price.target_reached && !isClosed,\n }\n )}\n >\n <div>\n <Button\n className=\"rounded-full border-none bg-neutral-900 p-2 text-[15px] shadow-none outline-none\"\n onClick={() => setIsClosed(true)}\n >\n <XMark />\n </Button>\n </div>\n\n <div className=\"w-[400px] rounded-lg bg-black p-6 text-white\">\n <div className=\"pb-4\">\n <div className=\"space-y-3\">\n <div className=\"flex justify-between text-[15px] text-neutral-400\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-white\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1.5 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1.5 w-fit flex-grow rounded-full bg-zinc-600\"></div>\n </div>\n </div>\n </div>\n\n <div className=\"flex gap-3\">\n <LocalizedClientLink\n className=\"rounded-2xl border-[1px] border-white bg-transparent px-4 py-2.5 text-[15px] shadow-none outline-none\"\n href=\"/cart\"\n >\n View cart\n </LocalizedClientLink>\n\n <LocalizedClientLink\n className=\"flex-grow rounded-2xl border-[1px] border-white bg-white px-4 py-2.5 text-center text-[15px] text-neutral-950 shadow-none outline-none\"\n href=\"/store\"\n >\n View products\n </LocalizedClientLink>\n </div>\n </div>\n </div>\n );\n}\n\nexport { ShippingPriceNudge };\n"],"mappings":";;;;;;;;;;AAaA,MAAM,iBAAiB,MAAY,UAA+B;CAChE,MAAM,aAAa,MAAM,cAAc,EAAE,EAAE,MACxC,OAAO,IAAI,cAAc,aAC3B;CAED,MAAM,gBAAgB,KAAK;CAC3B,MAAM,eAAe,WAAW,UAAU,MAAM;AAEhD,KAAI,UAAU,aAAa,KACzB,QAAO;EACL,gBAAgB;EAChB,eAAe;EACf,g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D,GAEN,yBAEE,EAEN,qBAAC;OACC,WAAW,IAAI,WAAW,EACxB,uBAAuB,MAAM,gBAC9B,CAAC;;QACH;QACM;QACL,oBAAC;SAAK,WAAU;mBACb,gBAAgB;UACf,QAAQ,MAAM;UACd,eAAe,KAAK;UACrB,CAAC;UACG;QAAC;QAAI;;QAER;OACF,EACN,qBAAC;MAAI,WAAU;iBACb,oBAAC;OACC,WAAW,IACT,qGACA,EACE,+BAA+B,MAAM,gBACtC,CACF;OACD,OAAO,EAAE,OAAO,GAAG,MAAM,qBAAqB,IAAI;QAC7C,EACP,oBAAC,SAAI,WAAU,mDAAuD;OAClE;MACF;KACF,EAEN,qBAAC;IAAI,WAAU;eACb,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB,EAEtB,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB;KAClB;IACF;GACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocalizedClientLink } from "../localized-client-link/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/interactive-link/index.d.ts
|
|
5
5
|
type InteractiveLinkProps = React.ComponentPropsWithoutRef<typeof LocalizedClientLink> & {
|
|
@@ -14,7 +14,7 @@ declare const InteractiveLink: ({
|
|
|
14
14
|
textClassName,
|
|
15
15
|
iconClassName,
|
|
16
16
|
...props
|
|
17
|
-
}: InteractiveLinkProps) =>
|
|
17
|
+
}: InteractiveLinkProps) => react_jsx_runtime5.JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { InteractiveLink };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe, ProductVariant } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/line-item-options/index.d.ts
|
|
5
5
|
type LineItemOptionsProps = {
|
|
@@ -11,7 +11,7 @@ declare const LineItemOptions: ({
|
|
|
11
11
|
variant,
|
|
12
12
|
"data-testid": dataTestid,
|
|
13
13
|
"data-value": dataValue
|
|
14
|
-
}: LineItemOptionsProps) =>
|
|
14
|
+
}: LineItemOptionsProps) => react_jsx_runtime7.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LineItemOptions };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LineItem } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/line-item-price/index.d.ts
|
|
5
5
|
type LineItemPriceProps = {
|
|
@@ -11,7 +11,7 @@ declare const LineItemPrice: ({
|
|
|
11
11
|
item,
|
|
12
12
|
style,
|
|
13
13
|
currencyCode
|
|
14
|
-
}: LineItemPriceProps) =>
|
|
14
|
+
}: LineItemPriceProps) => react_jsx_runtime8.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LineItemPrice };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-price/index.tsx"],"sourcesContent":[],"mappings":";;;;KAMK,kBAAA;QACG;;EADH,YAAA,EAAA,MAAA;AACW,CAAA;cAKV,aAAiB,EAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EAIpB,kBAJoB,EAAA,GAIF,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-price/index.tsx"],"sourcesContent":[],"mappings":";;;;KAMK,kBAAA;QACG;;EADH,YAAA,EAAA,MAAA;AACW,CAAA;cAKV,aAAiB,EAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EAIpB,kBAJoB,EAAA,GAIF,kBAAA,CAAA,GAAA,CAAA,OAJE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, DetailedHTMLProps } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/localized-client-link/index.d.ts
|
|
5
5
|
type LocalizedClientLinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & {
|
|
@@ -10,7 +10,7 @@ declare const LocalizedClientLink: ({
|
|
|
10
10
|
href,
|
|
11
11
|
locale,
|
|
12
12
|
...props
|
|
13
|
-
}: LocalizedClientLinkProps) =>
|
|
13
|
+
}: LocalizedClientLinkProps) => react_jsx_runtime4.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { LocalizedClientLink };
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,9 +12,7 @@ const LocalizedClientLink = ({ children, href, locale, ...props }) => {
|
|
|
12
12
|
}, []);
|
|
13
13
|
const getLocaleFromPathname = (pathname$1) => {
|
|
14
14
|
const pathLocale = pathname$1.split("/")[1];
|
|
15
|
-
if (pathLocale && LOCALE_REGEX.test(pathLocale))
|
|
16
|
-
return pathLocale;
|
|
17
|
-
}
|
|
15
|
+
if (pathLocale && LOCALE_REGEX.test(pathLocale)) return pathLocale;
|
|
18
16
|
return "dk";
|
|
19
17
|
};
|
|
20
18
|
const activeLocale = locale || getLocaleFromPathname(pathname);
|
|
@@ -22,13 +20,11 @@ const LocalizedClientLink = ({ children, href, locale, ...props }) => {
|
|
|
22
20
|
if (!href$1) return "";
|
|
23
21
|
return href$1.startsWith("/") ? href$1 : `/${href$1}`;
|
|
24
22
|
};
|
|
25
|
-
if (href?.startsWith("http") || href?.startsWith("//")) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
}
|
|
23
|
+
if (href?.startsWith("http") || href?.startsWith("//")) return /* @__PURE__ */ jsx("a", {
|
|
24
|
+
href,
|
|
25
|
+
...props,
|
|
26
|
+
children
|
|
27
|
+
});
|
|
32
28
|
return /* @__PURE__ */ jsx("a", {
|
|
33
29
|
href: `/${activeLocale}${normalizeHref(href)}`,
|
|
34
30
|
suppressHydrationWarning: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["pathname","href"],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n AnchorHTMLAttributes,\n DetailedHTMLProps,\n useEffect,\n useState,\n} from 'react';\n\nconst LOCALE_REGEX = /^[a-z]{2}(?:-[A-Z]{2})?$/;\n\ntype LocalizedClientLinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> & {\n locale?: string;\n};\n\nconst LocalizedClientLink = ({\n children,\n href,\n locale,\n ...props\n}: LocalizedClientLinkProps) => {\n const [pathname, setPathname] = useState('');\n\n useEffect(() => {\n setPathname(window.location.pathname);\n }, []);\n\n const getLocaleFromPathname = (pathname: string): string => {\n const pathLocale = pathname.split('/')[1];\n if (pathLocale && LOCALE_REGEX.test(pathLocale)) {\n return pathLocale;\n }\n return 'dk';\n };\n\n const activeLocale = locale || getLocaleFromPathname(pathname);\n\n const normalizeHref = (href?: string) => {\n if (!href) return '';\n return href.startsWith('/') ? href : `/${href}`;\n };\n\n if (href?.startsWith('http') || href?.startsWith('//')) {\n return (\n <a href={href} {...props}>\n {children}\n </a>\n );\n }\n\n return (\n <a\n href={`/${activeLocale}${normalizeHref(href)}`}\n suppressHydrationWarning\n {...props}\n >\n {children}\n </a>\n );\n};\n\nexport { LocalizedClientLink };\n"],"mappings":";;;;;;AASA,MAAM,eAAe;AASrB,MAAM,uBAAuB,EAC3B,UACA,MACA,QACA,GAAG,YAC2B;CAC9B,MAAM,CAAC,UAAU,eAAe,SAAS,GAAG;AAE5C,iBAAgB;AACd,cAAY,OAAO,SAAS,SAAS;IACpC,EAAE,CAAC;CAEN,MAAM,yBAAyB,eAA6B;EAC1D,MAAM,aAAaA,WAAS,MAAM,IAAI,CAAC;AACvC,MAAI,cAAc,aAAa,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","names":["pathname","href"],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n AnchorHTMLAttributes,\n DetailedHTMLProps,\n useEffect,\n useState,\n} from 'react';\n\nconst LOCALE_REGEX = /^[a-z]{2}(?:-[A-Z]{2})?$/;\n\ntype LocalizedClientLinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> & {\n locale?: string;\n};\n\nconst LocalizedClientLink = ({\n children,\n href,\n locale,\n ...props\n}: LocalizedClientLinkProps) => {\n const [pathname, setPathname] = useState('');\n\n useEffect(() => {\n setPathname(window.location.pathname);\n }, []);\n\n const getLocaleFromPathname = (pathname: string): string => {\n const pathLocale = pathname.split('/')[1];\n if (pathLocale && LOCALE_REGEX.test(pathLocale)) {\n return pathLocale;\n }\n return 'dk';\n };\n\n const activeLocale = locale || getLocaleFromPathname(pathname);\n\n const normalizeHref = (href?: string) => {\n if (!href) return '';\n return href.startsWith('/') ? href : `/${href}`;\n };\n\n if (href?.startsWith('http') || href?.startsWith('//')) {\n return (\n <a href={href} {...props}>\n {children}\n </a>\n );\n }\n\n return (\n <a\n href={`/${activeLocale}${normalizeHref(href)}`}\n suppressHydrationWarning\n {...props}\n >\n {children}\n </a>\n );\n};\n\nexport { LocalizedClientLink };\n"],"mappings":";;;;;;AASA,MAAM,eAAe;AASrB,MAAM,uBAAuB,EAC3B,UACA,MACA,QACA,GAAG,YAC2B;CAC9B,MAAM,CAAC,UAAU,eAAe,SAAS,GAAG;AAE5C,iBAAgB;AACd,cAAY,OAAO,SAAS,SAAS;IACpC,EAAE,CAAC;CAEN,MAAM,yBAAyB,eAA6B;EAC1D,MAAM,aAAaA,WAAS,MAAM,IAAI,CAAC;AACvC,MAAI,cAAc,aAAa,KAAK,WAAW,CAC7C,QAAO;AAET,SAAO;;CAGT,MAAM,eAAe,UAAU,sBAAsB,SAAS;CAE9D,MAAM,iBAAiB,WAAkB;AACvC,MAAI,CAACC,OAAM,QAAO;AAClB,SAAOA,OAAK,WAAW,IAAI,GAAGA,SAAO,IAAIA;;AAG3C,KAAI,MAAM,WAAW,OAAO,IAAI,MAAM,WAAW,KAAK,CACpD,QACE,oBAAC;EAAQ;EAAM,GAAI;EAChB;GACC;AAIR,QACE,oBAAC;EACC,MAAM,IAAI,eAAe,cAAc,KAAK;EAC5C;EACA,GAAI;EAEH;GACC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/modal/index.d.ts
|
|
5
5
|
type ModalProps = {
|
|
@@ -20,7 +20,7 @@ declare const Modal: {
|
|
|
20
20
|
children,
|
|
21
21
|
"data-testid": dataTestId,
|
|
22
22
|
"aria-label": ariaLabel
|
|
23
|
-
}: ModalProps):
|
|
23
|
+
}: ModalProps): react_jsx_runtime6.JSX.Element;
|
|
24
24
|
Title: React.FC<{
|
|
25
25
|
children: React.ReactNode;
|
|
26
26
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":[],"mappings":";;;;KAQK,UAAA;;;EAAA,IAAA,CAAA,EAAA,OAAU,GAAA,QAAA,GAKH,OAAM;EAKZ,MAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":[],"mappings":";;;;KAQK,UAAA;;;EAAA,IAAA,CAAA,EAAA,OAAU,GAAA,QAAA,GAKH,OAAM;EAKZ,MAAA,CAAA,EAmEL,OAAA;YAxEW,KAAA,CAAM;;;;cAKZ;;;;;;;;;KAQH,aAAU,kBAAA,CAAA,GAAA,CAAA;;IAAV,QAAA,EA6D+B,KAAA,CAAM,SA7DrC;EAAU,CAAA,CAAA;EA6DqB,WAAM,UAAA,CAAA;cAeA,KAAA,CAAM;EAAN,CAAA,CAAA;;IAQD,QAAA,EAAN,KAAA,CAAM,SAAA;;EAIJ,MAAM,UAAA,CAAA;cAAN,KAAA,CAAM"}
|
|
@@ -24,13 +24,13 @@ const Modal = ({ isOpen, close, size = "medium", search = false, children, "data
|
|
|
24
24
|
leave: "ease-in duration-200",
|
|
25
25
|
leaveFrom: "opacity-100",
|
|
26
26
|
leaveTo: "opacity-0",
|
|
27
|
-
children: /* @__PURE__ */ jsx("div", { className: "fixed inset-0 h-screen bg-
|
|
27
|
+
children: /* @__PURE__ */ jsx("div", { className: "fixed inset-0 h-screen bg-black/20 backdrop-blur-sm" })
|
|
28
28
|
}), /* @__PURE__ */ jsx("div", {
|
|
29
29
|
className: "fixed inset-0 overflow-y-hidden",
|
|
30
30
|
children: /* @__PURE__ */ jsx("div", {
|
|
31
|
-
className: clx("flex h-full min-h-full justify-center
|
|
32
|
-
"items-center": !search,
|
|
33
|
-
"items-start": search
|
|
31
|
+
className: clx("flex h-full min-h-full justify-center text-center", {
|
|
32
|
+
"items-center p-4": !search,
|
|
33
|
+
"items-start small:pt-[68px] small:px-4 small:pb-4": search
|
|
34
34
|
}),
|
|
35
35
|
children: /* @__PURE__ */ jsx(Transition.Child, {
|
|
36
36
|
as: Fragment,
|
|
@@ -42,12 +42,10 @@ const Modal = ({ isOpen, close, size = "medium", search = false, children, "data
|
|
|
42
42
|
leaveTo: "opacity-0 scale-95",
|
|
43
43
|
children: /* @__PURE__ */ jsx(Dialog.Panel, {
|
|
44
44
|
"data-testid": dataTestId,
|
|
45
|
-
className: clx("flex h-fit max-h-[75vh] w-full transform flex-col justify-start p-5 text-left align-middle transition-all", {
|
|
45
|
+
className: clx("flex h-dvh small:h-fit small:max-h-[75vh] w-full transform flex-col justify-start rounded-none small:rounded-rounded border bg-white p-4 small:p-5 shadow-xl text-left align-middle transition-all", {
|
|
46
46
|
"max-w-md": size === "small",
|
|
47
47
|
"max-w-xl": size === "medium",
|
|
48
|
-
"max-w-3xl": size === "large"
|
|
49
|
-
"bg-transparent shadow-none": search,
|
|
50
|
-
"rounded-rounded border bg-white shadow-xl": !search
|
|
48
|
+
"max-w-3xl": size === "large"
|
|
51
49
|
}),
|
|
52
50
|
children: /* @__PURE__ */ jsx(ModalProvider, {
|
|
53
51
|
close,
|