@team-monolith/cds 1.9.9 → 1.10.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 (24) hide show
  1. package/dist/icons/Custom.d.ts +8 -0
  2. package/dist/icons/Custom.js +11 -0
  3. package/dist/icons/custom/pdf-color.svg +12 -0
  4. package/dist/icons/custom/pdf.svg +3 -0
  5. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.d.ts +2 -2
  6. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/ProblemSelectNode.js +1 -1
  7. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox.d.ts +1 -1
  8. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox.js +1 -1
  9. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectComponent.js +2 -7
  10. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/FormSelection.d.ts +3 -6
  11. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/FormSelection.js +39 -45
  12. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageDialog.d.ts +2 -2
  13. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageDialog.js +10 -7
  14. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageUploadedDialogBody.d.ts +4 -4
  15. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageUploadedDialogBody.js +5 -6
  16. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageUriDialogBody.d.ts +3 -4
  17. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/InsertImageUriDialogBody.js +4 -7
  18. package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SettingForm/SettingForm.js +17 -7
  19. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/InsertImageDialog.js +7 -6
  20. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/InsertImageUploadedDialogBody.d.ts +13 -4
  21. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/InsertImageUploadedDialogBody.js +5 -6
  22. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/InsertImageUriDialogBody.d.ts +9 -4
  23. package/dist/patterns/LexicalEditor/plugins/ImagesPlugin/InsertImageUriDialogBody.js +4 -7
  24. package/package.json +1 -1
@@ -87,3 +87,11 @@ export declare const customQuizColorSvg: string;
87
87
  export declare const CustomQuizColorIcon: React.ForwardRefExoticComponent<{
88
88
  className?: string | undefined;
89
89
  } & React.RefAttributes<any>>;
90
+ export declare const customPdfColorSvg: string;
91
+ export declare const CustomPdfColorIcon: React.ForwardRefExoticComponent<{
92
+ className?: string | undefined;
93
+ } & React.RefAttributes<any>>;
94
+ export declare const customPdfSvg: string;
95
+ export declare const CustomPdfIcon: React.ForwardRefExoticComponent<{
96
+ className?: string | undefined;
97
+ } & React.RefAttributes<any>>;
@@ -91,3 +91,14 @@ export const CustomQuizColorIcon = forwardRef((props, ref) => {
91
91
  const uniqueId = useMemo(uid, []);
92
92
  return (_jsxs("svg", Object.assign({}, props, { ref: ref, width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsxs("g", Object.assign({ clipPath: `url(#clip0_${uniqueId})` }, { children: [_jsx("path", { d: "M19.5238 19.81C19.5238 20.3913 19.2927 20.9478 18.8819 21.3584C18.4712 21.7691 17.9137 22.0002 17.3333 22.0002H4.19048C3.60913 22.0002 3.05258 21.7691 2.64186 21.3584C2.23115 20.9478 2 20.3903 2 19.81V6.09309C2 5.5118 2.23115 4.95531 2.64186 4.54463C3.05258 4.13396 3.61012 3.90283 4.19048 3.90283H17.3333C17.9147 3.90283 18.4712 4.13396 18.8819 4.54463C19.2927 4.95531 19.5238 5.51279 19.5238 6.09309V19.81C19.5238 20.3913 19.2927 20.9478 18.8819 21.3584C18.4712 21.7691 17.9137 22.0002 17.3333 22.0002", fill: "#FBEAF3" }), _jsx("path", { d: "M21.9999 17.9072C21.9999 18.4884 21.7687 19.0449 21.358 19.4556C20.9473 19.8663 20.3898 20.0974 19.8094 20.0974H6.66655C6.0852 20.0974 5.52865 19.8663 5.11794 19.4556C4.70723 19.0449 4.47607 18.4875 4.47607 17.9072V4.19026C4.47607 3.60897 4.70723 3.05247 5.11794 2.6418C5.52865 2.23113 6.08619 2 6.66655 2H19.8094C20.3908 2 20.9473 2.23113 21.358 2.6418C21.7687 3.05247 21.9999 3.60996 21.9999 4.19026V17.9072C21.9999 18.4884 21.7687 19.0449 21.358 19.4556C20.9473 19.8663 20.3898 20.0974 19.8094 20.0974", fill: "#F889AA" }), _jsx("path", { d: "M17.2836 14.917C18.4152 13.8846 19.0484 12.3944 19.0484 10.7363C19.0484 7.62109 16.8132 5.09766 13.2381 5.09766C9.66292 5.09766 7.42773 7.62274 7.42773 10.7363C7.42773 13.8499 9.66292 16.375 13.2381 16.375C14.044 16.375 14.7805 16.246 15.4394 16.0113L16.0651 16.9064C16.118 16.9833 16.2147 17.0172 16.304 16.9916L18.0341 16.494C18.1011 16.4742 18.1556 16.4237 18.1796 16.3568C18.2028 16.2907 18.1928 16.2171 18.1523 16.1584L17.2836 14.917ZM13.2381 13.6656C11.3815 13.6656 10.2192 12.3539 10.2192 10.7363C10.2192 9.11878 11.3798 7.80706 13.2381 7.80706C15.0963 7.80706 16.2569 9.11878 16.2569 10.7363C16.2569 11.4331 16.0403 12.0728 15.6468 12.5762L14.8864 11.4885C14.8326 11.4124 14.7367 11.3777 14.6475 11.4033L12.9165 11.9009C12.8496 11.9208 12.795 11.9712 12.771 12.0381C12.7479 12.1042 12.7578 12.1778 12.7983 12.2365L13.7696 13.6251C13.6001 13.6499 13.4241 13.6656 13.2381 13.6656Z", fill: "#FBEAF3" })] })), _jsx("defs", { children: _jsx("clipPath", Object.assign({ id: `clip0_${uniqueId}` }, { children: _jsx("rect", { width: "20", height: "20", fill: "white", transform: "translate(2 2)" }) })) })] })));
93
93
  });
