@team-monolith/cds 1.96.0 → 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.
@@ -1,5 +1,6 @@
1
1
  import { ImageProps } from "../../../components/InsertImageDialog";
2
2
  export interface SelectBoxViewProps {
3
+ multipleSelectionsEnabled: boolean;
3
4
  index: number;
4
5
  isSelected: boolean;
5
6
  isAnswer?: boolean;
@@ -20,15 +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 selectBoxType = isSelected
26
- ? isAnswer === undefined
27
- ? "primary"
28
- : isAnswer
29
- ? "success"
30
- : "danger"
31
- : undefined;
54
+ const { multipleSelectionsEnabled, index, isSelected, isAnswer, image, text, onClick, } = props;
55
+ const { type, description } = getTypeAndDescription(isSelected, isAnswer, onClick);
32
56
  const boxRef = useRef(null);
33
57
  const handleKeyDown = (e) => {
34
58
  // onClick이 없으면 아무것도 하지 않음.
@@ -50,7 +74,7 @@ export function SelectBoxView(props) {
50
74
  const ariaText = text || (image && image.altText) || index.toString() + "번 선택지";
51
75
  return (_jsx(SelectBoxComponent, { css: css `
52
76
  width: 100%;
53
- `, ref: boxRef, role: onClick ? "checkbox" : undefined, "aria-checked": isSelected, "aria-label": onClick ? ariaText + (isSelected ? " 선택됨" : " 선택하기") : ariaText, tabIndex: onClick ? 0 : -1, type: selectBoxType, index: selectBoxType ? TYPE_TO_INDEX_ICON(selectBoxType) : 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,
54
78
  // 선택되지 않았으나 정답일 때 정답 태그를 표시
55
79
  endIcon: isAnswer &&
56
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 showMultipleSolutions = hasMultipleSolutions ||
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(_Fragment, { children: [showMultipleSolutions && (_jsxs(Alert, { children: [_jsx(AlarmWarningFillIcon, { css: css `
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 (showMultipleSolutions) {
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 `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.96.0",
3
+ "version": "1.96.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,