@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,2 +1,2 @@
|
|
|
1
|
-
import{H as e}from"./definitions-
|
|
2
|
-
//# sourceMappingURL=scan-
|
|
1
|
+
import{H as e}from"./definitions-BybSa1mq.js";import{St as t}from"./runtime-C25QK5B0.js";var n=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`noembed`,`noframes`,`noscript`]),r=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]),i=`astl-doc`;function a(e){return e===32||e===9||e===10||e===12||e===13}function o(e){return e>=65&&e<=90||e>=97&&e<=122}function s(e,t){if(e.startsWith(`<!-->`,t))return t+5;if(e.startsWith(`<!--->`,t))return t+6;let n=[e.indexOf(`-->`,t+4),e.indexOf(`--!>`,t+4)].filter(e=>e>=0);if(n.length===0)return e.length;let r=Math.min(...n);return r+(e.startsWith(`-->`,r)?3:4)}function c(e,t){let n=e.indexOf(`>`,t);return n<0?e.length:n+1}function l(e,t,n){let r=RegExp(`</${n}(?=[\\t\\n\\f\\r />])`,`gi`);return r.lastIndex=t,r.exec(e)?.index??e.length}function u(e,t,n){let r=e.length,i=t+(n===`end`?2:1),o=i;for(;i<r;){let t=e.charCodeAt(i);if(a(t)||t===47||t===62)break;i++}let s=e.slice(o,i).toLowerCase(),c=[],l=(e,r)=>({type:n,name:s,start:t,end:e,attributes:c,selfClosing:r});for(;i<r;){let t=e.charCodeAt(i);if(a(t)){i++;continue}if(t===62)return l(i+1,!1);if(t===47){if(e.charCodeAt(i+1)===62)return l(i+2,!0);i++;continue}let n=i;for(i++;i<r;){let t=e.charCodeAt(i);if(a(t)||t===47||t===62||t===61)break;i++}let o=e.slice(n,i).toLowerCase(),s=i;for(;s<r&&a(e.charCodeAt(s));)s++;if(e.charCodeAt(s)!==61){c.push({name:o,raw:null,start:n,end:i});continue}for(s++;s<r&&a(e.charCodeAt(s));)s++;let u=e[s];if(u===`"`||u===`'`){let t=e.indexOf(u,s+1),a=t<0?r:t+1;c.push({name:o,raw:e.slice(s+1,t<0?r:t),start:n,end:a}),i=a}else{let t=s;for(;t<r&&!a(e.charCodeAt(t))&&e.charCodeAt(t)!==62;)t++;c.push({name:o,raw:e.slice(s,t),start:n,end:t}),i=t}}return l(r,!1)}function d(e){let t=[],r=e.length,i=0;for(;i<r;){let a=e.indexOf(`<`,i);if(a<0)break;i=a;let d=e.charCodeAt(i+1);if(e.startsWith(`<!--`,i))i=s(e,i);else if(d===33||d===63)i=c(e,i+2);else if(d===47){let n=e.charCodeAt(i+2);if(o(n)){let n=u(e,i,`end`);t.push(n),i=n.end}else i=n===62?i+3:c(e,i+2)}else if(o(d)){let a=u(e,i,`start`);t.push(a),i=a.end,n.has(a.name)?i=l(e,i,a.name):a.name===`plaintext`&&(i=r)}else i++}return t}function f(e){return e.includes(`-`)}function p(e){let t=[],n=[],i=e=>(n[n.length-1]?.children??t).push(e),a=(e,t,n)=>i({name:e.name,start:e.start,end:t,startTag:e.startTag,endTag:n,children:e.children});for(let t of d(e)){if(t.type===`start`){r.has(t.name)||t.selfClosing&&f(t.name)?i({name:t.name,start:t.start,end:t.end,startTag:t,endTag:null,children:[]}):n.push({name:t.name,start:t.start,startTag:t,children:[]});continue}let e=n.length-1;for(;e>=0&&n[e]?.name!==t.name;)e--;if(!(e<0)){for(;n.length-1>e;)a(n.pop(),t.start,null);a(n.pop(),t.end,t)}}for(;n.length>0;)a(n.pop(),e.length,null);return t}function m(t){if(!t.includes(`&`))return t;let[n]=e(`<b title="${t.replaceAll(`"`,`"`)}"></b>`);return n?.type===`element`?n.attrs.title??t:t}function h(e,t){let n=e.attributes.find(e=>e.name===t);return n===void 0?null:n.raw===null?``:m(n.raw)}function g(e){let n=[],r=e=>{for(let a of e){let{name:e}=a;if(e===`astl-style`||e===`astl-columns`||e===`astl-column`||t.has(e))r(a.children);else{if(e===`astl-page`||f(e)&&e!==i){let t=h(a.startTag,`id`);if(n.push({tag:e,id:t,start:a.start,end:a.end,range:a}),e!==`astl-page`)continue}r(a.children)}}};return r(p(e)),n}function _(e){return g(e).map(({tag:e,id:t,start:n,end:r})=>({tag:e,id:t,start:n,end:r}))}function v(e){let t=new Set;for(let n of d(e)){if(n.type!==`start`)continue;let e=h(n,`id`);e!==null&&t.add(e)}return t}var y=String.fromCodePoint(160),b=RegExp(`[&<>${y}]`,`g`),x=RegExp(`[&"<>${y}]`,`g`),S=RegExp(`[&<>"'${y}]`,`g`),C={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,[y]:` `},w=e=>C[e]??e;function T(e){return e.replace(b,w)}function E(e){return e.replace(x,w)}function D(e){return e.replace(S,w)}function O(e,t){let n=e;for(let e of[...t].sort((e,t)=>t.start-e.start))n=n.slice(0,e.start)+e.text+n.slice(e.end);return n}function k(e,t){let n=t;for(;n>0&&a(e.charCodeAt(n-1));)n--;return n}export{D as a,g as c,v as d,E as i,k as l,h as n,T as o,p as r,_ as s,O as t,d as u};
|
|
2
|
+
//# sourceMappingURL=scan-BVhxT2Hw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-jWgPnVxA.js","names":["parseHtml","HELP_TAGS","RAW_TEXT","VOID","DOC_TAG","isSpace","code","isAsciiLetter","commentEnd","source","at","ends","i","end","afterNextGt","gt","from","rawTextEnd","re","name","readTag","n","start","type","nameStart","c","attributes","done","attrStart","d","attrName","j","quote","close","k","tokenize","out","lt","next","tag","isCustom","elementTree","roots","stack","add","range","open","index","decodeAttribute","raw","node","attributeValue","attribute","a","scanRanges","walk","ranges","id","scanElements","usedIds","ids","NBSP","TEXT_SPECIALS","ATTRIBUTE_SPECIALS","HTML_SPECIALS","ENTITIES","entity","ch","escapeText","value","escapeAttribute","escapeHtml","applyEdits","edit","edits","b","spaceBefore"],"sources":["../../../../editor/src/scan.ts"],"sourcesContent":["/**\n * A small, tolerant HTML tokenizer for text-based editing. It only locates tags (with exact source offsets), so edits\n * can splice the source and leave everything else byte-identical. Reading values the way a browser would (entities,\n * tree construction) is the engine's `parseHtml`.\n */\nimport { COLUMN_TAG, COLUMNS_TAG, HELP_TAGS, PAGE_TAG, STYLE_TAG } from '@astl/core';\nimport { parseHtml } from '@astl/engine';\n\nexport interface AttributeToken {\n /** Lowercase name. */\n readonly name: string;\n /** Value as written (entities not decoded); null for a bare attribute. */\n readonly raw: string | null;\n /** Offset of the name. */\n readonly start: number;\n /** Offset after the value (after the closing quote), or after the name of a bare attribute. */\n readonly end: number;\n}\n\nexport interface TagToken {\n readonly type: 'start' | 'end';\n /** Lowercase name. */\n readonly name: string;\n /** Offset of `<`. */\n readonly start: number;\n /** Offset after `>`, or the end of the source for an unterminated tag. */\n readonly end: number;\n readonly attributes: readonly AttributeToken[];\n /** Written as `<name ... />`. */\n readonly selfClosing: boolean;\n}\n\n/** An element located in the source. `end` is after its end tag, or where it was implicitly closed. */\nexport interface ElementRange {\n readonly name: string;\n readonly start: number;\n readonly end: number;\n readonly startTag: TagToken;\n readonly endTag: TagToken | null;\n readonly children: readonly ElementRange[];\n}\n\n/** A page or a component found by `scanElements`. Offsets index into the scanned string. */\nexport interface ScannedElement {\n readonly tag: string;\n /** The `id` attribute (entities decoded), or null when absent. */\n readonly id: string | null;\n readonly start: number;\n readonly end: number;\n}\n\n/** Elements whose content the HTML parser reads as raw text: tags inside them are not tags. */\nconst RAW_TEXT: ReadonlySet<string> = new Set([\n 'script',\n 'style',\n 'textarea',\n 'title',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'noscript',\n]);\n\nconst VOID: ReadonlySet<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nconst DOC_TAG = 'astl-doc';\n\nfunction isSpace(code: number): boolean {\n return code === 32 || code === 9 || code === 10 || code === 12 || code === 13;\n}\n\nfunction isAsciiLetter(code: number): boolean {\n return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n}\n\n/** Offset after a comment that starts at `at` (`<!--`). */\nfunction commentEnd(source: string, at: number): number {\n if (source.startsWith('<!-->', at)) return at + 5;\n if (source.startsWith('<!--->', at)) return at + 6;\n const ends = [source.indexOf('-->', at + 4), source.indexOf('--!>', at + 4)].filter((i) => i >= 0);\n if (ends.length === 0) return source.length;\n const end = Math.min(...ends);\n return end + (source.startsWith('-->', end) ? 3 : 4);\n}\n\n/** Offset after the next `>` (bogus comments, doctypes), or the end. */\nfunction afterNextGt(source: string, from: number): number {\n const gt = source.indexOf('>', from);\n return gt < 0 ? source.length : gt + 1;\n}\n\n/** Offset of the end tag that closes a raw text element, or the end of the source. */\nfunction rawTextEnd(source: string, from: number, name: string): number {\n const re = new RegExp(`</${name}(?=[\\\\t\\\\n\\\\f\\\\r />])`, 'gi');\n re.lastIndex = from;\n return re.exec(source)?.index ?? source.length;\n}\n\nfunction readTag(source: string, start: number, type: 'start' | 'end'): TagToken {\n const n = source.length;\n let i = start + (type === 'end' ? 2 : 1);\n const nameStart = i;\n while (i < n) {\n const c = source.charCodeAt(i);\n if (isSpace(c) || c === 47 /* / */ || c === 62 /* > */) break;\n i++;\n }\n const name = source.slice(nameStart, i).toLowerCase();\n const attributes: AttributeToken[] = [];\n const done = (end: number, selfClosing: boolean): TagToken => ({\n type,\n name,\n start,\n end,\n attributes,\n selfClosing,\n });\n while (i < n) {\n const c = source.charCodeAt(i);\n if (isSpace(c)) {\n i++;\n continue;\n }\n if (c === 62) return done(i + 1, false);\n if (c === 47) {\n if (source.charCodeAt(i + 1) === 62) return done(i + 2, true);\n i++;\n continue;\n }\n // Attribute name: up to space, `/`, `>` or `=` (a leading `=` belongs to the name, as in the HTML tokenizer).\n const attrStart = i;\n i++;\n while (i < n) {\n const d = source.charCodeAt(i);\n if (isSpace(d) || d === 47 || d === 62 || d === 61 /* = */) break;\n i++;\n }\n const attrName = source.slice(attrStart, i).toLowerCase();\n let j = i;\n while (j < n && isSpace(source.charCodeAt(j))) j++;\n if (source.charCodeAt(j) !== 61) {\n attributes.push({ name: attrName, raw: null, start: attrStart, end: i });\n continue;\n }\n j++;\n while (j < n && isSpace(source.charCodeAt(j))) j++;\n const quote = source[j];\n if (quote === '\"' || quote === \"'\") {\n const close = source.indexOf(quote, j + 1);\n const end = close < 0 ? n : close + 1;\n attributes.push({\n name: attrName,\n raw: source.slice(j + 1, close < 0 ? n : close),\n start: attrStart,\n end,\n });\n i = end;\n } else {\n let k = j;\n while (k < n && !isSpace(source.charCodeAt(k)) && source.charCodeAt(k) !== 62) k++;\n attributes.push({ name: attrName, raw: source.slice(j, k), start: attrStart, end: k });\n i = k;\n }\n }\n return done(n, false);\n}\n\n/**\n * Start and end tags in source order. Comments, doctypes and bogus comments are skipped, and so is the content of raw\n * text elements (`script`, `style`, `textarea`, ...). A `<` that does not start a tag is text.\n */\nexport function tokenize(source: string): TagToken[] {\n const out: TagToken[] = [];\n const n = source.length;\n let i = 0;\n while (i < n) {\n const lt = source.indexOf('<', i);\n if (lt < 0) break;\n i = lt;\n const next = source.charCodeAt(i + 1);\n if (source.startsWith('<!--', i)) {\n i = commentEnd(source, i);\n } else if (next === 33 /* ! */ || next === 63 /* ? */) {\n i = afterNextGt(source, i + 2);\n } else if (next === 47 /* / */) {\n const c = source.charCodeAt(i + 2);\n if (isAsciiLetter(c)) {\n const tag = readTag(source, i, 'end');\n out.push(tag);\n i = tag.end;\n } else {\n i = c === 62 ? i + 3 : afterNextGt(source, i + 2);\n }\n } else if (isAsciiLetter(next)) {\n const tag = readTag(source, i, 'start');\n out.push(tag);\n i = tag.end;\n if (RAW_TEXT.has(tag.name)) i = rawTextEnd(source, i, tag.name);\n else if (tag.name === 'plaintext') i = n;\n } else {\n i++;\n }\n }\n return out;\n}\n\ninterface OpenElement {\n readonly name: string;\n readonly start: number;\n readonly startTag: TagToken;\n readonly children: ElementRange[];\n}\n\nfunction isCustom(name: string): boolean {\n return name.includes('-');\n}\n\n/**\n * The element tree of `source` with offsets. Tolerant: an end tag closes the nearest open element of its name (and\n * everything opened inside it); stray end tags are ignored; elements still open at the end close there. Custom\n * elements written `<x-y ... />` count as closed (the author's intent; HTML would leave them open).\n */\nexport function elementTree(source: string): ElementRange[] {\n const roots: ElementRange[] = [];\n const stack: OpenElement[] = [];\n const add = (range: ElementRange) => (stack[stack.length - 1]?.children ?? roots).push(range);\n const close = (open: OpenElement, end: number, endTag: TagToken | null) =>\n add({\n name: open.name,\n start: open.start,\n end,\n startTag: open.startTag,\n endTag,\n children: open.children,\n });\n for (const tag of tokenize(source)) {\n if (tag.type === 'start') {\n if (VOID.has(tag.name) || (tag.selfClosing && isCustom(tag.name))) {\n add({ name: tag.name, start: tag.start, end: tag.end, startTag: tag, endTag: null, children: [] });\n } else {\n stack.push({ name: tag.name, start: tag.start, startTag: tag, children: [] });\n }\n continue;\n }\n let index = stack.length - 1;\n while (index >= 0 && stack[index]?.name !== tag.name) index--;\n if (index < 0) continue;\n while (stack.length - 1 > index) close(stack.pop() as OpenElement, tag.start, null);\n close(stack.pop() as OpenElement, tag.end, tag);\n }\n while (stack.length > 0) close(stack.pop() as OpenElement, source.length, null);\n return roots;\n}\n\n/** Decodes entities in an attribute value, exactly as the HTML parser does. */\nexport function decodeAttribute(raw: string): string {\n if (!raw.includes('&')) return raw;\n const [node] = parseHtml(`<b title=\"${raw.replaceAll('\"', '"')}\"></b>`);\n return node?.type === 'element' ? (node.attrs.title ?? raw) : raw;\n}\n\n/** Decoded value of the first attribute called `name`; '' for a bare attribute, null when absent. */\nexport function attributeValue(tag: TagToken, name: string): string | null {\n const attribute = tag.attributes.find((a) => a.name === name);\n if (attribute === undefined) return null;\n return attribute.raw === null ? '' : decodeAttribute(attribute.raw);\n}\n\nexport interface ScannedElementRange extends ScannedElement {\n readonly range: ElementRange;\n}\n\n/** Pages and components with their ranges (internal form of `scanElements`). */\nexport function scanRanges(source: string): ScannedElementRange[] {\n const out: ScannedElementRange[] = [];\n const walk = (ranges: readonly ElementRange[]) => {\n for (const range of ranges) {\n const { name } = range;\n // Neither a named style nor a layout is a component; what a layout holds is on its page, and so is what follows\n // a self-closed named style, which HTML reads as its content.\n // Nor is help for students on a page: what it holds (a component, wrongly) is on the page too.\n if (name === STYLE_TAG || name === COLUMNS_TAG || name === COLUMN_TAG || HELP_TAGS.has(name)) {\n walk(range.children);\n continue;\n }\n if (name === PAGE_TAG || (isCustom(name) && name !== DOC_TAG)) {\n const id = attributeValue(range.startTag, 'id');\n out.push({ tag: name, id, start: range.start, end: range.end, range });\n // Components do not nest: custom elements inside one are its children (options, alternatives).\n if (name !== PAGE_TAG) continue;\n }\n walk(range.children);\n }\n };\n walk(elementTree(source));\n return out;\n}\n\n/**\n * Pages (`astl-page`) and components in document order, with offsets into `source`, for text-based adapters. An\n * component is any custom element outside another component (so a misspelt tag is found too), but for the tags of the\n * format: a layout's are looked through, named styles are skipped; custom elements inside a component are its children.\n * Tolerant of messy input: comments, quoted `>` in attributes, any case, unclosed or self-closed elements.\n */\nexport function scanElements(source: string): ScannedElement[] {\n return scanRanges(source).map(({ tag, id, start, end }) => ({ tag, id, start, end }));\n}\n\n/** Every `id` attribute value in the source (pages, components and local child ids). */\nexport function usedIds(source: string): Set<string> {\n const ids = new Set<string>();\n for (const tag of tokenize(source)) {\n if (tag.type !== 'start') continue;\n const id = attributeValue(tag, 'id');\n if (id !== null) ids.add(id);\n }\n return ids;\n}\n\nconst NBSP = String.fromCodePoint(0xa0);\nconst TEXT_SPECIALS = new RegExp(`[&<>${NBSP}]`, 'g');\nconst ATTRIBUTE_SPECIALS = new RegExp(`[&\"<>${NBSP}]`, 'g');\nconst HTML_SPECIALS = new RegExp(`[&<>\"'${NBSP}]`, 'g');\nconst ENTITIES: Readonly<Record<string, string>> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n [NBSP]: ' ',\n};\nconst entity = (ch: string) => ENTITIES[ch] ?? ch;\n\nexport function escapeText(value: string): string {\n return value.replace(TEXT_SPECIALS, entity);\n}\n\nexport function escapeAttribute(value: string): string {\n return value.replace(ATTRIBUTE_SPECIALS, entity);\n}\n\n/** Safe in text and in quoted attribute values. */\nexport function escapeHtml(value: string): string {\n return value.replace(HTML_SPECIALS, entity);\n}\n\nexport interface Edit {\n readonly start: number;\n readonly end: number;\n readonly text: string;\n}\n\n/** Applies non-overlapping edits. */\nexport function applyEdits(source: string, edits: readonly Edit[]): string {\n let out = source;\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n }\n return out;\n}\n\n/** Start of the whitespace run that ends at `at` (or `at` itself). */\nexport function spaceBefore(source: string, at: number): number {\n let i = at;\n while (i > 0 && isSpace(source.charCodeAt(i - 1))) i--;\n return i;\n}\n"],"mappings":"A,yFAoDA,IAAME,EAAgC,IAAI,IAAI,CAC5C,SACA,QACA,WACA,QACA,MACA,SACA,UACA,WACA,UACF,CAAC,EAEKC,EAA4B,IAAI,IAAI,CACxC,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,SACA,QACA,KACF,CAAC,EAEKC,EAAU,WAEhB,SAASC,EAAQ,EAAuB,CACtC,OAAOC,IAAS,IAAMA,IAAS,GAAKA,IAAS,IAAMA,IAAS,IAAMA,IAAS,EAC7E,CAEA,SAASC,EAAc,EAAuB,CAC5C,OAAQD,GAAQ,IAAMA,GAAQ,IAAQA,GAAQ,IAAMA,GAAQ,GAC9D,CAGA,SAASE,EAAW,EAAgB,EAAoB,CACtD,GAAIC,EAAO,WAAW,QAASC,CAAE,EAAG,OAAOA,EAAK,EACh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I,GAAG,EAChDI,EAA6C,CACjD,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,SACJJ,GAAO,QACV,EACMK,EAAU,GAAeD,EAASE,IAAOA,EAE/C,SAAgBC,EAAW,EAAuB,CAChD,OAAOC,EAAM,QAAQP,EAAeI,CAAM,CAC5C,CAEA,SAAgBI,EAAgB,EAAuB,CACrD,OAAOD,EAAM,QAAQN,EAAoBG,CAAM,CACjD,CAGA,SAAgBK,EAAW,EAAuB,CAChD,OAAOF,EAAM,QAAQL,EAAeE,CAAM,CAC5C,CASA,SAAgBM,EAAW,EAAgB,EAAgC,CACzE,IAAIpC,EAAM3B,EACV,IAAK,IAAMgE,IAAQ,CAAC,GAAGC,CAAK,CAAC,CAAC,MAAM,EAAG,IAAMC,EAAE,MAAQtB,EAAE,KAAK,EAC5D,EAAMjB,EAAI,MAAM,EAAGqC,EAAK,KAAK,EAAIA,EAAK,KAAOrC,EAAI,MAAMqC,EAAK,GAAG,EAEjE,OAAOrC,CACT,CAGA,SAAgBwC,EAAY,EAAgB,EAAoB,CAC9D,IAAIhE,EAAIF,EACR,KAAOE,EAAI,GAAKP,EAAQI,EAAO,WAAWG,EAAI,CAAC,CAAC,GAAG,IACnD,OAAOA,CACT,C"}
|
|
1
|
+
{"version":3,"file":"scan-BVhxT2Hw.js","names":["parseHtml","HELP_TAGS","RAW_TEXT","VOID","DOC_TAG","isSpace","code","isAsciiLetter","commentEnd","source","at","ends","i","end","afterNextGt","gt","from","rawTextEnd","re","name","readTag","n","start","type","nameStart","c","attributes","done","attrStart","d","attrName","j","quote","close","k","tokenize","out","lt","next","tag","isCustom","elementTree","roots","stack","add","range","open","index","decodeAttribute","raw","node","attributeValue","attribute","a","scanRanges","walk","ranges","id","scanElements","usedIds","ids","NBSP","TEXT_SPECIALS","ATTRIBUTE_SPECIALS","HTML_SPECIALS","ENTITIES","entity","ch","escapeText","value","escapeAttribute","escapeHtml","applyEdits","edit","edits","b","spaceBefore"],"sources":["../../../../editor/src/scan.ts"],"sourcesContent":["/**\n * A small, tolerant HTML tokenizer for text-based editing. It only locates tags (with exact source offsets), so edits\n * can splice the source and leave everything else byte-identical. Reading values the way a browser would (entities,\n * tree construction) is the engine's `parseHtml`.\n */\nimport { COLUMN_TAG, COLUMNS_TAG, HELP_TAGS, PAGE_TAG, STYLE_TAG } from '@astl/core';\nimport { parseHtml } from '@astl/engine';\n\nexport interface AttributeToken {\n /** Lowercase name. */\n readonly name: string;\n /** Value as written (entities not decoded); null for a bare attribute. */\n readonly raw: string | null;\n /** Offset of the name. */\n readonly start: number;\n /** Offset after the value (after the closing quote), or after the name of a bare attribute. */\n readonly end: number;\n}\n\nexport interface TagToken {\n readonly type: 'start' | 'end';\n /** Lowercase name. */\n readonly name: string;\n /** Offset of `<`. */\n readonly start: number;\n /** Offset after `>`, or the end of the source for an unterminated tag. */\n readonly end: number;\n readonly attributes: readonly AttributeToken[];\n /** Written as `<name ... />`. */\n readonly selfClosing: boolean;\n}\n\n/** An element located in the source. `end` is after its end tag, or where it was implicitly closed. */\nexport interface ElementRange {\n readonly name: string;\n readonly start: number;\n readonly end: number;\n readonly startTag: TagToken;\n readonly endTag: TagToken | null;\n readonly children: readonly ElementRange[];\n}\n\n/** A page or a component found by `scanElements`. Offsets index into the scanned string. */\nexport interface ScannedElement {\n readonly tag: string;\n /** The `id` attribute (entities decoded), or null when absent. */\n readonly id: string | null;\n readonly start: number;\n readonly end: number;\n}\n\n/** Elements whose content the HTML parser reads as raw text: tags inside them are not tags. */\nconst RAW_TEXT: ReadonlySet<string> = new Set([\n 'script',\n 'style',\n 'textarea',\n 'title',\n 'xmp',\n 'iframe',\n 'noembed',\n 'noframes',\n 'noscript',\n]);\n\nconst VOID: ReadonlySet<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nconst DOC_TAG = 'astl-doc';\n\nfunction isSpace(code: number): boolean {\n return code === 32 || code === 9 || code === 10 || code === 12 || code === 13;\n}\n\nfunction isAsciiLetter(code: number): boolean {\n return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n}\n\n/** Offset after a comment that starts at `at` (`<!--`). */\nfunction commentEnd(source: string, at: number): number {\n if (source.startsWith('<!-->', at)) return at + 5;\n if (source.startsWith('<!--->', at)) return at + 6;\n const ends = [source.indexOf('-->', at + 4), source.indexOf('--!>', at + 4)].filter((i) => i >= 0);\n if (ends.length === 0) return source.length;\n const end = Math.min(...ends);\n return end + (source.startsWith('-->', end) ? 3 : 4);\n}\n\n/** Offset after the next `>` (bogus comments, doctypes), or the end. */\nfunction afterNextGt(source: string, from: number): number {\n const gt = source.indexOf('>', from);\n return gt < 0 ? source.length : gt + 1;\n}\n\n/** Offset of the end tag that closes a raw text element, or the end of the source. */\nfunction rawTextEnd(source: string, from: number, name: string): number {\n const re = new RegExp(`</${name}(?=[\\\\t\\\\n\\\\f\\\\r />])`, 'gi');\n re.lastIndex = from;\n return re.exec(source)?.index ?? source.length;\n}\n\nfunction readTag(source: string, start: number, type: 'start' | 'end'): TagToken {\n const n = source.length;\n let i = start + (type === 'end' ? 2 : 1);\n const nameStart = i;\n while (i < n) {\n const c = source.charCodeAt(i);\n if (isSpace(c) || c === 47 /* / */ || c === 62 /* > */) break;\n i++;\n }\n const name = source.slice(nameStart, i).toLowerCase();\n const attributes: AttributeToken[] = [];\n const done = (end: number, selfClosing: boolean): TagToken => ({\n type,\n name,\n start,\n end,\n attributes,\n selfClosing,\n });\n while (i < n) {\n const c = source.charCodeAt(i);\n if (isSpace(c)) {\n i++;\n continue;\n }\n if (c === 62) return done(i + 1, false);\n if (c === 47) {\n if (source.charCodeAt(i + 1) === 62) return done(i + 2, true);\n i++;\n continue;\n }\n // Attribute name: up to space, `/`, `>` or `=` (a leading `=` belongs to the name, as in the HTML tokenizer).\n const attrStart = i;\n i++;\n while (i < n) {\n const d = source.charCodeAt(i);\n if (isSpace(d) || d === 47 || d === 62 || d === 61 /* = */) break;\n i++;\n }\n const attrName = source.slice(attrStart, i).toLowerCase();\n let j = i;\n while (j < n && isSpace(source.charCodeAt(j))) j++;\n if (source.charCodeAt(j) !== 61) {\n attributes.push({ name: attrName, raw: null, start: attrStart, end: i });\n continue;\n }\n j++;\n while (j < n && isSpace(source.charCodeAt(j))) j++;\n const quote = source[j];\n if (quote === '\"' || quote === \"'\") {\n const close = source.indexOf(quote, j + 1);\n const end = close < 0 ? n : close + 1;\n attributes.push({\n name: attrName,\n raw: source.slice(j + 1, close < 0 ? n : close),\n start: attrStart,\n end,\n });\n i = end;\n } else {\n let k = j;\n while (k < n && !isSpace(source.charCodeAt(k)) && source.charCodeAt(k) !== 62) k++;\n attributes.push({ name: attrName, raw: source.slice(j, k), start: attrStart, end: k });\n i = k;\n }\n }\n return done(n, false);\n}\n\n/**\n * Start and end tags in source order. Comments, doctypes and bogus comments are skipped, and so is the content of raw\n * text elements (`script`, `style`, `textarea`, ...). A `<` that does not start a tag is text.\n */\nexport function tokenize(source: string): TagToken[] {\n const out: TagToken[] = [];\n const n = source.length;\n let i = 0;\n while (i < n) {\n const lt = source.indexOf('<', i);\n if (lt < 0) break;\n i = lt;\n const next = source.charCodeAt(i + 1);\n if (source.startsWith('<!--', i)) {\n i = commentEnd(source, i);\n } else if (next === 33 /* ! */ || next === 63 /* ? */) {\n i = afterNextGt(source, i + 2);\n } else if (next === 47 /* / */) {\n const c = source.charCodeAt(i + 2);\n if (isAsciiLetter(c)) {\n const tag = readTag(source, i, 'end');\n out.push(tag);\n i = tag.end;\n } else {\n i = c === 62 ? i + 3 : afterNextGt(source, i + 2);\n }\n } else if (isAsciiLetter(next)) {\n const tag = readTag(source, i, 'start');\n out.push(tag);\n i = tag.end;\n if (RAW_TEXT.has(tag.name)) i = rawTextEnd(source, i, tag.name);\n else if (tag.name === 'plaintext') i = n;\n } else {\n i++;\n }\n }\n return out;\n}\n\ninterface OpenElement {\n readonly name: string;\n readonly start: number;\n readonly startTag: TagToken;\n readonly children: ElementRange[];\n}\n\nfunction isCustom(name: string): boolean {\n return name.includes('-');\n}\n\n/**\n * The element tree of `source` with offsets. Tolerant: an end tag closes the nearest open element of its name (and\n * everything opened inside it); stray end tags are ignored; elements still open at the end close there. Custom\n * elements written `<x-y ... />` count as closed (the author's intent; HTML would leave them open).\n */\nexport function elementTree(source: string): ElementRange[] {\n const roots: ElementRange[] = [];\n const stack: OpenElement[] = [];\n const add = (range: ElementRange) => (stack[stack.length - 1]?.children ?? roots).push(range);\n const close = (open: OpenElement, end: number, endTag: TagToken | null) =>\n add({\n name: open.name,\n start: open.start,\n end,\n startTag: open.startTag,\n endTag,\n children: open.children,\n });\n for (const tag of tokenize(source)) {\n if (tag.type === 'start') {\n if (VOID.has(tag.name) || (tag.selfClosing && isCustom(tag.name))) {\n add({ name: tag.name, start: tag.start, end: tag.end, startTag: tag, endTag: null, children: [] });\n } else {\n stack.push({ name: tag.name, start: tag.start, startTag: tag, children: [] });\n }\n continue;\n }\n let index = stack.length - 1;\n while (index >= 0 && stack[index]?.name !== tag.name) index--;\n if (index < 0) continue;\n while (stack.length - 1 > index) close(stack.pop() as OpenElement, tag.start, null);\n close(stack.pop() as OpenElement, tag.end, tag);\n }\n while (stack.length > 0) close(stack.pop() as OpenElement, source.length, null);\n return roots;\n}\n\n/** Decodes entities in an attribute value, exactly as the HTML parser does. */\nexport function decodeAttribute(raw: string): string {\n if (!raw.includes('&')) return raw;\n const [node] = parseHtml(`<b title=\"${raw.replaceAll('\"', '"')}\"></b>`);\n return node?.type === 'element' ? (node.attrs.title ?? raw) : raw;\n}\n\n/** Decoded value of the first attribute called `name`; '' for a bare attribute, null when absent. */\nexport function attributeValue(tag: TagToken, name: string): string | null {\n const attribute = tag.attributes.find((a) => a.name === name);\n if (attribute === undefined) return null;\n return attribute.raw === null ? '' : decodeAttribute(attribute.raw);\n}\n\nexport interface ScannedElementRange extends ScannedElement {\n readonly range: ElementRange;\n}\n\n/** Pages and components with their ranges (internal form of `scanElements`). */\nexport function scanRanges(source: string): ScannedElementRange[] {\n const out: ScannedElementRange[] = [];\n const walk = (ranges: readonly ElementRange[]) => {\n for (const range of ranges) {\n const { name } = range;\n // Neither a named style nor a layout is a component; what a layout holds is on its page, and so is what follows\n // a self-closed named style, which HTML reads as its content.\n // Nor is help for students on a page: what it holds (a component, wrongly) is on the page too.\n if (name === STYLE_TAG || name === COLUMNS_TAG || name === COLUMN_TAG || HELP_TAGS.has(name)) {\n walk(range.children);\n continue;\n }\n if (name === PAGE_TAG || (isCustom(name) && name !== DOC_TAG)) {\n const id = attributeValue(range.startTag, 'id');\n out.push({ tag: name, id, start: range.start, end: range.end, range });\n // Components do not nest: custom elements inside one are its children (options, alternatives).\n if (name !== PAGE_TAG) continue;\n }\n walk(range.children);\n }\n };\n walk(elementTree(source));\n return out;\n}\n\n/**\n * Pages (`astl-page`) and components in document order, with offsets into `source`, for text-based adapters. An\n * component is any custom element outside another component (so a misspelt tag is found too), but for the tags of the\n * format: a layout's are looked through, named styles are skipped; custom elements inside a component are its children.\n * Tolerant of messy input: comments, quoted `>` in attributes, any case, unclosed or self-closed elements.\n */\nexport function scanElements(source: string): ScannedElement[] {\n return scanRanges(source).map(({ tag, id, start, end }) => ({ tag, id, start, end }));\n}\n\n/** Every `id` attribute value in the source (pages, components and local child ids). */\nexport function usedIds(source: string): Set<string> {\n const ids = new Set<string>();\n for (const tag of tokenize(source)) {\n if (tag.type !== 'start') continue;\n const id = attributeValue(tag, 'id');\n if (id !== null) ids.add(id);\n }\n return ids;\n}\n\nconst NBSP = String.fromCodePoint(0xa0);\nconst TEXT_SPECIALS = new RegExp(`[&<>${NBSP}]`, 'g');\nconst ATTRIBUTE_SPECIALS = new RegExp(`[&\"<>${NBSP}]`, 'g');\nconst HTML_SPECIALS = new RegExp(`[&<>\"'${NBSP}]`, 'g');\nconst ENTITIES: Readonly<Record<string, string>> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n [NBSP]: ' ',\n};\nconst entity = (ch: string) => ENTITIES[ch] ?? ch;\n\nexport function escapeText(value: string): string {\n return value.replace(TEXT_SPECIALS, entity);\n}\n\nexport function escapeAttribute(value: string): string {\n return value.replace(ATTRIBUTE_SPECIALS, entity);\n}\n\n/** Safe in text and in quoted attribute values. */\nexport function escapeHtml(value: string): string {\n return value.replace(HTML_SPECIALS, entity);\n}\n\nexport interface Edit {\n readonly start: number;\n readonly end: number;\n readonly text: string;\n}\n\n/** Applies non-overlapping edits. */\nexport function applyEdits(source: string, edits: readonly Edit[]): string {\n let out = source;\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);\n }\n return out;\n}\n\n/** Start of the whitespace run that ends at `at` (or `at` itself). */\nexport function spaceBefore(source: string, at: number): number {\n let i = at;\n while (i > 0 && isSpace(source.charCodeAt(i - 1))) i--;\n return i;\n}\n"],"mappings":"A,yFAoDA,IAAME,EAAgC,IAAI,IAAI,CAC5C,SACA,QACA,WACA,QACA,MACA,SACA,UACA,WACA,UACF,CAAC,EAEKC,EAA4B,IAAI,IAAI,CACxC,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,SACA,QACA,KACF,CAAC,EAEKC,EAAU,WAEhB,SAASC,EAAQ,EAAuB,CACtC,OAAOC,IAAS,IAAMA,IAAS,GAAKA,IAAS,IAAMA,IAAS,IAAMA,IAAS,EAC7E,CAEA,SAASC,EAAc,EAAuB,CAC5C,OAAQD,GAAQ,IAAMA,GAAQ,IAAQA,GAAQ,IAAMA,GAAQ,GAC9D,CAGA,SAASE,EAAW,EAAgB,EAAoB,CACtD,GAAIC,EAAO,WAAW,QAASC,CAAE,EAAG,OAAOA,EAAK,EAChD,GAAID,EAAO,WAAW,SAAUC,CAAE,EAAG,OAAOA,EAAK,EACjD,IAAMC,EAAO,CAACF,EAAO,QAAQ,MAAOC,EAAK,CAAC,EAAGD,EAAO,QAAQ,OA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C,SAAgBC,EAAW,EAAuB,CAChD,OAAOC,EAAM,QAAQP,EAAeI,CAAM,CAC5C,CAEA,SAAgBI,EAAgB,EAAuB,CACrD,OAAOD,EAAM,QAAQN,EAAoBG,CAAM,CACjD,CAGA,SAAgBK,EAAW,EAAuB,CAChD,OAAOF,EAAM,QAAQL,EAAeE,CAAM,CAC5C,CASA,SAAgBM,EAAW,EAAgB,EAAgC,CACzE,IAAIpC,EAAM3B,EACV,IAAK,IAAMgE,IAAQ,CAAC,GAAGC,CAAK,CAAC,CAAC,MAAM,EAAG,IAAMC,EAAE,MAAQtB,EAAE,KAAK,EAC5D,EAAMjB,EAAI,MAAM,EAAGqC,EAAK,KAAK,EAAIA,EAAK,KAAOrC,EAAI,MAAMqC,EAAK,GAAG,EAEjE,OAAOrC,CACT,CAGA,SAAgBwC,EAAY,EAAgB,EAAoB,CAC9D,IAAIhE,EAAIF,EACR,KAAOE,EAAI,GAAKP,EAAQI,EAAO,WAAWG,EAAI,CAAC,CAAC,GAAG,IACnD,OAAOA,CACT,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,T as n,b as r,h as i,r as a,v as o,y as s}from"./runtime-
|
|
1
|
+
import{C as e,E as t,T 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"./select-manifest-BBMbvdkH.js";import{t as d}from"./live-qnReIRtj.js";import{t as f}from"./inline-styles-CFNlb6f2.js";var p=`astl.select`,m=[{namespace:p,locale:`en`,messages:c},{namespace:p,locale:`pl`,messages:u}],h=String.fromCodePoint(8288),g=1e3,_=10,v=/\p{M}/gu,y={ł:`l`,ø:`o`,đ:`d`,ß:`ss`,æ:`ae`,œ:`oe`,ı:`i`},b=/[łøđßæœı]/gu;function x(e,t){let n;try{n=e.normalize(`NFKC`).toLocaleLowerCase(t===``?void 0:t)}catch{n=e.normalize(`NFKC`).toLowerCase()}return n.normalize(`NFD`).replace(v,``).replace(b,e=>y[e]??e).replace(/\s+/gu,` `).trim()}var S=(e,t)=>x(e,t)+(/\s$/u.test(e)&&e.trim()!==``?` `:``),C=n`<path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`,w=n`<circle cx="8.5" cy="8.5" r="5.5" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12.5 12.5l4.5 4.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>`,T=n`<path d="M4 10.5l4 4 8-9" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>`,E=(t,n)=>e`<svg class=${t} viewBox="0 0 20 20" aria-hidden="true" focusable="false">${n}</svg>`,D=e`<span class="separator" part="separator" aria-hidden="true">/</span>`,O=class extends a{static manifest=l;static messages=m;static shadowRootOptions={...s.shadowRootOptions,delegatesFocus:!0};static properties={query:{state:!0},expanded:{state:!0},active:{state:!0}};static styles=[t`
|
|
2
2
|
:host {
|
|
3
3
|
--astl-select-icon: 0px;
|
|
4
4
|
--astl-select-tail: 1ch;
|
|
@@ -342,4 +342,4 @@ color: var(--astl-on-accent);
|
|
|
342
342
|
aria-describedby=${o(n.describedBy)}
|
|
343
343
|
.value=${d(i?.label??``)}
|
|
344
344
|
></textarea>`}#u(e){let t=this.contentLang,n=x(this.query??``,t);return n===``?e:e.filter(e=>x(e.label,t).includes(n))}#d(e){let t=this.#u(this.options).length;this.expanded=t>0,this.active=this.expanded?Math.min(e,t-1):-1,this.announce(this.t(`ui.results`,{count:t}))}#f(){this.expanded=!1,this.active=-1}#p(){this.query=null,this.#f()}#m(e){this.query=e,this.#d(-1);let t=this.contentLang,n=x(e,t),r=this.options.filter(e=>n!==``&&x(e.label,t)===n);this.updateValue(r.length===1?r[0]?.id??``:``)}#h(e){this.#p(),this.updateValue(e.id)}#g(){return this.options.findIndex(e=>e.id===this.value)}#_(e){this.expanded=this.options.length>0,this.active=this.expanded?e:-1}#v(){let e=this.options[this.active];this.#f(),e!==void 0&&this.updateValue(e.id)}#y(e){return this.#e!==``&&e-this.#t<=g}#b(e,t){let n=this.contentLang,r=this.options.map(e=>x(e.label,n)),i=e=>{let t=[...e],i=t.every(e=>e===t[0]),a=S(i?t[0]??``:e,n),o=i?this.active+1:Math.max(this.active,0);for(let e=0;e<r.length;e++){let t=(o+e)%r.length;if(a!==``&&r[t]?.startsWith(a))return t}return-1},a=this.#y(t)?this.#e:``,o=a+e,s=i(o);return s<0&&a!==``&&(o=e,s=i(o)),this.#e=s<0?``:o,this.#t=t,s>=0&&(this.active=s),s>=0}#x=e=>{if(e.ctrlKey||e.metaKey||e.isComposing)return;let{key:t}=e,n=this.options.length-1,r=this.expanded,i=()=>e.preventDefault();if(t===`Tab`)r&&this.#v();else if(t===`Escape`){if(!r)return;i(),e.stopPropagation(),this.#f()}else if(t===`ArrowDown`||t===`ArrowUp`)i(),r?e.altKey?t===`ArrowUp`&&this.#v():this.active=t===`ArrowDown`?this.active<0?0:Math.min(this.active+1,n):this.active<0?n:Math.max(this.active-1,0):this.#_(this.#g());else if(t===`Home`||t===`End`)i(),this.#_(t===`Home`?0:n);else if(t===`PageUp`||t===`PageDown`){if(!r)return;i(),this.active=t===`PageDown`?Math.min(this.active+_,n):Math.max(this.active-_,0)}else t===` `&&r&&this.#y(e.timeStamp)&&this.#b(t,e.timeStamp)?i():t===`Enter`||t===` `?(i(),r?this.#v():this.#_(this.#g())):[...t].length===1&&!e.altKey&&(i(),r||this.#_(this.#g()),this.#b(t,e.timeStamp))};#S(e){let t=this.#u(this.options),n=t.length-1,r=()=>e.preventDefault();switch(e.key){case`ArrowDown`:r(),e.altKey?this.#d(-1):this.expanded?this.active=Math.min(this.active+1,n):this.#d(0);break;case`ArrowUp`:r(),e.altKey?this.#f():this.expanded?this.active=Math.max(this.active-1,0):this.#d(n);break;case`Home`:case`End`:if(!this.expanded||this.active<0)break;r(),this.active=e.key===`Home`?0:n;break;case`Enter`:{let e=this.expanded?t[this.active]:void 0;e===void 0?this.expanded&&(r(),this.#f()):(r(),this.#h(e));break}case`Escape`:this.expanded?(r(),e.stopPropagation(),this.#f()):((this.query??``)!==``||this.value!==``)&&(r(),this.query=``,this.updateValue(``))}}},k={manifest:l,element:O,messages:m};export{k as selectElement};
|
|
345
|
-
//# sourceMappingURL=select-
|
|
345
|
+
//# sourceMappingURL=select-DPpKJwSg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-DTA3dJzr.js","names":["en","pl","LitElement","nothing","ifDefined","live","b","i$1","w","A","verdictIcon","SingleSlotElement","i","en_default","selectManifest","pl_default","l","inlineStyles","namespace","selectUiMessages","WORD_JOINER","TYPE_AHEAD_MS","PAGE","MARKS","FOLDED","FOLDABLE","searchForm","lower","text","lang","ch","typedForm","CHEVRON","MAGNIFIER","CHECK","icon","className","shape","SEPARATOR","SelectElement","items","child","value","answers","option","#close","changed","options","verdict","solutionId","solution","ui","describedBy","id","common","number","variant","control","#buttons","#box","choose","#locked","#search","#dropdown","#list","sizes","event","list","#filtered","active","picked","item","#type","#key","#collapse","#open","#listbox","#listKey","#show","#pickedIndex","selected","#pick","stop","#keydown","radios","radio","query","o","count","index","typed","exact","#typed","time","#typedAt","forms","find","chars","again","prefix","from","before","#typing","key","last","open","handled","#commit","#typeAhead","selectElement"],"sources":["../../../../components/src/select/ui-messages.ts","../../../../components/src/select/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.select';\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 `selectMessages` would put the authoring strings into the element's chunk.\n */\nexport const selectUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, GroupVerdict, MessageCatalog } from '@astl/core';\nimport { type ElementRegistration, SingleSlotElement, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n svg,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { inlineStyles } from '../inline-styles.js';\nimport { selectManifest } from './manifest.js';\nimport { selectUiMessages } from './ui-messages.js';\n\n/** U+2060: keeps the text right after the select (a full stop, a comma) on its line. */\nconst WORD_JOINER = String.fromCodePoint(0x2060);\n/** Type-ahead: a key within this many milliseconds of the last one adds to the typed text (as in Chromium). */\nconst TYPE_AHEAD_MS = 1000;\n/** PageUp and PageDown move the visual focus this many options (as in the APG example). */\nconst PAGE = 10;\n\n/** One option as the element shows it. */\ninterface Item {\n readonly id: string;\n /** The text with whitespace runs collapsed, as a control shows it. */\n readonly label: string;\n readonly lang: string | undefined;\n readonly dir: string | undefined;\n}\n\n/** What every control of the element carries. */\ninterface Common {\n readonly label: string;\n readonly verdict: GroupVerdict | null;\n readonly describedBy: string | undefined;\n readonly lang: string | undefined;\n}\n\nconst MARKS = /\\p{M}/gu;\n/** Letters that NFD does not decompose (after lower-casing), searched as their base letters. */\nconst FOLDED: Readonly<Record<string, string>> = {\n ł: 'l',\n ø: 'o',\n đ: 'd',\n ß: 'ss',\n æ: 'ae',\n œ: 'oe',\n ı: 'i',\n};\nconst FOLDABLE = /[łøđßæœı]/gu;\n\n/**\n * The form the search compares: compatibility characters unified (NFKC), lower case in the content language (Turkish\n * İ and I work), diacritics dropped (ż = z, ł = l, é = e), spaces collapsed. Presentation only: grading compares\n * opaque option ids, never text.\n */\nfunction searchForm(text: string, lang: string): string {\n let lower: string;\n try {\n lower = text.normalize('NFKC').toLocaleLowerCase(lang === '' ? undefined : lang);\n } catch {\n // A malformed content language must not break the search.\n lower = text.normalize('NFKC').toLowerCase();\n }\n return lower\n .normalize('NFD')\n .replace(MARKS, '')\n .replace(FOLDABLE, (ch) => FOLDED[ch] ?? ch)\n .replace(/\\s+/gu, ' ')\n .trim();\n}\n\n/** The search form of typed text that keeps a space at its end, so \"the \" still tells \"the end\" from \"then\". */\nconst typedForm = (text: string, lang: string): string =>\n searchForm(text, lang) + (/\\s$/u.test(text) && text.trim() !== '' ? ' ' : '');\n\nconst CHEVRON = svg`<path d=\"M5 8l5 5 5-5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\nconst MAGNIFIER = svg`<circle cx=\"8.5\" cy=\"8.5\" r=\"5.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"/><path d=\"M12.5 12.5l4.5 4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/>`;\nconst CHECK = svg`<path d=\"M4 10.5l4 4 8-9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\nconst icon = (className: string, shape: TemplateResult) =>\n html`<svg class=${className} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${shape}</svg>`;\n\n/** Between two buttons: shown only where a look sets `--astl-separator-display` (\"mat / hat\"). */\nconst SEPARATOR = html`<span class=\"separator\" part=\"separator\" aria-hidden=\"true\">/</span>`;\n\n/**\n * `<astl-select>`: a choice inside running text. One slot, the element id; the answer is the picked option's id.\n * - `dropdown`: the WAI-ARIA APG select-only combobox, a list in the components' style under the field: the focus\n * stays on the field (the option with visual focus is its active descendant), typing jumps to the option that starts\n * with the typed text (case and diacritics ignored), Enter, Space or a click picks, Escape closes, Tab picks and\n * moves on. With `native`: a native `<select>` (the platform's picker on phones, native screen reader support).\n * - `search`: the WAI-ARIA APG combobox with a listbox popup and list autocomplete: typing filters the options\n * (case and diacritics ignored), the arrows move through them, Enter picks, Escape closes (or clears). The field\n * is one line (a long option ends in an ellipsis while it is edited); after a check, out of focus, the picked option\n * shows whole and wrapped over it.\n * - `buttons`: the options as buttons in a tray (native radios in a radio group): one tab stop (the picked option,\n * else the first), the arrow keys move and pick (wrapping), Home and End go to the ends.\n * - locked (review, handed in): a read-only text field with the picked option, so a long one wraps and shows in full;\n * the buttons stay, disabled.\n * The dropdown and the search list are as wide as the longest option (a hidden sizer in the same grid cell), so the\n * width never tells which option is right; the dropdown's list wraps a long option in the field. The two lists share\n * their options: parts `option` plus `option-active` (visual focus) and `option-picked`. The light-DOM\n * `<astl-option>` children are read, never moved or changed.\n */\nexport class SelectElement extends SingleSlotElement {\n static override manifest: ComponentManifest = selectManifest;\n static override messages: readonly MessageCatalog[] = selectUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static override properties: PropertyDeclarations = {\n query: { state: true },\n expanded: { state: true },\n active: { state: 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 select, so a full-line select keeps its full stop; the indicator\n // is the chevron or magnifier at the inline end, and the end padding keeps text clear of it.\n css`\n :host {\n --astl-select-icon: 0px;\n --astl-select-tail: 1ch;\n --astl-select-indicator: 1em;\n --astl-select-pad-end: calc(2 * var(--astl-space-2) + var(--astl-select-indicator));\n }\n .field.verdict {\n --astl-select-icon: calc(1.1em + var(--astl-space-1));\n }\n `,\n // One grid cell for the control and the sizer: the cell is as wide as the longest option.\n css`\n .box {\n position: relative;\n display: inline-grid;\n max-inline-size: calc(100% - var(--astl-select-icon) - var(--astl-select-tail));\n vertical-align: baseline;\n }\n .box > :not(.listbox) {\n grid-area: 1 / 1;\n }\n `,\n // Every option on its own line, invisible and without height: only its width counts.\n css`\n .sizer {\n block-size: 0;\n padding-inline: var(--astl-space-2) var(--astl-select-pad-end);\n border-inline: var(--astl-outline-width) solid transparent;\n overflow: hidden;\n visibility: hidden;\n white-space: normal;\n line-height: 1.4;\n }\n `,\n // The control in the box takes the cell's width and never widens it, so only the sizer counts: no width of its\n // own, at least the whole cell. Not `contain: inline-size`: Chromium still sizes a native select to its widest\n // option, rounded up to a whole pixel, so the dropdown came out up to 1px wider than the search field.\n // By element name (not `.box > .control`), so the locked textarea's own padding below still wins.\n css`\n :is(select, input, textarea, div, .shown).control {\n inline-size: 0;\n min-inline-size: 100%;\n padding-inline: var(--astl-space-2) var(--astl-select-pad-end);\n text-overflow: ellipsis;\n }\n select.control {\n appearance: none;\n cursor: pointer;\n }\n .indicator {\n justify-self: end;\n align-self: center;\n inline-size: var(--astl-select-indicator);\n block-size: var(--astl-select-indicator);\n margin-inline-end: calc(var(--astl-space-2) + var(--astl-outline-width));\n color: var(--astl-ink);\n pointer-events: none;\n }\n `,\n // The dropdown's list: the field shows the picked option (else \"Choose...\" in the muted ink) and wraps a long one,\n // its last line on the sentence's baseline, so the text after it (a full stop) follows that line; one line sits\n // where a native select's text would.\n css`\n div.control {\n display: flex;\n align-items: center;\n align-self: last baseline;\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .placeholder {\n color: var(--astl-ink-muted);\n }\n `,\n // Search after a check: the picked option shown whole over the field, wrapped as in the dropdown's list, its last\n // line on the sentence's baseline; the field under it keeps the height and hides its one-line copy. While the field\n // has the focus the student types as before (one line, an ellipsis), and the box keeps its height.\n css`\n span.control.shown {\n display: flex;\n align-items: center;\n align-self: last baseline;\n border-color: transparent;\n background: transparent;\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n pointer-events: none;\n }\n .box:has(> .shown) > input.control:not(:focus) {\n color: transparent;\n }\n .box:has(> input.control:focus) > .shown {\n visibility: hidden;\n }\n `,\n // Locked: as tall as its lines (field-sizing), so one line sits on the sentence's baseline and the text after it\n // (a full stop) follows the last line, as after a gap.\n css`\n .box.locked {\n vertical-align: bottom;\n }\n textarea.control {\n padding-inline-end: var(--astl-space-2);\n overflow-y: hidden;\n field-sizing: content;\n }\n `,\n // Both lists: the options under the field.\n css`\n .listbox {\n position: absolute;\n z-index: 2;\n inset-block-start: calc(100% + var(--astl-space-1));\n inset-inline: 0;\n box-sizing: border-box;\n max-block-size: calc(6 * var(--astl-target-min) + 2 * var(--astl-outline-width));\n overflow-y: auto;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n white-space: normal;\n line-height: 1.4;\n }\n .listbox[hidden] {\n display: none;\n }\n .option {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-1);\n min-block-size: var(--astl-target-min);\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-2);\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .option:hover {\n background: var(--astl-accent-soft);\n }\n `,\n // The option with visual focus: a ring (shape) and a fill, never the fill alone. The picked option: the check and\n // bold text, in hc also a bar at the inline start (as a picked button), which forced colours keep too.\n css`\n .option[data-active] {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: calc(-1 * var(--astl-focus-width));\n background: var(--astl-selected-soft);\n }\n .option[data-picked] {\n position: relative;\n font-weight: 600;\n }\n .option[data-picked]::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n .check {\n flex: none;\n inline-size: 1em;\n block-size: 1em;\n }\n .option:not([data-picked]) .check {\n visibility: hidden;\n }\n `,\n // Buttons: a tinted tray (the control, so it shows the verdict) of buttons that wrap, at most as wide as the line.\n // Its edge shows only a verdict: a frame around framed buttons would read as a double border. The buttons are\n // labels around visually hidden radios; their text wraps (the field's nowrap stops at the tray).\n css`\n .control.tray {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1);\n max-inline-size: calc(100% - var(--astl-select-icon) - var(--astl-select-tail));\n padding: var(--astl-space-1);\n border-color: transparent;\n background: var(--astl-canvas);\n white-space: normal;\n }\n .chip {\n position: relative;\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n padding-inline: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n overflow: clip;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .chip:has(:enabled):hover {\n background: var(--astl-accent-soft);\n }\n .chip:has(:disabled) {\n cursor: default;\n }\n .chip:has(:focus-visible) {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: var(--astl-focus-offset);\n }\n .separator {\n display: var(--astl-separator-display, none);\n color: var(--astl-ink-muted);\n }\n `,\n // Picked: the theme's fill and a doubled edge (an inset ring), so the pick never shows by colour alone (the radio\n // is hidden); in hc also a bar at the inline start. No bold: a word in a heading or in strong text keeps its weight,\n // and a pick never reflows the sentence.\n css`\n .chip:has(:checked) {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n box-shadow: inset 0 0 0 var(--astl-outline-width) var(--astl-selected);\n }\n .chip:has(:checked)::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n `,\n // System colours draw no fills: the picked button takes the highlight pair instead.\n css`\n @media (forced-colors: active) {\n .chip:has(:checked) {\n forced-color-adjust: none;\n background: var(--astl-selected);\n color: var(--astl-on-accent);\n }\n }\n `,\n inlineStyles,\n ];\n\n /** Search: the text the student is typing; null shows the picked option. */\n declare protected query: string | null;\n /** Dropdown list and search: whether the listbox is open. */\n declare protected expanded: boolean;\n /** Index of the option with visual focus, among the options (dropdown list) or the filtered ones (search); -1 = none. */\n declare protected active: number;\n /** Dropdown list: the type-ahead text so far, and when its last key came (an event time stamp). */\n #typed = '';\n #typedAt = Number.NEGATIVE_INFINITY;\n\n constructor() {\n super();\n this.query = null;\n this.expanded = false;\n this.active = -1;\n }\n\n /** `dropdown`, `search` or `buttons` (the manifest default for an absent or unknown value). */\n get variant(): string {\n return this.stringAttribute('variant') ?? 'dropdown';\n }\n\n /** `<astl-option>` children in rendered order: view order, or per attempt with `shuffle` and a seed. */\n get options(): readonly Item[] {\n const items = this.childElements('astl-option').map(\n (child): Item => ({\n id: child.id,\n label: (child.textContent ?? '').replace(/\\s+/gu, ' ').trim(),\n lang: child.getAttribute('lang') ?? undefined,\n dir: child.getAttribute('dir') ?? undefined,\n }),\n );\n return this.booleanAttribute('shuffle') ? this.shuffled(items) : items;\n }\n\n override setAnswers(answers: Answers): void {\n const value = answers[this.id];\n if (value === undefined) return;\n // Only option ids can be shown (`''` clears): anything else clears the answer, as in a single choice.\n this.value = this.options.some((option) => option.id === value) ? value : '';\n this.#close();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('disabled') && this.disabled) this.#close();\n }\n\n protected override updated(): void {\n if (!this.expanded || this.active < 0) return;\n this.renderRoot.querySelector('.option[data-active]')?.scrollIntoView({ block: 'nearest' });\n }\n\n protected override render(): TemplateResult {\n const options = this.options;\n const verdict = this.verdict;\n // A correct answer needs no correction: the solution shows for wrong and empty slots only.\n const solutionId = verdict === 'correct' ? null : this.solutionValue;\n const solution = options.find((option) => option.id === solutionId) ?? null;\n const ui = this.uiLanguage;\n const { number } = this.context;\n const describedBy = [verdict === null ? '' : 'verdict', solution === null ? '' : 'solution']\n .filter((id) => id !== '')\n .join(' ');\n const lang = this.contentLang;\n const common: Common = {\n label: number > 0 ? this.t('ui.label', { n: number }) : this.t('ui.labelPlain'),\n verdict,\n describedBy: describedBy === '' ? undefined : describedBy,\n lang: lang === '' ? undefined : lang,\n };\n const variant = this.variant;\n const control =\n variant === 'buttons' ? this.#buttons(options, common) : this.#box(options, common, variant);\n return html`<span class=\"select\" part=\"select\"\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.label })}</span\n ><span aria-hidden=\"true\" lang=${ifDefined(solution.lang)} dir=${ifDefined(solution.dir)}\n >${solution.label}</span\n ></span\n >`\n }</span\n >${WORD_JOINER}`;\n }\n\n /** The dropdown (a list, or with `native` a native select), the search list or the locked field, in one grid cell with the sizer. */\n #box(options: readonly Item[], common: Common, variant: string): TemplateResult {\n const choose = this.t('ui.choose');\n const control = this.disabled\n ? this.#locked(options, common)\n : variant === 'search'\n ? this.#search(options, common)\n : this.booleanAttribute('native')\n ? this.#dropdown(options, common, choose)\n : this.#list(options, common, choose);\n const sizes = [choose, ...options.map((option) => option.label)];\n return html`<span class=${this.disabled ? 'box locked' : 'box'}\n >${control}<span class=\"sizer\" aria-hidden=\"true\"\n >${sizes.map((text, i) => html`${i > 0 ? html`<br />` : nothing}<span>${text}</span>`)}</span\n ></span\n >`;\n }\n\n #dropdown(options: readonly Item[], common: Common, choose: string): TemplateResult {\n const value = this.value;\n const ui = this.uiLanguage;\n // `.selected` per option, not `.value` on the select: on the first render the options do not exist yet.\n return html`<select\n part=\"control\"\n class=\"control\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n @change=${(event: Event) => this.updateValue((event.target as HTMLSelectElement).value)}\n ><option value=\"\" lang=${ui.lang} dir=${ui.dir} .selected=${live(value === '')}>${choose}</option\n >${options.map(\n (option) =>\n html`<option\n value=${option.id}\n lang=${ifDefined(option.lang)}\n dir=${ifDefined(option.dir)}\n .selected=${live(option.id === value)}\n >${option.label}</option>`,\n )}</select\n >${icon('indicator', CHEVRON)}`;\n }\n\n #search(options: readonly Item[], common: Common): TemplateResult {\n const list = this.#filtered(options);\n const active = this.expanded ? list[this.active] : undefined;\n const picked = options.find((option) => option.id === this.value);\n const optionId = (item: Item) => `option-${options.indexOf(item)}`;\n return html`<input\n part=\"control\"\n class=\"control\"\n type=\"text\"\n role=\"combobox\"\n size=\"1\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-autocomplete=\"list\"\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=\"listbox\"\n aria-activedescendant=${active === undefined ? nothing : optionId(active)}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n placeholder=${this.t('ui.choose')}\n .value=${live(this.query ?? picked?.label ?? '')}\n @input=${(event: Event) => this.#type((event.target as HTMLInputElement).value)}\n @keydown=${(event: KeyboardEvent) => this.#key(event)}\n @click=${() => (this.expanded ? this.#collapse() : this.#open(-1))}\n @blur=${() => this.#close()}\n />${\n common.verdict !== null && this.query === null && picked !== undefined\n ? html`<span class=\"control shown\" aria-hidden=\"true\" lang=${ifDefined(picked.lang)} dir=${ifDefined(picked.dir)}\n >${picked.label}</span\n >`\n : nothing\n }${icon('indicator', MAGNIFIER)}${this.#listbox(options, list, common, 'active')}`;\n }\n\n /**\n * The dropdown's list: the WAI-ARIA APG select-only combobox. The focus stays on this field; the option with visual\n * focus is its active descendant, and aria-selected marks the picked one.\n */\n #list(options: readonly Item[], common: Common, choose: string): TemplateResult {\n const picked = options.find((option) => option.id === this.value);\n const ui = this.uiLanguage;\n return html`<div\n part=\"control\"\n class=\"control\"\n role=\"combobox\"\n tabindex=\"0\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=\"listbox\"\n aria-activedescendant=${this.expanded && this.active >= 0 ? `option-${this.active}` : nothing}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n @keydown=${this.#listKey}\n @click=${() => (this.expanded ? this.#collapse() : this.#show(this.#pickedIndex()))}\n @blur=${() => this.#collapse()}\n >${\n picked === undefined\n ? html`<span class=\"placeholder\" lang=${ui.lang} dir=${ui.dir}>${choose}</span>`\n : html`<span lang=${ifDefined(picked.lang)} dir=${ifDefined(picked.dir)}>${picked.label}</span>`\n }</div\n >${icon('indicator', CHEVRON)}${this.#listbox(options, options, common, 'picked')}`;\n }\n\n /**\n * The options under the field, shared by both lists: `items` (the search list's filtered ones), each with the id of\n * its place among `options`. aria-selected marks the picked option (dropdown list) or the active one (search, the\n * APG's list autocomplete); the parts name both states, so a host styles both lists alike.\n */\n #listbox(\n options: readonly Item[],\n items: readonly Item[],\n common: Common,\n selected: 'picked' | 'active',\n ): TemplateResult {\n return html`<div\n class=\"listbox\"\n part=\"listbox\"\n role=\"listbox\"\n id=\"listbox\"\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n ?hidden=${!this.expanded}\n @mousedown=${(event: Event) => event.preventDefault()}\n >${items.map((item, i) => {\n const active = i === this.active;\n const picked = item.id === this.value;\n const part = `option${active ? ' option-active' : ''}${picked ? ' option-picked' : ''}`;\n return html`<div\n class=\"option\"\n part=${part}\n role=\"option\"\n id=\"option-${options.indexOf(item)}\"\n lang=${ifDefined(item.lang)}\n dir=${ifDefined(item.dir)}\n aria-selected=${(selected === 'picked' ? picked : active) ? 'true' : 'false'}\n ?data-active=${active}\n ?data-picked=${picked}\n @click=${() => this.#pick(item)}\n >${icon('check', CHECK)}<span>${item.label}</span></div>`;\n })}</div>`;\n }\n\n /**\n * One native radio per option in a labelled radio group: the arrow keys move and pick, wrapping (the platform's own\n * radio group). Only the picked option (else the first) is a tab stop, so Shift+Tab lands there too.\n */\n #buttons(options: readonly Item[], common: Common): TemplateResult {\n const picked = options.findIndex((option) => option.id === this.value);\n // Locked: no tab stop (disabled radios take no focus).\n const stop = this.disabled ? -1 : Math.max(0, picked);\n return html`<span\n part=\"control\"\n class=\"control tray\"\n role=\"radiogroup\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n @keydown=${this.#keydown}\n >${options.map(\n (option, i) =>\n html`${i > 0 ? SEPARATOR : nothing}<label class=\"chip\" part=\"option\"\n ><input\n class=\"astl-vh\"\n type=\"radio\"\n name=\"option\"\n value=${option.id}\n tabindex=${i === stop ? 0 : -1}\n .checked=${live(option.id === this.value)}\n ?disabled=${this.disabled}\n aria-describedby=${ifDefined(common.describedBy)}\n @change=${() => this.updateValue(option.id)}\n /><span lang=${ifDefined(option.lang)} dir=${ifDefined(option.dir)}>${option.label}</span></label\n >`,\n )}</span\n >`;\n }\n\n /** Buttons: Home and End pick the first and the last option, which radio groups do not do by themselves. */\n #keydown = (event: KeyboardEvent): void => {\n if ((event.key !== 'Home' && event.key !== 'End') || event.altKey || event.ctrlKey || event.metaKey)\n return;\n const radios = this.renderRoot.querySelectorAll('input');\n const radio = radios[event.key === 'Home' ? 0 : radios.length - 1];\n event.preventDefault();\n radio?.focus();\n radio?.click();\n };\n\n #locked(options: readonly Item[], common: Common): TemplateResult {\n const picked = options.find((option) => option.id === this.value);\n return html`<textarea\n part=\"control\"\n class=\"control\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n rows=\"1\"\n cols=\"1\"\n lang=${ifDefined(picked?.lang ?? common.lang)}\n spellcheck=\"false\"\n readonly\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n .value=${live(picked?.label ?? '')}\n ></textarea>`;\n }\n\n /** Options whose search form contains the typed text's; every option while nothing is typed. */\n #filtered(options: readonly Item[]): readonly Item[] {\n const lang = this.contentLang;\n const query = searchForm(this.query ?? '', lang);\n return query === '' ? options : options.filter((o) => searchForm(o.label, lang).includes(query));\n }\n\n /** Opens the list (announcing how many options it shows) with visual focus on `index` (-1 = none). */\n #open(index: number): void {\n const count = this.#filtered(this.options).length;\n this.expanded = count > 0;\n this.active = this.expanded ? Math.min(index, count - 1) : -1;\n this.announce(this.t('ui.results', { count }));\n }\n\n /** Hides the list; what the student typed stays. */\n #collapse(): void {\n this.expanded = false;\n this.active = -1;\n }\n\n /** Hides the list and shows the picked option again (leaving the field, picking, a new answer). */\n #close(): void {\n this.query = null;\n this.#collapse();\n }\n\n /**\n * Typing filters the list. Text that equals one option (in the search form) answers with it, any other text\n * clears the answer: what the field shows is always what is graded once the student leaves it.\n */\n #type(text: string): void {\n this.query = text;\n this.#open(-1);\n const lang = this.contentLang;\n const typed = searchForm(text, lang);\n const exact = this.options.filter((o) => typed !== '' && searchForm(o.label, lang) === typed);\n this.updateValue(exact.length === 1 ? (exact[0]?.id ?? '') : '');\n }\n\n #pick(item: Item): void {\n this.#close();\n this.updateValue(item.id);\n }\n\n /** Dropdown list: the index of the picked option, -1 when none is. */\n #pickedIndex(): number {\n return this.options.findIndex((option) => option.id === this.value);\n }\n\n /** Dropdown list: opens it (when it has options) with visual focus on `index` (-1 = none). */\n #show(index: number): void {\n this.expanded = this.options.length > 0;\n this.active = this.expanded ? index : -1;\n }\n\n /** Dropdown list: picks the option with visual focus, if one has it, and closes the list. */\n #commit(): void {\n const item = this.options[this.active];\n this.#collapse();\n if (item !== undefined) this.updateValue(item.id);\n }\n\n /** Dropdown list: a key within the type-ahead time of the last typed one. */\n #typing(time: number): boolean {\n return this.#typed !== '' && time - this.#typedAt <= TYPE_AHEAD_MS;\n }\n\n /**\n * Dropdown list type-ahead, as a native select's: a key within a second of the last one adds to the typed text, and\n * the visual focus goes to the first option from the active one on that starts with it, ignoring case and\n * diacritics in the content language (as the search does); one letter typed again moves on to the next option with\n * that letter. Text no option starts with starts over from the last key. Returns whether an option matched.\n */\n #typeAhead(key: string, time: number): boolean {\n const lang = this.contentLang;\n const forms = this.options.map((option) => searchForm(option.label, lang));\n const find = (typed: string): number => {\n const chars = [...typed];\n const again = chars.every((ch) => ch === chars[0]);\n const prefix = typedForm(again ? (chars[0] ?? '') : typed, lang);\n const from = again ? this.active + 1 : Math.max(this.active, 0);\n for (let i = 0; i < forms.length; i++) {\n const index = (from + i) % forms.length;\n if (prefix !== '' && forms[index]?.startsWith(prefix)) return index;\n }\n return -1;\n };\n const before = this.#typing(time) ? this.#typed : '';\n let typed = before + key;\n let index = find(typed);\n if (index < 0 && before !== '') {\n typed = key;\n index = find(typed);\n }\n this.#typed = index < 0 ? '' : typed;\n this.#typedAt = time;\n if (index >= 0) this.active = index;\n return index >= 0;\n }\n\n /**\n * Dropdown list keys (the APG select-only combobox): closed, Enter, Space and the arrows open it (Home and End on\n * the first and the last option); open, the arrows, Home, End, PageUp and PageDown move, Enter, Space and\n * Alt+ArrowUp pick and close, Escape closes, Tab picks and moves on. Typing opens it and jumps (type-ahead); Space\n * goes on typing while the typed text and a space start an option (\"the p...\").\n */\n #listKey = (event: KeyboardEvent): void => {\n if (event.ctrlKey || event.metaKey || event.isComposing) return;\n const { key } = event;\n const last = this.options.length - 1;\n const open = this.expanded;\n const handled = (): void => event.preventDefault();\n if (key === 'Tab') {\n if (open) this.#commit();\n return;\n }\n if (key === 'Escape') {\n if (!open) return;\n handled();\n event.stopPropagation();\n this.#collapse();\n return;\n }\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n handled();\n if (!open) this.#show(this.#pickedIndex());\n else if (event.altKey) {\n if (key === 'ArrowUp') this.#commit();\n } else if (key === 'ArrowDown') this.active = this.active < 0 ? 0 : Math.min(this.active + 1, last);\n else this.active = this.active < 0 ? last : Math.max(this.active - 1, 0);\n return;\n }\n if (key === 'Home' || key === 'End') {\n handled();\n this.#show(key === 'Home' ? 0 : last);\n return;\n }\n if (key === 'PageUp' || key === 'PageDown') {\n if (!open) return;\n handled();\n this.active = key === 'PageDown' ? Math.min(this.active + PAGE, last) : Math.max(this.active - PAGE, 0);\n return;\n }\n if (key === ' ' && open && this.#typing(event.timeStamp) && this.#typeAhead(key, event.timeStamp)) {\n handled();\n return;\n }\n if (key === 'Enter' || key === ' ') {\n handled();\n if (open) this.#commit();\n else this.#show(this.#pickedIndex());\n return;\n }\n if ([...key].length === 1 && !event.altKey) {\n handled();\n if (!open) this.#show(this.#pickedIndex());\n this.#typeAhead(key, event.timeStamp);\n }\n };\n\n #key(event: KeyboardEvent): void {\n const list = this.#filtered(this.options);\n const last = list.length - 1;\n const handled = (): void => event.preventDefault();\n switch (event.key) {\n case 'ArrowDown':\n handled();\n if (event.altKey) this.#open(-1);\n else if (!this.expanded) this.#open(0);\n else this.active = Math.min(this.active + 1, last);\n break;\n case 'ArrowUp':\n handled();\n if (event.altKey) this.#collapse();\n else if (!this.expanded) this.#open(last);\n else this.active = Math.max(this.active - 1, 0);\n break;\n case 'Home':\n case 'End':\n // With visual focus in the list they move it there; otherwise they move the caret as usual.\n if (!this.expanded || this.active < 0) break;\n handled();\n this.active = event.key === 'Home' ? 0 : last;\n break;\n case 'Enter': {\n const item = this.expanded ? list[this.active] : undefined;\n if (item !== undefined) {\n handled();\n this.#pick(item);\n } else if (this.expanded) {\n handled();\n this.#collapse();\n }\n break;\n }\n case 'Escape':\n if (this.expanded) {\n handled();\n event.stopPropagation();\n this.#collapse();\n } else if ((this.query ?? '') !== '' || this.value !== '') {\n // Closed: Escape clears the field and the answer (the APG's optional behaviour).\n handled();\n this.query = '';\n this.updateValue('');\n }\n break;\n }\n }\n}\n\nexport const selectElement: ElementRegistration = {\n manifest: selectManifest,\n element: SelectElement,\n messages: selectUiMessages,\n};\n"],"mappings":"A,kPAIA,IAAMkB,EAAY,cAMLC,EAA8C,CACzD,CAAE,YAAW,OAAQ,KAAM,SAAUnB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECOMmB,EAAc,OAAO,cAAc,IAAM,EAEzCC,EAAgB,IAEhBC,EAAO,GAmBPC,EAAQ,UAERC,EAA2C,CAC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,IAAI,KAAK,OAAS,EAAG6B,CAAI,EADxB,KAAK7B,GAAM,CAAC,EAErC,MACF,IAAK,UACH+B,EAAQ,EACJxC,EAAM,OAAQ,KAAKQ,GAAU,EACvB,KAAK,SACV,KAAK,OAAS,KAAK,IAAI,KAAK,OAAS,EAAG,CAAC,EADrB,KAAKC,GAAM6B,CAAI,EAExC,MACF,IAAK,OACL,IAAK,MAEH,GAAI,CAAC,KAAK,UAAY,KAAK,OAAS,EAAG,MACvCE,EAAQ,EACR,KAAK,OAASxC,EAAM,MAAQ,OAAS,EAAIsC,EACzC,MACF,IAAK,QAAS,CACZ,IAAMjC,EAAO,KAAK,SAAWJ,EAAK,KAAK,QAAU,IAAA,GAC7CI,IAAS,IAAA,GAGF,KAAK,WACdmC,EAAQ,EACR,KAAKhC,GAAU,IAJfgC,EAAQ,EACR,KAAKzB,GAAMV,CAAI,GAKjB,KACF,CACA,IAAK,SACC,KAAK,UACPmC,EAAQ,EACRxC,EAAM,gBAAgB,EACtB,KAAKQ,GAAU,KACL,KAAK,OAAS,MAAQ,IAAM,KAAK,QAAU,MAErDgC,EAAQ,EACR,KAAK,MAAQ,GACb,KAAK,YAAY,EAAE,EAGzB,CACF,CACF,EAEaG,EAAqC,CAChD,SAAU/F,EACV,QAASyB,EACT,SAAUpB,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"select-DPpKJwSg.js","names":["en","pl","LitElement","nothing","ifDefined","live","b","i$1","w","A","verdictIcon","SingleSlotElement","i","en_default","selectManifest","pl_default","l","inlineStyles","namespace","selectUiMessages","WORD_JOINER","TYPE_AHEAD_MS","PAGE","MARKS","FOLDED","FOLDABLE","searchForm","lower","text","lang","ch","typedForm","CHEVRON","MAGNIFIER","CHECK","icon","className","shape","SEPARATOR","SelectElement","items","child","value","answers","option","#close","changed","options","verdict","solutionId","solution","ui","describedBy","id","common","number","variant","control","#buttons","#box","choose","#locked","#search","#dropdown","#list","sizes","event","list","#filtered","active","picked","item","#type","#key","#collapse","#open","#listbox","#listKey","#show","#pickedIndex","selected","#pick","stop","#keydown","radios","radio","query","o","count","index","typed","exact","#typed","time","#typedAt","forms","find","chars","again","prefix","from","before","#typing","key","last","open","handled","#commit","#typeAhead","selectElement"],"sources":["../../../../components/src/select/ui-messages.ts","../../../../components/src/select/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.select';\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 `selectMessages` would put the authoring strings into the element's chunk.\n */\nexport const selectUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, GroupVerdict, MessageCatalog } from '@astl/core';\nimport { type ElementRegistration, SingleSlotElement, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n svg,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { inlineStyles } from '../inline-styles.js';\nimport { selectManifest } from './manifest.js';\nimport { selectUiMessages } from './ui-messages.js';\n\n/** U+2060: keeps the text right after the select (a full stop, a comma) on its line. */\nconst WORD_JOINER = String.fromCodePoint(0x2060);\n/** Type-ahead: a key within this many milliseconds of the last one adds to the typed text (as in Chromium). */\nconst TYPE_AHEAD_MS = 1000;\n/** PageUp and PageDown move the visual focus this many options (as in the APG example). */\nconst PAGE = 10;\n\n/** One option as the element shows it. */\ninterface Item {\n readonly id: string;\n /** The text with whitespace runs collapsed, as a control shows it. */\n readonly label: string;\n readonly lang: string | undefined;\n readonly dir: string | undefined;\n}\n\n/** What every control of the element carries. */\ninterface Common {\n readonly label: string;\n readonly verdict: GroupVerdict | null;\n readonly describedBy: string | undefined;\n readonly lang: string | undefined;\n}\n\nconst MARKS = /\\p{M}/gu;\n/** Letters that NFD does not decompose (after lower-casing), searched as their base letters. */\nconst FOLDED: Readonly<Record<string, string>> = {\n ł: 'l',\n ø: 'o',\n đ: 'd',\n ß: 'ss',\n æ: 'ae',\n œ: 'oe',\n ı: 'i',\n};\nconst FOLDABLE = /[łøđßæœı]/gu;\n\n/**\n * The form the search compares: compatibility characters unified (NFKC), lower case in the content language (Turkish\n * İ and I work), diacritics dropped (ż = z, ł = l, é = e), spaces collapsed. Presentation only: grading compares\n * opaque option ids, never text.\n */\nfunction searchForm(text: string, lang: string): string {\n let lower: string;\n try {\n lower = text.normalize('NFKC').toLocaleLowerCase(lang === '' ? undefined : lang);\n } catch {\n // A malformed content language must not break the search.\n lower = text.normalize('NFKC').toLowerCase();\n }\n return lower\n .normalize('NFD')\n .replace(MARKS, '')\n .replace(FOLDABLE, (ch) => FOLDED[ch] ?? ch)\n .replace(/\\s+/gu, ' ')\n .trim();\n}\n\n/** The search form of typed text that keeps a space at its end, so \"the \" still tells \"the end\" from \"then\". */\nconst typedForm = (text: string, lang: string): string =>\n searchForm(text, lang) + (/\\s$/u.test(text) && text.trim() !== '' ? ' ' : '');\n\nconst CHEVRON = svg`<path d=\"M5 8l5 5 5-5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\nconst MAGNIFIER = svg`<circle cx=\"8.5\" cy=\"8.5\" r=\"5.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"/><path d=\"M12.5 12.5l4.5 4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/>`;\nconst CHECK = svg`<path d=\"M4 10.5l4 4 8-9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\nconst icon = (className: string, shape: TemplateResult) =>\n html`<svg class=${className} viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${shape}</svg>`;\n\n/** Between two buttons: shown only where a look sets `--astl-separator-display` (\"mat / hat\"). */\nconst SEPARATOR = html`<span class=\"separator\" part=\"separator\" aria-hidden=\"true\">/</span>`;\n\n/**\n * `<astl-select>`: a choice inside running text. One slot, the element id; the answer is the picked option's id.\n * - `dropdown`: the WAI-ARIA APG select-only combobox, a list in the components' style under the field: the focus\n * stays on the field (the option with visual focus is its active descendant), typing jumps to the option that starts\n * with the typed text (case and diacritics ignored), Enter, Space or a click picks, Escape closes, Tab picks and\n * moves on. With `native`: a native `<select>` (the platform's picker on phones, native screen reader support).\n * - `search`: the WAI-ARIA APG combobox with a listbox popup and list autocomplete: typing filters the options\n * (case and diacritics ignored), the arrows move through them, Enter picks, Escape closes (or clears). The field\n * is one line (a long option ends in an ellipsis while it is edited); after a check, out of focus, the picked option\n * shows whole and wrapped over it.\n * - `buttons`: the options as buttons in a tray (native radios in a radio group): one tab stop (the picked option,\n * else the first), the arrow keys move and pick (wrapping), Home and End go to the ends.\n * - locked (review, handed in): a read-only text field with the picked option, so a long one wraps and shows in full;\n * the buttons stay, disabled.\n * The dropdown and the search list are as wide as the longest option (a hidden sizer in the same grid cell), so the\n * width never tells which option is right; the dropdown's list wraps a long option in the field. The two lists share\n * their options: parts `option` plus `option-active` (visual focus) and `option-picked`. The light-DOM\n * `<astl-option>` children are read, never moved or changed.\n */\nexport class SelectElement extends SingleSlotElement {\n static override manifest: ComponentManifest = selectManifest;\n static override messages: readonly MessageCatalog[] = selectUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static override properties: PropertyDeclarations = {\n query: { state: true },\n expanded: { state: true },\n active: { state: 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 select, so a full-line select keeps its full stop; the indicator\n // is the chevron or magnifier at the inline end, and the end padding keeps text clear of it.\n css`\n :host {\n --astl-select-icon: 0px;\n --astl-select-tail: 1ch;\n --astl-select-indicator: 1em;\n --astl-select-pad-end: calc(2 * var(--astl-space-2) + var(--astl-select-indicator));\n }\n .field.verdict {\n --astl-select-icon: calc(1.1em + var(--astl-space-1));\n }\n `,\n // One grid cell for the control and the sizer: the cell is as wide as the longest option.\n css`\n .box {\n position: relative;\n display: inline-grid;\n max-inline-size: calc(100% - var(--astl-select-icon) - var(--astl-select-tail));\n vertical-align: baseline;\n }\n .box > :not(.listbox) {\n grid-area: 1 / 1;\n }\n `,\n // Every option on its own line, invisible and without height: only its width counts.\n css`\n .sizer {\n block-size: 0;\n padding-inline: var(--astl-space-2) var(--astl-select-pad-end);\n border-inline: var(--astl-outline-width) solid transparent;\n overflow: hidden;\n visibility: hidden;\n white-space: normal;\n line-height: 1.4;\n }\n `,\n // The control in the box takes the cell's width and never widens it, so only the sizer counts: no width of its\n // own, at least the whole cell. Not `contain: inline-size`: Chromium still sizes a native select to its widest\n // option, rounded up to a whole pixel, so the dropdown came out up to 1px wider than the search field.\n // By element name (not `.box > .control`), so the locked textarea's own padding below still wins.\n css`\n :is(select, input, textarea, div, .shown).control {\n inline-size: 0;\n min-inline-size: 100%;\n padding-inline: var(--astl-space-2) var(--astl-select-pad-end);\n text-overflow: ellipsis;\n }\n select.control {\n appearance: none;\n cursor: pointer;\n }\n .indicator {\n justify-self: end;\n align-self: center;\n inline-size: var(--astl-select-indicator);\n block-size: var(--astl-select-indicator);\n margin-inline-end: calc(var(--astl-space-2) + var(--astl-outline-width));\n color: var(--astl-ink);\n pointer-events: none;\n }\n `,\n // The dropdown's list: the field shows the picked option (else \"Choose...\" in the muted ink) and wraps a long one,\n // its last line on the sentence's baseline, so the text after it (a full stop) follows that line; one line sits\n // where a native select's text would.\n css`\n div.control {\n display: flex;\n align-items: center;\n align-self: last baseline;\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .placeholder {\n color: var(--astl-ink-muted);\n }\n `,\n // Search after a check: the picked option shown whole over the field, wrapped as in the dropdown's list, its last\n // line on the sentence's baseline; the field under it keeps the height and hides its one-line copy. While the field\n // has the focus the student types as before (one line, an ellipsis), and the box keeps its height.\n css`\n span.control.shown {\n display: flex;\n align-items: center;\n align-self: last baseline;\n border-color: transparent;\n background: transparent;\n white-space: normal;\n overflow-wrap: anywhere;\n hyphens: auto;\n pointer-events: none;\n }\n .box:has(> .shown) > input.control:not(:focus) {\n color: transparent;\n }\n .box:has(> input.control:focus) > .shown {\n visibility: hidden;\n }\n `,\n // Locked: as tall as its lines (field-sizing), so one line sits on the sentence's baseline and the text after it\n // (a full stop) follows the last line, as after a gap.\n css`\n .box.locked {\n vertical-align: bottom;\n }\n textarea.control {\n padding-inline-end: var(--astl-space-2);\n overflow-y: hidden;\n field-sizing: content;\n }\n `,\n // Both lists: the options under the field.\n css`\n .listbox {\n position: absolute;\n z-index: 2;\n inset-block-start: calc(100% + var(--astl-space-1));\n inset-inline: 0;\n box-sizing: border-box;\n max-block-size: calc(6 * var(--astl-target-min) + 2 * var(--astl-outline-width));\n overflow-y: auto;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface-raised);\n color: var(--astl-ink);\n white-space: normal;\n line-height: 1.4;\n }\n .listbox[hidden] {\n display: none;\n }\n .option {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-1);\n min-block-size: var(--astl-target-min);\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-2);\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .option:hover {\n background: var(--astl-accent-soft);\n }\n `,\n // The option with visual focus: a ring (shape) and a fill, never the fill alone. The picked option: the check and\n // bold text, in hc also a bar at the inline start (as a picked button), which forced colours keep too.\n css`\n .option[data-active] {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: calc(-1 * var(--astl-focus-width));\n background: var(--astl-selected-soft);\n }\n .option[data-picked] {\n position: relative;\n font-weight: 600;\n }\n .option[data-picked]::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n .check {\n flex: none;\n inline-size: 1em;\n block-size: 1em;\n }\n .option:not([data-picked]) .check {\n visibility: hidden;\n }\n `,\n // Buttons: a tinted tray (the control, so it shows the verdict) of buttons that wrap, at most as wide as the line.\n // Its edge shows only a verdict: a frame around framed buttons would read as a double border. The buttons are\n // labels around visually hidden radios; their text wraps (the field's nowrap stops at the tray).\n css`\n .control.tray {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1);\n max-inline-size: calc(100% - var(--astl-select-icon) - var(--astl-select-tail));\n padding: var(--astl-space-1);\n border-color: transparent;\n background: var(--astl-canvas);\n white-space: normal;\n }\n .chip {\n position: relative;\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n padding-inline: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n overflow: clip;\n overflow-wrap: anywhere;\n hyphens: auto;\n cursor: pointer;\n }\n .chip:has(:enabled):hover {\n background: var(--astl-accent-soft);\n }\n .chip:has(:disabled) {\n cursor: default;\n }\n .chip:has(:focus-visible) {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: var(--astl-focus-offset);\n }\n .separator {\n display: var(--astl-separator-display, none);\n color: var(--astl-ink-muted);\n }\n `,\n // Picked: the theme's fill and a doubled edge (an inset ring), so the pick never shows by colour alone (the radio\n // is hidden); in hc also a bar at the inline start. No bold: a word in a heading or in strong text keeps its weight,\n // and a pick never reflows the sentence.\n css`\n .chip:has(:checked) {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n box-shadow: inset 0 0 0 var(--astl-outline-width) var(--astl-selected);\n }\n .chip:has(:checked)::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n `,\n // System colours draw no fills: the picked button takes the highlight pair instead.\n css`\n @media (forced-colors: active) {\n .chip:has(:checked) {\n forced-color-adjust: none;\n background: var(--astl-selected);\n color: var(--astl-on-accent);\n }\n }\n `,\n inlineStyles,\n ];\n\n /** Search: the text the student is typing; null shows the picked option. */\n declare protected query: string | null;\n /** Dropdown list and search: whether the listbox is open. */\n declare protected expanded: boolean;\n /** Index of the option with visual focus, among the options (dropdown list) or the filtered ones (search); -1 = none. */\n declare protected active: number;\n /** Dropdown list: the type-ahead text so far, and when its last key came (an event time stamp). */\n #typed = '';\n #typedAt = Number.NEGATIVE_INFINITY;\n\n constructor() {\n super();\n this.query = null;\n this.expanded = false;\n this.active = -1;\n }\n\n /** `dropdown`, `search` or `buttons` (the manifest default for an absent or unknown value). */\n get variant(): string {\n return this.stringAttribute('variant') ?? 'dropdown';\n }\n\n /** `<astl-option>` children in rendered order: view order, or per attempt with `shuffle` and a seed. */\n get options(): readonly Item[] {\n const items = this.childElements('astl-option').map(\n (child): Item => ({\n id: child.id,\n label: (child.textContent ?? '').replace(/\\s+/gu, ' ').trim(),\n lang: child.getAttribute('lang') ?? undefined,\n dir: child.getAttribute('dir') ?? undefined,\n }),\n );\n return this.booleanAttribute('shuffle') ? this.shuffled(items) : items;\n }\n\n override setAnswers(answers: Answers): void {\n const value = answers[this.id];\n if (value === undefined) return;\n // Only option ids can be shown (`''` clears): anything else clears the answer, as in a single choice.\n this.value = this.options.some((option) => option.id === value) ? value : '';\n this.#close();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('disabled') && this.disabled) this.#close();\n }\n\n protected override updated(): void {\n if (!this.expanded || this.active < 0) return;\n this.renderRoot.querySelector('.option[data-active]')?.scrollIntoView({ block: 'nearest' });\n }\n\n protected override render(): TemplateResult {\n const options = this.options;\n const verdict = this.verdict;\n // A correct answer needs no correction: the solution shows for wrong and empty slots only.\n const solutionId = verdict === 'correct' ? null : this.solutionValue;\n const solution = options.find((option) => option.id === solutionId) ?? null;\n const ui = this.uiLanguage;\n const { number } = this.context;\n const describedBy = [verdict === null ? '' : 'verdict', solution === null ? '' : 'solution']\n .filter((id) => id !== '')\n .join(' ');\n const lang = this.contentLang;\n const common: Common = {\n label: number > 0 ? this.t('ui.label', { n: number }) : this.t('ui.labelPlain'),\n verdict,\n describedBy: describedBy === '' ? undefined : describedBy,\n lang: lang === '' ? undefined : lang,\n };\n const variant = this.variant;\n const control =\n variant === 'buttons' ? this.#buttons(options, common) : this.#box(options, common, variant);\n return html`<span class=\"select\" part=\"select\"\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.label })}</span\n ><span aria-hidden=\"true\" lang=${ifDefined(solution.lang)} dir=${ifDefined(solution.dir)}\n >${solution.label}</span\n ></span\n >`\n }</span\n >${WORD_JOINER}`;\n }\n\n /** The dropdown (a list, or with `native` a native select), the search list or the locked field, in one grid cell with the sizer. */\n #box(options: readonly Item[], common: Common, variant: string): TemplateResult {\n const choose = this.t('ui.choose');\n const control = this.disabled\n ? this.#locked(options, common)\n : variant === 'search'\n ? this.#search(options, common)\n : this.booleanAttribute('native')\n ? this.#dropdown(options, common, choose)\n : this.#list(options, common, choose);\n const sizes = [choose, ...options.map((option) => option.label)];\n return html`<span class=${this.disabled ? 'box locked' : 'box'}\n >${control}<span class=\"sizer\" aria-hidden=\"true\"\n >${sizes.map((text, i) => html`${i > 0 ? html`<br />` : nothing}<span>${text}</span>`)}</span\n ></span\n >`;\n }\n\n #dropdown(options: readonly Item[], common: Common, choose: string): TemplateResult {\n const value = this.value;\n const ui = this.uiLanguage;\n // `.selected` per option, not `.value` on the select: on the first render the options do not exist yet.\n return html`<select\n part=\"control\"\n class=\"control\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n @change=${(event: Event) => this.updateValue((event.target as HTMLSelectElement).value)}\n ><option value=\"\" lang=${ui.lang} dir=${ui.dir} .selected=${live(value === '')}>${choose}</option\n >${options.map(\n (option) =>\n html`<option\n value=${option.id}\n lang=${ifDefined(option.lang)}\n dir=${ifDefined(option.dir)}\n .selected=${live(option.id === value)}\n >${option.label}</option>`,\n )}</select\n >${icon('indicator', CHEVRON)}`;\n }\n\n #search(options: readonly Item[], common: Common): TemplateResult {\n const list = this.#filtered(options);\n const active = this.expanded ? list[this.active] : undefined;\n const picked = options.find((option) => option.id === this.value);\n const optionId = (item: Item) => `option-${options.indexOf(item)}`;\n return html`<input\n part=\"control\"\n class=\"control\"\n type=\"text\"\n role=\"combobox\"\n size=\"1\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-autocomplete=\"list\"\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=\"listbox\"\n aria-activedescendant=${active === undefined ? nothing : optionId(active)}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n placeholder=${this.t('ui.choose')}\n .value=${live(this.query ?? picked?.label ?? '')}\n @input=${(event: Event) => this.#type((event.target as HTMLInputElement).value)}\n @keydown=${(event: KeyboardEvent) => this.#key(event)}\n @click=${() => (this.expanded ? this.#collapse() : this.#open(-1))}\n @blur=${() => this.#close()}\n />${\n common.verdict !== null && this.query === null && picked !== undefined\n ? html`<span class=\"control shown\" aria-hidden=\"true\" lang=${ifDefined(picked.lang)} dir=${ifDefined(picked.dir)}\n >${picked.label}</span\n >`\n : nothing\n }${icon('indicator', MAGNIFIER)}${this.#listbox(options, list, common, 'active')}`;\n }\n\n /**\n * The dropdown's list: the WAI-ARIA APG select-only combobox. The focus stays on this field; the option with visual\n * focus is its active descendant, and aria-selected marks the picked one.\n */\n #list(options: readonly Item[], common: Common, choose: string): TemplateResult {\n const picked = options.find((option) => option.id === this.value);\n const ui = this.uiLanguage;\n return html`<div\n part=\"control\"\n class=\"control\"\n role=\"combobox\"\n tabindex=\"0\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-expanded=${this.expanded ? 'true' : 'false'}\n aria-controls=\"listbox\"\n aria-activedescendant=${this.expanded && this.active >= 0 ? `option-${this.active}` : nothing}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n @keydown=${this.#listKey}\n @click=${() => (this.expanded ? this.#collapse() : this.#show(this.#pickedIndex()))}\n @blur=${() => this.#collapse()}\n >${\n picked === undefined\n ? html`<span class=\"placeholder\" lang=${ui.lang} dir=${ui.dir}>${choose}</span>`\n : html`<span lang=${ifDefined(picked.lang)} dir=${ifDefined(picked.dir)}>${picked.label}</span>`\n }</div\n >${icon('indicator', CHEVRON)}${this.#listbox(options, options, common, 'picked')}`;\n }\n\n /**\n * The options under the field, shared by both lists: `items` (the search list's filtered ones), each with the id of\n * its place among `options`. aria-selected marks the picked option (dropdown list) or the active one (search, the\n * APG's list autocomplete); the parts name both states, so a host styles both lists alike.\n */\n #listbox(\n options: readonly Item[],\n items: readonly Item[],\n common: Common,\n selected: 'picked' | 'active',\n ): TemplateResult {\n return html`<div\n class=\"listbox\"\n part=\"listbox\"\n role=\"listbox\"\n id=\"listbox\"\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n ?hidden=${!this.expanded}\n @mousedown=${(event: Event) => event.preventDefault()}\n >${items.map((item, i) => {\n const active = i === this.active;\n const picked = item.id === this.value;\n const part = `option${active ? ' option-active' : ''}${picked ? ' option-picked' : ''}`;\n return html`<div\n class=\"option\"\n part=${part}\n role=\"option\"\n id=\"option-${options.indexOf(item)}\"\n lang=${ifDefined(item.lang)}\n dir=${ifDefined(item.dir)}\n aria-selected=${(selected === 'picked' ? picked : active) ? 'true' : 'false'}\n ?data-active=${active}\n ?data-picked=${picked}\n @click=${() => this.#pick(item)}\n >${icon('check', CHECK)}<span>${item.label}</span></div>`;\n })}</div>`;\n }\n\n /**\n * One native radio per option in a labelled radio group: the arrow keys move and pick, wrapping (the platform's own\n * radio group). Only the picked option (else the first) is a tab stop, so Shift+Tab lands there too.\n */\n #buttons(options: readonly Item[], common: Common): TemplateResult {\n const picked = options.findIndex((option) => option.id === this.value);\n // Locked: no tab stop (disabled radios take no focus).\n const stop = this.disabled ? -1 : Math.max(0, picked);\n return html`<span\n part=\"control\"\n class=\"control tray\"\n role=\"radiogroup\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n lang=${ifDefined(common.lang)}\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n @keydown=${this.#keydown}\n >${options.map(\n (option, i) =>\n html`${i > 0 ? SEPARATOR : nothing}<label class=\"chip\" part=\"option\"\n ><input\n class=\"astl-vh\"\n type=\"radio\"\n name=\"option\"\n value=${option.id}\n tabindex=${i === stop ? 0 : -1}\n .checked=${live(option.id === this.value)}\n ?disabled=${this.disabled}\n aria-describedby=${ifDefined(common.describedBy)}\n @change=${() => this.updateValue(option.id)}\n /><span lang=${ifDefined(option.lang)} dir=${ifDefined(option.dir)}>${option.label}</span></label\n >`,\n )}</span\n >`;\n }\n\n /** Buttons: Home and End pick the first and the last option, which radio groups do not do by themselves. */\n #keydown = (event: KeyboardEvent): void => {\n if ((event.key !== 'Home' && event.key !== 'End') || event.altKey || event.ctrlKey || event.metaKey)\n return;\n const radios = this.renderRoot.querySelectorAll('input');\n const radio = radios[event.key === 'Home' ? 0 : radios.length - 1];\n event.preventDefault();\n radio?.focus();\n radio?.click();\n };\n\n #locked(options: readonly Item[], common: Common): TemplateResult {\n const picked = options.find((option) => option.id === this.value);\n return html`<textarea\n part=\"control\"\n class=\"control\"\n data-verdict=${ifDefined(common.verdict ?? undefined)}\n rows=\"1\"\n cols=\"1\"\n lang=${ifDefined(picked?.lang ?? common.lang)}\n spellcheck=\"false\"\n readonly\n aria-label=${common.label}\n aria-invalid=${common.verdict === 'incorrect' ? 'true' : nothing}\n aria-describedby=${ifDefined(common.describedBy)}\n .value=${live(picked?.label ?? '')}\n ></textarea>`;\n }\n\n /** Options whose search form contains the typed text's; every option while nothing is typed. */\n #filtered(options: readonly Item[]): readonly Item[] {\n const lang = this.contentLang;\n const query = searchForm(this.query ?? '', lang);\n return query === '' ? options : options.filter((o) => searchForm(o.label, lang).includes(query));\n }\n\n /** Opens the list (announcing how many options it shows) with visual focus on `index` (-1 = none). */\n #open(index: number): void {\n const count = this.#filtered(this.options).length;\n this.expanded = count > 0;\n this.active = this.expanded ? Math.min(index, count - 1) : -1;\n this.announce(this.t('ui.results', { count }));\n }\n\n /** Hides the list; what the student typed stays. */\n #collapse(): void {\n this.expanded = false;\n this.active = -1;\n }\n\n /** Hides the list and shows the picked option again (leaving the field, picking, a new answer). */\n #close(): void {\n this.query = null;\n this.#collapse();\n }\n\n /**\n * Typing filters the list. Text that equals one option (in the search form) answers with it, any other text\n * clears the answer: what the field shows is always what is graded once the student leaves it.\n */\n #type(text: string): void {\n this.query = text;\n this.#open(-1);\n const lang = this.contentLang;\n const typed = searchForm(text, lang);\n const exact = this.options.filter((o) => typed !== '' && searchForm(o.label, lang) === typed);\n this.updateValue(exact.length === 1 ? (exact[0]?.id ?? '') : '');\n }\n\n #pick(item: Item): void {\n this.#close();\n this.updateValue(item.id);\n }\n\n /** Dropdown list: the index of the picked option, -1 when none is. */\n #pickedIndex(): number {\n return this.options.findIndex((option) => option.id === this.value);\n }\n\n /** Dropdown list: opens it (when it has options) with visual focus on `index` (-1 = none). */\n #show(index: number): void {\n this.expanded = this.options.length > 0;\n this.active = this.expanded ? index : -1;\n }\n\n /** Dropdown list: picks the option with visual focus, if one has it, and closes the list. */\n #commit(): void {\n const item = this.options[this.active];\n this.#collapse();\n if (item !== undefined) this.updateValue(item.id);\n }\n\n /** Dropdown list: a key within the type-ahead time of the last typed one. */\n #typing(time: number): boolean {\n return this.#typed !== '' && time - this.#typedAt <= TYPE_AHEAD_MS;\n }\n\n /**\n * Dropdown list type-ahead, as a native select's: a key within a second of the last one adds to the typed text, and\n * the visual focus goes to the first option from the active one on that starts with it, ignoring case and\n * diacritics in the content language (as the search does); one letter typed again moves on to the next option with\n * that letter. Text no option starts with starts over from the last key. Returns whether an option matched.\n */\n #typeAhead(key: string, time: number): boolean {\n const lang = this.contentLang;\n const forms = this.options.map((option) => searchForm(option.label, lang));\n const find = (typed: string): number => {\n const chars = [...typed];\n const again = chars.every((ch) => ch === chars[0]);\n const prefix = typedForm(again ? (chars[0] ?? '') : typed, lang);\n const from = again ? this.active + 1 : Math.max(this.active, 0);\n for (let i = 0; i < forms.length; i++) {\n const index = (from + i) % forms.length;\n if (prefix !== '' && forms[index]?.startsWith(prefix)) return index;\n }\n return -1;\n };\n const before = this.#typing(time) ? this.#typed : '';\n let typed = before + key;\n let index = find(typed);\n if (index < 0 && before !== '') {\n typed = key;\n index = find(typed);\n }\n this.#typed = index < 0 ? '' : typed;\n this.#typedAt = time;\n if (index >= 0) this.active = index;\n return index >= 0;\n }\n\n /**\n * Dropdown list keys (the APG select-only combobox): closed, Enter, Space and the arrows open it (Home and End on\n * the first and the last option); open, the arrows, Home, End, PageUp and PageDown move, Enter, Space and\n * Alt+ArrowUp pick and close, Escape closes, Tab picks and moves on. Typing opens it and jumps (type-ahead); Space\n * goes on typing while the typed text and a space start an option (\"the p...\").\n */\n #listKey = (event: KeyboardEvent): void => {\n if (event.ctrlKey || event.metaKey || event.isComposing) return;\n const { key } = event;\n const last = this.options.length - 1;\n const open = this.expanded;\n const handled = (): void => event.preventDefault();\n if (key === 'Tab') {\n if (open) this.#commit();\n return;\n }\n if (key === 'Escape') {\n if (!open) return;\n handled();\n event.stopPropagation();\n this.#collapse();\n return;\n }\n if (key === 'ArrowDown' || key === 'ArrowUp') {\n handled();\n if (!open) this.#show(this.#pickedIndex());\n else if (event.altKey) {\n if (key === 'ArrowUp') this.#commit();\n } else if (key === 'ArrowDown') this.active = this.active < 0 ? 0 : Math.min(this.active + 1, last);\n else this.active = this.active < 0 ? last : Math.max(this.active - 1, 0);\n return;\n }\n if (key === 'Home' || key === 'End') {\n handled();\n this.#show(key === 'Home' ? 0 : last);\n return;\n }\n if (key === 'PageUp' || key === 'PageDown') {\n if (!open) return;\n handled();\n this.active = key === 'PageDown' ? Math.min(this.active + PAGE, last) : Math.max(this.active - PAGE, 0);\n return;\n }\n if (key === ' ' && open && this.#typing(event.timeStamp) && this.#typeAhead(key, event.timeStamp)) {\n handled();\n return;\n }\n if (key === 'Enter' || key === ' ') {\n handled();\n if (open) this.#commit();\n else this.#show(this.#pickedIndex());\n return;\n }\n if ([...key].length === 1 && !event.altKey) {\n handled();\n if (!open) this.#show(this.#pickedIndex());\n this.#typeAhead(key, event.timeStamp);\n }\n };\n\n #key(event: KeyboardEvent): void {\n const list = this.#filtered(this.options);\n const last = list.length - 1;\n const handled = (): void => event.preventDefault();\n switch (event.key) {\n case 'ArrowDown':\n handled();\n if (event.altKey) this.#open(-1);\n else if (!this.expanded) this.#open(0);\n else this.active = Math.min(this.active + 1, last);\n break;\n case 'ArrowUp':\n handled();\n if (event.altKey) this.#collapse();\n else if (!this.expanded) this.#open(last);\n else this.active = Math.max(this.active - 1, 0);\n break;\n case 'Home':\n case 'End':\n // With visual focus in the list they move it there; otherwise they move the caret as usual.\n if (!this.expanded || this.active < 0) break;\n handled();\n this.active = event.key === 'Home' ? 0 : last;\n break;\n case 'Enter': {\n const item = this.expanded ? list[this.active] : undefined;\n if (item !== undefined) {\n handled();\n this.#pick(item);\n } else if (this.expanded) {\n handled();\n this.#collapse();\n }\n break;\n }\n case 'Escape':\n if (this.expanded) {\n handled();\n event.stopPropagation();\n this.#collapse();\n } else if ((this.query ?? '') !== '' || this.value !== '') {\n // Closed: Escape clears the field and the answer (the APG's optional behaviour).\n handled();\n this.query = '';\n this.updateValue('');\n }\n break;\n }\n }\n}\n\nexport const selectElement: ElementRegistration = {\n manifest: selectManifest,\n element: SelectElement,\n messages: selectUiMessages,\n};\n"],"mappings":"A,kPAIA,IAAMkB,EAAY,cAMLC,EAA8C,CACzD,CAAE,YAAW,OAAQ,KAAM,SAAUnB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECOMmB,EAAc,OAAO,cAAc,IAAM,EAEzCC,EAAgB,IAEhBC,EAAO,GAmBPC,EAAQ,UAERC,EAA2C,CAC/C,EAAG,IACH,EAAG,IACH,EAAG,IACH,EAAG,KACH,EAAG,KACH,EAAG,KACH,EAAG,GACL,EACMC,EAAW,cAOjB,SAASC,EAAW,EAAc,EAAsB,CACtD,IAAIC,EACJ,GAAI,CACF,EAAQC,EAAK,UAAU,MAAM,CAAC,CAAC,kBAAkBC,IAAS,GAAK,IAAA,GAAYA,CAAI,CACjF,MAAQ,CAEN,EAAQD,EAAK,UAAU,MAAM,CAAC,CAAC,YAAY,CAC7C,CACA,OAAOD,EACJ,UAAU,KAAK,CAAC,CAChB,QAAQJ,EAAO,EAAE,CAAC,CAClB,QAAQE,EAAW,GAAOD,EAAOM,IAAOA,CAAE,CAAC,CAC3C,QAAQ,QAAS,GAAG,CAAC,CACrB,KAAK,CACV,CAGA,IAAMC,GAAa,EAAc,IAC/BL,EAAWE,EAAMC,CAAI,GAAK,OAAO,KAAKD,CAAI,GAAKA,EAAK,KAAK,IAAM,GAAK,IAAM,IAEtEI,EAAU,CAAG,6HACbC,EAAY,CAAG,iMACfC,EAAQ,CAAG,kIAEXC,GAAQ,EAAm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,QAAU,MAErDgC,EAAQ,EACR,KAAK,MAAQ,GACb,KAAK,YAAY,EAAE,EAGzB,CACF,CACF,EAEaG,EAAqC,CAChD,SAAU/F,EACV,QAASyB,EACT,SAAUpB,CACZ,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=`0.3125em`,t=`0.75rem`,n=e=>`linear-gradient(${e},transparent calc(100% / 3 - .05em - .5px),currentColor calc(100% / 3 - .05em) calc(100% / 3 + .05em),transparent calc(100% / 3 + .05em + .5px))`;function r(r){return`${r}{appearance:none;padding-inline-end:calc(${t} + 2 * ${e} + 0.375rem);background-image:${n(`45deg`)},${n(`-45deg`)};background-size:calc(2 * ${e}) ${e};background-repeat:no-repeat;background-position:right ${t} center}${r}:dir(rtl){background-position:left ${t} center}@media (forced-colors:active){${r}{appearance:auto;background-image:none}}`}export{r as t};
|
|
2
|
+
//# sourceMappingURL=select-QZ35cyns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-QZ35cyns.js","names":["ARM","INSET","arm","angle","nativeSelectCss","selector"],"sources":["../../../../tokens/src/select.ts"],"sourcesContent":["/**\n * A native select's chevron. A module of its own: the player's first load takes `tokensCss`, and a bundler keeps all\n * of a module's exports in one chunk, so this goes only where a select needs it (the kit, a component's chunk).\n */\n/** Half the chevron's width (its height), its distance from the inner edge, and the room between it and the text. */\nconst ARM = '0.3125em';\nconst INSET = '0.75rem';\nconst ROOM = '0.375rem';\n/**\n * One arm in the chevron's box, which is twice as wide as high: a stroke 0.1em thick, its edges softened by half a\n * pixel, along the diagonal from a top corner to the middle of the bottom edge (a third of the way along a 45-degree\n * gradient line in such a box). Both arms in one box, so no seam parts them; its bottom edge cuts their tip flat.\n */\nconst arm = (angle: string): string =>\n `linear-gradient(${angle},transparent calc(100% / 3 - .05em - .5px),currentColor calc(100% / 3 - .05em) ` +\n 'calc(100% / 3 + .05em),transparent calc(100% / 3 + .05em + .5px))';\n\n/**\n * Native selects with a chevron of their own, inset from the inline end: the platform's arrow keeps a few pixels from\n * the border whatever the padding (Chromium), so `appearance: none` drops it and two gradients draw a chevron in the\n * text colour, with end padding that keeps the text clear of it. Mirrored in right-to-left text. Forced colours drop\n * gradients, so the platform's own arrow comes back there. `selector` is one selector, not a list (the right-to-left\n * rule appends `:dir(rtl)` to it). Goes after the rules that give the select its padding and background.\n */\nexport function nativeSelectCss(selector: string): string {\n return (\n `${selector}{appearance:none;padding-inline-end:calc(${INSET} + 2 * ${ARM} + ${ROOM});` +\n `background-image:${arm('45deg')},${arm('-45deg')};background-size:calc(2 * ${ARM}) ${ARM};` +\n `background-repeat:no-repeat;background-position:right ${INSET} center}` +\n `${selector}:dir(rtl){background-position:left ${INSET} center}` +\n `@media (forced-colors:active){${selector}{appearance:auto;background-image:none}}`\n );\n}\n"],"mappings":"AAKA,IAAMA,EAAM,WACNC,EAAQ,UAORC,EAAO,GACX,mBAAmBC,EAAM,kJAU3B,SAAgBC,EAAgB,EAA0B,CACxD,MACE,GAAGC,EAAS,2CAA2CJ,EAAM,SAASD,EAAI,gCACtDE,EAAI,OAAO,EAAE,GAAGA,EAAI,QAAQ,EAAE,4BAA4BF,EAAI,IAAIA,EAAI,yDACjCC,EAAM,UAC5DI,EAAS,qCAAqCJ,EAAM,wCACtBI,EAAS,yCAE9C,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as e,U as t}from"./definitions-
|
|
1
|
+
import{H as e,U as t}from"./definitions-BybSa1mq.js";import{Bt as n,C as r,E as i,Pt as a,Tt as o,Vt as s,dn as c,fn as l,jt as u}from"./runtime-C25QK5B0.js";import{n as d,r as f}from"./issue-list-CzSmohtT.js";var p=new Set([o,u,n,s,`ul`,`ol`,`blockquote`]),m=` `,h=/^[\t\n\f\r ]*$/;function g(n){let r;try{r=e(n)}catch{return n}return r.some(_)?t(r):v(r,0)??t(r)}var _=e=>l(e)&&(e.tag===`plaintext`||e.children.some(_));function v(e,t){return e.some(e=>e.type===`text`&&!h.test(e.value))?null:e.filter(e=>l(e)).map(e=>m.repeat(t)+y(e,t)).join(`
|
|
2
2
|
`)}function y(e,n){let r=p.has(e.tag)&&e.children.some(e=>l(e))?v(e.children,n+1):null;if(r===null)return t([e]);let i=t([c(e.tag,e.attrs)]),a=`</${e.tag}>`;return`${i.slice(0,-a.length)}\n${r}\n${m.repeat(n)}${a}`}var b=i`
|
|
3
3
|
.source {
|
|
4
4
|
display: grid;
|
|
@@ -26,4 +26,4 @@ outline-offset: var(--astl-focus-offset);
|
|
|
26
26
|
@input=${e=>o(e.target.value)}></textarea>
|
|
27
27
|
${f(i,t,null,n)}
|
|
28
28
|
</div>`}export{g as formatHtml,S as renderSource};
|
|
29
|
-
//# sourceMappingURL=source-view-
|
|
29
|
+
//# sourceMappingURL=source-view-gqFlZzwR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-view-
|
|
1
|
+
{"version":3,"file":"source-view-gqFlZzwR.js","names":["parseHtml","serializeHtml","COLUMNS_TAG","b","directionOf","DOC_TAG","COLUMN_TAG","element","isElement","PAGE_TAG","issueStyles","renderIssues","LAID_OUT","INDENT","WHITE_SPACE","formatHtml","nodes","source","endsInput","laidOut","node","depth","formatElement","inner","child","empty","end","sourceStyles","adopt","root","sheets","missing","sheet","renderSource","lang","authoring","text","errors","onInput","event"],"sources":["../../../../editor-tiptap/src/source-view.ts"],"sourcesContent":["/**\n * The source view of `<astl-editor>` (`part=\"source\"`): the document's HTML (content format 1) laid out for reading\n * (`formatHtml`) in a monospace text area, and under it the errors that keep the editor in this view. A module of its\n * own, imported when the view first opens, so the editor's first load goes without it.\n */\nimport {\n COLUMN_TAG,\n COLUMNS_TAG,\n DOC_TAG,\n directionOf,\n type ElementNode,\n element,\n type Node as HtmlNode,\n type Issue,\n isElement,\n PAGE_TAG,\n} from '@astl/core';\nimport { type Authoring, issueStyles, renderIssues } from '@astl/editor';\nimport { parseHtml, serializeHtml } from '@astl/engine';\nimport { css, html, type TemplateResult } from 'lit';\n\n/** Where formatHtml puts each child element on a line of its own: elements that hold blocks, not text. */\nconst LAID_OUT: ReadonlySet<string> = new Set([\n DOC_TAG,\n PAGE_TAG,\n COLUMNS_TAG,\n COLUMN_TAG,\n 'ul',\n 'ol',\n 'blockquote',\n]);\n\nconst INDENT = ' ';\n\n/** HTML inter-element white space (ASCII only, as in the HTML standard). */\nconst WHITE_SPACE = /^[\\t\\n\\f\\r ]*$/;\n\n/**\n * A source laid out for reading. In the document, a page, a layout, a column, a list and a quote (and at the top)\n * that hold elements and only inter-element white space, each child element goes on a line of its own, indented two\n * spaces per level, and the end tag on its own line: white space there means nothing to Astrolabe, to the editor or\n * to a browser. Everything else (paragraphs, headings, list items, figures, rules, components) is written as\n * `serializeHtml` writes it, on one line, so no white space is added where it would count: a component keeps its\n * children as data, text included.\n *\n * Dropping the added white space gives the same tree back, and formatting twice gives the same text. A source the\n * parser refuses comes back as it is.\n */\nexport function formatHtml(source: string): string {\n let nodes: HtmlNode[];\n try {\n nodes = parseHtml(source);\n } catch {\n return source;\n }\n // `<plaintext>` takes the rest of the input as its text: no line may follow it.\n return nodes.some(endsInput) ? serializeHtml(nodes) : (laidOut(nodes, 0) ?? serializeHtml(nodes));\n}\n\nconst endsInput = (node: HtmlNode): boolean =>\n isElement(node) && (node.tag === 'plaintext' || node.children.some(endsInput));\n\n/** Each element of `nodes` on a line of its own, `depth` levels in; null when they hold text. */\nfunction laidOut(nodes: readonly HtmlNode[], depth: number): string | null {\n if (nodes.some((node) => node.type === 'text' && !WHITE_SPACE.test(node.value))) return null;\n return nodes\n .filter((node): node is ElementNode => isElement(node))\n .map((node) => INDENT.repeat(depth) + formatElement(node, depth))\n .join('\\n');\n}\n\nfunction formatElement(node: ElementNode, depth: number): string {\n const inner =\n LAID_OUT.has(node.tag) && node.children.some((child) => isElement(child))\n ? laidOut(node.children, depth + 1)\n : null;\n if (inner === null) return serializeHtml([node]);\n // The start tag as serializeHtml writes it: the element emptied, without its end tag.\n const empty = serializeHtml([element(node.tag, node.attrs)]);\n const end = `</${node.tag}>`;\n return `${empty.slice(0, -end.length)}\\n${inner}\\n${INDENT.repeat(depth)}${end}`;\n}\n\n// The text area grows with the laid-out source where the browser sizes fields by their content (`field-sizing`),\n// so the page scrolls rather than a box in it; elsewhere it keeps its height and scrolls.\nconst sourceStyles = css`\n .source {\n display: grid;\n gap: var(--astl-space-2);\n }\n .source textarea {\n box-sizing: border-box;\n inline-size: 100%;\n min-block-size: 24rem;\n field-sizing: content;\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-l);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: var(--astl-size-small) / 1.5 var(--astl-font-mono);\n }\n .source textarea:focus-visible {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: var(--astl-focus-offset);\n }\n`;\n\n/** Adopts the view's stylesheets into the shadow root holding `node`, once. */\nfunction adopt(node: Node): void {\n const root = node.getRootNode() as Partial<DocumentOrShadowRoot>;\n const sheets = [issueStyles.styleSheet, sourceStyles.styleSheet];\n if (root.adoptedStyleSheets === undefined || sheets.includes(undefined)) return;\n const missing = sheets.filter((sheet) => sheet !== undefined && !root.adoptedStyleSheets?.includes(sheet));\n if (missing.length > 0)\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, ...(missing as CSSStyleSheet[])];\n}\n\n/**\n * The view for `text` (what the author is editing) with `errors` listed under it (sentences of `describe`, nothing\n * focusable); `onInput` gets each edit.\n */\nexport function renderSource(\n root: Node,\n authoring: Authoring,\n text: string,\n errors: readonly Issue[],\n onInput: (text: string) => void,\n): TemplateResult {\n adopt(root);\n const lang = authoring.locale;\n return html`<div class=\"source\" part=\"source\" lang=${lang} dir=${directionOf(lang)}>\n <label for=\"source\">${authoring.t('astl.editor', 'view.sourceLabel')}</label>\n <textarea id=\"source\" dir=\"ltr\" spellcheck=\"false\" .value=${text} aria-invalid=${errors.length > 0}\n @input=${(event: Event) => onInput((event.target as HTML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IAAIK,GAC7E,CAIA,IAAMC,EAAe,CAAG;;;;;;;;;;;;;;;;;;;;;EAwBxB,SAASC,EAAM,EAAkB,CAC/B,IAAMC,EAAOT,EAAK,YAAY,EACxBU,EAAS,CAACpB,EAAY,WAAYiB,EAAa,UAAU,EAC/D,GAAIE,EAAK,qBAAuB,IAAA,IAAaC,EAAO,SAAS,IAAA,EAAS,EAAG,OACzE,IAAMC,EAAUD,EAAO,OAAQ,GAAUE,IAAU,IAAA,IAAa,CAACH,EAAK,oBAAoB,SAASG,CAAK,CAAC,EACrGD,EAAQ,OAAS,IACnB,EAAK,mBAAqB,CAAC,GAAGF,EAAK,mBAAoB,GAAIE,CAA2B,EAC1F,CAMA,SAAgBE,EACd,EACA,EACA,EACA,EACA,EACgB,CAChBL,EAAMC,CAAI,EACV,IAAMK,EAAOC,EAAU,OACvB,MAAO,EAAI,0CAA0CD,EAAK,OAAO9B,EAAY8B,CAAI,EAAE;0BAC3DC,EAAU,EAAE,cAAe,kBAAkB,EAAE;gEACTC,EAAK,gBAAgBC,EAAO,OAAS,EAAE;eACvF,GAAiBC,EAASC,EAAM,OAA+B,KAAK,EAAE;MAChF5B,EAAa0B,EAAQF,EAAW,KAAMC,CAAI,EAAE;SAElD,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,b as n}from"./runtime-
|
|
1
|
+
import{C as e,E as t,b as n}from"./runtime-C25QK5B0.js";import{c as r,i,n as a,o,p as s}from"./declarations-BhqOz1ap.js";import{a as c}from"./style-model-ZXNe_c8R.js";import{n as l,r as u}from"./styles-DiY3VA_T.js";import{t as d}from"./live-qnReIRtj.js";import{n as f,o as p,r as m,t as h}from"./style-placing-DPw1zyrz.js";import{t as g}from"./style-messages-B136zSom.js";import{n as _,t as v}from"./color-control-1kkdM8ns.js";var y={kind:`font`,property:`font-family`},b={kind:`number`,property:`width`,unit:`%`,min:1,max:100},x={kind:`position`,property:`position`},S=[y,{kind:`number`,property:`font-size`,unit:`px`,min:10,max:96},{kind:`select`,property:`font-weight`,options:[`normal`,`bold`]},{kind:`select`,property:`font-style`,options:[`normal`,`italic`]},{kind:`color`,property:`color`},{kind:`select`,property:`text-align`,options:[`start`,`center`,`end`,`justify`]},{kind:`number`,property:`line-height`,unit:``,min:.8,max:4,step:.05}],C=[{kind:`color`,property:`background-color`},{kind:`number`,property:`border-width`,unit:`px`,min:0,max:16},{kind:`select`,property:`border-style`,options:[`none`,`solid`,`dashed`,`dotted`,`double`]},{kind:`color`,property:`border-color`},{kind:`number`,property:`border-radius`,unit:`px`,min:0,max:128}],w=[{kind:`number`,property:`padding`,unit:`px`,min:0,max:64},{kind:`number`,property:`margin-block-start`,unit:`px`,min:0,max:128},{kind:`number`,property:`margin-block-end`,unit:`px`,min:0,max:128}],T=(e,t)=>{let n=[`text`,S],r=[`box`,C],i=[`spacing`,w],a=[`size`,[x,b]];switch(e){case`picture`:return t?[r]:[a,r];case`figure`:return[a,r,i,n];case`layout`:return[[`size`,[{kind:`number`,property:`gap`,unit:`px`,min:0,max:64},{kind:`select`,property:`align-items`,options:[`stretch`,`start`,`center`,`end`]}]],r,i,n];case`column`:return[[`size`,[{kind:`number`,property:`flex-grow`,unit:``,min:0,max:12}]],r,i,n];case`component`:return[n,r,i,a];case`named`:case`block`:return[n,r,i,[`size`,[b]]];default:return[n,r,i]}};function E(e,t){return e.length>2e3?[{name:`style`,reason:`length`}]:t.map(e=>({name:e,reason:i.includes(e)?`value`:/^-{0,2}[a-z][a-z-]*$/.test(e)?`property`:`text`}))}var D=(e,t)=>{let n=/^(\d*\.?\d+)([a-z%]*)$/.exec(e??``);if(n===null)return null;let[,r,i]=n;return i===t||r===`0`||t===``&&i===``?r:null},O=class extends u{static properties={...u.properties,target:{},rule:{attribute:!1}};static styles=[l,_,t`
|
|
2
2
|
.form {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -237,4 +237,4 @@ flex-basis: 100%;
|
|
|
237
237
|
</div>
|
|
238
238
|
</details>
|
|
239
239
|
</div>`}};export{O as AstlStyleForm};
|
|
240
|
-
//# sourceMappingURL=style-form-
|
|
240
|
+
//# sourceMappingURL=style-form-DuR0EEum.js.map
|