@ctonti/ask-golf-veneto 1.0.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/app-0PjpnX92.d.mts +16 -0
- package/dist/app-0PjpnX92.d.mts.map +1 -0
- package/dist/app-DWg095Qd.mjs +150 -0
- package/dist/app-DWg095Qd.mjs.map +1 -0
- package/dist/app-Daoze0po.cjs +189 -0
- package/dist/app-DzCpb5z9.d.cts +16 -0
- package/dist/app-DzCpb5z9.d.cts.map +1 -0
- package/dist/catalog-BlF_Hq2u.mjs +344 -0
- package/dist/catalog-BlF_Hq2u.mjs.map +1 -0
- package/dist/catalog-englM86y.cjs +362 -0
- package/dist/exports/browser.cjs +3 -0
- package/dist/exports/browser.d.cts +2 -0
- package/dist/exports/browser.d.mts +2 -0
- package/dist/exports/browser.mjs +2 -0
- package/dist/exports/catalog.cjs +5 -0
- package/dist/exports/catalog.d.cts +676 -0
- package/dist/exports/catalog.d.cts.map +1 -0
- package/dist/exports/catalog.d.mts +676 -0
- package/dist/exports/catalog.d.mts.map +1 -0
- package/dist/exports/catalog.mjs +2 -0
- package/dist/exports/client.cjs +10 -0
- package/dist/exports/client.d.cts +48 -0
- package/dist/exports/client.d.cts.map +1 -0
- package/dist/exports/client.d.mts +48 -0
- package/dist/exports/client.d.mts.map +1 -0
- package/dist/exports/client.mjs +3 -0
- package/dist/exports/registry.cjs +6 -0
- package/dist/exports/registry.d.cts +12 -0
- package/dist/exports/registry.d.cts.map +1 -0
- package/dist/exports/registry.d.mts +12 -0
- package/dist/exports/registry.d.mts.map +1 -0
- package/dist/exports/registry.mjs +2 -0
- package/dist/globals.css +91 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/plugin-B0vGrWcM.d.cts +7 -0
- package/dist/plugin-B0vGrWcM.d.cts.map +1 -0
- package/dist/plugin-BdhObzU8.cjs +14 -0
- package/dist/plugin-DYfnXStA.mjs +11 -0
- package/dist/plugin-DYfnXStA.mjs.map +1 -0
- package/dist/plugin-X9b5Ujac.d.mts +7 -0
- package/dist/plugin-X9b5Ujac.d.mts.map +1 -0
- package/dist/postcss.config.mjs +5 -0
- package/dist/registry-Bq-3Pbqd.mjs +1211 -0
- package/dist/registry-Bq-3Pbqd.mjs.map +1 -0
- package/dist/registry-E8Of7gsT.cjs +1261 -0
- package/dist/styles.css +2354 -0
- package/package.json +102 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
import { ChatProviderProps, PluginOptions } from "@websolutespa/ask-plugin";
|
|
3
|
+
|
|
4
|
+
//#region src/components/chat.d.ts
|
|
5
|
+
declare function Chat({
|
|
6
|
+
appKey,
|
|
7
|
+
apiKey,
|
|
8
|
+
...props
|
|
9
|
+
}: Partial<ChatProviderProps>): _$react.JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/components/app.d.ts
|
|
12
|
+
type AppProps = PluginOptions;
|
|
13
|
+
declare const App: (props: AppProps) => _$react.JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { AppProps as n, Chat as r, App as t };
|
|
16
|
+
//# sourceMappingURL=app-0PjpnX92.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-0PjpnX92.d.mts","names":[],"sources":["../src/components/chat.tsx","../src/components/app.tsx"],"mappings":";;;;iBAYgB,IAAA,CAAA;EAAO,MAAA;EAAQ,MAAA;EAAA,GAAW;AAAA,GAAS,OAAA,CAAQ,iBAAA,IAAkB,OAAA,CAAA,GAAA,CAAA,OAAA;;;KCJjE,QAAA,GAAW,aAAA;AAAA,cAEV,GAAA,GAAO,KAAA,EAAO,QAAA,KAAQ,OAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { r as registry } from "./registry-Bq-3Pbqd.mjs";
|
|
2
|
+
import { TooltipProvider } from "@websolutespa/ask-ui/components/tooltip";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { ChatContext, ChatProvider, ComponentsContext, ComponentsProvider, ViewProvider } from "@websolutespa/ask-plugin";
|
|
5
|
+
import { Toaster } from "@websolutespa/ask-ui/components/sonner";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { cn } from "@websolutespa/ask-ui";
|
|
8
|
+
import { ActionProvider, Renderer, StateProvider, VisibilityProvider } from "@json-render/react";
|
|
9
|
+
import { toast } from "sonner";
|
|
10
|
+
//#region src/components/intro.tsx
|
|
11
|
+
function Intro() {
|
|
12
|
+
const { PromptIntro } = useContext(ComponentsContext);
|
|
13
|
+
const { contents } = useContext(ChatContext);
|
|
14
|
+
const title = contents.intro?.title || "Progetta la tua <em>vacanza golf</em> in Veneto";
|
|
15
|
+
return /* @__PURE__ */ jsx("section", {
|
|
16
|
+
className: "relative flex min-h-[calc(100vh-115px)] flex-col items-center justify-center gap-8 bg-background text-foreground",
|
|
17
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
18
|
+
className: "relative w-full max-w-215 p-2",
|
|
19
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "flex flex-col gap-20",
|
|
21
|
+
children: [title && /* @__PURE__ */ jsx("h1", {
|
|
22
|
+
className: "text-center text-[40px] font-thin leading-[1.45] tracking-[-0.02em] font-heading italic text-primary",
|
|
23
|
+
dangerouslySetInnerHTML: { __html: title }
|
|
24
|
+
}), /* @__PURE__ */ jsx(PromptIntro, {})]
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/main.tsx
|
|
31
|
+
function Main() {
|
|
32
|
+
const { Intro, Thread } = useContext(ComponentsContext);
|
|
33
|
+
const { shouldShowIntro } = useContext(ChatContext);
|
|
34
|
+
return /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: "w-full min-h-svh flex flex-col gap-8 bg-background text-foreground",
|
|
36
|
+
children: shouldShowIntro ? /* @__PURE__ */ jsx(Intro, {}) : /* @__PURE__ */ jsx(Thread, {})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/components/preview.tsx
|
|
41
|
+
function Preview({ spec }) {
|
|
42
|
+
return /* @__PURE__ */ jsxs(ComponentsProvider, {
|
|
43
|
+
components: COMPONENTS,
|
|
44
|
+
children: [/* @__PURE__ */ jsx(PreviewRenderer, { spec }), /* @__PURE__ */ jsx(Toaster, {})]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function PreviewRenderer({ spec, className }) {
|
|
48
|
+
const { Renderer } = useContext(ComponentsContext);
|
|
49
|
+
return /* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: cn("w-full flex flex-col gap-10 py-5 @md:gap-20 @md:py-10", className),
|
|
51
|
+
children: spec ? /* @__PURE__ */ jsx(Renderer, { spec }) : /* @__PURE__ */ jsx("div", { children: "Spec not provided" })
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/components/renderer.tsx
|
|
56
|
+
function Renderer$1({ spec, isStreaming = false, mounted = false }) {
|
|
57
|
+
const { Fallback } = useContext(ComponentsContext);
|
|
58
|
+
if (!spec) return;
|
|
59
|
+
return /* @__PURE__ */ jsx(StateProvider, {
|
|
60
|
+
initialState: spec.state ?? {},
|
|
61
|
+
children: /* @__PURE__ */ jsx(VisibilityProvider, { children: /* @__PURE__ */ jsx(ActionProvider, {
|
|
62
|
+
handlers: { linkClick: async (params) => {
|
|
63
|
+
const href = params?.href || "#";
|
|
64
|
+
if (mounted) {
|
|
65
|
+
const { url } = params;
|
|
66
|
+
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
67
|
+
} else toast.info(`Navigating to: ${href}`);
|
|
68
|
+
} },
|
|
69
|
+
children: /* @__PURE__ */ jsx(Renderer, {
|
|
70
|
+
spec,
|
|
71
|
+
registry,
|
|
72
|
+
fallback: Fallback,
|
|
73
|
+
loading: isStreaming
|
|
74
|
+
})
|
|
75
|
+
}) })
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components.ts
|
|
80
|
+
const COMPONENTS = {
|
|
81
|
+
App,
|
|
82
|
+
Chat,
|
|
83
|
+
Intro,
|
|
84
|
+
Main,
|
|
85
|
+
Preview,
|
|
86
|
+
Renderer: Renderer$1
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/components/chat.tsx
|
|
90
|
+
function Chat({ appKey, apiKey, ...props }) {
|
|
91
|
+
if (!appKey) return /* @__PURE__ */ jsx("div", { children: "appKey not defined" });
|
|
92
|
+
if (!apiKey) return /* @__PURE__ */ jsx("div", { children: "apiKey not defined" });
|
|
93
|
+
return /* @__PURE__ */ jsx(ComponentsProvider, {
|
|
94
|
+
components: COMPONENTS,
|
|
95
|
+
children: /* @__PURE__ */ jsx(ChatProvider, {
|
|
96
|
+
appKey,
|
|
97
|
+
apiKey,
|
|
98
|
+
...props,
|
|
99
|
+
children: /* @__PURE__ */ jsxs(ViewProvider, { children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(Toaster, {})] })
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/app.tsx
|
|
105
|
+
const App = (props) => {
|
|
106
|
+
useMemo(() => {
|
|
107
|
+
if (typeof window !== "undefined") {
|
|
108
|
+
const htmlLang = getHtmlLang();
|
|
109
|
+
const title = document.querySelector("title");
|
|
110
|
+
const description = document.querySelector("meta[name=\"description\"]");
|
|
111
|
+
const canonical = document.querySelector("link[rel=\"canonical\"]");
|
|
112
|
+
return {
|
|
113
|
+
locale: htmlLang?.locale || "it",
|
|
114
|
+
market: htmlLang?.market || "ww",
|
|
115
|
+
origin: window.origin,
|
|
116
|
+
canonical: canonical?.getAttribute("href") || window.location.href,
|
|
117
|
+
title: title ? title.innerText : "Untitled",
|
|
118
|
+
description: description?.getAttribute("content") || "",
|
|
119
|
+
slug: window.location.pathname
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
locale: "it",
|
|
124
|
+
market: "ww",
|
|
125
|
+
origin: "",
|
|
126
|
+
canonical: "",
|
|
127
|
+
title: "Untitled",
|
|
128
|
+
description: "",
|
|
129
|
+
slug: ""
|
|
130
|
+
};
|
|
131
|
+
}, []);
|
|
132
|
+
return /* @__PURE__ */ jsx("div", {
|
|
133
|
+
className: "@container w-full",
|
|
134
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, { children: props.preview ? /* @__PURE__ */ jsx(Preview, { spec: props.initialSpec }) : /* @__PURE__ */ jsx(Chat, { ...props }) })
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
function getHtmlLang() {
|
|
138
|
+
const htmlLang = document.querySelector("html")?.getAttribute("lang");
|
|
139
|
+
if (htmlLang) {
|
|
140
|
+
const segments = htmlLang.toLowerCase().split("-");
|
|
141
|
+
return {
|
|
142
|
+
locale: segments[0],
|
|
143
|
+
market: segments[1] || "ww"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
export { Preview as a, Renderer$1 as i, Chat as n, PreviewRenderer as o, COMPONENTS as r, Main as s, App as t };
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=app-DWg095Qd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-DWg095Qd.mjs","names":["Renderer","JsonRenderer"],"sources":["../src/components/intro.tsx","../src/components/main.tsx","../src/components/preview.tsx","../src/components/renderer.tsx","../src/components.ts","../src/components/chat.tsx","../src/components/app.tsx"],"sourcesContent":["'use client';\n\nimport { ChatContext, ComponentsContext } from '@websolutespa/ask-plugin';\nimport { useContext } from 'react';\n\nexport function Intro() {\n const { PromptIntro } = useContext(ComponentsContext);\n const { contents } = useContext(ChatContext);\n const title =\n contents.intro?.title || 'Progetta la tua <em>vacanza golf</em> in Veneto';\n return (\n <section className=\"relative flex min-h-[calc(100vh-115px)] flex-col items-center justify-center gap-8 bg-background text-foreground\">\n <div className=\"relative w-full max-w-215 p-2\">\n <div className=\"flex flex-col gap-20\">\n {title && (\n <h1\n className=\"text-center text-[40px] font-thin leading-[1.45] tracking-[-0.02em] font-heading italic text-primary\"\n dangerouslySetInnerHTML={{ __html: title }}\n />\n )}\n <PromptIntro />\n </div>\n </div>\n </section>\n );\n}\n","'use client';\n\nimport { ChatContext, ComponentsContext } from '@websolutespa/ask-plugin';\nimport { useContext } from 'react';\n\nexport function Main() {\n const { Intro, Thread } = useContext(ComponentsContext);\n const { shouldShowIntro } = useContext(ChatContext);\n return (\n <div className=\"w-full min-h-svh flex flex-col gap-8 bg-background text-foreground\">\n {shouldShowIntro ? <Intro /> : <Thread />}\n </div>\n );\n}\n","'use client';\n\nimport { Spec } from '@json-render/core';\nimport { ComponentsContext, ComponentsProvider } from '@websolutespa/ask-plugin';\nimport { cn } from '@websolutespa/ask-ui';\nimport { Toaster } from '@websolutespa/ask-ui/components/sonner';\nimport { useContext } from 'react';\nimport { COMPONENTS } from '../components';\n\nexport function Preview({ spec }: { spec?: Spec | null }) {\n return (\n <ComponentsProvider components={COMPONENTS}>\n <PreviewRenderer spec={spec} />\n <Toaster />\n </ComponentsProvider>\n );\n}\n\nexport function PreviewRenderer({\n spec,\n className,\n}: {\n spec?: Spec | null;\n className?: string;\n}) {\n const { Renderer } = useContext(ComponentsContext);\n return (\n <div className={cn('w-full flex flex-col gap-10 py-5 @md:gap-20 @md:py-10', className)}>\n {spec ? <Renderer spec={spec} /> : <div>Spec not provided</div>}\n </div>\n );\n}\n","'use client';\n\nimport { Spec } from '@json-render/core';\nimport {\n ActionProvider,\n Renderer as JsonRenderer,\n StateProvider,\n VisibilityProvider,\n} from '@json-render/react';\nimport { ComponentsContext } from '@websolutespa/ask-plugin';\nimport { useContext } from 'react';\nimport { toast } from 'sonner';\n// IMPORTANT: import YOUR OWN registry so your custom blocks are rendered.\nimport { registry } from '../registry';\n\nexport function Renderer({\n spec,\n isStreaming = false,\n mounted = false,\n}: {\n spec?: Spec | null;\n isStreaming?: boolean;\n mounted?: boolean;\n}) {\n const { Fallback } = useContext(ComponentsContext);\n if (!spec) {\n return;\n }\n return (\n <StateProvider initialState={spec.state ?? {}}>\n <VisibilityProvider>\n <ActionProvider\n handlers={{\n linkClick: async (params) => {\n const href = (params?.href as string) || '#';\n if (mounted) {\n const { url } = params as { url?: string };\n if (url) window.open(url, '_blank', 'noopener,noreferrer');\n } else {\n toast.info(`Navigating to: ${href}`);\n }\n },\n }}\n >\n <JsonRenderer\n spec={spec}\n registry={registry}\n fallback={Fallback}\n loading={isStreaming}\n />\n </ActionProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n}\n","import { App } from './components/app';\nimport { Chat } from './components/chat';\nimport { Intro } from './components/intro';\nimport { Main } from './components/main';\nimport { Preview } from './components/preview';\nimport { Renderer } from './components/renderer';\n\n// Components injected into the shared chat engine via ComponentsProvider.\n// Only list what you override; everything else falls back to @websolutespa/ask-plugin.\nexport const COMPONENTS = {\n App,\n Chat,\n Intro,\n Main,\n Preview,\n Renderer,\n};\n\nexport type Components = typeof COMPONENTS;\n\nexport * from './components/app';\nexport * from './components/chat';\nexport * from './components/main';\nexport * from './components/preview';\nexport * from './components/renderer';\n","'use client';\n\nimport {\n ChatProvider,\n ChatProviderProps,\n ComponentsProvider,\n ViewProvider,\n} from '@websolutespa/ask-plugin';\nimport { Toaster } from '@websolutespa/ask-ui/components/sonner';\nimport { COMPONENTS } from '../components';\nimport { Main } from './main';\n\nexport function Chat({ appKey, apiKey, ...props }: Partial<ChatProviderProps>) {\n if (!appKey) {\n return <div>appKey not defined</div>;\n }\n if (!apiKey) {\n return <div>apiKey not defined</div>;\n }\n return (\n <ComponentsProvider components={COMPONENTS}>\n <ChatProvider appKey={appKey} apiKey={apiKey} {...props}>\n <ViewProvider>\n <Main />\n <Toaster />\n </ViewProvider>\n </ChatProvider>\n </ComponentsProvider>\n );\n}\n","'use client';\n\nimport type { PageData, PluginOptions } from '@websolutespa/ask-plugin';\nimport { TooltipProvider } from '@websolutespa/ask-ui/components/tooltip';\nimport { useMemo } from 'react';\nimport { Chat } from './chat';\nimport { Preview } from './preview';\n\nexport type AppProps = PluginOptions;\n\nexport const App = (props: AppProps) => {\n const _data = useMemo<PageData>(() => {\n if (typeof window !== 'undefined') {\n const htmlLang = getHtmlLang();\n const title = document.querySelector('title');\n const description = document.querySelector('meta[name=\"description\"]');\n const canonical = document.querySelector('link[rel=\"canonical\"]');\n return {\n locale: htmlLang?.locale || 'it',\n market: htmlLang?.market || 'ww',\n origin: window.origin,\n canonical: canonical?.getAttribute('href') || window.location.href,\n title: title ? title.innerText : 'Untitled',\n description: description?.getAttribute('content') || '',\n slug: window.location.pathname,\n };\n }\n return {\n locale: 'it',\n market: 'ww',\n origin: '',\n canonical: '',\n title: 'Untitled',\n description: '',\n slug: '',\n };\n }, []);\n\n return (\n <div className=\"@container w-full\">\n <TooltipProvider>\n {props.preview ? (\n <Preview spec={props.initialSpec} />\n ) : (\n <Chat {...props} />\n )}\n </TooltipProvider>\n </div>\n );\n};\n\nfunction getHtmlLang(): { locale: string; market: string } | undefined {\n const html = document.querySelector('html');\n const htmlLang = html?.getAttribute('lang');\n if (htmlLang) {\n const segments = htmlLang.toLowerCase().split('-');\n return { locale: segments[0], market: segments[1] || 'ww' };\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;AAKA,SAAgB,QAAQ;CACtB,MAAM,EAAE,gBAAgB,WAAW,kBAAkB;CACrD,MAAM,EAAE,aAAa,WAAW,YAAY;CAC5C,MAAM,QACJ,SAAS,OAAO,SAAS;AAC3B,QACE,oBAAC,WAAD;EAAS,WAAU;YACjB,oBAAC,OAAD;GAAK,WAAU;aACb,qBAAC,OAAD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pC,oBAAC,MAAD,EAAM,GAAI,OAAS,CAAA,EAEL,CAAA;EACd,CAAA;;AAIV,SAAS,cAA8D;CAErE,MAAM,WADO,SAAS,cAAc,OACf,EAAE,aAAa,OAAO;AAC3C,KAAI,UAAU;EACZ,MAAM,WAAW,SAAS,aAAa,CAAC,MAAM,IAAI;AAClD,SAAO;GAAE,QAAQ,SAAS;GAAI,QAAQ,SAAS,MAAM;GAAM"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const require_registry = require("./registry-E8Of7gsT.cjs");
|
|
2
|
+
let _websolutespa_ask_ui_components_tooltip = require("@websolutespa/ask-ui/components/tooltip");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _websolutespa_ask_plugin = require("@websolutespa/ask-plugin");
|
|
5
|
+
let _websolutespa_ask_ui_components_sonner = require("@websolutespa/ask-ui/components/sonner");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _websolutespa_ask_ui = require("@websolutespa/ask-ui");
|
|
8
|
+
let _json_render_react = require("@json-render/react");
|
|
9
|
+
let sonner = require("sonner");
|
|
10
|
+
//#region src/components/intro.tsx
|
|
11
|
+
function Intro() {
|
|
12
|
+
const { PromptIntro } = (0, react.useContext)(_websolutespa_ask_plugin.ComponentsContext);
|
|
13
|
+
const { contents } = (0, react.useContext)(_websolutespa_ask_plugin.ChatContext);
|
|
14
|
+
const title = contents.intro?.title || "Progetta la tua <em>vacanza golf</em> in Veneto";
|
|
15
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
16
|
+
className: "relative flex min-h-[calc(100vh-115px)] flex-col items-center justify-center gap-8 bg-background text-foreground",
|
|
17
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
18
|
+
className: "relative w-full max-w-215 p-2",
|
|
19
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20
|
+
className: "flex flex-col gap-20",
|
|
21
|
+
children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
22
|
+
className: "text-center text-[40px] font-thin leading-[1.45] tracking-[-0.02em] font-heading italic text-primary",
|
|
23
|
+
dangerouslySetInnerHTML: { __html: title }
|
|
24
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromptIntro, {})]
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/main.tsx
|
|
31
|
+
function Main() {
|
|
32
|
+
const { Intro, Thread } = (0, react.useContext)(_websolutespa_ask_plugin.ComponentsContext);
|
|
33
|
+
const { shouldShowIntro } = (0, react.useContext)(_websolutespa_ask_plugin.ChatContext);
|
|
34
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
35
|
+
className: "w-full min-h-svh flex flex-col gap-8 bg-background text-foreground",
|
|
36
|
+
children: shouldShowIntro ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Intro, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Thread, {})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/components/preview.tsx
|
|
41
|
+
function Preview({ spec }) {
|
|
42
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_websolutespa_ask_plugin.ComponentsProvider, {
|
|
43
|
+
components: COMPONENTS,
|
|
44
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PreviewRenderer, { spec }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_websolutespa_ask_ui_components_sonner.Toaster, {})]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function PreviewRenderer({ spec, className }) {
|
|
48
|
+
const { Renderer } = (0, react.useContext)(_websolutespa_ask_plugin.ComponentsContext);
|
|
49
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
50
|
+
className: (0, _websolutespa_ask_ui.cn)("w-full flex flex-col gap-10 py-5 @md:gap-20 @md:py-10", className),
|
|
51
|
+
children: spec ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { spec }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "Spec not provided" })
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/components/renderer.tsx
|
|
56
|
+
function Renderer({ spec, isStreaming = false, mounted = false }) {
|
|
57
|
+
const { Fallback } = (0, react.useContext)(_websolutespa_ask_plugin.ComponentsContext);
|
|
58
|
+
if (!spec) return;
|
|
59
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_json_render_react.StateProvider, {
|
|
60
|
+
initialState: spec.state ?? {},
|
|
61
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_json_render_react.VisibilityProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_json_render_react.ActionProvider, {
|
|
62
|
+
handlers: { linkClick: async (params) => {
|
|
63
|
+
const href = params?.href || "#";
|
|
64
|
+
if (mounted) {
|
|
65
|
+
const { url } = params;
|
|
66
|
+
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
|
67
|
+
} else sonner.toast.info(`Navigating to: ${href}`);
|
|
68
|
+
} },
|
|
69
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_json_render_react.Renderer, {
|
|
70
|
+
spec,
|
|
71
|
+
registry: require_registry.registry,
|
|
72
|
+
fallback: Fallback,
|
|
73
|
+
loading: isStreaming
|
|
74
|
+
})
|
|
75
|
+
}) })
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components.ts
|
|
80
|
+
const COMPONENTS = {
|
|
81
|
+
App,
|
|
82
|
+
Chat,
|
|
83
|
+
Intro,
|
|
84
|
+
Main,
|
|
85
|
+
Preview,
|
|
86
|
+
Renderer
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/components/chat.tsx
|
|
90
|
+
function Chat({ appKey, apiKey, ...props }) {
|
|
91
|
+
if (!appKey) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "appKey not defined" });
|
|
92
|
+
if (!apiKey) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "apiKey not defined" });
|
|
93
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_websolutespa_ask_plugin.ComponentsProvider, {
|
|
94
|
+
components: COMPONENTS,
|
|
95
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_websolutespa_ask_plugin.ChatProvider, {
|
|
96
|
+
appKey,
|
|
97
|
+
apiKey,
|
|
98
|
+
...props,
|
|
99
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_websolutespa_ask_plugin.ViewProvider, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Main, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_websolutespa_ask_ui_components_sonner.Toaster, {})] })
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/components/app.tsx
|
|
105
|
+
const App = (props) => {
|
|
106
|
+
(0, react.useMemo)(() => {
|
|
107
|
+
if (typeof window !== "undefined") {
|
|
108
|
+
const htmlLang = getHtmlLang();
|
|
109
|
+
const title = document.querySelector("title");
|
|
110
|
+
const description = document.querySelector("meta[name=\"description\"]");
|
|
111
|
+
const canonical = document.querySelector("link[rel=\"canonical\"]");
|
|
112
|
+
return {
|
|
113
|
+
locale: htmlLang?.locale || "it",
|
|
114
|
+
market: htmlLang?.market || "ww",
|
|
115
|
+
origin: window.origin,
|
|
116
|
+
canonical: canonical?.getAttribute("href") || window.location.href,
|
|
117
|
+
title: title ? title.innerText : "Untitled",
|
|
118
|
+
description: description?.getAttribute("content") || "",
|
|
119
|
+
slug: window.location.pathname
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
locale: "it",
|
|
124
|
+
market: "ww",
|
|
125
|
+
origin: "",
|
|
126
|
+
canonical: "",
|
|
127
|
+
title: "Untitled",
|
|
128
|
+
description: "",
|
|
129
|
+
slug: ""
|
|
130
|
+
};
|
|
131
|
+
}, []);
|
|
132
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
133
|
+
className: "@container w-full",
|
|
134
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_websolutespa_ask_ui_components_tooltip.TooltipProvider, { children: props.preview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { spec: props.initialSpec }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chat, { ...props }) })
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
function getHtmlLang() {
|
|
138
|
+
const htmlLang = document.querySelector("html")?.getAttribute("lang");
|
|
139
|
+
if (htmlLang) {
|
|
140
|
+
const segments = htmlLang.toLowerCase().split("-");
|
|
141
|
+
return {
|
|
142
|
+
locale: segments[0],
|
|
143
|
+
market: segments[1] || "ww"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
Object.defineProperty(exports, "App", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function() {
|
|
151
|
+
return App;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(exports, "COMPONENTS", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function() {
|
|
157
|
+
return COMPONENTS;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "Chat", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function() {
|
|
163
|
+
return Chat;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(exports, "Main", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function() {
|
|
169
|
+
return Main;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(exports, "Preview", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
get: function() {
|
|
175
|
+
return Preview;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(exports, "PreviewRenderer", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
get: function() {
|
|
181
|
+
return PreviewRenderer;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(exports, "Renderer", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
get: function() {
|
|
187
|
+
return Renderer;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChatProviderProps, PluginOptions } from "@websolutespa/ask-plugin";
|
|
2
|
+
import * as _$react from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/chat.d.ts
|
|
5
|
+
declare function Chat({
|
|
6
|
+
appKey,
|
|
7
|
+
apiKey,
|
|
8
|
+
...props
|
|
9
|
+
}: Partial<ChatProviderProps>): _$react.JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/components/app.d.ts
|
|
12
|
+
type AppProps = PluginOptions;
|
|
13
|
+
declare const App: (props: AppProps) => _$react.JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { AppProps as n, Chat as r, App as t };
|
|
16
|
+
//# sourceMappingURL=app-DzCpb5z9.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-DzCpb5z9.d.cts","names":[],"sources":["../src/components/chat.tsx","../src/components/app.tsx"],"mappings":";;;;iBAYgB,IAAA,CAAA;EAAO,MAAA;EAAQ,MAAA;EAAA,GAAW;AAAA,GAAS,OAAA,CAAQ,iBAAA,IAAkB,OAAA,CAAA,GAAA,CAAA,OAAA;;;KCJjE,QAAA,GAAW,aAAA;AAAA,cAEV,GAAA,GAAO,KAAA,EAAO,QAAA,KAAQ,OAAA,CAAA,GAAA,CAAA,OAAA"}
|