@webwriter/quiz 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/LICENSE +7 -0
- package/custom.d.ts +176 -0
- package/dist/widgets/webwriter-choice-item.css +444 -0
- package/dist/widgets/webwriter-choice-item.js +288 -0
- package/dist/widgets/webwriter-choice.css +444 -0
- package/dist/widgets/webwriter-choice.js +327 -0
- package/dist/widgets/webwriter-cloze-gap.css +444 -0
- package/dist/widgets/webwriter-cloze-gap.js +722 -0
- package/dist/widgets/webwriter-cloze.css +444 -0
- package/dist/widgets/webwriter-cloze.js +177 -0
- package/dist/widgets/webwriter-mark.css +444 -0
- package/dist/widgets/webwriter-mark.js +410 -0
- package/dist/widgets/webwriter-order-item.css +444 -0
- package/dist/widgets/webwriter-order-item.js +464 -0
- package/dist/widgets/webwriter-order.css +444 -0
- package/dist/widgets/webwriter-order.js +560 -0
- package/dist/widgets/webwriter-pairing-item.css +444 -0
- package/dist/widgets/webwriter-pairing-item.js +203 -0
- package/dist/widgets/webwriter-pairing.css +444 -0
- package/dist/widgets/webwriter-pairing.js +224 -0
- package/dist/widgets/webwriter-quiz.css +444 -0
- package/dist/widgets/webwriter-quiz.js +323 -0
- package/dist/widgets/webwriter-speech.css +444 -0
- package/dist/widgets/webwriter-speech.js +320 -0
- package/dist/widgets/webwriter-task-explainer.css +444 -0
- package/dist/widgets/webwriter-task-explainer.js +90 -0
- package/dist/widgets/webwriter-task-hint.css +444 -0
- package/dist/widgets/webwriter-task-hint.js +67 -0
- package/dist/widgets/webwriter-task-prompt.css +444 -0
- package/dist/widgets/webwriter-task-prompt.js +68 -0
- package/dist/widgets/webwriter-task.css +444 -0
- package/dist/widgets/webwriter-task.js +546 -0
- package/dist/widgets/webwriter-text.css +444 -0
- package/dist/widgets/webwriter-text.js +174 -0
- package/package.json +199 -0
- package/src/lib/combobox.ts +456 -0
- package/src/lib/highlighter-fill.svg +6 -0
- package/src/snippets/choice.html +8 -0
- package/src/snippets/cloze.html +4 -0
- package/src/snippets/mark.html +4 -0
- package/src/snippets/order.html +8 -0
- package/src/snippets/pairing.html +10 -0
- package/src/snippets/speech.html +4 -0
- package/src/snippets/text.html +4 -0
- package/src/snippets/wordsearch.html +4 -0
- package/src/widgets/webwriter-choice-item.ts +251 -0
- package/src/widgets/webwriter-choice.ts +310 -0
- package/src/widgets/webwriter-cloze-gap.ts +217 -0
- package/src/widgets/webwriter-cloze.ts +136 -0
- package/src/widgets/webwriter-mark.ts +435 -0
- package/src/widgets/webwriter-order-item.ts +445 -0
- package/src/widgets/webwriter-order.ts +273 -0
- package/src/widgets/webwriter-pairing-item.ts +156 -0
- package/src/widgets/webwriter-pairing.ts +188 -0
- package/src/widgets/webwriter-quiz.ts +281 -0
- package/src/widgets/webwriter-speech.ts +268 -0
- package/src/widgets/webwriter-task-explainer.ts +38 -0
- package/src/widgets/webwriter-task-hint.ts +17 -0
- package/src/widgets/webwriter-task-prompt.ts +18 -0
- package/src/widgets/webwriter-task.ts +544 -0
- package/src/widgets/webwriter-text.ts +131 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
+
|
|
51
|
+
// src/widgets/webwriter-choice-item.ts
|
|
52
|
+
import { css, html } from "lit";
|
|
53
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
54
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
55
|
+
import { LitElementWw } from "@webwriter/lit";
|
|
56
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
57
|
+
import SlRadio from "@shoelace-style/shoelace/dist/components/radio/radio.component.js";
|
|
58
|
+
import SlCheckbox from "@shoelace-style/shoelace/dist/components/checkbox/checkbox.component.js";
|
|
59
|
+
import SlIcon from "@shoelace-style/shoelace/dist/components/icon/icon.component.js";
|
|
60
|
+
import { keyed } from "lit/directives/keyed.js";
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/bootstrap-icons/icons/x.svg
|
|
63
|
+
var x_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x" viewBox="0 0 16 16">%0A <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708"/>%0A</svg>';
|
|
64
|
+
|
|
65
|
+
// ../../node_modules/bootstrap-icons/icons/check.svg
|
|
66
|
+
var check_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check" viewBox="0 0 16 16">%0A <path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>%0A</svg>';
|
|
67
|
+
|
|
68
|
+
// src/widgets/webwriter-choice-item.ts
|
|
69
|
+
var _checkbox_dec, _layout_dec, _valid_dec, _active_dec, _a, _WebwriterChoiceItem_decorators, _init, _active, _valid, _layout, _checkbox;
|
|
70
|
+
_WebwriterChoiceItem_decorators = [customElement("webwriter-choice-item")];
|
|
71
|
+
var _WebwriterChoiceItem = class _WebwriterChoiceItem extends (_a = LitElementWw, _active_dec = [property({ type: Boolean, attribute: false })], _valid_dec = [property({ type: Boolean, attribute: false })], _layout_dec = [property({ type: String, attribute: true, reflect: true })], _checkbox_dec = [query("sl-checkbox")], _a) {
|
|
72
|
+
constructor() {
|
|
73
|
+
super(...arguments);
|
|
74
|
+
__publicField(this, "msg", (str) => this.lang in _WebwriterChoiceItem.localization ? _WebwriterChoiceItem.localization[this.lang][str] ?? str : str);
|
|
75
|
+
__privateAdd(this, _active, __runInitializers(_init, 8, this, false)), __runInitializers(_init, 11, this);
|
|
76
|
+
__privateAdd(this, _valid, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
77
|
+
__privateAdd(this, _layout, __runInitializers(_init, 16, this, "list")), __runInitializers(_init, 19, this);
|
|
78
|
+
__publicField(this, "handleClick", (e) => {
|
|
79
|
+
const checkboxClicked = e.composedPath().some((v) => v?.classList?.contains("checkbox__control"));
|
|
80
|
+
const editable = this.isContentEditable;
|
|
81
|
+
if (editable && !checkboxClicked) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
} else {
|
|
84
|
+
e.stopImmediatePropagation();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
__publicField(this, "handleChange", (e) => {
|
|
88
|
+
if (this.isContentEditable) {
|
|
89
|
+
this.valid = !this.valid;
|
|
90
|
+
} else {
|
|
91
|
+
this.active = !this.active;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
__privateAdd(this, _checkbox, __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
|
|
95
|
+
__publicField(this, "observer");
|
|
96
|
+
}
|
|
97
|
+
async updated(_changedProperties) {
|
|
98
|
+
await this.checkbox.updateComplete;
|
|
99
|
+
const labelEl = this.checkbox.shadowRoot.querySelector(".checkbox__label");
|
|
100
|
+
if (_changedProperties.has("layout") && this.layout === "list") {
|
|
101
|
+
this.syncSize(true);
|
|
102
|
+
this.observer?.disconnect();
|
|
103
|
+
} else if (_changedProperties.has("layout") && this.layout === "tiles") {
|
|
104
|
+
this.syncSize();
|
|
105
|
+
this.observer = new MutationObserver(() => this.syncSize());
|
|
106
|
+
this.observer.observe(labelEl, { attributeFilter: ["style"], attributes: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
syncSize(clear = false) {
|
|
110
|
+
const labelEl = this.checkbox?.shadowRoot.querySelector(".checkbox__label");
|
|
111
|
+
if (labelEl && !clear) {
|
|
112
|
+
this.style.width = labelEl.style.width;
|
|
113
|
+
this.style.height = labelEl.style.height;
|
|
114
|
+
} else if (labelEl && clear) {
|
|
115
|
+
this.style.width = labelEl.style.width = null;
|
|
116
|
+
this.style.height = labelEl.style.height = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
disconnectedCallback() {
|
|
120
|
+
super.disconnectedCallback();
|
|
121
|
+
this.observer?.disconnect();
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
return keyed(this.layout, html`
|
|
125
|
+
${this.valid !== void 0 && (this.active || !this.active && this.valid) ? html`<sl-icon class="solution user-only" ?data-valid=${this.valid} src=${this.valid ? check_default : x_default}></sl-icon>` : null}
|
|
126
|
+
<sl-checkbox class=${classMap({ valid: this.valid, active: this.active })} exportparts="base, control, label" @click=${this.handleClick} @sl-change=${this.handleChange} ?checked=${this.isContentEditable ? this.valid : this.active}>
|
|
127
|
+
<slot part="slot" style=${styleMap({ "--ww-placeholder": `"${this.msg("Option")}"` })}></slot>
|
|
128
|
+
</sl-checkbox>
|
|
129
|
+
`);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
_init = __decoratorStart(_a);
|
|
133
|
+
_active = new WeakMap();
|
|
134
|
+
_valid = new WeakMap();
|
|
135
|
+
_layout = new WeakMap();
|
|
136
|
+
_checkbox = new WeakMap();
|
|
137
|
+
__decorateElement(_init, 4, "active", _active_dec, _WebwriterChoiceItem, _active);
|
|
138
|
+
__decorateElement(_init, 4, "valid", _valid_dec, _WebwriterChoiceItem, _valid);
|
|
139
|
+
__decorateElement(_init, 4, "layout", _layout_dec, _WebwriterChoiceItem, _layout);
|
|
140
|
+
__decorateElement(_init, 4, "checkbox", _checkbox_dec, _WebwriterChoiceItem, _checkbox);
|
|
141
|
+
_WebwriterChoiceItem = __decorateElement(_init, 0, "WebwriterChoiceItem", _WebwriterChoiceItem_decorators, _WebwriterChoiceItem);
|
|
142
|
+
__publicField(_WebwriterChoiceItem, "localization", {});
|
|
143
|
+
__publicField(_WebwriterChoiceItem, "scopedElements", {
|
|
144
|
+
"sl-radio": SlRadio,
|
|
145
|
+
"sl-checkbox": SlCheckbox,
|
|
146
|
+
"sl-icon": SlIcon
|
|
147
|
+
});
|
|
148
|
+
__publicField(_WebwriterChoiceItem, "styles", css`
|
|
149
|
+
|
|
150
|
+
:host {
|
|
151
|
+
width: 100%;
|
|
152
|
+
position: relative;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
|
|
156
|
+
display: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
:host(:is([contenteditable=true], [contenteditable=""])) .user-only {
|
|
160
|
+
display: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host(:is([contenteditable=true], [contenteditable=""])) sl-checkbox.valid {
|
|
164
|
+
--webwriter-control-color-600: var(--sl-color-success-600);
|
|
165
|
+
--webwriter-control-color-400: var(--sl-color-success-400);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
sl-checkbox {
|
|
169
|
+
display: block;
|
|
170
|
+
width: 100%;
|
|
171
|
+
&::part(base) {
|
|
172
|
+
width: 100%;
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: row;
|
|
175
|
+
align-items: center;
|
|
176
|
+
cursor: unset;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&::part(control) {
|
|
180
|
+
cursor: pointer;
|
|
181
|
+
border-radius: var(--webwriter-choice-radius, 2px);
|
|
182
|
+
border-width: 2px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&::part(control):not(:hover){
|
|
186
|
+
border-color: var(--sl-color-gray-500);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&::part(control):hover {
|
|
190
|
+
border-color: var(--sl-color-gray-700);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&::part(control--checked):not(:hover) {
|
|
194
|
+
background-color: var(--webwriter-control-color-600, var(--sl-color-primary-600));
|
|
195
|
+
border-color: var(--sl-color-gray-500);
|
|
196
|
+
}
|
|
197
|
+
&::part(control--checked):hover {
|
|
198
|
+
background-color: var(--webwriter-control-color-400, var(--sl-color-primary-400));
|
|
199
|
+
border-color: var(--webwriter-control-color-600, var(--sl-color-primary-600));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&::part(label) {
|
|
203
|
+
width: 100%;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.solution {
|
|
208
|
+
position: absolute;
|
|
209
|
+
top: -6px;
|
|
210
|
+
left: -6px;
|
|
211
|
+
border: 2px solid var(--sl-color-gray-500);
|
|
212
|
+
border-radius: var(--webwriter-choice-radius, 2px);
|
|
213
|
+
width: 12px;
|
|
214
|
+
height: 12px;
|
|
215
|
+
z-index: 1;
|
|
216
|
+
color: white;
|
|
217
|
+
|
|
218
|
+
&[data-valid] {
|
|
219
|
+
background: var(--sl-color-success-600);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&:not([data-valid]) {
|
|
223
|
+
background: var(--sl-color-danger-600);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
:host([layout=tiles]) {
|
|
228
|
+
position: relative;
|
|
229
|
+
overflow: visible !important;
|
|
230
|
+
|
|
231
|
+
& ::slotted(:is(picture, audio, video, img, iframe)) {
|
|
232
|
+
height: 100%;
|
|
233
|
+
width: 100%;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
& ::slotted(:not(:is(picture, audio, video, img, iframe))) {
|
|
237
|
+
margin: 5px !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
sl-checkbox {
|
|
241
|
+
display: block;
|
|
242
|
+
&::part(base) {
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: row;
|
|
245
|
+
align-items: center;
|
|
246
|
+
cursor: unset;
|
|
247
|
+
position: static;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&::part(control) {
|
|
251
|
+
position: absolute;
|
|
252
|
+
bottom: -10px;
|
|
253
|
+
left: -10px;
|
|
254
|
+
cursor: pointer;
|
|
255
|
+
border-radius: var(--webwriter-choice-radius, 2px);
|
|
256
|
+
z-index: 100;
|
|
257
|
+
border-color: var(--sl-color-gray-500);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&::part(control--checked):not(:hover) {
|
|
261
|
+
background-color: var(--webwriter-control-color-600, var(--sl-color-primary-600));
|
|
262
|
+
border-color: var(--sl-color-gray-500);
|
|
263
|
+
}
|
|
264
|
+
&::part(control--checked):hover {
|
|
265
|
+
background-color: var(--webwriter-control-color-400, var(--sl-color-primary-400));
|
|
266
|
+
border-color: var(--webwriter-control-color-600, var(--sl-color-primary-600));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
&::part(label) {
|
|
270
|
+
aspect-ratio: 1;
|
|
271
|
+
min-width: 125px;
|
|
272
|
+
max-width: 350px;
|
|
273
|
+
min-height: 125px;
|
|
274
|
+
max-height: 350px;
|
|
275
|
+
overflow: hidden;
|
|
276
|
+
resize: both;
|
|
277
|
+
margin-inline-start: 0;
|
|
278
|
+
overflow-y: auto;
|
|
279
|
+
scrollbar-width: thin;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`);
|
|
284
|
+
__runInitializers(_init, 1, _WebwriterChoiceItem);
|
|
285
|
+
var WebwriterChoiceItem = _WebwriterChoiceItem;
|
|
286
|
+
export {
|
|
287
|
+
WebwriterChoiceItem
|
|
288
|
+
};
|