@aarti_hurix/pepsico-ai-coach 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/README.md +29 -0
- package/dist/AiCoach.d.ts +12 -0
- package/dist/AiCoach.d.ts.map +1 -0
- package/dist/components/VoiceTextInput.d.ts +8 -0
- package/dist/components/VoiceTextInput.d.ts.map +1 -0
- package/dist/demo-ai-coach.css +1 -0
- package/dist/demo-ai-coach.js +345 -0
- package/dist/demo-ai-coach.umd.cjs +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
|
+
* Other community or team contact
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./App.scss";
|
|
2
|
+
export type InteractionPayload = {
|
|
3
|
+
interactionId: string;
|
|
4
|
+
learnerResponse: string;
|
|
5
|
+
result: "correct" | "neutral" | "incorrect";
|
|
6
|
+
};
|
|
7
|
+
type AiCoachProps = {
|
|
8
|
+
onInteraction?: (payload: InteractionPayload) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function AiCoach({ onInteraction }: AiCoachProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=AiCoach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiCoach.d.ts","sourceRoot":"","sources":["../src/AiCoach.tsx"],"names":[],"mappings":"AAEA,OAAO,YAAY,CAAC;AAOpB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;CAC7C,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACvD,CAAC;AAMF,wBAAgB,OAAO,CAAC,EAAE,aAAa,EAAE,EAAE,YAAY,2CAuDtD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './_voiceTextInput.scss';
|
|
2
|
+
type Props = {
|
|
3
|
+
onSend: (text: string) => void;
|
|
4
|
+
onReset?: () => void;
|
|
5
|
+
};
|
|
6
|
+
export default function VoiceTextInput({ onSend, onReset }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=VoiceTextInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceTextInput.d.ts","sourceRoot":"","sources":["../../src/components/VoiceTextInput.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC;AAEhC,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,2CA2EhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.main-app{padding:1rem;width:40%;justify-content:center;flex-wrap:wrap;flex-direction:column;display:flex;margin:0 auto;align-items:center}h1{text-align:center;color:#003284}.chat-window{display:flex;flex-direction:column;gap:10px;width:90%;height:62vh;padding:1rem;overflow-y:scroll}.chat-window::-webkit-scrollbar{width:4px}.chat-window::-webkit-scrollbar-thumb{background:#0000004d;border-radius:10px}.chat-window::-webkit-scrollbar-track{background:transparent}.chat-message{display:flex}.chat-message.sent{justify-content:flex-end}.chat-message.received{justify-content:flex-start}.bubble{max-width:60%;padding:10px 14px;border-radius:12px;font-size:14px}.sent .bubble{background-color:#003284;color:#fff;border-bottom-right-radius:2px}.received .bubble{background-color:#f1f1f1;color:#000;border-bottom-left-radius:2px}.voice-input{display:flex;gap:8px;margin-top:10px;width:90%}.voice-input input{flex:1;padding:10px;border-radius:6px;border:1px solid #ccc}.voice-input input:focus-within,.voice-input input:focus{border:1px solid #003284}.voice-input input:focus-visible{outline:0}.voice-input button{padding:10px 12px;border-radius:6px;border:none;background:#003284;color:#fff;cursor:pointer}.voice-input button:disabled{background:#aaa;cursor:not-allowed}.voice-input button.resetbtn{padding:0;background:transparent;font-size:1.7rem;color:#003284}.voice-input button.listening-btn{background:transparent;border:1px solid #003284}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import te, { useState as W, useRef as ne, useEffect as ae } from "react";
|
|
2
|
+
var k = { exports: {} }, v = {};
|
|
3
|
+
var F;
|
|
4
|
+
function oe() {
|
|
5
|
+
if (F) return v;
|
|
6
|
+
F = 1;
|
|
7
|
+
var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function l(i, n, a) {
|
|
9
|
+
var m = null;
|
|
10
|
+
if (a !== void 0 && (m = "" + a), n.key !== void 0 && (m = "" + n.key), "key" in n) {
|
|
11
|
+
a = {};
|
|
12
|
+
for (var c in n)
|
|
13
|
+
c !== "key" && (a[c] = n[c]);
|
|
14
|
+
} else a = n;
|
|
15
|
+
return n = a.ref, {
|
|
16
|
+
$$typeof: u,
|
|
17
|
+
type: i,
|
|
18
|
+
key: m,
|
|
19
|
+
ref: n !== void 0 ? n : null,
|
|
20
|
+
props: a
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return v.Fragment = d, v.jsx = l, v.jsxs = l, v;
|
|
24
|
+
}
|
|
25
|
+
var b = {};
|
|
26
|
+
var L;
|
|
27
|
+
function se() {
|
|
28
|
+
return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function u(e) {
|
|
30
|
+
if (e == null) return null;
|
|
31
|
+
if (typeof e == "function")
|
|
32
|
+
return e.$$typeof === K ? null : e.displayName || e.name || null;
|
|
33
|
+
if (typeof e == "string") return e;
|
|
34
|
+
switch (e) {
|
|
35
|
+
case S:
|
|
36
|
+
return "Fragment";
|
|
37
|
+
case V:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case G:
|
|
40
|
+
return "StrictMode";
|
|
41
|
+
case H:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case B:
|
|
44
|
+
return "SuspenseList";
|
|
45
|
+
case Q:
|
|
46
|
+
return "Activity";
|
|
47
|
+
}
|
|
48
|
+
if (typeof e == "object")
|
|
49
|
+
switch (typeof e.tag == "number" && console.error(
|
|
50
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
+
), e.$$typeof) {
|
|
52
|
+
case J:
|
|
53
|
+
return "Portal";
|
|
54
|
+
case z:
|
|
55
|
+
return e.displayName || "Context";
|
|
56
|
+
case q:
|
|
57
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case X:
|
|
59
|
+
var r = e.render;
|
|
60
|
+
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
+
case Z:
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
|
|
63
|
+
case A:
|
|
64
|
+
r = e._payload, e = e._init;
|
|
65
|
+
try {
|
|
66
|
+
return u(e(r));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function d(e) {
|
|
73
|
+
return "" + e;
|
|
74
|
+
}
|
|
75
|
+
function l(e) {
|
|
76
|
+
try {
|
|
77
|
+
d(e);
|
|
78
|
+
var r = !1;
|
|
79
|
+
} catch {
|
|
80
|
+
r = !0;
|
|
81
|
+
}
|
|
82
|
+
if (r) {
|
|
83
|
+
r = console;
|
|
84
|
+
var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
|
+
return t.call(
|
|
86
|
+
r,
|
|
87
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
+
o
|
|
89
|
+
), d(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function i(e) {
|
|
93
|
+
if (e === S) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === A)
|
|
95
|
+
return "<...>";
|
|
96
|
+
try {
|
|
97
|
+
var r = u(e);
|
|
98
|
+
return r ? "<" + r + ">" : "<...>";
|
|
99
|
+
} catch {
|
|
100
|
+
return "<...>";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function n() {
|
|
104
|
+
var e = j.A;
|
|
105
|
+
return e === null ? null : e.getOwner();
|
|
106
|
+
}
|
|
107
|
+
function a() {
|
|
108
|
+
return Error("react-stack-top-frame");
|
|
109
|
+
}
|
|
110
|
+
function m(e) {
|
|
111
|
+
if (N.call(e, "key")) {
|
|
112
|
+
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
|
+
if (r && r.isReactWarning) return !1;
|
|
114
|
+
}
|
|
115
|
+
return e.key !== void 0;
|
|
116
|
+
}
|
|
117
|
+
function c(e, r) {
|
|
118
|
+
function t() {
|
|
119
|
+
C || (C = !0, console.error(
|
|
120
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
|
+
r
|
|
122
|
+
));
|
|
123
|
+
}
|
|
124
|
+
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
125
|
+
get: t,
|
|
126
|
+
configurable: !0
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function p() {
|
|
130
|
+
var e = u(this.type);
|
|
131
|
+
return I[e] || (I[e] = !0, console.error(
|
|
132
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
|
+
}
|
|
135
|
+
function x(e, r, t, o, h, w) {
|
|
136
|
+
var s = t.ref;
|
|
137
|
+
return e = {
|
|
138
|
+
$$typeof: P,
|
|
139
|
+
type: e,
|
|
140
|
+
key: r,
|
|
141
|
+
props: t,
|
|
142
|
+
_owner: o
|
|
143
|
+
}, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
|
+
enumerable: !1,
|
|
145
|
+
get: p
|
|
146
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
|
+
configurable: !1,
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
writable: !0,
|
|
150
|
+
value: 0
|
|
151
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
152
|
+
configurable: !1,
|
|
153
|
+
enumerable: !1,
|
|
154
|
+
writable: !0,
|
|
155
|
+
value: null
|
|
156
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
157
|
+
configurable: !1,
|
|
158
|
+
enumerable: !1,
|
|
159
|
+
writable: !0,
|
|
160
|
+
value: h
|
|
161
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
162
|
+
configurable: !1,
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: w
|
|
166
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
|
+
}
|
|
168
|
+
function _(e, r, t, o, h, w) {
|
|
169
|
+
var s = r.children;
|
|
170
|
+
if (s !== void 0)
|
|
171
|
+
if (o)
|
|
172
|
+
if (ee(s)) {
|
|
173
|
+
for (o = 0; o < s.length; o++)
|
|
174
|
+
R(s[o]);
|
|
175
|
+
Object.freeze && Object.freeze(s);
|
|
176
|
+
} else
|
|
177
|
+
console.error(
|
|
178
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
|
+
);
|
|
180
|
+
else R(s);
|
|
181
|
+
if (N.call(r, "key")) {
|
|
182
|
+
s = u(e);
|
|
183
|
+
var E = Object.keys(r).filter(function(re) {
|
|
184
|
+
return re !== "key";
|
|
185
|
+
});
|
|
186
|
+
o = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", D[s + o] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
188
|
+
let props = %s;
|
|
189
|
+
<%s {...props} />
|
|
190
|
+
React keys must be passed directly to JSX without using spread:
|
|
191
|
+
let props = %s;
|
|
192
|
+
<%s key={someKey} {...props} />`,
|
|
193
|
+
o,
|
|
194
|
+
s,
|
|
195
|
+
E,
|
|
196
|
+
s
|
|
197
|
+
), D[s + o] = !0);
|
|
198
|
+
}
|
|
199
|
+
if (s = null, t !== void 0 && (l(t), s = "" + t), m(r) && (l(r.key), s = "" + r.key), "key" in r) {
|
|
200
|
+
t = {};
|
|
201
|
+
for (var O in r)
|
|
202
|
+
O !== "key" && (t[O] = r[O]);
|
|
203
|
+
} else t = r;
|
|
204
|
+
return s && c(
|
|
205
|
+
t,
|
|
206
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
+
), x(
|
|
208
|
+
e,
|
|
209
|
+
s,
|
|
210
|
+
t,
|
|
211
|
+
n(),
|
|
212
|
+
h,
|
|
213
|
+
w
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function R(e) {
|
|
217
|
+
y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function y(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === P;
|
|
221
|
+
}
|
|
222
|
+
var T = te, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), J = /* @__PURE__ */ Symbol.for("react.portal"), S = /* @__PURE__ */ Symbol.for("react.fragment"), G = /* @__PURE__ */ Symbol.for("react.strict_mode"), V = /* @__PURE__ */ Symbol.for("react.profiler"), q = /* @__PURE__ */ Symbol.for("react.consumer"), z = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), A = /* @__PURE__ */ Symbol.for("react.lazy"), Q = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), j = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, ee = Array.isArray, g = console.createTask ? console.createTask : function() {
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
T = {
|
|
226
|
+
react_stack_bottom_frame: function(e) {
|
|
227
|
+
return e();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var C, I = {}, Y = T.react_stack_bottom_frame.bind(
|
|
231
|
+
T,
|
|
232
|
+
a
|
|
233
|
+
)(), $ = g(i(a)), D = {};
|
|
234
|
+
b.Fragment = S, b.jsx = function(e, r, t) {
|
|
235
|
+
var o = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return _(
|
|
237
|
+
e,
|
|
238
|
+
r,
|
|
239
|
+
t,
|
|
240
|
+
!1,
|
|
241
|
+
o ? Error("react-stack-top-frame") : Y,
|
|
242
|
+
o ? g(i(e)) : $
|
|
243
|
+
);
|
|
244
|
+
}, b.jsxs = function(e, r, t) {
|
|
245
|
+
var o = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return _(
|
|
247
|
+
e,
|
|
248
|
+
r,
|
|
249
|
+
t,
|
|
250
|
+
!0,
|
|
251
|
+
o ? Error("react-stack-top-frame") : Y,
|
|
252
|
+
o ? g(i(e)) : $
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
})()), b;
|
|
256
|
+
}
|
|
257
|
+
var M;
|
|
258
|
+
function le() {
|
|
259
|
+
return M || (M = 1, process.env.NODE_ENV === "production" ? k.exports = oe() : k.exports = se()), k.exports;
|
|
260
|
+
}
|
|
261
|
+
var f = le();
|
|
262
|
+
function ce({ onSend: u, onReset: d }) {
|
|
263
|
+
const [l, i] = W(""), n = ne(null);
|
|
264
|
+
ae(() => {
|
|
265
|
+
const c = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
266
|
+
if (!c) {
|
|
267
|
+
console.warn("Speech recognition not supported");
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const p = new c();
|
|
271
|
+
p.lang = "en-US", p.continuous = !1, p.interimResults = !1, p.onresult = (x) => {
|
|
272
|
+
const _ = x.results[0][0].transcript;
|
|
273
|
+
i((R) => R ? R + " " + _ : _);
|
|
274
|
+
}, n.current = p;
|
|
275
|
+
}, []);
|
|
276
|
+
const a = () => {
|
|
277
|
+
l.trim() && (u(l.trim()), i(""));
|
|
278
|
+
}, m = () => {
|
|
279
|
+
i(""), d?.();
|
|
280
|
+
};
|
|
281
|
+
return /* @__PURE__ */ f.jsxs("div", { className: "voice-input", children: [
|
|
282
|
+
/* @__PURE__ */ f.jsx("button", { onClick: m, className: "resetbtn", title: "Restart conversation", children: "š" }),
|
|
283
|
+
/* @__PURE__ */ f.jsx(
|
|
284
|
+
"input",
|
|
285
|
+
{
|
|
286
|
+
type: "text",
|
|
287
|
+
placeholder: "Type or speak your response...",
|
|
288
|
+
value: l,
|
|
289
|
+
onChange: (c) => i(c.target.value),
|
|
290
|
+
onKeyDown: (c) => {
|
|
291
|
+
c.key === "Enter" && l.trim() && (c.preventDefault(), a());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
/* @__PURE__ */ f.jsx("button", { onClick: a, disabled: !l.trim(), children: "Send" })
|
|
296
|
+
] });
|
|
297
|
+
}
|
|
298
|
+
const U = [
|
|
299
|
+
{ sender: "jordan", text: "Iām Jordan, your AI coach." }
|
|
300
|
+
];
|
|
301
|
+
function ue({ onInteraction: u }) {
|
|
302
|
+
const [d, l] = W(U), i = (n) => {
|
|
303
|
+
l((a) => [...a, { sender: "leader", text: n }]), u?.({
|
|
304
|
+
interactionId: "DP4.2_AI_COACHING_DIALOGUE",
|
|
305
|
+
learnerResponse: n,
|
|
306
|
+
result: "neutral"
|
|
307
|
+
}), setTimeout(() => {
|
|
308
|
+
l((a) => [
|
|
309
|
+
...a,
|
|
310
|
+
{
|
|
311
|
+
sender: "jordan",
|
|
312
|
+
text: "Thanks for talking through the data calmly. That helps."
|
|
313
|
+
}
|
|
314
|
+
]);
|
|
315
|
+
}, 800);
|
|
316
|
+
};
|
|
317
|
+
return /* @__PURE__ */ f.jsxs("div", { className: "main-app", children: [
|
|
318
|
+
/* @__PURE__ */ f.jsx("h1", { children: "Pepsico AI Coach" }),
|
|
319
|
+
/* @__PURE__ */ f.jsx("div", { className: "chat-window", children: d.map((n, a) => /* @__PURE__ */ f.jsx(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
className: `chat-message ${n.sender === "leader" ? "sent" : "received"}`,
|
|
323
|
+
children: /* @__PURE__ */ f.jsxs("div", { className: "bubble", children: [
|
|
324
|
+
/* @__PURE__ */ f.jsxs("b", { children: [
|
|
325
|
+
n.sender === "leader" ? "Leader" : "Jordan",
|
|
326
|
+
":"
|
|
327
|
+
] }),
|
|
328
|
+
" ",
|
|
329
|
+
n.text
|
|
330
|
+
] })
|
|
331
|
+
},
|
|
332
|
+
a
|
|
333
|
+
)) }),
|
|
334
|
+
/* @__PURE__ */ f.jsx(
|
|
335
|
+
ce,
|
|
336
|
+
{
|
|
337
|
+
onSend: i,
|
|
338
|
+
onReset: () => l(U)
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
] });
|
|
342
|
+
}
|
|
343
|
+
export {
|
|
344
|
+
ue as AiCoach
|
|
345
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(p,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(p=typeof globalThis<"u"?globalThis:p||self,d(p.DemoAiCoach={},p.React))})(this,(function(p,d){"use strict";var k={exports:{}},v={};var N;function V(){if(N)return v;N=1;var f=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function c(i,n,o){var E=null;if(o!==void 0&&(E=""+o),n.key!==void 0&&(E=""+n.key),"key"in n){o={};for(var l in n)l!=="key"&&(o[l]=n[l])}else o=n;return n=o.ref,{$$typeof:f,type:i,key:E,ref:n!==void 0?n:null,props:o}}return v.Fragment=m,v.jsx=c,v.jsxs=c,v}var b={};var C;function $(){return C||(C=1,process.env.NODE_ENV!=="production"&&(function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case j:return"Fragment";case Z:return"Profiler";case B:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList";case oe:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case H:return"Portal";case K:return e.displayName||"Context";case Q:return(e._context.displayName||"Context")+".Consumer";case ee:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return r=e.displayName||null,r!==null?r:f(e.type)||"Memo";case g:r=e._payload,e=e._init;try{return f(e(r))}catch{}}return null}function m(e){return""+e}function c(e){try{m(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),m(e)}}function i(e){if(e===j)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var r=f(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function n(){var e=y.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function E(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function l(e,r){function t(){L||(L=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function _(){var e=f(this.type);return U[e]||(U[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function A(e,r,t,a,S,O){var s=t.ref;return e={$$typeof:M,type:e,key:r,props:t,_owner:a},(s!==void 0?s:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:_}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:O}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,t,a,S,O){var s=r.children;if(s!==void 0)if(a)if(se(s)){for(a=0;a<s.length;a++)h(s[a]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else h(s);if(F.call(r,"key")){s=f(e);var R=Object.keys(r).filter(function(ce){return ce!=="key"});a=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",G[s+a]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,a,s,R,s),G[s+a]=!0)}if(s=null,t!==void 0&&(c(t),s=""+t),E(r)&&(c(r.key),s=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return s&&l(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),A(e,s,t,n(),S,O)}function h(e){D(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?D(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function D(e){return typeof e=="object"&&e!==null&&e.$$typeof===M}var x=d,M=Symbol.for("react.transitional.element"),H=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),oe=Symbol.for("react.activity"),ae=Symbol.for("react.client.reference"),y=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,se=Array.isArray,w=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(e){return e()}};var L,U={},W=x.react_stack_bottom_frame.bind(x,o)(),J=w(i(o)),G={};b.Fragment=j,b.jsx=function(e,r,t){var a=1e4>y.recentlyCreatedOwnerStacks++;return T(e,r,t,!1,a?Error("react-stack-top-frame"):W,a?w(i(e)):J)},b.jsxs=function(e,r,t){var a=1e4>y.recentlyCreatedOwnerStacks++;return T(e,r,t,!0,a?Error("react-stack-top-frame"):W,a?w(i(e)):J)}})()),b}var I;function z(){return I||(I=1,process.env.NODE_ENV==="production"?k.exports=V():k.exports=$()),k.exports}var u=z();function X({onSend:f,onReset:m}){const[c,i]=d.useState(""),n=d.useRef(null);d.useEffect(()=>{const l=window.SpeechRecognition||window.webkitSpeechRecognition;if(!l){console.warn("Speech recognition not supported");return}const _=new l;_.lang="en-US",_.continuous=!1,_.interimResults=!1,_.onresult=A=>{const T=A.results[0][0].transcript;i(h=>h?h+" "+T:T)},n.current=_},[]);const o=()=>{c.trim()&&(f(c.trim()),i(""))},E=()=>{i(""),m?.()};return u.jsxs("div",{className:"voice-input",children:[u.jsx("button",{onClick:E,className:"resetbtn",title:"Restart conversation",children:"š"}),u.jsx("input",{type:"text",placeholder:"Type or speak your response...",value:c,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c.trim()&&(l.preventDefault(),o())}}),u.jsx("button",{onClick:o,disabled:!c.trim(),children:"Send"})]})}const Y=[{sender:"jordan",text:"Iām Jordan, your AI coach."}];function q({onInteraction:f}){const[m,c]=d.useState(Y),i=n=>{c(o=>[...o,{sender:"leader",text:n}]),f?.({interactionId:"DP4.2_AI_COACHING_DIALOGUE",learnerResponse:n,result:"neutral"}),setTimeout(()=>{c(o=>[...o,{sender:"jordan",text:"Thanks for talking through the data calmly. That helps."}])},800)};return u.jsxs("div",{className:"main-app",children:[u.jsx("h1",{children:"Pepsico AI Coach"}),u.jsx("div",{className:"chat-window",children:m.map((n,o)=>u.jsx("div",{className:`chat-message ${n.sender==="leader"?"sent":"received"}`,children:u.jsxs("div",{className:"bubble",children:[u.jsxs("b",{children:[n.sender==="leader"?"Leader":"Jordan",":"]})," ",n.text]})},o))}),u.jsx(X,{onSend:i,onReset:()=>c(Y)})]})}p.AiCoach=q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aarti_hurix/pepsico-ai-coach",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable AI coaching chat component for LMS platforms",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/demo-ai-coach.umd.cjs",
|
|
7
|
+
"module": "dist/demo-ai-coach.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"preview": "vite preview"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"react": ">=17",
|
|
20
|
+
"react-dom": ">=17"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@eslint/js": "^9.39.1",
|
|
24
|
+
"@types/node": "^24.10.1",
|
|
25
|
+
"@types/react": "^19.2.5",
|
|
26
|
+
"@types/react-dom": "^19.2.3",
|
|
27
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
28
|
+
"eslint": "^9.39.1",
|
|
29
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
30
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
31
|
+
"globals": "^16.5.0",
|
|
32
|
+
"sass": "^1.97.2",
|
|
33
|
+
"typescript": "~5.9.3",
|
|
34
|
+
"typescript-eslint": "^8.46.4",
|
|
35
|
+
"vite": "^7.2.4",
|
|
36
|
+
"vite-plugin-dts": "^4.5.4"
|
|
37
|
+
}
|
|
38
|
+
}
|