ados-rcm 1.0.41 → 1.0.42

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,30 +1,18 @@
1
1
  /// <reference types="react" />
2
2
  import { Resources } from '../AResource/AResource';
3
- import { IAEventCallers, TActionRef } from '../ATypes/ATypes';
3
+ import { IAEvent, TActionRef } from '../ATypes/ATypes';
4
4
  /**
5
5
  * onOk와 ok의 네이밍 차이 : 해당 function이 Action임을 정의하는 기준을 고찰.
6
6
  * onAction은 callback으로 action이 수행될 때 호출된다. 따라서 기본적으로 onAction을 호출하는 곳은 action 한 곳 뿐이다.
7
7
  * 이와 다르게 action은 여러 곳에서 해당 action을 수행하고 싶을 때 호출할 수 있다. 만약 한 곳에서만 action을 호출하는 상황이라면 onAction을 사용하도록 한다.
8
8
  */
9
9
  export interface IADialogActions {
10
- /**
11
- * open : () => void
12
- *
13
- * Description : open dialog
14
- */
15
- open: () => void;
16
10
  /**
17
11
  * close : () => void
18
12
  *
19
13
  * Description : close dialog
20
14
  */
21
15
  close: () => void;
22
- /**
23
- * toggle : () => void
24
- *
25
- * Description : toggle dialog
26
- */
27
- toggle: () => void;
28
16
  /**
29
17
  * ok : () => void
30
18
  *
@@ -38,8 +26,17 @@ export interface IADialogActions {
38
26
  */
39
27
  cancel: () => void;
40
28
  }
29
+ export interface IADialogChildren {
30
+ children?: React.ReactNode;
31
+ }
41
32
  export type TADialogTypes = 'okCancel' | 'cancelOk' | 'ok' | 'cancel' | 'none';
