@eliceio/cdk-cli 1.4.0 → 1.5.0
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/README.md +17 -16
- package/es/cli.js +1 -1
- package/es/commands/create/index.js +1 -0
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/core/config.d.ts +36 -0
- package/es/core/config.js +234 -6
- package/es/core/quiz-check.js +123 -4
- package/es/dev/grading.d.ts +26 -4
- package/es/dev/grading.js +66 -11
- package/es/dev/mock-api.d.ts +6 -1
- package/es/dev/mock-api.js +45 -6
- package/es/rules/answers.d.ts +1 -0
- package/es/rules/answers.js +8 -0
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +1 -1
- package/skills/_shared/always.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +8 -7
- package/skills/_shared/references/03-create-the-project.md +10 -9
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
- package/skills/_shared/references/16-using-the-survey-template.md +158 -0
- package/skills/elice-content-create/SKILL.md +2 -2
- package/skills/elice-content-edit/SKILL.md +2 -2
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +22 -3
- package/templates/_shared/lib/cdk-mock.js +78 -11
- package/templates/_shared/lib/elice-content.d.ts +17 -1
- package/templates/_shared/lib/elice-content.js +47 -5
- package/templates/blank/template.json +1 -1
- package/templates/document/template.json +1 -1
- package/templates/quiz/README.md +26 -1
- package/templates/quiz/core/behaviors.d.ts +5 -0
- package/templates/quiz/core/behaviors.js +16 -1
- package/templates/quiz/core/model.d.ts +78 -1
- package/templates/quiz/core/model.js +219 -4
- package/templates/quiz/screens/edit.js +244 -55
- package/templates/quiz/screens/learn.js +137 -27
- package/templates/quiz/styles.css +258 -5
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/templates/edit.d.ts +1 -0
- package/templates/quiz/ui/templates/edit.js +67 -8
- package/templates/quiz/ui/templates/page.js +34 -0
- package/templates/quiz/ui/templates/text.js +15 -2
- package/templates/quiz/ui/texts.js +61 -0
- package/templates/steps/template.json +1 -1
- package/templates/survey/README.md +112 -0
- package/templates/survey/commentary.txt +2 -0
- package/templates/survey/core/behaviors.d.ts +14 -0
- package/templates/survey/core/behaviors.js +115 -0
- package/templates/survey/core/dom.d.ts +13 -0
- package/templates/survey/core/dom.js +83 -0
- package/templates/survey/core/editor.d.ts +80 -0
- package/templates/survey/core/editor.js +720 -0
- package/templates/survey/core/markdown.d.ts +21 -0
- package/templates/survey/core/markdown.js +298 -0
- package/templates/survey/core/model.d.ts +83 -0
- package/templates/survey/core/model.js +209 -0
- package/templates/survey/core/rich-text.d.ts +18 -0
- package/templates/survey/core/rich-text.js +469 -0
- package/templates/survey/edit.html +26 -0
- package/templates/survey/gitignore +4 -0
- package/templates/survey/index.html +26 -0
- package/templates/survey/metadata.json +9 -0
- package/templates/survey/package.json +13 -0
- package/templates/survey/screens/edit.js +345 -0
- package/templates/survey/screens/learn.js +100 -0
- package/templates/survey/styles.css +1264 -0
- package/templates/survey/template.json +6 -0
- package/templates/survey/ui/templates/edit.d.ts +27 -0
- package/templates/survey/ui/templates/edit.js +656 -0
- package/templates/survey/ui/templates/index.d.ts +3 -0
- package/templates/survey/ui/templates/index.js +3 -0
- package/templates/survey/ui/templates/learn.js +147 -0
- package/templates/survey/ui/templates/page.js +19 -0
- package/templates/survey/ui/texts.d.ts +3 -0
- package/templates/survey/ui/texts.js +116 -0
- package/templates/survey/ui/theme.css +42 -0
- package/templates/video/template.json +10 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ui/templates/edit.js 타입 (테스트용). 각 조각이 남겨야 할 data-role은 edit.js에 적혀 있습니다.
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
type Template = (props?: any) => any;
|
|
4
|
+
|
|
5
|
+
export declare const inlineField: Template;
|
|
6
|
+
export declare const richField: Template;
|
|
7
|
+
export declare const blockText: Template;
|
|
8
|
+
export declare const blockImage: Template;
|
|
9
|
+
export declare const mdTools: Template;
|
|
10
|
+
export declare const section: Template;
|
|
11
|
+
export declare const reveal: Template;
|
|
12
|
+
export declare const list: Template;
|
|
13
|
+
export declare const row: Template;
|
|
14
|
+
export declare const addButton: Template;
|
|
15
|
+
export declare const otherRow: Template;
|
|
16
|
+
export declare const otherAdd: Template;
|
|
17
|
+
export declare const pickButton: Template;
|
|
18
|
+
export declare const scaleEditor: Template;
|
|
19
|
+
export declare const endField: Template;
|
|
20
|
+
export declare const textPreview: Template;
|
|
21
|
+
export declare const requiredSwitch: Template;
|
|
22
|
+
export declare const typeMenu: Template;
|
|
23
|
+
export declare const card: Template;
|
|
24
|
+
export declare const infoCard: Template;
|
|
25
|
+
export declare const snackbar: Template;
|
|
26
|
+
export declare const addQuestion: Template;
|
|
27
|
+
export declare const formWrap: Template;
|
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
// 내용 편집 화면(CMS)의 HTML 조각. 값 넣기 · 입력 반영 · 끌어서 순서 바꾸기 · 고르기 목록은 core/editor.js가 붙입니다.
|
|
2
|
+
// 마크업 · 클래스는 자유롭게 바꿔도 되고, 각 조각에 적힌 data-role만 남기면 동작이 그대로입니다.
|
|
3
|
+
// 입력 칸에는 값을 넣지 않습니다 (동작이 value로 넣음). 퀴즈 템플릿의 편집 조각에서 정답 칸을 빼고 설문 칸(필수 응답 · 기타 · 척도)을 더했습니다.
|
|
4
|
+
import { html } from '../../core/dom.js';
|
|
5
|
+
import { texts } from '../texts.js';
|
|
6
|
+
|
|
7
|
+
const t = texts.edit;
|
|
8
|
+
/** 아이콘. 요소는 한 자리에만 들어가므로 쓸 때마다 새로 만든다 (색은 버튼 글자색을 따름) */
|
|
9
|
+
const icons = {
|
|
10
|
+
trash: () => html`
|
|
11
|
+
<svg
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
width="18"
|
|
14
|
+
height="18"
|
|
15
|
+
fill="none"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
stroke-width="2"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
>
|
|
22
|
+
<path
|
|
23
|
+
d="M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4h6v3"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
`,
|
|
27
|
+
info: () => html`
|
|
28
|
+
<svg
|
|
29
|
+
viewBox="0 0 24 24"
|
|
30
|
+
width="20"
|
|
31
|
+
height="20"
|
|
32
|
+
fill="none"
|
|
33
|
+
stroke="currentColor"
|
|
34
|
+
stroke-width="2"
|
|
35
|
+
stroke-linecap="round"
|
|
36
|
+
stroke-linejoin="round"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
<circle cx="12" cy="12" r="9" />
|
|
40
|
+
<path d="M12 11v5M12 8h.01" />
|
|
41
|
+
</svg>
|
|
42
|
+
`,
|
|
43
|
+
check: () => html`
|
|
44
|
+
<svg
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
width="20"
|
|
47
|
+
height="20"
|
|
48
|
+
fill="none"
|
|
49
|
+
stroke="currentColor"
|
|
50
|
+
stroke-width="2.5"
|
|
51
|
+
stroke-linecap="round"
|
|
52
|
+
stroke-linejoin="round"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
>
|
|
55
|
+
<path d="M5 12.5l4.5 4.5L19 7.5" />
|
|
56
|
+
</svg>
|
|
57
|
+
`,
|
|
58
|
+
textbox: () => html`
|
|
59
|
+
<svg
|
|
60
|
+
viewBox="0 0 24 24"
|
|
61
|
+
width="18"
|
|
62
|
+
height="18"
|
|
63
|
+
fill="none"
|
|
64
|
+
stroke="currentColor"
|
|
65
|
+
stroke-width="2"
|
|
66
|
+
stroke-linecap="round"
|
|
67
|
+
stroke-linejoin="round"
|
|
68
|
+
aria-hidden="true"
|
|
69
|
+
>
|
|
70
|
+
<rect x="3" y="6" width="18" height="12" rx="2" />
|
|
71
|
+
<path d="M8 10v4" />
|
|
72
|
+
</svg>
|
|
73
|
+
`,
|
|
74
|
+
// 설명 추가 (말풍선 줄)
|
|
75
|
+
comment: () => html`
|
|
76
|
+
<svg
|
|
77
|
+
viewBox="0 0 24 24"
|
|
78
|
+
width="18"
|
|
79
|
+
height="18"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
stroke-width="2"
|
|
83
|
+
stroke-linecap="round"
|
|
84
|
+
stroke-linejoin="round"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
>
|
|
87
|
+
<path d="M5 3.5h14a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-8.2L6 20.5v-4H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2z" />
|
|
88
|
+
<path d="M7.5 8.5h9M7.5 12h6" />
|
|
89
|
+
</svg>
|
|
90
|
+
`,
|
|
91
|
+
chevronDown: () => html`
|
|
92
|
+
<svg
|
|
93
|
+
viewBox="0 0 24 24"
|
|
94
|
+
width="16"
|
|
95
|
+
height="16"
|
|
96
|
+
fill="none"
|
|
97
|
+
stroke="currentColor"
|
|
98
|
+
stroke-width="2.5"
|
|
99
|
+
stroke-linecap="round"
|
|
100
|
+
stroke-linejoin="round"
|
|
101
|
+
aria-hidden="true"
|
|
102
|
+
>
|
|
103
|
+
<path d="M6 9l6 6 6-6" />
|
|
104
|
+
</svg>
|
|
105
|
+
`,
|
|
106
|
+
align: () => html`
|
|
107
|
+
<svg
|
|
108
|
+
viewBox="0 0 24 24"
|
|
109
|
+
width="18"
|
|
110
|
+
height="18"
|
|
111
|
+
fill="none"
|
|
112
|
+
stroke="currentColor"
|
|
113
|
+
stroke-width="2"
|
|
114
|
+
stroke-linecap="round"
|
|
115
|
+
stroke-linejoin="round"
|
|
116
|
+
aria-hidden="true"
|
|
117
|
+
>
|
|
118
|
+
<path d="M4 6h16M4 10h10M4 14h16M4 18h10" />
|
|
119
|
+
</svg>
|
|
120
|
+
`,
|
|
121
|
+
bulb: () => html`
|
|
122
|
+
<svg
|
|
123
|
+
viewBox="0 0 24 24"
|
|
124
|
+
width="18"
|
|
125
|
+
height="18"
|
|
126
|
+
fill="none"
|
|
127
|
+
stroke="currentColor"
|
|
128
|
+
stroke-width="2"
|
|
129
|
+
stroke-linecap="round"
|
|
130
|
+
stroke-linejoin="round"
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
>
|
|
133
|
+
<path
|
|
134
|
+
d="M9 18h6M10 21h4M12 3a6 6 0 0 0-3.5 10.9c.6.5 1 1.2 1 2.1h5c0-.9.4-1.6 1-2.1A6 6 0 0 0 12 3z"
|
|
135
|
+
/>
|
|
136
|
+
</svg>
|
|
137
|
+
`,
|
|
138
|
+
shuffle: () => html`
|
|
139
|
+
<svg
|
|
140
|
+
viewBox="0 0 24 24"
|
|
141
|
+
width="16"
|
|
142
|
+
height="16"
|
|
143
|
+
fill="none"
|
|
144
|
+
stroke="currentColor"
|
|
145
|
+
stroke-width="2"
|
|
146
|
+
stroke-linecap="round"
|
|
147
|
+
stroke-linejoin="round"
|
|
148
|
+
aria-hidden="true"
|
|
149
|
+
>
|
|
150
|
+
<path d="M16 3h5v5M4 20 21 3M21 16v5h-5M15 15l6 6M4 4l5 5" />
|
|
151
|
+
</svg>
|
|
152
|
+
`,
|
|
153
|
+
plus: () => html`
|
|
154
|
+
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
|
|
155
|
+
<path d="M12 5v14M5 12h14" />
|
|
156
|
+
</svg>
|
|
157
|
+
`,
|
|
158
|
+
xmark: () => html`
|
|
159
|
+
<svg
|
|
160
|
+
viewBox="0 0 24 24"
|
|
161
|
+
width="18"
|
|
162
|
+
height="18"
|
|
163
|
+
fill="none"
|
|
164
|
+
stroke="currentColor"
|
|
165
|
+
stroke-width="2"
|
|
166
|
+
stroke-linecap="round"
|
|
167
|
+
aria-hidden="true"
|
|
168
|
+
>
|
|
169
|
+
<path d="M6 6l12 12M18 6L6 18" />
|
|
170
|
+
</svg>
|
|
171
|
+
`,
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* 라벨 없는 바로 쓰는 칸 (퀴즈 제목 · 안내, 질문 · 설명). 보이는 라벨 대신 placeholder와 글자 크기로 무슨 칸인지 알리고,
|
|
175
|
+
* 화면 낭독기에는 aria-label로 이름을 준다. size: 'title'(퀴즈 제목) · 'question'(질문) · 'body'(안내 · 설명)
|
|
176
|
+
* data-role="input" (input · textarea) · max가 있고 showCount가 false가 아니면 data-role="count" (글자 수, 칸에 초점이 있을 때만 보임)
|
|
177
|
+
* showCount: false면 max(입력 제한)는 지키되 글자 수 표시는 뺀다
|
|
178
|
+
* 필수 칸은 data-required: 비운 채 저장하면 동작이 aria-invalid를 붙인다 (빨간 밑줄)
|
|
179
|
+
*/
|
|
180
|
+
export const inlineField = ({
|
|
181
|
+
label,
|
|
182
|
+
placeholder,
|
|
183
|
+
size = "body",
|
|
184
|
+
required = false,
|
|
185
|
+
max,
|
|
186
|
+
showCount = true,
|
|
187
|
+
multiline = false,
|
|
188
|
+
}) => html`
|
|
189
|
+
<div class="qe-inline qe-inline-${size} ec-field ec-field-${size}">
|
|
190
|
+
${
|
|
191
|
+
multiline
|
|
192
|
+
? html`<textarea
|
|
193
|
+
class="qe-inline-input ec-field-input"
|
|
194
|
+
data-role="input"
|
|
195
|
+
rows="1"
|
|
196
|
+
aria-label="${label}"
|
|
197
|
+
placeholder="${placeholder}"
|
|
198
|
+
${required && "data-required aria-required=true"}
|
|
199
|
+
></textarea>`
|
|
200
|
+
: html`<input
|
|
201
|
+
class="qe-inline-input ec-field-input"
|
|
202
|
+
data-role="input"
|
|
203
|
+
aria-label="${label}"
|
|
204
|
+
placeholder="${placeholder}"
|
|
205
|
+
${required && "data-required aria-required=true"}
|
|
206
|
+
/>`
|
|
207
|
+
}
|
|
208
|
+
${max && showCount && html`<span class="qe-count ec-field-count" data-role="count"></span>`}
|
|
209
|
+
</div>
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 지문 · 해설 칸 (보이는 그대로 고치는 글 칸과 올린 그림 칸이 차례로). 동작(core/editor.js richField)이 칸을 채운다.
|
|
214
|
+
* data-role="input" (값을 든 숨은 textarea) · "blocks" (글 칸 blockText · 그림 칸 blockImage가 들어가는 자리)
|
|
215
|
+
*/
|
|
216
|
+
export const richField = ({ label }) => html`
|
|
217
|
+
<div class="qe-inline qe-inline-body qe-blocks ec-field ec-field-body" role="group" aria-label="${label}">
|
|
218
|
+
<textarea data-role="input" hidden tabindex="-1" aria-hidden="true"></textarea>
|
|
219
|
+
<div class="qe-blocks-list" data-role="blocks"></div>
|
|
220
|
+
</div>
|
|
221
|
+
`;
|
|
222
|
+
|
|
223
|
+
/** 글 칸 (contenteditable). 비어 있으면 data-empty가 붙어 placeholder 글을 보인다 */
|
|
224
|
+
export const blockText = ({ label, placeholder }) => html`
|
|
225
|
+
<div
|
|
226
|
+
class="qe-inline-input qe-wys qz-markdown"
|
|
227
|
+
data-role="block-text"
|
|
228
|
+
contenteditable="true"
|
|
229
|
+
role="textbox"
|
|
230
|
+
aria-multiline="true"
|
|
231
|
+
aria-label="${label}"
|
|
232
|
+
data-placeholder="${placeholder}"
|
|
233
|
+
></div>
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
/** 올린 그림 칸. data-role="block-remove" (그림 지우기) */
|
|
237
|
+
export const blockImage = ({ alt, src, removeLabel }) => html`
|
|
238
|
+
<figure class="qe-block-image">
|
|
239
|
+
${src && html`<img src="${src}" alt="${alt}" />`}
|
|
240
|
+
<button
|
|
241
|
+
type="button"
|
|
242
|
+
class="qe-block-remove"
|
|
243
|
+
data-role="block-remove"
|
|
244
|
+
aria-label="${removeLabel}"
|
|
245
|
+
title="${removeLabel}"
|
|
246
|
+
>
|
|
247
|
+
${icons.xmark()}
|
|
248
|
+
</button>
|
|
249
|
+
</figure>
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
const toolIcon = {
|
|
253
|
+
ul: () => html`
|
|
254
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
255
|
+
<line x1="8" y1="6" x2="21" y2="6" /><line x1="8" y1="12" x2="21" y2="12" /><line x1="8" y1="18" x2="21" y2="18" />
|
|
256
|
+
<line x1="3" y1="6" x2="3.01" y2="6" /><line x1="3" y1="12" x2="3.01" y2="12" /><line x1="3" y1="18" x2="3.01" y2="18" />
|
|
257
|
+
</svg>
|
|
258
|
+
`,
|
|
259
|
+
ol: () => html`
|
|
260
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
261
|
+
<line x1="10" x2="21" y1="6" y2="6" /><line x1="10" x2="21" y1="12" y2="12" /><line x1="10" x2="21" y1="18" y2="18" />
|
|
262
|
+
<path d="M4 6h1v4" /><path d="M4 10h2" /><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" />
|
|
263
|
+
</svg>
|
|
264
|
+
`,
|
|
265
|
+
code: () => html`
|
|
266
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
267
|
+
<polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" />
|
|
268
|
+
</svg>
|
|
269
|
+
`,
|
|
270
|
+
image: () => html`
|
|
271
|
+
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
272
|
+
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" />
|
|
273
|
+
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />
|
|
274
|
+
</svg>
|
|
275
|
+
`,
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 지문 · 해설 서식 도구 (칸에 초점이 있을 때 칸 아래에 뜸). 버튼마다 data-role:
|
|
280
|
+
* "md-bold" · "md-italic" · "md-strike" · "md-ul" · "md-ol" · "md-code" · "md-image" (그림 올리기, 못 쓰면 동작이 숨김)
|
|
281
|
+
*/
|
|
282
|
+
export const mdTools = () => {
|
|
283
|
+
const m = t.md;
|
|
284
|
+
const tool = (role, name, glyph) => html`
|
|
285
|
+
<button type="button" class="qe-md-btn" data-role="${role}" aria-label="${name}" title="${name}" aria-pressed="false">
|
|
286
|
+
${glyph}
|
|
287
|
+
</button>
|
|
288
|
+
`;
|
|
289
|
+
return html`
|
|
290
|
+
<div class="qe-md" role="toolbar" aria-label="${m.toolbar}">
|
|
291
|
+
${tool("md-bold", m.bold, html`<b>B</b>`)} ${tool("md-italic", m.italic, html`<i>I</i>`)}
|
|
292
|
+
${tool("md-strike", m.strike, html`<s>S</s>`)}
|
|
293
|
+
<span class="qe-md-sep" aria-hidden="true"></span>
|
|
294
|
+
${tool("md-ul", m.ul, toolIcon.ul())} ${tool("md-ol", m.ol, toolIcon.ol())}
|
|
295
|
+
<span class="qe-md-sep" aria-hidden="true"></span>
|
|
296
|
+
${tool("md-code", m.code, toolIcon.code())}
|
|
297
|
+
<button type="button" class="qe-md-btn" data-role="md-image" aria-label="${m.image}" title="${m.image}">
|
|
298
|
+
${toolIcon.image()}
|
|
299
|
+
</button>
|
|
300
|
+
</div>
|
|
301
|
+
`;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 제목이 붙은 묶음 (보기). action: 제목줄 오른쪽에 둘 요소
|
|
306
|
+
*/
|
|
307
|
+
export const section = ({ label, body }) => html`
|
|
308
|
+
<div class="qe-section ec-section">
|
|
309
|
+
<div class="qe-section-head ec-section-head">
|
|
310
|
+
<span class="qe-label ec-label">${label}</span>
|
|
311
|
+
</div>
|
|
312
|
+
${body}
|
|
313
|
+
</div>
|
|
314
|
+
`;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 필요할 때만 여는 칸 (설명 · 해설). 닫혀 있으면 윤곽선 알약 버튼만 보인다.
|
|
318
|
+
* title이 있으면(해설) 열렸을 때 머리줄(아이콘 · 제목 · 지우기)이 있는 카드 안에 칸을 둔다.
|
|
319
|
+
* data-role="reveal" (열기 버튼) · "reveal-body" (열린 칸 묶음, 닫히면 hidden) · "reveal-close" (비우고 닫기)
|
|
320
|
+
* icon: icons의 이름 (예: 'bulb') · hint: 이름 옆에 두는 보조 글자 (글을 써도 사라지지 않는 안내)
|
|
321
|
+
*/
|
|
322
|
+
const revealClose = (name, glyph) => html`
|
|
323
|
+
<button
|
|
324
|
+
type="button"
|
|
325
|
+
class="ec-icon-button ec-danger"
|
|
326
|
+
data-role="reveal-close"
|
|
327
|
+
aria-label="${t.revealClose(name)}"
|
|
328
|
+
title="${t.revealClose(name)}"
|
|
329
|
+
>
|
|
330
|
+
${glyph}
|
|
331
|
+
</button>
|
|
332
|
+
`;
|
|
333
|
+
|
|
334
|
+
export const reveal = ({ label, field, title, icon, hint }) =>
|
|
335
|
+
title
|
|
336
|
+
? html`
|
|
337
|
+
<div class="qe-reveal qe-reveal-card ec-reveal">
|
|
338
|
+
<button type="button" class="qe-reveal-button ec-reveal-button" data-role="reveal">
|
|
339
|
+
${icon && icons[icon]?.()}<span>${label}</span
|
|
340
|
+
><span aria-hidden="true">+</span>
|
|
341
|
+
</button>
|
|
342
|
+
<div class="qe-reveal-body ec-reveal-body" data-role="reveal-body">
|
|
343
|
+
<div class="qe-reveal-head ec-reveal-head">
|
|
344
|
+
${icon && icons[icon]?.()}<strong>${title}</strong>
|
|
345
|
+
${hint && html`<span class="qe-reveal-hint ec-hint-inline" title="${hint}">${hint}</span>`}
|
|
346
|
+
${revealClose(title, icons.trash())}
|
|
347
|
+
</div>
|
|
348
|
+
<div class="qe-reveal-field">${field}</div>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
`
|
|
352
|
+
: html`
|
|
353
|
+
<div class="qe-reveal ec-reveal">
|
|
354
|
+
<button type="button" class="qe-reveal-button ec-reveal-button" data-role="reveal">
|
|
355
|
+
${label}
|
|
356
|
+
</button>
|
|
357
|
+
<div class="qe-reveal-body ec-reveal-body" data-role="reveal-body">
|
|
358
|
+
${field} ${revealClose(label, icons.xmark())}
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
`;
|
|
362
|
+
|
|
363
|
+
/** 보기 목록. rows: row()들 (같은 부모 아래 형제로 두어야 끌어서 순서 바꾸기가 됨) · add: 추가 버튼 */
|
|
364
|
+
export const list = ({ rows, add }) => html`<div class="qe-options ec-list">${rows}${add}</div>`;
|
|
365
|
+
|
|
366
|
+
/** 보기 줄 앞 표시 (학생이 볼 단추 모양: 단일 선택은 동그라미, 다중 선택은 네모) */
|
|
367
|
+
const mark = (type) => html`<span class="sv-mark ${type === 'checkbox' ? 'is-check' : 'is-radio'}" aria-hidden="true"></span>`;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* 보기 한 줄. index: 0부터 · canDelete: 최소 개수보다 많음 · answer.type: 'radio'(단일) · 'checkbox'(다중)로 앞 표시 모양만 정한다
|
|
371
|
+
* data-role="handle" (끌기 손잡이) · data-role="input" · data-role="delete"
|
|
372
|
+
*/
|
|
373
|
+
export const row = ({ index, canDelete, min, answer }) => html`
|
|
374
|
+
<div class="qe-option ec-list-row">
|
|
375
|
+
<button
|
|
376
|
+
type="button"
|
|
377
|
+
class="qe-handle ec-handle"
|
|
378
|
+
data-role="handle"
|
|
379
|
+
aria-label="${t.sortLabel(t.option(index + 1))}"
|
|
380
|
+
title="${t.sortTitle}"
|
|
381
|
+
>
|
|
382
|
+
${t.handle}
|
|
383
|
+
</button>
|
|
384
|
+
${mark(answer?.type)}
|
|
385
|
+
<span class="qe-option-field">
|
|
386
|
+
<input
|
|
387
|
+
class="qe-inline-input qe-option-text ec-field-input"
|
|
388
|
+
data-role="input"
|
|
389
|
+
aria-label="${t.option(index + 1)}"
|
|
390
|
+
placeholder="${t.option(index + 1)}"
|
|
391
|
+
/>
|
|
392
|
+
</span>
|
|
393
|
+
<button
|
|
394
|
+
type="button"
|
|
395
|
+
class="ec-icon-button ec-danger"
|
|
396
|
+
data-role="delete"
|
|
397
|
+
aria-label="${t.optionDelete(index + 1)}"
|
|
398
|
+
title="${canDelete ? '' : t.optionsMin(min)}"
|
|
399
|
+
${!canDelete && 'disabled'}
|
|
400
|
+
>
|
|
401
|
+
${icons.xmark()}
|
|
402
|
+
</button>
|
|
403
|
+
</div>
|
|
404
|
+
`;
|
|
405
|
+
|
|
406
|
+
/** 목록 끝의 "+ 보기 추가". full: 최대 개수에 닿음 */
|
|
407
|
+
export const addButton = ({ full, max }) => html`
|
|
408
|
+
<button type="button" class="qe-add ec-list-add" title="${full ? t.optionsMax(max) : ''}" ${full && 'disabled'}>
|
|
409
|
+
${t.addOption}
|
|
410
|
+
</button>
|
|
411
|
+
`;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* '기타(자유 입력)' 줄 (보기 목록 끝, "+ 보기 추가" 앞): 학생이 직접 쓰는 칸이 있다는 표시. data-role="other-delete"
|
|
415
|
+
*/
|
|
416
|
+
export const otherRow = ({ type }) => html`
|
|
417
|
+
<div class="qe-option ec-list-row sv-other-row">
|
|
418
|
+
<span class="qe-handle ec-handle sv-handle-space" aria-hidden="true"></span>
|
|
419
|
+
${mark(type)}
|
|
420
|
+
<span class="qe-option-field sv-other-field">
|
|
421
|
+
<span class="sv-other-label">${t.other}</span>
|
|
422
|
+
<span class="sv-other-preview" aria-hidden="true">${t.otherPreview}</span>
|
|
423
|
+
</span>
|
|
424
|
+
<button
|
|
425
|
+
type="button"
|
|
426
|
+
class="ec-icon-button ec-danger"
|
|
427
|
+
data-role="other-delete"
|
|
428
|
+
aria-label="${t.otherDelete}"
|
|
429
|
+
title="${t.otherDelete}"
|
|
430
|
+
>
|
|
431
|
+
${icons.xmark()}
|
|
432
|
+
</button>
|
|
433
|
+
</div>
|
|
434
|
+
`;
|
|
435
|
+
|
|
436
|
+
/** '기타'가 없을 때 그 자리의 "+ 기타(자유 입력) 추가". data-role="other-add" */
|
|
437
|
+
export const otherAdd = () => html`
|
|
438
|
+
<div class="qe-option ec-list-row sv-other-ghost">
|
|
439
|
+
<span class="qe-handle ec-handle sv-handle-space" aria-hidden="true"></span>
|
|
440
|
+
<button type="button" class="sv-other-add" data-role="other-add">
|
|
441
|
+
<span class="sv-mark-plus" aria-hidden="true">${icons.plus()}</span>${t.addOther}
|
|
442
|
+
</button>
|
|
443
|
+
</div>
|
|
444
|
+
`;
|
|
445
|
+
|
|
446
|
+
/** 고르기 버튼 (척도 시작값 · 끝값): 유형 버튼과 같은 회색 알약. 누르면 core/editor.js picker가 목록을 연다 */
|
|
447
|
+
export const pickButton = ({ label, value }) => html`
|
|
448
|
+
<button
|
|
449
|
+
type="button"
|
|
450
|
+
class="qe-type sv-scale-pick"
|
|
451
|
+
aria-haspopup="listbox"
|
|
452
|
+
aria-expanded="false"
|
|
453
|
+
aria-label="${label}"
|
|
454
|
+
>
|
|
455
|
+
<span class="qe-type-label">${value}</span>${icons.chevronDown()}
|
|
456
|
+
</button>
|
|
457
|
+
`;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* 척도 편집: "척도 [시작 ∨] ~ [끝 ∨]" · 학생이 볼 칸 미리보기(누를 수 없음) · 양 끝 이름 칸.
|
|
461
|
+
* min · max: pickButton · ends: endField 둘 · steps: 수들 · columns: { wide, narrow }
|
|
462
|
+
*/
|
|
463
|
+
export const scaleEditor = ({ min, max, steps, columns, ends }) => html`
|
|
464
|
+
<div class="qe-section ec-section">
|
|
465
|
+
<div class="sv-scale-range">
|
|
466
|
+
<span class="qe-label ec-label">${t.scale}</span>
|
|
467
|
+
${min}
|
|
468
|
+
<span aria-hidden="true">${t.scaleTo}</span>
|
|
469
|
+
${max}
|
|
470
|
+
</div>
|
|
471
|
+
<div
|
|
472
|
+
class="sv-scale-preview"
|
|
473
|
+
aria-hidden="true"
|
|
474
|
+
style="--sv-cols: ${columns.wide}; --sv-cols-narrow: ${columns.narrow}"
|
|
475
|
+
>
|
|
476
|
+
${steps.map((n) => html`<span>${n}</span>`)}
|
|
477
|
+
</div>
|
|
478
|
+
<div class="sv-ends">${ends}</div>
|
|
479
|
+
</div>
|
|
480
|
+
`;
|
|
481
|
+
|
|
482
|
+
/** 척도 끝 이름 칸 ("1 전혀 그렇지 않다"). data-role="input" */
|
|
483
|
+
export const endField = ({ no, placeholder }) => html`
|
|
484
|
+
<label class="sv-end">
|
|
485
|
+
<span class="sv-end-no">${no}</span>
|
|
486
|
+
<input
|
|
487
|
+
class="qe-inline-input ec-field-input"
|
|
488
|
+
data-role="input"
|
|
489
|
+
aria-label="${t.scaleEndLabel(no)}"
|
|
490
|
+
placeholder="${placeholder}"
|
|
491
|
+
/>
|
|
492
|
+
</label>
|
|
493
|
+
`;
|
|
494
|
+
|
|
495
|
+
/** 서술형: 학생이 쓸 칸 자리 표시 (누를 수 없음) */
|
|
496
|
+
export const textPreview = () => html`
|
|
497
|
+
<div class="qe-section ec-section">
|
|
498
|
+
<div class="sv-text-preview" aria-hidden="true">${t.textHint}</div>
|
|
499
|
+
</div>
|
|
500
|
+
`;
|
|
501
|
+
|
|
502
|
+
/** 필수 응답 스위치 (카드 머리). data-role="input" (checkbox role="switch") */
|
|
503
|
+
export const requiredSwitch = () => html`
|
|
504
|
+
<label class="sv-req-switch" title="${t.requiredTitle}">
|
|
505
|
+
<span class="sv-req-switch-label">${t.required}</span>
|
|
506
|
+
<span class="qe-sw"
|
|
507
|
+
><input type="checkbox" role="switch" data-role="input" /><span class="qe-sw-track" aria-hidden="true"></span
|
|
508
|
+
></span>
|
|
509
|
+
</label>
|
|
510
|
+
`;
|
|
511
|
+
|
|
512
|
+
/** 문항 유형 아이콘 (유형 고르기 앞 · 목록) */
|
|
513
|
+
const typeIcons = {
|
|
514
|
+
single: () => html`
|
|
515
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
516
|
+
<circle cx="12" cy="12" r="9" />
|
|
517
|
+
<circle cx="12" cy="12" r="3.5" fill="currentColor" stroke="none" />
|
|
518
|
+
</svg>
|
|
519
|
+
`,
|
|
520
|
+
multiple: () => html`
|
|
521
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
522
|
+
<rect x="4" y="4" width="16" height="16" rx="3" />
|
|
523
|
+
<path d="M8.5 12.5l2.5 2.5 4.5-5" />
|
|
524
|
+
</svg>
|
|
525
|
+
`,
|
|
526
|
+
scale: () => html`
|
|
527
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
528
|
+
<path d="M3 12h18" />
|
|
529
|
+
<circle cx="5" cy="12" r="1.8" fill="currentColor" />
|
|
530
|
+
<circle cx="12" cy="12" r="1.8" fill="currentColor" />
|
|
531
|
+
<circle cx="19" cy="12" r="1.8" fill="currentColor" />
|
|
532
|
+
</svg>
|
|
533
|
+
`,
|
|
534
|
+
text: () => html`
|
|
535
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
536
|
+
<rect x="3" y="6" width="18" height="12" rx="2" />
|
|
537
|
+
<path d="M8 10v4" />
|
|
538
|
+
</svg>
|
|
539
|
+
`,
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
const typeName = (types, value) => types.find(([v]) => v === value)?.[1] ?? '';
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* 유형 고르기 목록 (문제 카드의 유형 버튼을 누르면 버튼 아래에 뜬다). 열고 닫기 · 키보드는 core/editor.js가 붙인다.
|
|
546
|
+
* 꼭 남길 것: role="listbox", 항목마다 role="option" · data-value · aria-selected (고른 항목에는 체크)
|
|
547
|
+
*/
|
|
548
|
+
export const typeMenu = ({ label, types, value }) => html`
|
|
549
|
+
<div class="qe-menu" role="listbox" aria-label="${label}">
|
|
550
|
+
${types.map(
|
|
551
|
+
([v, name]) => html`
|
|
552
|
+
<div
|
|
553
|
+
class="qe-menu-item"
|
|
554
|
+
role="option"
|
|
555
|
+
tabindex="-1"
|
|
556
|
+
data-value="${v}"
|
|
557
|
+
aria-selected="${v === value ? "true" : "false"}"
|
|
558
|
+
>
|
|
559
|
+
${typeIcons[v]?.()}
|
|
560
|
+
<span class="qe-menu-label">${name}</span>
|
|
561
|
+
${v === value && html`<span class="qe-menu-check" aria-hidden="true">${icons.check()}</span>`}
|
|
562
|
+
</div>
|
|
563
|
+
`,
|
|
564
|
+
)}
|
|
565
|
+
</div>
|
|
566
|
+
`;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* 문항 카드. body: 문항 칸들 · types: [[값, 이름], …] · required: 필수 응답 스위치 (requiredSwitch)
|
|
570
|
+
* data-role="type" (유형 버튼: 누르면 typeMenu) · data-role="up" · data-role="down" · data-role="delete"
|
|
571
|
+
* 문항이 하나뿐이면 ↑ · ↓는 숨기고 삭제는 끈다 (설문에는 문항이 하나 이상 있어야 함)
|
|
572
|
+
*/
|
|
573
|
+
export const card = ({ q, index, count, types, body, required }) => html`
|
|
574
|
+
<section class="qe-card ec-edit-card">
|
|
575
|
+
<header class="qe-card-head ec-edit-card-head">
|
|
576
|
+
<strong>${t.question(index + 1)}</strong>
|
|
577
|
+
<button
|
|
578
|
+
type="button"
|
|
579
|
+
class="qe-type"
|
|
580
|
+
data-role="type"
|
|
581
|
+
data-value="${q.type}"
|
|
582
|
+
aria-haspopup="listbox"
|
|
583
|
+
aria-expanded="false"
|
|
584
|
+
aria-label="${t.questionTypeNow(index + 1, typeName(types, q.type))}"
|
|
585
|
+
>
|
|
586
|
+
${typeIcons[q.type]?.()}
|
|
587
|
+
<span class="qe-type-label">${typeName(types, q.type)}</span>
|
|
588
|
+
${icons.chevronDown()}
|
|
589
|
+
</button>
|
|
590
|
+
${required}
|
|
591
|
+
<span class="qe-head-sep" aria-hidden="true"></span>
|
|
592
|
+
<button
|
|
593
|
+
type="button"
|
|
594
|
+
class="ec-icon-button"
|
|
595
|
+
data-role="up"
|
|
596
|
+
aria-label="${t.questionUp(index + 1)}"
|
|
597
|
+
${index === 0 && 'disabled'}
|
|
598
|
+
${count === 1 && 'hidden'}
|
|
599
|
+
>
|
|
600
|
+
${t.up}
|
|
601
|
+
</button>
|
|
602
|
+
<button
|
|
603
|
+
type="button"
|
|
604
|
+
class="ec-icon-button"
|
|
605
|
+
data-role="down"
|
|
606
|
+
aria-label="${t.questionDown(index + 1)}"
|
|
607
|
+
${index === count - 1 && 'disabled'}
|
|
608
|
+
${count === 1 && 'hidden'}
|
|
609
|
+
>
|
|
610
|
+
${t.down}
|
|
611
|
+
</button>
|
|
612
|
+
<button
|
|
613
|
+
type="button"
|
|
614
|
+
class="ec-icon-button"
|
|
615
|
+
data-role="delete"
|
|
616
|
+
aria-label="${t.questionDelete(index + 1)}"
|
|
617
|
+
${count === 1 && 'disabled'}
|
|
618
|
+
>
|
|
619
|
+
${icons.trash()}
|
|
620
|
+
</button>
|
|
621
|
+
</header>
|
|
622
|
+
${body}
|
|
623
|
+
</section>
|
|
624
|
+
`;
|
|
625
|
+
|
|
626
|
+
/** 설문 안내 카드 (맨 위). field: 안내 칸 */
|
|
627
|
+
export const infoCard = ({ field }) => html`<section class="qe-card ec-edit-card qe-quiz-info">${field}</section>`;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* 스낵바 (EDS Snackbar · info): 짧은 알림 + 되돌리기(action이 없으면 알림만). 화면 아래에 떠 있다. data-role="undo" (되돌리기 버튼)
|
|
631
|
+
* 상태 알림이라 role="status" (초점을 가져가지 않고 낭독기가 읽음)
|
|
632
|
+
*/
|
|
633
|
+
export const snackbar = ({ text, action }) => html`
|
|
634
|
+
<div class="qe-snackbar ec-snackbar" role="status">
|
|
635
|
+
<span class="qe-snackbar-icon ec-snackbar-icon">${icons.info()}</span>
|
|
636
|
+
<span class="qe-snackbar-text ec-snackbar-text">${text}</span>
|
|
637
|
+
${action &&
|
|
638
|
+
html`<button type="button" class="qe-snackbar-action ec-snackbar-action" data-role="undo">
|
|
639
|
+
${action}
|
|
640
|
+
</button>`}
|
|
641
|
+
</div>
|
|
642
|
+
`;
|
|
643
|
+
|
|
644
|
+
/** 문항 추가 버튼. full: 최대 개수에 닿음 */
|
|
645
|
+
export const addQuestion = ({ full, max } = {}) =>
|
|
646
|
+
html`<button
|
|
647
|
+
type="button"
|
|
648
|
+
class="qe-add qe-add-question ec-add"
|
|
649
|
+
title="${full ? t.questionsMax(max) : ''}"
|
|
650
|
+
${full && 'disabled'}
|
|
651
|
+
>
|
|
652
|
+
${t.addQuestion}
|
|
653
|
+
</button>`;
|
|
654
|
+
|
|
655
|
+
/** 편집 화면 전체 묶음 (안내 카드 · 문항 카드들 · 문항 추가) */
|
|
656
|
+
export const formWrap = ({ children }) => html`<div class="sv-form">${children}</div>`;
|