@1024pix/epreuves-components 0.4.1 → 0.5.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.
@@ -0,0 +1,61 @@
1
+ import { d as m, c as a, o as n, a as s, t, F as i, r as d, b as r, _ as p, e as u } from "../_plugin-vue_export-helper-rf--DmCY.js";
2
+ import { p as f, L as l } from "../LLMMessage.ce-CklO8QgD.js";
3
+ const g = {
4
+ class: "header",
5
+ "aria-hidden": "true"
6
+ }, h = { class: "sr-only" }, v = { class: "llm-compare-messages" }, _ = { class: "conversation1" }, y = { class: "conversation2" }, b = { class: "conversation1" }, w = {
7
+ "aria-hidden": "true",
8
+ class: "conversation2"
9
+ }, x = /* @__PURE__ */ m({
10
+ __name: "LLMCompareMessages.ce",
11
+ props: {
12
+ conversation1: { type: Object },
13
+ conversation2: { type: Object },
14
+ userName: { type: String },
15
+ messages: { type: Array }
16
+ },
17
+ setup(N) {
18
+ return f(), (e, C) => (n(), a(i, null, [
19
+ s("div", g, [
20
+ s("p", null, t(e.conversation1.title), 1),
21
+ s("p", null, t(e.conversation2.title), 1)
22
+ ]),
23
+ s("p", h, " Comparaison entre la conversation " + t(e.conversation1.title) + " et la conversation " + t(e.conversation2.title), 1),
24
+ s("div", v, [
25
+ (n(!0), a(i, null, d(e.messages, (o, c) => (n(), a("div", {
26
+ key: c,
27
+ class: "llm-compare-messages__row"
28
+ }, [
29
+ Array.isArray(o) ? (n(), a(i, { key: 0 }, [
30
+ s("div", _, [
31
+ r(l, {
32
+ message: o[0],
33
+ name: e.conversation1.llmName
34
+ }, null, 8, ["message", "name"])
35
+ ]),
36
+ s("div", y, [
37
+ r(l, {
38
+ message: o[1],
39
+ name: e.conversation2.llmName
40
+ }, null, 8, ["message", "name"])
41
+ ])
42
+ ], 64)) : (n(), a(i, { key: 1 }, [
43
+ s("div", b, [
44
+ r(l, {
45
+ message: o,
46
+ name: e.userName
47
+ }, null, 8, ["message", "name"])
48
+ ]),
49
+ s("div", w, [
50
+ r(l, {
51
+ message: o,
52
+ name: e.userName
53
+ }, null, 8, ["message", "name"])
54
+ ])
55
+ ], 64))
56
+ ]))), 128))
57
+ ])
58
+ ], 64));
59
+ }
60
+ }), L = '*{box-sizing:border-box}:host{display:flex;flex-direction:column}.llm-compare-messages{display:flex;flex-direction:column;padding:24px;gap:24px;position:relative;height:100%;overflow:auto}.llm-compare-messages:after{content:"";position:absolute;height:100%;top:0;left:50%;border-left:dashed 1px grey}.llm-compare-messages__row{display:flex;flex-direction:row;justify-content:space-between}.llm-compare-messages__row>div{display:flex;flex-direction:column;width:calc(50% - 12px)}.conversation1 .inbound .bubble{background:#e9f4c3}.header{display:flex}.header p{background:#e6eaf2;display:flex;width:50%;justify-content:center;align-items:center;padding:1rem;margin:0;font-size:1.2rem;font-weight:700}.header p:first-child{background:#e9f4c3}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}', k = /* @__PURE__ */ p(x, [["styles", [L]]]);
61
+ window.customElements.define("llm-compare-messages", u(k));
@@ -0,0 +1,28 @@
1
+ import { d as m, u as i, w as p, c as o, o as s, F as g, r as d, f, _ as u, e as _ } from "../_plugin-vue_export-helper-rf--DmCY.js";
2
+ import { p as h, L as w } from "../LLMMessage.ce-CklO8QgD.js";
3
+ const y = {
4
+ class: "llm-messages",
5
+ "aria-live": "polite"
6
+ }, L = /* @__PURE__ */ m({
7
+ __name: "LLMMessages.ce",
8
+ props: {
9
+ messages: { type: Array }
10
+ },
11
+ setup(t) {
12
+ const a = t;
13
+ h();
14
+ const e = i();
15
+ function l() {
16
+ e.scrollTop = e.scrollHeight;
17
+ }
18
+ return p(async () => {
19
+ a.messages, l();
20
+ }), (n, B) => (s(), o("div", y, [
21
+ (s(!0), o(g, null, d(n.messages, (r, c) => (s(), f(w, {
22
+ key: c,
23
+ message: r
24
+ }, null, 8, ["message"]))), 128))
25
+ ]));
26
+ }
27
+ }), v = ":host{height:100%;overflow:auto;scroll-behavior:smooth}.llm-messages{display:flex;flex-direction:column;gap:24px;padding:24px}", x = /* @__PURE__ */ u(L, [["styles", [v]]]);
28
+ window.customElements.define("llm-messages", _(x));
@@ -0,0 +1,95 @@
1
+ import { _ as f, c as i, o as t, d as x, g as D, k as v, l as S, n as h, p as u, a as p, q as b, t as _, b as $, F as y, r as k, f as M, e as A } from "../_plugin-vue_export-helper-rf--DmCY.js";
2
+ const C = ".loader{width:8px;aspect-ratio:1;border-radius:50%;animation:l5 1s infinite linear alternate;transform:translate(100%)}@keyframes l5{0%{box-shadow:13px 0 #000,-13px 0 #0002;background:#000}33%{box-shadow:13px 0 #000,-13px 0 #0002;background:#0002}66%{box-shadow:13px 0 #0002,-13px 0 #000;background:#0002}to{box-shadow:13px 0 #0002,-13px 0 #000;background:#000}}@media (prefers-reduced-motion: reduce){.loader{display:none}}", B = {}, V = { class: "loader" };
3
+ function E(n, s) {
4
+ return t(), i("div", V);
5
+ }
6
+ const F = /* @__PURE__ */ f(B, [["render", E], ["styles", [C]]]), z = ["part"], L = {
7
+ key: 1,
8
+ class: "message__loader message__content",
9
+ "aria-hidden": "true"
10
+ }, T = ["part"], j = { key: 0 }, q = /* @__PURE__ */ x({
11
+ __name: "Message.ce",
12
+ props: {
13
+ displaySender: { type: Boolean, default: !0 },
14
+ message: { type: Object },
15
+ startAnimation: { type: Number },
16
+ animationDuration: { type: Number },
17
+ loadingDuration: { type: Number }
18
+ },
19
+ setup(n) {
20
+ const s = D("hidden"), m = v(() => n.message.content.split(`
21
+ `));
22
+ function r(e) {
23
+ return new Promise((a) => setTimeout(a, e));
24
+ }
25
+ return S(async () => {
26
+ await r(n.startAnimation), s.value = "loading", await r(n.loadingDuration), s.value = "visible", await r(n.animationDuration);
27
+ }), (e, a) => (t(), i("div", {
28
+ class: h(["message", [
29
+ `message--${e.message.direction}`,
30
+ { "hidden-state": s.value === "hidden" }
31
+ ]])
32
+ }, [
33
+ e.displaySender ? (t(), i("p", {
34
+ key: 0,
35
+ class: "message__sender",
36
+ part: `sender ${e.message.direction}`
37
+ }, [
38
+ a[0] || (a[0] = p("span", { class: "sr-only" }, "Message de ", -1)),
39
+ b(_(e.message.userName), 1)
40
+ ], 8, z)) : u("", !0),
41
+ s.value === "loading" ? (t(), i("div", L, [
42
+ $(F)
43
+ ])) : u("", !0),
44
+ p("p", {
45
+ class: h(["message__content", { "hidden-state": s.value !== "visible" }]),
46
+ part: `message ${e.message.direction}`
47
+ }, [
48
+ (t(!0), i(y, null, k(m.value, (d, o) => (t(), i(y, { key: o }, [
49
+ o > 0 ? (t(), i("br", j)) : u("", !0),
50
+ b(" " + _(d), 1)
51
+ ], 64))), 128))
52
+ ], 10, T)
53
+ ], 2));
54
+ }
55
+ }), O = ".message{max-width:80%;position:relative}.message--incoming{align-self:start}.message--incoming .message__sender{padding-left:10px}.message--incoming .message__loader{left:10px}.message--incoming .message__content{background-color:#e8e8e8}.message--outgoing{align-self:end}.message--outgoing .message__sender{padding-right:10px;text-align:right}.message--outgoing .message__loader{right:10px}.message--outgoing .message__content{background-color:#d1eaff}.message__sender{color:#444;font-size:.8rem;font-weight:700;margin:0}.message__loader{position:absolute;width:24px}.message__content{border-radius:16px;margin:0;padding:10px 14px}.message__content:not(.hidden-state){animation:fade .3s ease-in-out both}.hidden-state{visibility:hidden}@keyframes fade{0%{opacity:0}to{opacity:1}}@media (prefers-reduced-motion: reduce){.message__content:not(.hidden-state){animation:none}.message__loader{display:none}.hidden-state{visibility:visible}}", P = /* @__PURE__ */ f(q, [["styles", [O]]]), G = { part: "conversation" }, H = { class: "sr-only" }, I = /* @__PURE__ */ x({
56
+ __name: "MessageConversation.ce",
57
+ props: {
58
+ title: { default: "Conversation par messages", type: String },
59
+ messages: { type: Array },
60
+ animationSpeed: { default: 20, type: Number }
61
+ },
62
+ setup(n) {
63
+ const s = 50 * n.animationSpeed, m = v(
64
+ () => n.messages.reduce(
65
+ (e, a, d) => {
66
+ const o = r(a);
67
+ if (d === 0)
68
+ return [{ message: a, displaySender: !0, startAnimation: 0, animationDuration: o }];
69
+ const {
70
+ message: l,
71
+ startAnimation: c,
72
+ animationDuration: g
73
+ } = e.at(-1), w = a.direction !== l.direction || a.userName !== l.userName, N = c + g + s;
74
+ return [...e, { message: a, displaySender: w, startAnimation: N, animationDuration: o }];
75
+ },
76
+ []
77
+ )
78
+ );
79
+ function r(e) {
80
+ return e.content.length * n.animationSpeed;
81
+ }
82
+ return (e, a) => (t(), i("figure", G, [
83
+ p("figcaption", H, _(e.title), 1),
84
+ (t(!0), i(y, null, k(m.value, ({ message: d, displaySender: o, startAnimation: l, animationDuration: c }, g) => (t(), M(P, {
85
+ message: d,
86
+ "start-animation": l,
87
+ "animation-duration": c,
88
+ "loading-duration": s,
89
+ "display-sender": o,
90
+ key: g
91
+ }, null, 8, ["message", "start-animation", "animation-duration", "display-sender"]))), 128))
92
+ ]));
93
+ }
94
+ }), J = "figure{background-color:#fff;border-radius:16px;display:flex;flex-direction:column;gap:8px;margin:0;padding:16px}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}", K = /* @__PURE__ */ f(I, [["styles", [J]]]);
95
+ window.customElements.define("message-conversation", A(K));
@@ -0,0 +1,97 @@
1
+ import { d as y, g as w, h as C, c as l, o as n, i as g, j as h, n as x, a as k, m as $, t as v, _ as b, k as p, s as N, F as P, r as B, f as S, e as z } from "../_plugin-vue_export-helper-rf--DmCY.js";
2
+ function j(c, t = L) {
3
+ const a = [...c];
4
+ for (let o = a.length - 1; o > 0; o--) {
5
+ const e = t() % (o + 1);
6
+ [a[o], a[e]] = [a[e], a[o]];
7
+ }
8
+ return a;
9
+ }
10
+ function L() {
11
+ return Math.floor(Math.random() * 2 ** 32);
12
+ }
13
+ const E = ["aria-checked", "tabindex"], I = { key: 0 }, q = /* @__PURE__ */ y({
14
+ __name: "ImageChoice.ce",
15
+ props: {
16
+ choice: { type: Object },
17
+ maxChoicesPerLine: { type: Number },
18
+ imageClass: { type: String },
19
+ nameClass: { type: String },
20
+ checked: { type: Boolean },
21
+ focusable: { type: Boolean }
22
+ },
23
+ emits: ["check", "checkNext", "checkPrevious"],
24
+ setup(c) {
25
+ const t = c, a = w();
26
+ C(() => {
27
+ var e;
28
+ t.checked && ((e = a.value) == null || e.focus());
29
+ });
30
+ const o = `image-choice-${(t.choice.response ?? t.choice.name).replace(/[^\w\-_:.]/g, "")}`;
31
+ return (e, i) => (n(), l("li", {
32
+ ref_key: "el",
33
+ ref: a,
34
+ role: "radio",
35
+ class: x(["image-choice", `image-choice--max${t.maxChoicesPerLine}`]),
36
+ "aria-labelledby": o,
37
+ "aria-checked": e.checked,
38
+ tabindex: e.focusable ? 0 : -1,
39
+ onClick: i[0] || (i[0] = h((r) => e.$emit("check"), ["stop"])),
40
+ onKeydown: [
41
+ i[1] || (i[1] = g(h((r) => e.$emit("check"), ["stop", "prevent"]), ["enter", "space"])),
42
+ i[2] || (i[2] = g(h((r) => e.$emit("checkPrevious"), ["stop", "prevent"]), ["up", "left"])),
43
+ i[3] || (i[3] = g(h((r) => e.$emit("checkNext"), ["stop", "prevent"]), ["down", "right"]))
44
+ ]
45
+ }, [
46
+ e.choice.image ? (n(), l("figure", I, [
47
+ k("img", $(e.choice.image, {
48
+ class: e.imageClass,
49
+ alt: ""
50
+ }), null, 16),
51
+ k("figcaption", {
52
+ class: x(e.nameClass),
53
+ id: o
54
+ }, v(e.choice.name), 3)
55
+ ])) : (n(), l("span", {
56
+ key: 1,
57
+ id: o
58
+ }, v(e.choice.name), 1))
59
+ ], 42, E));
60
+ }
61
+ }), M = 'ul,li{padding:0;margin:0}li{list-style:none}.image-choice{display:flex;position:relative;flex-direction:column;align-items:center;justify-content:center;margin:1em;border:solid 2px #c1c7d0;border-radius:10px;background:#fff;width:calc(20% - 2em);min-width:120px}.image-choice--max4{width:calc(25% - 2em);min-width:175px}.image-choice--max3{width:calc(33% - 2em)}.image-choice--max2{width:calc(50% - 2em);min-width:300px}.image-choice--max1{width:calc(100% - 4em);min-width:300px}.image-choice:hover{cursor:pointer;box-shadow:0 3px 10px #0000001a;transform:scale(1.04);transition:transform ease-in .1s}.image-choice:focus{outline:none;box-shadow:5px 5px #ffbe00,-5px 5px #ffbe00,5px -5px #ffbe00,-5px -5px #ffbe00}.image-choice[aria-checked=true]{border-color:#3d68ff}.image-choice[aria-checked=true]:after{content:"";position:absolute;width:100%;height:100%;background:#3d68ff4d;border-radius:10px;z-index:3}.image-choice figure{width:100%;padding:0 10px;margin:3px;text-align:center}.image-choice figure img{max-width:100%;height:auto}.image-choice figure img.icon{max-height:100px;width:auto}.image-choice figure img.medium{max-width:50%;height:auto}.image-choice figure figcaption{margin:1ex}', A = /* @__PURE__ */ b(q, [["styles", [M]]]), F = ["aria-label"], K = /* @__PURE__ */ y({
62
+ __name: "QCUImage.ce",
63
+ props: {
64
+ choices: { type: Array },
65
+ maxChoicesPerLine: { default: 5, type: Number },
66
+ name: { type: String },
67
+ hideChoicesName: { type: Boolean },
68
+ orderChoices: { type: Boolean },
69
+ imageChoicesSize: { default: "icon", type: String }
70
+ },
71
+ emits: ["answer"],
72
+ setup(c, { emit: t }) {
73
+ const a = t, o = p(() => c.hideChoicesName ? "sr-only" : ""), e = p(() => c.orderChoices ? c.choices : j(c.choices)), i = N(), r = p(() => i.value ?? e.value[0]);
74
+ function u(s) {
75
+ s === -1 ? i.value = e.value[e.value.length - 1] : s === e.value.length ? i.value = e.value[0] : i.value = e.value[s], a("answer", i.value.response ?? i.value.name);
76
+ }
77
+ return (s, R) => (n(), l("ul", {
78
+ role: "radiogroup",
79
+ class: "qcu-image",
80
+ "aria-label": s.name
81
+ }, [
82
+ (n(!0), l(P, null, B(e.value, (d, m) => (n(), S(A, {
83
+ choice: d,
84
+ "max-choices-per-line": s.maxChoicesPerLine,
85
+ key: m,
86
+ "name-class": o.value,
87
+ "image-class": c.imageChoicesSize,
88
+ checked: d === i.value,
89
+ focusable: d === r.value,
90
+ onCheck: (f) => u(m),
91
+ onCheckNext: (f) => u(m + 1),
92
+ onCheckPrevious: (f) => u(m - 1)
93
+ }, null, 8, ["choice", "max-choices-per-line", "name-class", "image-class", "checked", "focusable", "onCheck", "onCheckNext", "onCheckPrevious"]))), 128))
94
+ ], 8, F));
95
+ }
96
+ }), O = "*{box-sizing:border-box}.qcu-image{display:flex;width:100%;flex-wrap:wrap;justify-content:space-around;font-size:110%;font-family:Open Sans,Arial,sans-serif}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}", Q = /* @__PURE__ */ b(K, [["styles", [O]]]);
97
+ window.customElements.define("qcu-image", z(Q));
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import "./components/message-conversation.js";
2
- import "./components/qcu-image.js";
3
- import "./components/cartes-a-retourner.js";
1
+ import "./components/message-conversation.ce.js.js";
2
+ import "./components/llm-messages.ce.js.js";
3
+ import "./components/llm-compare-messages.ce.js.js";
4
+ import "./components/qcu-image.ce.js.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/epreuves-components",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "A collection of interactive components to be used in Pix challenges or modules",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",