@justinkahrs/on-device-demo
v0.1.0
Published
Reusable React mock mobile chat UI with scripted message playback.
Downloads
113
Maintainers
Readme
@justinkahrs/on-device-demo
Reusable React component library for rendering a mock mobile chat UI with scripted message playback.
Install
npm install @justinkahrs/on-device-demoreact and react-dom are peer dependencies. Most React app templates already include them.
Quick start
import {
MockMobileDevice,
type MockMessageScript,
} from "@justinkahrs/on-device-demo";
const script: MockMessageScript[] = [
{ from: "guest", text: "Hey, can you share check-in details?" },
{ from: "bot", text: "Check-in starts at 3:00 PM." },
];
export function Demo() {
return <MockMobileDevice script={script} messageDelayMs={1200} />;
}Script format
import type { MockMessageScript } from "@justinkahrs/on-device-demo";
const script: MockMessageScript[] = [
{ from: "guest", text: "Hey, can you share check-in details?" },
{
id: "main-choice",
from: "bot",
awaitUser: true,
branches: {
upgrade: "upgrade-path",
support: "support-path",
},
component: <>Need anything else?</>,
},
{ id: "upgrade-path", from: "guest", text: "Upgrade my checkout time" },
];from:"guest" | "bot" | "owner"text: plain message contentcomponent: custom React node contentawaitUser: pause playback untilresume()is calledid: optional message id for pointer targetsbranches: map from selected value to the next message id/indexnext: explicit next message id/index
QuickReplies can pass branch values as strings or { label, value }.
Public exports
MockMobileDeviceuseMockMobileChatChatProviderMessage,TypingIndicatorQuickRepliesHeaderPhoneContainerChatWindowAppleButtonCommonButtonGuestNameRichLink- Types:
MockMessageScript,MockMobileDeviceProps,QuickReplyOption,HeaderProps
Local development
npm install
npm run devOpen:
http://localhost:3000(demo app)http://localhost:3000/library-demo(library playground)
Build the library
npm run build:libThis generates dist/ (JS + type declarations + CSS module assets).
Publish to npm
- Confirm the package name in
/package.jsonmatches your npm scope. - Bump the version:
npm version patch(orminor/major). - Login once:
npm login. - Publish:
npm publish.
prepublishOnly runs build:lib and npm pack --dry-run, so publish fails early if packaging is broken.