94
+ import customPdfColorSvgImport from "./custom/pdf-color.svg";
95
+ export const customPdfColorSvg = customPdfColorSvgImport;
96
+ export const CustomPdfColorIcon = forwardRef((props, ref) => {
97
+ const uniqueId = useMemo(uid, []);
98
+ return (_jsxs("svg", Object.assign({}, props, { ref: ref, width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsxs("g", Object.assign({ clipPath: `url(#clip0_${uniqueId})` }, { children: [_jsx("path", { d: "M21 6.5V20.8C21 21.3839 20.7626 21.9428 20.3407 22.3553C19.9188 22.7678 19.3461 23 18.75 23H5.25C4.65285 23 4.08118 22.7678 3.65931 22.3553C3.23743 21.9428 3 21.3829 3 20.8V3.2C3 2.61612 3.23743 2.05716 3.65931 1.64466C4.08118 1.23216 4.65285 1 5.25 1H15.375L21 6.5Z", fill: "#FF5850" }), _jsx("path", { d: "M16.5 6.5H21L15.375 1V5.4C15.375 5.69194 15.4932 5.97192 15.7041 6.17817C15.9151 6.38442 16.2014 6.5 16.5 6.5Z", fill: "#F1E0E0" }), _jsx("path", { d: "M12.7437 6.80746H10.6651C10.5459 6.80746 10.4507 6.90052 10.4481 7.01705C10.4089 8.90249 9.84591 11.0932 8.91557 13.1195C7.98522 15.1502 6.7418 16.8982 5.43701 17.9757C5.35073 18.047 5.3365 18.1723 5.40321 18.2618L6.63863 19.9133C6.70711 20.0046 6.83608 20.0273 6.93303 19.9646C10.4934 17.6731 14.4149 16.1077 18.2217 16.5695C18.332 16.5825 18.4352 16.5138 18.4609 16.4086L18.9439 14.4066C18.9697 14.3005 18.9083 14.1944 18.8043 14.1579C15.6165 13.0343 13.0719 9.94435 12.9598 7.00923C12.9554 6.89617 12.8584 6.80833 12.7437 6.80833V6.80746ZM11.1427 15.0989C10.9586 15.165 10.7869 14.9788 10.8732 14.8067C10.9871 14.5805 11.0965 14.3527 11.2023 14.1222C11.478 13.5195 11.728 12.8986 11.9476 12.269C12.0046 12.1055 12.2269 12.075 12.3292 12.2168C12.7926 12.8577 13.3209 13.4526 13.9053 13.9909C14.0334 14.1083 13.9729 14.317 13.8012 14.3518C12.8984 14.5336 12.0108 14.7884 11.1427 15.0989Z", fill: "#F1E0E0" })] })), _jsx("defs", { children: _jsx("clipPath", Object.assign({ id: `clip0_${uniqueId}` }, { children: _jsx("rect", { width: "18", height: "22", fill: "white", transform: "translate(3 1)" }) })) })] })));
99
+ });
100
+ import customPdfSvgImport from "./custom/pdf.svg";
101
+ export const customPdfSvg = customPdfSvgImport;
102
+ export const CustomPdfIcon = forwardRef((props, ref) => {
103
+ return (_jsx("svg", Object.assign({}, props, { ref: ref, width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M21 20.8V6.5L15.375 1H5.25C4.65285 1 4.08118 1.23216 3.65931 1.64466C3.23743 2.05716 3 2.61612 3 3.2V20.8C3 21.3829 3.23743 21.9428 3.65931 22.3553C4.08118 22.7678 4.65285 23 5.25 23H18.75C19.3461 23 19.9188 22.7678 20.3407 22.3553C20.7626 21.9428 21 21.3839 21 20.8ZM10.6651 6.80746H12.7437V6.80832C12.8585 6.80832 12.9554 6.89616 12.9599 7.00922C13.0719 9.94434 15.6166 13.0343 18.8043 14.1579C18.9084 14.1944 18.9698 14.3005 18.944 14.4066L18.461 16.4086C18.4352 16.5138 18.332 16.5825 18.2217 16.5695C14.415 16.1077 10.4935 17.6731 6.93308 19.9646C6.83613 20.0272 6.70717 20.0046 6.63868 19.9133L5.40326 18.2618C5.33655 18.1723 5.35078 18.047 5.43706 17.9757C6.74186 16.8982 7.98528 15.1502 8.91562 13.1195C9.84597 11.0932 10.409 8.90248 10.4481 7.01704C10.4508 6.90051 10.546 6.80746 10.6651 6.80746ZM10.8733 14.8066C10.787 14.9788 10.9586 15.1649 11.1428 15.0989C12.0108 14.7884 12.8985 14.5336 13.8013 14.3518C13.9729 14.317 14.0334 14.1083 13.9053 13.9909C13.321 13.4526 12.7927 12.8577 12.3293 12.2168C12.227 12.075 12.0046 12.1055 11.9477 12.269C11.728 12.8986 11.4781 13.5195 11.2024 14.1222C11.0965 14.3527 10.9871 14.5805 10.8733 14.8066Z", fill: "#363636" }) })));
104
+ });
@@ -0,0 +1,12 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_881_50)">
3
+ <path d="M21 6.5V20.8C21 21.3839 20.7626 21.9428 20.3407 22.3553C19.9188 22.7678 19.3461 23 18.75 23H5.25C4.65285 23 4.08118 22.7678 3.65931 22.3553C3.23743 21.9428 3 21.3829 3 20.8V3.2C3 2.61612 3.23743 2.05716 3.65931 1.64466C4.08118 1.23216 4.65285 1 5.25 1H15.375L21 6.5Z" fill="#FF5850" style="fill:#FF5850;fill:color(display-p3 1.0000 0.3449 0.3125);fill-opacity:1;"/>
4
+ <path d="M16.5 6.5H21L15.375 1V5.4C15.375 5.69194 15.4932 5.97192 15.7041 6.17817C15.9151 6.38442 16.2014 6.5 16.5 6.5Z" fill="#F1E0E0" style="fill:#F1E0E0;fill:color(display-p3 0.9451 0.8784 0.8784);fill-opacity:1;"/>
5
+ <path d="M12.7437 6.80746H10.6651C10.5459 6.80746 10.4507 6.90052 10.4481 7.01705C10.4089 8.90249 9.84591 11.0932 8.91557 13.1195C7.98522 15.1502 6.7418 16.8982 5.43701 17.9757C5.35073 18.047 5.3365 18.1723 5.40321 18.2618L6.63863 19.9133C6.70711 20.0046 6.83608 20.0273 6.93303 19.9646C10.4934 17.6731 14.4149 16.1077 18.2217 16.5695C18.332 16.5825 18.4352 16.5138 18.4609 16.4086L18.9439 14.4066C18.9697 14.3005 18.9083 14.1944 18.8043 14.1579C15.6165 13.0343 13.0719 9.94435 12.9598 7.00923C12.9554 6.89617 12.8584 6.80833 12.7437 6.80833V6.80746ZM11.1427 15.0989C10.9586 15.165 10.7869 14.9788 10.8732 14.8067C10.9871 14.5805 11.0965 14.3527 11.2023 14.1222C11.478 13.5195 11.728 12.8986 11.9476 12.269C12.0046 12.1055 12.2269 12.075 12.3292 12.2168C12.7926 12.8577 13.3209 13.4526 13.9053 13.9909C14.0334 14.1083 13.9729 14.317 13.8012 14.3518C12.8984 14.5336 12.0108 14.7884 11.1427 15.0989Z" fill="#F1E0E0" style="fill:#F1E0E0;fill:color(display-p3 0.9451 0.8784 0.8784);fill-opacity:1;"/>
6
+ </g>
7
+ <defs>
8
+ <clipPath id="clip0_881_50">
9
+ <rect width="18" height="22" fill="white" style="fill:white;fill-opacity:1;" transform="translate(3 1)"/>
10
+ </clipPath>
11
+ </defs>
12
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21 20.8V6.5L15.375 1H5.25C4.65285 1 4.08118 1.23216 3.65931 1.64466C3.23743 2.05716 3 2.61612 3 3.2V20.8C3 21.3829 3.23743 21.9428 3.65931 22.3553C4.08118 22.7678 4.65285 23 5.25 23H18.75C19.3461 23 19.9188 22.7678 20.3407 22.3553C20.7626 21.9428 21 21.3839 21 20.8ZM10.6651 6.80746H12.7437V6.80832C12.8585 6.80832 12.9554 6.89616 12.9599 7.00922C13.0719 9.94434 15.6166 13.0343 18.8043 14.1579C18.9084 14.1944 18.9698 14.3005 18.944 14.4066L18.461 16.4086C18.4352 16.5138 18.332 16.5825 18.2217 16.5695C14.415 16.1077 10.4935 17.6731 6.93308 19.9646C6.83613 20.0272 6.70717 20.0046 6.63868 19.9133L5.40326 18.2618C5.33655 18.1723 5.35078 18.047 5.43706 17.9757C6.74186 16.8982 7.98528 15.1502 8.91562 13.1195C9.84597 11.0932 10.409 8.90248 10.4481 7.01704C10.4508 6.90051 10.546 6.80746 10.6651 6.80746ZM10.8733 14.8066C10.787 14.9788 10.9586 15.1649 11.1428 15.0989C12.0108 14.7884 12.8985 14.5336 13.8013 14.3518C13.9729 14.317 14.0334 14.1083 13.9053 13.9909C13.321 13.4526 12.7927 12.8577 12.3293 12.2168C12.227 12.075 12.0046 12.1055 11.9477 12.269C11.728 12.8986 11.4781 13.5195 11.2024 14.1222C11.0965 14.3527 10.9871 14.5805 10.8733 14.8066Z" fill="#363636" style="fill:#363636;fill:color(display-p3 0.2118 0.2118 0.2118);fill-opacity:1;"/>
3
+ </svg>
@@ -7,7 +7,7 @@ export interface ImageProps {
7
7
  export interface Selection {
8
8
  isAnswer: boolean;
9
9
  show: {
10
- image?: ImageProps;
10
+ image?: ImageProps | null;
11
11
  text: string;
12
12
  };
13
13
  value: string;
@@ -31,7 +31,7 @@ export declare class ProblemSelectNode extends DecoratorNode<ReactNode> {
31
31
  static getType(): string;
32
32
  getSelections(): Selection[];
33
33
  getSelected(): string[];
34
- setSolutions(selections: Selection[]): void;
34
+ setSelections(selections: Selection[]): void;
35
35
  setSelected(selected: string[]): void;
36
36
  static clone(node: ProblemSelectNode): ProblemSelectNode;
37
37
  constructor(selections: Selection[], selected: string[], hasMultipleAnswers?: boolean, key?: NodeKey);
@@ -19,7 +19,7 @@ export class ProblemSelectNode extends DecoratorNode {
19
19
  getSelected() {
20
20
  return this.__selected;
21
21
  }
22
- setSolutions(selections) {
22
+ setSelections(selections) {
23
23
  const self = this.getWritable();
24
24
  self.__selections = selections;
25
25
  }
@@ -3,7 +3,7 @@ export interface SelectBoxProps {
3
3
  index: number;
4
4
  isSelected?: boolean;
5
5
  isAnswer?: boolean;
6
- image?: ImageProps;
6
+ image?: ImageProps | null;
7
7
  text: string;
8
8
  onClick?: () => void;
9
9
  fullWidth?: boolean;
@@ -12,7 +12,7 @@ export default function SelectBox(props) {
12
12
  ` })) : (index) })), _jsxs(Content, { children: [image && (_jsx("img", { src: image.src, alt: image.altText, css: css `
13
13
  height: auto;
14
14
  // 이미지로 인해 좌우로 스크롤이 생기는 것을 방지
15
- max-width: min(328px, 100%);
15
+ max-width: 100%;
16
16
  width: fit-content;
17
17
  border-radius: 6px;
18
18
  ` })), text] }), isAnswer && (_jsx(CheckboxCircleFillIcon, { color: theme.color.foreground.success, css: css `
@@ -45,10 +45,7 @@ export function SelectComponent(props) {
45
45
  if (!$isProblemSelectNode(node)) {
46
46
  return;
47
47
  }
48
- const newSelected = [...selected];
49
- const index = newSelected.indexOf(selection.value);
50
- newSelected.splice(index, 1);
51
- node.setSelected(newSelected);
48
+ node.setSelected(selected.filter((v) => v !== selection.value));
52
49
  });
53
50
  }
54
51
  else {
@@ -57,9 +54,7 @@ export function SelectComponent(props) {
57
54
  if (!$isProblemSelectNode(node)) {
58
55
  return;
59
56
  }
60
- const newSelected = [...selected];
61
- newSelected.push(selection.value);
62
- node.setSelected(newSelected);
57
+ node.setSelected([...selected, selection.value]);
63
58
  });
64
59
  }
65
60
  }, fullWidth: true }, index)))] }));
