@1024pix/epreuves-components 0.5.0 → 0.6.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.
@@ -1,5 +1,5 @@
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";
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-BDNE3C4u.js";
2
+ import { p as f, L as l } from "../LLMMessage.ce-CHtRURwX.js";
3
3
  const g = {
4
4
  class: "header",
5
5
  "aria-hidden": "true"
@@ -1,28 +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 = {
1
+ import { d as m, u as i, w as p, c as o, o as e, F as d, r as u, i as g, _ as f, e as h } from "../_plugin-vue_export-helper-BDNE3C4u.js";
2
+ import { p as _, L as v } from "../LLMMessage.ce-CHtRURwX.js";
3
+ const w = {
4
4
  class: "llm-messages",
5
5
  "aria-live": "polite"
6
- }, L = /* @__PURE__ */ m({
6
+ }, y = /* @__PURE__ */ m({
7
7
  __name: "LLMMessages.ce",
8
8
  props: {
9
9
  messages: { type: Array }
10
10
  },
11
11
  setup(t) {
12
12
  const a = t;
13
- h();
14
- const e = i();
15
- function l() {
16
- e.scrollTop = e.scrollHeight;
13
+ _();
14
+ const s = i();
15
+ function r() {
16
+ s.scrollTop = s.scrollHeight;
17
17
  }
18
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, {
19
+ a.messages, r();
20
+ }), (l, B) => (e(), o("div", w, [
21
+ (e(!0), o(d, null, u(l.messages, (n, c) => (e(), g(v, {
22
22
  key: c,
23
- message: r
23
+ message: n
24
24
  }, null, 8, ["message"]))), 128))
25
25
  ]));
26
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));
27
+ }), L = ":host{height:100%;overflow:auto;scroll-behavior:smooth}@media (prefers-reduced-motion: reduce){:host{scroll-behavior:auto}}.llm-messages{display:flex;flex-direction:column;gap:24px;padding:24px}", x = /* @__PURE__ */ f(y, [["styles", [L]]]);
28
+ window.customElements.define("llm-messages", h(x));
@@ -0,0 +1,67 @@
1
+ import { d as h, f as c, g as y, c as i, o as d, b as x, a as l, h as w, F as _, r as k, t as S, _ as C, e as L } from "../_plugin-vue_export-helper-BDNE3C4u.js";
2
+ import "./llm-messages.ce.js.js";
3
+ const N = { class: "prompt-select" }, P = { class: "prompt-select__options" }, B = ["disabled", "onClick"], E = /* @__PURE__ */ h({
4
+ __name: "LLMPromptSelect.ce",
5
+ props: {
6
+ messages: { type: Array },
7
+ prompts: { type: Array },
8
+ speed: { type: Number }
9
+ },
10
+ setup(f, { expose: b }) {
11
+ const t = f, s = c(t.messages), m = c(t.prompts.map((e) => ({
12
+ ...e,
13
+ disabled: !1
14
+ }))), r = c(!1);
15
+ function g() {
16
+ s.value = t.messages, m.value = t.prompts.map((e) => ({
17
+ ...e,
18
+ disabled: !1
19
+ })), r.value = !1;
20
+ }
21
+ b({
22
+ reset: g
23
+ });
24
+ async function v(e) {
25
+ const o = t.speed === 0 || window.matchMedia("(prefers-reduced-motion: reduce)").matches;
26
+ if (s.value = [
27
+ ...s.value,
28
+ {
29
+ direction: "outbound",
30
+ content: e.prompt
31
+ },
32
+ {
33
+ direction: "inbound",
34
+ content: o ? e.response : ""
35
+ }
36
+ ], e.disabled = !0, o) return;
37
+ const a = s.value.length - 1;
38
+ r.value = !0;
39
+ const n = e.response.split(/(\s+|<[^>]+>)/);
40
+ for (const p of n)
41
+ await new Promise((u) => {
42
+ setTimeout(u, t.speed ?? 20);
43
+ }), s.value = [...s.value], s.value[a].content += p;
44
+ r.value = !1;
45
+ }
46
+ return (e, o) => {
47
+ const a = y("llm-messages");
48
+ return d(), i(_, null, [
49
+ x(a, { messages: s.value }, null, 8, ["messages"]),
50
+ l("div", N, [
51
+ o[0] || (o[0] = l("p", { class: "prompt-select__label" }, [
52
+ w(" Sélectionner un des prompts "),
53
+ l("span", { class: "sr-only" }, "  une fois sélectionnés, les prompts ne sont plus disponibles. ")
54
+ ], -1)),
55
+ l("div", P, [
56
+ (d(!0), i(_, null, k(m.value, (n, p) => (d(), i("button", {
57
+ key: p,
58
+ disabled: n.disabled || r.value,
59
+ onClick: (u) => v(n)
60
+ }, S(n.prompt), 9, B))), 128))
61
+ ])
62
+ ])
63
+ ], 64);
64
+ };
65
+ }
66
+ }), M = ".sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}llm-messages{display:block;height:400px}.prompt-select{border-top:solid 1px grey;padding:24px}.prompt-select__label{margin-top:0;font-weight:700}.prompt-select__options{display:flex;gap:1rem;justify-content:left;padding-bottom:1rem;flex-wrap:wrap}.prompt-select__options>button{padding:.5rem 1.5rem;border:none;background:#cec3f4;border-radius:5px}.prompt-select__options>button:hover:not(:disabled){background:#9a8dc7;color:#fff;cursor:pointer}.prompt-select__options>button:disabled{cursor:not-allowed}", V = /* @__PURE__ */ C(E, [["styles", [M]]]);
67
+ window.customElements.define("llm-prompt-select", L(V));
@@ -1,4 +1,4 @@
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";
1
+ import { _ as f, c as i, o as t, d as x, f as D, p as v, q as S, n as h, v as u, a as p, h as b, t as _, b as $, F as y, r as w, i as M, e as A } from "../_plugin-vue_export-helper-BDNE3C4u.js";
2
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
3
  function E(n, s) {
4
4
  return t(), i("div", V);
@@ -45,7 +45,7 @@ const F = /* @__PURE__ */ f(B, [["render", E], ["styles", [C]]]), z = ["part"],
45
45
  class: h(["message__content", { "hidden-state": s.value !== "visible" }]),
46
46
  part: `message ${e.message.direction}`
47
47
  }, [
48
- (t(!0), i(y, null, k(m.value, (d, o) => (t(), i(y, { key: o }, [
48
+ (t(!0), i(y, null, w(m.value, (d, o) => (t(), i(y, { key: o }, [
49
49
  o > 0 ? (t(), i("br", j)) : u("", !0),
50
50
  b(" " + _(d), 1)
51
51
  ], 64))), 128))
@@ -70,8 +70,8 @@ const F = /* @__PURE__ */ f(B, [["render", E], ["styles", [C]]]), z = ["part"],
70
70
  message: l,
71
71
  startAnimation: c,
72
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 }];
73
+ } = e.at(-1), k = a.direction !== l.direction || a.userName !== l.userName, N = c + g + s;
74
+ return [...e, { message: a, displaySender: k, startAnimation: N, animationDuration: o }];
75
75
  },
76
76
  []
77
77
  )
@@ -81,7 +81,7 @@ const F = /* @__PURE__ */ f(B, [["render", E], ["styles", [C]]]), z = ["part"],
81
81
  }
82
82
  return (e, a) => (t(), i("figure", G, [
83
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, {
84
+ (t(!0), i(y, null, w(m.value, ({ message: d, displaySender: o, startAnimation: l, animationDuration: c }, g) => (t(), M(P, {
85
85
  message: d,
86
86
  "start-animation": l,
87
87
  "animation-duration": c,
@@ -1,4 +1,4 @@
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";
1
+ import { d as y, f as w, j as C, c as l, o as n, k as p, l as h, n as x, a as k, m as $, t as v, _ as b, p as g, s as N, F as P, r as B, i as S, e as z } from "../_plugin-vue_export-helper-BDNE3C4u.js";
2
2
  function j(c, t = L) {
3
3
  const a = [...c];
4
4
  for (let o = a.length - 1; o > 0; o--) {
@@ -38,9 +38,9 @@ const E = ["aria-checked", "tabindex"], I = { key: 0 }, q = /* @__PURE__ */ y({
38
38
  tabindex: e.focusable ? 0 : -1,
39
39
  onClick: i[0] || (i[0] = h((r) => e.$emit("check"), ["stop"])),
40
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"]))
41
+ i[1] || (i[1] = p(h((r) => e.$emit("check"), ["stop", "prevent"]), ["enter", "space"])),
42
+ i[2] || (i[2] = p(h((r) => e.$emit("checkPrevious"), ["stop", "prevent"]), ["up", "left"])),
43
+ i[3] || (i[3] = p(h((r) => e.$emit("checkNext"), ["stop", "prevent"]), ["down", "right"]))
44
44
  ]
45
45
  }, [
46
46
  e.choice.image ? (n(), l("figure", I, [
@@ -70,7 +70,7 @@ const E = ["aria-checked", "tabindex"], I = { key: 0 }, q = /* @__PURE__ */ y({
70
70
  },
71
71
  emits: ["answer"],
72
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]);
73
+ const a = t, o = g(() => c.hideChoicesName ? "sr-only" : ""), e = g(() => c.orderChoices ? c.choices : j(c.choices)), i = N(), r = g(() => i.value ?? e.value[0]);
74
74
  function u(s) {
75
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
76
  }
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./components/message-conversation.ce.js.js";
2
2
  import "./components/llm-messages.ce.js.js";
3
3
  import "./components/llm-compare-messages.ce.js.js";
4
+ import "./components/llm-prompt-select.ce.js.js";
4
5
  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.5.0",
3
+ "version": "0.6.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",