@yungu-fed/question-editor 0.1.13 → 0.2.1

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.
Files changed (48) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1948 -1652
  4. package/dist/index.mjs +1156 -919
  5. package/dist/question/player/QuestionBlankGroupPlayer.d.ts +3 -3
  6. package/dist/question/player/QuestionBlankGroupPlayer.d.ts.map +1 -1
  7. package/dist/question/player/QuestionClassificationPlayer.d.ts +3 -3
  8. package/dist/question/player/QuestionClassificationPlayer.d.ts.map +1 -1
  9. package/dist/question/player/QuestionFillTextCandidateButton.d.ts +1 -1
  10. package/dist/question/player/QuestionFillTextCandidateButton.d.ts.map +1 -1
  11. package/dist/question/player/QuestionFillTextContentPlayer.d.ts +1 -1
  12. package/dist/question/player/QuestionFillTextContentPlayer.d.ts.map +1 -1
  13. package/dist/question/player/QuestionFillTextPlayer.d.ts +3 -3
  14. package/dist/question/player/QuestionFillTextPlayer.d.ts.map +1 -1
  15. package/dist/question/player/QuestionJudgementGroupPlayer.d.ts +3 -3
  16. package/dist/question/player/QuestionJudgementGroupPlayer.d.ts.map +1 -1
  17. package/dist/question/player/QuestionLineConnectPlayer.d.ts +3 -3
  18. package/dist/question/player/QuestionLineConnectPlayer.d.ts.map +1 -1
  19. package/dist/question/player/QuestionMatchingPlayer.d.ts +3 -3
  20. package/dist/question/player/QuestionMatchingPlayer.d.ts.map +1 -1
  21. package/dist/question/player/QuestionOptionGroupPlayer.d.ts +3 -3
  22. package/dist/question/player/QuestionOptionGroupPlayer.d.ts.map +1 -1
  23. package/dist/question/player/QuestionOrderingPlayer.d.ts +3 -3
  24. package/dist/question/player/QuestionOrderingPlayer.d.ts.map +1 -1
  25. package/dist/question/player/QuestionPlayer.d.ts.map +1 -1
  26. package/dist/question/player/QuestionPlayerComposite.d.ts +4 -4
  27. package/dist/question/player/QuestionPlayerComposite.d.ts.map +1 -1
  28. package/dist/question/player/QuestionPlayerElement.d.ts +3 -3
  29. package/dist/question/player/QuestionPlayerElement.d.ts.map +1 -1
  30. package/dist/question/player/QuestionTextMarkerPlayer.d.ts +3 -3
  31. package/dist/question/player/QuestionTextMarkerPlayer.d.ts.map +1 -1
  32. package/dist/question/player/QuestionTextResponsePlayer.d.ts +3 -3
  33. package/dist/question/player/QuestionTextResponsePlayer.d.ts.map +1 -1
  34. package/dist/question/player/QuestionWordBuilderPlayer.d.ts +3 -3
  35. package/dist/question/player/QuestionWordBuilderPlayer.d.ts.map +1 -1
  36. package/dist/question/player/helpers.d.ts +18 -16
  37. package/dist/question/player/helpers.d.ts.map +1 -1
  38. package/dist/question/player/response-contract.d.ts +8 -0
  39. package/dist/question/player/response-contract.d.ts.map +1 -0
  40. package/dist/question/player/types.d.ts +30 -35
  41. package/dist/question/player/types.d.ts.map +1 -1
  42. package/dist/question/player/view-response-types.d.ts +61 -0
  43. package/dist/question/player/view-response-types.d.ts.map +1 -0
  44. package/dist/question/presentation-contract.d.ts +20 -0
  45. package/dist/question/presentation-contract.d.ts.map +1 -0
  46. package/dist/question/preview/QuestionPreview.d.ts +3 -2
  47. package/dist/question/preview/QuestionPreview.d.ts.map +1 -1
  48. package/package.json +15 -15
