@1024pix/epreuves-components 0.2.0 → 0.3.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,4 +1,4 @@
1
- import { d as i, r as l, c as n, o as a, n as p, a as t, b as c, F as u, e as f, f as m, _ as g, g as _ } from "../_plugin-vue_export-helper-DhEI-a9q.js";
1
+ import { d as i, r as l, c as n, o as a, n as p, a as t, b as c, F as u, e as f, f as m, _ as g, g as _ } from "../_plugin-vue_export-helper-ne_y2ta8.js";
2
2
  const v = { class: "card-inner" }, y = /* @__PURE__ */ i({
3
3
  __name: "CarteARetourner",
4
4
  props: {
@@ -1,33 +1,93 @@
1
- import { d as r, c as o, o as s, n as m, a as n, h as p, t, F as d, e as l, f as _, _ as u, g as f } from "../_plugin-vue_export-helper-DhEI-a9q.js";
2
- const h = { class: "message__sender" }, x = { class: "message__content" }, y = /* @__PURE__ */ r({
1
+ import { _ as b, c as t, o as a, d as v, r as $, h as k, i as A, n as y, j as p, a as _, k as x, t as f, l as N, F as h, e as w, f as C, g as M } from "../_plugin-vue_export-helper-ne_y2ta8.js";
2
+ const B = {}, V = { class: "loader" };
3
+ function E(o, n) {
4
+ return a(), t("div", V);
5
+ }
6
+ const F = /* @__PURE__ */ b(B, [["render", E]]), j = ["part"], z = {
7
+ key: 1,
8
+ class: "message__loader message__content",
9
+ "aria-hidden": "true"
10
+ }, L = ["part"], T = { key: 0 }, O = /* @__PURE__ */ v({
3
11
  __name: "Message",
4
12
  props: {
5
- message: {}
13
+ displaySender: { type: Boolean, default: !0 },
14
+ message: {},
15
+ startAnimation: {},
16
+ animationDuration: {},
17
+ loadingDuration: {}
6
18
  },
7
- setup(i) {
8
- return (e, a) => (s(), o("article", {
9
- class: m(["message", `message--${e.message.direction}`])
19
+ setup(o) {
20
+ const n = $("hidden"), c = k(() => o.message.content.split(`
21
+ `));
22
+ function d(s) {
23
+ return new Promise((e) => setTimeout(e, s));
24
+ }
25
+ return A(async () => {
26
+ await d(o.startAnimation), n.value = "loading", await d(o.loadingDuration), n.value = "visible", await d(o.animationDuration);
27
+ }), (s, e) => (a(), t("div", {
28
+ class: y(["message", [
29
+ `message--${s.message.direction}`,
30
+ { "hidden-state": n.value === "hidden" }
31
+ ]])
10
32
  }, [
11
- n("p", h, [
12
- a[0] || (a[0] = n("span", { class: "sr-only" }, "Message de ", -1)),
13
- p(t(e.message.userName), 1)
14
- ]),
15
- n("p", x, t(e.message.content), 1)
33
+ s.displaySender ? (a(), t("p", {
34
+ key: 0,
35
+ class: "message__sender",
36
+ part: `sender ${s.message.direction}`
37
+ }, [
38
+ e[0] || (e[0] = _("span", { class: "sr-only" }, "Message de ", -1)),
39
+ x(f(s.message.userName), 1)
40
+ ], 8, j)) : p("", !0),
41
+ n.value === "loading" ? (a(), t("div", z, [
42
+ N(F)
43
+ ])) : p("", !0),
44
+ _("p", {
45
+ class: y(["message__content", { "hidden-state": n.value !== "visible" }]),
46
+ part: `message ${s.message.direction}`
47
+ }, [
48
+ (a(!0), t(h, null, w(c.value, (i, r) => (a(), t(h, { key: r }, [
49
+ r > 0 ? (a(), t("br", T)) : p("", !0),
50
+ x(" " + f(i), 1)
51
+ ], 64))), 128))
52
+ ], 10, L)
16
53
  ], 2));
17
54
  }
18
- }), b = { part: "conversation" }, w = { class: "sr-only" }, k = /* @__PURE__ */ r({
55
+ }), P = { part: "conversation" }, q = { class: "sr-only" }, G = /* @__PURE__ */ v({
19
56
  __name: "MessageConversation.ce",
20
57
  props: {
21
58
  props: { type: Object }
22
59
  },
23
- setup(i) {
24
- return (e, a) => (s(), o("figure", b, [
25
- n("figcaption", w, t(e.props.title ?? "Conversation par messages"), 1),
26
- (s(!0), o(d, null, l(e.props.messages, (g, c) => (s(), _(y, {
27
- message: g,
28
- key: c
29
- }, null, 8, ["message"]))), 128))
60
+ setup(o) {
61
+ const n = o.props.animationSpeed ?? 20, c = 50 * n, d = k(
62
+ () => o.props.messages.reduce(
63
+ (e, i, r) => {
64
+ const l = s(i);
65
+ if (r === 0)
66
+ return [{ message: i, displaySender: !0, startAnimation: 0, animationDuration: l }];
67
+ const {
68
+ message: m,
69
+ startAnimation: g,
70
+ animationDuration: u
71
+ } = e.at(-1), D = i.direction !== m.direction || i.userName !== m.userName, S = g + u + c;
72
+ return [...e, { message: i, displaySender: D, startAnimation: S, animationDuration: l }];
73
+ },
74
+ []
75
+ )
76
+ );
77
+ function s(e) {
78
+ return e.content.length * n;
79
+ }
80
+ return (e, i) => (a(), t("figure", P, [
81
+ _("figcaption", q, f(e.props.title ?? "Conversation par messages"), 1),
82
+ (a(!0), t(h, null, w(d.value, ({ message: r, displaySender: l, startAnimation: m, animationDuration: g }, u) => (a(), C(O, {
83
+ message: r,
84
+ "start-animation": m,
85
+ "animation-duration": g,
86
+ "loading-duration": c,
87
+ "display-sender": l,
88
+ key: u
89
+ }, null, 8, ["message", "start-animation", "animation-duration", "display-sender"]))), 128))
30
90
  ]));
31
91
  }
32
- }), v = "figure{background-color:#fff;border-radius:16px;display:flex;flex-direction:column;gap:8px;margin:0;padding:16px}.message{max-width:80%}.message--incoming{align-self:start}.message--incoming .message__sender{padding-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__content{background-color:#d1eaff}.message__sender{color:#444;font-size:.8rem;font-weight:700;margin:0}.message__content{border-radius:16px;margin:0;padding:10px 14px}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}", C = /* @__PURE__ */ u(k, [["styles", [v]]]);
33
- window.customElements.define("message-conversation", f(C));
92
+ }), H = "figure{background-color:#fff;border-radius:16px;display:flex;flex-direction:column;gap:8px;margin:0;padding:16px}.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}.loader{width:8px;aspect-ratio:1;border-radius:50%;animation:l5 1s infinite linear alternate;transform:translate(100%)}.hidden-state{visibility:hidden}.sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes fade{0%{opacity:0}to{opacity:1}}@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){.message__content:not(.hidden-state){animation:none}.loader,.message__loader{display:none}.hidden-state{visibility:visible}}", I = /* @__PURE__ */ b(G, [["styles", [H]]]);
93
+ window.customElements.define("message-conversation", M(I));
@@ -1,5 +1,5 @@
1
- import { d as b, r as _, w as y, c as u, o as r, i as g, j as p, n as v, a as k, m as q, t as w, k as m, s as $, F as P, e as B, f as N, _ as j, g as z } from "../_plugin-vue_export-helper-DhEI-a9q.js";
2
- function L(o, n = E) {
1
+ import { d as b, r as _, w as y, c as h, o as r, m as g, p, n as v, a as k, q, t as w, h as m, s as $, F as P, e as B, f as N, _ as z, g as L } from "../_plugin-vue_export-helper-ne_y2ta8.js";
2
+ function j(o, n = E) {
3
3
  const i = [...o];
4
4
  for (let a = i.length - 1; a > 0; a--) {
5
5
  const e = n() % (a + 1);
@@ -28,7 +28,7 @@ const M = ["aria-checked", "tabindex"], Q = { key: 0 }, S = /* @__PURE__ */ b({
28
28
  n.checked && ((e = i.value) == null || e.focus());
29
29
  });
30
30
  const a = `qcu-image-choice-${(n.choice.response ?? n.choice.name).replace(/[^\w\-_:.]/g, "")}`;
31
- return (e, s) => (r(), u("li", {
31
+ return (e, s) => (r(), h("li", {
32
32
  ref_key: "el",
33
33
  ref: i,
34
34
  role: "radio",
@@ -43,7 +43,7 @@ const M = ["aria-checked", "tabindex"], Q = { key: 0 }, S = /* @__PURE__ */ b({
43
43
  s[3] || (s[3] = g(p((c) => e.$emit("checkNext"), ["stop", "prevent"]), ["down", "right"]))
44
44
  ]
45
45
  }, [
46
- e.choice.image ? (r(), u("figure", Q, [
46
+ e.choice.image ? (r(), h("figure", Q, [
47
47
  k("img", q(e.choice.image, {
48
48
  class: e.imageClass,
49
49
  alt: ""
@@ -52,7 +52,7 @@ const M = ["aria-checked", "tabindex"], Q = { key: 0 }, S = /* @__PURE__ */ b({
52
52
  class: v(e.nameClass),
53
53
  id: a
54
54
  }, w(e.choice.name), 3)
55
- ])) : (r(), u("span", {
55
+ ])) : (r(), h("span", {
56
56
  key: 1,
57
57
  id: a
58
58
  }, w(e.choice.name), 1))
@@ -65,28 +65,28 @@ const M = ["aria-checked", "tabindex"], Q = { key: 0 }, S = /* @__PURE__ */ b({
65
65
  },
66
66
  emits: ["answer"],
67
67
  setup(o, { emit: n }) {
68
- const i = n, a = m(() => o.props.maxChoicesPerLine ?? 5), e = m(() => o.props.hideChoicesName ? "sr-only" : ""), s = m(() => o.props.imageChoicesSize ?? "icon"), c = m(() => o.props.orderChoices ? o.props.choices : L(o.props.choices)), t = $(), C = m(() => t.value ?? c.value[0]);
68
+ const i = n, a = m(() => o.props.maxChoicesPerLine ?? 5), e = m(() => o.props.hideChoicesName ? "sr-only" : ""), s = m(() => o.props.imageChoicesSize ?? "icon"), c = m(() => o.props.orderChoices ? o.props.choices : j(o.props.choices)), t = $(), C = m(() => t.value ?? c.value[0]);
69
69
  function d(l) {
70
70
  l === -1 ? t.value = c.value[c.value.length - 1] : l === c.value.length ? t.value = c.value[0] : t.value = c.value[l], i("answer", t.value.response ?? t.value.name);
71
71
  }
72
- return (l, O) => (r(), u("ul", {
72
+ return (l, O) => (r(), h("ul", {
73
73
  role: "radiogroup",
74
74
  class: "qcu-image",
75
75
  "aria-label": l.props.name
76
76
  }, [
77
- (r(!0), u(P, null, B(c.value, (f, h) => (r(), N(S, {
77
+ (r(!0), h(P, null, B(c.value, (f, u) => (r(), N(S, {
78
78
  choice: f,
79
79
  "max-choices-per-line": a.value,
80
- key: h,
80
+ key: u,
81
81
  "name-class": e.value,
82
82
  "image-class": s.value,
83
83
  checked: f === t.value,
84
84
  focusable: f === C.value,
85
- onCheck: (x) => d(h),
86
- onCheckNext: (x) => d(h + 1),
87
- onCheckPrevious: (x) => d(h - 1)
85
+ onCheck: (x) => d(u),
86
+ onCheckNext: (x) => d(u + 1),
87
+ onCheckPrevious: (x) => d(u - 1)
88
88
  }, null, 8, ["choice", "max-choices-per-line", "name-class", "image-class", "checked", "focusable", "onCheck", "onCheckNext", "onCheckPrevious"]))), 128))
89
89
  ], 8, U));
90
90
  }
91
- }), I = '*{box-sizing:border-box}ul,li{padding:0;margin:0}li{list-style:none}.qcu-image{display:flex;width:100%;flex-wrap:wrap;justify-content:space-around;font-size:110%;font-family:Open Sans,Arial,sans-serif}.qcu-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}.qcu-image__choice--max4{width:calc(25% - 2em);min-width:175px}.qcu-image__choice--max3{width:calc(33% - 2em)}.qcu-image__choice--max2{width:calc(50% - 2em);min-width:300px}.qcu-image__choice--max1{width:calc(100% - 4em);min-width:300px}.qcu-image__choice:hover{cursor:pointer;box-shadow:0 3px 10px #0000001a;transform:scale(1.04);transition:transform ease-in .1s}.qcu-image__choice:focus{outline:none;box-shadow:5px 5px #ffbe00,-5px 5px #ffbe00,5px -5px #ffbe00,-5px -5px #ffbe00}.qcu-image__choice[aria-checked=true]{border-color:#3d68ff}.qcu-image__choice[aria-checked=true]:after{content:"";position:absolute;width:100%;height:100%;background:#3d68ff4d;border-radius:10px;z-index:3}.qcu-image__choice figure{width:100%;padding:0 10px;margin:3px;text-align:center}.qcu-image__choice figure img{max-width:100%;height:auto}.qcu-image__choice figure img.icon{max-height:100px;width:auto}.qcu-image__choice figure img.medium{max-width:50%;height:auto}.qcu-image__choice figure figcaption{margin:1ex}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}', K = /* @__PURE__ */ j(F, [["styles", [I]]]);
92
- window.customElements.define("qcu-image", z(K));
91
+ }), I = '*{box-sizing:border-box}ul,li{padding:0;margin:0}li{list-style:none}.qcu-image{display:flex;width:100%;flex-wrap:wrap;justify-content:space-around;font-size:110%;font-family:Open Sans,Arial,sans-serif}.qcu-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}.qcu-image__choice--max4{width:calc(25% - 2em);min-width:175px}.qcu-image__choice--max3{width:calc(33% - 2em)}.qcu-image__choice--max2{width:calc(50% - 2em);min-width:300px}.qcu-image__choice--max1{width:calc(100% - 4em);min-width:300px}.qcu-image__choice:hover{cursor:pointer;box-shadow:0 3px 10px #0000001a;transform:scale(1.04);transition:transform ease-in .1s}.qcu-image__choice:focus{outline:none;box-shadow:5px 5px #ffbe00,-5px 5px #ffbe00,5px -5px #ffbe00,-5px -5px #ffbe00}.qcu-image__choice[aria-checked=true]{border-color:#3d68ff}.qcu-image__choice[aria-checked=true]:after{content:"";position:absolute;width:100%;height:100%;background:#3d68ff4d;border-radius:10px;z-index:3}.qcu-image__choice figure{width:100%;padding:0 10px;margin:3px;text-align:center}.qcu-image__choice figure img{max-width:100%;height:auto}.qcu-image__choice figure img.icon{max-height:100px;width:auto}.qcu-image__choice figure img.medium{max-width:50%;height:auto}.qcu-image__choice figure figcaption{margin:1ex}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}', K = /* @__PURE__ */ z(F, [["styles", [I]]]);
92
+ window.customElements.define("qcu-image", L(K));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/epreuves-components",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",