@@ -1,16 +1,13 @@
1
1
  import { Selection } from "../ProblemSelectNode";
2
- import { Control, FieldArrayWithId, UseFieldArrayUpdate } from "react-hook-form";
2
+ import { Control, UseFormWatch } from "react-hook-form";
3
3
  export interface FormSelectionProps {
4
4
  index: number;
5
5
  control: Control<{
6
6
  selections: Selection[];
7
7
  }, any>;
8
- field: FieldArrayWithId<{
8
+ watch: UseFormWatch<{
9
9
  selections: Selection[];
10
- }, "selections", "uid">;
11
- update: UseFieldArrayUpdate<{
12
- selections: Selection[];
13
- }, "selections">;
10
+ }>;
14
11
  rules?: any;
15
12
  onDelete?: () => void;
16
13
  }
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import styled from "@emotion/styled";
4
- import { Controller, } from "react-hook-form";
4
+ import { Controller } from "react-hook-form";
5
5
  import { css } from "@emotion/react";
6
6
  import Input from "../../../../../components/Input";
7
7
  import { DeleteBinLineIcon, ErrorWarningFillIcon, ImageAddFillIcon, ImageEditFillIcon, } from "../../../../../icons";
@@ -10,51 +10,45 @@ import Switch from "../../../../../components/Switch";
10
10
  import { useState } from "react";
