@yak-io/react 0.4.0 → 0.4.1
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/YakProvider.d.ts +1 -1
- package/dist/YakProvider.d.ts.map +1 -1
- package/dist/YakProvider.js +19 -7
- package/dist/YakWidget.d.ts +1 -1
- package/dist/YakWidget.d.ts.map +1 -1
- package/dist/YakWidget.js +37 -34
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +7 -5
package/dist/YakProvider.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YakProvider.d.ts","sourceRoot":"","sources":["../src/YakProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"YakProvider.d.ts","sourceRoot":"","sources":["../src/YakProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAEL,KAAK,KAAK,EAGV,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAEpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B;;OAEG;IACH,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C;;OAEG;IACH,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,mCAAmC;IACnC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,qEAAqE;IACrE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,uDAAuD;IACvD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,0BAA0B;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAmMF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,oBAAoB,EACpB,QAAQ,GACT,EAAE,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAqVtC"}
|
package/dist/YakProvider.js
CHANGED
|
@@ -260,7 +260,18 @@ export function YakProvider({ appId, getConfig, onToolCall, onGraphQLSchemaCall,
|
|
|
260
260
|
chatConfig: chatConfig ?? undefined,
|
|
261
261
|
onToolCallComplete: handleToolCallComplete,
|
|
262
262
|
});
|
|
263
|
-
}, [
|
|
263
|
+
}, [
|
|
264
|
+
appId,
|
|
265
|
+
onToolCall,
|
|
266
|
+
onGraphQLSchemaCall,
|
|
267
|
+
onRESTSchemaCall,
|
|
268
|
+
theme,
|
|
269
|
+
onRedirect,
|
|
270
|
+
disableRestartButton,
|
|
271
|
+
chatConfig,
|
|
272
|
+
client,
|
|
273
|
+
handleToolCallComplete,
|
|
274
|
+
]);
|
|
264
275
|
// Update client iframe window
|
|
265
276
|
useEffect(() => {
|
|
266
277
|
client.setIframeWindow(iframeWindow);
|
|
@@ -320,7 +331,10 @@ export function YakProvider({ appId, getConfig, onToolCall, onGraphQLSchemaCall,
|
|
|
320
331
|
return;
|
|
321
332
|
const mobileQuery = window.matchMedia("(max-width: 640px)");
|
|
322
333
|
const notifyFullscreen = (isFullscreen) => {
|
|
323
|
-
const msg = {
|
|
334
|
+
const msg = {
|
|
335
|
+
type: "yak:viewport",
|
|
336
|
+
payload: { fullscreen: isFullscreen },
|
|
337
|
+
};
|
|
324
338
|
iframeWindow?.postMessage(msg, iframeOrigin);
|
|
325
339
|
};
|
|
326
340
|
// Send initial state
|
|
@@ -450,10 +464,8 @@ export function YakProvider({ appId, getConfig, onToolCall, onGraphQLSchemaCall,
|
|
|
450
464
|
// Determine color mode class for the container
|
|
451
465
|
const colorModeClass = colorMode === "light" ? "yak-panel-light" : colorMode === "dark" ? "yak-panel-dark" : "";
|
|
452
466
|
// Build container class names
|
|
453
|
-
const containerClasses = [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
colorModeClass,
|
|
457
|
-
].filter(Boolean).join(" ");
|
|
467
|
+
const containerClasses = ["yak-panel-container", isDrawer && "yak-panel-drawer", colorModeClass]
|
|
468
|
+
.filter(Boolean)
|
|
469
|
+
.join(" ");
|
|
458
470
|
return (_jsxs(YakContext.Provider, { value: contextValue, children: [children, _jsx("style", { children: getIframeStyles() }), hasBeenOpened && (_jsx("div", { className: "yak-panel-root", "data-expanded": isExpanded, children: _jsx("div", { className: containerClasses, "data-position": position, "data-open": isWidgetOpen && isIframeReady, "data-expanded": isExpanded, children: _jsx("iframe", { ref: iframeRef, src: iframeSrc, className: "yak-panel-iframe", title: "yak-chat-host" }) }) }))] }));
|
|
459
471
|
}
|
package/dist/YakWidget.d.ts
CHANGED
package/dist/YakWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YakWidget.d.ts","sourceRoot":"","sources":["../src/YakWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"YakWidget.d.ts","sourceRoot":"","sources":["../src/YakWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAwPzD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,0BAA0B;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACxC,0CAA0C;IAC1C,WAAW,CAAC,EAAE;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,yCAAyC;IACzC,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAwCF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,YAA4B,EAC5B,QAAyB,EACzB,SAAS,EACT,WAAW,EACX,UAAU,GACX,GAAE,cAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAuCzC"}
|
package/dist/YakWidget.js
CHANGED
|
@@ -208,23 +208,33 @@ function getButtonStyles() {
|
|
|
208
208
|
/**
|
|
209
209
|
* Inline SVG for brain/circuit fallback icon
|
|
210
210
|
*/
|
|
211
|
-
function BrainCircuitIcon({ size = 20, className }) {
|
|
212
|
-
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: className, children: [_jsx("path", { d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }), _jsx("path", { d: "M9 13a4.5 4.5 0 0 0 3-4" }), _jsx("path", { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }), _jsx("path", { d: "M3.477 10.896a4 4 0 0 1 .585-.396" }), _jsx("path", { d: "M6 18a4 4 0 0 1-1.967-.516" }), _jsx("path", { d: "M12 13h4" }), _jsx("path", { d: "M12 18h6a2 2 0 0 1 2 2v1" }), _jsx("path", { d: "M12 8h8" }), _jsx("path", { d: "M16 8V5a2 2 0 0 1 2-2" }), _jsx("circle", { cx: "16", cy: "13", r: ".5" }), _jsx("circle", { cx: "18", cy: "3", r: ".5" }), _jsx("circle", { cx: "20", cy: "21", r: ".5" }), _jsx("circle", { cx: "20", cy: "8", r: ".5" })] }));
|
|
211
|
+
function BrainCircuitIcon({ size = 20, className, }) {
|
|
212
|
+
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: className, children: [_jsx("path", { d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }), _jsx("path", { d: "M9 13a4.5 4.5 0 0 0 3-4" }), _jsx("path", { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }), _jsx("path", { d: "M3.477 10.896a4 4 0 0 1 .585-.396" }), _jsx("path", { d: "M6 18a4 4 0 0 1-1.967-.516" }), _jsx("path", { d: "M12 13h4" }), _jsx("path", { d: "M12 18h6a2 2 0 0 1 2 2v1" }), _jsx("path", { d: "M12 8h8" }), _jsx("path", { d: "M16 8V5a2 2 0 0 1 2-2" }), _jsx("circle", { cx: "16", cy: "13", r: ".5" }), _jsx("circle", { cx: "18", cy: "3", r: ".5" }), _jsx("circle", { cx: "20", cy: "21", r: ".5" }), _jsx("circle", { cx: "20", cy: "8", r: ".5" })] }));
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
216
|
-
* The chat iframe is rendered by YakProvider - this is just the trigger button.
|
|
215
|
+
* Compute button CSS variables from custom button color props
|
|
217
216
|
*/
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
function buildButtonStyle(lightButton, darkButton) {
|
|
218
|
+
const style = {};
|
|
219
|
+
if (lightButton?.background)
|
|
220
|
+
style["--yak-btn-light-bg"] = lightButton.background;
|
|
221
|
+
if (lightButton?.color)
|
|
222
|
+
style["--yak-btn-light-color"] = lightButton.color;
|
|
223
|
+
if (lightButton?.border)
|
|
224
|
+
style["--yak-btn-light-border"] = lightButton.border;
|
|
225
|
+
if (darkButton?.background)
|
|
226
|
+
style["--yak-btn-dark-bg"] = darkButton.background;
|
|
227
|
+
if (darkButton?.color)
|
|
228
|
+
style["--yak-btn-dark-color"] = darkButton.color;
|
|
229
|
+
if (darkButton?.border)
|
|
230
|
+
style["--yak-btn-dark-border"] = darkButton.border;
|
|
231
|
+
return style;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Compute button class names from color mode and custom theme flags
|
|
235
|
+
*/
|
|
236
|
+
function buildButtonClasses(colorMode, hasLightCustom, hasDarkCustom) {
|
|
226
237
|
const colorModeClass = colorMode === "light" ? "yak-widget-light" : colorMode === "dark" ? "yak-widget-dark" : "";
|
|
227
|
-
// Determine which custom class to apply based on color mode
|
|
228
238
|
let customButtonClass = "";
|
|
229
239
|
if (colorMode === "light" && hasLightCustom) {
|
|
230
240
|
customButtonClass = "yak-widget-custom-light";
|
|
@@ -232,25 +242,18 @@ export function YakWidget({ triggerLabel = "Ask with AI", position = "bottom-rig
|
|
|
232
242
|
else if (colorMode === "dark" && hasDarkCustom) {
|
|
233
243
|
customButtonClass = "yak-widget-custom-dark";
|
|
234
244
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// Build button class names
|
|
250
|
-
const buttonClasses = [
|
|
251
|
-
"yak-widget-trigger",
|
|
252
|
-
colorModeClass,
|
|
253
|
-
customButtonClass,
|
|
254
|
-
].filter(Boolean).join(" ");
|
|
255
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { children: getButtonStyles() }), _jsxs("button", { onClick: open, className: buttonClasses, style: Object.keys(buttonStyle).length > 0 ? buttonStyle : undefined, "data-position": position, "data-has-light-custom": hasLightCustom || undefined, "data-has-dark-custom": hasDarkCustom || undefined, "aria-label": isLoading ? "Loading chat" : "Open chat", disabled: isLoading, children: [_jsx("span", { className: "yak-widget-trigger-label", children: triggerLabel }), _jsx("div", { className: "yak-widget-icon-bg", children: isLoading ? (_jsx("div", { className: "yak-widget-spinner", "aria-hidden": "true" })) : (_jsx(BrainCircuitIcon, { size: 20, className: "yak-widget-icon" })) })] })] }));
|
|
245
|
+
return ["yak-widget-trigger", colorModeClass, customButtonClass].filter(Boolean).join(" ");
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* YakWidget renders a fixed-position launcher button.
|
|
249
|
+
* The chat iframe is rendered by YakProvider - this is just the trigger button.
|
|
250
|
+
*/
|
|
251
|
+
export function YakWidget({ triggerLabel = "Ask with AI", position = "bottom-right", colorMode, lightButton, darkButton, } = {}) {
|
|
252
|
+
const { open, isOpen, isIframeReady } = useYak();
|
|
253
|
+
const isLoading = isOpen && !isIframeReady;
|
|
254
|
+
const hasLightCustom = lightButton?.background || lightButton?.color || lightButton?.border;
|
|
255
|
+
const hasDarkCustom = darkButton?.background || darkButton?.color || darkButton?.border;
|
|
256
|
+
const buttonStyle = buildButtonStyle(lightButton, darkButton);
|
|
257
|
+
const buttonClasses = buildButtonClasses(colorMode, hasLightCustom, hasDarkCustom);
|
|
258
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: getButtonStyles() }), _jsxs("button", { type: "button", onClick: open, className: buttonClasses, style: Object.keys(buttonStyle).length > 0 ? buttonStyle : undefined, "data-position": position, "data-has-light-custom": hasLightCustom || undefined, "data-has-dark-custom": hasDarkCustom || undefined, "aria-label": isLoading ? "Loading chat" : "Open chat", disabled: isLoading, children: [_jsx("span", { className: "yak-widget-trigger-label", children: triggerLabel }), _jsx("div", { className: "yak-widget-icon-bg", children: isLoading ? (_jsx("div", { className: "yak-widget-spinner", "aria-hidden": "true" })) : (_jsx(BrainCircuitIcon, { size: 20, className: "yak-widget-icon" })) })] })] }));
|
|
256
259
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { YakProvider } from "./YakProvider.js";
|
|
|
4
4
|
export type { YakProviderProps } from "./YakProvider.js";
|
|
5
5
|
export { YakWidget } from "./YakWidget.js";
|
|
6
6
|
export type { YakWidgetProps } from "./YakWidget.js";
|
|
7
|
-
export {
|
|
7
|
+
export type { GraphQLSchemaHandler, RESTSchemaHandler, GraphQLRequest, RESTRequest, ToolCallHandler, ToolCallEvent, SchemaSource, GraphQLSchemaSource, OpenAPISchemaSource, Theme, ThemeColors, ButtonColors, WidgetPosition, } from "@yak-io/javascript";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGrD,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yak-io/react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "React SDK for embedding yak chatbot",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"author": "Yak <support@yak.io>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/
|
|
10
|
+
"url": "https://github.com/388-labs/yak.git",
|
|
11
11
|
"directory": "packages/react"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"./package.json": "./package.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@yak-io/javascript": "0.4.
|
|
44
|
+
"@yak-io/javascript": "0.4.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -49,13 +49,15 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^24.10.4",
|
|
52
|
-
"@types/react": "^19.2.
|
|
52
|
+
"@types/react": "^19.2.14",
|
|
53
53
|
"@types/react-dom": "^19.2.0",
|
|
54
54
|
"typescript": "^5.3.0",
|
|
55
55
|
"@repo/typescript-config": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsc",
|
|
59
|
-
"check-types": "tsc --noEmit"
|
|
59
|
+
"check-types": "tsc --noEmit",
|
|
60
|
+
"lint": "biome lint ./src --fix",
|
|
61
|
+
"format": "biome format ./src --write"
|
|
60
62
|
}
|
|
61
63
|
}
|