@@ -0,0 +1,61 @@
1
+ import type { QuestionRichContentValue, QuestionJudgementValues } from "../content-editor/types";
2
+ export type QuestionPlayerFillTextAnswer = {
3
+ kind: "option";
4
+ optionIds: string[];
5
+ } | {
6
+ kind: "text";
7
+ value: string;
8
+ };
9
+ export type QuestionPlayerOptionGroupViewResponseItem = {
10
+ selectedOptionIds: string[];
11
+ type: "choice";
12
+ };
13
+ export type QuestionPlayerBlankGroupViewResponseItem = {
14
+ answers: Record<string, string>;
15
+ type: "fill";
16
+ };
17
+ export type QuestionPlayerFillTextViewResponseItem = {
18
+ answers: Record<string, QuestionPlayerFillTextAnswer>;
19
+ type: "inlineFill";
20
+ };
21
+ export type QuestionPlayerWordBuilderViewResponseItem = {
22
+ answers: Record<string, string>;
23
+ type: "wordBuilder";
24
+ };
25
+ export type QuestionPlayerJudgementGroupViewResponseItem = {
26
+ selectedValues: QuestionJudgementValues;
27
+ type: "judgement";
28
+ };
29
+ export type QuestionPlayerClassificationViewResponseItem = {
30
+ placements: Record<string, string>;
31
+ type: "classification";
32
+ };
33
+ export type QuestionPlayerLineConnectViewResponseItem = {
34
+ connections: Record<string, string[]>;
35
+ type: "lineConnect";
36
+ };
37
+ export type QuestionPlayerMatchingViewResponseItem = {
38
+ connections: Record<string, string[]>;
39
+ type: "matching";
40
+ };
41
+ export type QuestionPlayerOrderingViewResponseItem = {
42
+ orderedOptionIds: string[];
43
+ type: "ordering";
44
+ };
45
+ export type QuestionPlayerTextMarkerViewResponseItem = {
46
+ selectedMarkers: string[];
47
+ type: "textMarker";
48
+ };
49
+ export type QuestionPlayerTextResponseViewItem = {
50
+ readonly content: QuestionRichContentValue;
51
+ readonly type: "textResponse";
52
+ };
53
+ export type QuestionPlayerViewResponseItem = QuestionPlayerBlankGroupViewResponseItem | QuestionPlayerClassificationViewResponseItem | QuestionPlayerFillTextViewResponseItem | QuestionPlayerJudgementGroupViewResponseItem | QuestionPlayerLineConnectViewResponseItem | QuestionPlayerMatchingViewResponseItem | QuestionPlayerOrderingViewResponseItem | QuestionPlayerOptionGroupViewResponseItem | QuestionPlayerTextMarkerViewResponseItem | QuestionPlayerTextResponseViewItem | QuestionPlayerWordBuilderViewResponseItem;
54
+ export type QuestionPlayerViewResponse = {
55
+ questionTypeKey: null | number;
56
+ children: QuestionPlayerViewResponse[];
57
+ id: null | number;
58
+ items: QuestionPlayerViewResponseItem[];
59
+ version: string;
60
+ };
61
+ //# sourceMappingURL=view-response-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-response-types.d.ts","sourceRoot":"","sources":["../../../src/question/player/view-response-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAA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CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAAG;IACrD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,8BAA8B,GACtC,wCAAwC,GACxC,4CAA4C,GAC5C,sCAAsC,GACtC,4CAA4C,GAC5C,yCAAyC,GACzC,sCAAsC,GACtC,sCAAsC,GACtC,yCAAyC,GACzC,wCAAwC,GACxC,kCAAkC,GAClC,yCAAyC,CAAC;AAE9C,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC;IAC/B,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,EAAE,EAAE,IAAI,GAAG,MAAM,CAAC;IAClB,KAAK,EAAE,8BAA8B,EAAE,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ChoiceAnswers } from "../model/types";
2
+ import type { QuestionContentDraft, QuestionContentExtraItem, QuestionContentItem, QuestionContentOptionGroupItem, QuestionContentQuestionTypeTemplate } from "./content-editor/types";
3
+ export type QuestionPresentationChoiceItem = {
4
+ readonly answers?: ChoiceAnswers;
5
+ readonly columns: QuestionContentOptionGroupItem["columns"];
6
+ readonly options: QuestionContentOptionGroupItem["options"];
7
+ readonly type: "choice";
8
+ };
9
+ export type QuestionPresentationItem = Exclude<QuestionContentItem, QuestionContentOptionGroupItem> | QuestionPresentationChoiceItem;
10
+ export type QuestionPresentationDraft = {
11
+ readonly questionTypeKey: null | number;
12
+ readonly children: readonly QuestionPresentationDraft[];
13
+ readonly elements: readonly QuestionPresentationItem[];
14
+ readonly extras: readonly QuestionContentExtraItem[];
15
+ readonly id: null | number;
16
+ readonly version: string;
17
+ };
18
+ export declare function reconcileQuestionPresentationDraftWithTemplates(value: QuestionPresentationDraft, templates: readonly QuestionContentQuestionTypeTemplate[]): QuestionContentDraft;
19
+ export declare function normalizeQuestionPresentationDraft(value: QuestionPresentationDraft): QuestionContentDraft;
20
+ //# sourceMappingURL=presentation-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presentation-contract.d.ts","sourceRoot":"","sources":["../../src/question/presentation-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,8BAA8B,EAC9B,mCAAmC,EACpC,MAAM,wBAAwB,CAAC;AAIhC,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC,SAAS,CAAC,CAAC;IAC5D,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC,SAAS,CAAC,CAAC;IAC5D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAChC,OAAO,CAAC,mBAAmB,EAAE,8BAA8B,CAAC,GAC5D,8BAA8B,CAAC;AAEnC,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACxD,QAAQ,CAAC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACvD,QAAQ,CAAC,MAAM,EAAE,SAAS,wBAAwB,EAAE,CAAC;IACrD,QAAQ,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,+CAA+C,CAC7D,KAAK,EAAE,yBAAyB,EAChC,SAAS,EAAE,SAAS,mCAAmC,EAAE,GACxD,oBAAoB,CAKtB;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,yBAAyB,GAC/B,oBAAoB,CAStB"}
@@ -1,13 +1,14 @@
1
1
  import type { ReactElement } from "react";