11
11
  import { InsertImageDialog } from "./InsertImageDialog";
12
12
  export function FormSelection(props) {
13
- const { index, control, field, update, rules, onDelete } = props;
13
+ const { index, control, rules, watch, onDelete } = props;
14
14
  const [imageOpen, setImageOpen] = useState(false);
15
15
  const [inputFocused, setInputFocused] = useState(false);
16
- return (_jsxs(_Fragment, { children: [_jsx(InsertImageDialog, { title: field.show.image ? "이미지 바꾸기" : "이미지 삽입하기", open: imageOpen, onClose: () => setImageOpen(false), updateImg: (props) => {
17
- update(index, Object.assign(Object.assign({}, field), { show: Object.assign(Object.assign({}, field.show), { image: props }) }));
18
- }, deleteImg: field.show.image
19
- ? () => {
20
- update(index, Object.assign(Object.assign({}, field), { show: Object.assign(Object.assign({}, field.show), { image: undefined }) }));
21
- }
22
- : undefined }), _jsxs(Container, { children: [_jsx(Index, { children: index + 1 }), _jsxs("div", Object.assign({ css: css `
23
- display: flex;
24
- flex: 1;
25
- flex-direction: column;
26
- gap: 4px;
27
- ` }, { children: [field.show.image && field.show.image.src && (_jsx("img", { src: field.show.image.src, alt: field.show.image.altText, css: css `
28
- height: auto;
29
- // 이미지로 인해 좌우로 스크롤이 생기는 것을 방지
30
- max-width: min(400px, 100%);
31
- width: fit-content;
32
- border-radius: 6px;
33
- `, draggable: "false" })), _jsx(Controller, { name: `selections.${index}.show.text`, control: control, rules: rules, render: ({ field: { value, onChange }, fieldState: { invalid, error }, }) => (_jsx(Input, { size: "small", color: invalid
34
- ? "activeDanger"
35
- : inputFocused
36
- ? "activePrimary"
37
- : "default", value: value, onChange: onChange, inputProps: {
38
- onFocus: (_e) => {
39
- setInputFocused(true);
40
- },
41
- onBlur: (_e) => {
42
- setInputFocused(false);
43
- update(index, Object.assign(Object.assign({}, field), { show: Object.assign(Object.assign({}, field.show), { text: value }) }));
44
- },
45
- }, placeholder: `${index + 1}번 선택지`, hintIcon: invalid ? _jsx(ErrorWarningFillIcon, {}) : undefined, hintText: error === null || error === void 0 ? void 0 : error.message, multiline: true, fullWidth: true, css: css `
46
- flex: 1;
47
- ` })) })] })), _jsxs("div", Object.assign({ css: css `
48
- display: flex;
49
- height: 36px;
50
- gap: 8px;
51
- align-items: center;
52
- ` }, { children: [_jsx(SquareButton, { color: "icon", size: "xsmall", icon: field.show.image ? _jsx(ImageEditFillIcon, {}) : _jsx(ImageAddFillIcon, {}), onClick: () => {
53
- setImageOpen(true);
54
- } }), _jsx(Controller, { name: `selections.${index}.isAnswer`, control: control, render: ({ field: { value, onChange } }) => (_jsxs(Answer, Object.assign({ onClick: () => {
55
- onChange(!value);
56
- update(index, Object.assign(Object.assign({}, field), { isAnswer: !value }));
57
- } }, { children: ["\uC815\uB2F5", _jsx(Switch, { checked: value, size: "small" })] }))) }), onDelete && (_jsx(SquareButton, { color: "white", size: "xsmall", icon: _jsx(DeleteBinLineIcon, {}), onClick: onDelete }))] }))] })] }));
16
+ return (_jsxs(Container, { children: [_jsx(Index, { children: index + 1 }), _jsxs("div", Object.assign({ css: css `
17
+ display: flex;
18
+ flex: 1;
19
+ flex-direction: column;
20
+ gap: 4px;
21
+ ` }, { children: [_jsx(Controller, { name: `selections.${index}.show.image`, control: control, render: ({ field: { value, onChange } }) => (_jsxs(_Fragment, { children: [_jsx(InsertImageDialog, { title: value ? "이미지 바꾸기" : "이미지 삽입하기", open: imageOpen, onClose: () => setImageOpen(false), updateImg: (props) => {
22
+ onChange(props);
23
+ }, deleteButton: value !== null }), value && value.src && (_jsx("img", { src: value.src, alt: value.altText, css: css `
24
+ height: auto;
25
+ // 이미지로 인해 좌우로 스크롤이 생기는 것을 방지
26
+ max-width: min(400px, 100%);
27
+ width: fit-content;
28
+ border-radius: 6px;
29
+ `, draggable: "false" }))] })) }), _jsx(Controller, { name: `selections.${index}.show.text`, control: control, rules: rules, render: ({ field: { value, onChange }, fieldState: { invalid, error }, }) => (_jsx(Input, { size: "small", color: invalid
30
+ ? "activeDanger"
31
+ : inputFocused
32
+ ? "activePrimary"
33
+ : "default", value: value, onChange: onChange, inputProps: {
34
+ onFocus: (_e) => {
35
+ setInputFocused(true);
36
+ },
37
+ onBlur: (_e) => {
38
+ setInputFocused(false);
39
+ },
40
+ }, placeholder: `${index + 1}번 선택지`, hintIcon: invalid ? _jsx(ErrorWarningFillIcon, {}) : undefined, hintText: error === null || error === void 0 ? void 0 : error.message, multiline: true, fullWidth: true, css: css `
41
+ flex: 1;
42
+ ` })) })] })), _jsxs("div", Object.assign({ css: css `
43
+ display: flex;
44
+ height: 36px;
45
+ gap: 8px;
46
+ align-items: center;
47
+ ` }, { children: [_jsx(SquareButton, { color: "icon", size: "xsmall", icon: watch(`selections.${index}.show.image`) ? (_jsx(ImageEditFillIcon, {})) : (_jsx(ImageAddFillIcon, {})), onClick: () => {
48
+ setImageOpen(true);
49
+ } }), _jsx(Controller, { name: `selections.${index}.isAnswer`, control: control, render: ({ field: { value, onChange } }) => (_jsxs(Answer, Object.assign({ onClick: () => {
50
+ onChange(!value);
51
+ } }, { children: ["\uC815\uB2F5", _jsx(Switch, { checked: value, size: "small" })] }))) }), onDelete && (_jsx(SquareButton, { color: "white", size: "xsmall", icon: _jsx(DeleteBinLineIcon, {}), onClick: onDelete }))] }))] }));
58
52
  }