42
33
  export interface IADialogProps {
34
+ /**
35
+ * setIsOpen : (isOpen: boolean) => void
36
+ *
37
+ * Description : setOpen of the dialog. it is used when the dialog is closed.
38
+ */
39
+ setIsOpen: (isOpen: boolean) => void;
43
40
  /**
44
41
  * type? : TADialogTypes = 'okCancel'
45
42
  *
@@ -77,47 +74,41 @@ export interface IADialogProps {
77
74
  */
78
75
  bodyStyle?: React.CSSProperties;
79
76
  /**
80
- * onOk : (e: IAEventCallers) => void;
81
- *
82
- * Description : onOk of the dialog. it closes the dialog by default
83
- */
84
- onOk?: (e: IAEventCallers) => void;
85
- /**
86
- * onCancel : (e: IAEventCallers) => void;
77
+ * onOk : (e: IAEvent) => void;
87
78
  *
88
- * Description : onCancel of the dialog. it closes the dialog by default
79
+ * Description : onOk of the dialog. it runs close by default
89
80
  */
90
- onCancel?: (e: IAEventCallers) => void;
81
+ onOk?: (e: IAEvent) => void;
91
82
  /**
92
- * onClose : (e: IAEventCallers) => void;
83
+ * onCancel : (e: IAEvent) => void;
93
84
  *
94
- * Description : onClose of the dialog. it closes the dialog by default
85
+ * Description : onCancel of the dialog. it runs close by default
95
86
  */
96
- onClose?: (e: IAEventCallers) => void;
87
+ onCancel?: (e: IAEvent) => void;
97
88
  /**
98
- * onEnterPress : (e: IAEventCallers) => void;
89
+ * onEnterPress : (e: IAEvent) => void;
99
90
  *
100
91
  * Description : onEnterPress of the dialog. it runs ok by default
101
92
  */
102
- onEnterPress?: (e: IAEventCallers) => void;
93
+ onEnterPress?: (e: IAEvent) => void;
103
94
  /**
104
- * onEscPress : (e: IAEventCallers) => void;
95
+ * onEscPress : (e: IAEvent) => void;
105
96
  *
106
97
  * Description : onEscPress of the dialog. it runs cancel by default
107
98
  */
108
- onEscPress?: (e: IAEventCallers) => void;
99
+ onEscPress?: (e: IAEvent) => void;
109
100
  /**
110
- * onSpacePress : (e: IAEventCallers) => void;
101
+ * onSpacePress : (e: IAEvent) => void;
111
102
  *
112
103
  * Description : onSpacePress of the dialog. it runs ok by default
113
104
  */
114
- onSpacePress?: (e: IAEventCallers) => void;
105
+ onSpacePress?: (e: IAEvent) => void;
115
106
  /**
116
- * onPaperClick : (e: IAEventCallers) => void;
107
+ * onPaperClick : (e: IAEvent) => void;
117
108
  *
118
109
  * Description : onPaperClick of the dialog. it runs cancel by default
119
110
  */
120
- onPaperClick?: (e: IAEventCallers) => void;
111
+ onPaperClick?: (e: IAEvent) => void;
121
112
  /**
122
113
  * noDim? : boolean = false
123
114
  *
@@ -163,19 +154,49 @@ export interface IADialogProps {
163
154
  *
164
155
  * Basic Usage :
165
156
  *
166
- * const actionRef = useRef<IADialogActions>();
157
+ * const [isOpen, setIsOpen] = useState(false);
167
158
  * const onOk = () => { console.log('ok') }
168
- * const onCancel = () => { console.log('cancel') }
159
+ * const onCancel = (e : IAEvent) => {
160
+ * e.event.preventDefault(); // this prevents the dialog from closing.
161
+ * console.log('cancel')
162
+ * }
169
163
  *
170
164
  * if (case 1)
171
- * <ADialog actionRef={actionRef}
172
- * title='Dialog Title'
173
- * onOk={onOk}
174
- * onCancel={onCancel}>
175
- * <div>Content</div>
176
- * </ADialog>
177
- * <AButton onClick={actionRef.current?.open}>Open</AButton>
178
- * <AButton onClick={actionRef.current?.close}>Close</AButton>
165
+ * <>
166
+ * {isOpen &&
167
+ * <ADialog setIsOpen={setIsOpen}
168
+ * title='Dialog Title'
169
+ * onOk={onOk}
170
+ * onCancel={onCancel}>
171
+ * <div>Content</div>
172
+ * </ADialog>
173
+ * }
174
+ * </>
175
+ *
176
+ * if (case 2)
177
+ * <>
178
+ * {isOpen &&
179
+ * <DTest setIsOpen={setIsOpen}
180
+ * onOk={onOk}
181
+ * onCancel={onCancel}>
182
+ * </DTest>
183
+ * }
184
+ * </>
185
+ *
186
+ * const DTest = (props: IADialogProps) => {
187
+ * let { setIsOpen, onOk, onCancel } = props;
188
+ * const [num, setNum] = useState(0);
189
+ * return (
190
+ * <ADialog setIsOpen={setIsOpen}
191
+ * title='Dialog Title'
192
+ * onOk={onOk}
193
+ * onCancel={onCancel}>
194
+ * {num}
195
+ * <AButton onClick={() => setNum(num + 1)}>Add</AButton>
196
+ * <AButton onClick={() => setNum(num - 1)}>Sub</AButton>
197
+ * </ADialog>
198
+ * )
199
+ * }
179
200
  *
180
201
  */
181
- export declare const ADialog: (props: IADialogProps) => import("react").ReactPortal | null;
202
+ export declare const ADialog: (props: IADialogProps) => import("react").ReactPortal;
@@ -27,13 +27,13 @@ export declare enum EDir12 {
27
27
  export declare function setDir12Style(anchorRef: React.RefObject<HTMLElement>, selfRef: React.RefObject<HTMLElement>, dir: EDir12): void;
28
28
  export type TActionRef<T> = React.MutableRefObject<T | null | undefined>;
29
29
  export type TIdx = number | string;
30
- export interface IAEvent {
30
+ export interface IACalledEvent {
31
31
  preventDefault: boolean;
32
32
  }
33
- export interface IAEventCallers {
33
+ export interface IAEvent {
34
34
  preventDefault: () => void;
35
35
  }
36
36
  export declare function createEvent(): {
37
- event: IAEvent;
38
- e: IAEventCallers;
37
+ event: IACalledEvent;
38
+ e: IAEvent;
39
39
  };