@webwriter/quiz 1.0.4 → 1.0.5
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.
|
@@ -1312,27 +1312,6 @@ function option(decl = { type: "string" }) {
|
|
|
1312
1312
|
context.addInitializer(init);
|
|
1313
1313
|
};
|
|
1314
1314
|
}
|
|
1315
|
-
function action(decl) {
|
|
1316
|
-
return (target, context) => {
|
|
1317
|
-
function init() {
|
|
1318
|
-
this.constructor["actions"] = { ...this.constructor["actions"], [context.name]: decl };
|
|
1319
|
-
}
|
|
1320
|
-
context.addInitializer(init);
|
|
1321
|
-
function func(...args) {
|
|
1322
|
-
this._inTransaction = true;
|
|
1323
|
-
try {
|
|
1324
|
-
return target.apply(this, args);
|
|
1325
|
-
} finally {
|
|
1326
|
-
this._inTransaction = false;
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
if (context.kind === "method") {
|
|
1330
|
-
return func;
|
|
1331
|
-
} else {
|
|
1332
|
-
context.access.set(this, func);
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
}
|
|
1336
1315
|
var _lang_dec;
|
|
1337
1316
|
var _contentEditable_dec;
|
|
1338
1317
|
var _a;
|
|
@@ -1555,17 +1534,17 @@ var LocalizeController = class {
|
|
|
1555
1534
|
return `${this.host.lang || documentLanguage}`.toLowerCase();
|
|
1556
1535
|
}
|
|
1557
1536
|
getTranslationData(lang) {
|
|
1558
|
-
var
|
|
1537
|
+
var _a3, _b;
|
|
1559
1538
|
const locale = new Intl.Locale(lang.replace(/_/g, "-"));
|
|
1560
1539
|
const language = locale === null || locale === void 0 ? void 0 : locale.language.toLowerCase();
|
|
1561
|
-
const region = (_b = (
|
|
1540
|
+
const region = (_b = (_a3 = locale === null || locale === void 0 ? void 0 : locale.region) === null || _a3 === void 0 ? void 0 : _a3.toLowerCase()) !== null && _b !== void 0 ? _b : "";
|
|
1562
1541
|
const primary = translations.get(`${language}-${region}`);
|
|
1563
1542
|
const secondary = translations.get(language);
|
|
1564
1543
|
return { locale, language, region, primary, secondary };
|
|
1565
1544
|
}
|
|
1566
1545
|
exists(key, options) {
|
|
1567
|
-
var
|
|
1568
|
-
const { primary, secondary } = this.getTranslationData((
|
|
1546
|
+
var _a3;
|
|
1547
|
+
const { primary, secondary } = this.getTranslationData((_a3 = options.lang) !== null && _a3 !== void 0 ? _a3 : this.lang());
|
|
1569
1548
|
options = Object.assign({ includeFallback: false }, options);
|
|
1570
1549
|
if (primary && primary[key] || secondary && secondary[key] || options.includeFallback && fallback && fallback[key]) {
|
|
1571
1550
|
return true;
|
|
@@ -1832,11 +1811,11 @@ var FormControlController = class {
|
|
|
1832
1811
|
}
|
|
1833
1812
|
};
|
|
1834
1813
|
this.handleFormSubmit = (event) => {
|
|
1835
|
-
var
|
|
1814
|
+
var _a3;
|
|
1836
1815
|
const disabled = this.options.disabled(this.host);
|
|
1837
1816
|
const reportValidity = this.options.reportValidity;
|
|
1838
1817
|
if (this.form && !this.form.noValidate) {
|
|
1839
|
-
(
|
|
1818
|
+
(_a3 = formCollections.get(this.form)) == null ? void 0 : _a3.forEach((control) => {
|
|
1840
1819
|
this.setUserInteracted(control, true);
|
|
1841
1820
|
});
|
|
1842
1821
|
}
|
|
@@ -1902,8 +1881,8 @@ var FormControlController = class {
|
|
|
1902
1881
|
value: (input) => input.value,
|
|
1903
1882
|
defaultValue: (input) => input.defaultValue,
|
|
1904
1883
|
disabled: (input) => {
|
|
1905
|
-
var
|
|
1906
|
-
return (
|
|
1884
|
+
var _a3;
|
|
1885
|
+
return (_a3 = input.disabled) != null ? _a3 : false;
|
|
1907
1886
|
},
|
|
1908
1887
|
reportValidity: (input) => typeof input.reportValidity === "function" ? input.reportValidity() : true,
|
|
1909
1888
|
checkValidity: (input) => typeof input.checkValidity === "function" ? input.checkValidity() : true,
|
|
@@ -2021,8 +2000,8 @@ var FormControlController = class {
|
|
|
2021
2000
|
}
|
|
2022
2001
|
/** Returns the associated `<form>` element, if one exists. */
|
|
2023
2002
|
getForm() {
|
|
2024
|
-
var
|
|
2025
|
-
return (
|
|
2003
|
+
var _a3;
|
|
2004
|
+
return (_a3 = this.form) != null ? _a3 : null;
|
|
2026
2005
|
}
|
|
2027
2006
|
/** Resets the form, restoring all the control to their default value */
|
|
2028
2007
|
reset(submitter) {
|
|
@@ -2954,9 +2933,6 @@ function watch(propertyName, options) {
|
|
|
2954
2933
|
// ../../node_modules/lit/node_modules/lit-html/directive-helpers.js
|
|
2955
2934
|
var { I: et3 } = si;
|
|
2956
2935
|
var nt = (o6, t5) => void 0 === t5 ? void 0 !== o6?._$litType$ : o6?._$litType$ === t5;
|
|
2957
|
-
var rt = (o6) => void 0 === o6.strings;
|
|
2958
|
-
var ht = {};
|
|
2959
|
-
var dt = (o6, t5 = ht) => o6._$AH = t5;
|
|
2960
2936
|
|
|
2961
2937
|
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.O7VCMB7W.js
|
|
2962
2938
|
var CACHEABLE_ERROR = Symbol();
|
|
@@ -2973,7 +2949,7 @@ var SlIcon = class extends ShoelaceElement {
|
|
|
2973
2949
|
}
|
|
2974
2950
|
/** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */
|
|
2975
2951
|
async resolveIcon(url, library2) {
|
|
2976
|
-
var
|
|
2952
|
+
var _a3;
|
|
2977
2953
|
let fileData;
|
|
2978
2954
|
if (library2 == null ? void 0 : library2.spriteSheet) {
|
|
2979
2955
|
this.svg = ke`<svg part="svg">
|
|
@@ -2992,7 +2968,7 @@ var SlIcon = class extends ShoelaceElement {
|
|
|
2992
2968
|
const div = document.createElement("div");
|
|
2993
2969
|
div.innerHTML = await fileData.text();
|
|
2994
2970
|
const svg = div.firstElementChild;
|
|
2995
|
-
if (((
|
|
2971
|
+
if (((_a3 = svg == null ? void 0 : svg.tagName) == null ? void 0 : _a3.toLowerCase()) !== "svg")
|
|
2996
2972
|
return CACHEABLE_ERROR;
|
|
2997
2973
|
if (!parser)
|
|
2998
2974
|
parser = new DOMParser();
|
|
@@ -3044,7 +3020,7 @@ var SlIcon = class extends ShoelaceElement {
|
|
|
3044
3020
|
}
|
|
3045
3021
|
}
|
|
3046
3022
|
async setIcon() {
|
|
3047
|
-
var
|
|
3023
|
+
var _a3;
|
|
3048
3024
|
const { url, fromLibrary } = this.getIconSource();
|
|
3049
3025
|
const library2 = fromLibrary ? getIconLibrary(this.library) : void 0;
|
|
3050
3026
|
if (!url) {
|
|
@@ -3085,7 +3061,7 @@ var SlIcon = class extends ShoelaceElement {
|
|
|
3085
3061
|
break;
|
|
3086
3062
|
default:
|
|
3087
3063
|
this.svg = svg.cloneNode(true);
|
|
3088
|
-
(
|
|
3064
|
+
(_a3 = library2 == null ? void 0 : library2.mutator) == null ? void 0 : _a3.call(library2, this.svg);
|
|
3089
3065
|
this.emit("sl-load");
|
|
3090
3066
|
}
|
|
3091
3067
|
}
|
|
@@ -3450,1671 +3426,197 @@ __decorateClass([
|
|
|
3450
3426
|
// ../../node_modules/bootstrap-icons/icons/plus.svg
|
|
3451
3427
|
var plus_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16">%0A <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>%0A</svg>';
|
|
3452
3428
|
|
|
3453
|
-
//
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
:host(:focus-visible) {
|
|
3460
|
-
outline: 0px;
|
|
3461
|
-
}
|
|
3462
|
-
|
|
3463
|
-
.radio {
|
|
3464
|
-
display: inline-flex;
|
|
3465
|
-
align-items: top;
|
|
3466
|
-
font-family: var(--sl-input-font-family);
|
|
3467
|
-
font-size: var(--sl-input-font-size-medium);
|
|
3468
|
-
font-weight: var(--sl-input-font-weight);
|
|
3469
|
-
color: var(--sl-input-label-color);
|
|
3470
|
-
vertical-align: middle;
|
|
3471
|
-
cursor: pointer;
|
|
3472
|
-
}
|
|
3473
|
-
|
|
3474
|
-
.radio--small {
|
|
3475
|
-
--toggle-size: var(--sl-toggle-size-small);
|
|
3476
|
-
font-size: var(--sl-input-font-size-small);
|
|
3477
|
-
}
|
|
3478
|
-
|
|
3479
|
-
.radio--medium {
|
|
3480
|
-
--toggle-size: var(--sl-toggle-size-medium);
|
|
3481
|
-
font-size: var(--sl-input-font-size-medium);
|
|
3429
|
+
// src/widgets/webwriter-order.ts
|
|
3430
|
+
function shuffle(a3) {
|
|
3431
|
+
for (let i4 = a3.length - 1; i4 > 0; i4--) {
|
|
3432
|
+
const j3 = Math.floor(Math.random() * (i4 + 1));
|
|
3433
|
+
[a3[i4], a3[j3]] = [a3[j3], a3[i4]];
|
|
3482
3434
|
}
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3435
|
+
return a3;
|
|
3436
|
+
}
|
|
3437
|
+
var _solution_dec, _items_dec, _itemsSlot_dec, _hideOrderButtons_dec, _layout_dec, _a2, _WebwriterOrder_decorators, _init2, _itemsSlot, _items, _solution;
|
|
3438
|
+
_WebwriterOrder_decorators = [t3("webwriter-order")];
|
|
3439
|
+
var WebwriterOrder = class extends (_a2 = LitElementWw, _layout_dec = [n5({ type: String, attribute: true, reflect: true }), option({
|
|
3440
|
+
type: "select",
|
|
3441
|
+
options: [
|
|
3442
|
+
{ value: "list", label: { "en": "List" } },
|
|
3443
|
+
{ value: "tiles", label: { "en": "Tiles" } }
|
|
3444
|
+
]
|
|
3445
|
+
})], _hideOrderButtons_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({ type: Boolean, label: { _: "Hide order buttons" } })], _itemsSlot_dec = [e5("#items-slot")], _items_dec = [o5()], _solution_dec = [n5({ attribute: false })], _a2) {
|
|
3446
|
+
constructor() {
|
|
3447
|
+
super(...arguments);
|
|
3448
|
+
__runInitializers(_init2, 5, this);
|
|
3449
|
+
__publicField(this, "observer");
|
|
3450
|
+
__publicField(this, "orderSheet", new CSSStyleSheet());
|
|
3451
|
+
__publicField(this, "clearDropPreviews", () => {
|
|
3452
|
+
this.items.forEach((item) => item.dropPreview = void 0);
|
|
3453
|
+
});
|
|
3454
|
+
__privateAdd(this, _itemsSlot, __runInitializers(_init2, 8, this)), __runInitializers(_init2, 11, this);
|
|
3455
|
+
__privateAdd(this, _items, __runInitializers(_init2, 12, this)), __runInitializers(_init2, 15, this);
|
|
3456
|
+
__publicField(this, "handleMove", (e7) => {
|
|
3457
|
+
const elem = e7.target;
|
|
3458
|
+
const children = Array.from(this.children);
|
|
3459
|
+
const pos = children.indexOf(elem);
|
|
3460
|
+
let i4;
|
|
3461
|
+
if (e7.type === "ww-moveup") {
|
|
3462
|
+
i4 = Math.max(0, pos - 1);
|
|
3463
|
+
} else if (e7.type === "ww-movedown") {
|
|
3464
|
+
i4 = Math.min(children.length, pos + 2);
|
|
3465
|
+
} else if (e7.type === "ww-moveto") {
|
|
3466
|
+
i4 = e7.detail.i;
|
|
3467
|
+
}
|
|
3468
|
+
this.moveChild(elem, i4);
|
|
3469
|
+
});
|
|
3470
|
+
__privateAdd(this, _solution, []);
|
|
3487
3471
|
}
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
display: inline-flex;
|
|
3491
|
-
width: var(--toggle-size);
|
|
3492
|
-
height: var(--toggle-size);
|
|
3472
|
+
get layout() {
|
|
3473
|
+
return this.children?.item(0)?.getAttribute("layout") ?? "list";
|
|
3493
3474
|
}
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
position: relative;
|
|
3498
|
-
display: inline-flex;
|
|
3499
|
-
align-items: center;
|
|
3500
|
-
justify-content: center;
|
|
3501
|
-
width: var(--toggle-size);
|
|
3502
|
-
height: var(--toggle-size);
|
|
3503
|
-
border: solid var(--sl-input-border-width) var(--sl-input-border-color);
|
|
3504
|
-
border-radius: 50%;
|
|
3505
|
-
background-color: var(--sl-input-background-color);
|
|
3506
|
-
color: transparent;
|
|
3507
|
-
transition:
|
|
3508
|
-
var(--sl-transition-fast) border-color,
|
|
3509
|
-
var(--sl-transition-fast) background-color,
|
|
3510
|
-
var(--sl-transition-fast) color,
|
|
3511
|
-
var(--sl-transition-fast) box-shadow;
|
|
3475
|
+
set layout(value) {
|
|
3476
|
+
this.querySelectorAll("webwriter-order-item").forEach((el) => el.setAttribute("layout", value));
|
|
3477
|
+
this.requestUpdate("layout");
|
|
3512
3478
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
position: absolute;
|
|
3516
|
-
opacity: 0;
|
|
3517
|
-
padding: 0;
|
|
3518
|
-
margin: 0;
|
|
3519
|
-
pointer-events: none;
|
|
3479
|
+
get hideOrderButtons() {
|
|
3480
|
+
return !!this.items[0]?.hideOrderButtons;
|
|
3520
3481
|
}
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
.radio:not(.radio--checked):not(.radio--disabled) .radio__control:hover {
|
|
3524
|
-
border-color: var(--sl-input-border-color-hover);
|
|
3525
|
-
background-color: var(--sl-input-background-color-hover);
|
|
3482
|
+
set hideOrderButtons(value) {
|
|
3483
|
+
this.items.forEach((item) => item.hideOrderButtons = value);
|
|
3526
3484
|
}
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3485
|
+
connectedCallback() {
|
|
3486
|
+
super.connectedCallback();
|
|
3487
|
+
this.addEventListener("ww-moveup", this.handleMove);
|
|
3488
|
+
this.addEventListener("ww-movedown", this.handleMove);
|
|
3489
|
+
this.addEventListener("ww-moveto", this.handleMove);
|
|
3490
|
+
this.observer = new MutationObserver(() => {
|
|
3491
|
+
this.items.forEach((item) => item.requestUpdate());
|
|
3492
|
+
if (this.isContentEditable) {
|
|
3493
|
+
this.solution = this.items.map((item) => item.id);
|
|
3494
|
+
}
|
|
3495
|
+
this.clearDropPreviews();
|
|
3496
|
+
});
|
|
3497
|
+
this.observer.observe(this, { childList: true });
|
|
3533
3498
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
.radio.radio--checked:not(.radio--disabled) .radio__control:hover {
|
|
3537
|
-
border-color: var(--sl-color-primary-500);
|
|
3538
|
-
background-color: var(--sl-color-primary-500);
|
|
3499
|
+
serializedCallback() {
|
|
3500
|
+
this.shuffleItems();
|
|
3539
3501
|
}
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
outline-offset: var(--sl-focus-ring-offset);
|
|
3502
|
+
disconnectedCallback() {
|
|
3503
|
+
super.disconnectedCallback();
|
|
3504
|
+
this.observer?.disconnect();
|
|
3505
|
+
this.observer = void 0;
|
|
3545
3506
|
}
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3507
|
+
addItem() {
|
|
3508
|
+
const orderItem = this.ownerDocument.createElement("webwriter-order-item");
|
|
3509
|
+
const p3 = this.ownerDocument.createElement("p");
|
|
3510
|
+
orderItem.appendChild(p3);
|
|
3511
|
+
orderItem.setAttribute("layout", this.layout);
|
|
3512
|
+
this.append(orderItem);
|
|
3513
|
+
this.solution = [...__privateGet(this, _solution), orderItem.id];
|
|
3514
|
+
this.ownerDocument.getSelection().setBaseAndExtent(p3, 0, p3, 0);
|
|
3551
3515
|
}
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3516
|
+
shuffleItems() {
|
|
3517
|
+
const n6 = this.items.length;
|
|
3518
|
+
const nums = shuffle([...new Array(n6).keys()]);
|
|
3519
|
+
this.innerHTML = nums.map((i4) => this.children.item(i4).outerHTML).join("");
|
|
3556
3520
|
}
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3521
|
+
handleKeyDown(e7) {
|
|
3522
|
+
if (e7.key == "ArrowDown") {
|
|
3523
|
+
e7.stopPropagation();
|
|
3524
|
+
e7.preventDefault();
|
|
3525
|
+
} else if (e7.key === "ArrowUp") {
|
|
3526
|
+
e7.stopPropagation();
|
|
3527
|
+
e7.preventDefault();
|
|
3528
|
+
}
|
|
3565
3529
|
}
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
this.
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
this.emit("sl-blur");
|
|
3579
|
-
};
|
|
3580
|
-
this.handleClick = () => {
|
|
3581
|
-
if (!this.disabled) {
|
|
3582
|
-
this.checked = true;
|
|
3583
|
-
}
|
|
3584
|
-
};
|
|
3585
|
-
this.handleFocus = () => {
|
|
3586
|
-
this.hasFocus = true;
|
|
3587
|
-
this.emit("sl-focus");
|
|
3588
|
-
};
|
|
3589
|
-
this.addEventListener("blur", this.handleBlur);
|
|
3590
|
-
this.addEventListener("click", this.handleClick);
|
|
3591
|
-
this.addEventListener("focus", this.handleFocus);
|
|
3530
|
+
/*
|
|
3531
|
+
If contenteditable: Reorder solution -> Triggers orderSheet change
|
|
3532
|
+
If not contenteditable: Reorder value -> Triggers orderSheet change
|
|
3533
|
+
*/
|
|
3534
|
+
moveChild(elem, i4) {
|
|
3535
|
+
if (i4 === 0) {
|
|
3536
|
+
this.insertAdjacentElement("afterbegin", elem);
|
|
3537
|
+
} else if (i4 < this.items.length) {
|
|
3538
|
+
this.items[i4].insertAdjacentElement("beforebegin", elem);
|
|
3539
|
+
} else {
|
|
3540
|
+
this.insertAdjacentElement("beforeend", elem);
|
|
3541
|
+
}
|
|
3592
3542
|
}
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
this.setInitialAttributes();
|
|
3543
|
+
get solution() {
|
|
3544
|
+
return __privateGet(this, _solution)?.length ? __privateGet(this, _solution) : void 0;
|
|
3596
3545
|
}
|
|
3597
|
-
|
|
3598
|
-
this
|
|
3599
|
-
|
|
3600
|
-
|
|
3546
|
+
set solution(value) {
|
|
3547
|
+
__privateSet(this, _solution, value);
|
|
3548
|
+
if (value) {
|
|
3549
|
+
this.dispatchEvent(new CustomEvent("ww-answer-change", {
|
|
3550
|
+
bubbles: true,
|
|
3551
|
+
composed: true
|
|
3552
|
+
}));
|
|
3553
|
+
}
|
|
3601
3554
|
}
|
|
3602
|
-
|
|
3603
|
-
this.
|
|
3604
|
-
this.setAttribute("tabindex", this.checked ? "0" : "-1");
|
|
3555
|
+
reportSolution() {
|
|
3556
|
+
this.solution.forEach((id, i4) => this.querySelector(`#${id}`).validOrder = i4);
|
|
3605
3557
|
}
|
|
3606
|
-
|
|
3607
|
-
this.
|
|
3558
|
+
reset() {
|
|
3559
|
+
this.solution = void 0;
|
|
3560
|
+
this.shuffleItems();
|
|
3608
3561
|
}
|
|
3609
3562
|
render() {
|
|
3610
3563
|
return ke`
|
|
3611
|
-
<
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
"radio--checked": this.checked,
|
|
3616
|
-
"radio--disabled": this.disabled,
|
|
3617
|
-
"radio--focused": this.hasFocus,
|
|
3618
|
-
"radio--small": this.size === "small",
|
|
3619
|
-
"radio--medium": this.size === "medium",
|
|
3620
|
-
"radio--large": this.size === "large"
|
|
3621
|
-
})}
|
|
3622
|
-
>
|
|
3623
|
-
<span part="${`control${this.checked ? " control--checked" : ""}`}" class="radio__control">
|
|
3624
|
-
${this.checked ? ke` <sl-icon part="checked-icon" class="radio__checked-icon" library="system" name="radio"></sl-icon> ` : ""}
|
|
3625
|
-
</span>
|
|
3626
|
-
|
|
3627
|
-
<slot part="label" class="radio__label"></slot>
|
|
3628
|
-
</span>
|
|
3564
|
+
<slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
|
|
3565
|
+
<sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
|
|
3566
|
+
<sl-icon src=${plus_default}></sl-icon><span>Add Option</span>
|
|
3567
|
+
</sl-button>
|
|
3629
3568
|
`;
|
|
3630
3569
|
}
|
|
3631
3570
|
};
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
], SlRadio.prototype, "handleDisabledChange", 1);
|
|
3571
|
+
_init2 = __decoratorStart(_a2);
|
|
3572
|
+
_itemsSlot = new WeakMap();
|
|
3573
|
+
_items = new WeakMap();
|
|
3574
|
+
_solution = new WeakMap();
|
|
3575
|
+
__decorateElement(_init2, 3, "layout", _layout_dec, WebwriterOrder);
|
|
3576
|
+
__decorateElement(_init2, 3, "hideOrderButtons", _hideOrderButtons_dec, WebwriterOrder);
|
|
3577
|
+
__decorateElement(_init2, 4, "itemsSlot", _itemsSlot_dec, WebwriterOrder, _itemsSlot);
|
|
3578
|
+
__decorateElement(_init2, 4, "items", _items_dec, WebwriterOrder, _items);
|
|
3579
|
+
__decorateElement(_init2, 3, "solution", _solution_dec, WebwriterOrder);
|
|
3580
|
+
WebwriterOrder = __decorateElement(_init2, 0, "WebwriterOrder", _WebwriterOrder_decorators, WebwriterOrder);
|
|
3581
|
+
__publicField(WebwriterOrder, "scopedElements", {
|
|
3582
|
+
"sl-button": SlButton,
|
|
3583
|
+
"sl-icon": SlIcon
|
|
3584
|
+
});
|
|
3585
|
+
__publicField(WebwriterOrder, "styles", i`
|
|
3586
|
+
:host {
|
|
3587
|
+
display: flex !important;
|
|
3588
|
+
flex-direction: column;
|
|
3589
|
+
align-items: flex-start;
|
|
3590
|
+
counter-reset: orderItem;
|
|
3591
|
+
gap: 2px;
|
|
3592
|
+
}
|
|
3655
3593
|
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3594
|
+
:host([layout=tiles]) {
|
|
3595
|
+
flex-direction: row;
|
|
3596
|
+
flex-wrap: wrap;
|
|
3597
|
+
gap: 15px;
|
|
3598
|
+
}
|
|
3661
3599
|
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
align-items: flex-start;
|
|
3666
|
-
font-family: var(--sl-input-font-family);
|
|
3667
|
-
font-weight: var(--sl-input-font-weight);
|
|
3668
|
-
color: var(--sl-input-label-color);
|
|
3669
|
-
vertical-align: middle;
|
|
3670
|
-
cursor: pointer;
|
|
3671
|
-
}
|
|
3600
|
+
:host(:is([contenteditable=true], [contenteditable=""])) {
|
|
3601
|
+
--text-color: var(--sl-color-success-700);
|
|
3602
|
+
}
|
|
3672
3603
|
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3604
|
+
:host ::slotted(*::part(counter)) {
|
|
3605
|
+
counter-increment: orderItem;
|
|
3606
|
+
content: counter(orderItem) '. ';
|
|
3607
|
+
cursor: move;
|
|
3608
|
+
text-align: right;
|
|
3609
|
+
padding-right: 0.5em;
|
|
3610
|
+
min-width: 1.5em;
|
|
3611
|
+
color: var(--text-color, auto);
|
|
3612
|
+
}
|
|
3677
3613
|
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
--toggle-size: var(--sl-toggle-size-large);
|
|
3685
|
-
font-size: var(--sl-input-font-size-large);
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
.checkbox__control {
|
|
3689
|
-
flex: 0 0 auto;
|
|
3690
|
-
position: relative;
|
|
3691
|
-
display: inline-flex;
|
|
3692
|
-
align-items: center;
|
|
3693
|
-
justify-content: center;
|
|
3694
|
-
width: var(--toggle-size);
|
|
3695
|
-
height: var(--toggle-size);
|
|
3696
|
-
border: solid var(--sl-input-border-width) var(--sl-input-border-color);
|
|
3697
|
-
border-radius: 2px;
|
|
3698
|
-
background-color: var(--sl-input-background-color);
|
|
3699
|
-
color: var(--sl-color-neutral-0);
|
|
3700
|
-
transition:
|
|
3701
|
-
var(--sl-transition-fast) border-color,
|
|
3702
|
-
var(--sl-transition-fast) background-color,
|
|
3703
|
-
var(--sl-transition-fast) color,
|
|
3704
|
-
var(--sl-transition-fast) box-shadow;
|
|
3705
|
-
}
|
|
3706
|
-
|
|
3707
|
-
.checkbox__input {
|
|
3708
|
-
position: absolute;
|
|
3709
|
-
opacity: 0;
|
|
3710
|
-
padding: 0;
|
|
3711
|
-
margin: 0;
|
|
3712
|
-
pointer-events: none;
|
|
3713
|
-
}
|
|
3714
|
-
|
|
3715
|
-
.checkbox__checked-icon,
|
|
3716
|
-
.checkbox__indeterminate-icon {
|
|
3717
|
-
display: inline-flex;
|
|
3718
|
-
width: var(--toggle-size);
|
|
3719
|
-
height: var(--toggle-size);
|
|
3720
|
-
}
|
|
3721
|
-
|
|
3722
|
-
/* Hover */
|
|
3723
|
-
.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__control:hover {
|
|
3724
|
-
border-color: var(--sl-input-border-color-hover);
|
|
3725
|
-
background-color: var(--sl-input-background-color-hover);
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
/* Focus */
|
|
3729
|
-
.checkbox:not(.checkbox--checked):not(.checkbox--disabled) .checkbox__input:focus-visible ~ .checkbox__control {
|
|
3730
|
-
outline: var(--sl-focus-ring);
|
|
3731
|
-
outline-offset: var(--sl-focus-ring-offset);
|
|
3732
|
-
}
|
|
3733
|
-
|
|
3734
|
-
/* Checked/indeterminate */
|
|
3735
|
-
.checkbox--checked .checkbox__control,
|
|
3736
|
-
.checkbox--indeterminate .checkbox__control {
|
|
3737
|
-
border-color: var(--sl-color-primary-600);
|
|
3738
|
-
background-color: var(--sl-color-primary-600);
|
|
3739
|
-
}
|
|
3740
|
-
|
|
3741
|
-
/* Checked/indeterminate + hover */
|
|
3742
|
-
.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__control:hover,
|
|
3743
|
-
.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__control:hover {
|
|
3744
|
-
border-color: var(--sl-color-primary-500);
|
|
3745
|
-
background-color: var(--sl-color-primary-500);
|
|
3746
|
-
}
|
|
3747
|
-
|
|
3748
|
-
/* Checked/indeterminate + focus */
|
|
3749
|
-
.checkbox.checkbox--checked:not(.checkbox--disabled) .checkbox__input:focus-visible ~ .checkbox__control,
|
|
3750
|
-
.checkbox.checkbox--indeterminate:not(.checkbox--disabled) .checkbox__input:focus-visible ~ .checkbox__control {
|
|
3751
|
-
outline: var(--sl-focus-ring);
|
|
3752
|
-
outline-offset: var(--sl-focus-ring-offset);
|
|
3753
|
-
}
|
|
3754
|
-
|
|
3755
|
-
/* Disabled */
|
|
3756
|
-
.checkbox--disabled {
|
|
3757
|
-
opacity: 0.5;
|
|
3758
|
-
cursor: not-allowed;
|
|
3759
|
-
}
|
|
3760
|
-
|
|
3761
|
-
.checkbox__label {
|
|
3762
|
-
display: inline-block;
|
|
3763
|
-
color: var(--sl-input-label-color);
|
|
3764
|
-
line-height: var(--toggle-size);
|
|
3765
|
-
margin-inline-start: 0.5em;
|
|
3766
|
-
user-select: none;
|
|
3767
|
-
-webkit-user-select: none;
|
|
3768
|
-
}
|
|
3769
|
-
|
|
3770
|
-
:host([required]) .checkbox__label::after {
|
|
3771
|
-
content: var(--sl-input-required-content);
|
|
3772
|
-
color: var(--sl-input-required-content-color);
|
|
3773
|
-
margin-inline-start: var(--sl-input-required-content-offset);
|
|
3774
|
-
}
|
|
3775
|
-
`;
|
|
3776
|
-
|
|
3777
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.GI7VDIWX.js
|
|
3778
|
-
var defaultValue = (propertyName = "value") => (proto, key) => {
|
|
3779
|
-
const ctor = proto.constructor;
|
|
3780
|
-
const attributeChangedCallback = ctor.prototype.attributeChangedCallback;
|
|
3781
|
-
ctor.prototype.attributeChangedCallback = function(name, old, value) {
|
|
3782
|
-
var _a4;
|
|
3783
|
-
const options = ctor.getPropertyOptions(propertyName);
|
|
3784
|
-
const attributeName = typeof options.attribute === "string" ? options.attribute : propertyName;
|
|
3785
|
-
if (name === attributeName) {
|
|
3786
|
-
const converter = options.converter || u;
|
|
3787
|
-
const fromAttribute = typeof converter === "function" ? converter : (_a4 = converter == null ? void 0 : converter.fromAttribute) != null ? _a4 : u.fromAttribute;
|
|
3788
|
-
const newValue = fromAttribute(value, options.type);
|
|
3789
|
-
if (this[propertyName] !== newValue) {
|
|
3790
|
-
this[key] = newValue;
|
|
3791
|
-
}
|
|
3792
|
-
}
|
|
3793
|
-
attributeChangedCallback.call(this, name, old, value);
|
|
3794
|
-
};
|
|
3795
|
-
};
|
|
3796
|
-
|
|
3797
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.SI4ACBFK.js
|
|
3798
|
-
var form_control_styles_default = i`
|
|
3799
|
-
.form-control .form-control__label {
|
|
3800
|
-
display: none;
|
|
3801
|
-
}
|
|
3802
|
-
|
|
3803
|
-
.form-control .form-control__help-text {
|
|
3804
|
-
display: none;
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3807
|
-
/* Label */
|
|
3808
|
-
.form-control--has-label .form-control__label {
|
|
3809
|
-
display: inline-block;
|
|
3810
|
-
color: var(--sl-input-label-color);
|
|
3811
|
-
margin-bottom: var(--sl-spacing-3x-small);
|
|
3812
|
-
}
|
|
3813
|
-
|
|
3814
|
-
.form-control--has-label.form-control--small .form-control__label {
|
|
3815
|
-
font-size: var(--sl-input-label-font-size-small);
|
|
3816
|
-
}
|
|
3817
|
-
|
|
3818
|
-
.form-control--has-label.form-control--medium .form-control__label {
|
|
3819
|
-
font-size: var(--sl-input-label-font-size-medium);
|
|
3820
|
-
}
|
|
3821
|
-
|
|
3822
|
-
.form-control--has-label.form-control--large .form-control__label {
|
|
3823
|
-
font-size: var(--sl-input-label-font-size-large);
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3826
|
-
:host([required]) .form-control--has-label .form-control__label::after {
|
|
3827
|
-
content: var(--sl-input-required-content);
|
|
3828
|
-
margin-inline-start: var(--sl-input-required-content-offset);
|
|
3829
|
-
color: var(--sl-input-required-content-color);
|
|
3830
|
-
}
|
|
3831
|
-
|
|
3832
|
-
/* Help text */
|
|
3833
|
-
.form-control--has-help-text .form-control__help-text {
|
|
3834
|
-
display: block;
|
|
3835
|
-
color: var(--sl-input-help-text-color);
|
|
3836
|
-
margin-top: var(--sl-spacing-3x-small);
|
|
3837
|
-
}
|
|
3838
|
-
|
|
3839
|
-
.form-control--has-help-text.form-control--small .form-control__help-text {
|
|
3840
|
-
font-size: var(--sl-input-help-text-font-size-small);
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
.form-control--has-help-text.form-control--medium .form-control__help-text {
|
|
3844
|
-
font-size: var(--sl-input-help-text-font-size-medium);
|
|
3845
|
-
}
|
|
3846
|
-
|
|
3847
|
-
.form-control--has-help-text.form-control--large .form-control__help-text {
|
|
3848
|
-
font-size: var(--sl-input-help-text-font-size-large);
|
|
3849
|
-
}
|
|
3850
|
-
|
|
3851
|
-
.form-control--has-help-text.form-control--radio-group .form-control__help-text {
|
|
3852
|
-
margin-top: var(--sl-spacing-2x-small);
|
|
3853
|
-
}
|
|
3854
|
-
`;
|
|
3855
|
-
|
|
3856
|
-
// ../../node_modules/lit/node_modules/lit-html/directives/live.js
|
|
3857
|
-
var Ft = e6(class extends i3 {
|
|
3858
|
-
constructor(r6) {
|
|
3859
|
-
if (super(r6), r6.type !== t4.PROPERTY && r6.type !== t4.ATTRIBUTE && r6.type !== t4.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
|
|
3860
|
-
if (!rt(r6)) throw Error("`live` bindings can only contain a single expression");
|
|
3861
|
-
}
|
|
3862
|
-
render(r6) {
|
|
3863
|
-
return r6;
|
|
3864
|
-
}
|
|
3865
|
-
update(r6, [e7]) {
|
|
3866
|
-
if (e7 === R || e7 === D) return e7;
|
|
3867
|
-
const i4 = r6.element, n6 = r6.name;
|
|
3868
|
-
if (r6.type === t4.PROPERTY) {
|
|
3869
|
-
if (e7 === i4[n6]) return R;
|
|
3870
|
-
} else if (r6.type === t4.BOOLEAN_ATTRIBUTE) {
|
|
3871
|
-
if (!!e7 === i4.hasAttribute(n6)) return R;
|
|
3872
|
-
} else if (r6.type === t4.ATTRIBUTE && i4.getAttribute(n6) === e7 + "") return R;
|
|
3873
|
-
return dt(r6), e7;
|
|
3874
|
-
}
|
|
3875
|
-
});
|
|
3876
|
-
|
|
3877
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.CX3DZWHK.js
|
|
3878
|
-
var SlCheckbox = class extends ShoelaceElement {
|
|
3879
|
-
constructor() {
|
|
3880
|
-
super(...arguments);
|
|
3881
|
-
this.formControlController = new FormControlController(this, {
|
|
3882
|
-
value: (control) => control.checked ? control.value || "on" : void 0,
|
|
3883
|
-
defaultValue: (control) => control.defaultChecked,
|
|
3884
|
-
setValue: (control, checked) => control.checked = checked
|
|
3885
|
-
});
|
|
3886
|
-
this.hasSlotController = new HasSlotController(this, "help-text");
|
|
3887
|
-
this.hasFocus = false;
|
|
3888
|
-
this.title = "";
|
|
3889
|
-
this.name = "";
|
|
3890
|
-
this.size = "medium";
|
|
3891
|
-
this.disabled = false;
|
|
3892
|
-
this.checked = false;
|
|
3893
|
-
this.indeterminate = false;
|
|
3894
|
-
this.defaultChecked = false;
|
|
3895
|
-
this.form = "";
|
|
3896
|
-
this.required = false;
|
|
3897
|
-
this.helpText = "";
|
|
3898
|
-
}
|
|
3899
|
-
/** Gets the validity state object */
|
|
3900
|
-
get validity() {
|
|
3901
|
-
return this.input.validity;
|
|
3902
|
-
}
|
|
3903
|
-
/** Gets the validation message */
|
|
3904
|
-
get validationMessage() {
|
|
3905
|
-
return this.input.validationMessage;
|
|
3906
|
-
}
|
|
3907
|
-
firstUpdated() {
|
|
3908
|
-
this.formControlController.updateValidity();
|
|
3909
|
-
}
|
|
3910
|
-
handleClick() {
|
|
3911
|
-
this.checked = !this.checked;
|
|
3912
|
-
this.indeterminate = false;
|
|
3913
|
-
this.emit("sl-change");
|
|
3914
|
-
}
|
|
3915
|
-
handleBlur() {
|
|
3916
|
-
this.hasFocus = false;
|
|
3917
|
-
this.emit("sl-blur");
|
|
3918
|
-
}
|
|
3919
|
-
handleInput() {
|
|
3920
|
-
this.emit("sl-input");
|
|
3921
|
-
}
|
|
3922
|
-
handleInvalid(event) {
|
|
3923
|
-
this.formControlController.setValidity(false);
|
|
3924
|
-
this.formControlController.emitInvalidEvent(event);
|
|
3925
|
-
}
|
|
3926
|
-
handleFocus() {
|
|
3927
|
-
this.hasFocus = true;
|
|
3928
|
-
this.emit("sl-focus");
|
|
3929
|
-
}
|
|
3930
|
-
handleDisabledChange() {
|
|
3931
|
-
this.formControlController.setValidity(this.disabled);
|
|
3932
|
-
}
|
|
3933
|
-
handleStateChange() {
|
|
3934
|
-
this.input.checked = this.checked;
|
|
3935
|
-
this.input.indeterminate = this.indeterminate;
|
|
3936
|
-
this.formControlController.updateValidity();
|
|
3937
|
-
}
|
|
3938
|
-
/** Simulates a click on the checkbox. */
|
|
3939
|
-
click() {
|
|
3940
|
-
this.input.click();
|
|
3941
|
-
}
|
|
3942
|
-
/** Sets focus on the checkbox. */
|
|
3943
|
-
focus(options) {
|
|
3944
|
-
this.input.focus(options);
|
|
3945
|
-
}
|
|
3946
|
-
/** Removes focus from the checkbox. */
|
|
3947
|
-
blur() {
|
|
3948
|
-
this.input.blur();
|
|
3949
|
-
}
|
|
3950
|
-
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
3951
|
-
checkValidity() {
|
|
3952
|
-
return this.input.checkValidity();
|
|
3953
|
-
}
|
|
3954
|
-
/** Gets the associated form, if one exists. */
|
|
3955
|
-
getForm() {
|
|
3956
|
-
return this.formControlController.getForm();
|
|
3957
|
-
}
|
|
3958
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
3959
|
-
reportValidity() {
|
|
3960
|
-
return this.input.reportValidity();
|
|
3961
|
-
}
|
|
3962
|
-
/**
|
|
3963
|
-
* Sets a custom validation message. The value provided will be shown to the user when the form is submitted. To clear
|
|
3964
|
-
* the custom validation message, call this method with an empty string.
|
|
3965
|
-
*/
|
|
3966
|
-
setCustomValidity(message) {
|
|
3967
|
-
this.input.setCustomValidity(message);
|
|
3968
|
-
this.formControlController.updateValidity();
|
|
3969
|
-
}
|
|
3970
|
-
render() {
|
|
3971
|
-
const hasHelpTextSlot = this.hasSlotController.test("help-text");
|
|
3972
|
-
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
|
|
3973
|
-
return ke`
|
|
3974
|
-
<div
|
|
3975
|
-
class=${Rt({
|
|
3976
|
-
"form-control": true,
|
|
3977
|
-
"form-control--small": this.size === "small",
|
|
3978
|
-
"form-control--medium": this.size === "medium",
|
|
3979
|
-
"form-control--large": this.size === "large",
|
|
3980
|
-
"form-control--has-help-text": hasHelpText
|
|
3981
|
-
})}
|
|
3982
|
-
>
|
|
3983
|
-
<label
|
|
3984
|
-
part="base"
|
|
3985
|
-
class=${Rt({
|
|
3986
|
-
checkbox: true,
|
|
3987
|
-
"checkbox--checked": this.checked,
|
|
3988
|
-
"checkbox--disabled": this.disabled,
|
|
3989
|
-
"checkbox--focused": this.hasFocus,
|
|
3990
|
-
"checkbox--indeterminate": this.indeterminate,
|
|
3991
|
-
"checkbox--small": this.size === "small",
|
|
3992
|
-
"checkbox--medium": this.size === "medium",
|
|
3993
|
-
"checkbox--large": this.size === "large"
|
|
3994
|
-
})}
|
|
3995
|
-
>
|
|
3996
|
-
<input
|
|
3997
|
-
class="checkbox__input"
|
|
3998
|
-
type="checkbox"
|
|
3999
|
-
title=${this.title}
|
|
4000
|
-
name=${this.name}
|
|
4001
|
-
value=${to(this.value)}
|
|
4002
|
-
.indeterminate=${Ft(this.indeterminate)}
|
|
4003
|
-
.checked=${Ft(this.checked)}
|
|
4004
|
-
.disabled=${this.disabled}
|
|
4005
|
-
.required=${this.required}
|
|
4006
|
-
aria-checked=${this.checked ? "true" : "false"}
|
|
4007
|
-
aria-describedby="help-text"
|
|
4008
|
-
@click=${this.handleClick}
|
|
4009
|
-
@input=${this.handleInput}
|
|
4010
|
-
@invalid=${this.handleInvalid}
|
|
4011
|
-
@blur=${this.handleBlur}
|
|
4012
|
-
@focus=${this.handleFocus}
|
|
4013
|
-
/>
|
|
4014
|
-
|
|
4015
|
-
<span
|
|
4016
|
-
part="control${this.checked ? " control--checked" : ""}${this.indeterminate ? " control--indeterminate" : ""}"
|
|
4017
|
-
class="checkbox__control"
|
|
4018
|
-
>
|
|
4019
|
-
${this.checked ? ke`
|
|
4020
|
-
<sl-icon part="checked-icon" class="checkbox__checked-icon" library="system" name="check"></sl-icon>
|
|
4021
|
-
` : ""}
|
|
4022
|
-
${!this.checked && this.indeterminate ? ke`
|
|
4023
|
-
<sl-icon
|
|
4024
|
-
part="indeterminate-icon"
|
|
4025
|
-
class="checkbox__indeterminate-icon"
|
|
4026
|
-
library="system"
|
|
4027
|
-
name="indeterminate"
|
|
4028
|
-
></sl-icon>
|
|
4029
|
-
` : ""}
|
|
4030
|
-
</span>
|
|
4031
|
-
|
|
4032
|
-
<div part="label" class="checkbox__label">
|
|
4033
|
-
<slot></slot>
|
|
4034
|
-
</div>
|
|
4035
|
-
</label>
|
|
4036
|
-
|
|
4037
|
-
<div
|
|
4038
|
-
aria-hidden=${hasHelpText ? "false" : "true"}
|
|
4039
|
-
class="form-control__help-text"
|
|
4040
|
-
id="help-text"
|
|
4041
|
-
part="form-control-help-text"
|
|
4042
|
-
>
|
|
4043
|
-
<slot name="help-text">${this.helpText}</slot>
|
|
4044
|
-
</div>
|
|
4045
|
-
</div>
|
|
4046
|
-
`;
|
|
4047
|
-
}
|
|
4048
|
-
};
|
|
4049
|
-
SlCheckbox.styles = [component_styles_default, form_control_styles_default, checkbox_styles_default];
|
|
4050
|
-
SlCheckbox.dependencies = { "sl-icon": SlIcon };
|
|
4051
|
-
__decorateClass([
|
|
4052
|
-
e5('input[type="checkbox"]')
|
|
4053
|
-
], SlCheckbox.prototype, "input", 2);
|
|
4054
|
-
__decorateClass([
|
|
4055
|
-
r5()
|
|
4056
|
-
], SlCheckbox.prototype, "hasFocus", 2);
|
|
4057
|
-
__decorateClass([
|
|
4058
|
-
n5()
|
|
4059
|
-
], SlCheckbox.prototype, "title", 2);
|
|
4060
|
-
__decorateClass([
|
|
4061
|
-
n5()
|
|
4062
|
-
], SlCheckbox.prototype, "name", 2);
|
|
4063
|
-
__decorateClass([
|
|
4064
|
-
n5()
|
|
4065
|
-
], SlCheckbox.prototype, "value", 2);
|
|
4066
|
-
__decorateClass([
|
|
4067
|
-
n5({ reflect: true })
|
|
4068
|
-
], SlCheckbox.prototype, "size", 2);
|
|
4069
|
-
__decorateClass([
|
|
4070
|
-
n5({ type: Boolean, reflect: true })
|
|
4071
|
-
], SlCheckbox.prototype, "disabled", 2);
|
|
4072
|
-
__decorateClass([
|
|
4073
|
-
n5({ type: Boolean, reflect: true })
|
|
4074
|
-
], SlCheckbox.prototype, "checked", 2);
|
|
4075
|
-
__decorateClass([
|
|
4076
|
-
n5({ type: Boolean, reflect: true })
|
|
4077
|
-
], SlCheckbox.prototype, "indeterminate", 2);
|
|
4078
|
-
__decorateClass([
|
|
4079
|
-
defaultValue("checked")
|
|
4080
|
-
], SlCheckbox.prototype, "defaultChecked", 2);
|
|
4081
|
-
__decorateClass([
|
|
4082
|
-
n5({ reflect: true })
|
|
4083
|
-
], SlCheckbox.prototype, "form", 2);
|
|
4084
|
-
__decorateClass([
|
|
4085
|
-
n5({ type: Boolean, reflect: true })
|
|
4086
|
-
], SlCheckbox.prototype, "required", 2);
|
|
4087
|
-
__decorateClass([
|
|
4088
|
-
n5({ attribute: "help-text" })
|
|
4089
|
-
], SlCheckbox.prototype, "helpText", 2);
|
|
4090
|
-
__decorateClass([
|
|
4091
|
-
watch("disabled", { waitUntilFirstUpdate: true })
|
|
4092
|
-
], SlCheckbox.prototype, "handleDisabledChange", 1);
|
|
4093
|
-
__decorateClass([
|
|
4094
|
-
watch(["checked", "indeterminate"], { waitUntilFirstUpdate: true })
|
|
4095
|
-
], SlCheckbox.prototype, "handleStateChange", 1);
|
|
4096
|
-
|
|
4097
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.2P5EQCYK.js
|
|
4098
|
-
var radio_button_styles_default = i`
|
|
4099
|
-
${button_styles_default}
|
|
4100
|
-
|
|
4101
|
-
.button__prefix,
|
|
4102
|
-
.button__suffix,
|
|
4103
|
-
.button__label {
|
|
4104
|
-
display: inline-flex;
|
|
4105
|
-
position: relative;
|
|
4106
|
-
align-items: center;
|
|
4107
|
-
}
|
|
4108
|
-
|
|
4109
|
-
/* We use a hidden input so constraint validation errors work, since they don't appear to show when used with buttons.
|
|
4110
|
-
We can't actually hide it, though, otherwise the messages will be suppressed by the browser. */
|
|
4111
|
-
.hidden-input {
|
|
4112
|
-
all: unset;
|
|
4113
|
-
position: absolute;
|
|
4114
|
-
top: 0;
|
|
4115
|
-
left: 0;
|
|
4116
|
-
bottom: 0;
|
|
4117
|
-
right: 0;
|
|
4118
|
-
outline: dotted 1px red;
|
|
4119
|
-
opacity: 0;
|
|
4120
|
-
z-index: -1;
|
|
4121
|
-
}
|
|
4122
|
-
`;
|
|
4123
|
-
|
|
4124
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.ZHOD7CUD.js
|
|
4125
|
-
var SlRadioButton = class extends ShoelaceElement {
|
|
4126
|
-
constructor() {
|
|
4127
|
-
super(...arguments);
|
|
4128
|
-
this.hasSlotController = new HasSlotController(this, "[default]", "prefix", "suffix");
|
|
4129
|
-
this.hasFocus = false;
|
|
4130
|
-
this.checked = false;
|
|
4131
|
-
this.disabled = false;
|
|
4132
|
-
this.size = "medium";
|
|
4133
|
-
this.pill = false;
|
|
4134
|
-
}
|
|
4135
|
-
connectedCallback() {
|
|
4136
|
-
super.connectedCallback();
|
|
4137
|
-
this.setAttribute("role", "presentation");
|
|
4138
|
-
}
|
|
4139
|
-
handleBlur() {
|
|
4140
|
-
this.hasFocus = false;
|
|
4141
|
-
this.emit("sl-blur");
|
|
4142
|
-
}
|
|
4143
|
-
handleClick(e7) {
|
|
4144
|
-
if (this.disabled) {
|
|
4145
|
-
e7.preventDefault();
|
|
4146
|
-
e7.stopPropagation();
|
|
4147
|
-
return;
|
|
4148
|
-
}
|
|
4149
|
-
this.checked = true;
|
|
4150
|
-
}
|
|
4151
|
-
handleFocus() {
|
|
4152
|
-
this.hasFocus = true;
|
|
4153
|
-
this.emit("sl-focus");
|
|
4154
|
-
}
|
|
4155
|
-
handleDisabledChange() {
|
|
4156
|
-
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
4157
|
-
}
|
|
4158
|
-
/** Sets focus on the radio button. */
|
|
4159
|
-
focus(options) {
|
|
4160
|
-
this.input.focus(options);
|
|
4161
|
-
}
|
|
4162
|
-
/** Removes focus from the radio button. */
|
|
4163
|
-
blur() {
|
|
4164
|
-
this.input.blur();
|
|
4165
|
-
}
|
|
4166
|
-
render() {
|
|
4167
|
-
return ke3`
|
|
4168
|
-
<div part="base" role="presentation">
|
|
4169
|
-
<button
|
|
4170
|
-
part="${`button${this.checked ? " button--checked" : ""}`}"
|
|
4171
|
-
role="radio"
|
|
4172
|
-
aria-checked="${this.checked}"
|
|
4173
|
-
class=${Rt({
|
|
4174
|
-
button: true,
|
|
4175
|
-
"button--default": true,
|
|
4176
|
-
"button--small": this.size === "small",
|
|
4177
|
-
"button--medium": this.size === "medium",
|
|
4178
|
-
"button--large": this.size === "large",
|
|
4179
|
-
"button--checked": this.checked,
|
|
4180
|
-
"button--disabled": this.disabled,
|
|
4181
|
-
"button--focused": this.hasFocus,
|
|
4182
|
-
"button--outline": true,
|
|
4183
|
-
"button--pill": this.pill,
|
|
4184
|
-
"button--has-label": this.hasSlotController.test("[default]"),
|
|
4185
|
-
"button--has-prefix": this.hasSlotController.test("prefix"),
|
|
4186
|
-
"button--has-suffix": this.hasSlotController.test("suffix")
|
|
4187
|
-
})}
|
|
4188
|
-
aria-disabled=${this.disabled}
|
|
4189
|
-
type="button"
|
|
4190
|
-
value=${to(this.value)}
|
|
4191
|
-
@blur=${this.handleBlur}
|
|
4192
|
-
@focus=${this.handleFocus}
|
|
4193
|
-
@click=${this.handleClick}
|
|
4194
|
-
>
|
|
4195
|
-
<slot name="prefix" part="prefix" class="button__prefix"></slot>
|
|
4196
|
-
<slot part="label" class="button__label"></slot>
|
|
4197
|
-
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
4198
|
-
</button>
|
|
4199
|
-
</div>
|
|
4200
|
-
`;
|
|
4201
|
-
}
|
|
4202
|
-
};
|
|
4203
|
-
SlRadioButton.styles = [component_styles_default, radio_button_styles_default];
|
|
4204
|
-
__decorateClass([
|
|
4205
|
-
e5(".button")
|
|
4206
|
-
], SlRadioButton.prototype, "input", 2);
|
|
4207
|
-
__decorateClass([
|
|
4208
|
-
e5(".hidden-input")
|
|
4209
|
-
], SlRadioButton.prototype, "hiddenInput", 2);
|
|
4210
|
-
__decorateClass([
|
|
4211
|
-
r5()
|
|
4212
|
-
], SlRadioButton.prototype, "hasFocus", 2);
|
|
4213
|
-
__decorateClass([
|
|
4214
|
-
n5({ type: Boolean, reflect: true })
|
|
4215
|
-
], SlRadioButton.prototype, "checked", 2);
|
|
4216
|
-
__decorateClass([
|
|
4217
|
-
n5()
|
|
4218
|
-
], SlRadioButton.prototype, "value", 2);
|
|
4219
|
-
__decorateClass([
|
|
4220
|
-
n5({ type: Boolean, reflect: true })
|
|
4221
|
-
], SlRadioButton.prototype, "disabled", 2);
|
|
4222
|
-
__decorateClass([
|
|
4223
|
-
n5({ reflect: true })
|
|
4224
|
-
], SlRadioButton.prototype, "size", 2);
|
|
4225
|
-
__decorateClass([
|
|
4226
|
-
n5({ type: Boolean, reflect: true })
|
|
4227
|
-
], SlRadioButton.prototype, "pill", 2);
|
|
4228
|
-
__decorateClass([
|
|
4229
|
-
watch("disabled", { waitUntilFirstUpdate: true })
|
|
4230
|
-
], SlRadioButton.prototype, "handleDisabledChange", 1);
|
|
4231
|
-
|
|
4232
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.B63YXDJO.js
|
|
4233
|
-
var radio_group_styles_default = i`
|
|
4234
|
-
:host {
|
|
4235
|
-
display: block;
|
|
4236
|
-
}
|
|
4237
|
-
|
|
4238
|
-
.form-control {
|
|
4239
|
-
position: relative;
|
|
4240
|
-
border: none;
|
|
4241
|
-
padding: 0;
|
|
4242
|
-
margin: 0;
|
|
4243
|
-
}
|
|
4244
|
-
|
|
4245
|
-
.form-control__label {
|
|
4246
|
-
padding: 0;
|
|
4247
|
-
}
|
|
4248
|
-
|
|
4249
|
-
.radio-group--required .radio-group__label::after {
|
|
4250
|
-
content: var(--sl-input-required-content);
|
|
4251
|
-
margin-inline-start: var(--sl-input-required-content-offset);
|
|
4252
|
-
}
|
|
4253
|
-
|
|
4254
|
-
.visually-hidden {
|
|
4255
|
-
position: absolute;
|
|
4256
|
-
width: 1px;
|
|
4257
|
-
height: 1px;
|
|
4258
|
-
padding: 0;
|
|
4259
|
-
margin: -1px;
|
|
4260
|
-
overflow: hidden;
|
|
4261
|
-
clip: rect(0, 0, 0, 0);
|
|
4262
|
-
white-space: nowrap;
|
|
4263
|
-
border: 0;
|
|
4264
|
-
}
|
|
4265
|
-
`;
|
|
4266
|
-
|
|
4267
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.2OUC42YY.js
|
|
4268
|
-
var button_group_styles_default = i`
|
|
4269
|
-
:host {
|
|
4270
|
-
display: inline-block;
|
|
4271
|
-
}
|
|
4272
|
-
|
|
4273
|
-
.button-group {
|
|
4274
|
-
display: flex;
|
|
4275
|
-
flex-wrap: nowrap;
|
|
4276
|
-
}
|
|
4277
|
-
`;
|
|
4278
|
-
|
|
4279
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.RBPP5PLA.js
|
|
4280
|
-
var SlButtonGroup = class extends ShoelaceElement {
|
|
4281
|
-
constructor() {
|
|
4282
|
-
super(...arguments);
|
|
4283
|
-
this.disableRole = false;
|
|
4284
|
-
this.label = "";
|
|
4285
|
-
}
|
|
4286
|
-
handleFocus(event) {
|
|
4287
|
-
const button = findButton(event.target);
|
|
4288
|
-
button == null ? void 0 : button.toggleAttribute("data-sl-button-group__button--focus", true);
|
|
4289
|
-
}
|
|
4290
|
-
handleBlur(event) {
|
|
4291
|
-
const button = findButton(event.target);
|
|
4292
|
-
button == null ? void 0 : button.toggleAttribute("data-sl-button-group__button--focus", false);
|
|
4293
|
-
}
|
|
4294
|
-
handleMouseOver(event) {
|
|
4295
|
-
const button = findButton(event.target);
|
|
4296
|
-
button == null ? void 0 : button.toggleAttribute("data-sl-button-group__button--hover", true);
|
|
4297
|
-
}
|
|
4298
|
-
handleMouseOut(event) {
|
|
4299
|
-
const button = findButton(event.target);
|
|
4300
|
-
button == null ? void 0 : button.toggleAttribute("data-sl-button-group__button--hover", false);
|
|
4301
|
-
}
|
|
4302
|
-
handleSlotChange() {
|
|
4303
|
-
const slottedElements = [...this.defaultSlot.assignedElements({ flatten: true })];
|
|
4304
|
-
slottedElements.forEach((el) => {
|
|
4305
|
-
const index = slottedElements.indexOf(el);
|
|
4306
|
-
const button = findButton(el);
|
|
4307
|
-
if (button) {
|
|
4308
|
-
button.toggleAttribute("data-sl-button-group__button", true);
|
|
4309
|
-
button.toggleAttribute("data-sl-button-group__button--first", index === 0);
|
|
4310
|
-
button.toggleAttribute("data-sl-button-group__button--inner", index > 0 && index < slottedElements.length - 1);
|
|
4311
|
-
button.toggleAttribute("data-sl-button-group__button--last", index === slottedElements.length - 1);
|
|
4312
|
-
button.toggleAttribute(
|
|
4313
|
-
"data-sl-button-group__button--radio",
|
|
4314
|
-
button.tagName.toLowerCase() === "sl-radio-button"
|
|
4315
|
-
);
|
|
4316
|
-
}
|
|
4317
|
-
});
|
|
4318
|
-
}
|
|
4319
|
-
render() {
|
|
4320
|
-
return ke`
|
|
4321
|
-
<div
|
|
4322
|
-
part="base"
|
|
4323
|
-
class="button-group"
|
|
4324
|
-
role="${this.disableRole ? "presentation" : "group"}"
|
|
4325
|
-
aria-label=${this.label}
|
|
4326
|
-
@focusout=${this.handleBlur}
|
|
4327
|
-
@focusin=${this.handleFocus}
|
|
4328
|
-
@mouseover=${this.handleMouseOver}
|
|
4329
|
-
@mouseout=${this.handleMouseOut}
|
|
4330
|
-
>
|
|
4331
|
-
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
4332
|
-
</div>
|
|
4333
|
-
`;
|
|
4334
|
-
}
|
|
4335
|
-
};
|
|
4336
|
-
SlButtonGroup.styles = [component_styles_default, button_group_styles_default];
|
|
4337
|
-
__decorateClass([
|
|
4338
|
-
e5("slot")
|
|
4339
|
-
], SlButtonGroup.prototype, "defaultSlot", 2);
|
|
4340
|
-
__decorateClass([
|
|
4341
|
-
r5()
|
|
4342
|
-
], SlButtonGroup.prototype, "disableRole", 2);
|
|
4343
|
-
__decorateClass([
|
|
4344
|
-
n5()
|
|
4345
|
-
], SlButtonGroup.prototype, "label", 2);
|
|
4346
|
-
function findButton(el) {
|
|
4347
|
-
var _a4;
|
|
4348
|
-
const selector = "sl-button, sl-radio-button";
|
|
4349
|
-
return (_a4 = el.closest(selector)) != null ? _a4 : el.querySelector(selector);
|
|
4350
|
-
}
|
|
4351
|
-
|
|
4352
|
-
// ../../node_modules/@shoelace-style/shoelace/dist/chunks/chunk.XISPCK6C.js
|
|
4353
|
-
var SlRadioGroup = class extends ShoelaceElement {
|
|
4354
|
-
constructor() {
|
|
4355
|
-
super(...arguments);
|
|
4356
|
-
this.formControlController = new FormControlController(this);
|
|
4357
|
-
this.hasSlotController = new HasSlotController(this, "help-text", "label");
|
|
4358
|
-
this.customValidityMessage = "";
|
|
4359
|
-
this.hasButtonGroup = false;
|
|
4360
|
-
this.errorMessage = "";
|
|
4361
|
-
this.defaultValue = "";
|
|
4362
|
-
this.label = "";
|
|
4363
|
-
this.helpText = "";
|
|
4364
|
-
this.name = "option";
|
|
4365
|
-
this.value = "";
|
|
4366
|
-
this.size = "medium";
|
|
4367
|
-
this.form = "";
|
|
4368
|
-
this.required = false;
|
|
4369
|
-
}
|
|
4370
|
-
/** Gets the validity state object */
|
|
4371
|
-
get validity() {
|
|
4372
|
-
const isRequiredAndEmpty = this.required && !this.value;
|
|
4373
|
-
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
4374
|
-
if (hasCustomValidityMessage) {
|
|
4375
|
-
return customErrorValidityState;
|
|
4376
|
-
} else if (isRequiredAndEmpty) {
|
|
4377
|
-
return valueMissingValidityState;
|
|
4378
|
-
}
|
|
4379
|
-
return validValidityState;
|
|
4380
|
-
}
|
|
4381
|
-
/** Gets the validation message */
|
|
4382
|
-
get validationMessage() {
|
|
4383
|
-
const isRequiredAndEmpty = this.required && !this.value;
|
|
4384
|
-
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
4385
|
-
if (hasCustomValidityMessage) {
|
|
4386
|
-
return this.customValidityMessage;
|
|
4387
|
-
} else if (isRequiredAndEmpty) {
|
|
4388
|
-
return this.validationInput.validationMessage;
|
|
4389
|
-
}
|
|
4390
|
-
return "";
|
|
4391
|
-
}
|
|
4392
|
-
connectedCallback() {
|
|
4393
|
-
super.connectedCallback();
|
|
4394
|
-
this.defaultValue = this.value;
|
|
4395
|
-
}
|
|
4396
|
-
firstUpdated() {
|
|
4397
|
-
this.formControlController.updateValidity();
|
|
4398
|
-
}
|
|
4399
|
-
getAllRadios() {
|
|
4400
|
-
return [...this.querySelectorAll("sl-radio, sl-radio-button")];
|
|
4401
|
-
}
|
|
4402
|
-
handleRadioClick(event) {
|
|
4403
|
-
const target = event.target.closest("sl-radio, sl-radio-button");
|
|
4404
|
-
const radios = this.getAllRadios();
|
|
4405
|
-
const oldValue = this.value;
|
|
4406
|
-
if (!target || target.disabled) {
|
|
4407
|
-
return;
|
|
4408
|
-
}
|
|
4409
|
-
this.value = target.value;
|
|
4410
|
-
radios.forEach((radio) => radio.checked = radio === target);
|
|
4411
|
-
if (this.value !== oldValue) {
|
|
4412
|
-
this.emit("sl-change");
|
|
4413
|
-
this.emit("sl-input");
|
|
4414
|
-
}
|
|
4415
|
-
}
|
|
4416
|
-
handleKeyDown(event) {
|
|
4417
|
-
var _a4;
|
|
4418
|
-
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "].includes(event.key)) {
|
|
4419
|
-
return;
|
|
4420
|
-
}
|
|
4421
|
-
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
4422
|
-
const checkedRadio = (_a4 = radios.find((radio) => radio.checked)) != null ? _a4 : radios[0];
|
|
4423
|
-
const incr = event.key === " " ? 0 : ["ArrowUp", "ArrowLeft"].includes(event.key) ? -1 : 1;
|
|
4424
|
-
const oldValue = this.value;
|
|
4425
|
-
let index = radios.indexOf(checkedRadio) + incr;
|
|
4426
|
-
if (index < 0) {
|
|
4427
|
-
index = radios.length - 1;
|
|
4428
|
-
}
|
|
4429
|
-
if (index > radios.length - 1) {
|
|
4430
|
-
index = 0;
|
|
4431
|
-
}
|
|
4432
|
-
this.getAllRadios().forEach((radio) => {
|
|
4433
|
-
radio.checked = false;
|
|
4434
|
-
if (!this.hasButtonGroup) {
|
|
4435
|
-
radio.setAttribute("tabindex", "-1");
|
|
4436
|
-
}
|
|
4437
|
-
});
|
|
4438
|
-
this.value = radios[index].value;
|
|
4439
|
-
radios[index].checked = true;
|
|
4440
|
-
if (!this.hasButtonGroup) {
|
|
4441
|
-
radios[index].setAttribute("tabindex", "0");
|
|
4442
|
-
radios[index].focus();
|
|
4443
|
-
} else {
|
|
4444
|
-
radios[index].shadowRoot.querySelector("button").focus();
|
|
4445
|
-
}
|
|
4446
|
-
if (this.value !== oldValue) {
|
|
4447
|
-
this.emit("sl-change");
|
|
4448
|
-
this.emit("sl-input");
|
|
4449
|
-
}
|
|
4450
|
-
event.preventDefault();
|
|
4451
|
-
}
|
|
4452
|
-
handleLabelClick() {
|
|
4453
|
-
const radios = this.getAllRadios();
|
|
4454
|
-
const checked = radios.find((radio) => radio.checked);
|
|
4455
|
-
const radioToFocus = checked || radios[0];
|
|
4456
|
-
if (radioToFocus) {
|
|
4457
|
-
radioToFocus.focus();
|
|
4458
|
-
}
|
|
4459
|
-
}
|
|
4460
|
-
handleInvalid(event) {
|
|
4461
|
-
this.formControlController.setValidity(false);
|
|
4462
|
-
this.formControlController.emitInvalidEvent(event);
|
|
4463
|
-
}
|
|
4464
|
-
async syncRadioElements() {
|
|
4465
|
-
var _a4, _b;
|
|
4466
|
-
const radios = this.getAllRadios();
|
|
4467
|
-
await Promise.all(
|
|
4468
|
-
// Sync the checked state and size
|
|
4469
|
-
radios.map(async (radio) => {
|
|
4470
|
-
await radio.updateComplete;
|
|
4471
|
-
radio.checked = radio.value === this.value;
|
|
4472
|
-
radio.size = this.size;
|
|
4473
|
-
})
|
|
4474
|
-
);
|
|
4475
|
-
this.hasButtonGroup = radios.some((radio) => radio.tagName.toLowerCase() === "sl-radio-button");
|
|
4476
|
-
if (radios.length > 0 && !radios.some((radio) => radio.checked)) {
|
|
4477
|
-
if (this.hasButtonGroup) {
|
|
4478
|
-
const buttonRadio = (_a4 = radios[0].shadowRoot) == null ? void 0 : _a4.querySelector("button");
|
|
4479
|
-
if (buttonRadio) {
|
|
4480
|
-
buttonRadio.setAttribute("tabindex", "0");
|
|
4481
|
-
}
|
|
4482
|
-
} else {
|
|
4483
|
-
radios[0].setAttribute("tabindex", "0");
|
|
4484
|
-
}
|
|
4485
|
-
}
|
|
4486
|
-
if (this.hasButtonGroup) {
|
|
4487
|
-
const buttonGroup = (_b = this.shadowRoot) == null ? void 0 : _b.querySelector("sl-button-group");
|
|
4488
|
-
if (buttonGroup) {
|
|
4489
|
-
buttonGroup.disableRole = true;
|
|
4490
|
-
}
|
|
4491
|
-
}
|
|
4492
|
-
}
|
|
4493
|
-
syncRadios() {
|
|
4494
|
-
if (customElements.get("sl-radio") && customElements.get("sl-radio-button")) {
|
|
4495
|
-
this.syncRadioElements();
|
|
4496
|
-
return;
|
|
4497
|
-
}
|
|
4498
|
-
if (customElements.get("sl-radio")) {
|
|
4499
|
-
this.syncRadioElements();
|
|
4500
|
-
} else {
|
|
4501
|
-
customElements.whenDefined("sl-radio").then(() => this.syncRadios());
|
|
4502
|
-
}
|
|
4503
|
-
if (customElements.get("sl-radio-button")) {
|
|
4504
|
-
this.syncRadioElements();
|
|
4505
|
-
} else {
|
|
4506
|
-
customElements.whenDefined("sl-radio-button").then(() => this.syncRadios());
|
|
4507
|
-
}
|
|
4508
|
-
}
|
|
4509
|
-
updateCheckedRadio() {
|
|
4510
|
-
const radios = this.getAllRadios();
|
|
4511
|
-
radios.forEach((radio) => radio.checked = radio.value === this.value);
|
|
4512
|
-
this.formControlController.setValidity(this.validity.valid);
|
|
4513
|
-
}
|
|
4514
|
-
handleSizeChange() {
|
|
4515
|
-
this.syncRadios();
|
|
4516
|
-
}
|
|
4517
|
-
handleValueChange() {
|
|
4518
|
-
if (this.hasUpdated) {
|
|
4519
|
-
this.updateCheckedRadio();
|
|
4520
|
-
}
|
|
4521
|
-
}
|
|
4522
|
-
/** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
|
|
4523
|
-
checkValidity() {
|
|
4524
|
-
const isRequiredAndEmpty = this.required && !this.value;
|
|
4525
|
-
const hasCustomValidityMessage = this.customValidityMessage !== "";
|
|
4526
|
-
if (isRequiredAndEmpty || hasCustomValidityMessage) {
|
|
4527
|
-
this.formControlController.emitInvalidEvent();
|
|
4528
|
-
return false;
|
|
4529
|
-
}
|
|
4530
|
-
return true;
|
|
4531
|
-
}
|
|
4532
|
-
/** Gets the associated form, if one exists. */
|
|
4533
|
-
getForm() {
|
|
4534
|
-
return this.formControlController.getForm();
|
|
4535
|
-
}
|
|
4536
|
-
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
4537
|
-
reportValidity() {
|
|
4538
|
-
const isValid = this.validity.valid;
|
|
4539
|
-
this.errorMessage = this.customValidityMessage || isValid ? "" : this.validationInput.validationMessage;
|
|
4540
|
-
this.formControlController.setValidity(isValid);
|
|
4541
|
-
this.validationInput.hidden = true;
|
|
4542
|
-
clearTimeout(this.validationTimeout);
|
|
4543
|
-
if (!isValid) {
|
|
4544
|
-
this.validationInput.hidden = false;
|
|
4545
|
-
this.validationInput.reportValidity();
|
|
4546
|
-
this.validationTimeout = setTimeout(() => this.validationInput.hidden = true, 1e4);
|
|
4547
|
-
}
|
|
4548
|
-
return isValid;
|
|
4549
|
-
}
|
|
4550
|
-
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
4551
|
-
setCustomValidity(message = "") {
|
|
4552
|
-
this.customValidityMessage = message;
|
|
4553
|
-
this.errorMessage = message;
|
|
4554
|
-
this.validationInput.setCustomValidity(message);
|
|
4555
|
-
this.formControlController.updateValidity();
|
|
4556
|
-
}
|
|
4557
|
-
render() {
|
|
4558
|
-
const hasLabelSlot = this.hasSlotController.test("label");
|
|
4559
|
-
const hasHelpTextSlot = this.hasSlotController.test("help-text");
|
|
4560
|
-
const hasLabel = this.label ? true : !!hasLabelSlot;
|
|
4561
|
-
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
|
|
4562
|
-
const defaultSlot = ke`
|
|
4563
|
-
<slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
|
|
4564
|
-
`;
|
|
4565
|
-
return ke`
|
|
4566
|
-
<fieldset
|
|
4567
|
-
part="form-control"
|
|
4568
|
-
class=${Rt({
|
|
4569
|
-
"form-control": true,
|
|
4570
|
-
"form-control--small": this.size === "small",
|
|
4571
|
-
"form-control--medium": this.size === "medium",
|
|
4572
|
-
"form-control--large": this.size === "large",
|
|
4573
|
-
"form-control--radio-group": true,
|
|
4574
|
-
"form-control--has-label": hasLabel,
|
|
4575
|
-
"form-control--has-help-text": hasHelpText
|
|
4576
|
-
})}
|
|
4577
|
-
role="radiogroup"
|
|
4578
|
-
aria-labelledby="label"
|
|
4579
|
-
aria-describedby="help-text"
|
|
4580
|
-
aria-errormessage="error-message"
|
|
4581
|
-
>
|
|
4582
|
-
<label
|
|
4583
|
-
part="form-control-label"
|
|
4584
|
-
id="label"
|
|
4585
|
-
class="form-control__label"
|
|
4586
|
-
aria-hidden=${hasLabel ? "false" : "true"}
|
|
4587
|
-
@click=${this.handleLabelClick}
|
|
4588
|
-
>
|
|
4589
|
-
<slot name="label">${this.label}</slot>
|
|
4590
|
-
</label>
|
|
4591
|
-
|
|
4592
|
-
<div part="form-control-input" class="form-control-input">
|
|
4593
|
-
<div class="visually-hidden">
|
|
4594
|
-
<div id="error-message" aria-live="assertive">${this.errorMessage}</div>
|
|
4595
|
-
<label class="radio-group__validation">
|
|
4596
|
-
<input
|
|
4597
|
-
type="text"
|
|
4598
|
-
class="radio-group__validation-input"
|
|
4599
|
-
?required=${this.required}
|
|
4600
|
-
tabindex="-1"
|
|
4601
|
-
hidden
|
|
4602
|
-
@invalid=${this.handleInvalid}
|
|
4603
|
-
/>
|
|
4604
|
-
</label>
|
|
4605
|
-
</div>
|
|
4606
|
-
|
|
4607
|
-
${this.hasButtonGroup ? ke`
|
|
4608
|
-
<sl-button-group part="button-group" exportparts="base:button-group__base" role="presentation">
|
|
4609
|
-
${defaultSlot}
|
|
4610
|
-
</sl-button-group>
|
|
4611
|
-
` : defaultSlot}
|
|
4612
|
-
</div>
|
|
4613
|
-
|
|
4614
|
-
<div
|
|
4615
|
-
part="form-control-help-text"
|
|
4616
|
-
id="help-text"
|
|
4617
|
-
class="form-control__help-text"
|
|
4618
|
-
aria-hidden=${hasHelpText ? "false" : "true"}
|
|
4619
|
-
>
|
|
4620
|
-
<slot name="help-text">${this.helpText}</slot>
|
|
4621
|
-
</div>
|
|
4622
|
-
</fieldset>
|
|
4623
|
-
`;
|
|
4624
|
-
}
|
|
4625
|
-
};
|
|
4626
|
-
SlRadioGroup.styles = [component_styles_default, form_control_styles_default, radio_group_styles_default];
|
|
4627
|
-
SlRadioGroup.dependencies = { "sl-button-group": SlButtonGroup };
|
|
4628
|
-
__decorateClass([
|
|
4629
|
-
e5("slot:not([name])")
|
|
4630
|
-
], SlRadioGroup.prototype, "defaultSlot", 2);
|
|
4631
|
-
__decorateClass([
|
|
4632
|
-
e5(".radio-group__validation-input")
|
|
4633
|
-
], SlRadioGroup.prototype, "validationInput", 2);
|
|
4634
|
-
__decorateClass([
|
|
4635
|
-
r5()
|
|
4636
|
-
], SlRadioGroup.prototype, "hasButtonGroup", 2);
|
|
4637
|
-
__decorateClass([
|
|
4638
|
-
r5()
|
|
4639
|
-
], SlRadioGroup.prototype, "errorMessage", 2);
|
|
4640
|
-
__decorateClass([
|
|
4641
|
-
r5()
|
|
4642
|
-
], SlRadioGroup.prototype, "defaultValue", 2);
|
|
4643
|
-
__decorateClass([
|
|
4644
|
-
n5()
|
|
4645
|
-
], SlRadioGroup.prototype, "label", 2);
|
|
4646
|
-
__decorateClass([
|
|
4647
|
-
n5({ attribute: "help-text" })
|
|
4648
|
-
], SlRadioGroup.prototype, "helpText", 2);
|
|
4649
|
-
__decorateClass([
|
|
4650
|
-
n5()
|
|
4651
|
-
], SlRadioGroup.prototype, "name", 2);
|
|
4652
|
-
__decorateClass([
|
|
4653
|
-
n5({ reflect: true })
|
|
4654
|
-
], SlRadioGroup.prototype, "value", 2);
|
|
4655
|
-
__decorateClass([
|
|
4656
|
-
n5({ reflect: true })
|
|
4657
|
-
], SlRadioGroup.prototype, "size", 2);
|
|
4658
|
-
__decorateClass([
|
|
4659
|
-
n5({ reflect: true })
|
|
4660
|
-
], SlRadioGroup.prototype, "form", 2);
|
|
4661
|
-
__decorateClass([
|
|
4662
|
-
n5({ type: Boolean, reflect: true })
|
|
4663
|
-
], SlRadioGroup.prototype, "required", 2);
|
|
4664
|
-
__decorateClass([
|
|
4665
|
-
watch("size", { waitUntilFirstUpdate: true })
|
|
4666
|
-
], SlRadioGroup.prototype, "handleSizeChange", 1);
|
|
4667
|
-
__decorateClass([
|
|
4668
|
-
watch("value")
|
|
4669
|
-
], SlRadioGroup.prototype, "handleValueChange", 1);
|
|
4670
|
-
|
|
4671
|
-
// ../../node_modules/bootstrap-icons/icons/plus-square.svg
|
|
4672
|
-
var plus_square_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-square" viewBox="0 0 16 16">%0A <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z"/>%0A <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>%0A</svg>';
|
|
4673
|
-
|
|
4674
|
-
// ../../node_modules/bootstrap-icons/icons/plus-circle.svg
|
|
4675
|
-
var plus_circle_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">%0A <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>%0A <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>%0A</svg>';
|
|
4676
|
-
|
|
4677
|
-
// src/widgets/webwriter-choice.ts
|
|
4678
|
-
function shuffle(a3) {
|
|
4679
|
-
for (let i4 = a3.length - 1; i4 > 0; i4--) {
|
|
4680
|
-
const j3 = Math.floor(Math.random() * (i4 + 1));
|
|
4681
|
-
[a3[i4], a3[j3]] = [a3[j3], a3[i4]];
|
|
4682
|
-
}
|
|
4683
|
-
return a3;
|
|
4684
|
-
}
|
|
4685
|
-
var _itemsSlotEl_dec, _value_dec, _items_dec, _addItem_dec, _slotEl_dec, _randomOrder_dec, _layout_dec, _mode_dec, _a2, _WebwriterChoice_decorators, _init2, _mode, _randomOrder, _slotEl, _items, _value, _itemsSlotEl;
|
|
4686
|
-
_WebwriterChoice_decorators = [t3("webwriter-choice")];
|
|
4687
|
-
var WebwriterChoice = class extends (_a2 = LitElementWw, _mode_dec = [n5({ type: String, attribute: true, reflect: true }), option({
|
|
4688
|
-
type: "select",
|
|
4689
|
-
options: [
|
|
4690
|
-
{ value: "truefalse", label: { "en": "True/False" } },
|
|
4691
|
-
{ value: "single", label: { "en": "Single Choice" } },
|
|
4692
|
-
{ value: "multiple", label: { "en": "Multiple Choice" } }
|
|
4693
|
-
]
|
|
4694
|
-
})], _layout_dec = [n5({ type: String, attribute: true, reflect: true }), option({
|
|
4695
|
-
type: "select",
|
|
4696
|
-
options: [
|
|
4697
|
-
{ value: "list", label: { "en": "List" } },
|
|
4698
|
-
{ value: "tiles", label: { "en": "Tiles" } }
|
|
4699
|
-
]
|
|
4700
|
-
})], _randomOrder_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({
|
|
4701
|
-
type: Boolean,
|
|
4702
|
-
label: { "en": "Random Choice Order" }
|
|
4703
|
-
})], _slotEl_dec = [e5("slot")], _addItem_dec = [action()], _items_dec = [o5()], _value_dec = [n5({ type: Array, attribute: false })], _itemsSlotEl_dec = [e5("#items-slot")], _a2) {
|
|
4704
|
-
constructor() {
|
|
4705
|
-
super(...arguments);
|
|
4706
|
-
__runInitializers(_init2, 5, this);
|
|
4707
|
-
__privateAdd(this, _mode, __runInitializers(_init2, 8, this, "single")), __runInitializers(_init2, 11, this);
|
|
4708
|
-
__privateAdd(this, _randomOrder, __runInitializers(_init2, 12, this, false)), __runInitializers(_init2, 15, this);
|
|
4709
|
-
__privateAdd(this, _slotEl, __runInitializers(_init2, 16, this)), __runInitializers(_init2, 19, this);
|
|
4710
|
-
__privateAdd(this, _items, __runInitializers(_init2, 20, this)), __runInitializers(_init2, 23, this);
|
|
4711
|
-
__privateAdd(this, _value, []);
|
|
4712
|
-
__publicField(this, "handleControlChange", (e7) => {
|
|
4713
|
-
if (this.mode === "single") {
|
|
4714
|
-
const item = e7.target;
|
|
4715
|
-
const otherItems = this.items.filter((el) => el !== item);
|
|
4716
|
-
otherItems.forEach((el) => this.isContentEditable ? el.valid = false : el.active = false);
|
|
4717
|
-
}
|
|
4718
|
-
this.applyValue();
|
|
4719
|
-
this.dispatchEvent(new CustomEvent("ww-answer-change", {
|
|
4720
|
-
detail: { value: this.value },
|
|
4721
|
-
bubbles: true,
|
|
4722
|
-
composed: true
|
|
4723
|
-
}));
|
|
4724
|
-
});
|
|
4725
|
-
__privateAdd(this, _itemsSlotEl, __runInitializers(_init2, 24, this)), __runInitializers(_init2, 27, this);
|
|
4726
|
-
}
|
|
4727
|
-
get layout() {
|
|
4728
|
-
return this.children?.item(0)?.getAttribute("layout") ?? "list";
|
|
4729
|
-
}
|
|
4730
|
-
set layout(value) {
|
|
4731
|
-
this.querySelectorAll("webwriter-choice-item").forEach((el) => el.setAttribute("layout", value));
|
|
4732
|
-
this.requestUpdate("layout");
|
|
4733
|
-
}
|
|
4734
|
-
get solution() {
|
|
4735
|
-
const validIDs = this.items.filter((item) => item.valid).map((item) => item.id);
|
|
4736
|
-
return validIDs.length ? validIDs : void 0;
|
|
4737
|
-
}
|
|
4738
|
-
set solution(value) {
|
|
4739
|
-
this.items.forEach((item) => value.includes(item.id) ? item.valid = true : null);
|
|
4740
|
-
}
|
|
4741
|
-
reportSolution() {
|
|
4742
|
-
if (!this.solution) {
|
|
4743
|
-
this.items.forEach((item) => item.valid = true);
|
|
4744
|
-
return;
|
|
4745
|
-
}
|
|
4746
|
-
this.items.forEach((item) => item.valid = (this.solution ?? []).includes(item.id));
|
|
4747
|
-
}
|
|
4748
|
-
reset() {
|
|
4749
|
-
this.items.forEach((item) => {
|
|
4750
|
-
item.valid = void 0;
|
|
4751
|
-
item.active = false;
|
|
4752
|
-
});
|
|
4753
|
-
this.shuffleItems();
|
|
4754
|
-
}
|
|
4755
|
-
addItem() {
|
|
4756
|
-
const choiceItem = this.ownerDocument.createElement("webwriter-choice-item");
|
|
4757
|
-
const p3 = this.ownerDocument.createElement("p");
|
|
4758
|
-
choiceItem.appendChild(p3);
|
|
4759
|
-
choiceItem.setAttribute("layout", this.layout);
|
|
4760
|
-
this.appendChild(choiceItem);
|
|
4761
|
-
this.ownerDocument.getSelection().setBaseAndExtent(p3, 0, p3, 0);
|
|
4762
|
-
}
|
|
4763
|
-
shuffleItems() {
|
|
4764
|
-
const items = this.slotEl.assignedElements();
|
|
4765
|
-
const n6 = items.length;
|
|
4766
|
-
const nums = shuffle([...new Array(n6).keys()]);
|
|
4767
|
-
items.forEach((el, i4) => el.style.order = String(nums[i4]));
|
|
4768
|
-
}
|
|
4769
|
-
connectedCallback() {
|
|
4770
|
-
super.connectedCallback();
|
|
4771
|
-
const observer = new MutationObserver(() => {
|
|
4772
|
-
if (!this.contentEditable && this.randomOrder) {
|
|
4773
|
-
this.shuffleItems();
|
|
4774
|
-
}
|
|
4775
|
-
});
|
|
4776
|
-
observer.observe(this, { childList: true });
|
|
4777
|
-
}
|
|
4778
|
-
firstUpdated(_changedProperties) {
|
|
4779
|
-
if (!this.contentEditable && this.randomOrder) {
|
|
4780
|
-
this.shuffleItems();
|
|
4781
|
-
}
|
|
4782
|
-
}
|
|
4783
|
-
get value() {
|
|
4784
|
-
return __privateGet(this, _value);
|
|
4785
|
-
}
|
|
4786
|
-
set value(value) {
|
|
4787
|
-
__privateSet(this, _value, value);
|
|
4788
|
-
this.items.forEach((item, i4) => {
|
|
4789
|
-
this.isContentEditable ? item.valid = __privateGet(this, _value).includes(i4) : item.active = __privateGet(this, _value).includes(i4);
|
|
4790
|
-
});
|
|
4791
|
-
}
|
|
4792
|
-
applyValue() {
|
|
4793
|
-
__privateSet(this, _value, this.items.map((item, i4) => [item.valid, i4]).filter(([valid]) => valid).map(([_3, i4]) => i4));
|
|
4794
|
-
}
|
|
4795
|
-
handleSlotChange(e7) {
|
|
4796
|
-
this.requestUpdate();
|
|
4797
|
-
}
|
|
4798
|
-
willUpdate(changed) {
|
|
4799
|
-
if (changed.has("mode") && this.mode === "single") {
|
|
4800
|
-
this.items.filter((el) => this.isContentEditable ? el.valid : el.active).slice(1).forEach((el) => this.isContentEditable ? el.valid = false : el.active = false);
|
|
4801
|
-
}
|
|
4802
|
-
if (changed.has("mode") && this.mode === "truefalse") {
|
|
4803
|
-
this.items.forEach((el) => el.remove());
|
|
4804
|
-
}
|
|
4805
|
-
}
|
|
4806
|
-
render() {
|
|
4807
|
-
return ke`
|
|
4808
|
-
${this.mode === "truefalse" ? ke`
|
|
4809
|
-
<sl-radio-group>
|
|
4810
|
-
<sl-radio-button value="true">True</sl-radio-button>
|
|
4811
|
-
<sl-radio-button value="false">False</sl-radio-button>
|
|
4812
|
-
</sl-radio-group>
|
|
4813
|
-
` : ke`
|
|
4814
|
-
<slot id="items-slot" @sl-change=${this.handleControlChange} @slotchange=${this.handleSlotChange}></slot>
|
|
4815
|
-
`}
|
|
4816
|
-
<sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
|
|
4817
|
-
<sl-icon src=${this.mode === "multiple" ? plus_square_default : plus_circle_default}></sl-icon><span>Add Option</span>
|
|
4818
|
-
</sl-button>
|
|
4819
|
-
`;
|
|
4820
|
-
}
|
|
4821
|
-
};
|
|
4822
|
-
_init2 = __decoratorStart(_a2);
|
|
4823
|
-
_mode = new WeakMap();
|
|
4824
|
-
_randomOrder = new WeakMap();
|
|
4825
|
-
_slotEl = new WeakMap();
|
|
4826
|
-
_items = new WeakMap();
|
|
4827
|
-
_value = new WeakMap();
|
|
4828
|
-
_itemsSlotEl = new WeakMap();
|
|
4829
|
-
__decorateElement(_init2, 4, "mode", _mode_dec, WebwriterChoice, _mode);
|
|
4830
|
-
__decorateElement(_init2, 3, "layout", _layout_dec, WebwriterChoice);
|
|
4831
|
-
__decorateElement(_init2, 4, "randomOrder", _randomOrder_dec, WebwriterChoice, _randomOrder);
|
|
4832
|
-
__decorateElement(_init2, 4, "slotEl", _slotEl_dec, WebwriterChoice, _slotEl);
|
|
4833
|
-
__decorateElement(_init2, 1, "addItem", _addItem_dec, WebwriterChoice);
|
|
4834
|
-
__decorateElement(_init2, 4, "items", _items_dec, WebwriterChoice, _items);
|
|
4835
|
-
__decorateElement(_init2, 3, "value", _value_dec, WebwriterChoice);
|
|
4836
|
-
__decorateElement(_init2, 4, "itemsSlotEl", _itemsSlotEl_dec, WebwriterChoice, _itemsSlotEl);
|
|
4837
|
-
WebwriterChoice = __decorateElement(_init2, 0, "WebwriterChoice", _WebwriterChoice_decorators, WebwriterChoice);
|
|
4838
|
-
__publicField(WebwriterChoice, "scopedElements", {
|
|
4839
|
-
"sl-button": SlButton,
|
|
4840
|
-
"sl-icon": SlIcon,
|
|
4841
|
-
"sl-radio": SlRadio,
|
|
4842
|
-
"sl-checkbox": SlCheckbox,
|
|
4843
|
-
"sl-radio-button": SlRadioButton,
|
|
4844
|
-
"sl-radio-group": SlRadioGroup
|
|
4845
|
-
});
|
|
4846
|
-
__publicField(WebwriterChoice, "styles", i`
|
|
4847
|
-
:host {
|
|
4848
|
-
display: flex !important;
|
|
4849
|
-
flex-direction: column;
|
|
4850
|
-
align-items: flex-start;
|
|
4851
|
-
gap: 0.5rem;
|
|
4852
|
-
}
|
|
4853
|
-
|
|
4854
|
-
:host([layout=tiles]) {
|
|
4855
|
-
|
|
4856
|
-
flex-direction: row;
|
|
4857
|
-
flex-wrap: wrap;
|
|
4858
|
-
gap: 15px;
|
|
4859
|
-
|
|
4860
|
-
& ::slotted(*) {
|
|
4861
|
-
aspect-ratio: 1;
|
|
4862
|
-
min-width: 125px;
|
|
4863
|
-
width: 125px;
|
|
4864
|
-
max-width: 350px;
|
|
4865
|
-
min-height: 125px;
|
|
4866
|
-
height: 125px;
|
|
4867
|
-
max-height: 350px;
|
|
4868
|
-
overflow: hidden;
|
|
4869
|
-
resize: both;
|
|
4870
|
-
border: 2px solid var(--sl-color-gray-500);
|
|
4871
|
-
border-radius: 5px;
|
|
4872
|
-
}
|
|
4873
|
-
}
|
|
4874
|
-
|
|
4875
|
-
sl-button::part(label) {
|
|
4876
|
-
padding: 0;
|
|
4877
|
-
display: flex;
|
|
4878
|
-
flex-direction: row;
|
|
4879
|
-
align-items: center;
|
|
4880
|
-
}
|
|
4881
|
-
|
|
4882
|
-
sl-button::part(base) {
|
|
4883
|
-
border: none;
|
|
4884
|
-
background: transparent;
|
|
4885
|
-
}
|
|
4886
|
-
|
|
4887
|
-
sl-icon {
|
|
4888
|
-
width: 19px;
|
|
4889
|
-
height: 19px;
|
|
4890
|
-
}
|
|
4891
|
-
|
|
4892
|
-
sl-icon::part(svg) {
|
|
4893
|
-
overflow: visible;
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
|
-
:host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
|
|
4897
|
-
display: none !important;
|
|
4898
|
-
}
|
|
4899
|
-
|
|
4900
|
-
#add-option span {
|
|
4901
|
-
margin-inline-start: 0.5em;
|
|
4902
|
-
}
|
|
4903
|
-
|
|
4904
|
-
:host(:is([contenteditable=true], [contenteditable=""])) ::slotted(*) {
|
|
4905
|
-
order: unset !important;
|
|
4906
|
-
}
|
|
4907
|
-
|
|
4908
|
-
:host(:not([mode=multiple])) {
|
|
4909
|
-
--webwriter-choice-radius: 100%;
|
|
4910
|
-
}
|
|
4911
|
-
|
|
4912
|
-
#add-option:not(:hover)::part(base) {
|
|
4913
|
-
color: darkgray;
|
|
4914
|
-
}
|
|
4915
|
-
|
|
4916
|
-
:host([layout=tiles]) #add-option {
|
|
4917
|
-
width: 125px;
|
|
4918
|
-
height: 125px;
|
|
4919
|
-
overflow: hidden;
|
|
4920
|
-
border: 2px solid var(--sl-color-gray-300);
|
|
4921
|
-
border-radius: 5px;
|
|
4922
|
-
padding: 5px;
|
|
4923
|
-
display: flex;
|
|
4924
|
-
align-items: center;
|
|
4925
|
-
justify-content: center;
|
|
4926
|
-
}
|
|
4927
|
-
|
|
4928
|
-
:host([mode=truefalse]) #add-option {
|
|
4929
|
-
display: none;
|
|
4930
|
-
}
|
|
4931
|
-
`);
|
|
4932
|
-
__runInitializers(_init2, 1, WebwriterChoice);
|
|
4933
|
-
|
|
4934
|
-
// src/widgets/webwriter-order.ts
|
|
4935
|
-
var _solution_dec, _items_dec2, _itemsSlot_dec, _hideOrderButtons_dec, _layout_dec2, _a3, _WebwriterOrder_decorators, _init3, _itemsSlot, _items2, _solution;
|
|
4936
|
-
_WebwriterOrder_decorators = [t3("webwriter-order")];
|
|
4937
|
-
var WebwriterOrder = class extends (_a3 = LitElementWw, _layout_dec2 = [n5({ type: String, attribute: true, reflect: true }), option({
|
|
4938
|
-
type: "select",
|
|
4939
|
-
options: [
|
|
4940
|
-
{ value: "list", label: { "en": "List" } },
|
|
4941
|
-
{ value: "tiles", label: { "en": "Tiles" } }
|
|
4942
|
-
]
|
|
4943
|
-
})], _hideOrderButtons_dec = [n5({ type: Boolean, attribute: true, reflect: true }), option({ type: Boolean, label: { _: "Hide order buttons" } })], _itemsSlot_dec = [e5("#items-slot")], _items_dec2 = [o5()], _solution_dec = [n5({ attribute: false })], _a3) {
|
|
4944
|
-
constructor() {
|
|
4945
|
-
super(...arguments);
|
|
4946
|
-
__runInitializers(_init3, 5, this);
|
|
4947
|
-
__publicField(this, "observer");
|
|
4948
|
-
__publicField(this, "orderSheet", new CSSStyleSheet());
|
|
4949
|
-
__publicField(this, "clearDropPreviews", () => {
|
|
4950
|
-
this.items.forEach((item) => item.dropPreview = void 0);
|
|
4951
|
-
});
|
|
4952
|
-
__privateAdd(this, _itemsSlot, __runInitializers(_init3, 8, this)), __runInitializers(_init3, 11, this);
|
|
4953
|
-
__privateAdd(this, _items2, __runInitializers(_init3, 12, this)), __runInitializers(_init3, 15, this);
|
|
4954
|
-
__publicField(this, "handleMove", (e7) => {
|
|
4955
|
-
const elem = e7.target;
|
|
4956
|
-
const children = Array.from(this.children);
|
|
4957
|
-
const pos = children.indexOf(elem);
|
|
4958
|
-
let i4;
|
|
4959
|
-
if (e7.type === "ww-moveup") {
|
|
4960
|
-
i4 = Math.max(0, pos - 1);
|
|
4961
|
-
} else if (e7.type === "ww-movedown") {
|
|
4962
|
-
i4 = Math.min(children.length, pos + 2);
|
|
4963
|
-
} else if (e7.type === "ww-moveto") {
|
|
4964
|
-
i4 = e7.detail.i;
|
|
4965
|
-
}
|
|
4966
|
-
this.moveChild(elem, i4);
|
|
4967
|
-
});
|
|
4968
|
-
__privateAdd(this, _solution, []);
|
|
4969
|
-
}
|
|
4970
|
-
get layout() {
|
|
4971
|
-
return this.children?.item(0)?.getAttribute("layout") ?? "list";
|
|
4972
|
-
}
|
|
4973
|
-
set layout(value) {
|
|
4974
|
-
this.querySelectorAll("webwriter-order-item").forEach((el) => el.setAttribute("layout", value));
|
|
4975
|
-
this.requestUpdate("layout");
|
|
4976
|
-
}
|
|
4977
|
-
get hideOrderButtons() {
|
|
4978
|
-
return !!this.items[0]?.hideOrderButtons;
|
|
4979
|
-
}
|
|
4980
|
-
set hideOrderButtons(value) {
|
|
4981
|
-
this.items.forEach((item) => item.hideOrderButtons = value);
|
|
4982
|
-
}
|
|
4983
|
-
connectedCallback() {
|
|
4984
|
-
super.connectedCallback();
|
|
4985
|
-
this.addEventListener("ww-moveup", this.handleMove);
|
|
4986
|
-
this.addEventListener("ww-movedown", this.handleMove);
|
|
4987
|
-
this.addEventListener("ww-moveto", this.handleMove);
|
|
4988
|
-
this.observer = new MutationObserver(() => {
|
|
4989
|
-
this.items.forEach((item) => item.requestUpdate());
|
|
4990
|
-
if (this.isContentEditable) {
|
|
4991
|
-
this.solution = this.items.map((item) => item.id);
|
|
4992
|
-
}
|
|
4993
|
-
this.clearDropPreviews();
|
|
4994
|
-
});
|
|
4995
|
-
this.observer.observe(this, { childList: true });
|
|
4996
|
-
}
|
|
4997
|
-
serializedCallback() {
|
|
4998
|
-
this.shuffleItems();
|
|
4999
|
-
}
|
|
5000
|
-
disconnectedCallback() {
|
|
5001
|
-
super.disconnectedCallback();
|
|
5002
|
-
this.observer?.disconnect();
|
|
5003
|
-
this.observer = void 0;
|
|
5004
|
-
}
|
|
5005
|
-
addItem() {
|
|
5006
|
-
const orderItem = this.ownerDocument.createElement("webwriter-order-item");
|
|
5007
|
-
const p3 = this.ownerDocument.createElement("p");
|
|
5008
|
-
orderItem.appendChild(p3);
|
|
5009
|
-
orderItem.setAttribute("layout", this.layout);
|
|
5010
|
-
this.append(orderItem);
|
|
5011
|
-
this.solution = [...__privateGet(this, _solution), orderItem.id];
|
|
5012
|
-
this.ownerDocument.getSelection().setBaseAndExtent(p3, 0, p3, 0);
|
|
5013
|
-
}
|
|
5014
|
-
shuffleItems() {
|
|
5015
|
-
const n6 = this.items.length;
|
|
5016
|
-
const nums = shuffle([...new Array(n6).keys()]);
|
|
5017
|
-
this.innerHTML = nums.map((i4) => this.children.item(i4).outerHTML).join("");
|
|
5018
|
-
}
|
|
5019
|
-
handleKeyDown(e7) {
|
|
5020
|
-
if (e7.key == "ArrowDown") {
|
|
5021
|
-
e7.stopPropagation();
|
|
5022
|
-
e7.preventDefault();
|
|
5023
|
-
} else if (e7.key === "ArrowUp") {
|
|
5024
|
-
e7.stopPropagation();
|
|
5025
|
-
e7.preventDefault();
|
|
5026
|
-
}
|
|
5027
|
-
}
|
|
5028
|
-
/*
|
|
5029
|
-
If contenteditable: Reorder solution -> Triggers orderSheet change
|
|
5030
|
-
If not contenteditable: Reorder value -> Triggers orderSheet change
|
|
5031
|
-
*/
|
|
5032
|
-
moveChild(elem, i4) {
|
|
5033
|
-
if (i4 === 0) {
|
|
5034
|
-
this.insertAdjacentElement("afterbegin", elem);
|
|
5035
|
-
} else if (i4 < this.items.length) {
|
|
5036
|
-
this.items[i4].insertAdjacentElement("beforebegin", elem);
|
|
5037
|
-
} else {
|
|
5038
|
-
this.insertAdjacentElement("beforeend", elem);
|
|
5039
|
-
}
|
|
5040
|
-
}
|
|
5041
|
-
get solution() {
|
|
5042
|
-
return __privateGet(this, _solution)?.length ? __privateGet(this, _solution) : void 0;
|
|
5043
|
-
}
|
|
5044
|
-
set solution(value) {
|
|
5045
|
-
__privateSet(this, _solution, value);
|
|
5046
|
-
if (value) {
|
|
5047
|
-
this.dispatchEvent(new CustomEvent("ww-answer-change", {
|
|
5048
|
-
bubbles: true,
|
|
5049
|
-
composed: true
|
|
5050
|
-
}));
|
|
5051
|
-
}
|
|
5052
|
-
}
|
|
5053
|
-
reportSolution() {
|
|
5054
|
-
this.solution.forEach((id, i4) => this.querySelector(`#${id}`).validOrder = i4);
|
|
5055
|
-
}
|
|
5056
|
-
reset() {
|
|
5057
|
-
this.solution = void 0;
|
|
5058
|
-
this.shuffleItems();
|
|
5059
|
-
}
|
|
5060
|
-
render() {
|
|
5061
|
-
return ke`
|
|
5062
|
-
<slot id="items-slot" @webwriter-clear-drop-preview=${this.clearDropPreviews}></slot>
|
|
5063
|
-
<sl-button size="small" id="add-option" class="author-only" @click=${() => this.addItem()}>
|
|
5064
|
-
<sl-icon src=${plus_default}></sl-icon><span>Add Option</span>
|
|
5065
|
-
</sl-button>
|
|
5066
|
-
`;
|
|
5067
|
-
}
|
|
5068
|
-
};
|
|
5069
|
-
_init3 = __decoratorStart(_a3);
|
|
5070
|
-
_itemsSlot = new WeakMap();
|
|
5071
|
-
_items2 = new WeakMap();
|
|
5072
|
-
_solution = new WeakMap();
|
|
5073
|
-
__decorateElement(_init3, 3, "layout", _layout_dec2, WebwriterOrder);
|
|
5074
|
-
__decorateElement(_init3, 3, "hideOrderButtons", _hideOrderButtons_dec, WebwriterOrder);
|
|
5075
|
-
__decorateElement(_init3, 4, "itemsSlot", _itemsSlot_dec, WebwriterOrder, _itemsSlot);
|
|
5076
|
-
__decorateElement(_init3, 4, "items", _items_dec2, WebwriterOrder, _items2);
|
|
5077
|
-
__decorateElement(_init3, 3, "solution", _solution_dec, WebwriterOrder);
|
|
5078
|
-
WebwriterOrder = __decorateElement(_init3, 0, "WebwriterOrder", _WebwriterOrder_decorators, WebwriterOrder);
|
|
5079
|
-
__publicField(WebwriterOrder, "scopedElements", {
|
|
5080
|
-
"sl-button": SlButton,
|
|
5081
|
-
"sl-icon": SlIcon
|
|
5082
|
-
});
|
|
5083
|
-
__publicField(WebwriterOrder, "styles", i`
|
|
5084
|
-
:host {
|
|
5085
|
-
display: flex !important;
|
|
5086
|
-
flex-direction: column;
|
|
5087
|
-
align-items: flex-start;
|
|
5088
|
-
counter-reset: orderItem;
|
|
5089
|
-
gap: 2px;
|
|
5090
|
-
}
|
|
5091
|
-
|
|
5092
|
-
:host([layout=tiles]) {
|
|
5093
|
-
flex-direction: row;
|
|
5094
|
-
flex-wrap: wrap;
|
|
5095
|
-
gap: 15px;
|
|
5096
|
-
}
|
|
5097
|
-
|
|
5098
|
-
:host(:is([contenteditable=true], [contenteditable=""])) {
|
|
5099
|
-
--text-color: var(--sl-color-success-700);
|
|
5100
|
-
}
|
|
5101
|
-
|
|
5102
|
-
:host ::slotted(*::part(counter)) {
|
|
5103
|
-
counter-increment: orderItem;
|
|
5104
|
-
content: counter(orderItem) '. ';
|
|
5105
|
-
cursor: move;
|
|
5106
|
-
text-align: right;
|
|
5107
|
-
padding-right: 0.5em;
|
|
5108
|
-
min-width: 1.5em;
|
|
5109
|
-
color: var(--text-color, auto);
|
|
5110
|
-
}
|
|
5111
|
-
|
|
5112
|
-
sl-button::part(label) {
|
|
5113
|
-
padding: 0;
|
|
5114
|
-
display: flex;
|
|
5115
|
-
flex-direction: row;
|
|
5116
|
-
align-items: center;
|
|
5117
|
-
}
|
|
3614
|
+
sl-button::part(label) {
|
|
3615
|
+
padding: 0;
|
|
3616
|
+
display: flex;
|
|
3617
|
+
flex-direction: row;
|
|
3618
|
+
align-items: center;
|
|
3619
|
+
}
|
|
5118
3620
|
|
|
5119
3621
|
sl-button::part(base) {
|
|
5120
3622
|
border: none;
|
|
@@ -5153,9 +3655,10 @@ __publicField(WebwriterOrder, "styles", i`
|
|
|
5153
3655
|
display: none;
|
|
5154
3656
|
}
|
|
5155
3657
|
`);
|
|
5156
|
-
__runInitializers(
|
|
3658
|
+
__runInitializers(_init2, 1, WebwriterOrder);
|
|
5157
3659
|
export {
|
|
5158
|
-
WebwriterOrder
|
|
3660
|
+
WebwriterOrder,
|
|
3661
|
+
shuffle
|
|
5159
3662
|
};
|
|
5160
3663
|
/*! Bundled license information:
|
|
5161
3664
|
|
|
@@ -5405,11 +3908,4 @@ lit-html/directives/if-defined.js:
|
|
|
5405
3908
|
* Copyright 2018 Google LLC
|
|
5406
3909
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5407
3910
|
*)
|
|
5408
|
-
|
|
5409
|
-
lit-html/directives/live.js:
|
|
5410
|
-
(**
|
|
5411
|
-
* @license
|
|
5412
|
-
* Copyright 2020 Google LLC
|
|
5413
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5414
|
-
*)
|
|
5415
3911
|
*/
|