59
53
  const Container = styled.div(({ theme }) => css `
60
54
  display: flex;
@@ -3,8 +3,8 @@ export interface InsertImageDialogProps {
3
3
  title: string;
4
4
  open: boolean;
5
5
  onClose: () => void;
6
- updateImg: (props: ImageProps) => void;
6
+ updateImg: (props: ImageProps | null) => void;
7
7
  /** 전달하면 "이미지 삭제하기" 버튼이 생깁니다. */
8
- deleteImg?: () => void;
8
+ deleteButton?: boolean;
9
9
  }
10
10
  export declare function InsertImageDialog(props: InsertImageDialogProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -18,22 +18,23 @@ import Button from "../../../../../components/Button";
18
18
  import { CodleDesignSystemContext } from "../../../../../CodleDesignSystemProvider";
19
19
  import { InsertImageUriDialogBody } from "./InsertImageUriDialogBody";
20
20
  import { InsertImageUploadedDialogBody } from "./InsertImageUploadedDialogBody";
21
+ import { useForm } from "react-hook-form";
21
22
  export function InsertImageDialog(props) {
22
- const { title, open, onClose, updateImg, deleteImg } = props;
23
+ const { title, open, onClose, updateImg, deleteButton } = props;
23
24
  const theme = useTheme();
24
25
  const [mode, setMode] = useState(null);
25
26
  const inputRef = useRef(null);
26
27
  const cdsContext = useContext(CodleDesignSystemContext);
27
- const [src, setSrc] = useState("");
28
- const [altText, setAltText] = useState("");
28
+ const { control, setValue, watch, reset } = useForm({
29
+ defaultValues: { src: "", altText: "" },
30
+ });
29
31
  const onClick = (props) => {
30
32
  updateImg(props);
31
33
  handleOnClose();
32
34
  };
33
35
  const handleOnClose = () => {
34
36
  setMode(null);
35
- setSrc("");
36
- setAltText("");
37
+ reset();
37
38
  onClose();
38
39
  };
39
40
  return (_jsxs(StyledAlertDialog, Object.assign({ icon: _jsx(ImageFillIcon, { color: theme.color.background.primary }), open: open, onClose: handleOnClose, disableIconPadding: true }, { children: [_jsx(StyledAlertDialogTitle, Object.assign({ onClose: handleOnClose }, { children: title })), !mode && (_jsx(AlertDialogContent, { children: _jsxs("div", Object.assign({ css: css `
@@ -52,10 +53,12 @@ export function InsertImageDialog(props) {
52
53
  return;
53
54
  const uploadByFile = (_b = cdsContext.lexical) === null || _b === void 0 ? void 0 : _b.uploadByFile;
54
55
  if (uploadByFile) {
55
- setSrc(yield uploadByFile(file));
56
+ setValue("src", yield uploadByFile(file));
56
57
  setMode("file");
57
58
  }
58
- }) })] })] }), deleteImg && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx(Button, { color: "textDanger", size: "medium", fullWidth: true, label: "\uC774\uBBF8\uC9C0 \uC0AD\uC81C\uD558\uAE30", onClick: deleteImg })] }))] })) })), mode === "url" && (_jsx(InsertImageUriDialogBody, { src: src, setSrc: setSrc, altText: altText, setAltText: setAltText, onClick: onClick })), mode === "file" && (_jsx(InsertImageUploadedDialogBody, { src: src, setSrc: setSrc, altText: altText, setAltText: setAltText, onClick: onClick }))] })));
59
+ }) })] })] }), deleteButton && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx(Button, { color: "textDanger", size: "medium", fullWidth: true, label: "\uC774\uBBF8\uC9C0 \uC0AD\uC81C\uD558\uAE30", onClick: () => {
60
+ onClick(null);
61
+ } })] }))] })) })), mode === "url" && (_jsx(InsertImageUriDialogBody, { control: control, watch: watch, onClick: onClick })), mode === "file" && (_jsx(InsertImageUploadedDialogBody, { control: control, watch: watch, setValue: setValue, onClick: onClick }))] })));
59
62
  }
