@thefreshop/tb 1.0.7 → 1.0.9

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/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
- import React__default, { createContext, useState, useContext, useEffect, useCallback, useRef, forwardRef, useImperativeHandle, memo, useMemo } from 'react';
2
+ import React__default, { createContext, useState, useEffect, useContext, useCallback, useMemo, useRef, forwardRef, useImperativeHandle, memo } from 'react';
3
+ import { useNavigate, useLocation, Outlet, createBrowserRouter, RouterProvider } from 'react-router';
3
4
  import Editor from '@monaco-editor/react';
4
5
  import { DownOutlined, UpOutlined, DoubleRightOutlined, DoubleLeftOutlined, LoadingOutlined, ReloadOutlined, SearchOutlined, UploadOutlined, ExclamationCircleOutlined, RedoOutlined, TagOutlined } from '@ant-design/icons';
5
- import { Typography, Row, Col, Space, Button, Input, Tag, Image as Image$1, Tooltip, Upload, Form, Select, DatePicker, Switch, InputNumber, Flex, Modal, Table, Checkbox, Tree, ConfigProvider, Result, Spin } from 'antd';
6
+ import { Typography, Row, Col, Space, Button, Input, Tag, Image as Image$1, Tooltip, Upload, Form, Select, DatePicker, Switch, InputNumber, Flex, Modal, Table, List, Card, Checkbox, Tree, ConfigProvider, Result, Spin } from 'antd';
6
7
  import moment$1 from 'moment-timezone';
7
8
  import require$$1 from 'react-dom';
8
9
  import dayjs from 'dayjs';
@@ -18,16 +19,35 @@ import 'dayjs/locale/ko';
18
19
 
19
20
  const tbContext = createContext(undefined);
20
21
 
