sales-frontend-components 0.0.63 → 0.0.64
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.js +60 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +61 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { FieldValues, UseControllerProps } from 'react-hook-form';
|
|
|
3
3
|
import { CheckboxButtonProps, CheckboxProps, DatePickerSingleHtmlProps, DatePickerRangeHtmlProps, SegmentGroupHtmlProps, FormField } from 'sales-frontend-design-system';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default from 'react';
|
|
6
|
+
import { getEnvironmentFromHostname } from 'sales-frontend-utils';
|
|
6
7
|
|
|
7
8
|
declare const FormCheckboxButton: <TFormValues extends FieldValues>({ name, control, disabled, children, ...props }: Pick<UseControllerProps<TFormValues>, "name" | "control" | "disabled"> & Omit<CheckboxButtonProps, "id">) => react_jsx_runtime.JSX.Element;
|
|
8
9
|
|
|
@@ -150,8 +151,9 @@ declare const testSignatureBase64Data = "data:image/png;base64,iVBORw0KGgoAAAANS
|
|
|
150
151
|
/**
|
|
151
152
|
* @file 디버그 툴 전체에서 사용되는 공용 TypeScript 타입을 정의합니다.
|
|
152
153
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
|
|
155
|
+
/** 실행 환경 ("local" | "dev" | "stg" | "prd") */
|
|
156
|
+
type Environment = ReturnType<typeof getEnvironmentFromHostname>;
|
|
155
157
|
/** `config.ts`에서 메뉴 아이템을 정의하기 위한 구조 */
|
|
156
158
|
interface MenuItem {
|
|
157
159
|
/** 메뉴의 고유 식별자 (예: 'console-log') */
|
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react'
|
|
|
5
5
|
import styles from './step-indicator/step-indicator.module.scss';
|
|
6
6
|
import styles$1 from './camera/camera.module.scss';
|
|
7
7
|
import styles$2 from './debug-tool/debug-tool.module.scss';
|
|
8
|
-
import { isClient } from 'sales-frontend-utils';
|
|
8
|
+
import { isClient, getEnvironmentFromHostname } from 'sales-frontend-utils';
|
|
9
9
|
import { useDebugStore } from 'sales-frontend-api';
|
|
10
10
|
import styles$3 from './debug-tool/features/network-log/network-log.module.scss';
|
|
11
11
|
|
|
@@ -1056,8 +1056,34 @@ const SEARCH_SECTIONS = [
|
|
|
1056
1056
|
{ value: "response", label: "\uC751\uB2F5" },
|
|
1057
1057
|
{ value: "error", label: "\uC5D0\uB7EC" }
|
|
1058
1058
|
];
|
|
1059
|
+
const getLogInfo = (log) => {
|
|
1060
|
+
if (log.holdStatus === "held") {
|
|
1061
|
+
if ("request" in log) {
|
|
1062
|
+
return log.request;
|
|
1063
|
+
}
|
|
1064
|
+
if ("response" in log) {
|
|
1065
|
+
return log.response;
|
|
1066
|
+
}
|
|
1067
|
+
if ("error" in log) {
|
|
1068
|
+
return log.error;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return log;
|
|
1072
|
+
};
|
|
1059
1073
|
const NetworkLog = ({ onClose }) => {
|
|
1060
|
-
const {
|
|
1074
|
+
const {
|
|
1075
|
+
requests,
|
|
1076
|
+
responses,
|
|
1077
|
+
errors,
|
|
1078
|
+
clear,
|
|
1079
|
+
isHold,
|
|
1080
|
+
toggleHold,
|
|
1081
|
+
heldRequests,
|
|
1082
|
+
heldResponses,
|
|
1083
|
+
heldErrors,
|
|
1084
|
+
playAllRequests,
|
|
1085
|
+
playAllResponses
|
|
1086
|
+
} = useDebugStore();
|
|
1061
1087
|
const [searchTerm, setSearchTerm] = useState("");
|
|
1062
1088
|
const [searchSection, setSearchSection] = useState(SEARCH_SECTIONS[0]?.value);
|
|
1063
1089
|
const allLogs = useMemo(() => {
|
|
@@ -1065,52 +1091,61 @@ const NetworkLog = ({ onClose }) => {
|
|
|
1065
1091
|
requests.forEach((req) => logs.push({ ...req, type: "request" }));
|
|
1066
1092
|
responses.forEach((res) => logs.push({ ...res, type: "response" }));
|
|
1067
1093
|
errors.forEach((err) => logs.push({ ...err, type: "error" }));
|
|
1094
|
+
heldRequests.forEach((req) => logs.push({ ...req, type: "request", holdStatus: "held" }));
|
|
1095
|
+
heldResponses.forEach((res) => logs.push({ ...res, type: "response", holdStatus: "held" }));
|
|
1096
|
+
heldErrors.forEach((err) => logs.push({ ...err, type: "error", holdStatus: "held" }));
|
|
1068
1097
|
logs.sort((a, b) => {
|
|
1069
|
-
const
|
|
1070
|
-
const
|
|
1098
|
+
const aInfo = getLogInfo(a);
|
|
1099
|
+
const bInfo = getLogInfo(b);
|
|
1100
|
+
const aTime = "startTime" in aInfo ? aInfo.startTime : 0;
|
|
1101
|
+
const bTime = "startTime" in bInfo ? bInfo.startTime : 0;
|
|
1071
1102
|
return bTime - aTime;
|
|
1072
1103
|
});
|
|
1073
1104
|
return logs;
|
|
1074
|
-
}, [requests, responses, errors]);
|
|
1105
|
+
}, [requests, responses, errors, heldRequests, heldResponses, heldErrors]);
|
|
1075
1106
|
const filteredLogs = useMemo(() => {
|
|
1076
1107
|
if (!searchTerm) {
|
|
1077
1108
|
return allLogs;
|
|
1078
1109
|
}
|
|
1079
1110
|
const lowercasedTerm = searchTerm.toLowerCase();
|
|
1080
1111
|
return allLogs.filter((log) => {
|
|
1112
|
+
const logInfo = getLogInfo(log);
|
|
1081
1113
|
switch (searchSection) {
|
|
1082
1114
|
case "url":
|
|
1083
|
-
return
|
|
1115
|
+
return logInfo.url?.toLowerCase().includes(lowercasedTerm);
|
|
1084
1116
|
case "headers":
|
|
1085
|
-
return "headers" in
|
|
1117
|
+
return "headers" in logInfo && logInfo.headers && JSON.stringify(logInfo.headers)?.toLowerCase().includes(lowercasedTerm);
|
|
1086
1118
|
case "params":
|
|
1087
|
-
return "params" in
|
|
1119
|
+
return "params" in logInfo && logInfo.params && JSON.stringify(logInfo.params)?.toLowerCase().includes(lowercasedTerm);
|
|
1088
1120
|
case "data":
|
|
1089
|
-
return "data" in
|
|
1121
|
+
return "data" in logInfo && logInfo.data && log.type === "request" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
|
|
1090
1122
|
case "response":
|
|
1091
|
-
return "data" in
|
|
1123
|
+
return "data" in logInfo && logInfo.data && log.type === "response" && JSON.stringify(logInfo.data)?.toLowerCase().includes(lowercasedTerm);
|
|
1092
1124
|
case "error":
|
|
1093
|
-
return log.type === "error" && JSON.stringify(
|
|
1125
|
+
return log.type === "error" && JSON.stringify(logInfo)?.toLowerCase().includes(lowercasedTerm);
|
|
1094
1126
|
case "all":
|
|
1095
1127
|
default:
|
|
1096
|
-
return JSON.stringify(
|
|
1128
|
+
return JSON.stringify(logInfo).toLowerCase().includes(lowercasedTerm);
|
|
1097
1129
|
}
|
|
1098
1130
|
});
|
|
1099
1131
|
}, [allLogs, searchTerm, searchSection]);
|
|
1100
1132
|
const renderLogSummary = (log) => {
|
|
1133
|
+
const logInfo = getLogInfo(log);
|
|
1134
|
+
const prefix = log.holdStatus === "held" ? "[HELD] " : "";
|
|
1101
1135
|
if (log.type === "request") {
|
|
1102
|
-
return
|
|
1136
|
+
return `${prefix}[REQ] ${logInfo.method.toUpperCase()} ${logInfo.url}`;
|
|
1103
1137
|
}
|
|
1104
|
-
if (log.type === "response" && "status" in
|
|
1105
|
-
return
|
|
1138
|
+
if (log.type === "response" && "status" in logInfo) {
|
|
1139
|
+
return `${prefix}[RES] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.status}`;
|
|
1106
1140
|
}
|
|
1107
|
-
if (log.type === "error" && "message" in
|
|
1108
|
-
return
|
|
1141
|
+
if (log.type === "error" && "message" in logInfo) {
|
|
1142
|
+
return `${prefix}[ERR] ${logInfo.method.toUpperCase()} ${logInfo.url} - ${logInfo.message}`;
|
|
1109
1143
|
}
|
|
1110
1144
|
return "Unknown Log";
|
|
1111
1145
|
};
|
|
1112
1146
|
const renderLogContent = (log) => {
|
|
1113
|
-
|
|
1147
|
+
const logInfo = getLogInfo(log);
|
|
1148
|
+
return /* @__PURE__ */ jsx("pre", { children: JSON.stringify(logInfo, null, 2) });
|
|
1114
1149
|
};
|
|
1115
1150
|
return /* @__PURE__ */ jsxs(Modal.Root, { isOpen: true, onClose, modalSize: "full-screen", children: [
|
|
1116
1151
|
/* @__PURE__ */ jsx(Modal.Overlay, {}),
|
|
@@ -1128,8 +1163,13 @@ const NetworkLog = ({ onClose }) => {
|
|
|
1128
1163
|
onChange: (e) => setSearchTerm(e.target.value)
|
|
1129
1164
|
}
|
|
1130
1165
|
),
|
|
1166
|
+
/* @__PURE__ */ jsx(Checkbox, { id: "hold-checkbox", checked: isHold, onChange: toggleHold, size: "small", variant: "main", children: "Hold" }),
|
|
1131
1167
|
/* @__PURE__ */ jsx(Button, { variant: "neutral", appearance: "outline", size: "xsmall", onClick: clear, children: "clear" })
|
|
1132
1168
|
] }),
|
|
1169
|
+
isHold && /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "row" }, children: [
|
|
1170
|
+
/* @__PURE__ */ jsx(Button, { size: "xsmall", onClick: () => playAllRequests(), variant: "primary", appearance: "outline", children: "REQ Resolve" }),
|
|
1171
|
+
/* @__PURE__ */ jsx(Button, { size: "xsmall", onClick: () => playAllResponses(), variant: "primary", appearance: "outline", children: "RES Resolve" })
|
|
1172
|
+
] }),
|
|
1133
1173
|
/* @__PURE__ */ jsx("div", { className: styles$3["log-list"], children: filteredLogs.length === 0 ? /* @__PURE__ */ jsx("p", { children: "\uD45C\uC2DC\uD560 \uB85C\uADF8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4." }) : /* @__PURE__ */ jsx(Accordion.Root, { children: filteredLogs.map((log, index) => /* @__PURE__ */ jsxs(Accordion.Item, { children: [
|
|
1134
1174
|
/* @__PURE__ */ jsx(Accordion.HeaderButton, { children: /* @__PURE__ */ jsx("p", { className: styles$3["log-summary"], children: renderLogSummary(log) }) }),
|
|
1135
1175
|
/* @__PURE__ */ jsx(Accordion.Content, { variant: "text", children: /* @__PURE__ */ jsx("div", { className: styles$3["log-content"], children: renderLogContent(log) }) })
|
|
@@ -1446,21 +1486,11 @@ const menuItems = [
|
|
|
1446
1486
|
|
|
1447
1487
|
const useEnvironment = () => {
|
|
1448
1488
|
const [envInfo, setEnvInfo] = useState({
|
|
1449
|
-
env: "
|
|
1489
|
+
env: "prd"
|
|
1450
1490
|
});
|
|
1451
1491
|
useEffect(() => {
|
|
1452
1492
|
const { hostname } = window.location;
|
|
1453
|
-
|
|
1454
|
-
if (hostname.includes("localhost") || hostname.includes("127.0.0.1")) {
|
|
1455
|
-
currentEnv = "local";
|
|
1456
|
-
} else if (hostname.includes("dev.")) {
|
|
1457
|
-
currentEnv = "dev";
|
|
1458
|
-
} else if (hostname.includes("stg.")) {
|
|
1459
|
-
currentEnv = "stage";
|
|
1460
|
-
} else {
|
|
1461
|
-
currentEnv = "prod";
|
|
1462
|
-
}
|
|
1463
|
-
setEnvInfo({ env: currentEnv });
|
|
1493
|
+
setEnvInfo({ env: getEnvironmentFromHostname(hostname) });
|
|
1464
1494
|
}, []);
|
|
1465
1495
|
return envInfo;
|
|
1466
1496
|
};
|
|
@@ -1477,7 +1507,7 @@ const DebugTool = ({ onLogin, envOverride, menuItemsOverride }) => {
|
|
|
1477
1507
|
const menuItems$1 = menuItemsOverride || menuItems;
|
|
1478
1508
|
const [isMenuOpen, setMenuOpen] = useState(false);
|
|
1479
1509
|
const [activeFeature, setActiveFeature] = useState(null);
|
|
1480
|
-
const isVisible = ["local", "dev", "
|
|
1510
|
+
const isVisible = ["local", "dev", "stg"].includes(env);
|
|
1481
1511
|
const handleMenuClick = (itemComponent) => {
|
|
1482
1512
|
setActiveFeature(() => itemComponent);
|
|
1483
1513
|
setMenuOpen(false);
|