seat-editor 3.5.18 → 3.5.20

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.
@@ -83,6 +83,7 @@ export default function NewBoard() {
83
83
  extraComponent: true,
84
84
  }, action: handleUploadImage, mappingKey: "properties", onCurrentStateChange: (setState) => {
85
85
  var _a, _b, _c;
86
+ console.log("setState", setState);
86
87
  if (((_a = setState === null || setState === void 0 ? void 0 : setState.components) === null || _a === void 0 ? void 0 : _a.length) > 0) {
87
88
  setInitialValue((_b = setState.components) !== null && _b !== void 0 ? _b : []);
88
89
  }
@@ -100,5 +101,8 @@ export default function NewBoard() {
100
101
  // console.log({ action });
101
102
  // return null
102
103
  // }}
103
- defaultSeatCountKey: "capacity" }) })] }) }));
104
+ defaultSeatCountKey: "capacity", hiddenStatusKey: {
105
+ key: "status",
106
+ value: 0,
107
+ } }) })] }) }));
104
108
  }
@@ -91,6 +91,7 @@ export default function NewBoard() {
91
91
  extraComponent: true,
92
92
  }} action={handleUploadImage} mappingKey="properties" onCurrentStateChange={(setState) => {
93
93
  var _a, _b, _c;
94
+ console.log("setState", setState);
94
95
  if (((_a = setState === null || setState === void 0 ? void 0 : setState.components) === null || _a === void 0 ? void 0 : _a.length) > 0) {
95
96
  setInitialValue((_b = setState.components) !== null && _b !== void 0 ? _b : []);
96
97
  }
@@ -108,7 +109,10 @@ export default function NewBoard() {
108
109
  // console.log({ action });
109
110
  // return null
110
111
  // }}
111
- defaultSeatCountKey="capacity"/>
112
+ defaultSeatCountKey="capacity" hiddenStatusKey={{
113
+ key: "status",
114
+ value: 0,
115
+ }}/>
112
116
  </div>
113
117
  </div>
114
118
  </>);
@@ -10,12 +10,10 @@ export interface TableEditorProps<TMeta = undefined> {
10
10
  onSelectComponent?: (component: ComponentProps<TMeta>) => void;
11
11
  mappingKey?: string;
12
12
  selectedTableColor?: string;
13
- colorMatchKey?: [
14
- {
15
- color: string;
16
- key: string;
17
- }
18
- ];
13
+ colorMatchKey?: {
14
+ color: string;
15
+ key: string;
16
+ }[];
19
17
  statusKey: string;
20
18
  defaultBackground?: string;
21
19
  defaultBoundingBox?: PropertiesProps;
@@ -46,6 +44,10 @@ export interface TableEditorProps<TMeta = undefined> {
46
44
  disabledView?: boolean;
47
45
  defaultSeatCountKey?: string;
48
46
  header?: React.ReactNode;
47
+ hiddenStatusKey?: {
48
+ key: string;
49
+ value: number;
50
+ };
49
51
  }
50
52
  declare const TableEditor: <TMeta>(props: TableEditorProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
51
53
  export default TableEditor;
@@ -11,6 +11,7 @@ import { Spin } from "antd";
11
11
  const TableEditor = (props) => {
12
12
  var _a;
13
13
  const [initialValue, setInitialValue] = useState(null);
14
+ const [hiddenIdList, setHiddenIdList] = useState([]);
14
15
  const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized, refs, loadingRender, } = props;
15
16
  const { components, extraComponents, backgroundColor, boundingBox } = useAppSelector((state) => state.board);
16
17
  const { loading } = useAppSelector((state) => state.panel);
@@ -61,6 +62,15 @@ const TableEditor = (props) => {
61
62
  }
62
63
  });
63
64
  const hasUndefined = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.some((item) => item === undefined);
65
+ if (props === null || props === void 0 ? void 0 : props.hiddenStatusKey) {
66
+ matchInitialValueWithComponents = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.map((_, i) => {
67
+ const hidden = hiddenIdList.find((h) => (h === null || h === void 0 ? void 0 : h.key) === i); // find by key, bukan index
68
+ if (hidden) {
69
+ return hidden === null || hidden === void 0 ? void 0 : hidden.data;
70
+ }
71
+ return _;
72
+ });
73
+ }
64
74
  if (!hasUndefined && !viewOnly) {
65
75
  onCurrentStateChange({
66
76
  // @ts-ignore
@@ -81,7 +91,19 @@ const TableEditor = (props) => {
81
91
  }
82
92
  }, [components, extraComponents, backgroundColor, boundingBox]);
83
93
  const convertComponentProps = () => {
84
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
94
+ let hiddenIdList = [];
95
+ let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item, i) => {
96
+ const isHidden = item &&
97
+ (props === null || props === void 0 ? void 0 : props.hiddenStatusKey["key"]) &&
98
+ (item === null || item === void 0 ? void 0 : item[props === null || props === void 0 ? void 0 : props.hiddenStatusKey["key"]]) ===
99
+ (props === null || props === void 0 ? void 0 : props.hiddenStatusKey["value"]);
100
+ if (isHidden) {
101
+ hiddenIdList.push({
102
+ key: i,
103
+ data: item,
104
+ });
105
+ return {};
106
+ }
85
107
  if (item && mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
86
108
  const data = typeof (item === null || item === void 0 ? void 0 : item[mappingKey]) === "object" && (item === null || item === void 0 ? void 0 : item[mappingKey]) !== null
87
109
  ? item === null || item === void 0 ? void 0 : item[mappingKey]
@@ -93,6 +115,7 @@ const TableEditor = (props) => {
93
115
  }
94
116
  return item;
95
117
  });
118
+ setHiddenIdList(hiddenIdList);
96
119
  return mappingData;
97
120
  };
98
121
  useEffect(() => {
@@ -172,6 +195,6 @@ const TableEditor = (props) => {
172
195
  switch: false,
173
196
  drop: false,
174
197
  rightClick: false,
175
- } }, `${viewOnly}`) })) : (_jsxs("div", { className: "w-full h-full flex relative", children: [loading && !isPreview && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx("div", { className: "absolute top-0 left-0 w-full bg-white py-[20px] z-[51] border-b border-gray-200", children: props.header ? (props.header) : (_jsx("div", { className: "text-xl font-bold h-[38px] leading-[38px] flex ", children: "Logo Navbar" })) }), _jsx(SideTool, { dragOnly: dragOnly, deleteAutorized: deleteAutorized }), _jsx(Board, { refs: refsBoard, loadingRender: props === null || props === void 0 ? void 0 : props.loadingRender, disabled: props === null || props === void 0 ? void 0 : props.disabledView }, `${viewOnly}`), _jsx(ControlPanels, { action: props.action, transform: (_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef })] }, `${viewOnly}`)) }) }));
198
+ } }, `${viewOnly}`) })) : (_jsxs("div", { className: "w-full h-full flex relative", children: [loading && !isPreview && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx("div", { className: "absolute top-0 left-0 w-full bg-white py-[20px] z-[51] border-b border-gray-200", children: props.header ? (props.header) : (_jsx("div", { className: "text-xl font-bold h-[38px] leading-[38px] flex ", children: "Logo Navbar" })) }), _jsx(SideTool, { dragOnly: dragOnly, deleteAutorized: deleteAutorized }), _jsx(Board, { refs: refsBoard, loadingRender: props === null || props === void 0 ? void 0 : props.loadingRender, disabled: props === null || props === void 0 ? void 0 : props.disabledView }, `${viewOnly}`), _jsx(ControlPanels, { action: props.action, transform: (_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef })] }, `${viewOnly}`)) }) }));
176
199
  };
