@1024pix/epreuves-components 0.6.0 → 0.8.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,97 +0,0 @@
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
- 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] = 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
- ]
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 = g(() => c.hideChoicesName ? "sr-only" : ""), e = g(() => c.orderChoices ? c.choices : j(c.choices)), i = N(), r = g(() => 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));