@team-monolith/cds 1.96.1 → 1.96.2
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/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxView.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxView.js +33 -26
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +9 -5
- package/package.json +1 -1
|
@@ -20,24 +20,39 @@ const TYPE_TO_INDEX_ICON = (type) => ({
|
|
|
20
20
|
height: 12px;
|
|
21
21
|
` })),
|
|
22
22
|
})[type];
|
|
23
|
+
/**
|
|
24
|
+
* isSelected, isAnswer, onClick에 따른 type, description 내용
|
|
25
|
+
* /images/2025-05-05-01-25-06.png
|
|
26
|
+
*/
|
|
27
|
+
function getTypeAndDescription(isSelected, isAnswer, onClick) {
|
|
28
|
+
if (isAnswer === undefined) {
|
|
29
|
+
return {
|
|
30
|
+
type: isSelected ? "primary" : undefined,
|
|
31
|
+
description: isSelected ? "선택됨" : onClick ? "선택하기" : "",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (isAnswer) {
|
|
35
|
+
return {
|
|
36
|
+
type: isSelected ? "success" : undefined,
|
|
37
|
+
description: isSelected
|
|
38
|
+
? "선택됨, 정답"
|
|
39
|
+
: onClick
|
|
40
|
+
? "선택하기, 정답"
|
|
41
|
+
: "정답",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
type: isSelected ? "danger" : undefined,
|
|
46
|
+
description: isSelected
|
|
47
|
+
? "선택됨, 오답"
|
|
48
|
+
: onClick
|
|
49
|
+
? "선택하기, 오답"
|
|
50
|
+
: "오답",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
23
53
|
export function SelectBoxView(props) {
|
|
24
|
-
const { index, isSelected, isAnswer, image, text, onClick } = props;
|
|
25
|
-
const
|
|
26
|
-
? isAnswer === undefined
|
|
27
|
-
? {
|
|
28
|
-
type: "primary",
|
|
29
|
-
description: "선택됨",
|
|
30
|
-
}
|
|
31
|
-
: isAnswer
|
|
32
|
-
? {
|
|
33
|
-
type: "success",
|
|
34
|
-
description: "선택됨, 정답",
|
|
35
|
-
}
|
|
36
|
-
: {
|
|
37
|
-
type: "danger",
|
|
38
|
-
description: "선택됨, 오답",
|
|
39
|
-
}
|
|
40
|
-
: null;
|
|
54
|
+
const { multipleSelectionsEnabled, index, isSelected, isAnswer, image, text, onClick, } = props;
|
|
55
|
+
const { type, description } = getTypeAndDescription(isSelected, isAnswer, onClick);
|
|
41
56
|
const boxRef = useRef(null);
|
|
42
57
|
const handleKeyDown = (e) => {
|
|
43
58
|
// onClick이 없으면 아무것도 하지 않음.
|
|
@@ -59,15 +74,7 @@ export function SelectBoxView(props) {
|
|
|
59
74
|
const ariaText = text || (image && image.altText) || index.toString() + "번 선택지";
|
|
60
75
|
return (_jsx(SelectBoxComponent, { css: css `
|
|
61
76
|
width: 100%;
|
|
62
|
-
`, ref: boxRef, role:
|
|
63
|
-
? ariaText +
|
|
64
|
-
" " +
|
|
65
|
-
(selectedTypeAndDescription
|
|
66
|
-
? selectedTypeAndDescription.description
|
|
67
|
-
: "선택하기")
|
|
68
|
-
: ariaText, tabIndex: onClick ? 0 : -1, type: selectedTypeAndDescription === null || selectedTypeAndDescription === void 0 ? void 0 : selectedTypeAndDescription.type, index: selectedTypeAndDescription
|
|
69
|
-
? TYPE_TO_INDEX_ICON(selectedTypeAndDescription.type)
|
|
70
|
-
: index, image: image, text: text, onClick: onClick,
|
|
77
|
+
`, ref: boxRef, role: multipleSelectionsEnabled ? "checkbox" : "radio", "aria-checked": isSelected, "aria-disabled": !onClick, "aria-label": [ariaText, description].filter(Boolean).join(" "), tabIndex: onClick ? 0 : -1, type: type, index: type ? TYPE_TO_INDEX_ICON(type) : index, image: image, text: text, onClick: onClick,
|
|
71
78
|
// 선택되지 않았으나 정답일 때 정답 태그를 표시
|
|
72
79
|
endIcon: isAnswer &&
|
|
73
80
|
!isSelected && (_jsx(Tag, { label: "\uC815\uB2F5", icon: _jsx(CheckboxCircleFillIcon, {}), color: "green", css: css `
|
|
@@ -18,15 +18,19 @@ export function SelectComponent(props) {
|
|
|
18
18
|
const [settingOpen, setSettingOpen] = useState(false);
|
|
19
19
|
const isEditable = useLexicalEditable();
|
|
20
20
|
const { freezeProblemNode, showQuizSolution } = useContext(LexicalCustomConfigContext);
|
|
21
|
-
const
|
|
21
|
+
const multipleSelectionsEnabled = hasMultipleSolutions ||
|
|
22
22
|
(hasMultipleSolutions === undefined &&
|
|
23
23
|
selections.filter((s) => "isAnswer" in s && s.isAnswer).length > 1);
|
|
24
24
|
// view
|
|
25
25
|
if (!isEditable) {
|
|
26
|
-
return (_jsxs(
|
|
26
|
+
return (_jsxs("div", Object.assign({ role: multipleSelectionsEnabled ? "group" : "radiogroup", css: css `
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 4px;
|
|
30
|
+
` }, { children: [multipleSelectionsEnabled && (_jsxs(Alert, { children: [_jsx(AlarmWarningFillIcon, { css: css `
|
|
27
31
|
width: 14px;
|
|
28
32
|
height: 14px;
|
|
29
|
-
` }), "\uC9C8\uBB38\uC5D0 \uD574\uB2F9\uD558\uB294 \uB2F5\uC744 \uBAA8\uB450 \uACE0\uB974\uB294 \uBB38\uC81C\uC785\uB2C8\uB2E4."] })), selections.map((selection, index) => (_jsx(SelectBoxView, { index: index + 1, isAnswer: showQuizSolution && "isAnswer" in selection
|
|
33
|
+
` }), "\uC9C8\uBB38\uC5D0 \uD574\uB2F9\uD558\uB294 \uB2F5\uC744 \uBAA8\uB450 \uACE0\uB974\uB294 \uBB38\uC81C\uC785\uB2C8\uB2E4."] })), selections.map((selection, index) => (_jsx(SelectBoxView, { multipleSelectionsEnabled: multipleSelectionsEnabled, index: index + 1, isAnswer: showQuizSolution && "isAnswer" in selection
|
|
30
34
|
? selection.isAnswer
|
|
31
35
|
: undefined, isSelected: selected.includes(selection.value), image: selection.show.image, text: selection.show.text, onClick: freezeProblemNode
|
|
32
36
|
? undefined
|
|
@@ -47,7 +51,7 @@ export function SelectComponent(props) {
|
|
|
47
51
|
if (!$isProblemSelectNode(node)) {
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
50
|
-
if (
|
|
54
|
+
if (multipleSelectionsEnabled) {
|
|
51
55
|
node.setSelected([...selected, selection.value]);
|
|
52
56
|
}
|
|
53
57
|
else {
|
|
@@ -55,7 +59,7 @@ export function SelectComponent(props) {
|
|
|
55
59
|
}
|
|
56
60
|
});
|
|
57
61
|
}
|
|
58
|
-
} }, index)))] }));
|
|
62
|
+
} }, index)))] })));
|
|
59
63
|
}
|
|
60
64
|
// 교사 edit view
|
|
61
65
|
return (_jsxs(_Fragment, { children: [_jsxs("div", Object.assign({ css: css `
|