@better-zap/react 0.2.0 → 0.2.2
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/bubble.cjs +93 -0
- package/dist/bubble.d.cts +61 -0
- package/dist/bubble.d.mts +61 -0
- package/dist/bubble.mjs +89 -0
- package/dist/composer.cjs +220 -0
- package/dist/composer.d.cts +96 -0
- package/dist/composer.d.mts +96 -0
- package/dist/composer.mjs +211 -0
- package/dist/conversation-list-BlhJhDsc.d.cts +100 -0
- package/dist/conversation-list-BwQ4oK2J.d.mts +100 -0
- package/dist/conversation-list-C0EmReS-.mjs +293 -0
- package/dist/conversation-list-CVWdddJh.cjs +311 -0
- package/dist/conversation-list.cjs +6 -0
- package/dist/conversation-list.d.cts +2 -0
- package/dist/conversation-list.d.mts +2 -0
- package/dist/conversation-list.mjs +5 -0
- package/dist/index.cjs +49 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.mjs +11 -0
- package/dist/message-bubble.cjs +116 -0
- package/dist/message-bubble.d.cts +38 -0
- package/dist/message-bubble.d.mts +38 -0
- package/dist/message-bubble.mjs +114 -0
- package/dist/message-input-CkaL6fb4.mjs +173 -0
- package/dist/message-input-DcEzHQ9t.cjs +191 -0
- package/dist/message-input.cjs +6 -0
- package/dist/message-input.d.cts +51 -0
- package/dist/message-input.d.mts +51 -0
- package/dist/message-input.mjs +5 -0
- package/dist/message-view.cjs +273 -0
- package/dist/message-view.d.cts +109 -0
- package/dist/message-view.d.mts +109 -0
- package/dist/message-view.mjs +266 -0
- package/dist/message.cjs +50 -0
- package/dist/message.d.cts +40 -0
- package/dist/message.d.mts +40 -0
- package/dist/message.mjs +43 -0
- package/dist/tailwind.css +33 -0
- package/dist/utils-Bp9IahGG.cjs +91 -0
- package/dist/utils.cjs +5 -0
- package/dist/utils.d.cts +20 -0
- package/dist/utils.d.mts +20 -0
- package/dist/utils.mjs +45 -0
- package/dist/whatsapp-dashboard.cjs +64 -0
- package/dist/whatsapp-dashboard.d.cts +33 -0
- package/dist/whatsapp-dashboard.d.mts +33 -0
- package/dist/whatsapp-dashboard.mjs +60 -0
- package/dist/wpp-bg.webp +0 -0
- package/package.json +1 -1
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ClassValue } from "clsx";
|
|
3
|
+
|
|
4
|
+
//#region src/utils.d.ts
|
|
5
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* Base UI-style element polymorphism: merge part props onto a render element.
|
|
8
|
+
* - className: cn(computed, render.props.className)
|
|
9
|
+
* - style: { ...computed.style, ...render.props.style }
|
|
10
|
+
* - other props: render element's own props win
|
|
11
|
+
* - children: part children win unless render element already has children
|
|
12
|
+
*/
|
|
13
|
+
declare function renderSlot(render: React.ReactElement<Record<string, unknown>>, computed: Record<string, unknown> & {
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}): React.ReactElement;
|
|
18
|
+
declare function getDisplayDate(dateStr: string): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { cn, getDisplayDate, renderSlot };
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ClassValue } from "clsx";
|
|
3
|
+
|
|
4
|
+
//#region src/utils.d.ts
|
|
5
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
6
|
+
/**
|
|
7
|
+
* Base UI-style element polymorphism: merge part props onto a render element.
|
|
8
|
+
* - className: cn(computed, render.props.className)
|
|
9
|
+
* - style: { ...computed.style, ...render.props.style }
|
|
10
|
+
* - other props: render element's own props win
|
|
11
|
+
* - children: part children win unless render element already has children
|
|
12
|
+
*/
|
|
13
|
+
declare function renderSlot(render: React.ReactElement<Record<string, unknown>>, computed: Record<string, unknown> & {
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}): React.ReactElement;
|
|
18
|
+
declare function getDisplayDate(dateStr: string): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { cn, getDisplayDate, renderSlot };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
function cn(...inputs) {
|
|
6
|
+
return twMerge(clsx(inputs));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Base UI-style element polymorphism: merge part props onto a render element.
|
|
10
|
+
* - className: cn(computed, render.props.className)
|
|
11
|
+
* - style: { ...computed.style, ...render.props.style }
|
|
12
|
+
* - other props: render element's own props win
|
|
13
|
+
* - children: part children win unless render element already has children
|
|
14
|
+
*/
|
|
15
|
+
function renderSlot(render, computed) {
|
|
16
|
+
const renderProps = render.props;
|
|
17
|
+
const merged = {
|
|
18
|
+
...computed,
|
|
19
|
+
...renderProps,
|
|
20
|
+
className: cn(computed.className, renderProps.className),
|
|
21
|
+
style: {
|
|
22
|
+
...computed.style ?? {},
|
|
23
|
+
...renderProps.style ?? {}
|
|
24
|
+
},
|
|
25
|
+
children: renderProps.children !== void 0 && renderProps.children !== null ? renderProps.children : computed.children
|
|
26
|
+
};
|
|
27
|
+
return React.cloneElement(render, merged);
|
|
28
|
+
}
|
|
29
|
+
function getDisplayDate(dateStr) {
|
|
30
|
+
const dateObj = new Date(dateStr);
|
|
31
|
+
const now = /* @__PURE__ */ new Date();
|
|
32
|
+
const isToday = dateObj.toDateString() === now.toDateString();
|
|
33
|
+
const yesterday = new Date(now);
|
|
34
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
35
|
+
const isYesterday = dateObj.toDateString() === yesterday.toDateString();
|
|
36
|
+
if (isToday) return "HOJE";
|
|
37
|
+
else if (isYesterday) return "ONTEM";
|
|
38
|
+
else return dateObj.toLocaleDateString("pt-BR", {
|
|
39
|
+
day: "2-digit",
|
|
40
|
+
month: "2-digit",
|
|
41
|
+
year: "numeric"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { cn, getDisplayDate, renderSlot };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_utils = require("./utils-Bp9IahGG.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_utils.__toESM(react);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/whatsapp-dashboard.tsx
|
|
8
|
+
const MOBILE_BREAKPOINT = 1024;
|
|
9
|
+
function useIsMobile(enabled = true) {
|
|
10
|
+
const [isMobile, setIsMobile] = (0, react.useState)(false);
|
|
11
|
+
(0, react.useEffect)(() => {
|
|
12
|
+
if (!enabled) return;
|
|
13
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
14
|
+
const onChange = (e) => {
|
|
15
|
+
setIsMobile(e.matches);
|
|
16
|
+
};
|
|
17
|
+
onChange(mql);
|
|
18
|
+
mql.addEventListener("change", onChange);
|
|
19
|
+
return () => mql.removeEventListener("change", onChange);
|
|
20
|
+
}, [enabled]);
|
|
21
|
+
return isMobile;
|
|
22
|
+
}
|
|
23
|
+
const WhatsappDashboardContext = (0, react.createContext)(null);
|
|
24
|
+
function useWhatsappDashboard() {
|
|
25
|
+
const ctx = (0, react.useContext)(WhatsappDashboardContext);
|
|
26
|
+
if (!ctx) throw new Error("useWhatsappDashboard must be used within <WhatsappDashboard>");
|
|
27
|
+
return ctx;
|
|
28
|
+
}
|
|
29
|
+
/** Returns the dashboard context, or null when rendered outside <WhatsappDashboard>. */
|
|
30
|
+
function useOptionalWhatsappDashboard() {
|
|
31
|
+
return (0, react.useContext)(WhatsappDashboardContext);
|
|
32
|
+
}
|
|
33
|
+
function WhatsappDashboard({ children, className, defaultMobileView = "list", mobileView: mobileViewProp, onMobileViewChange, isMobile: isMobileProp, ...props }) {
|
|
34
|
+
const detectedIsMobile = useIsMobile(isMobileProp === void 0);
|
|
35
|
+
const isMobile = isMobileProp ?? detectedIsMobile;
|
|
36
|
+
const [uncontrolledView, setUncontrolledView] = (0, react.useState)(defaultMobileView);
|
|
37
|
+
const isViewControlled = mobileViewProp !== void 0;
|
|
38
|
+
const mobileView = isViewControlled ? mobileViewProp : uncontrolledView;
|
|
39
|
+
const setMobileView = (0, react.useCallback)((view) => {
|
|
40
|
+
if (!isViewControlled) setUncontrolledView(view);
|
|
41
|
+
onMobileViewChange?.(view);
|
|
42
|
+
}, [isViewControlled, onMobileViewChange]);
|
|
43
|
+
const value = (0, react.useMemo)(() => ({
|
|
44
|
+
isMobile,
|
|
45
|
+
mobileView,
|
|
46
|
+
setMobileView
|
|
47
|
+
}), [
|
|
48
|
+
isMobile,
|
|
49
|
+
mobileView,
|
|
50
|
+
setMobileView
|
|
51
|
+
]);
|
|
52
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WhatsappDashboardContext.Provider, {
|
|
53
|
+
value,
|
|
54
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
55
|
+
className: require_utils.cn("flex h-full w-full overflow-hidden bg-[#f0f2f5]", className),
|
|
56
|
+
...props,
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.WhatsappDashboard = WhatsappDashboard;
|
|
63
|
+
exports.useOptionalWhatsappDashboard = useOptionalWhatsappDashboard;
|
|
64
|
+
exports.useWhatsappDashboard = useWhatsappDashboard;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/whatsapp-dashboard.d.ts
|
|
5
|
+
type MobileView = "list" | "chat";
|
|
6
|
+
interface WhatsappDashboardContextValue {
|
|
7
|
+
isMobile: boolean;
|
|
8
|
+
mobileView: MobileView;
|
|
9
|
+
setMobileView: (view: MobileView) => void;
|
|
10
|
+
}
|
|
11
|
+
declare function useWhatsappDashboard(): WhatsappDashboardContextValue;
|
|
12
|
+
/** Returns the dashboard context, or null when rendered outside <WhatsappDashboard>. */
|
|
13
|
+
declare function useOptionalWhatsappDashboard(): WhatsappDashboardContextValue | null;
|
|
14
|
+
interface WhatsappDashboardProps extends React.ComponentProps<"div"> {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
defaultMobileView?: MobileView;
|
|
17
|
+
/** Controlled mobile navigation view. When set, local state is not updated. */
|
|
18
|
+
mobileView?: MobileView;
|
|
19
|
+
onMobileViewChange?: (view: MobileView) => void;
|
|
20
|
+
/** Override media-query detection (e.g. app-owned responsive state). */
|
|
21
|
+
isMobile?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare function WhatsappDashboard({
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
defaultMobileView,
|
|
27
|
+
mobileView: mobileViewProp,
|
|
28
|
+
onMobileViewChange,
|
|
29
|
+
isMobile: isMobileProp,
|
|
30
|
+
...props
|
|
31
|
+
}: WhatsappDashboardProps): react_jsx_runtime0.JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { MobileView, WhatsappDashboard, WhatsappDashboardContextValue, WhatsappDashboardProps, useOptionalWhatsappDashboard, useWhatsappDashboard };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/whatsapp-dashboard.d.ts
|
|
5
|
+
type MobileView = "list" | "chat";
|
|
6
|
+
interface WhatsappDashboardContextValue {
|
|
7
|
+
isMobile: boolean;
|
|
8
|
+
mobileView: MobileView;
|
|
9
|
+
setMobileView: (view: MobileView) => void;
|
|
10
|
+
}
|
|
11
|
+
declare function useWhatsappDashboard(): WhatsappDashboardContextValue;
|
|
12
|
+
/** Returns the dashboard context, or null when rendered outside <WhatsappDashboard>. */
|
|
13
|
+
declare function useOptionalWhatsappDashboard(): WhatsappDashboardContextValue | null;
|
|
14
|
+
interface WhatsappDashboardProps extends React.ComponentProps<"div"> {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
defaultMobileView?: MobileView;
|
|
17
|
+
/** Controlled mobile navigation view. When set, local state is not updated. */
|
|
18
|
+
mobileView?: MobileView;
|
|
19
|
+
onMobileViewChange?: (view: MobileView) => void;
|
|
20
|
+
/** Override media-query detection (e.g. app-owned responsive state). */
|
|
21
|
+
isMobile?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare function WhatsappDashboard({
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
defaultMobileView,
|
|
27
|
+
mobileView: mobileViewProp,
|
|
28
|
+
onMobileViewChange,
|
|
29
|
+
isMobile: isMobileProp,
|
|
30
|
+
...props
|
|
31
|
+
}: WhatsappDashboardProps): react_jsx_runtime0.JSX.Element;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { MobileView, WhatsappDashboard, WhatsappDashboardContextValue, WhatsappDashboardProps, useOptionalWhatsappDashboard, useWhatsappDashboard };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./utils.mjs";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/whatsapp-dashboard.tsx
|
|
6
|
+
const MOBILE_BREAKPOINT = 1024;
|
|
7
|
+
function useIsMobile(enabled = true) {
|
|
8
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!enabled) return;
|
|
11
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
12
|
+
const onChange = (e) => {
|
|
13
|
+
setIsMobile(e.matches);
|
|
14
|
+
};
|
|
15
|
+
onChange(mql);
|
|
16
|
+
mql.addEventListener("change", onChange);
|
|
17
|
+
return () => mql.removeEventListener("change", onChange);
|
|
18
|
+
}, [enabled]);
|
|
19
|
+
return isMobile;
|
|
20
|
+
}
|
|
21
|
+
const WhatsappDashboardContext = createContext(null);
|
|
22
|
+
function useWhatsappDashboard() {
|
|
23
|
+
const ctx = useContext(WhatsappDashboardContext);
|
|
24
|
+
if (!ctx) throw new Error("useWhatsappDashboard must be used within <WhatsappDashboard>");
|
|
25
|
+
return ctx;
|
|
26
|
+
}
|
|
27
|
+
/** Returns the dashboard context, or null when rendered outside <WhatsappDashboard>. */
|
|
28
|
+
function useOptionalWhatsappDashboard() {
|
|
29
|
+
return useContext(WhatsappDashboardContext);
|
|
30
|
+
}
|
|
31
|
+
function WhatsappDashboard({ children, className, defaultMobileView = "list", mobileView: mobileViewProp, onMobileViewChange, isMobile: isMobileProp, ...props }) {
|
|
32
|
+
const detectedIsMobile = useIsMobile(isMobileProp === void 0);
|
|
33
|
+
const isMobile = isMobileProp ?? detectedIsMobile;
|
|
34
|
+
const [uncontrolledView, setUncontrolledView] = useState(defaultMobileView);
|
|
35
|
+
const isViewControlled = mobileViewProp !== void 0;
|
|
36
|
+
const mobileView = isViewControlled ? mobileViewProp : uncontrolledView;
|
|
37
|
+
const setMobileView = useCallback((view) => {
|
|
38
|
+
if (!isViewControlled) setUncontrolledView(view);
|
|
39
|
+
onMobileViewChange?.(view);
|
|
40
|
+
}, [isViewControlled, onMobileViewChange]);
|
|
41
|
+
const value = useMemo(() => ({
|
|
42
|
+
isMobile,
|
|
43
|
+
mobileView,
|
|
44
|
+
setMobileView
|
|
45
|
+
}), [
|
|
46
|
+
isMobile,
|
|
47
|
+
mobileView,
|
|
48
|
+
setMobileView
|
|
49
|
+
]);
|
|
50
|
+
return /* @__PURE__ */ jsx(WhatsappDashboardContext.Provider, {
|
|
51
|
+
value,
|
|
52
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
53
|
+
className: cn("flex h-full w-full overflow-hidden bg-[#f0f2f5]", className),
|
|
54
|
+
...props,
|
|
55
|
+
children
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { WhatsappDashboard, useOptionalWhatsappDashboard, useWhatsappDashboard };
|
package/dist/wpp-bg.webp
ADDED
|
Binary file
|