2
- import type { QuestionContentDraft, QuestionContentQuestionTypeTemplate } from "../content-editor/types";
2
+ import type { QuestionContentQuestionTypeTemplate } from "../content-editor/types";
3
3
  import type { QuestionLocale } from "../i18n";
4
+ import type { QuestionPresentationDraft } from "../presentation-contract";
4
5
  export type QuestionPreviewProps = {
5
6
  className?: string;
6
7
  locale?: QuestionLocale;
7
8
  showAnswer?: boolean;
8
9
  showExtraAttributes?: boolean;
9
10
  questionTypeTemplates: readonly QuestionContentQuestionTypeTemplate[];
10
- value: QuestionContentDraft;
11
+ value: QuestionPresentationDraft;
11
12
  };
12
13
  export declare function QuestionPreview({ locale, ...props }: Readonly<QuestionPreviewProps>): ReactElement;
13
14
  //# sourceMappingURL=QuestionPreview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuestionPreview.d.ts","sourceRoot":"","sources":["../../../src/question/preview/QuestionPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EACV,oBAAoB,EAMpB,mCAAmC,EACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,SAAS,CAAC;AAgBjB,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB,EAAE,SAAS,mCAAmC,EAAE,CAAC;IACtE,KAAK,EAAE,oBAAoB,CAAC;CAC7B,CAAC;AAOF,wBAAgB,eAAe,CAC7B,EAAE,MAAgB,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAC7D,YAAY,CAad"}
1
+ {"version":3,"file":"QuestionPreview.d.ts","sourceRoot":"","sources":["../../../src/question/preview/QuestionPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAOV,mCAAmC,EACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAgB1E,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB,EAAE,SAAS,mCAAmC,EAAE,CAAC;IACtE,KAAK,EAAE,yBAAyB,CAAC;CAClC,CAAC;AAQF,wBAAgB,eAAe,CAC7B,EAAE,MAAgB,EAAE,GAAG,KAAK,EAAE,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAC7D,YAAY,CAad"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yungu-fed/question-editor",
3
3
  "private": false,
4
- "version": "0.1.13",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -21,19 +21,6 @@
21
21
  "dist",
22
22
  "README.md"
23
23
  ],
24
- "scripts": {
25
- "build": "pnpm run typecheck && vite build && tsc -p tsconfig.types.json",
26
- "build:watch": "vite build --watch",
27
- "build-ladle": "ladle build --viteConfig ./ladle.vite.config.ts",
28
- "check": "pnpm run checkstyle && pnpm run lint && pnpm run test && pnpm run build && pnpm run build-ladle",
29
- "checkstyle": "stylelint \"src/**/*.css\" --allow-empty-input",
30
- "ladle": "ladle serve --viteConfig ./ladle.vite.config.ts",
31
- "lint": "eslint .",
32
- "test": "vitest run --passWithNoTests",
33
- "test:coverage": "vitest run --coverage",
34
- "test:watch": "vitest",
35
- "typecheck": "tsc -b"
36
- },
37
24
  "peerDependencies": {
38
25
  "@types/react": ">=16.14.0 <20",
39
26
  "react": ">=16.14.0 <20",
@@ -84,5 +71,18 @@
84
71
  "dependencies": {
85
72
  "@yungu-fed/rich-text-editor": "^0.1.5",
86
73
  "ulid": "^3.0.2"
74
+ },
75
+ "scripts": {
76
+ "build": "pnpm run typecheck && vite build && tsc -p tsconfig.types.json",
77
+ "build:watch": "vite build --watch",
78
+ "build-ladle": "ladle build --viteConfig ./ladle.vite.config.ts",
79
+ "check": "pnpm run checkstyle && pnpm run lint && pnpm run test && pnpm run build && pnpm run build-ladle",
80
+ "checkstyle": "stylelint \"src/**/*.css\" --allow-empty-input",
81
+ "ladle": "ladle serve --viteConfig ./ladle.vite.config.ts",
82
+ "lint": "eslint .",
83
+ "test": "vitest run --passWithNoTests",
84
+ "test:coverage": "vitest run --coverage",
85
+ "test:watch": "vitest",
86
+ "typecheck": "tsc -b"
87
87
  }
88
- }
88
+ }