seat-editor 3.4.2 → 3.4.4

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.
@@ -42,23 +42,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
42
42
  const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
43
43
  const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
44
44
  const maxSeat = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey]) || 0;
45
- return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Shape" }), allowChangeShape && (_jsx(Flex, { gap: 2, className: "w-full", children: _jsx(Form.Item, { label: "Name", name: "shape", className: "w-full", children: _jsx(Select
46
- // options={optionsShape.map((item) => ({
47
- // ...item,
48
- // label:
49
- // item.value === "table-seat-rect-circle"
50
- // ? `Type 5 (only for 4 ${seatKey})`
51
- // : item.label,
52
- // }))}
53
- , {
54
- // options={optionsShape.map((item) => ({
55
- // ...item,
56
- // label:
57
- // item.value === "table-seat-rect-circle"
58
- // ? `Type 5 (only for 4 ${seatKey})`
59
- // : item.label,
60
- // }))}
61
- className: "w-full", children: optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
45
+ return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Shape" }), allowChangeShape && (_jsx(Flex, { gap: 2, className: "w-full", children: _jsx(Form.Item, { label: "Name", name: "shape", className: "w-full", children: _jsx(Select, { className: "w-full", children: optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
62
46
  const disabled = item.value === "table-seat-rect-circle" && maxSeat > 4;
63
47
  return (_jsx(Option, { value: item.value, disabled: disabled, children: item.value === "table-seat-rect-circle" ?
64
48
  `Type 5 (only for 4 ${seatKey})` : item.label }, item.value));
@@ -45,15 +45,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
45
45
  <h1 className="heading-s">Shape</h1>
46
46
  {allowChangeShape && (<Flex gap={2} className="w-full">
47
47
  <Form.Item label="Name" name="shape" className="w-full">
48
- <Select
49
- // options={optionsShape.map((item) => ({
50
- // ...item,
51
- // label:
52
- // item.value === "table-seat-rect-circle"
53
- // ? `Type 5 (only for 4 ${seatKey})`
54
- // : item.label,
55
- // }))}
56
- className="w-full">
48
+ <Select className="w-full">
57
49
  {optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
58
50
  const disabled = item.value === "table-seat-rect-circle" && maxSeat > 4;
59
51
  return (<Option key={item.value} value={item.value} disabled={disabled}>
@@ -146,11 +146,11 @@ const TableEditor = (props) => {
146
146
  // },
147
147
  // })
148
148
  // }
149
- if (loading) {
150
- setTimeout(() => {
151
- dispatch({ type: "panel/setLoading", payload: false });
152
- }, 1000);
153
- }
149
+ // if (loading) {
150
+ setTimeout(() => {
151
+ dispatch({ type: "panel/setLoading", payload: false });
152
+ }, 1000);
153
+ // }
154
154
  }, [
155
155
  componentProps,
156
156
  extraComponentProps,
@@ -145,11 +145,11 @@ const TableEditor = (props) => {
145
145
  // },
146
146
  // })
147
147
  // }
148
- if (loading) {
149
- setTimeout(() => {
150
- dispatch({ type: "panel/setLoading", payload: false });
151
- }, 1000);
152
- }
148
+ // if (loading) {
149
+ setTimeout(() => {
150
+ dispatch({ type: "panel/setLoading", payload: false });
151
+ }, 1000);
152
+ // }
153
153
  }, [
154
154
  componentProps,
155
155
  extraComponentProps,
@@ -3,8 +3,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { ColorPicker, Flex, Form, Divider, InputNumber } from "antd";
4
4
  import SectionLabel from "../../components/form-tools/label";
5
5
  import SectionShape from "../../components/form-tools/shape";
6
- // import { useAppSelector } from "@/hooks/use-redux";
6
+ import { useAppSelector } from "../../hooks/use-redux";
7
7
  const SeatCircle = () => {
8
- return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx(SectionShape, {}), _jsx("h1", { className: "heading-s", children: "Section Seating" }), _jsx(Divider, { style: { margin: 4 } }), _jsxs(Flex, { children: [_jsx(Form.Item, { name: "seatCount", label: "Seat Count", className: "w-full", children: _jsx(InputNumber, { min: 0, disabled: true }) }), _jsx(Form.Item, { name: "openSpace", label: "Open Space", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 10, suffix: "%" }) })] }), _jsx(Flex, { gap: 2, children: _jsx(Form.Item, { label: "Seat Fill", name: "seatFill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }) }), _jsx(SectionLabel, {})] }) }));
8
+ const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
9
+ const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
10
+ const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
11
+ const disabled = seatCountDefault > 0;
12
+ return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx(SectionShape, {}), _jsx("h1", { className: "heading-s", children: "Section Seating" }), _jsx(Divider, { style: { margin: 4 } }), _jsxs(Flex, { children: [_jsx(Form.Item, { name: "seatCount", label: "Seat Count", className: "w-full", children: _jsx(InputNumber, { min: 0, disabled: disabled }) }), _jsx(Form.Item, { name: "openSpace", label: "Open Space", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 10, suffix: "%" }) })] }), _jsx(Flex, { gap: 2, children: _jsx(Form.Item, { label: "Seat Fill", name: "seatFill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }) }), _jsx(SectionLabel, {})] }) }));
9
13
  };
10
14
  export default SeatCircle;
@@ -2,8 +2,12 @@
2
2
  import { ColorPicker, Flex, Form, Divider, InputNumber } from "antd";
3
3
  import SectionLabel from "../../components/form-tools/label";
4
4
  import SectionShape from "../../components/form-tools/shape";
5
- // import { useAppSelector } from "@/hooks/use-redux";
5
+ import { useAppSelector } from "../../hooks/use-redux";
6
6
  const SeatCircle = () => {
7
+ const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
8
+ const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
9
+ const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
10
+ const disabled = seatCountDefault > 0;
7
11
  return (<>
8
12
  <div className="py-2">
9
13
  <SectionShape />
@@ -11,7 +15,7 @@ const SeatCircle = () => {
11
15
  <Divider style={{ margin: 4 }}/>
12
16
  <Flex>
13
17
  <Form.Item name="seatCount" label="Seat Count" className="w-full">
14
- <InputNumber min={0} disabled/>
18
+ <InputNumber min={0} disabled={disabled}/>
15
19
  </Form.Item>
16
20
  <Form.Item name="openSpace" label="Open Space" className="w-full">
17
21
  <InputNumber max={100} min={0} step={10} suffix="%"/>
@@ -2,7 +2,7 @@ import { PropertiesProps } from "../../dto/table";
2
2
  import { SeatShape } from "../../utils/constant";
3
3
  export declare const isSeatShape: (shape: string) => shape is SeatShape;
4
4
  export declare const getSeatCount: (shape: string, props: PropertiesProps, defaultValue: number) => number;
5
- export declare const getSeatPosition: (shape: string, props: PropertiesProps, defaultValue: number) => {
5
+ export declare const getSeatPosition: (shape: string, props: PropertiesProps, defaultValue: number | undefined) => {
6
6
  top: number;
7
7
  right: number;
8
8
  bottom: number;
@@ -10,32 +10,57 @@ export const getSeatCount = (shape, props, defaultValue) => {
10
10
  // return top + bottom + left + right;
11
11
  // }
12
12
  // }
13
+ if (!defaultValue) {
14
+ if (props === null || props === void 0 ? void 0 : props.seatCount) {
15
+ return props.seatCount;
16
+ }
17
+ else {
18
+ return 4;
19
+ }
20
+ }
13
21
  return (props === null || props === void 0 ? void 0 : props.seatCount) || defaultValue || 0;
14
22
  };
15
23
  export const getSeatPosition = (shape, props, defaultValue) => {
16
24
  let seatCountDefault = defaultValue;
17
- if (seatCountDefault === 0) {
18
- return {
19
- top: 0,
20
- bottom: 0,
21
- left: 0,
22
- right: 0,
23
- };
24
- }
25
25
  if (shape === "table-seat-rect-circle") {
26
26
  if (seatCountDefault > 4) {
27
27
  seatCountDefault = 4;
28
28
  }
29
+ console.log(props === null || props === void 0 ? void 0 : props.seatPositions);
30
+ if (getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) > 4) {
31
+ return distributeSeats(4);
32
+ }
33
+ console.log(getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions));
29
34
  return (props === null || props === void 0 ? void 0 : props.seatPositions) &&
30
35
  getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) <= seatCountDefault
31
36
  ? normalizeSeatPosition(props === null || props === void 0 ? void 0 : props.seatPositions)
32
37
  : distributeSeats(seatCountDefault);
33
38
  }
34
- console.log("seatCountDefault", props === null || props === void 0 ? void 0 : props.seatPositions);
35
- if (getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) <= seatCountDefault && (getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) !== 0)) {
39
+ if (!defaultValue) {
40
+ if (props === null || props === void 0 ? void 0 : props.seatPositions) {
41
+ return props === null || props === void 0 ? void 0 : props.seatPositions;
42
+ }
43
+ else {
44
+ return {
45
+ top: 1,
46
+ bottom: 1,
47
+ left: 1,
48
+ right: 1,
49
+ };
50
+ }
51
+ }
52
+ if (seatCountDefault === 0) {
53
+ return {
54
+ top: 0,
55
+ bottom: 0,
56
+ left: 0,
57
+ right: 0,
58
+ };
59
+ }
60
+ if (getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) <= seatCountDefault &&
61
+ getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) !== 0) {
36
62
  return props === null || props === void 0 ? void 0 : props.seatPositions;
37
63
  }
38
- console.log("seatCountDefault", seatCountDefault);
39
64
  return distributeSeats(seatCountDefault);
40
65
  };
41
66
  export const adjustHeightWidthForSeatShape = (shape, props) => {
@@ -89,11 +89,9 @@ const LayerView = (props) => {
89
89
  payload: defaultBoundingBox,
90
90
  });
91
91
  // }
92
- if (loading) {
93
- setTimeout(() => {
94
- dispatch({ type: "panel/setLoading", payload: false });
95
- }, 1000);
96
- }
92
+ setTimeout(() => {
93
+ dispatch({ type: "panel/setLoading", payload: false });
94
+ }, 1000);
97
95
  }, [
98
96
  componentProps,
99
97
  extraComponentProps,
@@ -88,11 +88,9 @@ const LayerView = (props) => {
88
88
  payload: defaultBoundingBox,
89
89
  });
90
90
  // }
91
- if (loading) {
92
- setTimeout(() => {
93
- dispatch({ type: "panel/setLoading", payload: false });
94
- }, 1000);
95
- }
91
+ setTimeout(() => {
92
+ dispatch({ type: "panel/setLoading", payload: false });
93
+ }, 1000);
96
94
  }, [
97
95
  componentProps,
98
96
  extraComponentProps,
@@ -90,11 +90,11 @@ const LayerView = (props) => {
90
90
  payload: defaultBoundingBox,
91
91
  });
92
92
  // }
93
- if (loading) {
94
- setTimeout(() => {
95
- dispatch({ type: "panel/setLoading", payload: false });
96
- }, 1000);
97
- }
93
+ // if (loading) {
94
+ setTimeout(() => {
95
+ dispatch({ type: "panel/setLoading", payload: false });
96
+ }, 1000);
97
+ // }
98
98
  }, [
99
99
  componentProps,
100
100
  extraComponentProps,
@@ -89,11 +89,11 @@ const LayerView = (props) => {
89
89
  payload: defaultBoundingBox,
90
90
  });
91
91
  // }
92
- if (loading) {
93
- setTimeout(() => {
94
- dispatch({ type: "panel/setLoading", payload: false });
95
- }, 1000);
96
- }
92
+ // if (loading) {
93
+ setTimeout(() => {
94
+ dispatch({ type: "panel/setLoading", payload: false });
95
+ }, 1000);
96
+ // }
97
97
  }, [
98
98
  componentProps,
99
99
  extraComponentProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.4.2",
3
+ "version": "3.4.4",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",