177
200
  export default TableEditor;
@@ -10,6 +10,7 @@ import { Spin } from "antd";
10
10
  const TableEditor = (props) => {
11
11
  var _a;
12
12
  const [initialValue, setInitialValue] = useState(null);
13
+ const [hiddenIdList, setHiddenIdList] = useState([]);
13
14
  const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized, refs, loadingRender, } = props;
14
15
  const { components, extraComponents, backgroundColor, boundingBox } = useAppSelector((state) => state.board);
15
16
  const { loading } = useAppSelector((state) => state.panel);
@@ -60,6 +61,15 @@ const TableEditor = (props) => {
60
61
  }
61
62
  });
62
63
  const hasUndefined = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.some((item) => item === undefined);
64
+ if (props === null || props === void 0 ? void 0 : props.hiddenStatusKey) {
65
+ matchInitialValueWithComponents = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.map((_, i) => {
66
+ const hidden = hiddenIdList.find((h) => (h === null || h === void 0 ? void 0 : h.key) === i); // find by key, bukan index
67
+ if (hidden) {
68
+ return hidden === null || hidden === void 0 ? void 0 : hidden.data;
69
+ }
70
+ return _;
71
+ });
72
+ }
63
73
  if (!hasUndefined && !viewOnly) {
64
74
  onCurrentStateChange({
65
75
  // @ts-ignore
@@ -80,7 +90,19 @@ const TableEditor = (props) => {
80
90
  }
81
91
  }, [components, extraComponents, backgroundColor, boundingBox]);
82
92
  const convertComponentProps = () => {
83
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
93
+ let hiddenIdList = [];
94
+ let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item, i) => {
95
+ const isHidden = item &&
96
+ (props === null || props === void 0 ? void 0 : props.hiddenStatusKey["key"]) &&
97
+ (item === null || item === void 0 ? void 0 : item[props === null || props === void 0 ? void 0 : props.hiddenStatusKey["key"]]) ===
98
+ (props === null || props === void 0 ? void 0 : props.hiddenStatusKey["value"]);
99
+ if (isHidden) {
100
+ hiddenIdList.push({
101
+ key: i,
102
+ data: item,
103
+ });
104
+ return {};
105
+ }
84
106
  if (item && mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
85
107
  const data = typeof (item === null || item === void 0 ? void 0 : item[mappingKey]) === "object" && (item === null || item === void 0 ? void 0 : item[mappingKey]) !== null
86
108
  ? item === null || item === void 0 ? void 0 : item[mappingKey]
@@ -92,6 +114,7 @@ const TableEditor = (props) => {
92
114
  }
93
115
  return item;
94
116
  });
117
+ setHiddenIdList(hiddenIdList);
95
118
  return mappingData;
96
119
  };
97
120
  useEffect(() => {
@@ -181,7 +204,7 @@ const TableEditor = (props) => {
181
204
  </div>)}
182
205
  <div className="absolute top-0 left-0 w-full bg-white py-[20px] z-[51] border-b border-gray-200">
183
206
  {props.header ? (props.header) : (<div className="text-xl font-bold h-[38px] leading-[38px] flex ">
184
- Logo Navbar
207
+ Logo Navbar
185
208
  </div>)}
186
209
  </div>
187
210
  <SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.5.18",
3
+ "version": "3.5.20",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",