60
63
  const StyledAlertDialog = styled(AlertDialog) `
61
64
  gap: 16px;
@@ -1,9 +1,9 @@
1
1
  import { ImageProps } from "../ProblemSelectNode";
2
+ import { Control, UseFormSetValue, UseFormWatch } from "react-hook-form";
2
3
  export interface InsertImageUploadedDialogBodyProps {
3
- src: string;
4
- setSrc: (src: string) => void;
5
- altText: string;
6
- setAltText: (altText: string) => void;
4
+ control: Control<ImageProps, any>;
5
+ watch: UseFormWatch<ImageProps>;
6
+ setValue: UseFormSetValue<ImageProps>;
7
7
  onClick: (props: ImageProps) => void;
8
8
  }
9
9
  export declare function InsertImageUploadedDialogBody(props: InsertImageUploadedDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -15,11 +15,12 @@ import { AlertDialogActions, AlertDialogContent, } from "../../../../../componen
15
15
  import Button from "../../../../../components/Button";
16
16
  import { RefreshLineIcon } from "../../../../../icons";
17
17
  import Input from "../../../../../components/Input";
18
+ import { Controller, } from "react-hook-form";
18
19
  export function InsertImageUploadedDialogBody(props) {
19
- const { src, setSrc, altText, setAltText, onClick } = props;
20
+ const { control, watch, setValue, onClick } = props;
20
21
  const inputRef = useRef(null);
21
22
  const cdsContext = useContext(CodleDesignSystemContext);
22
- const isDisabled = src === "";
23
+ const isDisabled = watch("src") === "";
23
24
  return (_jsxs(_Fragment, { children: [_jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Button, { fullWidth: true, color: "grey", size: "medium", label: "\uD30C\uC77C \uBC14\uAFB8\uAE30", onClick: () => {
24
25
  var _a;
25
26
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
@@ -30,11 +31,9 @@ export function InsertImageUploadedDialogBody(props) {
30
31
  return;
31
32
  const uploadByFile = (_b = cdsContext.lexical) === null || _b === void 0 ? void 0 : _b.uploadByFile;
32
33
  if (uploadByFile) {
33
- setSrc(yield uploadByFile(file));
34
+ setValue("src", yield uploadByFile(file));
34
35
  }
35
- }) }), _jsxs(ImagePreview, { children: ["\uC774\uBBF8\uC9C0 \uBBF8\uB9AC\uBCF4\uAE30", _jsx("img", { src: src, alt: altText })] }), _jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: (e) => {
36
- setAltText(e.target.value);
37
- }, value: altText })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText, src }) }) })] }));
36
+ }) }), _jsxs(ImagePreview, { children: ["\uC774\uBBF8\uC9C0 \uBBF8\uB9AC\uBCF4\uAE30", _jsx("img", { src: watch("src"), alt: watch("altText") })] }), _jsx(Controller, { name: "altText", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: onChange, value: value })) })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText: watch("altText"), src: watch("src") }) }) })] }));
38
37
  }
39
38
  const Inputs = styled.div `
40
39
  display: flex;
@@ -1,9 +1,8 @@
1
1
  import { ImageProps } from "../ProblemSelectNode";
2
+ import { Control, UseFormWatch } from "react-hook-form";
2
3
  export interface InsertImageUriDialogBodyProps {
3
- src: string;
4
- setSrc: (src: string) => void;
5
- altText: string;
6
- setAltText: (altText: string) => void;
4
+ control: Control<ImageProps, any>;
5
+ watch: UseFormWatch<ImageProps>;
7
6
  onClick: (props: ImageProps) => void;
8
7
  }
9
8
  export declare function InsertImageUriDialogBody(props: InsertImageUriDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -4,14 +4,11 @@ import { AlertDialogActions, AlertDialogContent, } from "../../../../../componen
4
4
  import Input from "../../../../../components/Input";
5
5
  import { LinkIcon } from "../../../../../icons";
6
6
  import Button from "../../../../../components/Button";
7
+ import { Controller } from "react-hook-form";
7
8
  export function InsertImageUriDialogBody(props) {
8
- const { src, setSrc, altText, setAltText, onClick } = props;
9
- const isDisabled = src === "";
10
- return (_jsxs(_Fragment, { children: [" ", _jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Input, { fullWidth: true, label: "URL", placeholder: "https://www.pexels.com/photo/n-2848492/", color: "default", size: "medium", onChange: (e) => {
11
- setSrc(e.target.value);
12
- }, value: src, startIcon: _jsx(LinkIcon, {}) }), _jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: (e) => {
13
- setAltText(e.target.value);
14
- }, value: altText })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText, src }) }) })] }));
9
+ const { control, watch, onClick } = props;
10
+ const isDisabled = watch("src") === "";
11
+ return (_jsxs(_Fragment, { children: [" ", _jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Controller, { name: "src", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "URL", placeholder: "https://www.pexels.com/photo/n-2848492/", color: "default", size: "medium", onChange: onChange, value: value, startIcon: _jsx(LinkIcon, {}) })) }), _jsx(Controller, { name: "altText", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: onChange, value: value })) })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText: watch("altText"), src: watch("src") }) }) })] }));
15
12
  }
