@team-monolith/cds 1.47.1 → 1.49.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.
@@ -30,11 +30,11 @@ export const light = {
30
30
  success: COLOR.green07,
31
31
  successActive: COLOR.green08,
32
32
  successDisabled: COLOR.green03,
33
- info: COLOR.teal08,
34
- infoActive: COLOR.teal09,
33
+ info: COLOR.teal06,
34
+ infoActive: COLOR.teal08,
35
35
  infoDisabled: COLOR.teal02,
36
- warning: COLOR.yellow08,
37
- warningActive: COLOR.yellow09,
36
+ warning: COLOR.yellow06,
37
+ warningActive: COLOR.yellow08,
38
38
  warningDisabled: COLOR.yellow02,
39
39
  inverse: COLOR.black,
40
40
  inverseActive: COLOR.grey08,
@@ -141,11 +141,11 @@ export const dark = {
141
141
  success: COLOR.green04,
142
142
  successActive: COLOR.green03,
143
143
  successDisabled: COLOR.green08,
144
- info: COLOR.teal03,
145
- infoActive: COLOR.teal02,
146
- infoDisabled: COLOR.teal09,
147
- warning: COLOR.yellow03,
148
- warningActive: COLOR.yellow02,
144
+ info: COLOR.teal06,
145
+ infoActive: COLOR.teal08,
146
+ infoDisabled: COLOR.teal02,
147
+ warning: COLOR.yellow08,
148
+ warningActive: COLOR.yellow06,
149
149
  warningDisabled: COLOR.yellow09,
150
150
  inverse: COLOR.white,
151
151
  inverseActive: COLOR.grey03,
@@ -15,6 +15,7 @@ import { LexicalCustomConfigContext } from "./LexicalCustomConfigContext";
15
15
  import { ProblemSelectNode } from "./nodes/ProblemSelectNode";
16
16
  import { LayoutContainerNode } from "./nodes/LayoutContainerNode";
17
17
  import { LayoutItemNode } from "./nodes/LayoutItemNode";
18
+ import _ from "lodash";
18
19
  function validateValue(value) {
19
20
  var _a, _b;
20
21
  if (value && typeof value !== "object") {
@@ -31,6 +32,25 @@ function validateValue(value) {
31
32
  }
32
33
  return true;
33
34
  }
35
+ /** undefined value를 제외한 객체 일치 여부를 판단합니다. */
36
+ function isCleanEqualObjects(oldObj, newObj) {
37
+ const cleanedOldObj = getCleanObject(oldObj);
38
+ const cleanedNewObj = getCleanObject(newObj);
39
+ return _.isEqual(cleanedOldObj, cleanedNewObj);
40
+ }
41
+ /** 객체 내에 undefined value를 갖는 key를 재귀적으로 모두 제거합니다. */
42
+ function getCleanObject(obj) {
43
+ const newObj = _.cloneDeep(obj);
44
+ for (const key in newObj) {
45
+ if (newObj[key] === undefined) {
46
+ delete newObj[key];
47
+ }
48
+ else if (_.isObject(newObj[key])) {
49
+ newObj[key] = getCleanObject(newObj[key]);
50
+ }
51
+ }
52
+ return newObj;
53
+ }
34
54
  export function LexicalEditor(props) {
35
55
  const { className, contentEditableClassName, value, onChange, editable = true, showQuizSolution = false, freezeProblemNode = false, isQuizEnabled = false, children, } = props;
36
56
  const theme = useTheme();
@@ -67,5 +87,17 @@ export function LexicalEditor(props) {
67
87
  editorState: validateValue(value) ? JSON.stringify(value) : undefined,
68
88
  editable: editable,
69
89
  };
70
- return (_jsx(LexicalCustomConfigContext.Provider, Object.assign({ value: { freezeProblemNode, showQuizSolution } }, { children: _jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { className: className, contentEditableClassName: contentEditableClassName, onChange: onChange, isQuizEnabled: isQuizEnabled }), _jsx(_Fragment, { children: children })] })) })));
90
+ /** onChangeHandler 도입 배경
91
+ * LayoutPlugIn이 알기 힘든 이슈로 blocks value중 indent key 등을 undefined로 만듭니다.
92
+ * 이로 인해, 렉시컬 RHF 폼에서 유저 상호작용 없이도 dirtyFields가 무의미하게 변화하게 되어, UX에 문제가 생깁니다.
93
+ * 이를 해결하기 위해, 유의미한 변경이 일어났을 때만 onChange를 호출합니다.
94
+ */
95
+ const onChangeHandler = onChange
96
+ ? (blocks) => {
97
+ if (!isCleanEqualObjects(value, blocks)) {
98
+ onChange(blocks);
99
+ }
100
+ }
101
+ : undefined;
102
+ return (_jsx(LexicalCustomConfigContext.Provider, Object.assign({ value: { freezeProblemNode, showQuizSolution } }, { children: _jsxs(LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [_jsx(Plugins, { className: className, contentEditableClassName: contentEditableClassName, onChange: onChangeHandler, isQuizEnabled: isQuizEnabled }), _jsx(_Fragment, { children: children })] })) })));
71
103
  }
@@ -2,4 +2,4 @@
2
2
  import { LexicalCommand } from "lexical";
3
3
  import { ProblemSelectPayload } from "../../nodes/ProblemSelectNode";
4
4
  export declare const INSERT_PROBLEM_SELECT_COMMAND: LexicalCommand<ProblemSelectPayload>;
5
- export default function ProblemInputPlugin(): JSX.Element | null;
5
+ export default function ProblemSelectPlugin(): JSX.Element | null;
@@ -4,7 +4,7 @@ import { COMMAND_PRIORITY_EDITOR, createCommand, } from "lexical";
4
4
  import { useEffect } from "react";
5
5
  import { $createProblemSelectNode, ProblemSelectNode, } from "../../nodes/ProblemSelectNode";
6
6
  export const INSERT_PROBLEM_SELECT_COMMAND = createCommand("INSERT_PROBLEM_SELECT_COMMAND");
7
- export default function ProblemInputPlugin() {
7
+ export default function ProblemSelectPlugin() {
8
8
  const [editor] = useLexicalComposerContext();
9
9
  useEffect(() => {
10
10
  if (!editor.hasNodes([ProblemSelectNode])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.47.1",
3
+ "version": "1.49.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,
@@ -15,6 +15,7 @@
15
15
  "@types/react-dom": "^18.2.13",
16
16
  "hex-to-css-filter": "^5.4.0",
17
17
  "lexical": "^0.12.4",
18
+ "lodash": "^4.17.21",
18
19
  "react": "^18.2.0",
19
20
  "react-dom": "^18.2.0",
20
21
  "react-hook-form": "^7.48.2",