21
- // export const TbBase = createContext<TbBaseProviderType>({})
22
+ const SESSION_STORAGE_KEY = "tbFrameState";
22
23
  const TbProvider = ({ children }) => {
23
24
  const [topkey, setTopkey] = useState("");
24
25
  const [currentTab, setCurrentTab] = useState();
25
26
  const [user, setloginUser] = useState();
26
- const [tabs, setTabs] = useState([]);
27
+ // const [tabs, setTabs] = useState<tabType[]>([]);
27
28
  const [startpage, setStartpage] = useState();
28
29
  const [errMsg, setErrMsg] = useState();
29
30
  const [globalpages, setGlobalpages] = useState();
30
31
  const [menupages, setMenupages] = useState();
32
+ // 1. 초기 상태를 sessionStorage 불러오도록 수정
33
+ const [tabs, setTabs] = useState(() => {
34
+ try {
35
+ const savedState = sessionStorage.getItem(SESSION_STORAGE_KEY);
36
+ return savedState ? JSON.parse(savedState).tabs : [];
37
+ }
38
+ catch (error) {
39
+ console.error("Failed to parse state from sessionStorage", error);
40
+ return [];
41
+ }
42
+ });
43
+ // 2. 상태가 변경될 때마다 sessionStorage 저장하는 useEffect 추가
44
+ useEffect(() => {
45
+ const stateToSave = {
46
+ tabs,
47
+ // ... 저장할 다른 상태들 ...
48
+ };
49
+ sessionStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(stateToSave));
50
+ }, [tabs, currentTab /* ... 다른 상태 의존성 ... */]);
31
51
  const addTabs = (tab) => {
32
52
  setCurrentTab(tab);
33
53
  if (tabs.find((m) => m.key === tab.key) === undefined) {
@@ -128,6 +148,7 @@ const TbProvider = ({ children }) => {
128
148
  SetWarning,
129
149
  errMsg,
130
150
  setGlobalpages,
151
+ globalpages,
131
152
  addGlobalTabs,
132
153
  setMenupages,
133
154
  goTabs,
@@ -253,6 +274,7 @@ const Menu = ({ menu_setting: { title, icon, key, children, hasPage, page, defal
253
274
  const [hover, setHover] = useState(false);
254
275
  const [subOpen, setSubOpen] = useState(false);
255
276
  const { addTabs, currentTab, user } = useTbState();
277
+ const navigate = useNavigate();
256
278
  useEffect(() => {
257
279
  if (defalultOpen) {
258
280
  setSubOpen(true);
@@ -284,12 +306,14 @@ const Menu = ({ menu_setting: { title, icon, key, children, hasPage, page, defal
284
306
  setHover(false);
285
307
  }, onClick: () => {
286
308
  setSubOpen((prev) => !prev);
287
- if (hasPage && currentTab?.key !== key)
309
+ if (hasPage && currentTab?.key !== key) {
288
310
  addTabs({
289
311
  title,
290
312
  key,
291
313
  page,
292
314
  });
315
+ navigate("/" + key);
316
+ }
293
317
  // console.log(tabs)
294
318
  } },
295
319
  React__default.createElement("div", { className: styles$9.nav_icon }, icon),
@@ -300,6 +324,7 @@ const Menu = ({ menu_setting: { title, icon, key, children, hasPage, page, defal
300
324
  const SubMenu = ({ menu_setting: { title, icon, key, page, hasPage } }) => {
301
325
  const [hover, setHover] = useState(false);
302
326
  const { addTabs, currentTab } = useTbState();
327
+ const navigate = useNavigate();
303
328
  return (React__default.createElement("div", { className: `${styles$9.sub_item} ${currentTab?.key === key ? styles$9.menu_select : hover ? styles$9.menu_hover : styles$9.menu_nomal}`, onMouseEnter: () => {
304
329
  setHover(true);
305
330
  }, onMouseLeave: () => {
@@ -311,6 +336,7 @@ const SubMenu = ({ menu_setting: { title, icon, key, page, hasPage } }) => {
311
336
  key,
312
337
  page,
313
338
  });
339
+ navigate("/" + key);
314
340
  // console.log(tabs)
315
341
  } },
316
342
  React__default.createElement("div", { className: styles$9.nav_icon }, icon),
@@ -339,12 +365,45 @@ var css_248z$9 = ".tabs-module_tabFrame__qyHsD{background-color:#fff;display:fle
339
365
  var styles$6 = {"tabFrame":"tabs-module_tabFrame__qyHsD","tab_item":"tabs-module_tab_item__dtp6M","tab_item_text":"tabs-module_tab_item_text__w9h73","tab_item_button":"tabs-module_tab_item_button__2CdJE","tab_x_button":"tabs-module_tab_x_button__To6OB","tab_normal":"tabs-module_tab_normal__Ky5vz","tab_select":"tabs-module_tab_select__kEPQi"};
340
366
  styleInject(css_248z$9);
341
367
 
342
- const Tabs = () => {
343
- const { tabs, removeTabs, setCurrentTab, currentTab } = useTbState();
344
- return (React__default.createElement("div", { className: styles$6.tabFrame }, tabs?.map((m, index) => {
345
- return (React__default.createElement("div", { key: index, className: `${styles$6.tab_item} ${currentTab?.key === m.key ? styles$6.tab_select : styles$6.tab_normal}` },
368
+ const Tabs = ({ nav: { menuSet, openIcon, closeIcon } }) => {
369
+ const { tabs, removeTabs, setCurrentTab, addTabs, currentTab, globalpages } = useTbState();
370
+ const navigate = useNavigate();
371
+ const location = useLocation();
372
+ const findTabs = useCallback((pathKey) => {
373
+ // 1. 현재 열린 탭 중에 있는지 확인
374
+ const existingTab = tabs.find((t) => t.key === pathKey);
375
+ if (existingTab) {
376
+ setCurrentTab(existingTab);
377
+ return;
378
+ }
379
+ // 2. 없다면, 전체 페이지 목록에서 찾아서 추가
380
+ let tabInfo;
381
+ // 2-1. 메뉴 페이지에서 찾기
382
+ menuSet.forEach((item) => {
383
+ item.menuSetting.forEach((sub) => {
384
+ if (sub.key === pathKey)
385
+ tabInfo = sub;
386
+ });
387
+ });
388
+ // 2-2. 전역 페이지에서 찾기 (메뉴에 없으면)
389
+ if (!tabInfo) {
390
+ tabInfo = globalpages?.find((m) => m.key === pathKey);
391
+ }
392
+ if (tabInfo) {
393
+ addTabs(tabInfo);
394
+ }
395
+ }, [tabs, globalpages]);
396
+ // 3. 페이지 로드 시 URL을 기반으로 currentTab을 설정하는 useEffect 추가
397
+ useEffect(() => {
398
+ const pathKey = location.pathname.substring(1); // 맨 앞의 '/' 제거
399
+ findTabs(pathKey);
400
+ // eslint-disable-next-line react-hooks/exhaustive-deps
401
+ }, []); // 이 효과는 컴포넌트가 처음 마운트될 때 한 번만 실행됩니다.
402
+ return (React__default.createElement("div", { className: styles$6.tabFrame }, tabs?.map((m) => {
403
+ return (React__default.createElement("div", { key: m.key, className: `${styles$6.tab_item} ${currentTab?.key === m.key ? styles$6.tab_select : styles$6.tab_normal}` },
346
404
  React__default.createElement("div", { className: styles$6.tab_item_text, onClick: () => {
347
405
  setCurrentTab(m);
406
+ navigate("/" + m.key);
348
407
  // console.log('setCurrentTab', m)
349
408
  } }, m.title),
350
409
  !m.noremove && (React__default.createElement("div", { className: styles$6.tab_item_button },
@@ -356,30 +415,21 @@ var css_248z$8 = ".main-module_mainFrame__Etjvl{height:100%;width:100%}\n/*# sou
356
415
  var styles$5 = {"mainFrame":"main-module_mainFrame__Etjvl"};
357
416
  styleInject(css_248z$8);
358
417
 
359
- var css_248z$7 = ".nullpage-module_nullpage__aLHyg{align-items:center;display:flex;flex-direction:row;height:30vh;justify-content:center;width:100%}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm51bGxwYWdlLm1vZHVsZS5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaUNBSUUsa0JBQW1CLENBSG5CLFlBQWEsQ0FDYixrQkFBbUIsQ0FJbkIsV0FBWSxDQUhaLHNCQUF1QixDQUV2QixVQUVGIiwiZmlsZSI6Im51bGxwYWdlLm1vZHVsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIubnVsbHBhZ2Uge1xyXG4gIGRpc3BsYXk6IGZsZXg7XHJcbiAgZmxleC1kaXJlY3Rpb246IHJvdztcclxuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcclxuICBhbGlnbi1pdGVtczogY2VudGVyO1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIGhlaWdodDogMzB2aDtcclxufVxyXG4iXX0= */";
360
- var styles$4 = {"nullpage":"nullpage-module_nullpage__aLHyg"};
361
- styleInject(css_248z$7);
362
-
363
- const NullPage = () => {
364
- return (React__default.createElement("div", { className: styles$4.nullpage },
365
- React__default.createElement("div", null, "\uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.")));
366
- };
367
-
368
418
  const Main = () => {
369
- const { currentTab } = useTbState();
370
- return (React__default.createElement("div", { className: styles$5.mainFrame }, currentTab?.page ? currentTab.page : React__default.createElement(NullPage, null)));
419
+ return (React__default.createElement("div", { className: styles$5.mainFrame },
420
+ React__default.createElement(Outlet, null)));
371
421
  };
372
422
 
373
- var css_248z$6 = ".loginpage-module_loginpage__TF9Rl{align-items:center;display:flex;flex-direction:column;height:100vh;justify-content:center;width:100%}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxvZ2lucGFnZS5tb2R1bGUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1DQUlFLGtCQUFtQixDQUhuQixZQUFhLENBQ2IscUJBQXNCLENBSXRCLFlBQWEsQ0FIYixzQkFBdUIsQ0FFdkIsVUFFRiIsImZpbGUiOiJsb2dpbnBhZ2UubW9kdWxlLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5sb2dpbnBhZ2Uge1xyXG4gIGRpc3BsYXk6IGZsZXg7XHJcbiAgZmxleC1kaXJlY3Rpb246IGNvbHVtbjtcclxuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcclxuICBhbGlnbi1pdGVtczogY2VudGVyO1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIGhlaWdodDogMTAwdmg7XHJcbn1cclxuIl19 */";
374
- var styles$3 = {"loginpage":"loginpage-module_loginpage__TF9Rl"};
375
- styleInject(css_248z$6);
423
+ var css_248z$7 = ".loginpage-module_loginpage__TF9Rl{align-items:center;display:flex;flex-direction:column;height:100vh;justify-content:center;width:100%}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxvZ2lucGFnZS5tb2R1bGUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG1DQUlFLGtCQUFtQixDQUhuQixZQUFhLENBQ2IscUJBQXNCLENBSXRCLFlBQWEsQ0FIYixzQkFBdUIsQ0FFdkIsVUFFRiIsImZpbGUiOiJsb2dpbnBhZ2UubW9kdWxlLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5sb2dpbnBhZ2Uge1xyXG4gIGRpc3BsYXk6IGZsZXg7XHJcbiAgZmxleC1kaXJlY3Rpb246IGNvbHVtbjtcclxuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcclxuICBhbGlnbi1pdGVtczogY2VudGVyO1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIGhlaWdodDogMTAwdmg7XHJcbn1cclxuIl19 */";
424
+ var styles$4 = {"loginpage":"loginpage-module_loginpage__TF9Rl"};
425
+ styleInject(css_248z$7);
376
426
 
377
427
  const LoginPage = () => {
378
428
  const { loginUser } = useTbState();
379
429
  const [user, setUser] = useState(defaultuser);
380
430
  const [isTypeCheck, setTypeCheck] = useState(true);
381
431
  const [editorValue, setEditorValue] = useState(JSON.stringify(defaultuser, null, 2));
382
- return (React__default.createElement("div", { className: styles$3.loginpage },
432
+ return (React__default.createElement("div", { className: styles$4.loginpage },
383
433
  React__default.createElement("div", { style: { display: "flex" } },
384
434
  React__default.createElement("button", { onClick: () => {
385
435
  setEditorValue(JSON.stringify(alluser, null, 2));
@@ -451,6 +501,15 @@ const testuser = {
451
501
  },
452
502
  };
453
503
 
504
+ var css_248z$6 = ".nullpage-module_nullpage__aLHyg{align-items:center;display:flex;flex-direction:row;height:30vh;justify-content:center;width:100%}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm51bGxwYWdlLm1vZHVsZS5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaUNBSUUsa0JBQW1CLENBSG5CLFlBQWEsQ0FDYixrQkFBbUIsQ0FJbkIsV0FBWSxDQUhaLHNCQUF1QixDQUV2QixVQUVGIiwiZmlsZSI6Im51bGxwYWdlLm1vZHVsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIubnVsbHBhZ2Uge1xyXG4gIGRpc3BsYXk6IGZsZXg7XHJcbiAgZmxleC1kaXJlY3Rpb246IHJvdztcclxuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcclxuICBhbGlnbi1pdGVtczogY2VudGVyO1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIGhlaWdodDogMzB2aDtcclxufVxyXG4iXX0= */";
505
+ var styles$3 = {"nullpage":"nullpage-module_nullpage__aLHyg"};
506
+ styleInject(css_248z$6);
507
+
508
+ const NullPage = () => {
509
+ return (React__default.createElement("div", { className: styles$3.nullpage },
510
+ React__default.createElement("div", null, "\uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.")));
511
+ };
512
+
454
513
  const TbFrame = ({ setting, top, bottom, nav, top_banner, }) => {
455
514
  const { user, startpage, setStartpage, errMsg, setGlobalpages, setMenupages } = useTbState();
456
515
  useEffect(() => {
@@ -471,6 +530,29 @@ const TbFrame = ({ setting, top, bottom, nav, top_banner, }) => {
471
530
  useEffect(() => {
472
531
  if (!errMsg?.isPopup) ;
473
532
  }, [errMsg]);
533
+ const route = () => {
534
+ let route = [];
535
+ nav.menuSet.forEach((m) => {
536
+ m.menuSetting.forEach((m) => {
537
+ route.push({
538
+ path: "/" + m.key,
539
+ element: m.page,
540
+ });
541
+ });
542
+ });
543
+ return route;
544
+ };
545
+ const router = useMemo(() => createBrowserRouter([
546
+ {
547
+ path: "/",
548
+ element: (React__default.createElement(MainLayout, { errMsg: errMsg, startpage: startpage, setting: setting, top_banner: top_banner, nav: nav, user: user, top: top, bottom: bottom })),
549
+ children: route(),
550
+ errorElement: React__default.createElement(NullPage, null),
551
+ },
552
+ ]), []);
553
+ return React__default.createElement(RouterProvider, { router: router });
554
+ };
555
+ const MainLayout = ({ errMsg, startpage, setting, top_banner, nav, user, top, bottom, }) => {
474
556
  const LOGIN = useCallback(() => {
475
557
  if (startpage)
476
558
  return setting?.loginpage ? setting.loginpage : React__default.createElement(LoginPage, null);
@@ -517,7 +599,7 @@ const TbFrame = ({ setting, top, bottom, nav, top_banner, }) => {
517
599
  React__default.createElement("div", { className: styles$9.centerFrame, style: top_banner ? { height: "calc(100vh - 120px)" } : { height: "calc(100vh - 80px)" } },
518
600
  React__default.createElement(Nav, { nav: nav, islogin: setting.islogin ?? false }),
519
601
  React__default.createElement("div", { className: styles$9.contentsFrame },
520
- React__default.createElement(Tabs, null),
602
+ React__default.createElement(Tabs, { nav: nav }),
521
603
  React__default.createElement(Main, null))),
522
604
  React__default.createElement("div", { className: styles$9.bottomFrame }, bottom && React__default.createElement(Bottom, { bottom: bottom }))))));
523
605
  };
@@ -22382,10 +22464,11 @@ var Cropper = /** @class */function (_super) {
22382
22464
  }
22383
22465
  };
22384
22466
  _this.recomputeCropPosition = function () {
22467
+ var _a, _b;
22385
22468
  if (!_this.state.cropSize) return;
22386
22469
  var adjustedCrop = _this.props.crop;
22387
22470
  // Only scale if we're initialized and this is a legitimate resize
22388
- if (_this.isInitialized && _this.previousCropSize) {
22471
+ if (_this.isInitialized && ((_a = _this.previousCropSize) === null || _a === void 0 ? void 0 : _a.width) && ((_b = _this.previousCropSize) === null || _b === void 0 ? void 0 : _b.height)) {
22389
22472
  var sizeChanged = Math.abs(_this.previousCropSize.width - _this.state.cropSize.width) > 1e-6 || Math.abs(_this.previousCropSize.height - _this.state.cropSize.height) > 1e-6;
22390
22473
  if (sizeChanged) {
22391
22474
  var scaleX = _this.state.cropSize.width / _this.previousCropSize.width;
@@ -23218,8 +23301,8 @@ const AntBaseModalCreate = ({ modalProps, formProps, props }) => {
23218
23301
  React__default.createElement(Button, { htmlType: "submit" }, props.buttonName ?? (isModify ? FORM_MODIFY : FORM_CREATE))))));
23219
23302
  };
23220
23303
 
23221
- const { Title } = Typography;
23222
- const { confirm } = Modal;
23304
+ const { Title: Title$1 } = Typography;
23305
+ const { confirm: confirm$1 } = Modal;
23223
23306
  const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, initData, customColumn, customValue, columns, expandable, size, onDoubleClick, onClick, selectProps, addProps, modifyProps, deleteProps, removeProps, resetProps, customProps, topProps, bottomProps, upProps, downProps, pageProps, scroll, onRefresh, isCounter, autoRefreshTime, createModalWidth = 1000, onCreateClose, }, ref) => {
23224
23307
  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
23225
23308
  const [selectedRow, setSelectedRow] = useState();
@@ -23348,7 +23431,7 @@ const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, init
23348
23431
  : typeof rowKey === "function"
23349
23432
  ? rowKey(selectedRow)
23350
23433
  : selectedRow[rowKey]);
23351
- confirm({
23434
+ confirm$1({
23352
23435
  title: "삭제 하시겠습니까?",
23353
23436
  icon: React__default.createElement(ExclamationCircleOutlined, null),
23354
23437
  content: content,
@@ -23375,7 +23458,7 @@ const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, init
23375
23458
  : typeof rowKey === "function"
23376
23459
  ? rowKey(selectedRow)
23377
23460
  : selectedRow[rowKey]);
23378
- confirm({
23461
+ confirm$1({
23379
23462
  title: "복구 하시겠습니까?",
23380
23463
  icon: React__default.createElement(ExclamationCircleOutlined, null),
23381
23464
  content: content,
@@ -23402,7 +23485,7 @@ const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, init
23402
23485
  : typeof rowKey === "function"
23403
23486
  ? rowKey(selectedRow)
23404
23487
  : selectedRow[rowKey]);
23405
- confirm({
23488
+ confirm$1({
23406
23489
  title: "완전 삭제 하시겠습니까?",
23407
23490
  icon: React__default.createElement(ExclamationCircleOutlined, null),
23408
23491
  content: content,
@@ -23537,7 +23620,7 @@ const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, init
23537
23620
  React__default.createElement(AntBaseModalCreate, { modalProps: {
23538
23621
  width: createModalWidth,
23539
23622
  title: (React__default.createElement("div", { style: { marginBottom: 20, marginTop: 10 } },
23540
- React__default.createElement(Title, { level: 4, style: { margin: 0 } }, popupModify ? "정보 수정" : "신규 등록"))),
23623
+ React__default.createElement(Title$1, { level: 4, style: { margin: 0 } }, popupModify ? "정보 수정" : "신규 등록"))),
23541
23624
  maskClosable: false,
23542
23625
  open: popupCreate,
23543
23626
  onCancel: () => {
@@ -23582,6 +23665,288 @@ const AntBaseTable$1 = ({ bordered, className, rowKey, rowName, dataSource, init
23582
23665
  */
23583
23666
  var AntBaseTable = forwardRef(AntBaseTable$1);
23584
23667
 
23668
+ const { Title } = Typography;
23669
+ const { confirm } = Modal;
23670
+ const AntBaseList$1 = ({ tableProps, render, }, ref) => {
23671
+ const { bordered, className, rowKey, rowName, dataSource, initData, customColumn, customValue, columns, expandable, size, onDoubleClick, onClick, selectProps, addProps, modifyProps, deleteProps, removeProps, resetProps, customProps, topProps, bottomProps, upProps, downProps, pageProps, scroll, onRefresh, isCounter, autoRefreshTime, createModalWidth = 1000, onCreateClose, } = tableProps;
23672
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
23673
+ const [selectedRow, setSelectedRow] = useState();
23674
+ const [popupCreate, setPopupCreate] = useState(false);
23675
+ const [popupModify, setPopupModify] = useState(false);
23676
+ useEffect(() => {
23677
+ setSelectedRow(dataSource?.find((m) => {
23678
+ if (m) {
23679
+ let key = typeof rowKey === "function" ? rowKey(m) : m[rowKey];
23680
+ return key === selectedRowKeys[0];
23681
+ }
23682
+ return false;
23683
+ }));
23684
+ }, [dataSource, rowKey, selectedRowKeys]);
23685
+ //선택 리셋
23686
+ const resetSelection = () => {
23687
+ setSelectedRowKeys([]);
23688
+ setSelectedRow(undefined);
23689
+ };
23690
+ //재 선택??
23691
+ const reSelection = () => {
23692
+ if (selectProps) {
23693
+ if (selectedRowKeys.length !== 0 && dataSource?.length !== 0) {
23694
+ setSelectedRow(dataSource?.find((m) => {
23695
+ if (m) {
23696
+ let key = typeof rowKey === "function" ? rowKey(m) : m[rowKey];
23697
+ return key === selectedRowKeys[0];
23698
+ }
23699
+ return false;
23700
+ }));
23701
+ if (selectProps.onUpdateData) {
23702
+ selectProps.onUpdateData(dataSource?.find((m) => {
23703
+ if (m) {
23704
+ let key = typeof rowKey === "function" ? rowKey(m) : m[rowKey];
23705
+ return key === selectedRowKeys[0];
23706
+ }
23707
+ return false;
23708
+ }));
23709
+ }
23710
+ }
23711
+ }
23712
+ };
23713
+ //ref 함수
23714
+ useImperativeHandle(ref, () => ({
23715
+ resetSelection,
23716
+ reSelection,
23717
+ popupCreate,
23718
+ popupModify,
23719
+ selectedRow,
23720
+ }), [selectedRow, popupCreate, popupModify]);
23721
+ // 추가 팝업 on/off
23722
+ const showCreatePopup = (show) => {
23723
+ setPopupCreate(show);
23724
+ setPopupModify(false);
23725
+ };
23726
+ // 추가/수정 완료
23727
+ const onCreate = (value) => {
23728
+ setPopupCreate(false);
23729
+ setPopupModify(false);
23730
+ if (popupModify && modifyProps) {
23731
+ let key = typeof rowKey === "function" ? rowKey(selectedRow) : rowKey;
23732
+ modifyProps.onFun({ [key.toString()]: key, ...value }, selectedRow);
23733
+ // 키 값과 함꼐 전달
23734
+ }
23735
+ else if (addProps) {
23736
+ addProps.onFun(value);
23737
+ }
23738
+ setSelectedRowKeys([]);
23739
+ setSelectedRow(undefined);
23740
+ };
23741
+ // 수정 창 열기전 beforeModify 확인후 수정 작업
23742
+ const showModify = () => {
23743
+ if (modifyProps?.beforeCheck) {
23744
+ modifyProps
23745
+ .beforeCheck(selectedRow)
23746
+ .then((newValue) => {
23747
+ setSelectedRow(newValue);
23748
+ setPopupCreate(true);
23749
+ setPopupModify(true);
23750
+ })
23751
+ .catch();
23752
+ }
23753
+ else {
23754
+ setPopupCreate(true);
23755
+ setPopupModify(true);
23756
+ }
23757
+ };
23758
+ //선택 유무
23759
+ const isSelect = selectedRowKeys.length !== 0;
23760
+ return (React__default.createElement("div", { className: className, style: {
23761
+ display: "flex",
23762
+ flexDirection: "column",
23763
+ flex: 1,
23764
+ gap: 10,
23765
+ height: "100%",
23766
+ padding: "20px",
23767
+ } },
23768
+ React__default.createElement(TableTopButtonGroup, { isSelect: isSelect, isCounter: isCounter, onRefresh: onRefresh, autoRefreshTime: autoRefreshTime, addProps: addProps && {
23769
+ ...addProps,
23770
+ onFun: () => {
23771
+ if (addProps.customModal) {
23772
+ addProps.onFun(selectedRow);
23773
+ }
23774
+ else {
23775
+ showCreatePopup(true);
23776
+ }
23777
+ },
23778
+ }, modifyProps: modifyProps && {
23779
+ ...modifyProps,
23780
+ onFun() {
23781
+ if (modifyProps.customModal) {
23782
+ modifyProps.onFun(selectedRow);
23783
+ }
23784
+ else {
23785
+ showModify();
23786
+ }
23787
+ },
23788
+ }, deleteProps: deleteProps && {
23789
+ ...deleteProps,
23790
+ onFun() {
23791
+ if (selectedRow) {
23792
+ let content = (rowName
23793
+ ? typeof rowName === "function"
23794
+ ? rowName(selectedRow)
23795
+ : selectedRow[rowName]
23796
+ : typeof rowKey === "function"
23797
+ ? rowKey(selectedRow)
23798
+ : selectedRow[rowKey]);
23799
+ confirm({
23800
+ title: "삭제 하시겠습니까?",
23801
+ icon: React__default.createElement(ExclamationCircleOutlined, null),
23802
+ content: content,
23803
+ okText: "Yes",
23804
+ okType: "danger",
23805
+ cancelText: "No",
23806
+ onOk: () => {
23807
+ deleteProps.onFun(selectedRow);
23808
+ },
23809
+ onCancel() {
23810
+ console.log("Cancel");
23811
+ },
23812
+ });
23813
+ }
23814
+ },
23815
+ }, resetProps: resetProps && {
23816
+ ...resetProps,
23817
+ onFun() {
23818
+ if (selectedRow) {
23819
+ let content = (rowName
23820
+ ? typeof rowName === "function"
23821
+ ? rowName(selectedRow)
23822
+ : selectedRow[rowName]
23823
+ : typeof rowKey === "function"
23824
+ ? rowKey(selectedRow)
23825
+ : selectedRow[rowKey]);
23826
+ confirm({
23827
+ title: "복구 하시겠습니까?",
23828
+ icon: React__default.createElement(ExclamationCircleOutlined, null),
23829
+ content: content,
23830
+ okText: "Yes",
23831
+ okType: "primary",
23832
+ cancelText: "No",
23833
+ onOk: () => {
23834
+ resetProps.onFun(selectedRow);
23835
+ },
23836
+ onCancel() {
23837
+ console.log("Cancel");
23838
+ },
23839
+ });
23840
+ }
23841
+ },
23842
+ }, removeProps: removeProps && {
23843
+ ...removeProps,
23844
+ onFun() {
23845
+ if (selectedRow) {
23846
+ let content = (rowName
23847
+ ? typeof rowName === "function"
23848
+ ? rowName(selectedRow)
23849
+ : selectedRow[rowName]
23850
+ : typeof rowKey === "function"
23851
+ ? rowKey(selectedRow)
23852
+ : selectedRow[rowKey]);
23853
+ confirm({
23854
+ title: "완전 삭제 하시겠습니까?",
23855
+ icon: React__default.createElement(ExclamationCircleOutlined, null),
23856
+ content: content,
23857
+ okText: "Yes",
23858
+ okType: "danger",
23859
+ cancelText: "No",
23860
+ onOk: () => {
23861
+ removeProps.onFun(selectedRow);
23862
+ },
23863
+ onCancel() {
23864
+ console.log("Cancel");
23865
+ },
23866
+ });
23867
+ }
23868
+ },
23869
+ }, customProps: customProps && {
23870
+ ...customProps,
23871
+ render: () => {
23872
+ if (customProps.render)
23873
+ return customProps.render(isSelect, selectedRow);
23874
+ else
23875
+ return null;
23876
+ },
23877
+ leftRender: () => {
23878
+ if (customProps.leftRender)
23879
+ return customProps.leftRender(isSelect, selectedRow);
23880
+ else
23881
+ return null;
23882
+ },
23883
+ rightRender: () => {
23884
+ if (customProps.rightRender)
23885
+ return customProps.rightRender(isSelect, selectedRow);
23886
+ else
23887
+ return null;
23888
+ },
23889
+ } }),
23890
+ React__default.createElement(List, { dataSource: dataSource?.map((i) => i), grid: { gutter: 1, column: 1 }, renderItem: (item, index) => (React__default.createElement(List.Item, null,
23891
+ React__default.createElement(Card, null, render ? render(item, index) : React__default.createElement("div", null, JSON.stringify(item))))) }),
23892
+ React__default.createElement(TableBottomButtonGroup, { isSelect: isSelect, topProps: topProps && {
23893
+ ...topProps,
23894
+ onFun() {
23895
+ if (selectedRow)
23896
+ topProps.onFun(selectedRow);
23897
+ },
23898
+ }, bottomProps: bottomProps && {
23899
+ ...bottomProps,
23900
+ onFun() {
23901
+ if (selectedRow)
23902
+ bottomProps.onFun(selectedRow);
23903
+ },
23904
+ }, upProps: upProps && {
23905
+ ...upProps,
23906
+ onFun() {
23907
+ if (selectedRow)
23908
+ upProps.onFun(selectedRow);
23909
+ },
23910
+ }, downProps: downProps && {
23911
+ ...downProps,
23912
+ onFun() {
23913
+ if (selectedRow)
23914
+ downProps.onFun(selectedRow);
23915
+ },
23916
+ } }),
23917
+ React__default.createElement(AntBaseModalCreate, { modalProps: {
23918
+ width: createModalWidth,
23919
+ title: (React__default.createElement("div", { style: { marginBottom: 20, marginTop: 10 } },
23920
+ React__default.createElement(Title, { level: 4, style: { margin: 0 } }, popupModify ? "정보 수정" : "신규 등록"))),
23921
+ maskClosable: false,
23922
+ open: popupCreate,
23923
+ onCancel: () => {
23924
+ if (onCreateClose)
23925
+ onCreateClose();
23926
+ showCreatePopup(false);
23927
+ },
23928
+ }, formProps: {
23929
+ initialValues: popupModify
23930
+ ? convert2FormData({
23931
+ data: selectedRow,
23932
+ columns: columns,
23933
+ })
23934
+ : initData
23935
+ ? convert2FormData({
23936
+ data: initData,
23937
+ columns: columns,
23938
+ })
23939
+ : {},
23940
+ onFinish: onCreate,
23941
+ }, props: {
23942
+ customColumn,
23943
+ customValue,
23944
+ columns: popupModify ? (modifyProps?.columns ? modifyProps?.columns : columns) : addProps?.columns ? addProps?.columns : columns,
23945
+ isModify: popupModify,
23946
+ } })));
23947
+ };
23948
+ var AntBaseList = forwardRef(AntBaseList$1);
23949
+
23585
23950
  var css_248z$2 = ".searchbox-module_searchboxFrame__VAWWj{background:#f0f8ff;display:flex;flex-direction:row;padding-bottom:25px;padding-top:15px;width:100%}.searchbox-module_searchboxRow__wzY7N{display:flex;flex-direction:column;justify-content:center;line-height:32px;padding-left:20px;width:100%}.searchbox-module_searchboxBtn__d8Bc6{align-items:flex-end;justify-content:center;width:300px}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNlYXJjaGJveC5tb2R1bGUuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHdDQU1FLGtCQUFxQixDQUxyQixZQUFhLENBQ2Isa0JBQW1CLENBR25CLG1CQUFvQixDQURwQixnQkFBaUIsQ0FEakIsVUFJRixDQUVBLHNDQUNFLFlBQWEsQ0FDYixxQkFBc0IsQ0FHdEIsc0JBQXVCLENBRHZCLGdCQUFpQixDQUVqQixpQkFBa0IsQ0FIbEIsVUFLRixDQUNBLHNDQUVFLG9CQUFxQixDQUNyQixzQkFBdUIsQ0FGdkIsV0FHRiIsImZpbGUiOiJzZWFyY2hib3gubW9kdWxlLmNzcyIsInNvdXJjZXNDb250ZW50IjpbIi5zZWFyY2hib3hGcmFtZSB7XHJcbiAgZGlzcGxheTogZmxleDtcclxuICBmbGV4LWRpcmVjdGlvbjogcm93O1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIHBhZGRpbmctdG9wOiAxNXB4O1xyXG4gIHBhZGRpbmctYm90dG9tOiAyNXB4O1xyXG4gIGJhY2tncm91bmQ6IGFsaWNlYmx1ZTtcclxufVxyXG5cclxuLnNlYXJjaGJveFJvdyB7XHJcbiAgZGlzcGxheTogZmxleDtcclxuICBmbGV4LWRpcmVjdGlvbjogY29sdW1uO1xyXG4gIHdpZHRoOiAxMDAlO1xyXG4gIGxpbmUtaGVpZ2h0OiAzMnB4O1xyXG4gIGp1c3RpZnktY29udGVudDogY2VudGVyO1xyXG4gIHBhZGRpbmctbGVmdDogMjBweDtcclxuXHJcbn1cclxuLnNlYXJjaGJveEJ0biB7XHJcbiAgd2lkdGg6IDMwMHB4O1xyXG4gIGFsaWduLWl0ZW1zOiBmbGV4LWVuZDtcclxuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcclxufVxyXG4iXX0= */";
23586
23951
  var styles$2 = {"searchboxFrame":"searchbox-module_searchboxFrame__VAWWj","searchboxRow":"searchbox-module_searchboxRow__wzY7N","searchboxBtn":"searchbox-module_searchboxBtn__d8Bc6"};
23587
23952
  styleInject(css_248z$2);
@@ -23999,7 +24364,7 @@ const LoadingLayout = ({ tip, isLoading, error, isError, style, children, classN
23999
24364
  const Tbpage = ({ tableProps, searchOption, searchDisabled = false, onSubmit, isLoading, title, decs, }) => {
24000
24365
  const { user } = useTbState();
24001
24366
  return (React__default.createElement("div", { className: styles$1.tableFrame },
24002
- title || decs ? React__default.createElement(TitleBox$1, { title: title, decs: decs }) : null,
24367
+ title || decs ? React__default.createElement(TitleBox$2, { title: title, decs: decs }) : null,
24003
24368
  searchOption && (React__default.createElement(SearchBox, { searchOption: searchOption, onSubmit: onSubmit, searchDisabled: searchDisabled, onReset: () => {
24004
24369
  if (onSubmit)
24005
24370
  onSubmit(null, null, true);
@@ -24008,7 +24373,7 @@ const Tbpage = ({ tableProps, searchOption, searchDisabled = false, onSubmit, is
24008
24373
  React__default.createElement("div", { className: styles$1.multiFrame },
24009
24374
  React__default.createElement(AntBaseTable, { ...tableProps })))));
24010
24375
  };
24011
- const TitleBox$1 = ({ title, decs }) => {
24376
+ const TitleBox$2 = ({ title, decs }) => {
24012
24377
  return (React__default.createElement("div", { className: styles$1.titleBox },
24013
24378
  React__default.createElement("div", { className: styles$1.title }, title),
24014
24379
  React__default.createElement("div", { className: styles$1.decs }, decs)));
@@ -24026,6 +24391,24 @@ const TbpageSm = ({ tableProps, searchOption, onSubmit, isLoading, title, decs,
24026
24391
  React__default.createElement(AntBaseTable, { ...tableProps })))));
24027
24392
  };
24028
24393
 
24394
+ const Tblist = ({ tableProps, searchOption, searchDisabled = false, onSubmit, isLoading, title, decs, render, }) => {
24395
+ const { user } = useTbState();
24396
+ return (React__default.createElement("div", { className: styles$1.tableFrame },
24397
+ title || decs ? React__default.createElement(TitleBox$1, { title: title, decs: decs }) : null,
24398
+ searchOption && (React__default.createElement(SearchBox, { searchOption: searchOption, onSubmit: onSubmit, searchDisabled: searchDisabled, onReset: () => {
24399
+ if (onSubmit)
24400
+ onSubmit(null, null, true);
24401
+ } })),
24402
+ React__default.createElement(LoadingLayout, { isLoading: isLoading },
24403
+ React__default.createElement("div", { className: styles$1.multiFrame },
24404
+ React__default.createElement(AntBaseList, { tableProps: tableProps, render: render })))));
24405
+ };
24406
+ const TitleBox$1 = ({ title, decs }) => {
24407
+ return (React__default.createElement("div", { className: styles$1.titleBox },
24408
+ React__default.createElement("div", { className: styles$1.title }, title),
24409
+ React__default.createElement("div", { className: styles$1.decs }, decs)));
24410
+ };
24411
+
24029
24412
  const TbpageMulti = ({ arrtableProps, arrflex, searchOption, searchDisabled = false, onSubmit, isLoading, title, decs, direction, }) => {
24030
24413
  const { user } = useTbState();
24031
24414
  return (React__default.createElement("div", { className: styles$1.tableFrame, style: direction === "column" ? { flexDirection: "column" } : {} },
@@ -24056,5 +24439,5 @@ const TitleBox = ({ title, decs }) => {
24056
24439
  React__default.createElement("div", { className: styles$1.decs }, decs)));
24057
24440
  };
24058
24441
 
24059
- export { AntBaseModalCreate, AntBaseTable, AuthTable, ContentLayout, TbFrame, TbProvider, TbpProvider, Tbpage, TbpageMulti, TbpageSm, tbContext, useTbState };
24442
+ export { AntBaseModalCreate, AntBaseTable, AuthTable, ContentLayout, TbFrame, TbProvider, Tblist, TbpProvider, Tbpage, TbpageMulti, TbpageSm, tbContext, useTbState };
24060
24443
  //# sourceMappingURL=index.js.map