sales-frontend-solution 0.0.47 → 0.0.48
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/index.cjs +666 -306
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +292 -27
- package/dist/index.d.ts +292 -27
- package/dist/index.js +663 -308
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/readme.md +1 -55
package/dist/index.cjs
CHANGED
|
@@ -8,9 +8,9 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
8
|
|
|
9
9
|
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
10
10
|
|
|
11
|
-
// src/v3-provider.tsx
|
|
11
|
+
// src/features/v3/v3-provider.tsx
|
|
12
12
|
|
|
13
|
-
// src/utils/load-script.ts
|
|
13
|
+
// src/shared/utils/load-script.ts
|
|
14
14
|
async function loadScript(url) {
|
|
15
15
|
await new Promise((resolve, reject) => {
|
|
16
16
|
const script = document.createElement("script");
|
|
@@ -51,7 +51,7 @@ var getServiceUrl = (serviceName) => {
|
|
|
51
51
|
INPUT_PREFILL_USER: `${getServiceUrl("nlc")}/user-ctfn/ncsr-info-inpt/post`
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
// src/v3.ts
|
|
54
|
+
// src/features/v3/v3.ts
|
|
55
55
|
var isAndroid = () => {
|
|
56
56
|
return /android/i.test(navigator.userAgent) && !/edge/i.test(navigator.userAgent);
|
|
57
57
|
};
|
|
@@ -102,60 +102,102 @@ var useV3 = () => {
|
|
|
102
102
|
}
|
|
103
103
|
return context;
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
|
|
106
|
+
// src/features/keypad/constants.ts
|
|
107
|
+
var KEYPAD_DEFAULTS = {
|
|
108
|
+
/** 키패드 너비 (%) */
|
|
109
|
+
WIDTH: 100,
|
|
110
|
+
/** 키패드 상단 위치 */
|
|
111
|
+
POSITION_TOP: 10,
|
|
112
|
+
/** 뷰 타입 */
|
|
113
|
+
VIEW_TYPE: "half",
|
|
114
|
+
/** 닫기 딜레이 */
|
|
115
|
+
CLOSE_DELAY: 0,
|
|
116
|
+
/** 숫자 키 행 수 */
|
|
117
|
+
NUMBER_KEY_ROW_COUNT: 3
|
|
118
|
+
};
|
|
119
|
+
var KEYPAD_SELECTORS = {
|
|
120
|
+
ALERT: "#xkalert"
|
|
121
|
+
};
|
|
122
|
+
var INPUT_SEPARATOR = ",";
|
|
123
|
+
var MASK_CHAR = "*";
|
|
124
|
+
|
|
125
|
+
// src/features/keypad/libs/constants.ts
|
|
126
|
+
var KEYPAD_SERVICE_PATH = {
|
|
127
|
+
XKP: "xkp",
|
|
128
|
+
NLC: "nlc"
|
|
129
|
+
};
|
|
130
|
+
var KEYPAD_SCRIPTS = {
|
|
131
|
+
MOBILE: "xkeypad_mobile.js"
|
|
132
|
+
};
|
|
133
|
+
var KEYPAD_STYLES = {
|
|
134
|
+
MOBILE: "xkp_mobile.css"
|
|
135
|
+
};
|
|
136
|
+
var DEFAULT_KEYPAD_CONFIG = {
|
|
137
|
+
VERSION: "1.0.5.1",
|
|
138
|
+
MAX_INPUT_SIZE: 56,
|
|
139
|
+
TEXT_INPUT_VIEW: 0,
|
|
140
|
+
TOUCH_OPTION: 0,
|
|
141
|
+
INPUT_BACKGROUND_COLOR: "#E4E4E4",
|
|
142
|
+
INPUT_BORDER_STYLE: "1px solid #9E9E9E",
|
|
143
|
+
INVALID_SESSION_MESSAGE: "\uBCF4\uC548\uC138\uC158\uC774 \uB9CC\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.\n'\uD655\uC778'\uC744 \uB204\uB974\uBA74 \uD0A4\uD328\uB4DC\uAC00 \uAC31\uC2E0 \uB429\uB2C8\uB2E4.",
|
|
144
|
+
INVALID_SESSION_AUTO_REFRESH: true,
|
|
145
|
+
ENABLE_ACCESSIBILITY: true,
|
|
146
|
+
USE_CUSTOM_ALERT: false,
|
|
147
|
+
FUNCTION_KEY_BUTTON_STYLE: "text"
|
|
148
|
+
};
|
|
149
|
+
var getServicePath2 = (service, env) => {
|
|
106
150
|
if (!salesFrontendUtils.isClient()) {
|
|
107
151
|
return;
|
|
108
152
|
}
|
|
109
|
-
const env = salesFrontendUtils.getEnvironmentFromHostname(location.hostname);
|
|
110
153
|
const convertedEnv = env === "local" ? "stg" : env;
|
|
111
154
|
return `https://nxl-${convertedEnv !== "prd" ? `${service}-${convertedEnv}` : service}.hanwhalife.com`;
|
|
112
155
|
};
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
156
|
+
var getKeypadServicePath = (env) => {
|
|
157
|
+
return `${getServicePath2(KEYPAD_SERVICE_PATH.XKP, env)}/xkp/xkscriptservice`;
|
|
158
|
+
};
|
|
159
|
+
var getKeypadContentsPath = (env, subPath = "") => {
|
|
160
|
+
const basePath = `${getServicePath2(KEYPAD_SERVICE_PATH.NLC, env)}/cnts-files/xkeyboard`;
|
|
161
|
+
return `${basePath}${subPath}`;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/features/keypad/libs/config.ts
|
|
165
|
+
var createKeypadConfig = () => {
|
|
166
|
+
const env = salesFrontendUtils.getEnvironmentFromHostname(salesFrontendUtils.isClient() ? location.hostname : "");
|
|
167
|
+
const keypadServicePath = getKeypadServicePath(env);
|
|
168
|
+
return {
|
|
169
|
+
version: DEFAULT_KEYPAD_CONFIG.VERSION,
|
|
121
170
|
server: keypadServicePath,
|
|
122
|
-
contextRoot:
|
|
123
|
-
cssPath:
|
|
124
|
-
logoImgPath:
|
|
125
|
-
inputObjectBackgroundColor:
|
|
126
|
-
inputObjectBorderStyle:
|
|
127
|
-
invalidSessionErrorMessage:
|
|
128
|
-
invalidSessionAutoRefresh:
|
|
129
|
-
enableAccessibility:
|
|
130
|
-
useCustomAlert:
|
|
131
|
-
functionKeyButtonStyle:
|
|
132
|
-
maxInputSize:
|
|
133
|
-
textInputView:
|
|
134
|
-
touchOption:
|
|
171
|
+
contextRoot: getKeypadContentsPath(env, "/js"),
|
|
172
|
+
cssPath: getKeypadContentsPath(env, `/css/${KEYPAD_STYLES.MOBILE}`),
|
|
173
|
+
logoImgPath: getKeypadContentsPath(env, "/img/logo.png"),
|
|
174
|
+
inputObjectBackgroundColor: DEFAULT_KEYPAD_CONFIG.INPUT_BACKGROUND_COLOR,
|
|
175
|
+
inputObjectBorderStyle: DEFAULT_KEYPAD_CONFIG.INPUT_BORDER_STYLE,
|
|
176
|
+
invalidSessionErrorMessage: DEFAULT_KEYPAD_CONFIG.INVALID_SESSION_MESSAGE,
|
|
177
|
+
invalidSessionAutoRefresh: DEFAULT_KEYPAD_CONFIG.INVALID_SESSION_AUTO_REFRESH,
|
|
178
|
+
enableAccessibility: DEFAULT_KEYPAD_CONFIG.ENABLE_ACCESSIBILITY,
|
|
179
|
+
useCustomAlert: DEFAULT_KEYPAD_CONFIG.USE_CUSTOM_ALERT,
|
|
180
|
+
functionKeyButtonStyle: DEFAULT_KEYPAD_CONFIG.FUNCTION_KEY_BUTTON_STYLE,
|
|
181
|
+
maxInputSize: DEFAULT_KEYPAD_CONFIG.MAX_INPUT_SIZE,
|
|
182
|
+
textInputView: DEFAULT_KEYPAD_CONFIG.TEXT_INPUT_VIEW,
|
|
183
|
+
touchOption: DEFAULT_KEYPAD_CONFIG.TOUCH_OPTION
|
|
135
184
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
existingLink.parentNode.removeChild(existingLink);
|
|
149
|
-
}
|
|
150
|
-
const linkElement = document.createElement("link");
|
|
151
|
-
linkElement.id = "xkStyle";
|
|
152
|
-
linkElement.rel = "stylesheet";
|
|
153
|
-
linkElement.type = "text/css";
|
|
154
|
-
linkElement.href = window.XKConfigMobile.cssPath;
|
|
155
|
-
headTag.appendChild(linkElement);
|
|
156
|
-
});
|
|
185
|
+
};
|
|
186
|
+
var initializeGlobalConfig = () => {
|
|
187
|
+
if (salesFrontendUtils.isClient() === false) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const config = createKeypadConfig();
|
|
191
|
+
window.XKConfigMobile = config;
|
|
192
|
+
return config;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/features/keypad/libs/keypad-manager.ts
|
|
196
|
+
var createKeypadManager = () => {
|
|
157
197
|
const keypads = {};
|
|
158
|
-
const getKeypad = (name) =>
|
|
198
|
+
const getKeypad = (name) => {
|
|
199
|
+
return keypads[name];
|
|
200
|
+
};
|
|
159
201
|
const setKeypad = (name, keypad) => {
|
|
160
202
|
keypads[name] = keypad;
|
|
161
203
|
return keypad;
|
|
@@ -172,7 +214,12 @@ var XKeyboardMobileInstance = (() => {
|
|
|
172
214
|
});
|
|
173
215
|
};
|
|
174
216
|
const newKeypad = (name) => {
|
|
175
|
-
|
|
217
|
+
const { XKModule } = window;
|
|
218
|
+
if (!XKModule) {
|
|
219
|
+
console.error("[XKeyboard] XKModule\uC774 \uB85C\uB4DC\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.");
|
|
220
|
+
return void 0;
|
|
221
|
+
}
|
|
222
|
+
return setKeypad(name, new XKModule());
|
|
176
223
|
};
|
|
177
224
|
return {
|
|
178
225
|
keypads,
|
|
@@ -182,9 +229,166 @@ var XKeyboardMobileInstance = (() => {
|
|
|
182
229
|
removeKeypad,
|
|
183
230
|
closeAll
|
|
184
231
|
};
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// src/features/keypad/libs/script-loader.ts
|
|
235
|
+
var isScriptsLoaded = false;
|
|
236
|
+
var loadingPromise = null;
|
|
237
|
+
var disableDocumentEvents = () => {
|
|
238
|
+
if (typeof document === "undefined") {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
document.oncontextmenu = () => false;
|
|
242
|
+
document.ondragstart = () => false;
|
|
243
|
+
document.onselectstart = () => false;
|
|
244
|
+
};
|
|
245
|
+
var loadKeypadStyles = (cssPath) => {
|
|
246
|
+
if (typeof document === "undefined") {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const headTag = document.head;
|
|
250
|
+
const existingLink = document.getElementById("xkStyle");
|
|
251
|
+
if (existingLink?.parentNode) {
|
|
252
|
+
existingLink.parentNode.removeChild(existingLink);
|
|
253
|
+
}
|
|
254
|
+
const linkElement = document.createElement("link");
|
|
255
|
+
linkElement.id = "xkStyle";
|
|
256
|
+
linkElement.rel = "stylesheet";
|
|
257
|
+
linkElement.type = "text/css";
|
|
258
|
+
linkElement.href = cssPath;
|
|
259
|
+
headTag.appendChild(linkElement);
|
|
260
|
+
};
|
|
261
|
+
var loadKeypadScripts = async (config) => {
|
|
262
|
+
if (isScriptsLoaded) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (loadingPromise) {
|
|
266
|
+
return loadingPromise;
|
|
267
|
+
}
|
|
268
|
+
loadingPromise = (async () => {
|
|
269
|
+
try {
|
|
270
|
+
disableDocumentEvents();
|
|
271
|
+
const scriptUrl = `${config.contextRoot}/${KEYPAD_SCRIPTS.MOBILE}`;
|
|
272
|
+
console.log("scriptUrl::", scriptUrl);
|
|
273
|
+
await loadScript(scriptUrl);
|
|
274
|
+
loadKeypadStyles(config.cssPath);
|
|
275
|
+
isScriptsLoaded = true;
|
|
276
|
+
} catch (error) {
|
|
277
|
+
loadingPromise = null;
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
})();
|
|
281
|
+
return loadingPromise;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/features/keypad/libs/index.ts
|
|
285
|
+
var XKeyboardMobileInstance = (() => {
|
|
286
|
+
if (salesFrontendUtils.isClient() === false) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
const config = initializeGlobalConfig();
|
|
290
|
+
if (!config) {
|
|
291
|
+
console.error("[XKeyboard] \uC124\uC815 \uCD08\uAE30\uD654\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
loadKeypadScripts(config).catch((error) => {
|
|
295
|
+
console.error("[XKeyboard] \uC2A4\uD06C\uB9BD\uD2B8 \uB85C\uB4DC \uC2E4\uD328:", error);
|
|
296
|
+
});
|
|
297
|
+
return createKeypadManager();
|
|
185
298
|
})();
|
|
186
299
|
|
|
187
|
-
// src/
|
|
300
|
+
// src/features/keypad/libs/keypad-param.ts
|
|
301
|
+
var createKeypadParam = (options) => {
|
|
302
|
+
const {
|
|
303
|
+
name,
|
|
304
|
+
inputRef,
|
|
305
|
+
keyType,
|
|
306
|
+
maxLength,
|
|
307
|
+
numberKeyRowCount,
|
|
308
|
+
onInputChange,
|
|
309
|
+
onKeypadClose,
|
|
310
|
+
keypad,
|
|
311
|
+
setIsShow,
|
|
312
|
+
setKeypadId,
|
|
313
|
+
removeKeypad
|
|
314
|
+
} = options;
|
|
315
|
+
return {
|
|
316
|
+
name: `xk-pad-${name}`,
|
|
317
|
+
editBox: inputRef,
|
|
318
|
+
keyType,
|
|
319
|
+
width: KEYPAD_DEFAULTS.WIDTH,
|
|
320
|
+
position: { top: KEYPAD_DEFAULTS.POSITION_TOP, left: null },
|
|
321
|
+
viewType: KEYPAD_DEFAULTS.VIEW_TYPE,
|
|
322
|
+
closeDelay: KEYPAD_DEFAULTS.CLOSE_DELAY,
|
|
323
|
+
autoKeyResize: true,
|
|
324
|
+
isE2E: true,
|
|
325
|
+
onlyMobile: false,
|
|
326
|
+
hasPressEffect: true,
|
|
327
|
+
maxLength,
|
|
328
|
+
numberKeyRowCount,
|
|
329
|
+
onInputChange: createInputChangeHandler({
|
|
330
|
+
maxLength,
|
|
331
|
+
keypad,
|
|
332
|
+
setIsShow,
|
|
333
|
+
setKeypadId,
|
|
334
|
+
onInputChange
|
|
335
|
+
}),
|
|
336
|
+
onKeypadClose: createCloseHandler({
|
|
337
|
+
name,
|
|
338
|
+
inputRef,
|
|
339
|
+
keyType,
|
|
340
|
+
keypad,
|
|
341
|
+
setIsShow,
|
|
342
|
+
setKeypadId,
|
|
343
|
+
onKeypadClose,
|
|
344
|
+
removeKeypad
|
|
345
|
+
})
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
var createInputChangeHandler = (options) => {
|
|
349
|
+
const { maxLength, keypad, setIsShow, setKeypadId, onInputChange } = options;
|
|
350
|
+
return (newLength) => {
|
|
351
|
+
onInputChange(newLength);
|
|
352
|
+
if (maxLength > 0 && newLength >= maxLength && keypad.isOpend()) {
|
|
353
|
+
keypad.close();
|
|
354
|
+
setIsShow(false);
|
|
355
|
+
setKeypadId(null);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
var createCloseHandler = (options) => {
|
|
360
|
+
const { name, inputRef, keyType, keypad, setIsShow, setKeypadId, onKeypadClose, removeKeypad } = options;
|
|
361
|
+
return () => {
|
|
362
|
+
const sessionInfo = keypad.get_sessionInfo();
|
|
363
|
+
const length = calculateInputLength(sessionInfo.input);
|
|
364
|
+
const response = {
|
|
365
|
+
length,
|
|
366
|
+
element: inputRef,
|
|
367
|
+
sessionInfo: {
|
|
368
|
+
input: sessionInfo.input,
|
|
369
|
+
sessionId: sessionInfo.sessionId,
|
|
370
|
+
secToken: sessionInfo.secToken
|
|
371
|
+
},
|
|
372
|
+
keyType,
|
|
373
|
+
name
|
|
374
|
+
};
|
|
375
|
+
setIsShow(false);
|
|
376
|
+
setKeypadId(null);
|
|
377
|
+
onKeypadClose(response);
|
|
378
|
+
removeKeypad(name);
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
var calculateInputLength = (input) => {
|
|
382
|
+
if (!input || input.length === 0) {
|
|
383
|
+
return 0;
|
|
384
|
+
}
|
|
385
|
+
if (input.indexOf(INPUT_SEPARATOR) >= 0) {
|
|
386
|
+
return input.split(INPUT_SEPARATOR).length;
|
|
387
|
+
}
|
|
388
|
+
return 0;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// src/features/keypad/types/keypad-message.enum.ts
|
|
188
392
|
var KeypadMessageTypeEnum = /* @__PURE__ */ ((KeypadMessageTypeEnum2) => {
|
|
189
393
|
KeypadMessageTypeEnum2[KeypadMessageTypeEnum2["NotSupportDevice"] = -1] = "NotSupportDevice";
|
|
190
394
|
KeypadMessageTypeEnum2[KeypadMessageTypeEnum2["Already"] = -2] = "Already";
|
|
@@ -192,7 +396,7 @@ var KeypadMessageTypeEnum = /* @__PURE__ */ ((KeypadMessageTypeEnum2) => {
|
|
|
192
396
|
})(KeypadMessageTypeEnum || {});
|
|
193
397
|
var keypad_message_enum_default = KeypadMessageTypeEnum;
|
|
194
398
|
|
|
195
|
-
// src/types/keypad-mode.enum.ts
|
|
399
|
+
// src/features/keypad/types/keypad-mode.enum.ts
|
|
196
400
|
var KeypadModeEnum = /* @__PURE__ */ ((KeypadModeEnum2) => {
|
|
197
401
|
KeypadModeEnum2["QWERTY_SMART"] = "qwertysmart";
|
|
198
402
|
KeypadModeEnum2["NUMBER"] = "number";
|
|
@@ -200,172 +404,143 @@ var KeypadModeEnum = /* @__PURE__ */ ((KeypadModeEnum2) => {
|
|
|
200
404
|
})(KeypadModeEnum || {});
|
|
201
405
|
var keypad_mode_enum_default = KeypadModeEnum;
|
|
202
406
|
|
|
203
|
-
// src/
|
|
204
|
-
var
|
|
205
|
-
|
|
206
|
-
const r = Math.random() * 16 || 0, v = c === "x" ? r : r && 3 || 8;
|
|
207
|
-
return v.toString(16);
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
// src/hooks/use-keypad.ts
|
|
407
|
+
// src/features/keypad/hooks/use-keypad.tsx
|
|
408
|
+
var keypadCounter = 0;
|
|
409
|
+
var generateKeypadId = () => `kp-${++keypadCounter}`;
|
|
212
410
|
function useKeypad() {
|
|
213
411
|
const [isShow, setIsShow] = React2.useState(false);
|
|
412
|
+
const [keypadId, setKeypadId] = React2.useState(null);
|
|
214
413
|
const show = React2.useCallback(
|
|
215
|
-
(inputRef, onInputChange, onKeypadClose, keyType = keypad_mode_enum_default.QWERTY_SMART, maxLength, numberKeyRowCount) => {
|
|
216
|
-
const name = uuidv4();
|
|
414
|
+
(inputRef, onInputChange, onKeypadClose, keyType = keypad_mode_enum_default.QWERTY_SMART, maxLength = 0, numberKeyRowCount = KEYPAD_DEFAULTS.NUMBER_KEY_ROW_COUNT) => {
|
|
217
415
|
if (!XKeyboardMobileInstance) {
|
|
416
|
+
console.warn("[useKeypad] XKeyboardMobileInstance\uAC00 \uCD08\uAE30\uD654\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.");
|
|
218
417
|
return;
|
|
219
418
|
}
|
|
220
|
-
|
|
419
|
+
const name = generateKeypadId();
|
|
420
|
+
const keypad = getOrCreateKeypad(name);
|
|
221
421
|
if (!keypad) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
keypad.refresh();
|
|
225
|
-
}
|
|
226
|
-
if (onInputChange && typeof onInputChange === "function") {
|
|
227
|
-
onInputChange(0);
|
|
422
|
+
console.error("[useKeypad] \uD0A4\uD328\uB4DC \uC778\uC2A4\uD134\uC2A4 \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
423
|
+
return;
|
|
228
424
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
425
|
+
onInputChange(0);
|
|
426
|
+
const keyPadParam = createKeypadParam({
|
|
427
|
+
name,
|
|
428
|
+
inputRef,
|
|
232
429
|
keyType,
|
|
233
|
-
width: 100,
|
|
234
|
-
position: { top: 10, left: null },
|
|
235
|
-
viewType: "half",
|
|
236
|
-
closeDelay: 0,
|
|
237
|
-
autoKeyResize: true,
|
|
238
|
-
isE2E: true,
|
|
239
|
-
onlyMobile: false,
|
|
240
|
-
hasPressEffect: true,
|
|
241
430
|
maxLength,
|
|
242
431
|
numberKeyRowCount,
|
|
243
|
-
onInputChange
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
onKeypadClose: () => {
|
|
257
|
-
if (!keypad) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (!XKeyboardMobileInstance) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
if (onKeypadClose && typeof onKeypadClose === "function") {
|
|
264
|
-
const sessionInfo = keypad.get_sessionInfo();
|
|
265
|
-
let length = 0;
|
|
266
|
-
if (sessionInfo.input && sessionInfo.input.indexOf(",") >= 0) {
|
|
267
|
-
length = sessionInfo.input.split(",").length;
|
|
268
|
-
}
|
|
269
|
-
const res = {
|
|
270
|
-
length,
|
|
271
|
-
element: inputRef,
|
|
272
|
-
sessionInfo: {
|
|
273
|
-
input: sessionInfo.input,
|
|
274
|
-
sessionId: sessionInfo.sessionId,
|
|
275
|
-
secToken: sessionInfo.secToken
|
|
276
|
-
},
|
|
277
|
-
keyType,
|
|
278
|
-
name
|
|
279
|
-
};
|
|
280
|
-
setIsShow(false);
|
|
281
|
-
onKeypadClose(res);
|
|
282
|
-
}
|
|
283
|
-
XKeyboardMobileInstance.removeKeypad(name);
|
|
284
|
-
if (!onKeypadClose) {
|
|
285
|
-
throw new Error("not found onKeypadClose");
|
|
286
|
-
}
|
|
287
|
-
if (typeof onKeypadClose !== "function") {
|
|
288
|
-
throw new Error("not found onKeypadClose");
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
const aRet = keypad.initialize(keyPadParam);
|
|
293
|
-
if (aRet === keypad_message_enum_default.NotSupportDevice) {
|
|
294
|
-
alert("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uAE30\uAE30 \uC785\uB2C8\uB2E4.");
|
|
295
|
-
return;
|
|
296
|
-
} else if (aRet === keypad_message_enum_default.Already) {
|
|
432
|
+
onInputChange,
|
|
433
|
+
onKeypadClose,
|
|
434
|
+
keypad,
|
|
435
|
+
setIsShow,
|
|
436
|
+
setKeypadId,
|
|
437
|
+
removeKeypad: (n) => XKeyboardMobileInstance?.removeKeypad(n)
|
|
438
|
+
});
|
|
439
|
+
const result = keypad.initialize(keyPadParam);
|
|
440
|
+
if (!handleInitializeResult(result)) {
|
|
441
|
+
console.warn("[useKeypad] \uD0A4\uD328\uB4DC \uCD08\uAE30\uD654 \uC2E4\uD328:", result);
|
|
297
442
|
return;
|
|
298
443
|
}
|
|
444
|
+
setKeypadId(name);
|
|
299
445
|
setIsShow(true);
|
|
300
446
|
},
|
|
301
447
|
[]
|
|
302
448
|
);
|
|
303
|
-
const
|
|
449
|
+
const getOrCreateKeypad = (name) => {
|
|
304
450
|
if (!XKeyboardMobileInstance) {
|
|
305
|
-
return;
|
|
451
|
+
return void 0;
|
|
306
452
|
}
|
|
307
|
-
|
|
308
|
-
if (!
|
|
309
|
-
|
|
453
|
+
let keypad = XKeyboardMobileInstance.getKeypad(name);
|
|
454
|
+
if (!keypad) {
|
|
455
|
+
keypad = XKeyboardMobileInstance.newKeypad(name);
|
|
456
|
+
} else {
|
|
457
|
+
keypad.refresh();
|
|
310
458
|
}
|
|
311
|
-
return
|
|
459
|
+
return keypad;
|
|
312
460
|
};
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
|
|
461
|
+
const handleInitializeResult = (result) => {
|
|
462
|
+
if (result === keypad_message_enum_default.NotSupportDevice) {
|
|
463
|
+
alert("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uAE30\uAE30 \uC785\uB2C8\uB2E4.");
|
|
464
|
+
return false;
|
|
316
465
|
}
|
|
317
|
-
if (
|
|
318
|
-
return
|
|
319
|
-
} else {
|
|
320
|
-
const keypadIds = Object.keys(XKeyboardMobileInstance.keypads);
|
|
321
|
-
for (const keypadId of keypadIds) {
|
|
322
|
-
const targetKeypad = XKeyboardMobileInstance.keypads[keypadId];
|
|
323
|
-
if (targetKeypad && targetKeypad.isOpen()) {
|
|
324
|
-
return targetKeypad;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
466
|
+
if (result === keypad_message_enum_default.Already) {
|
|
467
|
+
return false;
|
|
327
468
|
}
|
|
469
|
+
return true;
|
|
328
470
|
};
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
};
|
|
333
|
-
const close = (name) => {
|
|
334
|
-
const targetKeypad = find(name);
|
|
335
|
-
if (targetKeypad) {
|
|
336
|
-
targetKeypad.close();
|
|
337
|
-
setIsShow(false);
|
|
471
|
+
const getValue = React2.useCallback((name) => {
|
|
472
|
+
if (!XKeyboardMobileInstance) {
|
|
473
|
+
return void 0;
|
|
338
474
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
475
|
+
const targetKeypad = XKeyboardMobileInstance.keypads[name];
|
|
476
|
+
return targetKeypad?.get_sessionInfo() ?? null;
|
|
477
|
+
}, []);
|
|
478
|
+
const find = React2.useCallback((name) => {
|
|
479
|
+
if (!XKeyboardMobileInstance) {
|
|
480
|
+
return void 0;
|
|
345
481
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const targetKeypad = find(name);
|
|
349
|
-
if (targetKeypad) {
|
|
350
|
-
targetKeypad.refresh();
|
|
482
|
+
if (name) {
|
|
483
|
+
return XKeyboardMobileInstance.keypads[name];
|
|
351
484
|
}
|
|
352
|
-
|
|
485
|
+
const keypadIds = Object.keys(XKeyboardMobileInstance.keypads);
|
|
486
|
+
for (const keypadId2 of keypadIds) {
|
|
487
|
+
const targetKeypad = XKeyboardMobileInstance.keypads[keypadId2];
|
|
488
|
+
if (targetKeypad?.isOpen()) {
|
|
489
|
+
return targetKeypad;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return void 0;
|
|
493
|
+
}, []);
|
|
494
|
+
const isOpen = React2.useCallback(
|
|
495
|
+
(name) => {
|
|
496
|
+
return !!find(name);
|
|
497
|
+
},
|
|
498
|
+
[find]
|
|
499
|
+
);
|
|
500
|
+
const close = React2.useCallback(
|
|
501
|
+
(name) => {
|
|
502
|
+
const targetKeypad = find(name);
|
|
503
|
+
if (targetKeypad) {
|
|
504
|
+
targetKeypad.close();
|
|
505
|
+
setIsShow(false);
|
|
506
|
+
setKeypadId(null);
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
[find]
|
|
510
|
+
);
|
|
511
|
+
const clear = React2.useCallback(
|
|
512
|
+
(name) => {
|
|
513
|
+
const targetKeypad = find(name);
|
|
514
|
+
if (targetKeypad) {
|
|
515
|
+
targetKeypad.clear();
|
|
516
|
+
setIsShow(false);
|
|
517
|
+
setKeypadId(null);
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
[find]
|
|
521
|
+
);
|
|
522
|
+
const refresh = React2.useCallback(
|
|
523
|
+
(name) => {
|
|
524
|
+
const targetKeypad = find(name);
|
|
525
|
+
targetKeypad?.refresh();
|
|
526
|
+
},
|
|
527
|
+
[find]
|
|
528
|
+
);
|
|
353
529
|
React2.useEffect(() => {
|
|
354
530
|
const handleMouseDown = (event) => {
|
|
355
531
|
if (!XKeyboardMobileInstance) {
|
|
356
532
|
return;
|
|
357
533
|
}
|
|
358
|
-
const keypadAlertDivTag = document.querySelector(
|
|
534
|
+
const keypadAlertDivTag = document.querySelector(KEYPAD_SELECTORS.ALERT);
|
|
359
535
|
const keypadDivTag = keypadAlertDivTag?.parentElement;
|
|
360
536
|
if (keypadDivTag && !keypadDivTag.contains(event.target)) {
|
|
361
537
|
XKeyboardMobileInstance.closeAll();
|
|
362
538
|
setIsShow(false);
|
|
539
|
+
setKeypadId(null);
|
|
363
540
|
}
|
|
364
541
|
};
|
|
365
542
|
document.addEventListener("mousedown", handleMouseDown);
|
|
366
|
-
return () =>
|
|
367
|
-
document.removeEventListener("mousedown", handleMouseDown);
|
|
368
|
-
};
|
|
543
|
+
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
369
544
|
}, []);
|
|
370
545
|
return {
|
|
371
546
|
show,
|
|
@@ -375,177 +550,362 @@ function useKeypad() {
|
|
|
375
550
|
getValue,
|
|
376
551
|
isOpen,
|
|
377
552
|
find,
|
|
378
|
-
isShow
|
|
553
|
+
isShow,
|
|
554
|
+
keypadId
|
|
379
555
|
};
|
|
380
556
|
}
|
|
381
|
-
|
|
382
|
-
|
|
557
|
+
var createMaskedValue = (length) => {
|
|
558
|
+
return "".padStart(length, MASK_CHAR);
|
|
559
|
+
};
|
|
560
|
+
var getInputLength = (input) => {
|
|
561
|
+
if (!input || input.length === 0) {
|
|
562
|
+
return 0;
|
|
563
|
+
}
|
|
564
|
+
return input.split(INPUT_SEPARATOR).length;
|
|
565
|
+
};
|
|
566
|
+
var KEYPAD_ID_PREFIX = "xk-pad-";
|
|
567
|
+
var findKeypadById = (keypadId) => {
|
|
568
|
+
const fullId = `${KEYPAD_ID_PREFIX}${keypadId}`;
|
|
569
|
+
const element = document.getElementById(fullId);
|
|
570
|
+
if (element && element.offsetHeight > 0) {
|
|
571
|
+
return element;
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
};
|
|
575
|
+
var waitForKeypadElement = (keypadId) => {
|
|
576
|
+
return new Promise((resolve) => {
|
|
577
|
+
const existing = findKeypadById(keypadId);
|
|
578
|
+
if (existing) {
|
|
579
|
+
resolve(existing);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const fullId = `${KEYPAD_ID_PREFIX}${keypadId}`;
|
|
583
|
+
const observer = new MutationObserver((_mutations, obs) => {
|
|
584
|
+
const keypad = document.getElementById(fullId);
|
|
585
|
+
if (keypad && keypad.offsetHeight > 0) {
|
|
586
|
+
obs.disconnect();
|
|
587
|
+
resolve(keypad);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
observer.observe(document.body, {
|
|
591
|
+
childList: true,
|
|
592
|
+
subtree: true
|
|
593
|
+
});
|
|
594
|
+
setTimeout(() => {
|
|
595
|
+
observer.disconnect();
|
|
596
|
+
resolve(null);
|
|
597
|
+
}, 3e3);
|
|
598
|
+
});
|
|
599
|
+
};
|
|
600
|
+
var toKeypadRect = (rect) => ({
|
|
601
|
+
height: rect.height,
|
|
602
|
+
top: rect.top,
|
|
603
|
+
bottom: rect.bottom,
|
|
604
|
+
width: rect.width,
|
|
605
|
+
left: rect.left,
|
|
606
|
+
right: rect.right
|
|
607
|
+
});
|
|
608
|
+
function Keypad({
|
|
609
|
+
value,
|
|
610
|
+
onChange,
|
|
611
|
+
mode,
|
|
612
|
+
maxLength,
|
|
613
|
+
inputElement,
|
|
614
|
+
onShow,
|
|
615
|
+
numberKeyRowCount = KEYPAD_DEFAULTS.NUMBER_KEY_ROW_COUNT,
|
|
616
|
+
wrapId
|
|
617
|
+
}) {
|
|
618
|
+
const { show, isShow, keypadId } = useKeypad();
|
|
383
619
|
const inputRef = React2.useRef(null);
|
|
384
620
|
const [maskedValue, setMaskedValue] = React2.useState("");
|
|
385
|
-
|
|
621
|
+
React2.useEffect(() => {
|
|
622
|
+
const input = inputRef.current;
|
|
623
|
+
if (!input) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (isShow && keypadId) {
|
|
627
|
+
waitForKeypadElement(keypadId).then((keypadElement) => {
|
|
628
|
+
if (keypadElement) {
|
|
629
|
+
const rect = keypadElement.getBoundingClientRect();
|
|
630
|
+
const wrap = wrapId && document.getElementById(wrapId);
|
|
631
|
+
if (wrap) {
|
|
632
|
+
const inputRect = input.getBoundingClientRect();
|
|
633
|
+
if (inputRect.bottom > rect.top) {
|
|
634
|
+
const diff = inputRect.bottom - rect.top;
|
|
635
|
+
wrap.style.transform = `translateY(-${diff}px)`;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
onShow?.({
|
|
639
|
+
isShow: true,
|
|
640
|
+
keypadElement,
|
|
641
|
+
keypadRect: toKeypadRect(rect),
|
|
642
|
+
inputElement: input
|
|
643
|
+
});
|
|
644
|
+
} else {
|
|
645
|
+
onShow?.({ isShow: true, keypadElement: null, keypadRect: null, inputElement: input });
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
} else {
|
|
649
|
+
const wrap = wrapId && document.getElementById(wrapId);
|
|
650
|
+
if (wrap) {
|
|
651
|
+
wrap.style.transform = "";
|
|
652
|
+
}
|
|
653
|
+
onShow?.({ isShow: false, keypadElement: null, keypadRect: null, inputElement: input });
|
|
654
|
+
}
|
|
655
|
+
}, [isShow, keypadId, onShow, wrapId]);
|
|
656
|
+
const handleKeypadClose = React2.useCallback(
|
|
386
657
|
(res) => {
|
|
387
658
|
onChange(res.sessionInfo);
|
|
388
659
|
},
|
|
389
660
|
[onChange]
|
|
390
661
|
);
|
|
391
|
-
const
|
|
662
|
+
const handleInputChange = React2.useCallback(
|
|
392
663
|
(length) => {
|
|
393
664
|
if (length === 0) {
|
|
394
665
|
onChange(null);
|
|
395
666
|
}
|
|
396
|
-
setMaskedValue(
|
|
667
|
+
setMaskedValue(createMaskedValue(length));
|
|
397
668
|
},
|
|
398
|
-
[onChange
|
|
669
|
+
[onChange]
|
|
399
670
|
);
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
};
|
|
411
|
-
const cloneElement = React2__default.default.cloneElement(inputElement, {
|
|
412
|
-
ref: inputRef,
|
|
413
|
-
value: maskedValue,
|
|
414
|
-
onClick: enhancedOnClick(inputElement.props.onClick, handleKeypad)
|
|
415
|
-
// iskeypadactive: isShow
|
|
416
|
-
});
|
|
671
|
+
const handleOpenKeypad = React2.useCallback(() => {
|
|
672
|
+
if (!inputRef.current) {
|
|
673
|
+
console.error("[Keypad] inputRef\uAC00 \uC5F0\uACB0\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.");
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
show(inputRef.current, handleInputChange, handleKeypadClose, mode, maxLength, numberKeyRowCount);
|
|
677
|
+
}, [show, handleInputChange, handleKeypadClose, mode, maxLength, numberKeyRowCount]);
|
|
678
|
+
const combinedOnClick = React2.useCallback(() => {
|
|
679
|
+
inputElement.props.onClick?.();
|
|
680
|
+
handleOpenKeypad();
|
|
681
|
+
}, [inputElement.props.onClick, handleOpenKeypad]);
|
|
417
682
|
React2.useEffect(() => {
|
|
418
|
-
const length = value?.input
|
|
419
|
-
setMaskedValue(
|
|
683
|
+
const length = getInputLength(value?.input);
|
|
684
|
+
setMaskedValue(createMaskedValue(length));
|
|
420
685
|
}, [value]);
|
|
421
686
|
React2.useEffect(() => {
|
|
422
687
|
if (inputRef.current && !(inputRef.current instanceof HTMLInputElement)) {
|
|
423
|
-
throw new Error("
|
|
688
|
+
throw new Error("[Keypad] inputElement\uB294 HTMLInputElement\uB97C \uB80C\uB354\uB9C1\uD574\uC57C \uD569\uB2C8\uB2E4.");
|
|
424
689
|
}
|
|
425
690
|
}, []);
|
|
426
|
-
|
|
691
|
+
const clonedElement = React2.useMemo(
|
|
692
|
+
() => React2__default.default.cloneElement(inputElement, {
|
|
693
|
+
ref: inputRef,
|
|
694
|
+
value: maskedValue,
|
|
695
|
+
onClick: combinedOnClick
|
|
696
|
+
}),
|
|
697
|
+
[inputElement, maskedValue, combinedOnClick]
|
|
698
|
+
);
|
|
699
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: clonedElement });
|
|
427
700
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
701
|
+
|
|
702
|
+
// src/features/nxl-one/libs/nxl-one.ts
|
|
703
|
+
var NXL_ONE_ENV_URLS = {
|
|
704
|
+
dev: "https://nxl-nlc-dev.hanwhalife.com",
|
|
705
|
+
stg: "https://nxl-nlc-stg.hanwhalife.com",
|
|
706
|
+
//prod: 'https://nxl-nlc.hanwhalife.com',
|
|
707
|
+
prd: "https://nxl-nlc.hanwhalife.com"
|
|
708
|
+
};
|
|
709
|
+
var NXL_ONE_AUTH_PATH = "/auth/v1";
|
|
710
|
+
var NXL_ONE_DEFAULT_POPUP = {
|
|
711
|
+
width: 744,
|
|
712
|
+
height: 720,
|
|
713
|
+
windowName: "self_cert"
|
|
714
|
+
};
|
|
715
|
+
var NXL_ONE_DEFAULT_IFRAME = {
|
|
716
|
+
sandbox: "allow-scripts allow-forms allow-same-origin"
|
|
717
|
+
};
|
|
718
|
+
var detectEnvFromUrl = () => {
|
|
719
|
+
if (typeof window === "undefined") {
|
|
720
|
+
return "prd";
|
|
721
|
+
}
|
|
722
|
+
const { href } = window.location;
|
|
723
|
+
if (href.includes("localhost") || href.includes("dev")) {
|
|
724
|
+
return "dev";
|
|
725
|
+
}
|
|
726
|
+
if (href.includes("stg")) {
|
|
727
|
+
return "stg";
|
|
728
|
+
}
|
|
729
|
+
return "prd";
|
|
730
|
+
};
|
|
731
|
+
var getBaseUrl = (env) => NXL_ONE_ENV_URLS[env ?? detectEnvFromUrl()];
|
|
732
|
+
var buildAuthUrl = (baseUrl, params, mode) => {
|
|
733
|
+
const url = new URL(NXL_ONE_AUTH_PATH, baseUrl);
|
|
734
|
+
url.searchParams.set("bizCode", params.bizCode);
|
|
735
|
+
url.searchParams.set("tmplCode", params.tmplCode);
|
|
736
|
+
url.searchParams.set("m", mode);
|
|
737
|
+
if (params.nlcCtfnId) {
|
|
738
|
+
url.searchParams.set("nlcCtfnId", params.nlcCtfnId);
|
|
739
|
+
}
|
|
740
|
+
if (params.t) {
|
|
741
|
+
url.searchParams.set("t", params.t);
|
|
742
|
+
}
|
|
743
|
+
if (params.ncsrInfoUuid) {
|
|
744
|
+
url.searchParams.set("ncsrInfoUuid", params.ncsrInfoUuid);
|
|
745
|
+
}
|
|
746
|
+
return url.toString();
|
|
747
|
+
};
|
|
748
|
+
var calcPopupCenter = (width, height) => ({
|
|
749
|
+
left: window.screenX + (window.outerWidth - width) / 2,
|
|
750
|
+
top: window.screenY + (window.outerHeight - height) / 2
|
|
751
|
+
});
|
|
752
|
+
var NXL_ONE_ERROR_CODES = {
|
|
753
|
+
/** 팝업이 브라우저에 의해 차단됨 */
|
|
754
|
+
POPUP_BLOCKED: "POPUP_BLOCKED",
|
|
755
|
+
/** 사용자가 인증을 취소함 */
|
|
756
|
+
AUTH_CANCELLED: "AUTH_CANCELLED",
|
|
757
|
+
/** 인증 실패 */
|
|
758
|
+
AUTH_FAILED: "AUTH_FAILED",
|
|
759
|
+
/** 잘못된 응답 */
|
|
760
|
+
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
761
|
+
};
|
|
762
|
+
var ERROR_MESSAGES = {
|
|
763
|
+
POPUP_BLOCKED: "\uD31D\uC5C5\uC774 \uCC28\uB2E8\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uD31D\uC5C5 \uCC28\uB2E8\uC744 \uD574\uC81C\uD574\uC8FC\uC138\uC694.",
|
|
764
|
+
AUTH_CANCELLED: "\uC778\uC99D\uC774 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",
|
|
765
|
+
AUTH_FAILED: "\uC778\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.",
|
|
766
|
+
INVALID_RESPONSE: "\uC798\uBABB\uB41C \uC751\uB2F5\uC744 \uBC1B\uC558\uC2B5\uB2C8\uB2E4."
|
|
767
|
+
};
|
|
768
|
+
var createNxlOneError = (code, customMessage) => ({
|
|
769
|
+
code,
|
|
770
|
+
message: customMessage ?? ERROR_MESSAGES[code]
|
|
771
|
+
});
|
|
772
|
+
var isNxlOneError = (value) => typeof value === "object" && value !== null && "code" in value && "message" in value && Object.values(NXL_ONE_ERROR_CODES).includes(value.code);
|
|
773
|
+
function NxlOneIframe({
|
|
774
|
+
bizCode,
|
|
775
|
+
tmplCode,
|
|
776
|
+
ncsrInfoUuid,
|
|
777
|
+
nlcCtfnId,
|
|
778
|
+
env,
|
|
779
|
+
width = "100%",
|
|
780
|
+
height = "100%",
|
|
781
|
+
className,
|
|
782
|
+
style,
|
|
783
|
+
allow,
|
|
784
|
+
sandbox = NXL_ONE_DEFAULT_IFRAME.sandbox,
|
|
785
|
+
onSuccess,
|
|
786
|
+
onError,
|
|
787
|
+
onClose,
|
|
788
|
+
strictOrigin = true,
|
|
789
|
+
autoHide = false
|
|
790
|
+
}) {
|
|
791
|
+
const [visible, setVisible] = React2.useState(true);
|
|
792
|
+
const callbacksRef = React2.useRef({ onSuccess, onError, onClose });
|
|
793
|
+
callbacksRef.current = { onSuccess, onError, onClose };
|
|
794
|
+
const baseUrl = env ? getBaseUrl(env) : salesFrontendUtils.getNlcHostFromEnvironment();
|
|
795
|
+
const targetUrl = React2.useMemo(
|
|
796
|
+
() => buildAuthUrl(baseUrl, { bizCode, tmplCode, nlcCtfnId, ncsrInfoUuid }, "iframe"),
|
|
797
|
+
[baseUrl, bizCode, tmplCode, nlcCtfnId, ncsrInfoUuid]
|
|
798
|
+
);
|
|
799
|
+
React2.useEffect(() => {
|
|
800
|
+
const handleMessage = (e) => {
|
|
801
|
+
if (strictOrigin && e.origin !== baseUrl) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const data = e.data;
|
|
805
|
+
if (!data?.action) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const { onSuccess: onSuccess2, onError: onError2, onClose: onClose2 } = callbacksRef.current;
|
|
809
|
+
if (autoHide) {
|
|
810
|
+
setVisible(false);
|
|
811
|
+
}
|
|
812
|
+
switch (data.action) {
|
|
813
|
+
case "complete":
|
|
814
|
+
onSuccess2?.(data);
|
|
815
|
+
break;
|
|
816
|
+
case "error":
|
|
817
|
+
onError2?.(data);
|
|
818
|
+
break;
|
|
819
|
+
case "close":
|
|
820
|
+
onClose2(data);
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
window.addEventListener("message", handleMessage);
|
|
825
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
826
|
+
}, [baseUrl, strictOrigin, autoHide]);
|
|
827
|
+
if (!visible) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
831
|
+
"iframe",
|
|
832
|
+
{
|
|
833
|
+
src: targetUrl,
|
|
834
|
+
width: typeof width === "number" ? `${width}px` : width,
|
|
835
|
+
height: typeof height === "number" ? `${height}px` : height,
|
|
836
|
+
className,
|
|
837
|
+
style: { border: 0, ...style },
|
|
838
|
+
sandbox,
|
|
839
|
+
allow
|
|
442
840
|
}
|
|
443
|
-
|
|
444
|
-
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
function useNxlOne({ bizCode, tmplCode, ncsrInfoUuid, nlcCtfnId, env }) {
|
|
844
|
+
const baseUrl = env ? getBaseUrl(env) : salesFrontendUtils.getNlcHostFromEnvironment();
|
|
845
|
+
const params = React2.useMemo(
|
|
846
|
+
() => ({ bizCode, tmplCode, nlcCtfnId, ncsrInfoUuid }),
|
|
847
|
+
[bizCode, tmplCode, nlcCtfnId, ncsrInfoUuid]
|
|
848
|
+
);
|
|
445
849
|
const redirect = () => {
|
|
446
|
-
|
|
447
|
-
targetUrl.searchParams.set("m", "redirect");
|
|
448
|
-
location.href = targetUrl.toString();
|
|
850
|
+
location.href = buildAuthUrl(baseUrl, params, "redirect");
|
|
449
851
|
};
|
|
450
|
-
const open =
|
|
852
|
+
const open = (options) => {
|
|
451
853
|
return new Promise((resolve, reject) => {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const
|
|
457
|
-
const
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
const popup = window.open(targetUrlBuild.toString(), options && options.windowName || "self_cert", popupFeatures);
|
|
854
|
+
const targetUrl = buildAuthUrl(baseUrl, params, "popup");
|
|
855
|
+
const width = options?.width ?? NXL_ONE_DEFAULT_POPUP.width;
|
|
856
|
+
const height = options?.height ?? NXL_ONE_DEFAULT_POPUP.height;
|
|
857
|
+
const center = calcPopupCenter(width, height);
|
|
858
|
+
const left = options?.left ?? center.left;
|
|
859
|
+
const top = options?.top ?? center.top;
|
|
860
|
+
const windowName = options?.windowName ?? NXL_ONE_DEFAULT_POPUP.windowName;
|
|
861
|
+
const popup = window.open(targetUrl, windowName, `width=${width},height=${height},left=${left},top=${top}`);
|
|
461
862
|
if (!popup) {
|
|
462
|
-
reject(
|
|
863
|
+
reject(createNxlOneError(NXL_ONE_ERROR_CODES.POPUP_BLOCKED));
|
|
463
864
|
return;
|
|
464
865
|
}
|
|
465
866
|
let isSettled = false;
|
|
867
|
+
let popupChecker = 0;
|
|
868
|
+
const cleanup = () => {
|
|
869
|
+
window.removeEventListener("message", handleMessage);
|
|
870
|
+
window.clearInterval(popupChecker);
|
|
871
|
+
};
|
|
466
872
|
const handleMessage = (event) => {
|
|
467
|
-
if (event.origin !==
|
|
873
|
+
if (event.origin !== baseUrl) {
|
|
468
874
|
return;
|
|
469
875
|
}
|
|
470
|
-
if (
|
|
471
|
-
isSettled = true;
|
|
472
|
-
if (event.data) {
|
|
473
|
-
resolve(event.data);
|
|
474
|
-
} else {
|
|
475
|
-
reject("\uC778\uC99D\uC774 \uCDE8\uC18C\uB418\uAC70\uB098 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.");
|
|
476
|
-
}
|
|
477
|
-
popup?.close();
|
|
478
|
-
window.removeEventListener("message", handleMessage);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
window.addEventListener("message", handleMessage);
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
|
-
const Iframe = function({
|
|
485
|
-
height = 720,
|
|
486
|
-
className,
|
|
487
|
-
style,
|
|
488
|
-
allow,
|
|
489
|
-
sandbox = "allow-scripts allow-forms allow-same-origin",
|
|
490
|
-
onSuccess,
|
|
491
|
-
onError,
|
|
492
|
-
onClose,
|
|
493
|
-
strictOrigin = true
|
|
494
|
-
}) {
|
|
495
|
-
const targetUrlBuild = buildUrl();
|
|
496
|
-
targetUrlBuild.searchParams.set("m", "iframe");
|
|
497
|
-
const targetUrl = targetUrlBuild.toString();
|
|
498
|
-
React2.useEffect(() => {
|
|
499
|
-
if (!onSuccess && !onError) {
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
const handler = (e) => {
|
|
503
|
-
const baseUrl = salesFrontendUtils.getNlcHostFromEnvironment();
|
|
504
|
-
if (strictOrigin && e.origin !== baseUrl) {
|
|
876
|
+
if (isSettled) {
|
|
505
877
|
return;
|
|
506
878
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return;
|
|
515
|
-
} else if (onSuccess && d.action === "complete") {
|
|
516
|
-
onSuccess(d);
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
} else if (onError) {
|
|
520
|
-
onError({
|
|
521
|
-
action: "error",
|
|
522
|
-
nlcCtfnId: "",
|
|
523
|
-
redirectUrl: ""
|
|
524
|
-
});
|
|
879
|
+
isSettled = true;
|
|
880
|
+
cleanup();
|
|
881
|
+
popup.close();
|
|
882
|
+
if (event.data) {
|
|
883
|
+
resolve(event.data);
|
|
884
|
+
} else {
|
|
885
|
+
reject(createNxlOneError(NXL_ONE_ERROR_CODES.INVALID_RESPONSE));
|
|
525
886
|
}
|
|
526
887
|
};
|
|
527
|
-
window.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
style: { border: 0, ...style },
|
|
537
|
-
className,
|
|
538
|
-
sandbox,
|
|
539
|
-
...allow ? { allow } : {}
|
|
540
|
-
}
|
|
541
|
-
);
|
|
888
|
+
popupChecker = window.setInterval(() => {
|
|
889
|
+
if (popup.closed && !isSettled) {
|
|
890
|
+
isSettled = true;
|
|
891
|
+
cleanup();
|
|
892
|
+
reject(createNxlOneError(NXL_ONE_ERROR_CODES.AUTH_CANCELLED));
|
|
893
|
+
}
|
|
894
|
+
}, 300);
|
|
895
|
+
window.addEventListener("message", handleMessage);
|
|
896
|
+
});
|
|
542
897
|
};
|
|
543
|
-
return { redirect, open
|
|
898
|
+
return { redirect, open };
|
|
544
899
|
}
|
|
545
900
|
|
|
546
901
|
exports.Keypad = Keypad;
|
|
547
902
|
exports.KeypadModeEnum = keypad_mode_enum_default;
|
|
903
|
+
exports.NXL_ONE_ERROR_CODES = NXL_ONE_ERROR_CODES;
|
|
904
|
+
exports.NxlOneIframe = NxlOneIframe;
|
|
548
905
|
exports.V3Provider = V3Provider;
|
|
906
|
+
exports.createNxlOneError = createNxlOneError;
|
|
907
|
+
exports.isNxlOneError = isNxlOneError;
|
|
908
|
+
exports.useKeypad = useKeypad;
|
|
549
909
|
exports.useNxlOne = useNxlOne;
|
|
550
910
|
exports.useV3 = useV3;
|
|
551
911
|
//# sourceMappingURL=index.cjs.map
|