@astl/astrolabe 0.1.2 → 0.1.4
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/CHANGELOG.md +30 -0
- package/dist/cdn/astrolabe-editor.js +3 -3
- package/dist/cdn/astrolabe-player.js +1 -1
- package/dist/cdn/astrolabe.js +1 -1
- package/dist/cdn/astrolabe.standalone.js +1094 -1060
- package/dist/cdn/chunks/{audio-B0LSIn5N.js → audio-Biof5aA3.js} +2 -2
- package/dist/cdn/chunks/{audio-B0LSIn5N.js.map → audio-Biof5aA3.js.map} +1 -1
- package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js → block-styles-CCtSFM4j.js} +2 -2
- package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js.map → block-styles-CCtSFM4j.js.map} +1 -1
- package/dist/cdn/chunks/{book-CHzDDaim.js → book-IFipARhv.js} +2 -2
- package/dist/cdn/chunks/{book-CHzDDaim.js.map → book-IFipARhv.js.map} +1 -1
- package/dist/cdn/chunks/{callout-QFLFLPc5.js → callout-CuajbbYY.js} +2 -2
- package/dist/cdn/chunks/{callout-QFLFLPc5.js.map → callout-CuajbbYY.js.map} +1 -1
- package/dist/cdn/chunks/{categorise-BO2tNVJ3.js → categorise-Cm6kXLXw.js} +2 -2
- package/dist/cdn/chunks/{categorise-BO2tNVJ3.js.map → categorise-Cm6kXLXw.js.map} +1 -1
- package/dist/cdn/chunks/{chip-styles-Dme5daTO.js → chip-styles--gboWK2Z.js} +2 -2
- package/dist/cdn/chunks/{chip-styles-Dme5daTO.js.map → chip-styles--gboWK2Z.js.map} +1 -1
- package/dist/cdn/chunks/{choice-CExBvqKj.js → choice-BSpB6LHl.js} +2 -2
- package/dist/cdn/chunks/{choice-CExBvqKj.js.map → choice-BSpB6LHl.js.map} +1 -1
- package/dist/cdn/chunks/{color-control-Cl5cuMSO.js → color-control-1kkdM8ns.js} +2 -2
- package/dist/cdn/chunks/{color-control-Cl5cuMSO.js.map → color-control-1kkdM8ns.js.map} +1 -1
- package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js → crossword-BdOAEPcL.js} +2 -2
- package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js.map → crossword-BdOAEPcL.js.map} +1 -1
- package/dist/cdn/chunks/{definitions-CNX90WtL.js → definitions-BybSa1mq.js} +2 -2
- package/dist/cdn/chunks/{definitions-CNX90WtL.js.map → definitions-BybSa1mq.js.map} +1 -1
- package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js → directive-helpers-US6zRjJ1.js} +2 -2
- package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js.map → directive-helpers-US6zRjJ1.js.map} +1 -1
- package/dist/cdn/chunks/{drop-vRXndjHu.js → drop-D4NQ0WK_.js} +2 -2
- package/dist/cdn/chunks/{drop-vRXndjHu.js.map → drop-D4NQ0WK_.js.map} +1 -1
- package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js → flash-cards-D4ebb5m6.js} +2 -2
- package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js.map → flash-cards-D4ebb5m6.js.map} +1 -1
- package/dist/cdn/chunks/{gap-lor-khst.js → gap-D-Sipuyu.js} +2 -2
- package/dist/cdn/chunks/{gap-lor-khst.js.map → gap-D-Sipuyu.js.map} +1 -1
- package/dist/cdn/chunks/{help-C-woafz5.js → help-CmCFuNXk.js} +2 -2
- package/dist/cdn/chunks/{help-C-woafz5.js.map → help-CmCFuNXk.js.map} +1 -1
- package/dist/cdn/chunks/{help-form-CDg3TCwI.js → help-form-Di2NtKDp.js} +14 -10
- package/dist/cdn/chunks/help-form-Di2NtKDp.js.map +1 -0
- package/dist/cdn/chunks/{hotspot-oel1Eelo.js → hotspot-B3bvqVzf.js} +2 -2
- package/dist/cdn/chunks/{hotspot-oel1Eelo.js.map → hotspot-B3bvqVzf.js.map} +1 -1
- package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js → image-drop-vLc2B7rF.js} +2 -2
- package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js.map → image-drop-vLc2B7rF.js.map} +1 -1
- package/dist/cdn/chunks/{image-label-Dm5shQSh.js → image-label-DsKxQDTQ.js} +2 -2
- package/dist/cdn/chunks/{image-label-Dm5shQSh.js.map → image-label-DsKxQDTQ.js.map} +1 -1
- package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js → inline-styles-CFNlb6f2.js} +2 -2
- package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js.map → inline-styles-CFNlb6f2.js.map} +1 -1
- package/dist/cdn/chunks/{insert-menu-7vANVmTK.js → insert-menu-DAQglwtG.js} +2 -2
- package/dist/cdn/chunks/{insert-menu-7vANVmTK.js.map → insert-menu-DAQglwtG.js.map} +1 -1
- package/dist/cdn/chunks/{issue-list-BT9qvnZU.js → issue-list-CzSmohtT.js} +2 -2
- package/dist/cdn/chunks/{issue-list-BT9qvnZU.js.map → issue-list-CzSmohtT.js.map} +1 -1
- package/dist/cdn/chunks/{live-jdiyYln2.js → live-qnReIRtj.js} +2 -2
- package/dist/cdn/chunks/{live-jdiyYln2.js.map → live-qnReIRtj.js.map} +1 -1
- package/dist/cdn/chunks/{long-answer-CtzClLAx.js → long-answer-NSWJiK0z.js} +2 -2
- package/dist/cdn/chunks/{long-answer-CtzClLAx.js.map → long-answer-NSWJiK0z.js.map} +1 -1
- package/dist/cdn/chunks/{mark-words-CpH3gTcX.js → mark-words-BKu-_uIl.js} +2 -2
- package/dist/cdn/chunks/{mark-words-CpH3gTcX.js.map → mark-words-BKu-_uIl.js.map} +1 -1
- package/dist/cdn/chunks/{match-DKE_4o-x.js → match-BpnJGW_5.js} +21 -13
- package/dist/cdn/chunks/match-BpnJGW_5.js.map +1 -0
- package/dist/cdn/chunks/{memory-B6hSyHyz.js → memory-BgTHujsU.js} +2 -2
- package/dist/cdn/chunks/{memory-B6hSyHyz.js.map → memory-BgTHujsU.js.map} +1 -1
- package/dist/cdn/chunks/messages-Qzse5KMX.js +2 -0
- package/dist/cdn/chunks/messages-Qzse5KMX.js.map +1 -0
- package/dist/cdn/chunks/{option-styles-WKzjKmCH.js → option-styles-B2sBX5Oz.js} +2 -2
- package/dist/cdn/chunks/{option-styles-WKzjKmCH.js.map → option-styles-B2sBX5Oz.js.map} +1 -1
- package/dist/cdn/chunks/{order-BhG_6IC-.js → order-B9gqH5wm.js} +2 -2
- package/dist/cdn/chunks/{order-BhG_6IC-.js.map → order-B9gqH5wm.js.map} +1 -1
- package/dist/cdn/chunks/{picture-view-BKnAyScQ.js → picture-view-Deodu_mb.js} +2 -2
- package/dist/cdn/chunks/{picture-view-BKnAyScQ.js.map → picture-view-Deodu_mb.js.map} +1 -1
- package/dist/cdn/chunks/{repeat-CY2W2URZ.js → repeat-BDXokpxQ.js} +2 -2
- package/dist/cdn/chunks/{repeat-CY2W2URZ.js.map → repeat-BDXokpxQ.js.map} +1 -1
- package/dist/cdn/chunks/{runtime-DxAbpr3S.js → runtime-C25QK5B0.js} +3 -3
- package/dist/cdn/chunks/{runtime-DxAbpr3S.js.map → runtime-C25QK5B0.js.map} +1 -1
- package/dist/cdn/chunks/{scan-jWgPnVxA.js → scan-BVhxT2Hw.js} +2 -2
- package/dist/cdn/chunks/{scan-jWgPnVxA.js.map → scan-BVhxT2Hw.js.map} +1 -1
- package/dist/cdn/chunks/{select-DTA3dJzr.js → select-DPpKJwSg.js} +2 -2
- package/dist/cdn/chunks/{select-DTA3dJzr.js.map → select-DPpKJwSg.js.map} +1 -1
- package/dist/cdn/chunks/select-QZ35cyns.js +2 -0
- package/dist/cdn/chunks/select-QZ35cyns.js.map +1 -0
- package/dist/cdn/chunks/{source-view-CZVxgTNQ.js → source-view-gqFlZzwR.js} +2 -2
- package/dist/cdn/chunks/{source-view-CZVxgTNQ.js.map → source-view-gqFlZzwR.js.map} +1 -1
- package/dist/cdn/chunks/{style-form-DUGbG_kL.js → style-form-DuR0EEum.js} +2 -2
- package/dist/cdn/chunks/{style-form-DUGbG_kL.js.map → style-form-DuR0EEum.js.map} +1 -1
- package/dist/cdn/chunks/{style-messages-qdf3pZbT.js → style-messages-B136zSom.js} +2 -2
- package/dist/cdn/chunks/{style-messages-qdf3pZbT.js.map → style-messages-B136zSom.js.map} +1 -1
- package/dist/cdn/chunks/{style-popups-BobgX1WK.js → style-popups-Bcl5imdP.js} +2 -2
- package/dist/cdn/chunks/{style-popups-BobgX1WK.js.map → style-popups-Bcl5imdP.js.map} +1 -1
- package/dist/cdn/chunks/{style-rules-D17QGzXk.js → style-rules-ozpLz2ec.js} +2 -2
- package/dist/cdn/chunks/{style-rules-D17QGzXk.js.map → style-rules-ozpLz2ec.js.map} +1 -1
- package/dist/cdn/chunks/{styled-Dmx5Yjv7.js → styled-bQqnDxBf.js} +2 -2
- package/dist/cdn/chunks/{styled-Dmx5Yjv7.js.map → styled-bQqnDxBf.js.map} +1 -1
- package/dist/cdn/chunks/{styles-CdJT6Pp9.js → styles-DiY3VA_T.js} +5 -5
- package/dist/cdn/chunks/styles-DiY3VA_T.js.map +1 -0
- package/dist/cdn/chunks/surface-CIz1z2oY.js +1059 -0
- package/dist/cdn/chunks/surface-CIz1z2oY.js.map +1 -0
- package/dist/cdn/chunks/{true-false-DP3MO599.js → true-false-C-S6RmZY.js} +2 -2
- package/dist/cdn/chunks/{true-false-DP3MO599.js.map → true-false-C-S6RmZY.js.map} +1 -1
- package/dist/cdn/chunks/{video-j9MCH6Kw.js → video-Dae8Gguf.js} +2 -2
- package/dist/cdn/chunks/{video-j9MCH6Kw.js.map → video-Dae8Gguf.js.map} +1 -1
- package/dist/cdn/chunks/{word-bank-ARjwUKZf.js → word-bank-CsIle0Ro.js} +2 -2
- package/dist/cdn/chunks/{word-bank-ARjwUKZf.js.map → word-bank-CsIle0Ro.js.map} +1 -1
- package/dist/cdn/chunks/{word-search-AHvM7yCJ.js → word-search-IOCwqo3y.js} +2 -2
- package/dist/cdn/chunks/{word-search-AHvM7yCJ.js.map → word-search-IOCwqo3y.js.map} +1 -1
- package/package.json +9 -9
- package/dist/cdn/chunks/help-form-CDg3TCwI.js.map +0 -1
- package/dist/cdn/chunks/match-DKE_4o-x.js.map +0 -1
- package/dist/cdn/chunks/messages-D1aJfyS_.js +0 -2
- package/dist/cdn/chunks/messages-D1aJfyS_.js.map +0 -1
- package/dist/cdn/chunks/styles-CdJT6Pp9.js.map +0 -1
- package/dist/cdn/chunks/surface-C6wtQkTY.js +0 -1037
- package/dist/cdn/chunks/surface-C6wtQkTY.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as e}from"./runtime-
|
|
1
|
+
import{w as e}from"./runtime-C25QK5B0.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
@@ -11,4 +11,4 @@ var t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},n=e
|
|
|
11
11
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
12
|
*/
|
|
13
13
|
let r=e._$AA.parentNode,o=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new i(r.insertBefore(s(),o),r.insertBefore(s(),o),e,e.options);else{let t=n._$AB.nextSibling,i=n._$AM,s=i!==e;if(s){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==i._$AU&&n._$AP(t)}if(t!==o||s){let e=n._$AA;for(;e!==t;){let t=a(e).nextSibling;a(r).insertBefore(e,o),e=t}}}return n},l=(e,t,n=e)=>(e._$AI(t,n),e),u={},d=(e,t=u)=>e._$AH=t,f=e=>e._$AH,p=e=>{e._$AR(),e._$AA.remove()};export{l as a,r as c,o as i,t as l,p as n,c as o,d as r,n as s,f as t};
|
|
14
|
-
//# sourceMappingURL=directive-helpers-
|
|
14
|
+
//# sourceMappingURL=directive-helpers-US6zRjJ1.js.map
|
package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js.map → directive-helpers-US6zRjJ1.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive-helpers-
|
|
1
|
+
{"version":3,"file":"directive-helpers-US6zRjJ1.js","names":["t","e","i","o","j$1","t$1","e$1","e","t","i$1","i","o","r","v","l","d","n","c","u","m","p","M","h"],"sources":["../../../../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/directive.js","../../../../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/directive-helpers.js"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n","import{_$LH as o}from\"./lit-html.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{I:t}=o,i=o=>o,n=o=>null===o||\"object\"!=typeof o&&\"function\"!=typeof o,e={HTML:1,SVG:2,MATHML:3},l=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,d=o=>null!=o?._$litType$?.h,c=o=>void 0!==o?._$litDirective$,f=o=>o?._$litDirective$,r=o=>void 0===o.strings,s=()=>document.createComment(\"\"),v=(o,n,e)=>{const l=o._$AA.parentNode,d=void 0===n?o._$AB:n._$AA;if(void 0===e){const i=l.insertBefore(s(),d),n=l.insertBefore(s(),d);e=new t(i,n,o,o.options)}else{const t=e._$AB.nextSibling,n=e._$AM,c=n!==o;if(c){let t;e._$AQ?.(o),e._$AM=o,void 0!==e._$AP&&(t=o._$AU)!==n._$AU&&e._$AP(t)}if(t!==d||c){let o=e._$AA;for(;o!==t;){const t=i(o).nextSibling;i(l).insertBefore(o,d),o=t}}}return e},u=(o,t,i=o)=>(o._$AI(t,i),o),m={},p=(o,t=m)=>o._$AH=t,M=o=>o._$AH,h=o=>{o._$AR(),o._$AA.remove()},j=o=>{o._$AR()};export{e as TemplateResultType,j as clearPart,M as getCommittedValue,f as getDirectiveClass,v as insertPart,d as isCompiledTemplateResult,c as isDirectiveResult,n as isPrimitive,r as isSingleExpression,l as isTemplateResult,h as removePart,u as setChildPartValue,p as setCommittedValue};\n//# sourceMappingURL=directive-helpers.js.map\n"],"ignoreList":[0,1],"mappings":";;;;;;AAKA,IAAMA,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAEC,EAAE,IAAI,GAAGM,KAAK,CAAC,gBAAgBC,EAAE,OAAOD,CAAC,GAASL,EAAN,KAAO,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,KAAKM,EAAE,KAAK,KAAKD,EAAE,KAAK,KAAKG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,OAAOF,EAAED,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,OAAO,GAAGA,CAAC,CAAC,CAAC,ECAnS,CAAC,EAAEC,GAAGL,EAAEO,EAAE,GAAGC,EAAsOC,EAAE,GAAYD,EAAE,UAAX,IAAK,GAAc,MAAM,SAAS,cAAc,EAAE,EAAEE,GAAG,EAAE,EAAE,IAAI;;;;;;AAAC,IAAMC,EAAEH,EAAE,KAAK,WAAWI,EAAWC,IAAT,IAAK,GAAML,EAAE,KAAKK,EAAE,KAAK,GAAYT,IAAT,IAAK,GAA6D,EAAE,IAAIC,EAApDM,EAAE,aAAa,EAAE,EAAEC,CAAmC,EAA9BD,EAAE,aAAa,EAAE,EAAEC,CAAa,EAAEJ,EAAEA,EAAE,OAAO,MAAM,CAAC,IAAM,EAAEJ,EAAE,KAAK,YAAYS,EAAET,EAAE,KAAKU,EAAED,IAAIL,EAAE,GAAGM,EAAE,CAAC,IAAI,EAAEV,EAAE,OAAOI,CAAC,EAAE,EAAE,KAAKA,EAAWJ,EAAE,OAAX,IAAK,KAAa,EAAEI,EAAE,QAAQK,EAAE,MAAMT,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAIQ,GAAGE,EAAE,CAAC,IAAIN,EAAEJ,EAAE,KAAK,KAAKI,IAAI,GAAG,CAAC,IAAM,EAAED,EAAEC,CAAC,CAAC,CAAC,YAAYD,EAAEI,CAAC,CAAC,CAAC,aAAaH,EAAEI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAOR,CAAC,EAAEW,GAAG,EAAE,EAAE,EAAEP,KAAKA,EAAE,KAAK,EAAED,CAAC,EAAEC,GAAGQ,EAAE,CAAC,EAAEC,GAAG,EAAE,EAAED,IAAI,EAAE,KAAK,EAAEE,EAAE,GAAGV,EAAE,KAAKW,EAAE,GAAG,CAACX,EAAE,KAAK,EAAEA,EAAE,KAAK,OAAO,CAAC,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,b as n,h as r,m as i,r as a,v as o}from"./runtime-
|
|
1
|
+
import{C as e,E as t,b as n,h as r,m as i,r as a,v as o}from"./runtime-C25QK5B0.js";import{n as s,r as c,t as l}from"./drop-manifest-bzNOa5ks.js";import{t as u}from"./inline-styles-CFNlb6f2.js";var d=`astl.drop`,f=[{namespace:d,locale:`en`,messages:s},{namespace:d,locale:`pl`,messages:l}],p=String.fromCodePoint(8288),m=e=>(e?.textContent??``).replace(/\s+/g,` `).trim(),h=class extends a{static manifest=c;static messages=f;static styles=[t`
|
|
2
2
|
.field.verdict {
|
|
3
3
|
--astl-drop-icon: calc(1.1em + var(--astl-space-1));
|
|
4
4
|
}
|
|
@@ -83,4 +83,4 @@ transition: none;
|
|
|
83
83
|
>${this.t(`ui.solution`,{answer:m(l)})}</span
|
|
84
84
|
><span aria-hidden="true">${m(l)}</span></span
|
|
85
85
|
>`}${p}`}},g={manifest:c,element:h,messages:f};export{g as dropElement};
|
|
86
|
-
//# sourceMappingURL=drop-
|
|
86
|
+
//# sourceMappingURL=drop-D4NQ0WK_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-vRXndjHu.js","names":["en","pl","ifDefined","nothing","b","i","A","verdictIcon","renderVerdict","SingleSlotElement","en_default","dropManifest","pl_default","inlineStyles","namespace","dropUiMessages","WORD_JOINER","textOf","el","DropElement","id","found","word","value","answers","#word","child","bank","pick","verdict","solution","ui","name","number","label","describedBy","target","content","event","node","key","params","dropElement"],"sources":["../../../../components/src/drop/ui-messages.ts","../../../../components/src/drop/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.drop';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `dropMessages` would put the authoring strings into the element's chunk.\n */\nexport const dropUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog } from '@astl/core';\nimport { type ElementRegistration, renderVerdict, SingleSlotElement, verdictIcon } from '@astl/player';\nimport { type CSSResultGroup, css, html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { inlineStyles } from '../inline-styles.js';\nimport { dropManifest } from './manifest.js';\nimport { dropUiMessages } from './ui-messages.js';\n\n/** U+2060: keeps the text right after the drop (a full stop, a comma) on its line. */\nconst WORD_JOINER = String.fromCodePoint(0x2060);\n\n/**\n * What a drop asks of its word bank (`<astl-word-bank>` with that id in the same view; the two folders never import\n * each other): its pick and place state, and what a click on the drop means.\n */\ninterface Bank extends HTMLElement {\n readonly pick: {\n readonly picked: string | null;\n readonly target: string | null;\n readonly over: string | null;\n readonly dragging: string | null;\n keydown(event: KeyboardEvent, item: string): boolean;\n pointerdown(event: PointerEvent, item: string): void;\n reset(): void;\n readonly touchmove: AddEventListenerOptions & EventListenerObject;\n };\n activate(drop: DropElement, event: MouseEvent): void;\n requestUpdate(): void;\n}\n\nconst textOf = (el: Element | undefined): string => (el?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n\n/**\n * `<astl-drop>`: a gap in running text that holds a word of its bank. One slot, the element id, answered with the\n * word's id. The drop is a button; what a press does is its bank's business (put the picked word here, take this one\n * out, or wait for a word), so one pick and place serves the bank and all its drops. A held word can be dragged on.\n */\nexport class DropElement extends SingleSlotElement {\n static override manifest: ComponentManifest = dropManifest;\n static override messages: readonly MessageCatalog[] = dropUiMessages;\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // A slot in the line with the metrics of a gap (inline-styles.ts: on the baseline, at least 24 px, the WCAG 2.5.8\n // inline exception), so the sentence keeps its lines, and the corners of the bank's chips, so a placed word looks\n // as it did there. Empty drops are all one width, so the width tells nothing about the answer; an empty one holds\n // a zero-width space (generated; the button holds nothing else, or :empty misses it), so it sits on the baseline\n // as a full one does. Its widest leaves room for the field's hair after it (inline-styles.ts). A word hyphenates inside the slot rather than\n // leave the line, and the icon keeps its room.\n css`\n .field.verdict {\n --astl-drop-icon: calc(1.1em + var(--astl-space-1));\n }\n .field > .control {\n min-inline-size: max(var(--astl-target-min), 5em);\n max-inline-size: calc(100% - var(--astl-drop-icon, 0px) - 0.2em);\n padding-inline: var(--astl-space-2);\n border-radius: var(--astl-radius-m);\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n transition: translate var(--astl-duration-fast);\n }\n .control:disabled {\n cursor: default;\n }\n .field > .control:empty::before {\n content: '\\\\200b';\n }\n `,\n // Locked without verdicts (review): the word written on a line, as a read-only gap shows its answer (that shared\n // rule keys on readonly, which a button cannot be).\n css`\n .field > .control:disabled:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n `,\n // Waiting for a word: the selection look (border, fill, weight; in hc the selected bar at the inline start), never\n // a verdict border. Where a picked word would go (the arrow keys' target, or under a dragged word): a doubled\n // edge, which forced colours keep. Its word dragged on (the bank moves the `chip` with the pointer): lifted, and\n // no pointer target, so what is under it counts.\n css`\n .control[aria-pressed='true'] {\n border-width: var(--astl-focus-width);\n border-inline-start-width: max(var(--astl-focus-width), var(--astl-selected-bar));\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n font-weight: var(--astl-selected-weight);\n }\n .control[data-target] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n background: var(--astl-accent-soft);\n }\n .control[data-dragging] {\n position: relative;\n z-index: 1;\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-outline);\n transition: none;\n pointer-events: none;\n }\n @media (prefers-reduced-motion: reduce) {\n .control {\n transition: none;\n }\n }\n `,\n inlineStyles,\n ];\n\n /** The word bank it takes words from, or null when the view has none with its `bank` id. */\n get bank(): Bank | null {\n const id = this.getAttribute('bank');\n const found =\n id && this.isConnected ? (this.getRootNode() as Document | ShadowRoot).getElementById(id) : null;\n return found?.localName === 'astl-word-bank' ? (found as Bank) : null;\n }\n\n /** The id of the word it holds; '' when empty. */\n get word(): string {\n return this.value;\n }\n\n /** Its number among the gaps of the text (0 outside a player). */\n get number(): number {\n return this.context.number;\n }\n\n /** Puts a word of its bank in (or '' takes it out), as the student did: reported like any answer. */\n place(word: string): void {\n this.updateValue(word);\n this.bank?.requestUpdate();\n }\n\n /** A word of its own bank, or '' to empty it: anything else cannot be shown, so the drop stays empty. */\n override setAnswers(answers: Answers): void {\n const value = answers[this.id];\n if (value === undefined) return;\n this.value = this.#word(value) === undefined ? '' : value;\n // The player sets answers on the gaps only (the bank has no slots): a pick or a wait of the bank goes with them.\n this.bank?.pick.reset();\n }\n\n #word(id: string): HTMLElement | undefined {\n if (id === '') return undefined;\n return [...(this.bank?.children ?? [])].find(\n (child): child is HTMLElement => child.localName === 'astl-word' && child.id === id,\n );\n }\n\n protected override render(): TemplateResult {\n const bank = this.bank;\n const pick = bank?.pick;\n const word = this.#word(this.value);\n const verdict = this.verdict;\n // A correct answer needs no correction: the solution shows for wrong and empty drops only.\n const solution = verdict === 'correct' ? undefined : this.#word(this.solutionValue ?? '');\n const ui = this.uiLanguage;\n const { number } = this.context;\n const name = number > 0 ? this.t('ui.name', { n: number }) : this.t('ui.namePlain');\n const label = word ? this.t('ui.label', { name, word: textOf(word) }) : this.t('ui.labelEmpty', { name });\n const describedBy = [verdict === null ? '' : 'verdict', solution === undefined ? '' : 'solution']\n .filter((id) => id !== '')\n .join(' ');\n const target =\n pick !== undefined && (pick.over ?? (pick.picked === null ? null : pick.target)) === this.id;\n const content = this.contentLang;\n return html`<span class=${verdict === null ? 'field' : 'field verdict'}\n ><button\n type=\"button\"\n class=\"control chip\"\n part=\"drop\"\n data-word=${this.value}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ?data-target=${target}\n ?data-dragging=${pick?.dragging === this.id}\n lang=${ifDefined(content === '' ? undefined : content)}\n aria-pressed=${pick?.picked === this.id ? 'true' : 'false'}\n aria-label=${label}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => bank?.activate(this, event)}\n @keydown=${(event: KeyboardEvent) => pick?.keydown(event, this.id)}\n @pointerdown=${(event: PointerEvent) => word && pick?.pointerdown(event, this.id)}\n @touchmove=${pick?.touchmove}\n >${\n word === undefined\n ? nothing\n : html`<span part=\"word\" lang=${ifDefined(word.closest('[lang]')?.getAttribute('lang') ?? undefined)}\n >${[...word.childNodes].map((node) => node.cloneNode(true))}</span\n >`\n }</button\n >${\n verdict === null\n ? nothing\n : renderVerdict(verdict, (key, params) => this.t(key, params), {\n hiddenWord: true,\n id: 'verdict',\n part: 'verdict',\n ...ui,\n })\n }</span\n >${\n solution === undefined\n ? nothing\n : html`<span class=\"solution\" part=\"solution\" id=\"solution\" data-word=${solution.id}\n >${verdictIcon('correct')}<span class=\"astl-vh\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution', { answer: textOf(solution) })}</span\n ><span aria-hidden=\"true\">${textOf(solution)}</span></span\n >`\n }${WORD_JOINER}`;\n }\n}\n\nexport const dropElement: ElementRegistration = {\n manifest: dropManifest,\n element: DropElement,\n messages: dropUiMessages,\n};\n"],"mappings":"A,kMAIA,IAAMc,EAAY,YAMLC,EAA4C,CACvD,CAAE,YAAW,OAAQ,KAAM,SAAUf,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECJMe,EAAc,OAAO,cAAc,IAAM,EAqBzCC,EAAU,IAAqCC,GAAI,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAOzFC,EAAb,cAAiCV,CAAkB,CACjD,OAAgB,SAA8BE,EAC9C,OAAgB,SAAsCI,EAGtD,OAAgB,OAAyB,CAOvC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;EA4BH,CAAG;;;;;;;EAYH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BHF,CACF,EAGA,IAAI,MAAoB,CACtB,IAAMO,EAAK,KAAK,aAAa,MAAM,EAC7BC,EACJD,GAAM,KAAK,YAAe,KAAK,YAAY,CAAC,CAA2B,eAAeA,CAAE,EAAI,KAC9F,OAAOC,GAAO,YAAc,iBAAoBA,EAAiB,IACnE,CAGA,IAAI,MAAe,CACjB,OAAO,KAAK,KACd,CAGA,IAAI,QAAiB,CACnB,OAAO,KAAK,QAAQ,MACtB,CAGA,MAAM,EAAoB,CACxB,KAAK,YAAYC,CAAI,EACrB,K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EAAUmC,IAAY,GAAK,IAAA,GAAYA,CAAO,EAAE;yBACxCT,GAAM,SAAW,KAAK,GAAK,OAAS,QAAQ;uBAC9CM,EAAM;6BACAC,IAAgB,GAAKhC,EAAUgC,EAAY;sBAClD,KAAK,SAAS;mBAChB,GAAsBR,GAAM,SAAS,KAAMW,CAAK,EAAE;qBAChD,GAAyBV,GAAM,QAAQU,EAAO,KAAK,EAAE,EAAE;yBACnD,GAAwBhB,GAAQM,GAAM,YAAYU,EAAO,KAAK,EAAE,EAAE;uBACrEV,GAAM,UAAU;WAE7BN,IAAS,IAAA,GACLnB,EACA,CAAI,0BAA0BD,EAAUoB,EAAK,QAAQ,QAAQ,CAAC,EAAE,aAAa,MAAM,GAAK,IAAA,EAAS,EAAE;qBAC5F,CAAC,GAAGA,EAAK,UAAU,CAAC,CAAC,IAAK,GAASiB,EAAK,UAAU,EAAI,CAAC,EAAE;mBAErE;WAECV,IAAY,KACR1B,EACAK,EAAcqB,GAAU,EAAK,IAAW,KAAK,EAAEW,EAAKC,CAAM,EAAG,CAC3D,WAAY,GACZ,GAAI,UACJ,KAAM,UACN,GAAGV,CACL,CAAC,EACN;SAEDD,IAAa,IAAA,GACT3B,EACA,CAAI,kEAAkE2B,EAAS,GAAG;iBAC7EvB,EAAY,SAAS,EAAE,6BAA6BwB,EAAG,KAAK,OAAOA,EAAG,IAAI;mBACxE,KAAK,EAAE,cAAe,CAAE,OAAQd,EAAOa,CAAQ,CAAE,CAAC,EAAE;0CAC7Bb,EAAOa,CAAQ,EAAE;iBAElDd,GACP,CACF,EAEa0B,EAAmC,CAC9C,SAAU/B,EACV,QAASQ,EACT,SAAUJ,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"drop-D4NQ0WK_.js","names":["en","pl","ifDefined","nothing","b","i","A","verdictIcon","renderVerdict","SingleSlotElement","en_default","dropManifest","pl_default","inlineStyles","namespace","dropUiMessages","WORD_JOINER","textOf","el","DropElement","id","found","word","value","answers","#word","child","bank","pick","verdict","solution","ui","name","number","label","describedBy","target","content","event","node","key","params","dropElement"],"sources":["../../../../components/src/drop/ui-messages.ts","../../../../components/src/drop/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.drop';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `dropMessages` would put the authoring strings into the element's chunk.\n */\nexport const dropUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog } from '@astl/core';\nimport { type ElementRegistration, renderVerdict, SingleSlotElement, verdictIcon } from '@astl/player';\nimport { type CSSResultGroup, css, html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { inlineStyles } from '../inline-styles.js';\nimport { dropManifest } from './manifest.js';\nimport { dropUiMessages } from './ui-messages.js';\n\n/** U+2060: keeps the text right after the drop (a full stop, a comma) on its line. */\nconst WORD_JOINER = String.fromCodePoint(0x2060);\n\n/**\n * What a drop asks of its word bank (`<astl-word-bank>` with that id in the same view; the two folders never import\n * each other): its pick and place state, and what a click on the drop means.\n */\ninterface Bank extends HTMLElement {\n readonly pick: {\n readonly picked: string | null;\n readonly target: string | null;\n readonly over: string | null;\n readonly dragging: string | null;\n keydown(event: KeyboardEvent, item: string): boolean;\n pointerdown(event: PointerEvent, item: string): void;\n reset(): void;\n readonly touchmove: AddEventListenerOptions & EventListenerObject;\n };\n activate(drop: DropElement, event: MouseEvent): void;\n requestUpdate(): void;\n}\n\nconst textOf = (el: Element | undefined): string => (el?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n\n/**\n * `<astl-drop>`: a gap in running text that holds a word of its bank. One slot, the element id, answered with the\n * word's id. The drop is a button; what a press does is its bank's business (put the picked word here, take this one\n * out, or wait for a word), so one pick and place serves the bank and all its drops. A held word can be dragged on.\n */\nexport class DropElement extends SingleSlotElement {\n static override manifest: ComponentManifest = dropManifest;\n static override messages: readonly MessageCatalog[] = dropUiMessages;\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // A slot in the line with the metrics of a gap (inline-styles.ts: on the baseline, at least 24 px, the WCAG 2.5.8\n // inline exception), so the sentence keeps its lines, and the corners of the bank's chips, so a placed word looks\n // as it did there. Empty drops are all one width, so the width tells nothing about the answer; an empty one holds\n // a zero-width space (generated; the button holds nothing else, or :empty misses it), so it sits on the baseline\n // as a full one does. Its widest leaves room for the field's hair after it (inline-styles.ts). A word hyphenates inside the slot rather than\n // leave the line, and the icon keeps its room.\n css`\n .field.verdict {\n --astl-drop-icon: calc(1.1em + var(--astl-space-1));\n }\n .field > .control {\n min-inline-size: max(var(--astl-target-min), 5em);\n max-inline-size: calc(100% - var(--astl-drop-icon, 0px) - 0.2em);\n padding-inline: var(--astl-space-2);\n border-radius: var(--astl-radius-m);\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n transition: translate var(--astl-duration-fast);\n }\n .control:disabled {\n cursor: default;\n }\n .field > .control:empty::before {\n content: '\\\\200b';\n }\n `,\n // Locked without verdicts (review): the word written on a line, as a read-only gap shows its answer (that shared\n // rule keys on readonly, which a button cannot be).\n css`\n .field > .control:disabled:not([data-verdict]) {\n border-color: transparent;\n border-block-end-color: var(--astl-outline);\n border-radius: 0;\n background: transparent;\n }\n `,\n // Waiting for a word: the selection look (border, fill, weight; in hc the selected bar at the inline start), never\n // a verdict border. Where a picked word would go (the arrow keys' target, or under a dragged word): a doubled\n // edge, which forced colours keep. Its word dragged on (the bank moves the `chip` with the pointer): lifted, and\n // no pointer target, so what is under it counts.\n css`\n .control[aria-pressed='true'] {\n border-width: var(--astl-focus-width);\n border-inline-start-width: max(var(--astl-focus-width), var(--astl-selected-bar));\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n font-weight: var(--astl-selected-weight);\n }\n .control[data-target] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n background: var(--astl-accent-soft);\n }\n .control[data-dragging] {\n position: relative;\n z-index: 1;\n box-shadow: 0 var(--astl-space-1) 0 0 var(--astl-outline);\n transition: none;\n pointer-events: none;\n }\n @media (prefers-reduced-motion: reduce) {\n .control {\n transition: none;\n }\n }\n `,\n inlineStyles,\n ];\n\n /** The word bank it takes words from, or null when the view has none with its `bank` id. */\n get bank(): Bank | null {\n const id = this.getAttribute('bank');\n const found =\n id && this.isConnected ? (this.getRootNode() as Document | ShadowRoot).getElementById(id) : null;\n return found?.localName === 'astl-word-bank' ? (found as Bank) : null;\n }\n\n /** The id of the word it holds; '' when empty. */\n get word(): string {\n return this.value;\n }\n\n /** Its number among the gaps of the text (0 outside a player). */\n get number(): number {\n return this.context.number;\n }\n\n /** Puts a word of its bank in (or '' takes it out), as the student did: reported like any answer. */\n place(word: string): void {\n this.updateValue(word);\n this.bank?.requestUpdate();\n }\n\n /** A word of its own bank, or '' to empty it: anything else cannot be shown, so the drop stays empty. */\n override setAnswers(answers: Answers): void {\n const value = answers[this.id];\n if (value === undefined) return;\n this.value = this.#word(value) === undefined ? '' : value;\n // The player sets answers on the gaps only (the bank has no slots): a pick or a wait of the bank goes with them.\n this.bank?.pick.reset();\n }\n\n #word(id: string): HTMLElement | undefined {\n if (id === '') return undefined;\n return [...(this.bank?.children ?? [])].find(\n (child): child is HTMLElement => child.localName === 'astl-word' && child.id === id,\n );\n }\n\n protected override render(): TemplateResult {\n const bank = this.bank;\n const pick = bank?.pick;\n const word = this.#word(this.value);\n const verdict = this.verdict;\n // A correct answer needs no correction: the solution shows for wrong and empty drops only.\n const solution = verdict === 'correct' ? undefined : this.#word(this.solutionValue ?? '');\n const ui = this.uiLanguage;\n const { number } = this.context;\n const name = number > 0 ? this.t('ui.name', { n: number }) : this.t('ui.namePlain');\n const label = word ? this.t('ui.label', { name, word: textOf(word) }) : this.t('ui.labelEmpty', { name });\n const describedBy = [verdict === null ? '' : 'verdict', solution === undefined ? '' : 'solution']\n .filter((id) => id !== '')\n .join(' ');\n const target =\n pick !== undefined && (pick.over ?? (pick.picked === null ? null : pick.target)) === this.id;\n const content = this.contentLang;\n return html`<span class=${verdict === null ? 'field' : 'field verdict'}\n ><button\n type=\"button\"\n class=\"control chip\"\n part=\"drop\"\n data-word=${this.value}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ?data-target=${target}\n ?data-dragging=${pick?.dragging === this.id}\n lang=${ifDefined(content === '' ? undefined : content)}\n aria-pressed=${pick?.picked === this.id ? 'true' : 'false'}\n aria-label=${label}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => bank?.activate(this, event)}\n @keydown=${(event: KeyboardEvent) => pick?.keydown(event, this.id)}\n @pointerdown=${(event: PointerEvent) => word && pick?.pointerdown(event, this.id)}\n @touchmove=${pick?.touchmove}\n >${\n word === undefined\n ? nothing\n : html`<span part=\"word\" lang=${ifDefined(word.closest('[lang]')?.getAttribute('lang') ?? undefined)}\n >${[...word.childNodes].map((node) => node.cloneNode(true))}</span\n >`\n }</button\n >${\n verdict === null\n ? nothing\n : renderVerdict(verdict, (key, params) => this.t(key, params), {\n hiddenWord: true,\n id: 'verdict',\n part: 'verdict',\n ...ui,\n })\n }</span\n >${\n solution === undefined\n ? nothing\n : html`<span class=\"solution\" part=\"solution\" id=\"solution\" data-word=${solution.id}\n >${verdictIcon('correct')}<span class=\"astl-vh\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution', { answer: textOf(solution) })}</span\n ><span aria-hidden=\"true\">${textOf(solution)}</span></span\n >`\n }${WORD_JOINER}`;\n }\n}\n\nexport const dropElement: ElementRegistration = {\n manifest: dropManifest,\n element: D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AK,QAAQ,QAAQ,CAAC,EAAE,aAAa,MAAM,GAAK,IAAA,EAAS,EAAE;qBAC5F,CAAC,GAAGA,EAAK,UAAU,CAAC,CAAC,IAAK,GAASiB,EAAK,UAAU,EAAI,CAAC,EAAE;mBAErE;WAECV,IAAY,KACR1B,EACAK,EAAcqB,GAAU,EAAK,IAAW,KAAK,EAAEW,EAAKC,CAAM,EAAG,CAC3D,WAAY,GACZ,GAAI,UACJ,KAAM,UACN,GAAGV,CACL,CAAC,EACN;SAEDD,IAAa,IAAA,GACT3B,EACA,CAAI,kEAAkE2B,EAAS,GAAG;iBAC7EvB,EAAY,SAAS,EAAE,6BAA6BwB,EAAG,KAAK,OAAOA,EAAG,IAAI;mBACxE,KAAK,EAAE,cAAe,CAAE,OAAQd,EAAOa,CAAQ,CAAE,CAAC,EAAE;0CAC7Bb,EAAOa,CAAQ,EAAE;iBAElDd,GACP,CACF,EAEa0B,EAAmC,CAC9C,SAAU/B,EACV,QAASQ,EACT,SAAUJ,CACZ,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,b as n,n as r,y as i}from"./runtime-
|
|
1
|
+
import{C as e,E as t,b as n,n as r,y as i}from"./runtime-C25QK5B0.js";import{n as a,r as o,t as s}from"./flash-cards-manifest-B8nWXbRy.js";import{t as c}from"./keys-DU-Qknmz.js";import{t as l}from"./block-styles-CCtSFM4j.js";var u=`astl.flash-cards`,d=[{namespace:u,locale:`en`,messages:a},{namespace:u,locale:`pl`,messages:s}],f=e=>e instanceof HTMLImageElement?` ${e.alt} `:e.nodeType===Node.TEXT_NODE?e.textContent??``:[...e.childNodes].map(f).join(``),p=class extends r{static manifest=o;static messages=d;static shadowRootOptions={...i.shadowRootOptions,slotAssignment:`manual`};static properties={current:{state:!0},back:{state:!0}};static styles=[t`
|
|
2
2
|
.deck {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -84,4 +84,4 @@ hyphens: auto;
|
|
|
84
84
|
<button type="button" part="next" @click=${()=>this.#r(1)}>${this.t(`ui.next`)}</button>
|
|
85
85
|
</div>`:n}
|
|
86
86
|
</div>`}updated(){let{element:e}=this.#t();this.renderRoot.querySelector(`slot`)?.assign(...e===void 0?[]:[e])}#n(){this.back=!this.back;let e=Number.parseFloat(getComputedStyle(this).getPropertyValue(`--astl-duration-normal`));e>0&&this.renderRoot.querySelector(`.card`)?.animate({transform:[`perspective(60rem) rotateY(90deg)`,`none`]},{duration:e,easing:`ease-out`}),this.announce(this.#t().name)}#r(e){let t=this.#e(!1).length;this.current=(this.current+e+t)%t,this.back=!1,this.announce(this.#t().name)}#i(e){let t=c(e,`inline`,this);t===0||this.#e(!1).length<2||(e.preventDefault(),this.#r(t))}},m={manifest:o,element:p,messages:d};export{m as flashCardsElement};
|
|
87
|
-
//# sourceMappingURL=flash-cards-
|
|
87
|
+
//# sourceMappingURL=flash-cards-D4ebb5m6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash-cards-0NrrKdrx.js","names":["en","pl","LitElement","nothing","b","i$1","A","AstlElement","en_default","flashCardsManifest","pl_default","arrowDelta","blockStyles","namespace","flashCardsUiMessages","spoken","node","FlashCardsElement","tag","back","child","total","#sides","element","caption","text","#shown","ui","#arrows","name","#turn","#move","duration","delta","event","flashCardsElement"],"sources":["../../../../components/src/flash-cards/ui-messages.ts","../../../../components/src/flash-cards/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.flash-cards';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `flashCardsMessages` would put the authoring strings into the element's chunk.\n */\nexport const flashCardsUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport { arrowDelta } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { blockStyles } from '../block-styles.js';\nimport { flashCardsManifest } from './manifest.js';\nimport { flashCardsUiMessages } from './ui-messages.js';\n\n/** What a screen reader reads for light-DOM content: its text, pictures by their alt text. */\nconst spoken = (node: Node): string =>\n node instanceof HTMLImageElement\n ? ` ${node.alt} `\n : node.nodeType === Node.TEXT_NODE\n ? (node.textContent ?? '')\n : [...node.childNodes].map(spoken).join('');\n\n/**\n * `<astl-flash-cards>`: one card at a time, a button that turns it over; previous and next (or the arrow keys) move\n * between cards, round the deck. The n-th `<astl-front>` and the n-th `<astl-back>` of the view make card n, slotted\n * manually and never changed. Nothing is answered or stored: no slots, and the current card is not part of the attempt.\n */\nexport class FlashCardsElement extends AstlElement {\n static override manifest: ComponentManifest = flashCardsManifest;\n static override messages: readonly MessageCatalog[] = flashCardsUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n current: { state: true },\n back: { state: true },\n };\n\n static override styles: CSSResultGroup = [\n css`\n .deck {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .hint {\n margin: 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n }\n button {\n box-sizing: border-box;\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-2);\n padding-inline: var(--astl-space-4);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n cursor: pointer;\n }\n .nav > button {\n flex: 1 1 auto;\n font-size: var(--astl-size-ui);\n font-weight: 600;\n white-space: nowrap;\n }\n .nav {\n display: flex;\n flex-wrap: wrap;\n justify-content: space-between;\n gap: var(--astl-space-2);\n }\n `,\n // The card: its position and side in a corner, the side's content in the middle, larger, as running text (its\n // formatting and pictures flow inline, centred); a word too long for the card hyphenates in the content's\n // language. The back is told apart by the words and the accent border, and by its fill where the theme has one.\n css`\n .card {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n inline-size: 100%;\n min-block-size: 12rem;\n padding: var(--astl-space-4);\n border-radius: var(--astl-radius-l);\n }\n .card[data-side='back'] {\n border-color: var(--astl-accent);\n background: var(--astl-accent-soft);\n }\n .side {\n align-self: flex-start;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n font-weight: 600;\n text-align: start;\n }\n .face {\n flex: 1;\n display: grid;\n place-items: center;\n font-size: 1.5rem;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n `,\n blockStyles,\n ];\n\n /** Index of the card shown. */\n declare protected current: number;\n /** Whether its back is shown. */\n declare protected back: boolean;\n\n constructor() {\n super();\n this.current = 0;\n this.back = false;\n }\n\n get slotIds(): readonly string[] {\n return [];\n }\n\n getAnswers(): Answers {\n return {};\n }\n\n setAnswers(): void {}\n\n units(): Units {\n return { answered: 0, total: 0 };\n }\n\n /** The fronts, or the backs, of the view in order: the n-th of each make card n. */\n #sides(back: boolean): Element[] {\n const tag = back ? 'astl-back' : 'astl-front';\n return Array.from(this.children).filter((child) => child.localName === tag);\n }\n\n /** The number of cards, the side shown, its caption (position and side), and the card's name: caption and text. */\n #shown(): {\n readonly total: number;\n readonly element: Element | undefined;\n readonly caption: string;\n readonly name: string;\n } {\n const total = this.#sides(false).length;\n const element = this.#sides(this.back)[this.current];\n const caption = this.t('ui.card', { n: this.current + 1, total, side: this.back ? 'back' : 'front' });\n const text = element === undefined ? '' : spoken(element).replace(/\\s+/g, ' ').trim();\n return { total, element, caption, name: this.t('ui.name', { card: caption, text }) };\n }\n\n protected override render(): TemplateResult {\n const { total, caption, name } = this.#shown();\n const ui = this.uiLanguage;\n // UI text in the UI language; the card's content keeps its own (children of a button are not read one by one:\n // its name says position, side and text). The face restates it: Chromium lays slotted content out in the language\n // of the shadow tree around the slot (the button's), so it would hyphenate English in a Polish UI as Polish.\n return html`<div class=\"deck\" part=\"flash-cards\" @keydown=${this.#arrows}>\n <p class=\"hint\" id=\"hint\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.hint', { total })}</p>\n <button\n type=\"button\"\n class=\"card\"\n part=\"card\"\n data-side=${this.back ? 'back' : 'front'}\n lang=${ui.lang}\n aria-label=${name}\n aria-describedby=\"hint\"\n @click=${this.#turn}\n >\n <span class=\"side\" part=\"side\" dir=${ui.dir}>${caption}</span>\n <span class=\"face\" lang=${this.contentLang || nothing}><slot></slot></span>\n </button>\n ${\n total > 1\n ? html`<div class=\"nav\" part=\"nav\" lang=${ui.lang} dir=${ui.dir}>\n <button type=\"button\" part=\"previous\" @click=${() => this.#move(-1)}>${this.t('ui.previous')}</button>\n <button type=\"button\" part=\"next\" @click=${() => this.#move(1)}>${this.t('ui.next')}</button>\n </div>`\n : nothing\n }\n </div>`;\n }\n\n protected override updated(): void {\n const { element } = this.#shown();\n this.renderRoot.querySelector('slot')?.assign(...(element === undefined ? [] : [element]));\n }\n\n #turn(): void {\n this.back = !this.back;\n // A quarter turn in, as long as the theme's normal duration (0 under reduced motion).\n const duration = Number.parseFloat(getComputedStyle(this).getPropertyValue('--astl-duration-normal'));\n if (duration > 0) {\n this.renderRoot\n .querySelector('.card')\n ?.animate(\n { transform: ['perspective(60rem) rotateY(90deg)', 'none'] },\n { duration, easing: 'ease-out' },\n );\n }\n this.announce(this.#shown().name);\n }\n\n #move(delta: number): void {\n const total = this.#sides(false).length;\n this.current = (this.current + delta + total) % total;\n this.back = false;\n this.announce(this.#shown().name);\n }\n\n #arrows(event: KeyboardEvent): void {\n const delta = arrowDelta(event, 'inline', this);\n if (delta === 0 || this.#sides(false).length < 2) return;\n event.preventDefault();\n this.#move(delta);\n }\n}\n\nexport const flashCardsElement: ElementRegistration =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QACA,CAAE,UAAW,CAAC,oCAAqC,MAAM,CAAE,EAC3D,CAAE,WAAU,OAAQ,UAAW,CACjC,EAEJ,KAAK,SAAS,KAAKN,GAAO,CAAC,CAAC,IAAI,CAClC,CAEA,GAAM,EAAqB,CACzB,IAAML,EAAQ,KAAKC,GAAO,EAAK,CAAC,CAAC,OACjC,KAAK,SAAW,KAAK,QAAUW,EAAQZ,GAASA,EAChD,KAAK,KAAO,GACZ,KAAK,SAAS,KAAKK,GAAO,CAAC,CAAC,IAAI,CAClC,CAEA,GAAQ,EAA4B,CAClC,IAAMO,EAAQtB,EAAWuB,EAAO,SAAU,IAAI,EAC1CD,IAAU,GAAK,KAAKX,GAAO,EAAK,CAAC,CAAC,OAAS,IAC/CY,EAAM,eAAe,EACrB,KAAKH,GAAME,CAAK,EAClB,CACF,EAEaE,EAAyC,CACpD,SAAU1B,EACV,QAASQ,EACT,SAAUH,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"flash-cards-D4ebb5m6.js","names":["en","pl","LitElement","nothing","b","i$1","A","AstlElement","en_default","flashCardsManifest","pl_default","arrowDelta","blockStyles","namespace","flashCardsUiMessages","spoken","node","FlashCardsElement","tag","back","child","total","#sides","element","caption","text","#shown","ui","#arrows","name","#turn","#move","duration","delta","event","flashCardsElement"],"sources":["../../../../components/src/flash-cards/ui-messages.ts","../../../../components/src/flash-cards/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.flash-cards';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `flashCardsMessages` would put the authoring strings into the element's chunk.\n */\nexport const flashCardsUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport { arrowDelta } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { blockStyles } from '../block-styles.js';\nimport { flashCardsManifest } from './manifest.js';\nimport { flashCardsUiMessages } from './ui-messages.js';\n\n/** What a screen reader reads for light-DOM content: its text, pictures by their alt text. */\nconst spoken = (node: Node): string =>\n node instanceof HTMLImageElement\n ? ` ${node.alt} `\n : node.nodeType === Node.TEXT_NODE\n ? (node.textContent ?? '')\n : [...node.childNodes].map(spoken).join('');\n\n/**\n * `<astl-flash-cards>`: one card at a time, a button that turns it over; previous and next (or the arrow keys) move\n * between cards, round the deck. The n-th `<astl-front>` and the n-th `<astl-back>` of the view make card n, slotted\n * manually and never changed. Nothing is answered or stored: no slots, and the current card is not part of the attempt.\n */\nexport class FlashCardsElement extends AstlElement {\n static override manifest: ComponentManifest = flashCardsManifest;\n static override messages: readonly MessageCatalog[] = flashCardsUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n current: { state: true },\n back: { state: true },\n };\n\n static override styles: CSSResultGroup = [\n css`\n .deck {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .hint {\n margin: 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n }\n button {\n box-sizing: border-box;\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-2);\n padding-inline: var(--astl-space-4);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n cursor: pointer;\n }\n .nav > button {\n flex: 1 1 auto;\n font-size: var(--astl-size-ui);\n font-weight: 600;\n white-space: nowrap;\n }\n .nav {\n display: flex;\n flex-wrap: wrap;\n justify-content: space-between;\n gap: var(--astl-space-2);\n }\n `,\n // The card: its position and side in a corner, the side's content in the middle, larger, as running text (its\n // formatting and pictures flow inline, centred); a word too long for the card hyphenates in the content's\n // language. The back is told apart by the words and the accent border, and by its fill where the theme has one.\n css`\n .card {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n inline-size: 100%;\n min-block-size: 12rem;\n padding: var(--astl-space-4);\n border-radius: var(--astl-radius-l);\n }\n .card[data-side='back'] {\n border-color: var(--astl-accent);\n background: var(--astl-accent-soft);\n }\n .side {\n align-self: flex-start;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n font-weight: 600;\n text-align: start;\n }\n .face {\n flex: 1;\n display: grid;\n place-items: center;\n font-size: 1.5rem;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n `,\n blockStyles,\n ];\n\n /** Index of the card shown. */\n declare protected current: number;\n /** Whether its back is shown. */\n declare protected back: boolean;\n\n constructor() {\n super();\n this.current = 0;\n this.back = false;\n }\n\n get slotIds(): readonly string[] {\n return [];\n }\n\n getAnswers(): Answers {\n return {};\n }\n\n setAnswers(): void {}\n\n units(): Units {\n return { answered: 0, total: 0 };\n }\n\n /** The fronts, or the backs, of the view in order: the n-th of each make card n. */\n #sides(back: boolean): Element[] {\n const tag = back ? 'astl-back' : 'astl-front';\n return Array.from(this.children).filter((child) => child.localName === tag);\n }\n\n /** The number of cards, the side shown, its caption (position and side), and the card's name: caption and text. */\n #shown(): {\n readonly total: number;\n readonly element: Element | undefined;\n readonly caption: string;\n readonly name: string;\n } {\n const total = this.#sides(false).length;\n const element = this.#sides(this.back)[this.current];\n const caption = this.t('ui.card', { n: this.current + 1, total, side: this.back ? 'back' : 'front' });\n const text = element === undefined ? '' : spoken(element).replace(/\\s+/g, ' ').trim();\n return { total, element, caption, name: this.t('ui.name', { card: caption, text }) };\n }\n\n protected override render(): TemplateResult {\n const { total, caption, name } = this.#shown();\n const ui = this.uiLanguage;\n // UI text in the UI language; the card's content keeps its own (children of a button are not read one by one:\n // its name says position, side and text). The face restates it: Chromium lays slotted content out in the language\n // of the shadow tree around the slot (the button's), so it would hyphenate English in a Polish UI as Polish.\n return html`<div class=\"deck\" part=\"flash-cards\" @keydown=${this.#arrows}>\n <p class=\"hint\" id=\"hint\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.hint', { total })}</p>\n <button\n type=\"button\"\n class=\"card\"\n part=\"card\"\n data-side=${this.back ? 'back' : 'front'}\n lang=${ui.lang}\n aria-label=${name}\n aria-describedby=\"hint\"\n @click=${this.#turn}\n >\n <span class=\"side\" part=\"side\" dir=${ui.dir}>${caption}</span>\n <span class=\"face\" lang=${this.contentLang || nothing}><slot></slot></span>\n </button>\n ${\n total > 1\n ? html`<div class=\"nav\" part=\"nav\" lang=${ui.lang} dir=${ui.dir}>\n <button type=\"button\" part=\"previous\" @click=${() => this.#move(-1)}>${this.t('ui.previous')}</button>\n <button type=\"button\" part=\"next\" @click=${() => this.#move(1)}>${this.t('ui.next')}</button>\n </div>`\n : nothing\n }\n </div>`;\n }\n\n protected override updated(): void {\n const { element } = this.#shown();\n this.renderRoot.querySelector('slot')?.assign(...(element === undefined ? [] : [element]));\n }\n\n #turn(): void {\n this.back = !this.back;\n // A quarter turn in, as long as the theme's normal duration (0 under reduced motion).\n const duration = Number.parseFloat(getComputedStyle(this).getPropertyValue('--astl-duration-normal'));\n if (duration > 0) {\n this.renderRoot\n .querySelector('.card')\n ?.animate(\n { transform: ['perspective(60rem) rotateY(90deg)', 'none'] },\n { duration, easing: 'ease-out' },\n );\n }\n this.announce(this.#shown().name);\n }\n\n #move(delta: number): void {\n const total = this.#sides(false).length;\n this.current = (this.current + delta + total) % total;\n this.back = false;\n this.announce(this.#shown().name);\n }\n\n #arrows(event: KeyboardEvent): void {\n const delta = arrowDelta(event, 'inline', this);\n if (delta === 0 || this.#sides(false).length < 2) return;\n event.preventDefault();\n this.#move(delta);\n }\n}\n\nexport const flashCardsElement: ElementRegistration = {\n manifest: flashCardsManifest,\n element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oCAAqC,MAAM,CAAE,EAC3D,CAAE,WAAU,OAAQ,UAAW,CACjC,EAEJ,KAAK,SAAS,KAAKN,GAAO,CAAC,CAAC,IAAI,CAClC,CAEA,GAAM,EAAqB,CACzB,IAAML,EAAQ,KAAKC,GAAO,EAAK,CAAC,CAAC,OACjC,KAAK,SAAW,KAAK,QAAUW,EAAQZ,GAASA,EAChD,KAAK,KAAO,GACZ,KAAK,SAAS,KAAKK,GAAO,CAAC,CAAC,IAAI,CAClC,CAEA,GAAQ,EAA4B,CAClC,IAAMO,EAAQtB,EAAWuB,EAAO,SAAU,IAAI,EAC1CD,IAAU,GAAK,KAAKX,GAAO,EAAK,CAAC,CAAC,OAAS,IAC/CY,EAAM,eAAe,EACrB,KAAKH,GAAME,CAAK,EAClB,CACF,EAEaE,EAAyC,CACpD,SAAU1B,EACV,QAASQ,EACT,SAAUH,CACZ,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,b as r,h as i,r as a,v as o,y as s}from"./runtime-
|
|
1
|
+
import{C as e,D as t,E as n,b as r,h as i,r as a,v as o,y as s}from"./runtime-C25QK5B0.js";import{n as c,r as l,t as u}from"./gap-manifest-RSydA41N.js";import{t as d}from"./live-qnReIRtj.js";import{t as f}from"./inline-styles-CFNlb6f2.js";var p=`astl.gap`,m=[{namespace:p,locale:`en`,messages:c},{namespace:p,locale:`pl`,messages:u}],h=40,g=500,_=8,v=t(Array.from({length:h},(e,t)=>`:host([size="${t+1}"]) { --astl-gap-chars: ${t+1}; }`).join(`
|
|
2
2
|
`)),y=``,b=class extends a{static manifest=l;static messages=m;static shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0};static styles=[n`
|
|
3
3
|
:host {
|
|
4
4
|
--astl-gap-chars: ${_};
|
|
@@ -75,4 +75,4 @@ border-width: var(--astl-focus-width);
|
|
|
75
75
|
><span aria-hidden="true">${n}</span></span
|
|
76
76
|
>`}</span
|
|
77
77
|
>${y}`}},x={manifest:l,element:b,messages:m};export{x as gapElement};
|
|
78
|
-
//# sourceMappingURL=gap-
|
|
78
|
+
//# sourceMappingURL=gap-D-Sipuyu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gap-
|
|
1
|
+
{"version":3,"file":"gap-D-Sipuyu.js","names":["en","pl","unsafeCSS","LitElement","ifDefined","nothing","live","b","r","i$1","A","verdictIcon","SingleSlotElement","i","en_default","gapManifest","pl_default","l","inlineStyles","namespace","gapUiMessages","MAX_CHARS","MAX_LENGTH","DEFAULT_CHARS","SIZE_RULES","WORD_JOINER","GapElement","verdict","solution","ui","label","number","describedBy","id","common","chars","control","event","gapElement"],"sources":["../../../../components/src/gap/ui-messages.ts","../../../../components/src/gap/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.gap';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `gapMessages` would put the authoring strings into the element's chunk.\n */\nexport const gapUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { ComponentManifest, MessageCatalog } from '@astl/core';\nimport { type ElementRegistration, SingleSlotElement, verdictIcon } from '@astl/player';\nimport { type CSSResultGroup, css, html, LitElement, nothing, type TemplateResult, unsafeCSS } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { inlineStyles } from '../inline-styles.js';\nimport { gapManifest } from './manifest.js';\nimport { gapUiMessages } from './ui-messages.js';\n\n/** Widest `inline` gap, in characters: the field grows with the answer up to this, and never past the line. */\nconst MAX_CHARS = 40;\n\n/** Longest answer the field takes. */\nconst MAX_LENGTH = 500;\n\n/** Default width when a view has no `size` (views always write it). */\nconst DEFAULT_CHARS = 8;\n\n/** `:host([size=\"n\"])` rules: the rest width comes from the view's attribute, so the host is never written to. */\nconst SIZE_RULES = unsafeCSS(\n Array.from(\n { length: MAX_CHARS },\n (_, i) => `:host([size=\"${i + 1}\"]) { --astl-gap-chars: ${i + 1}; }`,\n ).join('\\n'),\n);\n\n/** U+2060: keeps the text right after the gap (a full stop, a comma) on the gap's line. */\nconst WORD_JOINER = '';\n\n/**\n * `<astl-gap>`: a text field inside running text. One slot, the element id. Editable it is an `<input>`; read-only\n * (review, handed in) it is a `<textarea readonly>` so a long answer wraps and shows in full. Variants: `inline` grows\n * with the answer up to 40 characters, `resizable` up to the whole line; neither gets narrower than `size`.\n */\nexport class GapElement extends SingleSlotElement {\n static override manifest: ComponentManifest = gapManifest;\n static override messages: readonly MessageCatalog[] = gapUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The tail is room for the punctuation after the gap, so a full-line gap keeps its full stop; the icon is the room\n // the verdict icon takes in the field.\n css`\n :host {\n --astl-gap-chars: ${DEFAULT_CHARS};\n --astl-gap-edges: calc(2 * var(--astl-space-2, 0px) + 2 * var(--astl-outline-width, 0px));\n --astl-gap-icon: 0px;\n --astl-gap-tail: 1ch;\n }\n .field.verdict {\n --astl-gap-icon: calc(1.1em + var(--astl-space-1));\n }\n `,\n // At rest: size characters, also next to a solution. Grows with the answer (field-sizing) up to 40, never past the\n // line; browsers without field-sizing keep the width of the size and cols attributes.\n css`\n .control {\n min-inline-size: min(\n calc(var(--astl-gap-chars) * 1ch + var(--astl-gap-edges)),\n calc(100% - var(--astl-gap-icon) - var(--astl-gap-tail))\n );\n max-inline-size: min(\n calc(${MAX_CHARS}ch + var(--astl-gap-edges)),\n calc(100% - var(--astl-gap-icon) - var(--astl-gap-tail))\n );\n padding-inline: var(--astl-space-2);\n field-sizing: content;\n }\n `,\n // Resizable: no 40-character cap, the line is the limit.\n css`\n :host([variant='resizable']) .control {\n max-inline-size: calc(100% - var(--astl-gap-icon) - var(--astl-gap-tail));\n }\n `,\n // The text after the gap (a full stop) follows the answer's last line. Partial (a double border) takes the focus\n // width, so both of its lines show.\n css`\n textarea.control {\n overflow: hidden;\n vertical-align: bottom;\n }\n .control[data-verdict='partial'] {\n border-width: var(--astl-focus-width);\n }\n `,\n SIZE_RULES,\n inlineStyles,\n ];\n\n protected override render(): TemplateResult {\n const verdict = this.verdict;\n // A correct answer needs no correction: the solution shows for wrong and empty slots only.\n const solution = verdict === 'correct' ? null : this.solutionValue;\n const { number } = this.context;\n const ui = this.uiLanguage;\n const label = number > 0 ? this.t('ui.label', { n: number }) : this.t('ui.labelPlain');\n const describedBy = [verdict === null ? '' : 'verdict', solution === null ? '' : 'solution']\n .filter((id) => id !== '')\n .join(' ');\n // What both controls carry (no attribute for an empty value).\n const common = { lang: this.contentLang || undefined, describedBy: describedBy || undefined };\n const chars = this.numberAttribute('size') ?? DEFAULT_CHARS;\n const control = this.disabled\n ? html`<textarea\n part=\"input\"\n class=\"control\"\n data-verdict=${ifDefined(verdict ?? undefined)}\n rows=\"1\"\n cols=${chars}\n maxlength=${MAX_LENGTH}\n lang=${ifDefined(common.lang)}\n spellcheck=\"false\"\n readonly\n aria-label=${label}\n aria-invalid=${verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n .value=${live(this.value)}\n ></textarea>`\n : html`<input\n part=\"input\"\n class=\"control\"\n data-verdict=${ifDefined(verdict ?? undefined)}\n type=\"text\"\n inputmode=${ifDefined(this.stringAttribute('type') === 'number' ? 'decimal' : undefined)}\n size=${chars}\n maxlength=${MAX_LENGTH}\n lang=${ifDefined(common.lang)}\n spellcheck=\"false\"\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n aria-label=${label}\n aria-invalid=${verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n .value=${live(this.value)}\n @input=${(event: Event) => this.updateValue((event.target as HTMLInputElement).value)}\n />`;\n return html`<span class=\"gap\" part=\"gap\"\n ><span class=${verdict === null ? 'field' : 'field verdict'}\n >${control}${this.renderVerdict(verdict, { hiddenWord: true, id: 'verdict' })}</span\n >${\n solution === null\n ? nothing\n : html`<span class=\"solution\" part=\"solution\" id=\"solution\"\n >${verdictIcon('correct')}<span class=\"astl-vh\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution', { answer: solution })}</span\n ><span aria-hidden=\"true\">${solution}</span></span\n >`\n }</span\n >${WORD_JOINER}`;\n }\n}\n\nexport const gapElement: ElementRegistration = {\n manifest: gapManifest,\n element: GapElement,\n messages: gapUiMessages,\n};\n"],"mappings":"A,+OAIA,IAAMmB,EAAY,WAMLC,EAA2C,CACtD,CAAE,YAAW,OAAQ,KAAM,SAAUpB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECHMoB,EAAY,GAGZC,EAAa,IAGbC,EAAgB,EAGhBC,EAAatB,EACjB,MAAM,KACJ,CAAE,OAAQmB,CAAU,GACnB,EAAG,IAAM,gBAAgBR,EAAI,EAAE,0BAA0BA,EAAI,EAAE,IAClE,CAAC,CAAC,KAAK;CAAI,CACb,EAGMY,EAAc,IAOPC,EAAb,cAAgCd,CAAkB,CAChD,OAAgB,SAA8BG,EAC9C,OAAgB,SAAsCK,EACtD,OAAgB,kBAAoC,CAClD,GAAGjB,EAAW,kBACd,eAAgB,EAClB,EAGA,OAAgB,OAAyB,CAGvC,CAAG;;4BAEqBoB,EAAc;;;;;;;;MAWtC,CAAG;;;;;;;iBAOUF,EAAU;;;;;;MAQvB,CAAG;;;;EAOH,CAAG;;;;;;;;EASHG,EACAN,CACF,EAEA,QAA4C,CAC1C,IAAMS,EAAU,KAAK,QAEfC,EAAWD,IAAY,UAAY,KAAO,KAAK,cAC/C,CAAE,UAAW,KAAK,QAClBE,EAAK,KAAK,WACVC,EAAQC,EAAS,EAAI,KAAK,EAAE,WA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EAAS;iBAE5C;SACAH,GACP,CACF,EAEaa,EAAkC,CAC7C,SAAUvB,EACV,QAASW,EACT,SAAUN,CACZ,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,J as n,b as r,bt as i,c as a,in as o,l as s,ln as c,lt as l,m as u,s as d,u as f,x as p}from"./runtime-
|
|
1
|
+
import{C as e,E as t,J as n,b as r,bt as i,c as a,in as o,l as s,ln as c,lt as l,m as u,s as d,u as f,x as p}from"./runtime-C25QK5B0.js";var m=[{namespace:s,locale:`en`,messages:{"help.label":`Help with this question`,"help.labelField":`Help with field {n}`,"help.labelPage":`Help with this page`,"help.hint":`Hint ({n}/{total})`,"help.hintCost":`Costs {percent}% of the points`,"help.hintItem":`Hint {n}`,"help.hintAnnounce":`Hint {n}: {text}`,"help.check":`this question`,"help.checkField":`field {n}`,"help.why":`Why?`,"error.hints_not_allowed":`Hints are not available in this exercise.`,"error.hints_exhausted":`There are no more hints.`}},{namespace:s,locale:`pl`,messages:{"help.label":`Pomoc do tego pytania`,"help.labelField":`Pomoc do pola {n}`,"help.labelPage":`Pomoc do tej strony`,"help.hint":`Podpowiedź ({n}/{total})`,"help.hintCost":`Kosztuje {percent}% punktów`,"help.hintItem":`Podpowiedź {n}`,"help.hintAnnounce":`Podpowiedź {n}: {text}`,"help.check":`to pytanie`,"help.checkField":`pole {n}`,"help.why":`Dlaczego?`,"error.hints_not_allowed":`W tym zadaniu nie ma podpowiedzi.`,"error.hints_exhausted":`Nie ma już więcej podpowiedzi.`}}],h=/^(?:0|1|0?\.\d{1,6}|1\.0{1,6})$/;function g(e){let t=t=>(e.getAttribute(t)??``).split(` `).filter(Boolean),n=t(`hints`).flatMap(e=>h.test(e)?[Number(e)]:[]),r=new Set(t(`feedback`)),a=i.filter(e=>r.has(e)),o=e.hasAttribute(`explanation`);return n.length===0&&a.length===0&&!o?null:{hints:n,explanation:o,feedback:a}}function _(e,t){let n=document.createElement(`template`);n.innerHTML=o(e);let r=n.content.ownerDocument.createElement(`div`);r.append(n.content),d(r,{manifests:new Map,urlPolicy:t},!1,!1);for(let e of Array.from(r.querySelectorAll(`*`)))e.localName.includes(`-`)&&e.remove();let i=document.importNode(r,!0);return i.className=`help-content`,i}var v=e=>typeof e==`object`&&!!e&&typeof e.html==`string`&&i.includes(e.variant),y=(e,t)=>typeof e==`object`&&e&&Object.hasOwn(e,t)?e[t]:void 0;function b(e){return e.length===0?null:e.every(e=>e===`empty`)?`empty`:e.every(e=>e===`correct`)?`correct`:e.some(e=>e===`correct`||e===`partial`)?`partial`:`incorrect`}var x=e=>Number.isInteger(e)&&e>=0;function S(e){let t=e;for(;t.parentElement!==null&&!/^astl-(page|column|doc)$/.test(t.parentElement.localName);)t=t.parentElement;return t}var C=[`float`,`width`,`inline-size`,`max-width`,`max-inline-size`,`margin`,`margin-inline`,`margin-inline-start`,`margin-inline-end`];function w(e,t){if(!(t instanceof HTMLElement))return;for(let n of C){let r=t.style.getPropertyValue(n);r!==``&&e.style.setProperty(n,r)}let n=t.style.getPropertyValue(`float`);n!==``&&n!==`none`&&e.style.setProperty(`clear`,n)}function T(t){let{controller:i,locale:o}=t,d=i.policy,h=n(d),C=d.mode===`practice`,T=l({catalogs:[...f,...m,...a.catalogs]}).translator(o,s);D(t.root);let E=[],O=new Map,k=(e,t,n)=>{let r=document.createElement(`div`);r.className=`astl-help`,r.setAttribute(`part`,`help`),r.setAttribute(`role`,`group`),r.setAttribute(`aria-label`,n.label),r.lang=o;let i={id:e.id,offer:t,box:r,...n,lang:e.closest(`[lang]`)?.getAttribute(`lang`)??``,dir:e.closest(`[dir]`)?.getAttribute(`dir`)??``,hints:[],used:0,total:t.hints.length,pending:!1,problem:null,verdict:null,feedback:null,explanation:null};return E.push(i),i},A=0;for(let{element:e,manifest:n}of t.mounted){let t=n.display===`inline`;t&&A++;let r=n.graded?g(e):null;if(r===null)continue;let i=A,a=k(e,r,{label:t?T(`help.labelField`,{n:i}):T(`help.label`),check:C&&h.checkScope===`interaction`?t?T(`help.checkField`,{n:i}):T(`help.check`):null,ownVerdict:!t,groups:e.groupIds??[e.id],slots:new Set(e.slotIds)}),o=S(e);(O.get(o)??o).after(a.box),O.set(o,a.box),w(a.box,o)}t.pages.forEach((e,t)=>{let n=e.localName===`astl-page`?g(e):null;if(n===null)return;let r=k(e,n,{label:T(`help.labelPage`),check:null,ownVerdict:!1,groups:[],slots:new Set(i.pages[t]?.slotIds??[])});r.box.dataset.page=``,e.append(r.box)});let j=(e,n)=>{if(typeof e!=`string`)return null;let r=_(e,t.urlPolicy);return n.lang&&(r.lang=n.lang),n.dir&&(r.dir=n.dir),r},M=(e,t)=>{let n=e.result;if(n!==null)for(let r of E){if(t!==null&&r.id!==t)continue;let i=n.groups.filter(e=>r.groups.includes(e.id)).map(e=>e.verdict);if(!(r.groups.length===0?Object.hasOwn(n.pages,r.id):i.length>0))continue;let a=y(e.feedback,r.id);r.verdict=v(a)?a.variant===`omitted`?`empty`:a.variant:b(i),r.feedback=v(a)?j(a.html,r):null,r.explanation=j(y(e.explanations,r.id),r)??r.explanation}},N=()=>{for(let e of E)p(I(e),e.box)},P=async e=>{let n=t.checker();if(!e.pending){e.pending=!0,e.problem=null,N();try{if(n?.hint===void 0)throw n===null?`no_checker`:`hints_not_allowed`;let r=await n.hint({element:e.id}),i=x(r.index)?r.index:e.used,a=j(r.html,e);e.hints=[...e.hints,{n:i+1,content:a}],e.used=i+1,e.total=x(r.left)?e.used+r.left:Math.max(e.total,e.used),t.announce(T(`help.hintAnnounce`,{n:i+1,text:a.textContent?.trim()??``}))}catch(n){let r=n instanceof c?n.problem.code:typeof n==`string`?n:`internal_error`;r===`hints_exhausted`&&(e.total=e.used),e.problem=r,t.announce(F(r))}finally{e.pending=!1;let n=t.root instanceof ShadowRoot?t.root.activeElement:document.activeElement,r=e.box.contains(n);N(),r&&e.used>=e.total&&e.box.querySelector(`.help-hints li:last-child`)?.focus()}}},F=e=>{let t=T(`error.${e}`);return t===`error.${e}`?T(`error.internal_error`):t},I=n=>{let a=!i.readOnly,s=n.used<n.total&&h.hints&&C&&a?n.used:null,c=s===null?0:n.offer.hints[s]??0,l=`astl-help-cost-${E.indexOf(n)}`,d=n.check!==null&&a,f=s!==null||d||n.hints.length>0||n.feedback!==null||n.explanation!==null;return n.box.hidden=!f&&n.problem===null,n.box.hidden?r:e`${s===null&&!d?r:e`<div class="help-actions">
|
|
2
2
|
${s===null?r:e`<span class="help-hint"
|
|
3
3
|
><button
|
|
4
4
|
type="button"
|
|
@@ -135,4 +135,4 @@ margin: 0;
|
|
|
135
135
|
color: var(--astl-ink);
|
|
136
136
|
}
|
|
137
137
|
`.styleSheet;function D(e){E!==void 0&&e instanceof ShadowRoot&&!e.adoptedStyleSheets.includes(E)&&(e.adoptedStyleSheets=[...e.adoptedStyleSheets,E])}export{m as helpMessages,T as mountHelp,_ as readContent,g as readHelp};
|
|
138
|
-
//# sourceMappingURL=help-
|
|
138
|
+
//# sourceMappingURL=help-CmCFuNXk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-C-woafz5.js","names":["en","pl","nothing","b","i","helpPolicy","A","FEEDBACK_VARIANTS","runtime","inertStyles","PLAYER_NAMESPACE","CheckerError","createI18n","renderVerdict","cleanContent","playerMessages","D","helpMessages","COST","readHelp","words","el","name","hints","w","written","feedback","v","explanation","readContent","template","content","holder","live","isFeedback","own","record","id","overall","verdicts","isCount","anchorOf","anchor","element","PLACING","place","value","box","float","mountHelp","host","policy","controller","help","practice","t","locale","adoptHelpSheet","rows","after","row","extra","entry","owner","offer","field","inline","manifest","n","page","index","shown","apply","result","response","only","g","update","view","ask","checker","hint","error","code","problemText","active","focused","message","open","next","cost","costId","check","shows","unsubscribe","change","r","changed","helpSheet","root"],"sources":["../../../../player/src/messages/help/en.json","../../../../player/src/messages/help/pl.json","../../../../player/src/player/help.ts"],"sourcesContent":["{\n \"help.label\": \"Help with this question\",\n \"help.labelField\": \"Help with field {n}\",\n \"help.labelPage\": \"Help with this page\",\n \"help.hint\": \"Hint ({n}/{total})\",\n \"help.hintCost\": \"Costs {percent}% of the points\",\n \"help.hintItem\": \"Hint {n}\",\n \"help.hintAnnounce\": \"Hint {n}: {text}\",\n \"help.check\": \"this question\",\n \"help.checkField\": \"field {n}\",\n \"help.why\": \"Why?\",\n \"error.hints_not_allowed\": \"Hints are not available in this exercise.\",\n \"error.hints_exhausted\": \"There are no more hints.\"\n}\n","{\n \"help.label\": \"Pomoc do tego pytania\",\n \"help.labelField\": \"Pomoc do pola {n}\",\n \"help.labelPage\": \"Pomoc do tej strony\",\n \"help.hint\": \"Podpowiedź ({n}/{total})\",\n \"help.hintCost\": \"Kosztuje {percent}% punktów\",\n \"help.hintItem\": \"Podpowiedź {n}\",\n \"help.hintAnnounce\": \"Podpowiedź {n}: {text}\",\n \"help.check\": \"to pytanie\",\n \"help.checkField\": \"pole {n}\",\n \"help.why\": \"Dlaczego?\",\n \"error.hints_not_allowed\": \"W tym zadaniu nie ma podpowiedzi.\",\n \"error.hints_exhausted\": \"Nie ma już więcej podpowiedzi.\"\n}\n","/**\n * Help for students in the player, in a module of its own: only a view that offers help (`hasHelp`) loads it, and\n * without it (or when its chunk fails) the exercise plays without help.\n *\n * Under each graded interaction that offers help (after the block holding it, for one in a line of text), and at the\n * foot of each page with help of its own, a row:\n * - \"Podpowiedź (1/2)\", one hint at a time from the checker, the cost of the next one said before it is used;\n * - \"Sprawdź\" for that interaction alone (practice with `checkScope: 'interaction'`), counted like any check;\n * - the feedback text of the last verdict, in a box of the verdict's colour and edge;\n * - \"Dlaczego?\", a disclosure with the explanation.\n * The texts come with check and submit responses as the policy says (`helpShown` in the engine); the view only says\n * what there is (`HELP_ATTRIBUTES`). A row next to a floated or placed interaction floats with it, below it.\n *\n * What a checker sends is read as hostile, like a view: counts are checked and the HTML is cleaned like view content.\n */\nimport {\n type AttemptPolicy,\n type Checker,\n CheckerError,\n type CheckResponse,\n type ComponentManifest,\n createI18n,\n type ElementHelp,\n FEEDBACK_VARIANTS,\n type Feedback,\n type GradeResult,\n type GroupVerdict,\n helpPolicy,\n inertStyles,\n type MessageCatalog,\n type PlayerElementApi,\n type SubmitResponse,\n type Translate,\n type UrlPolicy,\n} from '@astl/core';\nimport { css, html, nothing, render, type TemplateResult } from 'lit';\nimport { renderVerdict } from '../a11y.js';\nimport type { AttemptController } from '../attempt/controller.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { PLAYER_NAMESPACE, playerMessages } from '../messages.js';\nimport { runtime } from '../runtime.js';\nimport { cleanContent } from './view.js';\n\n/** The help strings of the player namespace: in this module, so a view without help never loads them. */\nexport const helpMessages: readonly MessageCatalog[] = [\n { namespace: PLAYER_NAMESPACE, locale: 'en', messages: en },\n { namespace: PLAYER_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the player gives the help module: the mounted attempt, and how to check, announce and show problems. */\nexport interface HelpHost {\n readonly controller: AttemptController;\n /** The mounted elements in view order, with their page index. */\n readonly mounted: readonly {\n readonly element: HTMLElement & PlayerElementApi;\n readonly manifest: ComponentManifest;\n readonly page: number;\n }[];\n /** The page elements, in order. */\n readonly pages: readonly HTMLElement[];\n /** The UI locale. */\n readonly locale: string;\n readonly urlPolicy: UrlPolicy;\n /** The player's shadow root, for the module's stylesheet. */\n readonly root: Node;\n checker(): Checker | null;\n /** Checks one interaction through the player, which shows a failure; resolves either way. */\n check(id: string): Promise<unknown>;\n announce(message: string): void;\n}\n\nexport interface Help {\n /** Removes the rows and stops listening. */\n destroy(): void;\n}\n\nconst COST = /^(?:0|1|0?\\.\\d{1,6}|1\\.0{1,6})$/;\n\n/** What a view element offers, from its `HELP_ATTRIBUTES`; null when nothing. Costs outside 0..1 are left out. */\nexport function readHelp(el: Element): ElementHelp | null {\n const words = (name: string) => (el.getAttribute(name) ?? '').split(' ').filter(Boolean);\n const hints = words('hints').flatMap((w) => (COST.test(w) ? [Number(w)] : []));\n const written = new Set(words('feedback'));\n const feedback = FEEDBACK_VARIANTS.filter((v) => written.has(v));\n const explanation = el.hasAttribute('explanation');\n return hints.length === 0 && feedback.length === 0 && !explanation\n ? null\n : { hints, explanation, feedback };\n}\n\n/**\n * Help content from a checker (rich text of format 1) as clean live DOM in a `div`: cleaned in an inert document like\n * a view's content, without components or other custom elements, and without styles (the engine writes none into\n * help; a `style` from elsewhere is parsed under its inert name, so a strict CSP reports nothing, and goes).\n */\nexport function readContent(content: string, urlPolicy: UrlPolicy): HTMLElement {\n const template = document.createElement('template');\n template.innerHTML = inertStyles(content);\n const holder = template.content.ownerDocument.createElement('div');\n holder.append(template.content);\n cleanContent(holder, { manifests: new Map(), urlPolicy }, false, false);\n for (const el of Array.from(holder.querySelectorAll('*'))) if (el.localName.includes('-')) el.remove();\n const live = document.importNode(holder, true);\n live.className = 'help-content';\n return live;\n}\n\nconst isFeedback = (v: unknown): v is Feedback =>\n typeof v === 'object' &&\n v !== null &&\n typeof (v as Feedback).html === 'string' &&\n FEEDBACK_VARIANTS.includes((v as Feedback).variant);\n\nconst own = <T>(record: Readonly<Record<string, T>> | undefined, id: string): T | undefined =>\n typeof record === 'object' && record !== null && Object.hasOwn(record, id) ? record[id] : undefined;\n\n/** The engine's rule for several groups: nothing answered is empty, all right correct, some right partial. */\nfunction overall(verdicts: readonly GroupVerdict[]): GroupVerdict | null {\n if (verdicts.length === 0) return null;\n if (verdicts.every((v) => v === 'empty')) return 'empty';\n if (verdicts.every((v) => v === 'correct')) return 'correct';\n return verdicts.some((v) => v === 'correct' || v === 'partial') ? 'partial' : 'incorrect';\n}\n\nconst isCount = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;\n\ninterface Row {\n /** View element or page id: what the checker's help is keyed by. */\n readonly id: string;\n readonly offer: ElementHelp;\n readonly box: HTMLElement;\n readonly label: string;\n /** The hidden end of the check button's name (\"to pytanie\"); null where there is no check of one interaction. */\n readonly check: string | null;\n /**\n * Its element says its verdict in words itself (a block, right above): the feedback box then keeps the icon beside\n * its text and leaves the word to assistive tech. A field in a line of text shows an icon only, a page nothing.\n */\n readonly ownVerdict: boolean;\n /** Its groups in a result (an element's own, or those it is graded in); empty for a page. */\n readonly groups: readonly string[];\n /** The slots whose change makes its feedback stale. */\n readonly slots: ReadonlySet<string>;\n /** The language and direction of its element: its help is content in that language, the row's labels UI text. */\n readonly lang: string;\n readonly dir: string;\n hints: { readonly n: number; readonly content: HTMLElement }[];\n /** Hints given so far, and how many there are (what the checker says once it was asked). */\n used: number;\n total: number;\n pending: boolean;\n /** Problem code of the last hint request. */\n problem: string | null;\n verdict: GroupVerdict | null;\n feedback: HTMLElement | null;\n explanation: HTMLElement | null;\n}\n\n/** Where an element's row goes: after the block of the page (or column) that holds it. */\nfunction anchorOf(element: Element): Element {\n let anchor = element;\n while (anchor.parentElement !== null && !/^astl-(page|column|doc)$/.test(anchor.parentElement.localName)) {\n anchor = anchor.parentElement;\n }\n return anchor;\n}\n\n/**\n * What a floated or placed block writes of its place: its row takes the same, and clears the float. `margin` brings a\n * centring an author wrote as `margin: 0 auto`, which the style keeps as the four sides.\n */\nconst PLACING = [\n 'float',\n 'width',\n 'inline-size',\n 'max-width',\n 'max-inline-size',\n 'margin',\n 'margin-inline',\n 'margin-inline-start',\n 'margin-inline-end',\n];\n\nfunction place(box: HTMLElement, anchor: Element): void {\n if (!(anchor instanceof HTMLElement)) return;\n for (const name of PLACING) {\n const value = anchor.style.getPropertyValue(name);\n if (value !== '') box.style.setProperty(name, value);\n }\n const float = anchor.style.getPropertyValue('float');\n if (float !== '' && float !== 'none') box.style.setProperty('clear', float);\n}\n\n/** Mounts the rows into a mounted view and keeps them in step with the attempt. */\nexport function mountHelp(host: HelpHost): Help {\n const { controller, locale } = host;\n const policy: AttemptPolicy = controller.policy;\n const help = helpPolicy(policy);\n const practice = policy.mode === 'practice';\n const t: Translate = createI18n({\n catalogs: [...playerMessages, ...helpMessages, ...runtime.catalogs],\n }).translator(locale, PLAYER_NAMESPACE);\n adoptHelpSheet(host.root);\n\n const rows: Row[] = [];\n const after = new Map<Element, Element>();\n const row = (\n owner: Element,\n offer: ElementHelp,\n extra: Pick<Row, 'label' | 'check' | 'ownVerdict' | 'groups' | 'slots'>,\n ) => {\n const box = document.createElement('div');\n box.className = 'astl-help';\n box.setAttribute('part', 'help');\n box.setAttribute('role', 'group');\n box.setAttribute('aria-label', extra.label);\n box.lang = locale;\n const entry: Row = {\n id: owner.id,\n offer,\n box,\n ...extra,\n lang: owner.closest('[lang]')?.getAttribute('lang') ?? '',\n dir: owner.closest('[dir]')?.getAttribute('dir') ?? '',\n hints: [],\n used: 0,\n total: offer.hints.length,\n pending: false,\n problem: null,\n verdict: null,\n feedback: null,\n explanation: null,\n };\n rows.push(entry);\n return entry;\n };\n\n let field = 0;\n for (const { element, manifest } of host.mounted) {\n const inline = manifest.display === 'inline';\n if (inline) field++;\n const offer = manifest.graded ? readHelp(element) : null;\n if (offer === null) continue;\n const n = field;\n const entry = row(element, offer, {\n label: inline ? t('help.labelField', { n }) : t('help.label'),\n check:\n practice && help.checkScope === 'interaction'\n ? inline\n ? t('help.checkField', { n })\n : t('help.check')\n : null,\n ownVerdict: !inline,\n groups: element.groupIds ?? [element.id],\n slots: new Set(element.slotIds),\n });\n const anchor = anchorOf(element);\n (after.get(anchor) ?? anchor).after(entry.box);\n after.set(anchor, entry.box);\n place(entry.box, anchor);\n }\n host.pages.forEach((page, index) => {\n const offer = page.localName === 'astl-page' ? readHelp(page) : null;\n if (offer === null) return;\n const entry = row(page, offer, {\n label: t('help.labelPage'),\n check: null,\n ownVerdict: false,\n groups: [],\n slots: new Set(controller.pages[index]?.slotIds ?? []),\n });\n entry.box.dataset.page = '';\n page.append(entry.box);\n });\n\n const content = (value: unknown, entry: Row): HTMLElement | null => {\n if (typeof value !== 'string') return null;\n const shown = readContent(value, host.urlPolicy);\n if (entry.lang) shown.lang = entry.lang;\n if (entry.dir) shown.dir = entry.dir;\n return shown;\n };\n\n /** Takes in what a response says of the rows it graded (`only`: a check of one interaction). */\n const apply = (response: CheckResponse | SubmitResponse, only: string | null): void => {\n const result: GradeResult | null = response.result;\n if (result === null) return;\n for (const entry of rows) {\n if (only !== null && entry.id !== only) continue;\n const verdicts = result.groups.filter((g) => entry.groups.includes(g.id)).map((g) => g.verdict);\n const graded = entry.groups.length === 0 ? Object.hasOwn(result.pages, entry.id) : verdicts.length > 0;\n if (!graded) continue;\n const feedback = own(response.feedback, entry.id);\n entry.verdict = isFeedback(feedback)\n ? feedback.variant === 'omitted'\n ? 'empty'\n : feedback.variant\n : overall(verdicts);\n entry.feedback = isFeedback(feedback) ? content(feedback.html, entry) : null;\n entry.explanation = content(own(response.explanations, entry.id), entry) ?? entry.explanation;\n }\n };\n\n const update = (): void => {\n for (const entry of rows) render(view(entry), entry.box);\n };\n\n const ask = async (entry: Row): Promise<void> => {\n const checker = host.checker();\n if (entry.pending) return;\n entry.pending = true;\n entry.problem = null;\n update();\n try {\n if (checker?.hint === undefined) throw checker === null ? 'no_checker' : 'hints_not_allowed';\n const hint = await checker.hint({ element: entry.id });\n const index = isCount(hint.index) ? hint.index : entry.used;\n const shown = content(hint.html, entry) as HTMLElement;\n entry.hints = [...entry.hints, { n: index + 1, content: shown }];\n entry.used = index + 1;\n entry.total = isCount(hint.left) ? entry.used + hint.left : Math.max(entry.total, entry.used);\n host.announce(t('help.hintAnnounce', { n: index + 1, text: shown.textContent?.trim() ?? '' }));\n } catch (error) {\n const code =\n error instanceof CheckerError\n ? error.problem.code\n : typeof error === 'string'\n ? error\n : 'internal_error';\n if (code === 'hints_exhausted') entry.total = entry.used;\n entry.problem = code;\n host.announce(problemText(code));\n } finally {\n entry.pending = false;\n const active = host.root instanceof ShadowRoot ? host.root.activeElement : document.activeElement;\n const focused = entry.box.contains(active);\n update();\n // The last hint takes its button away: the focus goes to that hint, not to the page.\n if (focused && entry.used >= entry.total) {\n entry.box.querySelector<HTMLElement>('.help-hints li:last-child')?.focus();\n }\n }\n };\n\n const problemText = (code: string): string => {\n const message = t(`error.${code}`);\n return message === `error.${code}` ? t('error.internal_error') : message;\n };\n\n const view = (entry: Row): TemplateResult | typeof nothing => {\n const open = !controller.readOnly;\n const next = entry.used < entry.total && help.hints && practice && open ? entry.used : null;\n const cost = next === null ? 0 : (entry.offer.hints[next] ?? 0);\n const costId = `astl-help-cost-${rows.indexOf(entry)}`;\n const check = entry.check !== null && open;\n const shows =\n next !== null ||\n check ||\n entry.hints.length > 0 ||\n entry.feedback !== null ||\n entry.explanation !== null;\n entry.box.hidden = !shows && entry.problem === null;\n if (entry.box.hidden) return nothing;\n return html`${\n next === null && !check\n ? nothing\n : html`<div class=\"help-actions\">\n ${\n next === null\n ? nothing\n : html`<span class=\"help-hint\"\n ><button\n type=\"button\"\n class=\"button\"\n aria-describedby=${cost > 0 ? costId : nothing}\n aria-disabled=${entry.pending ? 'true' : nothing}\n @click=${() => void ask(entry)}\n >\n ${t('help.hint', { n: next + 1, total: entry.total })}\n </button>\n ${\n cost > 0\n ? html`<span class=\"help-cost\" id=${costId}\n >${t('help.hintCost', { percent: Math.round(cost * 100) })}</span\n >`\n : nothing\n }</span\n >`\n }\n ${\n check\n ? html`<button\n type=\"button\"\n class=\"button\"\n aria-disabled=${controller.canCheck() ? nothing : 'true'}\n @click=${() => {\n if (controller.canCheck()) void host.check(entry.id);\n }}\n >\n ${t('action.check')}<span class=\"astl-vh\"> ${entry.check}</span>\n </button>`\n : nothing\n }\n </div>`\n }\n ${\n entry.hints.length === 0\n ? nothing\n : html`<ol class=\"help-hints\">\n ${entry.hints.map(\n (hint) =>\n html`<li tabindex=\"-1\">\n <span class=\"help-label\">${t('help.hintItem', { n: hint.n })}</span>${hint.content}\n </li>`,\n )}\n </ol>`\n }\n ${\n entry.feedback === null || entry.verdict === null\n ? nothing\n : html`<div class=\"help-feedback\" data-verdict=${entry.verdict} ?data-own=${entry.ownVerdict}>\n ${renderVerdict(entry.verdict, t, { lang: locale, hiddenWord: entry.ownVerdict })}${entry.feedback}\n </div>`\n }\n ${\n entry.explanation === null\n ? nothing\n : html`<details class=\"help-why\">\n <summary>${t('help.why')}</summary>\n ${entry.explanation}\n </details>`\n }\n ${entry.problem === null ? nothing : html`<p class=\"help-problem\" role=\"alert\">${problemText(entry.problem)}</p>`}`;\n };\n\n const unsubscribe = controller.subscribe((change) => {\n if (change.type === 'result') apply(change.response, null);\n else if (change.type === 'element') {\n apply(change.response, change.id);\n const entry = rows.find((r) => r.id === change.id);\n if (entry?.verdict != null) {\n host.announce(\n [t(`verdict.${entry.verdict}`), entry.feedback?.textContent?.trim()].filter(Boolean).join('. '),\n );\n }\n } else if (change.type === 'answers') {\n const changed = Object.keys(change.answers);\n for (const entry of rows) {\n if (changed.some((id) => entry.slots.has(id))) {\n entry.verdict = null;\n entry.feedback = null;\n }\n }\n } else if (change.type === 'reset') {\n for (const entry of rows) {\n entry.verdict = null;\n entry.feedback = null;\n entry.explanation = null;\n }\n }\n update();\n });\n update();\n\n return {\n destroy() {\n unsubscribe();\n for (const entry of rows) entry.box.remove();\n },\n };\n}\n\n// Rows sit in the content's flow, in the UI's type size. A page's row opens with a line across the page, under its\n// floats. The feedback box has the verdict's colour and edge (solid, double, dashed, dotted), never colour alone;\n// under a block, which says its verdict in words right above, it keeps the icon beside the text, the word hidden.\n// A hint's cost stays by its button (closer than the next action), and wraps under it, never beside \"Check\".\nconst helpSheet = css`\n .canvas .astl-help {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--astl-space-2);\n margin-block: 0 var(--astl-space-4);\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n .canvas .astl-help[hidden] {\n display: none;\n }\n .canvas .astl-help[data-page] {\n clear: both;\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n .help-actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2) var(--astl-space-5);\n }\n .help-hint {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1) var(--astl-space-2);\n }\n .help-cost {\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n .help-hints {\n display: grid;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .help-hints li,\n .help-feedback,\n .help-why {\n box-sizing: border-box;\n max-inline-size: 100%;\n padding-block: var(--astl-space-2);\n padding-inline: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n }\n .help-label {\n display: block;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n font-weight: 600;\n }\n .help-feedback {\n border-style: var(--astl-verdict-border);\n border-color: var(--astl-verdict-color);\n background: var(--astl-verdict-soft);\n }\n .help-feedback[data-own] {\n display: flex;\n align-items: flex-start;\n gap: var(--astl-space-2);\n }\n .help-feedback[data-own] > .astl-verdict {\n block-size: 1lh;\n }\n .help-feedback[data-own] > .help-content {\n flex: 1;\n min-inline-size: 0;\n }\n .help-content > :first-child {\n margin-block-start: 0;\n }\n .help-content > :last-child {\n margin-block-end: 0;\n }\n .help-why {\n padding-block: 0;\n }\n .help-why summary {\n display: flex;\n align-items: center;\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n cursor: pointer;\n font-weight: 600;\n }\n .help-why[open] {\n padding-block-end: var(--astl-space-2);\n }\n .help-problem {\n margin: 0;\n color: var(--astl-ink);\n }\n`.styleSheet;\n\n/** Adopts the rows' stylesheet in a player's root, once. */\nfunction adoptHelpSheet(root: Node): void {\n if (helpSheet !== undefined && root instanceof ShadowRoot && !root.adoptedStyleSheets.includes(helpSheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, helpSheet];\n }\n}\n"],"mappings":"A,yIE6CA,IAAaiB,EAA0C,CACrD,CAAE,UAAWP,EAAkB,OAAQ,KAAM,SAAUV,C,+cAAAA,CAAG,EAC1D,CAAE,UAAWU,EAAkB,OAAQ,KAAM,SAAU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M,IAAIzB,CAAE,CAAC,IAC1C,EAAM,QAAU,KAChB,EAAM,SAAW,KAGvB,MAAO,GAAI0D,EAAO,OAAS,QACzB,IAAK,IAAMjC,KAASJ,EAClB,EAAM,QAAU,KAChB,EAAM,SAAW,KACjB,EAAM,YAAc,KAGxBmB,EAAO,CACT,CAAC,EAGD,OAFAA,EAAO,EAEA,CACL,SAAU,CACRiB,EAAY,EACZ,IAAK,IAAMhC,KAASJ,EAAMI,EAAM,IAAI,OAAO,CAC7C,CACF,CACF,CAMA,IAAMoC,EAAY,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoGnB,WAGF,SAASzC,EAAe,EAAkB,CACpCyC,IAAc,IAAA,IAAaC,aAAgB,YAAc,CAACA,EAAK,mBAAmB,SAASD,CAAS,IACtG,EAAK,mBAAqB,CAAC,GAAGC,EAAK,mBAAoBD,CAAS,EAEpE,C"}
|
|
1
|
+
{"version":3,"file":"help-CmCFuNXk.js","names":["en","pl","nothing","b","i","helpPolicy","A","FEEDBACK_VARIANTS","runtime","inertStyles","PLAYER_NAMESPACE","CheckerError","createI18n","renderVerdict","cleanContent","playerMessages","D","helpMessages","COST","readHelp","words","el","name","hints","w","written","feedback","v","explanation","readContent","template","content","holder","live","isFeedback","own","record","id","overall","verdicts","isCount","anchorOf","anchor","element","PLACING","place","value","box","float","mountHelp","host","policy","controller","help","practice","t","locale","adoptHelpSheet","rows","after","row","extra","entry","owner","offer","field","inline","manifest","n","page","index","shown","apply","result","response","only","g","update","view","ask","checker","hint","error","code","problemText","active","focused","message","open","next","cost","costId","check","shows","unsubscribe","change","r","changed","helpSheet","root"],"sources":["../../../../player/src/messages/help/en.json","../../../../player/src/messages/help/pl.json","../../../../player/src/player/help.ts"],"sourcesContent":["{\n \"help.label\": \"Help with this question\",\n \"help.labelField\": \"Help with field {n}\",\n \"help.labelPage\": \"Help with this page\",\n \"help.hint\": \"Hint ({n}/{total})\",\n \"help.hintCost\": \"Costs {percent}% of the points\",\n \"help.hintItem\": \"Hint {n}\",\n \"help.hintAnnounce\": \"Hint {n}: {text}\",\n \"help.check\": \"this question\",\n \"help.checkField\": \"field {n}\",\n \"help.why\": \"Why?\",\n \"error.hints_not_allowed\": \"Hints are not available in this exercise.\",\n \"error.hints_exhausted\": \"There are no more hints.\"\n}\n","{\n \"help.label\": \"Pomoc do tego pytania\",\n \"help.labelField\": \"Pomoc do pola {n}\",\n \"help.labelPage\": \"Pomoc do tej strony\",\n \"help.hint\": \"Podpowiedź ({n}/{total})\",\n \"help.hintCost\": \"Kosztuje {percent}% punktów\",\n \"help.hintItem\": \"Podpowiedź {n}\",\n \"help.hintAnnounce\": \"Podpowiedź {n}: {text}\",\n \"help.check\": \"to pytanie\",\n \"help.checkField\": \"pole {n}\",\n \"help.why\": \"Dlaczego?\",\n \"error.hints_not_allowed\": \"W tym zadaniu nie ma podpowiedzi.\",\n \"error.hints_exhausted\": \"Nie ma już więcej podpowiedzi.\"\n}\n","/**\n * Help for students in the player, in a module of its own: only a view that offers help (`hasHelp`) loads it, and\n * without it (or when its chunk fails) the exercise plays without help.\n *\n * Under each graded interaction that offers help (after the block holding it, for one in a line of text), and at the\n * foot of each page with help of its own, a row:\n * - \"Podpowiedź (1/2)\", one hint at a time from the checker, the cost of the next one said before it is used;\n * - \"Sprawdź\" for that interaction alone (practice with `checkScope: 'interaction'`), counted like any check;\n * - the feedback text of the last verdict, in a box of the verdict's colour and edge;\n * - \"Dlaczego?\", a disclosure with the explanation.\n * The texts come with check and submit responses as the policy says (`helpShown` in the engine); the view only says\n * what there is (`HELP_ATTRIBUTES`). A row next to a floated or placed interaction floats with it, below it.\n *\n * What a checker sends is read as hostile, like a view: counts are checked and the HTML is cleaned like view content.\n */\nimport {\n type AttemptPolicy,\n type Checker,\n CheckerError,\n type CheckResponse,\n type ComponentManifest,\n createI18n,\n type ElementHelp,\n FEEDBACK_VARIANTS,\n type Feedback,\n type GradeResult,\n type GroupVerdict,\n helpPolicy,\n inertStyles,\n type MessageCatalog,\n type PlayerElementApi,\n type SubmitResponse,\n type Translate,\n type UrlPolicy,\n} from '@astl/core';\nimport { css, html, nothing, render, type TemplateResult } from 'lit';\nimport { renderVerdict } from '../a11y.js';\nimport type { AttemptController } from '../attempt/controller.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { PLAYER_NAMESPACE, playerMessages } from '../messages.js';\nimport { runtime } from '../runtime.js';\nimport { cleanContent } from './view.js';\n\n/** The help strings of the player namespace: in this module, so a view without help never loads them. */\nexport const helpMessages: readonly MessageCatalog[] = [\n { namespace: PLAYER_NAMESPACE, locale: 'en', messages: en },\n { namespace: PLAYER_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the player gives the help module: the mounted attempt, and how to check, announce and show problems. */\nexport interface HelpHost {\n readonly controller: AttemptController;\n /** The mounted elements in view order, with their page index. */\n readonly mounted: readonly {\n readonly element: HTMLElement & PlayerElementApi;\n readonly manifest: ComponentManifest;\n readonly page: number;\n }[];\n /** The page elements, in order. */\n readonly pages: readonly HTMLElement[];\n /** The UI locale. */\n readonly locale: string;\n readonly urlPolicy: UrlPolicy;\n /** The player's shadow root, for the module's stylesheet. */\n readonly root: Node;\n checker(): Checker | null;\n /** Checks one interaction through the player, which shows a failure; resolves either way. */\n check(id: string): Promise<unknown>;\n announce(message: string): void;\n}\n\nexport interface Help {\n /** Removes the rows and stops listening. */\n destroy(): void;\n}\n\nconst COST = /^(?:0|1|0?\\.\\d{1,6}|1\\.0{1,6})$/;\n\n/** What a view element offers, from its `HELP_ATTRIBUTES`; null when nothing. Costs outside 0..1 are left out. */\nexport function readHelp(el: Element): ElementHelp | null {\n const words = (name: string) => (el.getAttribute(name) ?? '').split(' ').filter(Boolean);\n const hints = words('hints').flatMap((w) => (COST.test(w) ? [Number(w)] : []));\n const written = new Set(words('feedback'));\n const feedback = FEEDBACK_VARIANTS.filter((v) => written.has(v));\n const explanation = el.hasAttribute('explanation');\n return hints.length === 0 && feedback.length === 0 && !explanation\n ? null\n : { hints, explanation, feedback };\n}\n\n/**\n * Help content from a checker (rich text of format 1) as clean live DOM in a `div`: cleaned in an inert document like\n * a view's content, without components or other custom elements, and without styles (the engine writes none into\n * help; a `style` from elsewhere is parsed under its inert name, so a strict CSP reports nothing, and goes).\n */\nexport function readContent(content: string, urlPolicy: UrlPolicy): HTMLElement {\n const template = document.createElement('template');\n template.innerHTML = inertStyles(content);\n const holder = template.content.ownerDocument.createElement('div');\n holder.append(template.content);\n cleanContent(holder, { manifests: new Map(), urlPolicy }, false, false);\n for (const el of Array.from(holder.querySelectorAll('*'))) if (el.localName.includes('-')) el.remove();\n const live = document.importNode(holder, true);\n live.className = 'help-content';\n return live;\n}\n\nconst isFeedback = (v: unknown): v is Feedback =>\n typeof v === 'object' &&\n v !== null &&\n typeof (v as Feedback).html === 'string' &&\n FEEDBACK_VARIANTS.includes((v as Feedback).variant);\n\nconst own = <T>(record: Readonly<Record<string, T>> | undefined, id: string): T | undefined =>\n typeof record === 'object' && record !== null && Object.hasOwn(record, id) ? record[id] : undefined;\n\n/** The engine's rule for several groups: nothing answered is empty, all right correct, some right partial. */\nfunction overall(verdicts: readonly GroupVerdict[]): GroupVerdict | null {\n if (verdicts.length === 0) return null;\n if (verdicts.every((v) => v === 'empty')) return 'empty';\n if (verdicts.every((v) => v === 'correct')) return 'correct';\n return verdicts.some((v) => v === 'correct' || v === 'partial') ? 'partial' : 'incorrect';\n}\n\nconst isCount = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;\n\ninterface Row {\n /** View element or page id: what the checker's help is keyed by. */\n readonly id: string;\n readonly offer: ElementHelp;\n readonly box: HTMLElement;\n readonly label: string;\n /** The hidden end of the check button's name (\"to pytanie\"); null where there is no check of one interaction. */\n readonly check: string | null;\n /**\n * Its element says its verdict in words itself (a block, right above): the feedback box then keeps the icon beside\n * its text and leaves the word to assistive tech. A field in a line of text shows an icon only, a page nothing.\n */\n readonly ownVerdict: boolean;\n /** Its groups in a result (an element's own, or those it is graded in); empty for a page. */\n readonly groups: readonly string[];\n /** The slots whose change makes its feedback stale. */\n readonly slots: ReadonlySet<string>;\n /** The language and direction of its element: its help is content in that language, the row's labels UI text. */\n readonly lang: string;\n readonly dir: string;\n hints: { readonly n: number; readonly content: HTMLElement }[];\n /** Hints given so far, and how many there are (what the checker says once it was asked). */\n used: number;\n total: number;\n pending: boolean;\n /** Problem code of the last hint request. */\n problem: string | null;\n verdict: GroupVerdict | null;\n feedback: HTMLElement | null;\n explanation: HTMLElement | null;\n}\n\n/** Where an element's row goes: after the block of the page (or column) that holds it. */\nfunction anchorOf(element: Element): Element {\n let anchor = element;\n while (anchor.parentElement !== null && !/^astl-(page|column|doc)$/.test(anchor.parentElement.localName)) {\n anchor = anchor.parentElement;\n }\n return anchor;\n}\n\n/**\n * What a floated or placed block writes of its place: its row takes the same, and clears the float. `margin` brings a\n * centring an author wrote as `margin: 0 auto`, which the style keeps as the four sides.\n */\nconst PLACING = [\n 'float',\n 'width',\n 'inline-size',\n 'max-width',\n 'max-inline-size',\n 'margin',\n 'margin-inline',\n 'margin-inline-start',\n 'margin-inline-end',\n];\n\nfunction place(box: HTMLElement, anchor: Element): void {\n if (!(anchor instanceof HTMLElement)) return;\n for (const name of PLACING) {\n const value = anchor.style.getPropertyValue(name);\n if (value !== '') box.style.setProperty(name, value);\n }\n const float = anchor.style.getPropertyValue('float');\n if (float !== '' && float !== 'none') box.style.setProperty('clear', float);\n}\n\n/** Mounts the rows into a mounted view and keeps them in step with the attempt. */\nexport function mountHelp(host: HelpHost): Help {\n const { controller, locale } = host;\n const policy: AttemptPolicy = controller.policy;\n const help = helpPolicy(policy);\n const practice = policy.mode === 'practice';\n const t: Translate = createI18n({\n catalogs: [...playerMessages, ...helpMessages, ...runtime.catalogs],\n }).translator(locale, PLAYER_NAMESPACE);\n adoptHelpSheet(host.root);\n\n const rows: Row[] = [];\n const after = new Map<Element, Element>();\n const row = (\n owner: Element,\n offer: ElementHelp,\n extra: Pick<Row, 'label' | 'check' | 'ownVerdict' | 'groups' | 'slots'>,\n ) => {\n const box = document.createElement('div');\n box.className = 'astl-help';\n box.setAttribute('part', 'help');\n box.setAttribute('role', 'group');\n box.setAttribute('aria-label', extra.label);\n box.lang = locale;\n const entry: Row = {\n id: owner.id,\n offer,\n box,\n ...extra,\n lang: owner.closest('[lang]')?.getAttribute('lang') ?? '',\n dir: owner.closest('[dir]')?.getAttribute('dir') ?? '',\n hints: [],\n used: 0,\n total: offer.hints.length,\n pending: false,\n problem: null,\n verdict: null,\n feedback: null,\n explanation: null,\n };\n rows.push(entry);\n return entry;\n };\n\n let field = 0;\n for (const { element, manifest } of host.mounted) {\n const inline = manifest.display === 'inline';\n if (inline) field++;\n const offer = manifest.graded ? readHelp(element) : null;\n if (offer === null) continue;\n const n = field;\n const entry = row(element, offer, {\n label: inline ? t('help.labelField', { n }) : t('help.label'),\n check:\n practice && help.checkScope === 'interaction'\n ? inline\n ? t('help.checkField', { n })\n : t('help.check')\n : null,\n ownVerdict: !inline,\n groups: element.groupIds ?? [element.id],\n slots: new Set(element.slotIds),\n });\n const anchor = anchorOf(element);\n (after.get(anchor) ?? anchor).after(entry.box);\n after.set(anchor, entry.box);\n place(entry.box, anchor);\n }\n host.pages.forEach((page, index) => {\n const offer = page.localName === 'astl-page' ? readHelp(page) : null;\n if (offer === null) return;\n const entry = row(page, offer, {\n label: t('help.labelPage'),\n check: null,\n ownVerdict: false,\n groups: [],\n slots: new Set(controller.pages[index]?.slotIds ?? []),\n });\n entry.box.dataset.page = '';\n page.append(entry.box);\n });\n\n const content = (value: unknown, entry: Row): HTMLElement | null => {\n if (typeof value !== 'string') return null;\n const shown = readContent(value, host.urlPolicy);\n if (entry.lang) shown.lang = entry.lang;\n if (entry.dir) shown.dir = entry.dir;\n return shown;\n };\n\n /** Takes in what a response says of the rows it graded (`only`: a check of one interaction). */\n const apply = (response: CheckResponse | SubmitResponse, only: string | null): void => {\n const result: GradeResult | null = response.result;\n if (result === null) return;\n for (const entry of rows) {\n if (only !== null && entry.id !== only) continue;\n const verdicts = result.groups.filter((g) => entry.groups.includes(g.id)).map((g) => g.verdict);\n const graded = entry.groups.length === 0 ? Object.hasOwn(result.pages, entry.id) : verdicts.length > 0;\n if (!graded) continue;\n const feedback = own(response.feedback, entry.id);\n entry.verdict = isFeedback(feedback)\n ? feedback.variant === 'omitted'\n ? 'empty'\n : feedback.variant\n : overall(verdicts);\n entry.feedback = isFeedback(feedback) ? content(feedback.html, entry) : null;\n entry.explanation = content(own(response.explanations, entry.id), entry) ?? entry.explanation;\n }\n };\n\n const update = (): void => {\n for (const entry of rows) render(view(entry), entry.box);\n };\n\n const ask = async (entry: Row): Promise<void> => {\n const checker = host.checker();\n if (entry.pending) return;\n entry.pending = true;\n entry.problem = null;\n update();\n try {\n if (checker?.hint === undefined) throw checker === null ? 'no_checker' : 'hints_not_allowed';\n const hint = await checker.hint({ element: entry.id });\n const index = isCount(hint.index) ? hint.index : entry.used;\n const shown = content(hint.html, entry) as HTMLElement;\n entry.hints = [...entry.hints, { n: index + 1, content: shown }];\n entry.used = index + 1;\n entry.total = isCount(hint.left) ? entry.used + hint.left : Math.max(entry.total, entry.used);\n host.announce(t('help.hintAnnounce', { n: index + 1, text: shown.textContent?.trim() ?? '' }));\n } catch (error) {\n const code =\n error instanceof CheckerError\n ? error.problem.code\n : typeof error === 'string'\n ? error\n : 'internal_error';\n if (code === 'hints_exhausted') entry.total = entry.used;\n entry.problem = code;\n host.announce(problemText(code));\n } finally {\n entry.pending = false;\n const active = host.root instanceof ShadowRoot ? host.root.activeElement : document.activeElement;\n const focused = entry.box.contains(active);\n update();\n // The last hint takes its button away: the focus goes to that hint, not to the page.\n if (focused && entry.used >= entry.total) {\n entry.box.querySelector<HTMLElement>('.help-hints li:last-child')?.focus();\n }\n }\n };\n\n const problemText = (code: string): string => {\n const message = t(`error.${code}`);\n return message === `error.${code}` ? t('error.internal_error') : message;\n };\n\n const view = (entry: Row): TemplateResult | typeof nothing => {\n const open = !controller.readOnly;\n const next = entry.used < entry.total && help.hints && practice && open ? entry.used : null;\n const cost = next === null ? 0 : (entry.offer.hints[next] ?? 0);\n const costId = `astl-help-cost-${rows.indexOf(entry)}`;\n const check = entry.check !== null && open;\n const shows =\n next !== null ||\n check ||\n entry.hints.length > 0 ||\n entry.feedback !== null ||\n entry.explanation !== null;\n entry.box.hidden = !shows && entry.problem === null;\n if (entry.box.hidden) return nothing;\n return html`${\n next === null && !check\n ? nothing\n : html`<div class=\"help-actions\">\n ${\n next === null\n ? nothing\n : html`<span class=\"help-hint\"\n ><button\n type=\"button\"\n class=\"button\"\n aria-describedby=${cost > 0 ? costId : nothing}\n aria-disabled=${entry.pending ? 'true' : nothing}\n @click=${() => void ask(entry)}\n >\n ${t('help.hint', { n: next + 1, total: entry.total })}\n </button>\n ${\n cost > 0\n ? html`<span class=\"help-cost\" id=${costId}\n >${t('help.hintCost', { percent: Math.round(cost * 100) })}</span\n >`\n : nothing\n }</span\n >`\n }\n ${\n check\n ? html`<button\n type=\"button\"\n class=\"button\"\n aria-disabled=${controller.canCheck() ? nothing : 'true'}\n @click=${() => {\n if (controller.canCheck()) void host.check(entry.id);\n }}\n >\n ${t('action.check')}<span class=\"astl-vh\"> ${entry.check}</span>\n </button>`\n : nothing\n }\n </div>`\n }\n ${\n entry.hints.length === 0\n ? nothing\n : html`<ol class=\"help-hints\">\n ${entry.hints.map(\n (hint) =>\n html`<li tabindex=\"-1\">\n <span class=\"help-label\">${t('help.hintItem', { n: hint.n })}</span>${hint.content}\n </li>`,\n )}\n </ol>`\n }\n ${\n entry.feedback === null || entry.verdict === null\n ? nothing\n : html`<div class=\"help-feedback\" data-verdict=${entry.verdict} ?data-own=${entry.ownVerdict}>\n ${renderVerdict(entry.verdict, t, { lang: locale, hiddenWord: entry.ownVerdict })}${entry.feedback}\n </div>`\n }\n ${\n entry.explanation === null\n ? nothing\n : html`<details class=\"help-why\">\n <summary>${t('help.why')}</summary>\n ${entry.explanation}\n </details>`\n }\n ${entry.problem === null ? nothing : html`<p class=\"help-problem\" role=\"alert\">${problemText(entry.problem)}</p>`}`;\n };\n\n const unsubscribe = controller.subscribe((change) => {\n if (change.type === 'result') apply(change.response, null);\n else if (change.type === 'element') {\n apply(change.response, change.id);\n const entry = rows.find((r) => r.id === change.id);\n if (entry?.verdict != null) {\n host.announce(\n [t(`verdict.${entry.verdict}`), entry.feedback?.textContent?.trim()].filter(Boolean).join('. '),\n );\n }\n } else if (change.type === 'answers') {\n const changed = Object.keys(change.answers);\n for (const entry of rows) {\n if (changed.some((id) => entry.slots.has(id))) {\n entry.verdict = null;\n entry.feedback = null;\n }\n }\n } else if (change.type === 'reset') {\n for (const entry of rows) {\n entry.verdict = null;\n entry.feedback = null;\n entry.explanation = null;\n }\n }\n update();\n });\n update();\n\n return {\n destroy() {\n unsubscribe();\n for (const entry of rows) entry.box.remove();\n },\n };\n}\n\n// Rows sit in the content's flow, in the UI's type size. A page's row opens with a line across the page, under its\n// floats. The feedback box has the verdict's colour and edge (solid, double, dashed, dotted), never colour alone;\n// under a block, which says its verdict in words right above, it keeps the icon beside the text, the word hidden.\n// A hint's cost stays by its button (closer than the next action), and wraps under it, never beside \"Check\".\nconst helpSheet = css`\n .canvas .astl-help {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--astl-space-2);\n margin-block: 0 var(--astl-space-4);\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n .canvas .astl-help[hidden] {\n display: none;\n }\n .canvas .astl-help[data-page] {\n clear: both;\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n .help-actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2) var(--astl-space-5);\n }\n .help-hint {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1) var(--astl-space-2);\n }\n .help-cost {\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n .help-hints {\n display: grid;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .help-hints li,\n .help-feedback,\n .help-why {\n box-sizing: border-box;\n max-inline-size: 100%;\n padding-block: var(--astl-space-2);\n padding-inline: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n }\n .help-label {\n display: block;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n font-weight: 600;\n }\n .help-feedback {\n border-style: var(--astl-verdict-border);\n border-color: var(--astl-verdict-color);\n background: var(--astl-verdict-soft);\n }\n .help-feedback[data-own] {\n display: flex;\n align-items: flex-start;\n gap: var(--astl-space-2);\n }\n .help-feedback[data-own] > .astl-verdict {\n block-size: 1lh;\n }\n .help-feedback[data-own] > .help-content {\n flex: 1;\n min-inline-size: 0;\n }\n .help-content > :first-child {\n margin-block-start: 0;\n }\n .help-content > :last-child {\n margin-block-end: 0;\n }\n .help-why {\n padding-block: 0;\n }\n .help-why summary {\n display: flex;\n align-items: center;\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n cursor: pointer;\n font-weight: 600;\n }\n .help-why[open] {\n padding-block-end: var(--astl-space-2);\n }\n .help-problem {\n margin: 0;\n color: var(--astl-ink);\n }\n`.styleSheet;\n\n/** Adopts the rows' stylesheet in a player's root, once. */\nfunction adoptHelpSheet(root: Node): void {\n if (helpSheet !== undefined && root instanceof ShadowRoot && !root.adoptedStyleSheets.includes(helpSheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, helpSheet];\n }\n}\n"],"mappings":"A,yIE6CA,IAAaiB,EAA0C,CACrD,CAAE,UAAWP,EAAkB,OAAQ,KAAM,SAAUV,C,+cAAAA,CAAG,EAC1D,CAAE,UAAWU,EAAkB,OAAQ,KA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AAM,MAAM,IAAIzB,CAAE,CAAC,IAC1C,EAAM,QAAU,KAChB,EAAM,SAAW,KAGvB,MAAO,GAAI0D,EAAO,OAAS,QACzB,IAAK,IAAMjC,KAASJ,EAClB,EAAM,QAAU,KAChB,EAAM,SAAW,KACjB,EAAM,YAAc,KAGxBmB,EAAO,CACT,CAAC,EAGD,OAFAA,EAAO,EAEA,CACL,SAAU,CACRiB,EAAY,EACZ,IAAK,IAAMhC,KAASJ,EAAMI,EAAM,IAAI,OAAO,CAC7C,CACF,CACF,CAMA,IAAMoC,EAAY,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoGnB,WAGF,SAASzC,EAAe,EAAkB,CACpCyC,IAAc,IAAA,IAAaC,aAAgB,YAAc,CAACA,EAAK,mBAAmB,SAASD,CAAS,IACtG,EAAK,mBAAqB,CAAC,GAAGC,EAAK,mBAAoBD,CAAS,EAEpE,C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{H as e}from"./definitions-
|
|
1
|
+
import{H as e}from"./definitions-BybSa1mq.js";import{C as t,Ct as n,E as r,St as i,b as a,bt as o,fn as s,mn as c,vt as l,yt as u}from"./runtime-C25QK5B0.js";import{i as d,l as f,n as p,o as m,r as h,t as g}from"./scan-BVhxT2Hw.js";import{t as _}from"./messages-Qzse5KMX.js";import{n as v,r as y}from"./styles-DiY3VA_T.js";import{t as b}from"./live-qnReIRtj.js";var x=(e,t)=>t.endTag===null&&t.startTag.selfClosing?``:e.slice(t.startTag.end,t.endTag?.start??t.end),S=e=>e.children.filter(e=>i.has(e.name)),C=e=>o.includes(e);function w(e){let t=h(e)[0],n=[],r=null,i={};for(let a of t===void 0?[]:S(t)){let t=x(e,a);if(a.name===`astl-hint`)n.push({html:t,cost:p(a.startTag,`cost`)});else if(a.name===`astl-explanation`)r??=t;else{let e=p(a.startTag,`when`);C(e)&&(i[e]??=t)}}return{hints:n,explanation:r,feedback:i}}function T(e){let t=e=>e===null?``:` cost="${d(e)}"`;return[...e.hints.map(e=>`<${n}${t(e.cost)}>${e.html}</${n}>`),...e.explanation===null?[]:[`<${l}>${e.explanation}</${l}>`],...o.flatMap(t=>{let n=e.feedback[t];return n===void 0?[]:[`<${u} when="${t}">${n}</${u}>`]})]}function E(e,t){let n=h(e)[0];if(n===void 0)return e;let r=g(e,S(n).map(t=>({start:f(e,t.start),end:t.end,text:``}))),i=T(t),a=h(r)[0];if(a===void 0||i.length===0)return r;let o=a.children.at(-1);if(o===void 0){let e=a.endTag?.start??a.end;return a.endTag===null&&a.startTag.selfClosing?`${r.slice(0,a.start)}${r.slice(a.start,f(r,a.startTag.end-2))}>${i.join(``)}</${a.name}>${r.slice(a.end)}`:g(r,[{start:e,end:e,text:i.join(``)}])}let s=r.slice(f(r,o.start),o.start),c=/^\s*$/.test(s)?s:``;return g(r,[{start:o.end,end:o.end,text:i.map(e=>c+e).join(``)}])}var D=e=>s(e)?e.tag===`br`?`
|
|
2
2
|
`:e.children.map(D).join(``):c(e);function O(t){return(e=>e.flatMap(e=>s(e)?e.tag===`p`||e.tag===`li`?[`\n\n${D(e).trim()}\n\n`]:[D(e)]:[c(e)]))(e(t)).join(``).replace(/[ \t]+/g,` `).split(/\n{2,}/).map(e=>e.trim()).filter(Boolean).join(`
|
|
3
3
|
|
|
4
|
-
`)}function k(t,n){let r=(e,t)=>!n&&Object.keys(e.attrs).length===0&&(t===0?e.tag===`p`:t===1&&e.tag===`br`),i=(e,t)=>e.some(e=>s(e)&&(!r(e,t)||i(e.children,t+1)));return i(e(t),0)}function A(e,t){return t?m(e.replace(/\s+/g,` `).trim()):e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${m(e).replace(/\n/g,`<br>`)}</p>`).join(``)}var j=[{namespace:_,locale:`en`,messages:{"help.title":`Help for students`,"help.hints":`Hints`,"help.hintsNote":`Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.`,"help.hintN":`Hint {n}`,"help.cost":`Cost (% of the points)`,"help.costN":`Hint {n}: cost (% of the points)`,"help.addHint":`Add a hint`,"help.up":`Up`,"help.down":`Down`,"help.upN":`Move hint {n} up`,"help.downN":`Move hint {n} down`,"help.removeN":`Remove hint {n}`,"help.drag":`Drag to reorder`,"help.explanationNote":`Students open it under "Why?" once their answer is checked. Leave it empty for none.`,"help.feedbackNote":`Shown after a check, by the verdict. Leave a text empty for none.`,"help.formatted":`This text has formatting. A change in this field keeps only the text.`}},{namespace:_,locale:`pl`,messages:{"help.title":`Pomoc dla ucznia`,"help.hints":`Podpowiedzi`,"help.hintsNote":`Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.`,"help.hintN":`Podpowiedź {n}`,"help.cost":`Koszt (% punktów)`,"help.costN":`Podpowiedź {n}: koszt (% punktów)`,"help.addHint":`Dodaj podpowiedź`,"help.up":`W górę`,"help.down":`W dół`,"help.upN":`Przenieś podpowiedź {n} w górę`,"help.downN":`Przenieś podpowiedź {n} w dół`,"help.removeN":`Usuń podpowiedź {n}`,"help.drag":`Przeciągnij, aby zmienić kolejność`,"help.explanationNote":`Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.`,"help.feedbackNote":`Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.`,"help.formatted":`Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.`}}],M=null,N=(e,t)=>e.descriptor(t)?.manifest.graded===!0;function P(e,t,n){let r=t.getSelection(),i=r===null?null:t.getElement(r.id);if(r===null||i===null||!N(e,r.tag)){let e=n===`feedback`?`<astl-feedback when="correct"><p></p></astl-feedback>`:`<astl-${n}><p></p></astl-${n}>`;return t.insert(e),e}let a=w(i),o,s;if(n===`hint`)o={...a,hints:[...a.hints,{html:``,cost:null}]},s=`hint-${a.hints.length}`;else if(n===`explanation`)o={...a,explanation:a.explanation??``},s=`explanation`;else{let e=F.find(e=>a.feedback[e]===void 0)??`correct`;o={...a,feedback:{...a.feedback,[e]:a.feedback[e]??``}},s=`feedback-${e}`}return M={element:r.id,field:s},t.replaceElement(r.id,E(i,o)),null}var F=[`correct`,`incorrect`,`omitted`,`partial`],I=e=>{if(e===null)return`0`;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?String(Math.round(t*100)):``},L=e=>e.target.value,R=class extends y{static properties={...y.properties,element:{},inline:{type:Boolean}};static styles=[v,r`
|
|
4
|
+
`)}function k(t,n){let r=(e,t)=>!n&&Object.keys(e.attrs).length===0&&(t===0?e.tag===`p`:t===1&&e.tag===`br`),i=(e,t)=>e.some(e=>s(e)&&(!r(e,t)||i(e.children,t+1)));return i(e(t),0)}function A(e,t){return t?m(e.replace(/\s+/g,` `).trim()):e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${m(e).replace(/\n/g,`<br>`)}</p>`).join(``)}var j=[{namespace:_,locale:`en`,messages:{"help.title":`Help for students`,"help.hints":`Hints`,"help.hintsNote":`Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.`,"help.hintN":`Hint {n}`,"help.cost":`Cost (% of the points)`,"help.costN":`Hint {n}: cost (% of the points)`,"help.addHint":`Add a hint`,"help.up":`Up`,"help.down":`Down`,"help.upN":`Move hint {n} up`,"help.downN":`Move hint {n} down`,"help.removeN":`Remove hint {n}`,"help.removeExplanation":`Remove the explanation`,"help.removeFeedback":`Remove the feedback: {when}`,"help.drag":`Drag to reorder`,"help.explanationNote":`Students open it under "Why?" once their answer is checked. Leave it empty for none.`,"help.feedbackNote":`Shown after a check, by the verdict. Leave a text empty for none.`,"help.formatted":`This text has formatting. A change in this field keeps only the text.`}},{namespace:_,locale:`pl`,messages:{"help.title":`Pomoc dla ucznia`,"help.hints":`Podpowiedzi`,"help.hintsNote":`Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.`,"help.hintN":`Podpowiedź {n}`,"help.cost":`Koszt (% punktów)`,"help.costN":`Podpowiedź {n}: koszt (% punktów)`,"help.addHint":`Dodaj podpowiedź`,"help.up":`W górę`,"help.down":`W dół`,"help.upN":`Przenieś podpowiedź {n} w górę`,"help.downN":`Przenieś podpowiedź {n} w dół`,"help.removeN":`Usuń podpowiedź {n}`,"help.removeExplanation":`Usuń wyjaśnienie`,"help.removeFeedback":`Usuń informację zwrotną: {when}`,"help.drag":`Przeciągnij, aby zmienić kolejność`,"help.explanationNote":`Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.`,"help.feedbackNote":`Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.`,"help.formatted":`Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.`}}],M=null,N=(e,t)=>e.descriptor(t)?.manifest.graded===!0;function P(e,t,n){let r=t.getSelection(),i=r===null?null:t.getElement(r.id);if(r===null||i===null||!N(e,r.tag)){let e=n===`feedback`?`<astl-feedback when="correct"><p></p></astl-feedback>`:`<astl-${n}><p></p></astl-${n}>`;return t.insert(e),e}let a=w(i),o,s;if(n===`hint`)o={...a,hints:[...a.hints,{html:``,cost:null}]},s=`hint-${a.hints.length}`;else if(n===`explanation`)o={...a,explanation:a.explanation??``},s=`explanation`;else{let e=F.find(e=>a.feedback[e]===void 0)??`correct`;o={...a,feedback:{...a.feedback,[e]:a.feedback[e]??``}},s=`feedback-${e}`}return M={element:r.id,field:s},t.replaceElement(r.id,E(i,o)),null}var F=[`correct`,`incorrect`,`omitted`,`partial`],I=e=>{if(e===null)return`0`;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?String(Math.round(t*100)):``},L=e=>e.target.value,R=class extends y{static properties={...y.properties,element:{},inline:{type:Boolean}};static styles=[v,r`
|
|
5
5
|
:host {
|
|
6
6
|
display: block;
|
|
7
7
|
}
|
|
@@ -126,18 +126,22 @@ color: var(--astl-danger);
|
|
|
126
126
|
<button type="button" class="delete" aria-label=${this.t(`help.removeN`,{n:i})}
|
|
127
127
|
@click=${()=>{this.#e.clear(),this.#r(e=>({...e,hints:e.hints.filter((e,t)=>t!==n)})),M={element:this.element??``,field:e.hints.length>1?`hint-${Math.max(0,n-1)}`:`add-hint`}}}>${this.t(`inspector.remove`)}</button>
|
|
128
128
|
</div>
|
|
129
|
-
</li>`}#u(e,n,r,i){let
|
|
129
|
+
</li>`}#u(e,n,r,i,o){let s=this.#a(e,i??``);return t`<div class="field">
|
|
130
130
|
<label for=${e}>${n}</label>
|
|
131
131
|
<textarea
|
|
132
132
|
id=${e}
|
|
133
133
|
data-help=${e}
|
|
134
134
|
dir="auto"
|
|
135
|
-
aria-describedby=${
|
|
136
|
-
.value=${b(this.#i(e,
|
|
137
|
-
@input=${t=>{let n=this.#o(e,t);
|
|
135
|
+
aria-describedby=${s===null?a:`${e}-formatted`}
|
|
136
|
+
.value=${b(this.#i(e,i??``))}
|
|
137
|
+
@input=${t=>{let n=this.#o(e,t);o(n===``?null:n)}}
|
|
138
138
|
@change=${()=>this.#s(e)}
|
|
139
139
|
></textarea>
|
|
140
|
-
${
|
|
140
|
+
${s??a}
|
|
141
|
+
${i==null?a:t`<div class="row">
|
|
142
|
+
<button type="button" class="delete" aria-label=${r}
|
|
143
|
+
@click=${()=>{this.#e.delete(e),M={element:this.element??``,field:e},o(null)}}>${this.t(`inspector.remove`)}</button>
|
|
144
|
+
</div>`}
|
|
141
145
|
</div>`}render(){let e=this.#n();if(e===null||this.authoring===null)return a;let{help:n}=e,{lang:r,dir:i}=this.ui;return t`<section class="kit" part="help" lang=${r} dir=${i} aria-labelledby="help-title">
|
|
142
146
|
<h3 id="help-title">${this.t(`help.title`)}</h3>
|
|
143
147
|
<fieldset aria-describedby="hints-note">
|
|
@@ -149,12 +153,12 @@ color: var(--astl-danger);
|
|
|
149
153
|
@click=${()=>{M={element:this.element??``,field:`hint-${n.hints.length}`},this.#r(e=>({...e,hints:[...e.hints,{html:``,cost:null}]}))}}>${this.t(`help.addHint`)}</button>
|
|
150
154
|
</div>
|
|
151
155
|
</fieldset>
|
|
152
|
-
${this.#u(`explanation`,this.t(`insert.explanation`),n.explanation,e=>this.#r(t=>({...t,explanation:e})))}
|
|
156
|
+
${this.#u(`explanation`,this.t(`insert.explanation`),this.t(`help.removeExplanation`),n.explanation,e=>this.#r(t=>({...t,explanation:e})))}
|
|
153
157
|
<p class="note">${this.t(`help.explanationNote`)}</p>
|
|
154
158
|
<fieldset aria-describedby="feedback-note">
|
|
155
159
|
<legend>${this.t(`insert.feedback`)}</legend>
|
|
156
160
|
<p class="note" id="feedback-note">${this.t(`help.feedbackNote`)}</p>
|
|
157
|
-
${o.map(e=>this.#u(`feedback-${e}`,this.t(`help.when.${e}`),n.feedback[e],t=>this.#r(n=>{let r={...n.feedback};return t===null?delete r[e]:r[e]=t,{...n,feedback:r}})))}
|
|
161
|
+
${o.map(e=>this.#u(`feedback-${e}`,this.t(`help.when.${e}`),this.t(`help.removeFeedback`,{when:this.t(`help.when.${e}`)}),n.feedback[e],t=>this.#r(n=>{let r={...n.feedback};return t===null?delete r[e]:r[e]=t,{...n,feedback:r}})))}
|
|
158
162
|
</fieldset>
|
|
159
163
|
</section>`}};export{R as AstlHelpForm,P as addHelp};
|
|
160
|
-
//# sourceMappingURL=help-form-
|
|
164
|
+
//# sourceMappingURL=help-form-Di2NtKDp.js.map
|