16
13
  const Inputs = styled.div `
17
14
  display: flex;
@@ -16,13 +16,22 @@ export default function SettingForm(props) {
16
16
  const { selections, nodeKey, onClose } = props;
17
17
  const [editor] = useLexicalComposerContext();
18
18
  const [tooltipOpen, setTooltipOpen] = useState(false);
19
- const { control, handleSubmit } = useForm({
19
+ const { control, handleSubmit, watch } = useForm({
20
20
  mode: "all",
21
21
  defaultValues: {
22
- selections,
22
+ selections: selections.map((selection) => {
23
+ var _a;
24
+ return ({
25
+ isAnswer: selection.isAnswer,
26
+ show: {
27
+ image: (_a = selection.show.image) !== null && _a !== void 0 ? _a : null,
28
+ text: selection.show.text,
29
+ },
30
+ });
31
+ }),
23
32
  },
24
33
  });
25
- const { fields, append, remove, update } = useFieldArray({
34
+ const { fields, append, remove } = useFieldArray({
26
35
  control,
27
36
  name: "selections",
28
37
  keyName: "uid",
@@ -33,7 +42,7 @@ export default function SettingForm(props) {
33
42
  if (!$isProblemSelectNode(node)) {
34
43
  return;
35
44
  }
36
- node.setSolutions(data.selections);
45
+ node.setSelections(data.selections);
37
46
  });
38
47
  onClose();
39
48
  };
@@ -47,12 +56,13 @@ export default function SettingForm(props) {
47
56
  return true;
48
57
  return `${duplicatedIndex + 1}번 선택지와 같은 내용입니다.`;
49
58
  }
50
- const hasMultipleAnswers = fields.filter((field) => field.isAnswer).length > 1;
51
- const hasAnswer = fields.some((field) => field.isAnswer);
59
+ const answersCount = watch("selections").filter((selection) => selection.isAnswer).length;
60
+ const hasMultipleAnswers = answersCount > 1;
61
+ const hasAnswer = answersCount > 0;
52
62
  return (_jsxs(Form, Object.assign({ onSubmit: handleSubmit(onSettingSubmit) }, { children: [_jsxs(Title, { children: [_jsx(ListRadioIcon, { css: css `
53
63
  width: 12px;
54
64
  height: 12px;
55
- ` }), "\uAC1D\uAD00\uC2DD \uC785\uB825 \uCE78"] }), _jsxs(Content, { children: [_jsxs(FormArea, { children: [_jsx(Label, { children: "\uB2F5\uC548" }), fields.map((field, index) => (_jsx(FormSelection, { index: index, control: control, field: field, update: update, rules: {
65
+ ` }), "\uAC1D\uAD00\uC2DD \uC785\uB825 \uCE78"] }), _jsxs(Content, { children: [_jsxs(FormArea, { children: [_jsx(Label, { children: "\uB2F5\uC548" }), fields.map((field, index) => (_jsx(FormSelection, { index: index, control: control, watch: watch, rules: {
56
66
  required: "필수 입력 항목입니다.",
57
67
  validate: () => validateDuplicatedSelection(fields, index),
58
68
  }, onDelete: index !== 0
@@ -18,6 +18,7 @@ import { ImageFillIcon, LinkIcon, UploadLineIcon } from "../../../../icons";
18
18
  import Button from "../../../../components/Button";
19
19
  import { useTheme } from "@emotion/react";
20
20
  import { CodleDesignSystemContext } from "../../../../CodleDesignSystemProvider";
21
+ import { useForm } from "react-hook-form";
21
22
  export function InsertImageDialog(props) {
22
23
  const { open, activeEditor, onClose } = props;
23
24
  const theme = useTheme();
@@ -25,8 +26,9 @@ export function InsertImageDialog(props) {
25
26
  const hasModifier = useRef(false);
26
27
  const inputRef = useRef(null);
27
28
  const cdsContext = useContext(CodleDesignSystemContext);
28
- const [src, setSrc] = useState("");
29
- const [altText, setAltText] = useState("");
29
+ const { control, setValue, watch, reset } = useForm({
30
+ defaultValues: { src: "", altText: "" },
31
+ });
30
32
  useEffect(() => {
31
33
  hasModifier.current = false;
32
34
  const handler = (e) => {
@@ -43,8 +45,7 @@ export function InsertImageDialog(props) {
43
45
  };
44
46
  const handleOnClose = () => {
45
47
  setMode(null);
46
- setSrc("");
47
- setAltText("");
48
+ reset();
48
49
  onClose();
49
50
  };
50
51
  return (_jsxs(StyledAlertDialog, Object.assign({ icon: _jsx(ImageFillIcon, { color: theme.color.background.primary }), open: open, onClose: handleOnClose, disableIconPadding: true }, { children: [_jsx(StyledAlertDialogTitle, Object.assign({ onClose: handleOnClose }, { children: "\uC774\uBBF8\uC9C0 \uC0BD\uC785\uD558\uAE30" })), !mode && (_jsx(AlertDialogContent, { children: _jsxs(Buttons, { children: [_jsxs(ButtonAndDescription, { children: [_jsx(Description, { children: "\uC774\uBBF8\uC9C0 URL\uC744 \uC54C\uACE0 \uC788\uB2E4\uBA74" }), _jsx(Button, { color: "grey", size: "medium", fullWidth: true, label: "URL\uB85C \uC0BD\uC785\uD558\uAE30", startIcon: _jsx(LinkIcon, {}), onClick: () => setMode("url") })] }), _jsxs(ButtonAndDescription, { children: [_jsx(Description, { children: "\uAC16\uACE0 \uC788\uB294 \uC774\uBBF8\uC9C0\uB97C \uC0BD\uC785\uD558\uACE0 \uC2F6\uB2E4\uBA74" }), _jsx(Button, { color: "grey", size: "medium", fullWidth: true, label: "\uD30C\uC77C \uC120\uD0DD\uD558\uAE30", startIcon: _jsx(UploadLineIcon, {}), onClick: () => {
@@ -57,10 +58,10 @@ export function InsertImageDialog(props) {
57
58
  return;
58
59
  const uploadByFile = (_b = cdsContext.lexical) === null || _b === void 0 ? void 0 : _b.uploadByFile;
59
60
  if (uploadByFile) {
60
- setSrc(yield uploadByFile(file));
61
+ setValue("src", yield uploadByFile(file));
61
62
  setMode("file");
62
63
  }
63
- }) })] })] }) })), mode === "url" && (_jsx(InsertImageUriDialogBody, { src: src, setSrc: setSrc, altText: altText, setAltText: setAltText, onClick: onClick })), mode === "file" && (_jsx(InsertImageUploadedDialogBody, { src: src, setSrc: setSrc, altText: altText, setAltText: setAltText, onClick: onClick }))] })));
64
+ }) })] })] }) })), mode === "url" && (_jsx(InsertImageUriDialogBody, { control: control, watch: watch, onClick: onClick })), mode === "file" && (_jsx(InsertImageUploadedDialogBody, { control: control, watch: watch, setValue: setValue, onClick: onClick }))] })));
64
65
  }
