@tapcart/mobile-components 0.15.1 → 0.16.0
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/core/button.d.ts +37 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.js +44 -0
- package/dist/components/core/html.d.ts +15 -0
- package/dist/components/core/html.d.ts.map +1 -0
- package/dist/components/core/html.js +45 -0
- package/dist/components/core/text.d.ts +29 -0
- package/dist/components/core/text.d.ts.map +1 -0
- package/dist/components/core/text.js +88 -0
- package/dist/components/hooks/use-order-details.d.ts.map +1 -1
- package/dist/components/hooks/use-order-details.js +13 -11
- package/dist/components/hooks/use-search-analytics-open-product.d.ts +3 -2
- package/dist/components/hooks/use-search-analytics-open-product.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/core/index.d.ts +99 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +98 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/get-data.d.ts +27 -0
- package/dist/lib/get-data.d.ts.map +1 -0
- package/dist/lib/get-data.js +65 -0
- package/dist/lib/get-data.test.d.ts +2 -0
- package/dist/lib/get-data.test.d.ts.map +1 -0
- package/dist/lib/get-data.test.js +74 -0
- package/dist/lib/to-html.d.ts +9 -0
- package/dist/lib/to-html.d.ts.map +1 -0
- package/dist/lib/to-html.js +102 -0
- package/dist/styles.css +9 -0
- package/dist/tests/use-order-details.test.d.ts +2 -0
- package/dist/tests/use-order-details.test.d.ts.map +1 -0
- package/dist/tests/use-order-details.test.js +65 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ButtonKind = "primary" | "secondary" | "outline" | "link" | "destructive";
|
|
3
|
+
export type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
4
|
+
export type ButtonIconSize = "xxs" | "xs" | "sm" | "md" | "lg";
|
|
5
|
+
/** Icon slot for a button. Pass `url` for a custom SVG or a Tabler icon URL. */
|
|
6
|
+
export type ButtonIcon = {
|
|
7
|
+
/** SVG URL — e.g. a Tabler icon from jsDelivr. */
|
|
8
|
+
url?: string;
|
|
9
|
+
/** Icon size token. Defaults to "sm". */
|
|
10
|
+
size?: ButtonIconSize;
|
|
11
|
+
/** Optional color override. */
|
|
12
|
+
color?: string;
|
|
13
|
+
};
|
|
14
|
+
export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "color"> {
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
/** Button kind — drives the brand class (color, border, radius). Required for brand styling. */
|
|
17
|
+
kind?: ButtonKind;
|
|
18
|
+
/** Button size — drives the brand size class (font, padding, gap). Defaults to "md". */
|
|
19
|
+
size?: ButtonSize;
|
|
20
|
+
/** Icon rendered before the label. */
|
|
21
|
+
leftIcon?: ButtonIcon;
|
|
22
|
+
/** Icon rendered after the label. */
|
|
23
|
+
rightIcon?: ButtonIcon;
|
|
24
|
+
/** Stretch to 100% container width. Defaults to false. */
|
|
25
|
+
fullWidth?: boolean;
|
|
26
|
+
/** Show loading spinner and disable interaction. */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
labelClassName?: string;
|
|
29
|
+
labelStyle?: React.CSSProperties;
|
|
30
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
31
|
+
}
|
|
32
|
+
declare const Button: {
|
|
33
|
+
({ className, labelClassName, labelStyle, size, kind, leftIcon, rightIcon, asChild, loading, onClick, type, fullWidth, style, disabled, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
displayName: string;
|
|
35
|
+
};
|
|
36
|
+
export { Button };
|
|
37
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/core/button.tsx"],"names":[],"mappings":"A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AAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Slot as RadixSlot } from "@radix-ui/react-slot";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { Icon } from "../ui/icon";
|
|
17
|
+
// ── Spinner ──
|
|
18
|
+
const Spinner = () => (_jsxs("svg", Object.assign({ className: "h-4 w-4 animate-spin", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" }, { children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] })));
|
|
19
|
+
// ── Component ──
|
|
20
|
+
const Button = (_a) => {
|
|
21
|
+
var { className, labelClassName, labelStyle, size = "md", kind, leftIcon, rightIcon, asChild = false, loading, onClick, type, fullWidth = false, style, disabled } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "size", "kind", "leftIcon", "rightIcon", "asChild", "loading", "onClick", "type", "fullWidth", "style", "disabled"]);
|
|
22
|
+
const Slot = asChild ? RadixSlot : "button";
|
|
23
|
+
const kindClass = kind ? `brand-button-${kind}` : "";
|
|
24
|
+
const sizeClass = `brand-button-${size}`;
|
|
25
|
+
const handleClick = onClick
|
|
26
|
+
? (e) => {
|
|
27
|
+
try {
|
|
28
|
+
onClick(e);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
: undefined;
|
|
35
|
+
const renderIconSlot = (slot) => (slot === null || slot === void 0 ? void 0 : slot.url) ? (_jsx(Icon, { url: slot.url, size: slot.size || "sm", style: slot.color ? { color: slot.color } : undefined })) : null;
|
|
36
|
+
const renderLabel = () => {
|
|
37
|
+
if (props.children == null)
|
|
38
|
+
return null;
|
|
39
|
+
return (_jsx("span", Object.assign({ className: cn("truncate", labelClassName), style: labelStyle }, { children: props.children })));
|
|
40
|
+
};
|
|
41
|
+
return (_jsxs(Slot, Object.assign({}, props, { type: type, className: cn(kindClass, sizeClass, className), style: Object.assign({ width: fullWidth ? "100%" : "max-content" }, style), onClick: handleClick, disabled: loading || disabled }, { children: [loading && _jsx(Spinner, {}), renderIconSlot(leftIcon), renderLabel(), renderIconSlot(rightIcon)] })));
|
|
42
|
+
};
|
|
43
|
+
Button.displayName = "Button";
|
|
44
|
+
export { Button };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type HtmlKind = "headline" | "title" | "subtitle" | "body" | "caption" | "header";
|
|
3
|
+
export interface HtmlProps {
|
|
4
|
+
className?: any;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
html: string;
|
|
7
|
+
kind?: HtmlKind;
|
|
8
|
+
disableDefaultClasses?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare function Html({ className, style, html, kind, disableDefaultClasses, }: HtmlProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare namespace Html {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export { Html };
|
|
15
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../components/core/html.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,OAAO,GACP,UAAU,GACV,MAAM,GACN,SAAS,GACT,QAAQ,CAAA;AAWZ,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,iBAAS,IAAI,CAAC,EACZ,SAAc,EACd,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,qBAA6B,GAC9B,EAAE,SAAS,2CA2CX;kBAjDQ,IAAI;;;AAqDb,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import DOMPurify from "dompurify";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
const kindToClass = {
|
|
6
|
+
headline: "brand-headline",
|
|
7
|
+
title: "brand-title",
|
|
8
|
+
subtitle: "brand-subtitle",
|
|
9
|
+
body: "brand-body",
|
|
10
|
+
caption: "brand-caption",
|
|
11
|
+
header: "brand-header",
|
|
12
|
+
};
|
|
13
|
+
function Html({ className = "", style, html, kind, disableDefaultClasses = false, }) {
|
|
14
|
+
const cleanHtml = DOMPurify.sanitize(html, {
|
|
15
|
+
ADD_TAGS: [
|
|
16
|
+
"iframe",
|
|
17
|
+
"table",
|
|
18
|
+
"thead",
|
|
19
|
+
"tbody",
|
|
20
|
+
"tr",
|
|
21
|
+
"th",
|
|
22
|
+
"td",
|
|
23
|
+
"tfoot",
|
|
24
|
+
"caption",
|
|
25
|
+
"colgroup",
|
|
26
|
+
"col",
|
|
27
|
+
"img",
|
|
28
|
+
],
|
|
29
|
+
ADD_ATTR: [
|
|
30
|
+
"allow",
|
|
31
|
+
"allowfullscreen",
|
|
32
|
+
"frameborder",
|
|
33
|
+
"scrolling",
|
|
34
|
+
"src",
|
|
35
|
+
"alt",
|
|
36
|
+
"loading",
|
|
37
|
+
"width",
|
|
38
|
+
"height",
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
const defaultClasses = "grid [&>ul]:list-disc [&>ol]:list-decimal [&>ul]:pl-5 [&>ul>li]:py-1 space-y-1 [&>b]:py-2 [&>p]:py-2";
|
|
42
|
+
return (_jsx("div", { className: cn(disableDefaultClasses ? "" : defaultClasses, kind && kindToClass[kind], className), style: style, dangerouslySetInnerHTML: { __html: cleanHtml } }));
|
|
43
|
+
}
|
|
44
|
+
Html.displayName = "Html";
|
|
45
|
+
export { Html };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
type Injections = Record<string, {
|
|
4
|
+
payload: string;
|
|
5
|
+
currencyMetadata?: {
|
|
6
|
+
currency: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
declare const textVariants: (props?: ({
|
|
11
|
+
kind?: "title" | "caption" | "body" | "header" | "headline" | "subtitle" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
13
|
+
export type TextKind = NonNullable<VariantProps<typeof textVariants>["kind"]>;
|
|
14
|
+
export interface TextProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
15
|
+
kind?: TextKind;
|
|
16
|
+
fontColor?: string | null;
|
|
17
|
+
fontFamily?: string | null;
|
|
18
|
+
fontWeight?: number | null;
|
|
19
|
+
fontSize?: number | null;
|
|
20
|
+
textAlignment?: string | null;
|
|
21
|
+
injections?: Injections;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
declare function Text({ className, kind, fontColor, fontFamily, fontWeight, fontSize, textAlignment, injections, children, style, ...props }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare namespace Text {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
export { Text, textVariants };
|
|
29
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../components/core/text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAQjE,KAAK,UAAU,GAAG,MAAM,CACtB,MAAM,EACN;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAC7E,CAAA;AAgDD,QAAA,MAAM,YAAY;;mFAchB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE7E,MAAM,WAAW,SAAU,SAAQ,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC;IAC3E,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,EACJ,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,UAAU,EACV,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,SAAS,2CAyCX;kBArDQ,IAAI;;;AAyDb,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { cva } from "class-variance-authority";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { useTranslation, getTextTranslation, } from "../contexts/translation-context";
|
|
17
|
+
import { Money } from "../ui/money";
|
|
18
|
+
function injectString(template, injections) {
|
|
19
|
+
if (!injections)
|
|
20
|
+
return undefined;
|
|
21
|
+
if (!Object.entries(injections).length)
|
|
22
|
+
return undefined;
|
|
23
|
+
const parts = [];
|
|
24
|
+
let lastIndex = 0;
|
|
25
|
+
const matches = Array.from(template.matchAll(/\{\{(.*?)\}\}/g));
|
|
26
|
+
matches.forEach((match, index) => {
|
|
27
|
+
const key = match[1];
|
|
28
|
+
const injection = injections[key];
|
|
29
|
+
if (match.index && match.index > lastIndex) {
|
|
30
|
+
parts.push(template.slice(lastIndex, match.index));
|
|
31
|
+
}
|
|
32
|
+
if (injection) {
|
|
33
|
+
if (injection.currencyMetadata) {
|
|
34
|
+
parts.push(_jsx(Money, { price: Number(injection.payload), currency: injection.currencyMetadata.currency || "USD", locale: injection.currencyMetadata.locale || "en-US" }, `price-${index}`));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
parts.push(injection.payload);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
lastIndex = (match.index || 0) + match[0].length;
|
|
41
|
+
});
|
|
42
|
+
if (lastIndex < template.length) {
|
|
43
|
+
parts.push(template.slice(lastIndex));
|
|
44
|
+
}
|
|
45
|
+
return parts.length ? parts : undefined;
|
|
46
|
+
}
|
|
47
|
+
// V2 kind tokens only — no legacy h1/h2/h3/body-primary/body-secondary/label.
|
|
48
|
+
const textVariants = cva("", {
|
|
49
|
+
variants: {
|
|
50
|
+
kind: {
|
|
51
|
+
headline: "brand-headline",
|
|
52
|
+
title: "brand-title",
|
|
53
|
+
subtitle: "brand-subtitle",
|
|
54
|
+
body: "brand-body",
|
|
55
|
+
caption: "brand-caption",
|
|
56
|
+
header: "brand-header",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
kind: "body",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
function Text(_a) {
|
|
64
|
+
var _b;
|
|
65
|
+
var { className, kind, fontColor, fontFamily, fontWeight, fontSize, textAlignment, injections, children, style } = _a, props = __rest(_a, ["className", "kind", "fontColor", "fontFamily", "fontWeight", "fontSize", "textAlignment", "injections", "children", "style"]);
|
|
66
|
+
const fontColorOverride = fontColor ? { color: fontColor } : {};
|
|
67
|
+
const fontFamilyOverride = fontFamily ? { fontFamily } : {};
|
|
68
|
+
const fontWeightOverride = fontWeight ? { fontWeight } : {};
|
|
69
|
+
const fontSizeOverride = fontSize ? { fontSize } : {};
|
|
70
|
+
const textAlignmentOverride = textAlignment
|
|
71
|
+
? { textAlign: textAlignment }
|
|
72
|
+
: {};
|
|
73
|
+
const translations = useTranslation();
|
|
74
|
+
const stringContents = React.Children.toArray(children).join("");
|
|
75
|
+
// Translate first, then resolve {{injections}} against the translated text
|
|
76
|
+
// so injected values land in the correct localized string.
|
|
77
|
+
const textContents = getTextTranslation({
|
|
78
|
+
text: stringContents,
|
|
79
|
+
translations,
|
|
80
|
+
});
|
|
81
|
+
const injectContents = injectString(textContents !== null && textContents !== void 0 ? textContents : stringContents, injections);
|
|
82
|
+
// Nullish coalescing so an empty translated string stays valid; fall back to
|
|
83
|
+
// children only when the resolved result is null/undefined.
|
|
84
|
+
const content = (_b = injectContents !== null && injectContents !== void 0 ? injectContents : textContents) !== null && _b !== void 0 ? _b : children;
|
|
85
|
+
return (_jsx("p", Object.assign({ className: cn(textVariants({ kind }), className), style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, style), fontColorOverride), fontFamilyOverride), fontWeightOverride), fontSizeOverride), textAlignmentOverride) }, props, { children: content })));
|
|
86
|
+
}
|
|
87
|
+
Text.displayName = "Text";
|
|
88
|
+
export { Text, textVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAKA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC,CAAA;AA0LD,eAAO,MAAM,qBAAqB,UACzB,OAAO,MAAM,EAAE,GAAG,CAAC;kBACT,OAAO,MAAM,EAAE,GAAG,CAAC;kBAAgB,OAAO,MAAM,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAKA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC,CAAA;AA0LD,eAAO,MAAM,qBAAqB,UACzB,OAAO,MAAM,EAAE,GAAG,CAAC;kBACT,OAAO,MAAM,EAAE,GAAG,CAAC;kBAAgB,OAAO,MAAM,EAAE,GAAG,CAAC;CAmOxE,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAY,GACb,EAAE,oBAAoB,GAAG,iBAAiB,CAiE1C"}
|
|
@@ -148,9 +148,12 @@ export const transformOrderDetails = (order) => {
|
|
|
148
148
|
return parseFloat(amount) || 0;
|
|
149
149
|
return 0;
|
|
150
150
|
};
|
|
151
|
+
// Shopify Order Editing sets currentQuantity to 0 for removed/refunded
|
|
152
|
+
// line items — those must not be shown to the customer
|
|
153
|
+
const activeLineItems = (order.lineItems || []).filter((lineItem) => { var _a, _b; return ((_b = (_a = lineItem.currentQuantity) !== null && _a !== void 0 ? _a : lineItem.quantity) !== null && _b !== void 0 ? _b : 1) > 0; });
|
|
151
154
|
// Transform line items to cart lines
|
|
152
|
-
const cartLines =
|
|
153
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
155
|
+
const cartLines = activeLineItems.map((lineItem) => {
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
154
157
|
const variant = lineItem.variant || {};
|
|
155
158
|
const product = variant.product || {};
|
|
156
159
|
return {
|
|
@@ -185,14 +188,13 @@ export const transformOrderDetails = (order) => {
|
|
|
185
188
|
productId: ((_k = variant.product) === null || _k === void 0 ? void 0 : _k.id) || lineItem.productId,
|
|
186
189
|
merchandiseId: variant.id || lineItem.merchandiseId,
|
|
187
190
|
title: lineItem.title || product.title || "Unknown Product",
|
|
188
|
-
quantity: lineItem.quantity
|
|
191
|
+
quantity: (_m = (_l = lineItem.currentQuantity) !== null && _l !== void 0 ? _l : lineItem.quantity) !== null && _m !== void 0 ? _m : 1,
|
|
189
192
|
uniqueId: crypto.randomUUID(),
|
|
190
193
|
vendor: product.vendor || lineItem.vendor || "Unknown",
|
|
191
194
|
compareAtPrice: {
|
|
192
|
-
amount: parseAmount(((
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
((_p = lineItem.compareAtPrice) === null || _p === void 0 ? void 0 : _p.currencyCode) ||
|
|
195
|
+
amount: parseAmount(((_o = lineItem.originalTotalPrice) === null || _o === void 0 ? void 0 : _o.amount) || ((_p = lineItem.compareAtPrice) === null || _p === void 0 ? void 0 : _p.amount)),
|
|
196
|
+
currencyCode: ((_q = lineItem.originalTotalPrice) === null || _q === void 0 ? void 0 : _q.currencyCode) ||
|
|
197
|
+
((_r = lineItem.compareAtPrice) === null || _r === void 0 ? void 0 : _r.currencyCode) ||
|
|
196
198
|
order.currency ||
|
|
197
199
|
"USD",
|
|
198
200
|
},
|
|
@@ -262,8 +264,8 @@ export const transformOrderDetails = (order) => {
|
|
|
262
264
|
value: app.value || { percentage: 0 },
|
|
263
265
|
})),
|
|
264
266
|
subtotalPrice: wrapMoney(subtotal, currencyCode),
|
|
265
|
-
lineItems:
|
|
266
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
267
|
+
lineItems: activeLineItems.map((lineItem) => {
|
|
268
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
267
269
|
const variant = lineItem.variant || {};
|
|
268
270
|
const product = variant.product || {};
|
|
269
271
|
const currencyCode = ((_a = lineItem.discountedTotalPrice) === null || _a === void 0 ? void 0 : _a.currencyCode) ||
|
|
@@ -313,9 +315,9 @@ export const transformOrderDetails = (order) => {
|
|
|
313
315
|
discountApplication: allocation.discountApplication || {},
|
|
314
316
|
});
|
|
315
317
|
}),
|
|
316
|
-
quantity: lineItem.quantity
|
|
318
|
+
quantity: (_t = (_s = lineItem.currentQuantity) !== null && _s !== void 0 ? _s : lineItem.quantity) !== null && _t !== void 0 ? _t : 1,
|
|
317
319
|
title: lineItem.title || product.title,
|
|
318
|
-
id: ((
|
|
320
|
+
id: ((_u = variant.id) === null || _u === void 0 ? void 0 : _u.split("/").pop()) || ((_v = lineItem.variantId) === null || _v === void 0 ? void 0 : _v.split("/").pop()),
|
|
319
321
|
};
|
|
320
322
|
}),
|
|
321
323
|
totalPrice: wrapMoney(total, currencyCode),
|
|
@@ -100,8 +100,9 @@ interface UseSearchAnalyticsImpressionParams {
|
|
|
100
100
|
emitProductImpression?: (payload: EmitProductInteractionPayload) => void;
|
|
101
101
|
surface?: string;
|
|
102
102
|
/**
|
|
103
|
-
* Whether search-analytics is enabled (the
|
|
104
|
-
* flag). Required to gate setup:
|
|
103
|
+
* Whether search-analytics is enabled (the active provider's
|
|
104
|
+
* `search-analytics-<provider>` flag). Required to gate setup:
|
|
105
|
+
* `emitProductImpression` is a truthy no-op
|
|
105
106
|
* when the flag is off, so without this the IntersectionObserver would still
|
|
106
107
|
* be constructed per-card on every search-backed grid. Defaults on for
|
|
107
108
|
* backward compatibility with callers that don't pass it yet.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search-analytics-open-product.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-search-analytics-open-product.ts"],"names":[],"mappings":"AAIA,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;CACrD;AAED,UAAU,6BAA6B;IACrC,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,UAAU,mCAAmC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,sBAAsB,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;IAC3D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,6BAA6B,KAAK,IAAI,CAAA;IACnE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,6BAA6B,CAAC,EAC5C,QAAQ,EACR,YAAY,EACZ,gBAAgB,EACh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a7D"}
|
|
@@ -145,7 +145,7 @@ Carousel.displayName = "Carousel";
|
|
|
145
145
|
const CarouselContent = React.forwardRef((_a, ref) => {
|
|
146
146
|
var { className, showOverflow = false } = _a, props = __rest(_a, ["className", "showOverflow"]);
|
|
147
147
|
const { carouselRef, orientation } = useCarousel();
|
|
148
|
-
return (_jsx("div", Object.assign({ ref: carouselRef, className:
|
|
148
|
+
return (_jsx("div", Object.assign({ ref: carouselRef, className: `touch-pan-y ${showOverflow ? "overflow-visible" : "overflow-hidden"}` }, { children: _jsx("div", Object.assign({ ref: ref, className: cn("flex", orientation === "horizontal" ? "" : "-mt-4 flex-col", className) }, props)) })));
|
|
149
149
|
});
|
|
150
150
|
CarouselContent.displayName = "CarouselContent";
|
|
151
151
|
const CarouselItem = React.forwardRef((_a, ref) => {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "../lib/utils";
|
|
2
|
+
export { toHtml } from "../lib/to-html";
|
|
3
|
+
export { getData } from "../lib/get-data";
|
|
4
|
+
export type { DataSource } from "../lib/get-data";
|
|
5
|
+
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "../lib/utils";
|
|
6
|
+
export type { WishlistEntryMatch } from "../lib/utils";
|
|
7
|
+
export * from "../lib/cart.util";
|
|
8
|
+
export * from "../lib/discountAllocation.util";
|
|
9
|
+
export * from "../lib/variablesCart.util";
|
|
10
|
+
export * from "../lib/isTapcartVersion20.util";
|
|
11
|
+
export * from "../components/contexts/translation-context";
|
|
12
|
+
export * from "../components/hooks/use-collection";
|
|
13
|
+
export * from "../components/hooks/use-infinite-scroll";
|
|
14
|
+
export * from "../components/hooks/swr-retry";
|
|
15
|
+
export * from "../components/hooks/use-infinite-wishlist";
|
|
16
|
+
export * from "../components/hooks/use-recommendations";
|
|
17
|
+
export * from "../components/hooks/use-search-analytics-open-product";
|
|
18
|
+
export * from "../components/hooks/use-products";
|
|
19
|
+
export * from "../components/hooks/use-personalized-cluster-feed";
|
|
20
|
+
export * from "../components/hooks/use-order-details";
|
|
21
|
+
export * from "../components/hooks/use-scroll-direction";
|
|
22
|
+
export * from "../components/hooks/use-sort-filter";
|
|
23
|
+
export * from "../components/hooks/use-product-options";
|
|
24
|
+
export * from "../components/hooks/use-shop";
|
|
25
|
+
export * from "../components/hooks/use-mock-products";
|
|
26
|
+
export * from "../components/hooks/use-block-conditional-rendering";
|
|
27
|
+
export * from "../components/hooks/use-mock-cart";
|
|
28
|
+
export * from "../components/ui/accordion";
|
|
29
|
+
export * from "../components/ui/animate-container";
|
|
30
|
+
export * from "../components/ui/animate-number";
|
|
31
|
+
export * from "../components/ui/apple-pay-button";
|
|
32
|
+
export * from "../components/ui/aspect-ratio";
|
|
33
|
+
export * from "../components/ui/badge";
|
|
34
|
+
export * from "../components/core/button";
|
|
35
|
+
export * from "../components/ui/carousel";
|
|
36
|
+
export * from "../components/ui/checkbox";
|
|
37
|
+
export * from "../components/ui/chip";
|
|
38
|
+
export * from "../components/ui/color-swatch";
|
|
39
|
+
export * from "../components/ui/container";
|
|
40
|
+
export * from "../components/ui/drawer";
|
|
41
|
+
export * from "../components/ui/dropdown";
|
|
42
|
+
export * from "../components/ui/empty-message";
|
|
43
|
+
export * from "../components/ui/fallback-on-condition";
|
|
44
|
+
export * from "../components/ui/favorite";
|
|
45
|
+
export * from "../components/ui/fallback-on-condition";
|
|
46
|
+
export * from "../components/ui/grid";
|
|
47
|
+
export * from "../components/ui/virtual-grid";
|
|
48
|
+
export * from "../components/ui/icon";
|
|
49
|
+
export * from "../components/ui/image";
|
|
50
|
+
export * from "../components/ui/Input/input";
|
|
51
|
+
export * from "../components/ui/label";
|
|
52
|
+
export * from "../components/ui/line-item-text-icons";
|
|
53
|
+
export * from "../components/ui/loading-dots";
|
|
54
|
+
export * from "../components/ui/loading-spinner";
|
|
55
|
+
export * from "../components/ui/money";
|
|
56
|
+
export * from "../components/ui/portal";
|
|
57
|
+
export * from "../components/ui/price";
|
|
58
|
+
export * from "../components/ui/product-card";
|
|
59
|
+
export * from "../components/ui/quantity-picker";
|
|
60
|
+
export * from "../components/ui/quantity-pickerNEW";
|
|
61
|
+
export * from "../components/ui/progress-bar";
|
|
62
|
+
export * from "../components/ui/radio-group";
|
|
63
|
+
export * from "../components/ui/scroll-area";
|
|
64
|
+
export * from "../components/ui/selectors";
|
|
65
|
+
export * from "../components/ui/separator";
|
|
66
|
+
export * from "../components/ui/skeleton";
|
|
67
|
+
export * from "../components/ui/slider";
|
|
68
|
+
export * from "../components/ui/star-rating";
|
|
69
|
+
export * from "../components/ui/subscription";
|
|
70
|
+
export * from "../components/ui/switch";
|
|
71
|
+
export * from "../components/ui/tabs";
|
|
72
|
+
export * from "../components/core/text";
|
|
73
|
+
export * from "../components/ui/textarea";
|
|
74
|
+
export * from "../components/ui/toast";
|
|
75
|
+
export * from "../components/ui/toaster";
|
|
76
|
+
export * from "../components/ui/toggle-group";
|
|
77
|
+
export * from "../components/ui/toggle";
|
|
78
|
+
export * from "../components/ui/use-toast";
|
|
79
|
+
export * from "../components/ui/video";
|
|
80
|
+
export * from "../components/ui/video-enhanced";
|
|
81
|
+
export * from "../components/ui/wishlist";
|
|
82
|
+
export * from "../components/ui/wishlist-select";
|
|
83
|
+
export * from "../components/core/html";
|
|
84
|
+
export * from "../components/hooks/use-shop";
|
|
85
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
86
|
+
export * from "../components/hooks/use-reviews";
|
|
87
|
+
export * from "../components/hooks/use-style-parent";
|
|
88
|
+
export * from "../components/ui/subcollection-tabs";
|
|
89
|
+
export * from "../components/ui/ProductCard/utils";
|
|
90
|
+
export * from "../lib/price";
|
|
91
|
+
export * from "../components/hooks/use-nosto-recommendation";
|
|
92
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
93
|
+
export * from "../components/ui/tap";
|
|
94
|
+
export * from "../components/ui/circular-progress";
|
|
95
|
+
export * from "../components/ui/swipeable-list-item";
|
|
96
|
+
export * from "../components/ui/dialog";
|
|
97
|
+
export * from "../components/ui/input-otp";
|
|
98
|
+
export { default as ProductsLocalStorage } from "../components/libs/cache/ProductsLocalStorage";
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../core/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,QAAQ,GACT,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACd,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,4BAA4B,EAC5B,OAAO,EACP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oC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,8CAA8C,CAAA;AAC5D,cAAc,mDAAmD,CAAA;AACjE,cAAc,sBAAsB,CAAA;AACpC,cAAc,oCAAoC,CAAA;AAClD,cAAc,sCAAsC,CAAA;AACpD,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+CAA+C,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// component exports
|
|
2
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "../lib/utils";
|
|
3
|
+
export { toHtml } from "../lib/to-html";
|
|
4
|
+
export { getData } from "../lib/get-data";
|
|
5
|
+
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "../lib/utils";
|
|
6
|
+
export * from "../lib/cart.util";
|
|
7
|
+
export * from "../lib/discountAllocation.util";
|
|
8
|
+
export * from "../lib/variablesCart.util";
|
|
9
|
+
export * from "../lib/isTapcartVersion20.util";
|
|
10
|
+
export * from "../components/contexts/translation-context";
|
|
11
|
+
export * from "../components/hooks/use-collection";
|
|
12
|
+
export * from "../components/hooks/use-infinite-scroll";
|
|
13
|
+
export * from "../components/hooks/swr-retry";
|
|
14
|
+
export * from "../components/hooks/use-infinite-wishlist";
|
|
15
|
+
export * from "../components/hooks/use-recommendations";
|
|
16
|
+
export * from "../components/hooks/use-search-analytics-open-product";
|
|
17
|
+
export * from "../components/hooks/use-products";
|
|
18
|
+
export * from "../components/hooks/use-personalized-cluster-feed";
|
|
19
|
+
export * from "../components/hooks/use-order-details";
|
|
20
|
+
export * from "../components/hooks/use-scroll-direction";
|
|
21
|
+
export * from "../components/hooks/use-sort-filter";
|
|
22
|
+
export * from "../components/hooks/use-product-options";
|
|
23
|
+
export * from "../components/hooks/use-shop";
|
|
24
|
+
export * from "../components/hooks/use-mock-products";
|
|
25
|
+
export * from "../components/hooks/use-block-conditional-rendering";
|
|
26
|
+
export * from "../components/hooks/use-mock-cart";
|
|
27
|
+
export * from "../components/ui/accordion";
|
|
28
|
+
export * from "../components/ui/animate-container";
|
|
29
|
+
export * from "../components/ui/animate-number";
|
|
30
|
+
export * from "../components/ui/apple-pay-button";
|
|
31
|
+
export * from "../components/ui/aspect-ratio";
|
|
32
|
+
export * from "../components/ui/badge";
|
|
33
|
+
export * from "../components/core/button";
|
|
34
|
+
export * from "../components/ui/carousel";
|
|
35
|
+
export * from "../components/ui/checkbox";
|
|
36
|
+
export * from "../components/ui/chip";
|
|
37
|
+
export * from "../components/ui/color-swatch";
|
|
38
|
+
export * from "../components/ui/container";
|
|
39
|
+
export * from "../components/ui/drawer";
|
|
40
|
+
export * from "../components/ui/dropdown";
|
|
41
|
+
export * from "../components/ui/empty-message";
|
|
42
|
+
export * from "../components/ui/fallback-on-condition";
|
|
43
|
+
export * from "../components/ui/favorite";
|
|
44
|
+
export * from "../components/ui/fallback-on-condition";
|
|
45
|
+
export * from "../components/ui/grid";
|
|
46
|
+
export * from "../components/ui/virtual-grid";
|
|
47
|
+
export * from "../components/ui/icon";
|
|
48
|
+
export * from "../components/ui/image";
|
|
49
|
+
export * from "../components/ui/Input/input";
|
|
50
|
+
export * from "../components/ui/label";
|
|
51
|
+
export * from "../components/ui/line-item-text-icons";
|
|
52
|
+
export * from "../components/ui/loading-dots";
|
|
53
|
+
export * from "../components/ui/loading-spinner";
|
|
54
|
+
export * from "../components/ui/money";
|
|
55
|
+
export * from "../components/ui/portal";
|
|
56
|
+
export * from "../components/ui/price";
|
|
57
|
+
export * from "../components/ui/product-card";
|
|
58
|
+
export * from "../components/ui/quantity-picker";
|
|
59
|
+
// TODO: make this the default quantity picker after new CartLineItem component is released
|
|
60
|
+
export * from "../components/ui/quantity-pickerNEW";
|
|
61
|
+
export * from "../components/ui/progress-bar";
|
|
62
|
+
export * from "../components/ui/radio-group";
|
|
63
|
+
export * from "../components/ui/scroll-area";
|
|
64
|
+
export * from "../components/ui/selectors";
|
|
65
|
+
export * from "../components/ui/separator";
|
|
66
|
+
export * from "../components/ui/skeleton";
|
|
67
|
+
export * from "../components/ui/slider";
|
|
68
|
+
export * from "../components/ui/star-rating";
|
|
69
|
+
export * from "../components/ui/subscription";
|
|
70
|
+
export * from "../components/ui/switch";
|
|
71
|
+
export * from "../components/ui/tabs";
|
|
72
|
+
export * from "../components/core/text";
|
|
73
|
+
export * from "../components/ui/textarea";
|
|
74
|
+
export * from "../components/ui/toast";
|
|
75
|
+
export * from "../components/ui/toaster";
|
|
76
|
+
export * from "../components/ui/toggle-group";
|
|
77
|
+
export * from "../components/ui/toggle";
|
|
78
|
+
export * from "../components/ui/use-toast";
|
|
79
|
+
export * from "../components/ui/video";
|
|
80
|
+
export * from "../components/ui/video-enhanced";
|
|
81
|
+
export * from "../components/ui/wishlist";
|
|
82
|
+
export * from "../components/ui/wishlist-select";
|
|
83
|
+
export * from "../components/core/html";
|
|
84
|
+
export * from "../components/hooks/use-shop";
|
|
85
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
86
|
+
export * from "../components/hooks/use-reviews";
|
|
87
|
+
export * from "../components/hooks/use-style-parent";
|
|
88
|
+
export * from "../components/ui/subcollection-tabs";
|
|
89
|
+
export * from "../components/ui/ProductCard/utils";
|
|
90
|
+
export * from "../lib/price";
|
|
91
|
+
export * from "../components/hooks/use-nosto-recommendation";
|
|
92
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
93
|
+
export * from "../components/ui/tap";
|
|
94
|
+
export * from "../components/ui/circular-progress";
|
|
95
|
+
export * from "../components/ui/swipeable-list-item";
|
|
96
|
+
export * from "../components/ui/dialog";
|
|
97
|
+
export * from "../components/ui/input-otp";
|
|
98
|
+
export { default as ProductsLocalStorage } from "../components/libs/cache/ProductsLocalStorage";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor,
|
|
1
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "./lib/utils";
|
|
2
|
+
export { toHtml } from "./lib/to-html";
|
|
3
|
+
export { getData } from "./lib/get-data";
|
|
4
|
+
export type { DataSource } from "./lib/get-data";
|
|
5
|
+
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "./lib/utils";
|
|
2
6
|
export type { WishlistEntryMatch } from "./lib/utils";
|
|
3
7
|
export * from "./lib/cart.util";
|
|
4
8
|
export * from "./lib/discountAllocation.util";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACd,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,4BAA4B,EAC5B,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0BAA0B,CAAA;A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@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor,
|
|
2
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "./lib/utils";
|
|
3
|
+
export { toHtml } from "./lib/to-html";
|
|
4
|
+
export { getData } from "./lib/get-data";
|
|
5
|
+
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "./lib/utils";
|
|
3
6
|
export * from "./lib/cart.util";
|
|
4
7
|
export * from "./lib/discountAllocation.util";
|
|
5
8
|
export * from "./lib/variablesCart.util";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DataSource = {
|
|
2
|
+
source: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* getData — Universal content resolver for V2 blocks.
|
|
7
|
+
*
|
|
8
|
+
* Accepts either:
|
|
9
|
+
* - a static HTML string (typography `content: "text"`) → returned as-is
|
|
10
|
+
* - a DataSource `{ source, value }` (typography `content: "data"`, or a
|
|
11
|
+
* data-source field) → resolved against Tapcart variables
|
|
12
|
+
* - null/undefined (typography `content: "none"`, i.e. no `value`) → null
|
|
13
|
+
*
|
|
14
|
+
* This lets a block render every typography field identically, with no
|
|
15
|
+
* conditional branching on the `content` mode. `content: "none"` returns null
|
|
16
|
+
* (not "") so falsy guards work cleanly and no empty wrapper renders:
|
|
17
|
+
* {getData(variables, field?.value) && (
|
|
18
|
+
* <Html html={getData(variables, field?.value)} />
|
|
19
|
+
* )}
|
|
20
|
+
*
|
|
21
|
+
* Note: a *data-source* that resolves to nothing still returns "" (it was a
|
|
22
|
+
* real binding that came back empty), only an absent value returns null.
|
|
23
|
+
*
|
|
24
|
+
* Never throws — returns empty string on any error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getData(variables: Record<string, any> | undefined, data: DataSource | string | null | undefined): string | null;
|
|
27
|
+
//# sourceMappingURL=get-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data.d.ts","sourceRoot":"","sources":["../../lib/get-data.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EAC1C,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CAyCf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { toHtml } from "./to-html";
|
|
2
|
+
/**
|
|
3
|
+
* getData — Universal content resolver for V2 blocks.
|
|
4
|
+
*
|
|
5
|
+
* Accepts either:
|
|
6
|
+
* - a static HTML string (typography `content: "text"`) → returned as-is
|
|
7
|
+
* - a DataSource `{ source, value }` (typography `content: "data"`, or a
|
|
8
|
+
* data-source field) → resolved against Tapcart variables
|
|
9
|
+
* - null/undefined (typography `content: "none"`, i.e. no `value`) → null
|
|
10
|
+
*
|
|
11
|
+
* This lets a block render every typography field identically, with no
|
|
12
|
+
* conditional branching on the `content` mode. `content: "none"` returns null
|
|
13
|
+
* (not "") so falsy guards work cleanly and no empty wrapper renders:
|
|
14
|
+
* {getData(variables, field?.value) && (
|
|
15
|
+
* <Html html={getData(variables, field?.value)} />
|
|
16
|
+
* )}
|
|
17
|
+
*
|
|
18
|
+
* Note: a *data-source* that resolves to nothing still returns "" (it was a
|
|
19
|
+
* real binding that came back empty), only an absent value returns null.
|
|
20
|
+
*
|
|
21
|
+
* Never throws — returns empty string on any error.
|
|
22
|
+
*/
|
|
23
|
+
export function getData(variables, data) {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
try {
|
|
26
|
+
// No value (content: "none") — return null so falsy guards skip rendering.
|
|
27
|
+
if (data == null)
|
|
28
|
+
return null;
|
|
29
|
+
// Static rich-text (content: "text") — already HTML, pass through.
|
|
30
|
+
if (typeof data === "string")
|
|
31
|
+
return data;
|
|
32
|
+
if (!(data === null || data === void 0 ? void 0 : data.source) || !(data === null || data === void 0 ? void 0 : data.value))
|
|
33
|
+
return "";
|
|
34
|
+
if (data.source === "custom")
|
|
35
|
+
return data.value;
|
|
36
|
+
const obj = variables === null || variables === void 0 ? void 0 : variables[data.source];
|
|
37
|
+
if (!obj)
|
|
38
|
+
return "";
|
|
39
|
+
if (data.value.startsWith("metafields.")) {
|
|
40
|
+
const parts = data.value.split(".");
|
|
41
|
+
if (parts.length === 3) {
|
|
42
|
+
return toHtml(((_b = (_a = obj.metafields) === null || _a === void 0 ? void 0 : _a[parts[1]]) === null || _b === void 0 ? void 0 : _b[parts[2]]) || "");
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
const field = data.value;
|
|
47
|
+
if (field === "description")
|
|
48
|
+
return obj.descriptionHtml || obj.description || "";
|
|
49
|
+
if (field === "tags")
|
|
50
|
+
return (obj.tags || []).join(", ");
|
|
51
|
+
// Handle nested paths like priceRange.minVariantPrice.amount
|
|
52
|
+
if (field.includes(".")) {
|
|
53
|
+
const val = field.split(".").reduce((o, k) => o === null || o === void 0 ? void 0 : o[k], obj);
|
|
54
|
+
if (Array.isArray(val))
|
|
55
|
+
return val.join(", ");
|
|
56
|
+
return String(val !== null && val !== void 0 ? val : "");
|
|
57
|
+
}
|
|
58
|
+
// Nullish coalescing (not ||) so legitimate 0 / false values survive
|
|
59
|
+
// instead of being flattened to an empty string.
|
|
60
|
+
return String((_c = obj[field]) !== null && _c !== void 0 ? _c : "");
|
|
61
|
+
}
|
|
62
|
+
catch (_d) {
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data.test.d.ts","sourceRoot":"","sources":["../../lib/get-data.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* eslint-env jest */
|
|
2
|
+
import { getData } from "./get-data";
|
|
3
|
+
describe("getData", () => {
|
|
4
|
+
const variables = {
|
|
5
|
+
product: {
|
|
6
|
+
descriptionHtml: "<p>Hello</p>",
|
|
7
|
+
description: "Hello",
|
|
8
|
+
tags: ["new", "sale"],
|
|
9
|
+
title: "Cool Product",
|
|
10
|
+
totalInventory: 0,
|
|
11
|
+
availableForSale: false,
|
|
12
|
+
metafields: {
|
|
13
|
+
custom: { subtitle: "A subtitle" },
|
|
14
|
+
},
|
|
15
|
+
priceRange: {
|
|
16
|
+
minVariantPrice: { amount: "19.99" },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
describe("static rich-text (content: text)", () => {
|
|
21
|
+
it("returns a plain HTML string as-is", () => {
|
|
22
|
+
expect(getData(variables, "<p><strong>Hi</strong></p>")).toBe("<p><strong>Hi</strong></p>");
|
|
23
|
+
});
|
|
24
|
+
it("returns an empty string as-is", () => {
|
|
25
|
+
expect(getData(variables, "")).toBe("");
|
|
26
|
+
});
|
|
27
|
+
it("passes through even when variables is undefined", () => {
|
|
28
|
+
expect(getData(undefined, "<p>Static</p>")).toBe("<p>Static</p>");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("no value (content: none)", () => {
|
|
32
|
+
it("returns null for null (falsy-guard friendly)", () => {
|
|
33
|
+
expect(getData(variables, null)).toBeNull();
|
|
34
|
+
});
|
|
35
|
+
it("returns null for undefined", () => {
|
|
36
|
+
expect(getData(variables, undefined)).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
it("returns empty string (not null) for a real data-source that came back empty", () => {
|
|
39
|
+
expect(getData(variables, { source: "", value: "" })).toBe("");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe("data-source (content: data)", () => {
|
|
43
|
+
it("returns custom value as-is", () => {
|
|
44
|
+
expect(getData(variables, { source: "custom", value: "<p>x</p>" })).toBe("<p>x</p>");
|
|
45
|
+
});
|
|
46
|
+
it("resolves description", () => {
|
|
47
|
+
expect(getData(variables, { source: "product", value: "description" })).toBe("<p>Hello</p>");
|
|
48
|
+
});
|
|
49
|
+
it("resolves tags joined", () => {
|
|
50
|
+
expect(getData(variables, { source: "product", value: "tags" })).toBe("new, sale");
|
|
51
|
+
});
|
|
52
|
+
it("resolves a metafield", () => {
|
|
53
|
+
expect(getData(variables, {
|
|
54
|
+
source: "product",
|
|
55
|
+
value: "metafields.custom.subtitle",
|
|
56
|
+
})).toBe("<p>A subtitle</p>");
|
|
57
|
+
});
|
|
58
|
+
it("resolves a nested path", () => {
|
|
59
|
+
expect(getData(variables, {
|
|
60
|
+
source: "product",
|
|
61
|
+
value: "priceRange.minVariantPrice.amount",
|
|
62
|
+
})).toBe("19.99");
|
|
63
|
+
});
|
|
64
|
+
it("returns empty string when source object is missing", () => {
|
|
65
|
+
expect(getData(variables, { source: "customer", value: "firstName" })).toBe("");
|
|
66
|
+
});
|
|
67
|
+
it("preserves a numeric zero (not flattened to empty string)", () => {
|
|
68
|
+
expect(getData(variables, { source: "product", value: "totalInventory" })).toBe("0");
|
|
69
|
+
});
|
|
70
|
+
it("preserves a boolean false (not flattened to empty string)", () => {
|
|
71
|
+
expect(getData(variables, { source: "product", value: "availableForSale" })).toBe("false");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toHtml — Universal content-to-HTML converter.
|
|
3
|
+
*
|
|
4
|
+
* Accepts any string: Shopify rich text JSON, plain HTML, or plain text.
|
|
5
|
+
* Always returns safe HTML ready for the Html component.
|
|
6
|
+
* Never throws — returns empty string on any error.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toHtml(content: any): string;
|
|
9
|
+
//# sourceMappingURL=to-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-html.d.ts","sourceRoot":"","sources":["../../lib/to-html.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2EH,wBAAgB,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAkB3C"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toHtml — Universal content-to-HTML converter.
|
|
3
|
+
*
|
|
4
|
+
* Accepts any string: Shopify rich text JSON, plain HTML, or plain text.
|
|
5
|
+
* Always returns safe HTML ready for the Html component.
|
|
6
|
+
* Never throws — returns empty string on any error.
|
|
7
|
+
*/
|
|
8
|
+
function escHtml(s) {
|
|
9
|
+
return String(s)
|
|
10
|
+
.replace(/&/g, "&")
|
|
11
|
+
.replace(/</g, "<")
|
|
12
|
+
.replace(/>/g, ">")
|
|
13
|
+
.replace(/"/g, """);
|
|
14
|
+
}
|
|
15
|
+
function convertInline(node) {
|
|
16
|
+
try {
|
|
17
|
+
if (!(node === null || node === void 0 ? void 0 : node.type))
|
|
18
|
+
return "";
|
|
19
|
+
if (node.type === "text") {
|
|
20
|
+
let t = escHtml(node.value || "");
|
|
21
|
+
if (node.bold)
|
|
22
|
+
t = `<strong>${t}</strong>`;
|
|
23
|
+
if (node.italic)
|
|
24
|
+
t = `<em>${t}</em>`;
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
if (node.type === "link") {
|
|
28
|
+
const href = escHtml(node.url || "");
|
|
29
|
+
const children = (node.children || []).map(convertInline).join("");
|
|
30
|
+
return `<a href="${href}">${children}</a>`;
|
|
31
|
+
}
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function convertNode(node) {
|
|
39
|
+
try {
|
|
40
|
+
if (!(node === null || node === void 0 ? void 0 : node.type))
|
|
41
|
+
return "";
|
|
42
|
+
switch (node.type) {
|
|
43
|
+
case "paragraph":
|
|
44
|
+
return `<p>${(node.children || []).map(convertInline).join("")}</p>`;
|
|
45
|
+
case "list": {
|
|
46
|
+
const tag = node.listType === "ordered" ? "ol" : "ul";
|
|
47
|
+
const items = (node.children || [])
|
|
48
|
+
.filter((c) => c.type === "list-item")
|
|
49
|
+
.map((item) => `<li>${(item.children || []).map(convertInline).join("")}</li>`)
|
|
50
|
+
.join("");
|
|
51
|
+
return `<${tag}>${items}</${tag}>`;
|
|
52
|
+
}
|
|
53
|
+
case "heading": {
|
|
54
|
+
const lvl = Math.min(Math.max(node.level || 1, 1), 6);
|
|
55
|
+
return `<h${lvl}>${(node.children || [])
|
|
56
|
+
.map(convertInline)
|
|
57
|
+
.join("")}</h${lvl}>`;
|
|
58
|
+
}
|
|
59
|
+
default:
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (_a) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function parseShopifyRichText(text) {
|
|
68
|
+
try {
|
|
69
|
+
const obj = JSON.parse(text);
|
|
70
|
+
if (!obj || obj.type !== "root" || !Array.isArray(obj.children))
|
|
71
|
+
return null;
|
|
72
|
+
return obj.children.map(convertNode).join("");
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function isHtml(text) {
|
|
79
|
+
return /<[a-z][\s\S]*>/i.test(text);
|
|
80
|
+
}
|
|
81
|
+
export function toHtml(content) {
|
|
82
|
+
try {
|
|
83
|
+
if (content == null)
|
|
84
|
+
return "";
|
|
85
|
+
if (typeof content !== "string")
|
|
86
|
+
return "";
|
|
87
|
+
if (content.trim() === "")
|
|
88
|
+
return "";
|
|
89
|
+
// Try Shopify rich text JSON first
|
|
90
|
+
const richText = parseShopifyRichText(content);
|
|
91
|
+
if (richText !== null)
|
|
92
|
+
return richText;
|
|
93
|
+
// Already HTML, pass through
|
|
94
|
+
if (isHtml(content))
|
|
95
|
+
return content;
|
|
96
|
+
// Plain text, wrap in paragraph
|
|
97
|
+
return `<p>${escHtml(content)}</p>`;
|
|
98
|
+
}
|
|
99
|
+
catch (_a) {
|
|
100
|
+
return "";
|
|
101
|
+
}
|
|
102
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -1219,6 +1219,9 @@ video {
|
|
|
1219
1219
|
.h-\[80vh\] {
|
|
1220
1220
|
height: 80vh;
|
|
1221
1221
|
}
|
|
1222
|
+
.h-\[90vh\] {
|
|
1223
|
+
height: 90vh;
|
|
1224
|
+
}
|
|
1222
1225
|
.h-auto {
|
|
1223
1226
|
height: auto;
|
|
1224
1227
|
}
|
|
@@ -2914,6 +2917,9 @@ video {
|
|
|
2914
2917
|
.opacity-100 {
|
|
2915
2918
|
opacity: 1;
|
|
2916
2919
|
}
|
|
2920
|
+
.opacity-25 {
|
|
2921
|
+
opacity: 0.25;
|
|
2922
|
+
}
|
|
2917
2923
|
.opacity-50 {
|
|
2918
2924
|
opacity: 0.5;
|
|
2919
2925
|
}
|
|
@@ -2923,6 +2929,9 @@ video {
|
|
|
2923
2929
|
.opacity-70 {
|
|
2924
2930
|
opacity: 0.7;
|
|
2925
2931
|
}
|
|
2932
|
+
.opacity-75 {
|
|
2933
|
+
opacity: 0.75;
|
|
2934
|
+
}
|
|
2926
2935
|
.opacity-\[0\.42\] {
|
|
2927
2936
|
opacity: 0.42;
|
|
2928
2937
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-order-details.test.d.ts","sourceRoot":"","sources":["../../tests/use-order-details.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { transformOrderDetails } from "../components/hooks/use-order-details";
|
|
2
|
+
// jsdom does not implement crypto.randomUUID, which transformOrderDetails
|
|
3
|
+
// uses for line uniqueIds
|
|
4
|
+
beforeAll(() => {
|
|
5
|
+
if (typeof crypto.randomUUID !== "function") {
|
|
6
|
+
Object.defineProperty(crypto, "randomUUID", {
|
|
7
|
+
configurable: true,
|
|
8
|
+
value: () => `00000000-0000-4000-8000-${`${Math.random()}`
|
|
9
|
+
.slice(2, 14)
|
|
10
|
+
.padEnd(12, "0")}`,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const buildLineItem = (overrides = {}) => (Object.assign({ title: "Pink Palm Pajamas", quantity: 1, variant: {
|
|
15
|
+
id: "gid://shopify/ProductVariant/111",
|
|
16
|
+
title: "Blush Bay / XS",
|
|
17
|
+
price: { amount: "95.23", currencyCode: "USD" },
|
|
18
|
+
product: {
|
|
19
|
+
id: "gid://shopify/Product/11",
|
|
20
|
+
title: "Pink Palm Pajamas",
|
|
21
|
+
vendor: "Pink Palm Puff",
|
|
22
|
+
},
|
|
23
|
+
}, discountedTotalPrice: { amount: "95.23", currencyCode: "USD" }, originalTotalPrice: { amount: "95.23", currencyCode: "USD" } }, overrides));
|
|
24
|
+
const buildOrder = (lineItems) => ({
|
|
25
|
+
id: "gid://shopify/Order/92625831",
|
|
26
|
+
currency: "USD",
|
|
27
|
+
totalAmount: "95.23",
|
|
28
|
+
lineItems,
|
|
29
|
+
});
|
|
30
|
+
describe("transformOrderDetails — Shopify Order Editing (currentQuantity)", () => {
|
|
31
|
+
it("prefers currentQuantity over quantity for edited orders", () => {
|
|
32
|
+
const { orderDetails, checkoutData } = transformOrderDetails(buildOrder([buildLineItem({ quantity: 3, currentQuantity: 2 })]));
|
|
33
|
+
expect(orderDetails.cart.lines).toHaveLength(1);
|
|
34
|
+
expect(orderDetails.cart.lines[0].quantity).toBe(2);
|
|
35
|
+
expect(checkoutData.lineItems[0].quantity).toBe(2);
|
|
36
|
+
});
|
|
37
|
+
it("excludes line items removed via order editing (currentQuantity 0)", () => {
|
|
38
|
+
const { orderDetails, checkoutData } = transformOrderDetails(buildOrder([
|
|
39
|
+
buildLineItem({
|
|
40
|
+
title: "Pink Palm Pajamas",
|
|
41
|
+
quantity: 1,
|
|
42
|
+
currentQuantity: 1,
|
|
43
|
+
}),
|
|
44
|
+
buildLineItem({
|
|
45
|
+
title: "Live in the Moment Hoodie",
|
|
46
|
+
quantity: 1,
|
|
47
|
+
currentQuantity: 0,
|
|
48
|
+
}),
|
|
49
|
+
]));
|
|
50
|
+
expect(orderDetails.cart.lines).toHaveLength(1);
|
|
51
|
+
expect(orderDetails.cart.lines[0].title).toBe("Pink Palm Pajamas");
|
|
52
|
+
expect(checkoutData.lineItems).toHaveLength(1);
|
|
53
|
+
expect(checkoutData.lineItems[0].title).toBe("Pink Palm Pajamas");
|
|
54
|
+
});
|
|
55
|
+
it("falls back to quantity when currentQuantity is absent (unedited orders)", () => {
|
|
56
|
+
const { orderDetails } = transformOrderDetails(buildOrder([buildLineItem({ quantity: 2 })]));
|
|
57
|
+
expect(orderDetails.cart.lines).toHaveLength(1);
|
|
58
|
+
expect(orderDetails.cart.lines[0].quantity).toBe(2);
|
|
59
|
+
});
|
|
60
|
+
it("defaults quantity to 1 when neither field is present", () => {
|
|
61
|
+
const { orderDetails } = transformOrderDetails(buildOrder([buildLineItem({ quantity: undefined })]));
|
|
62
|
+
expect(orderDetails.cart.lines).toHaveLength(1);
|
|
63
|
+
expect(orderDetails.cart.lines[0].quantity).toBe(1);
|
|
64
|
+
});
|
|
65
|
+
});
|