@tapcart/mobile-components 0.7.8 → 0.7.10-beta.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/ui/drawer.d.ts +8 -2
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +22 -11
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +4 -1
- package/dist/tests/utils.test.d.ts +2 -0
- package/dist/tests/utils.test.d.ts.map +1 -0
- package/dist/tests/utils.test.js +34 -0
- package/package.json +7 -2
|
@@ -5,27 +5,33 @@ type DrawerTriggerProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
|
5
5
|
};
|
|
6
6
|
type DrawerPortalProps = {
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
containerRef?: HTMLElement;
|
|
8
9
|
};
|
|
9
10
|
type DrawerCloseProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
10
11
|
asChild?: boolean;
|
|
11
12
|
};
|
|
12
13
|
declare const DrawerTrigger: React.FC<DrawerTriggerProps>;
|
|
13
|
-
declare const DrawerPortal:
|
|
14
|
+
declare const DrawerPortal: {
|
|
15
|
+
({ children, containerRef }: DrawerPortalProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
14
18
|
declare const DrawerClose: React.FC<DrawerCloseProps>;
|
|
15
19
|
type DrawerProps = React.ComponentProps<typeof DrawerPrimitive.Root> & {
|
|
16
20
|
containerRef?: HTMLElement;
|
|
17
21
|
};
|
|
18
22
|
declare const Drawer: {
|
|
19
|
-
({ shouldScaleBackground, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
({ shouldScaleBackground, containerRef, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
20
24
|
displayName: string;
|
|
21
25
|
};
|
|
22
26
|
declare const DrawerOverlay: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
23
27
|
backdropHexColor?: string | undefined;
|
|
28
|
+
containerRef?: HTMLElement | undefined;
|
|
24
29
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
30
|
declare const DrawerContentBase: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
26
31
|
hideBackdrop?: boolean | undefined;
|
|
27
32
|
backdropHexColor?: string | undefined;
|
|
28
33
|
isSheet?: boolean | undefined;
|
|
34
|
+
containerRef?: HTMLElement | undefined;
|
|
29
35
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
30
36
|
declare const DrawerFooter: {
|
|
31
37
|
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../components/ui/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../components/ui/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,MAAM,CAAA;AAKhD,KAAK,kBAAkB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,KAAK,gBAAgB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,QAAA,MAAM,aAAa,8BAA0D,CAAA;AAG7E,QAAA,MAAM,YAAY;iCAAgC,iBAAiB;;CAKlE,CAAA;AAGD,QAAA,MAAM,WAAW,4BAAsD,CAAA;AAGvE,KAAK,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG;IACrE,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,QAAA,MAAM,MAAM;wDAIT,WAAW;;CAgBb,CAAA;AAQD,QAAA,MAAM,aAAa;;;wCAsBlB,CAAA;AAUD,QAAA,MAAM,iBAAiB;;;;;wCAiDtB,CAAA;AA0BD,QAAA,MAAM,YAAY;8BAGf,MAAM,cAAc,CAAC,cAAc,CAAC;;CAQtC,CAAA;AAGD,QAAA,MAAM,iBAAiB,qLASrB,CAAA;AAGF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;CACjD,CAAA;AAED,QAAA,MAAM,YAAY,0DAKf,iBAAiB,4CA8BnB,CAAA;AAED,QAAA,MAAM,aAAa,sCAIhB,MAAM,cAAc,CAAC,cAAc,CAAC,4CAMtC,CAAA;AAED,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,CAAA"}
|
|
@@ -15,29 +15,40 @@ import * as React from "react";
|
|
|
15
15
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
16
16
|
import { cn } from "../../lib/utils";
|
|
17
17
|
import { Icon } from "./icon";
|
|
18
|
+
import ReactDOM from "react-dom";
|
|
18
19
|
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
19
20
|
DrawerTrigger.displayName = "DrawerTrigger";
|
|
20
|
-
const DrawerPortal =
|
|
21
|
+
const DrawerPortal = ({ children, containerRef }) => {
|
|
22
|
+
if (containerRef) {
|
|
23
|
+
return ReactDOM.createPortal(children, containerRef);
|
|
24
|
+
}
|
|
25
|
+
return _jsx(DrawerPrimitive.Portal, { children: children });
|
|
26
|
+
};
|
|
21
27
|
DrawerPortal.displayName = "DrawerPortal";
|
|
22
28
|
const DrawerClose = DrawerPrimitive.Close;
|
|
23
29
|
DrawerClose.displayName = "DrawerClose";
|
|
24
30
|
const Drawer = (_a) => {
|
|
25
|
-
var { shouldScaleBackground } = _a, props = __rest(_a, ["shouldScaleBackground"]);
|
|
26
|
-
return (_jsx(DrawerPrimitive.Root, Object.assign({ shouldScaleBackground: true }, props, { noBodyStyles: true, disablePreventScroll: true })
|
|
31
|
+
var { shouldScaleBackground, containerRef } = _a, props = __rest(_a, ["shouldScaleBackground", "containerRef"]);
|
|
32
|
+
return (_jsx(DrawerPrimitive.Root, Object.assign({ shouldScaleBackground: true }, props, { noBodyStyles: true, disablePreventScroll: true }, { children: React.Children.map(props.children, (child) => {
|
|
33
|
+
if (React.isValidElement(child)) {
|
|
34
|
+
return React.cloneElement(child, { containerRef });
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
37
|
+
}) })));
|
|
27
38
|
};
|
|
28
39
|
Drawer.displayName = "Drawer";
|
|
29
40
|
const DrawerOverlay = React.forwardRef((_a, ref) => {
|
|
30
|
-
var { className, backdropHexColor = "#000000" } = _a, props = __rest(_a, ["className", "backdropHexColor"]);
|
|
31
|
-
const style = { backgroundColor: `${backdropHexColor}CC` };
|
|
32
|
-
return (_jsx(DrawerPrimitive.Overlay, Object.assign({ style: style, ref: ref, className: cn(`fixed inset-0 z-50`, className) }, props)));
|
|
41
|
+
var { className, backdropHexColor = "#000000", containerRef } = _a, props = __rest(_a, ["className", "backdropHexColor", "containerRef"]);
|
|
42
|
+
const style = Object.assign({ backgroundColor: `${backdropHexColor}CC` }, (containerRef && { position: "absolute" }));
|
|
43
|
+
return (_jsx(DrawerPrimitive.Overlay, Object.assign({ style: style, ref: ref, className: cn(`fixed inset-0 z-50`, containerRef && "absolute", className) }, props)));
|
|
33
44
|
});
|
|
34
45
|
DrawerOverlay.displayName = "DrawerOverlay";
|
|
35
46
|
const DrawerContentBase = React.forwardRef((_a, ref) => {
|
|
36
|
-
var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false,
|
|
37
|
-
const styles = isSheet
|
|
47
|
+
var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false, containerRef } = _a, props = __rest(_a, ["className", "children", "hideBackdrop", "backdropHexColor", "isSheet", "containerRef"]);
|
|
48
|
+
const styles = Object.assign(Object.assign({}, (isSheet
|
|
38
49
|
? { height: "calc(100vh - 112px)" }
|
|
39
|
-
: { maxHeight: "calc(100vh - 112px)" };
|
|
40
|
-
return (_jsxs(DrawerPortal, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: styles, className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] }));
|
|
50
|
+
: { maxHeight: "calc(100vh - 112px)" })), (containerRef && { position: "absolute" }));
|
|
51
|
+
return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor, containerRef: containerRef })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: styles, className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", containerRef && "absolute", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
|
|
41
52
|
});
|
|
42
53
|
DrawerContentBase.displayName = "DrawerContentBase";
|
|
43
54
|
const DrawerHeaderBase = (_a) => {
|
|
@@ -65,6 +76,6 @@ const DrawerHeader = ({ title, iconLeftName, iconRightName, onCloseClick, }) =>
|
|
|
65
76
|
};
|
|
66
77
|
const DrawerContent = (_a) => {
|
|
67
78
|
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
68
|
-
return _jsx("div", Object.assign({ className: cn("h-full overflow-scroll", className) }, props, { children: children }));
|
|
79
|
+
return (_jsx("div", Object.assign({ className: cn("h-full overflow-scroll", className) }, props, { children: children })));
|
|
69
80
|
};
|
|
70
81
|
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContentBase, DrawerContent, DrawerFooter, DrawerDescription, DrawerHeader, };
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAKvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAI9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAUtD,CAAA;AAED,KAAK,UAAU,GAAG,KAAK,GAA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AM,WAAW,kBAAkB,yBAO/B,MAAM,WAAW,kBAAkB,yBAEhC,MAAM,WAAW,kBAAkB,yBAS3D,CAAA;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,YAOlD;AAED,eAAO,MAAM,wBAAwB,gBACtB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,2BAQpE,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -193,7 +193,10 @@ export const getOverlayStyle = (opacity) => {
|
|
|
193
193
|
const DESTINATION_HANDLERS = {
|
|
194
194
|
"app-screen": (location, actions) => actions.openScreen({ destination: { type: "internal", url: location } }),
|
|
195
195
|
url: (location, actions) => actions.openScreen({
|
|
196
|
-
destination: {
|
|
196
|
+
destination: {
|
|
197
|
+
type: "web",
|
|
198
|
+
url: location.includes("https://") ? location : `https://${location}`,
|
|
199
|
+
},
|
|
197
200
|
}),
|
|
198
201
|
product: (location, actions) => actions.openProduct({ productId: location }),
|
|
199
202
|
collection: (location, actions) => actions.openCollection({ collectionId: location }),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../tests/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getDestinationHandler } from "../lib/utils";
|
|
2
|
+
describe("DESTINATION_HANDLERS", () => {
|
|
3
|
+
describe("url handler", () => {
|
|
4
|
+
const mockActions = {
|
|
5
|
+
openScreen: jest.fn(),
|
|
6
|
+
openProduct: jest.fn(),
|
|
7
|
+
openCollection: jest.fn(),
|
|
8
|
+
};
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
it("should prepend https:// when URL does not include it", () => {
|
|
13
|
+
const urlHandler = getDestinationHandler("url");
|
|
14
|
+
urlHandler("example.com", mockActions);
|
|
15
|
+
expect(mockActions.openScreen).toHaveBeenCalledWith({
|
|
16
|
+
destination: { type: "web", url: "https://example.com" },
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it("should not modify URL when it already includes https://", () => {
|
|
20
|
+
const urlHandler = getDestinationHandler("url");
|
|
21
|
+
urlHandler("https://example.com", mockActions);
|
|
22
|
+
expect(mockActions.openScreen).toHaveBeenCalledWith({
|
|
23
|
+
destination: { type: "web", url: "https://example.com" },
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it("should not modify URL when it includes http://", () => {
|
|
27
|
+
const urlHandler = getDestinationHandler("url");
|
|
28
|
+
urlHandler("http://example.com", mockActions);
|
|
29
|
+
expect(mockActions.openScreen).toHaveBeenCalledWith({
|
|
30
|
+
destination: { type: "web", url: "https://http://example.com" },
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -19,13 +19,16 @@
|
|
|
19
19
|
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
20
20
|
"dev:ts": "tsc -w -p tsconfig.json",
|
|
21
21
|
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
22
|
-
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\""
|
|
22
|
+
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"test:watch": "jest --watch"
|
|
23
25
|
},
|
|
24
26
|
"peerDependencies": {
|
|
25
27
|
"react": "^17.0.2 || ^18.0.0",
|
|
26
28
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
31
|
+
"@types/jest": "^29.5.14",
|
|
29
32
|
"@types/lodash": "4.17.5",
|
|
30
33
|
"@types/react": "^18.2.0",
|
|
31
34
|
"@types/react-dom": "^18.2.0",
|
|
@@ -35,8 +38,10 @@
|
|
|
35
38
|
"concurrently": "^8.2.2",
|
|
36
39
|
"eslint": "^7.32.0",
|
|
37
40
|
"eslint-config-custom": "workspace:*",
|
|
41
|
+
"jest": "^29.7.0",
|
|
38
42
|
"postcss": "^8.4.24",
|
|
39
43
|
"tailwindcss": "^3.3.2",
|
|
44
|
+
"ts-jest": "^29.2.5",
|
|
40
45
|
"tsc-alias": "^1.8.10",
|
|
41
46
|
"tsconfig": "workspace:*",
|
|
42
47
|
"typescript": "^4.5.2"
|