65
66
  const StyledAlertDialog = styled(AlertDialog) `
66
67
  gap: 16px;
@@ -1,9 +1,18 @@
1
1
  import { InsertImagePayload } from ".";
2
+ import { Control, UseFormSetValue, UseFormWatch } from "react-hook-form";
2
3
  export interface InsertImageUploadedDialogBodyProps {
3
- src: string;
4
- setSrc: (src: string) => void;
5
- altText: string;
6
- setAltText: (altText: string) => void;
4
+ control: Control<{
5
+ src: string;
6
+ altText: string;
7
+ }, any>;
8
+ watch: UseFormWatch<{
9
+ src: string;
10
+ altText: string;
11
+ }>;
12
+ setValue: UseFormSetValue<{
13
+ src: string;
14
+ altText: string;
15
+ }>;
7
16
  onClick: (payload: InsertImagePayload) => void;
8
17
  }
9
18
  export declare function InsertImageUploadedDialogBody(props: InsertImageUploadedDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -15,11 +15,12 @@ import { AlertDialogContent, AlertDialogActions, } from "../../../../components/
15
15
  import Button from "../../../../components/Button";
16
16
  import Input from "../../../../components/Input";
17
17
  import { RefreshLineIcon } from "../../../../icons";
18
+ import { Controller, } from "react-hook-form";
18
19
  export function InsertImageUploadedDialogBody(props) {
19
- const { src, setSrc, altText, setAltText, onClick } = props;
20
+ const { control, watch, setValue, onClick } = props;
20
21
  const inputRef = useRef(null);
21
22
  const cdsContext = useContext(CodleDesignSystemContext);
22
- const isDisabled = src === "";
23
+ const isDisabled = watch("src") === "";
23
24
  return (_jsxs(_Fragment, { children: [_jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Button, { fullWidth: true, color: "grey", size: "medium", label: "\uD30C\uC77C \uBC14\uAFB8\uAE30", onClick: () => {
24
25
  var _a;
25
26
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
@@ -30,11 +31,9 @@ export function InsertImageUploadedDialogBody(props) {
30
31
  return;
31
32
  const uploadByFile = (_b = cdsContext.lexical) === null || _b === void 0 ? void 0 : _b.uploadByFile;
32
33
  if (uploadByFile) {
33
- setSrc(yield uploadByFile(file));
34
+ setValue("src", yield uploadByFile(file));
34
35
  }
35
- }) }), _jsxs(ImagePreview, { children: ["\uC774\uBBF8\uC9C0 \uBBF8\uB9AC\uBCF4\uAE30", _jsx("img", { src: src, alt: altText })] }), _jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: (e) => {
36
- setAltText(e.target.value);
37
- }, value: altText })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText, src }) }) })] }));
36
+ }) }), _jsxs(ImagePreview, { children: ["\uC774\uBBF8\uC9C0 \uBBF8\uB9AC\uBCF4\uAE30", _jsx("img", { src: watch("src"), alt: watch("altText") })] }), _jsx(Controller, { name: "altText", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: onChange, value: value })) })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText: watch("altText"), src: watch("src") }) }) })] }));
38
37
  }
39
38
  const Inputs = styled.div `
40
39
  display: flex;
@@ -1,9 +1,14 @@
1
1
  import { InsertImagePayload } from ".";
2
+ import { Control, UseFormWatch } from "react-hook-form";
2
3
  export interface InsertImageUriDialogBodyProps {
3
- src: string;
4
- setSrc: (src: string) => void;
5
- altText: string;
6
- setAltText: (altText: string) => void;
4
+ control: Control<{
5
+ src: string;
6
+ altText: string;
7
+ }, any>;
8
+ watch: UseFormWatch<{
9
+ src: string;
10
+ altText: string;
11
+ }>;
7
12
  onClick: (payload: InsertImagePayload) => void;
8
13
  }
9
14
  export declare function InsertImageUriDialogBody(props: InsertImageUriDialogBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -4,14 +4,11 @@ import { AlertDialogActions, AlertDialogContent, } from "../../../../components/
4
4
  import Input from "../../../../components/Input";
5
5
  import { LinkIcon } from "../../../../icons";
6
6
  import Button from "../../../../components/Button";
7
+ import { Controller } from "react-hook-form";
7
8
  export function InsertImageUriDialogBody(props) {
8
- const { src, setSrc, altText, setAltText, onClick } = props;
9
- const isDisabled = src === "";
10
- return (_jsxs(_Fragment, { children: [" ", _jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Input, { fullWidth: true, label: "URL", placeholder: "https://www.pexels.com/photo/n-2848492/", color: "default", size: "medium", onChange: (e) => {
11
- setSrc(e.target.value);
12
- }, value: src, startIcon: _jsx(LinkIcon, {}) }), _jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: (e) => {
13
- setAltText(e.target.value);
14
- }, value: altText })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText, src }) }) })] }));
9
+ const { control, watch, onClick } = props;
10
+ const isDisabled = watch("src") === "";
11
+ return (_jsxs(_Fragment, { children: [" ", _jsx(AlertDialogContent, { children: _jsxs(Inputs, { children: [_jsx(Controller, { name: "src", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "URL", placeholder: "https://www.pexels.com/photo/n-2848492/", color: "default", size: "medium", onChange: onChange, value: value, startIcon: _jsx(LinkIcon, {}) })) }), _jsx(Controller, { name: "altText", control: control, render: ({ field: { value, onChange } }) => (_jsx(Input, { fullWidth: true, label: "\uB300\uCCB4 \uD14D\uC2A4\uD2B8", placeholder: "\uC0BD\uC785\uD558\uB294 \uC774\uBBF8\uC9C0\uC5D0 \uAD00\uD55C \uC124\uBA85", color: "default", size: "medium", onChange: onChange, value: value })) })] }) }), _jsx(AlertDialogActions, { children: _jsx(Button, { fullWidth: true, label: "\uC0BD\uC785\uD558\uAE30", size: "medium", color: "primary", disabled: isDisabled, onClick: () => onClick({ altText: watch("altText"), src: watch("src") }) }) })] }));
15
12
  }
16
13
  const Inputs = styled.div `
17
14
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.9.9",
3
+ "version": "1.10.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,