@qti-components/test 1.10.0-next.3 → 2.0.0-next.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.
@@ -1,7 +1,14 @@
1
1
  import { LitElement } from 'lit';
2
- import type { TestHost } from '../../internal/test-host.context';
2
+ import type { View } from '@qti-components/base';
3
+ /**
4
+ * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
5
+ * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
6
+ * something switches it back (`test-view-toggle`).
7
+ *
8
+ * @attr view - The view to switch to after the attempt ended.
9
+ */
3
10
  export declare class TestCheckItem extends LitElement {
4
- protected testHost?: TestHost;
11
+ view: View;
5
12
  static styles: import("lit").CSSResult;
6
13
  constructor();
7
14
  render(): import("lit").TemplateResult<1>;
@@ -4,11 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { consume } from '@lit/context';
8
7
  import { css, html, LitElement } from 'lit';
9
- import { testHostContext } from '../../internal/test-host.context';
8
+ import { property } from 'lit/decorators.js';
10
9
  import * as styles from '../styles';
11
10
  import { dispatchPublic } from '../../public-events';
11
+ /**
12
+ * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which
13
+ * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until
14
+ * something switches it back (`test-view-toggle`).
15
+ *
16
+ * @attr view - The view to switch to after the attempt ended.
17
+ */
12
18
  export class TestCheckItem extends LitElement {
13
19
  static { this.styles = css `
14
20
  :host {
@@ -26,15 +32,10 @@ export class TestCheckItem extends LitElement {
26
32
  `; }
27
33
  constructor() {
28
34
  super();
35
+ this.view = 'scorer';
29
36
  this.addEventListener('click', () => {
30
37
  dispatchPublic(this, 'cito-test-end-attempt', {});
31
- const testContainer = this.testHost?.querySelector('test-container');
32
- if (!testContainer)
33
- return;
34
- const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));
35
- viewElements.forEach((element) => {
36
- element.classList.toggle('show', true);
37
- });
38
+ dispatchPublic(this, 'cito-test-switch-view', this.view);
38
39
  });
39
40
  }
40
41
  render() {
@@ -42,6 +43,6 @@ export class TestCheckItem extends LitElement {
42
43
  }
43
44
  }
44
45
  __decorate([
45
- consume({ context: testHostContext, subscribe: true })
46
- ], TestCheckItem.prototype, "testHost", void 0);
46
+ property({ type: String })
47
+ ], TestCheckItem.prototype, "view", void 0);
47
48
  //# sourceMappingURL=test-check-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,MAAM,OAAO,aAAc,SAAQ,UAAU;aAI3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAgB,gBAAgB,CAAC,CAAC;YACpF,IAAI,CAAC,aAAa;gBAAE,OAAO;YAE3B,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAErF,YAAY,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAlCS;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACzB","sourcesContent":["import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TestContainer } from '../test-container/test-container';\n\nexport class TestCheckItem extends LitElement {\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n const testContainer = this.testHost?.querySelector<TestContainer>('test-container');\n if (!testContainer) return;\n\n const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', true);\n });\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
1
+ {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAEF;QACE,KAAK,EAAE,CAAC;QAlBkB,SAAI,GAAS,QAAQ,CAAC;QAmBhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA3B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qti-components/test",
3
3
  "description": "QTI test utilities",
4
- "version": "1.10.0-next.3",
4
+ "version": "2.0.0-next.4",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",