seat-editor 3.3.13 → 3.3.15

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.
Files changed (136) hide show
  1. package/dist/app/constant.d.ts +1 -0
  2. package/dist/app/constant.js +1 -0
  3. package/dist/app/layout.d.ts +6 -0
  4. package/dist/app/layout.jsx +27 -0
  5. package/dist/app/new-board/page.jsx +55 -0
  6. package/dist/app/old-board/page.d.ts +3 -0
  7. package/dist/app/old-board/page.jsx +510 -0
  8. package/dist/app/only-view/chair.d.ts +1 -0
  9. package/dist/app/only-view/chair.js +12 -0
  10. package/dist/app/only-view/constant.d.ts +60 -0
  11. package/dist/app/only-view/constant.js +1336 -0
  12. package/dist/app/only-view/page.jsx +248 -0
  13. package/dist/app/only-view/user.d.ts +1 -0
  14. package/dist/app/only-view/user.js +12 -0
  15. package/dist/app/page.d.ts +2 -0
  16. package/dist/app/page.jsx +13 -0
  17. package/dist/app/test/page.d.ts +2 -0
  18. package/dist/app/test/page.jsx +45 -0
  19. package/dist/app/v2/page.d.ts +2 -0
  20. package/dist/app/v2/page.jsx +13 -0
  21. package/dist/components/button-tools/index.d.ts +11 -0
  22. package/dist/components/button-tools/index.jsx +17 -0
  23. package/dist/components/form-tools/label.d.ts +2 -0
  24. package/dist/components/form-tools/label.jsx +63 -0
  25. package/dist/components/form-tools/shape.d.ts +8 -0
  26. package/dist/components/form-tools/shape.jsx +113 -0
  27. package/dist/components/input/number-indicator.d.ts +7 -0
  28. package/dist/components/input/number-indicator.jsx +36 -0
  29. package/dist/components/joystick/index.d.ts +12 -0
  30. package/dist/components/joystick/index.jsx +49 -0
  31. package/dist/components/layer/index.d.ts +19 -0
  32. package/dist/components/layer/index.jsx +383 -0
  33. package/dist/components/layer-v2/index.d.ts +19 -0
  34. package/dist/components/layer-v2/index.jsx +370 -0
  35. package/dist/components/layer-v3/index.d.ts +13 -0
  36. package/dist/components/layer-v3/index.jsx +631 -0
  37. package/dist/components/layer-v3/utils.d.ts +19 -0
  38. package/dist/components/layer-v3/utils.js +72 -0
  39. package/dist/components/layer-v4/constant.d.ts +60 -0
  40. package/dist/components/layer-v4/constant.js +93 -0
  41. package/dist/components/layer-v4/index.d.ts +24 -0
  42. package/dist/components/layer-v4/index.jsx +1046 -0
  43. package/dist/components/lib/index.d.ts +8 -0
  44. package/dist/components/lib/index.jsx +33 -0
  45. package/dist/components/modal-preview/index.d.ts +4 -0
  46. package/dist/components/modal-preview/index.jsx +11 -0
  47. package/dist/dto/event-handler.d.ts +1 -0
  48. package/dist/dto/event-handler.js +1 -0
  49. package/dist/dto/table.d.ts +80 -0
  50. package/dist/dto/table.js +1 -0
  51. package/dist/features/board/board-slice.d.ts +14 -0
  52. package/dist/features/board/board-slice.js +52 -0
  53. package/dist/features/board/index.d.ts +6 -0
  54. package/dist/features/board/index.jsx +725 -0
  55. package/dist/features/board-v2/board-slice.d.ts +14 -0
  56. package/dist/features/board-v2/board-slice.js +52 -0
  57. package/dist/features/board-v2/index.d.ts +8 -0
  58. package/dist/features/board-v2/index.jsx +869 -0
  59. package/dist/features/board-v3/board-slice.d.ts +19 -0
  60. package/dist/features/board-v3/board-slice.js +274 -0
  61. package/dist/features/board-v3/constant.d.ts +5 -0
  62. package/dist/features/board-v3/constant.js +5 -0
  63. package/dist/features/board-v3/history-slice.d.ts +27 -0
  64. package/dist/features/board-v3/history-slice.js +27 -0
  65. package/dist/features/board-v3/icons.d.ts +4 -0
  66. package/dist/features/board-v3/icons.jsx +100 -0
  67. package/dist/features/board-v3/index.d.ts +16 -0
  68. package/dist/features/board-v3/index.jsx +1678 -0
  69. package/dist/features/board-v3/polygon.d.ts +28 -0
  70. package/dist/features/board-v3/polygon.js +109 -0
  71. package/dist/features/board-v3/rect.d.ts +9 -0
  72. package/dist/features/board-v3/rect.js +152 -0
  73. package/dist/features/board-v3/resize-element.d.ts +12 -0
  74. package/dist/features/board-v3/resize-element.js +43 -0
  75. package/dist/features/board-v3/utils.d.ts +180 -0
  76. package/dist/features/board-v3/utils.js +1235 -0
  77. package/dist/features/navbar/index.d.ts +2 -0
  78. package/dist/features/navbar/index.jsx +5 -0
  79. package/dist/features/panel/index.d.ts +6 -0
  80. package/dist/features/panel/index.jsx +251 -0
  81. package/dist/features/panel/panel-slice.d.ts +23 -0
  82. package/dist/features/panel/panel-slice.js +46 -0
  83. package/dist/features/panel/select-tool.d.ts +6 -0
  84. package/dist/features/panel/select-tool.jsx +70 -0
  85. package/dist/features/panel/selected-group.d.ts +2 -0
  86. package/dist/features/panel/selected-group.jsx +93 -0
  87. package/dist/features/panel/square-circle-tool.d.ts +2 -0
  88. package/dist/features/panel/square-circle-tool.jsx +10 -0
  89. package/dist/features/panel/table-seat-circle.d.ts +2 -0
  90. package/dist/features/panel/table-seat-circle.jsx +36 -0
  91. package/dist/features/panel/table-seat-square.d.ts +2 -0
  92. package/dist/features/panel/table-seat-square.jsx +51 -0
  93. package/dist/features/panel/text-tool.d.ts +2 -0
  94. package/dist/features/panel/text-tool.jsx +57 -0
  95. package/dist/features/panel/upload-tool.d.ts +10 -0
  96. package/dist/features/panel/upload-tool.jsx +176 -0
  97. package/dist/features/panel/utils.d.ts +5 -0
  98. package/dist/features/panel/utils.js +47 -0
  99. package/dist/features/side-tool/index.d.ts +8 -0
  100. package/dist/features/side-tool/index.jsx +390 -0
  101. package/dist/features/side-tool/side-tool-slice.d.ts +16 -0
  102. package/dist/features/side-tool/side-tool-slice.js +28 -0
  103. package/dist/features/theme/theme-slice.d.ts +12 -0
  104. package/dist/features/theme/theme-slice.js +15 -0
  105. package/dist/features/view-only/index.d.ts +19 -0
  106. package/dist/features/view-only/index.jsx +205 -0
  107. package/dist/features/view-only-2/index.d.ts +19 -0
  108. package/dist/features/view-only-2/index.jsx +190 -0
  109. package/dist/features/view-only-3/index.d.ts +89 -0
  110. package/dist/features/view-only-3/index.jsx +590 -0
  111. package/dist/features/view-only-3/utils.d.ts +1 -0
  112. package/dist/features/view-only-3/utils.js +3 -0
  113. package/dist/hooks/use-redux.d.ts +4 -0
  114. package/dist/hooks/use-redux.js +3 -0
  115. package/dist/index.js +10 -0
  116. package/dist/libs/middleware.d.ts +2 -0
  117. package/dist/libs/middleware.js +5 -0
  118. package/dist/libs/rootReducer.d.ts +12 -0
  119. package/dist/libs/rootReducer.js +14 -0
  120. package/dist/libs/store.d.ts +18 -0
  121. package/dist/libs/store.js +19 -0
  122. package/dist/provider/antd-provider.d.ts +4 -0
  123. package/dist/provider/antd-provider.jsx +46 -0
  124. package/dist/provider/redux-provider.d.ts +3 -0
  125. package/dist/provider/redux-provider.jsx +6 -0
  126. package/dist/provider/store-provider.d.ts +4 -0
  127. package/dist/provider/store-provider.jsx +10 -0
  128. package/dist/utils/constant.d.ts +3 -0
  129. package/dist/utils/constant.js +13 -0
  130. package/dist/utils/format.d.ts +2 -0
  131. package/dist/utils/format.js +29 -0
  132. package/dist/utils/injectCss.d.ts +1 -0
  133. package/dist/utils/injectCss.js +13 -0
  134. package/dist/utils/regex.d.ts +3 -0
  135. package/dist/utils/regex.js +3 -0
  136. package/package.json +1 -1
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { ColorPicker, Flex, Form, Input, InputNumber } from "antd";
3
+ const TextTool = () => {
4
+ return (<div className="py-2">
5
+ <Form.Item label="Name" name="shape" className="w-full hidden">
6
+ <Input defaultValue={"text"}/>
7
+ </Form.Item>
8
+
9
+ <Form.Item name="text" label="Text">
10
+ <Input />
11
+ </Form.Item>
12
+ <Flex className="w-full" gap={2}>
13
+ <Form.Item name={"fontColor"} label="Color" getValueFromEvent={(color) => color.toHexString()}>
14
+ <ColorPicker allowClear format="hex" defaultFormat="hex"/>
15
+ </Form.Item>
16
+ <Form.Item name={"fontSize"} label="Size">
17
+ <InputNumber suffix="px"/>
18
+ </Form.Item>
19
+ </Flex>
20
+ <Flex gap={2} className="w-full">
21
+ <Form.Item label="Width" name="width" className="w-full">
22
+ <InputNumber suffix="px" controls parser={(value) => {
23
+ var _a;
24
+ const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
25
+ return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
26
+ }}/>
27
+ </Form.Item>
28
+ <Form.Item label="Height" name="height" className="w-full">
29
+ <InputNumber suffix="px" parser={(value) => {
30
+ var _a;
31
+ const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
32
+ return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
33
+ }}/>
34
+ </Form.Item>
35
+ </Flex>
36
+ <Flex gap={2}>
37
+ <Form.Item label="Position X" name="x" className="w-full">
38
+ <InputNumber />
39
+ </Form.Item>
40
+ <Form.Item label="Position Y" name="y" className="w-full">
41
+ <InputNumber />
42
+ </Form.Item>
43
+ <Form.Item label="Rotation" name="rotation" className="w-full">
44
+ <InputNumber suffix="°" min={0} max={360} parser={(value) => {
45
+ if (!value)
46
+ return 0;
47
+ const num = Number(value.replace(/\D/g, ""));
48
+ if (Number.isNaN(num))
49
+ return 0;
50
+ return Math.min(360, Math.max(0, num));
51
+ }}/>
52
+ </Form.Item>
53
+ </Flex>
54
+
55
+ </div>);
56
+ };
57
+ export default TextTool;
@@ -0,0 +1,10 @@
1
+ import { PropertiesProps } from "../../dto/table";
2
+ interface UploadToolProps {
3
+ name: string;
4
+ type?: "component" | "background" | "assets";
5
+ action?: (file: File) => Promise<string>;
6
+ defaultValue?: PropertiesProps;
7
+ transform?: any;
8
+ }
9
+ declare const UploadTool: ({ name, type, action, defaultValue, transform }: UploadToolProps) => import("react").JSX.Element;
10
+ export default UploadTool;
@@ -0,0 +1,176 @@
1
+ "use client";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { useState, useEffect } from "react";
12
+ import { Upload, Image, Button, Form } from "antd";
13
+ import { InboxOutlined, LoadingOutlined } from "@ant-design/icons";
14
+ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
15
+ import SectionLabel from "../../components/form-tools/label";
16
+ import SectionShape from "../../components/form-tools/shape";
17
+ const { Dragger } = Upload;
18
+ const UploadTool = ({ name, type, action, defaultValue, transform }) => {
19
+ // const src = Form.useWatch("src");
20
+ // const height = Form.useWatch("height");
21
+ // const width = Form.useWatch("width");
22
+ // const x = Form.useWatch("x");
23
+ // const y = Form.useWatch("y");
24
+ // const shape = Form.useWatch("shape");
25
+ var _a, _b, _c;
26
+ const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
27
+ const transformState = (_a = transform === null || transform === void 0 ? void 0 : transform.instance) === null || _a === void 0 ? void 0 : _a.transformState;
28
+ const [defaultSrc, setDefaultSrc] = useState(null);
29
+ const [isEdit, setIsEdit] = useState(false);
30
+ const [loading, setLoading] = useState(false);
31
+ useEffect(() => {
32
+ if (defaultValue) {
33
+ setDefaultSrc(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.src);
34
+ setIsEdit(true);
35
+ setLoading(false);
36
+ }
37
+ }, [defaultValue]);
38
+ useEffect(() => {
39
+ if (selectedComponent && selectedComponent.shape === name) {
40
+ setDefaultSrc(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.src);
41
+ setIsEdit(true);
42
+ setLoading(false);
43
+ }
44
+ }, [selectedComponent]);
45
+ const dispatch = useAppDispatch();
46
+ const widthWorkspace = ((_b = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _b === void 0 ? void 0 : _b.clientWidth) || 0;
47
+ const heightWorkspace = ((_c = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0;
48
+ const defaultFormatValue = (width, height, src, id, x, y) => ({
49
+ id: id || new Date().getTime(),
50
+ x: x || Math.abs(transformState === null || transformState === void 0 ? void 0 : transformState.positionX),
51
+ y: y || Math.abs(transformState === null || transformState === void 0 ? void 0 : transformState.positionY),
52
+ width: width < 1 ? 200 : width,
53
+ height: height < 1 ? 200 : height,
54
+ rotation: 0,
55
+ shape: name,
56
+ src,
57
+ });
58
+ const propsUpload = {
59
+ name: "file",
60
+ multiple: true,
61
+ maxCount: 1,
62
+ showUploadList: false,
63
+ onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
64
+ setLoading(true);
65
+ if (info.file) {
66
+ const file = info.file;
67
+ const img = new window.Image();
68
+ let srcFromResponse = "";
69
+ try {
70
+ // ⬇️ IF ada custom action (upload ke server)
71
+ if (action) {
72
+ const src = yield action(file);
73
+ if (isEdit) {
74
+ dispatch({
75
+ type: "board/updateComponent",
76
+ payload: Object.assign({}, defaultFormatValue(selectedComponent.width, selectedComponent.height, src, Number(selectedComponent.id), selectedComponent.x, selectedComponent.y)),
77
+ });
78
+ dispatch({
79
+ type: "panel/setSelectedComponent",
80
+ payload: Object.assign({}, defaultFormatValue(selectedComponent.width, selectedComponent.height, src, Number(selectedComponent.id), selectedComponent.x, selectedComponent.y)),
81
+ });
82
+ setDefaultSrc(src);
83
+ dispatch({ type: "board/setFlagChange", payload: true });
84
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
85
+ }
86
+ else {
87
+ const defaultValue = Object.assign({}, defaultFormatValue(0, 0, src));
88
+ dispatch({
89
+ type: type === "component"
90
+ ? "board/addComponent"
91
+ : "board/setExtraComponent",
92
+ payload: defaultValue,
93
+ });
94
+ dispatch({
95
+ type: "panel/setSelectedComponent",
96
+ payload: defaultValue,
97
+ });
98
+ }
99
+ }
100
+ // ⬇️ IF local upload
101
+ else {
102
+ img.onload = () => {
103
+ const scaleX = widthWorkspace / img.width;
104
+ const scaleY = heightWorkspace / img.height;
105
+ const scale = Math.min(1, scaleX, scaleY);
106
+ const width = img.width * scale;
107
+ const height = img.height * scale;
108
+ if (isEdit) {
109
+ dispatch({
110
+ type: "board/updateComponent",
111
+ payload: Object.assign({}, defaultFormatValue(selectedComponent.width, selectedComponent.height, img.src, Number(selectedComponent.id), selectedComponent.x, selectedComponent.y)),
112
+ });
113
+ dispatch({
114
+ type: "panel/setSelectedComponent",
115
+ payload: Object.assign({}, defaultFormatValue(selectedComponent.width, selectedComponent.height, img.src, Number(selectedComponent.id), selectedComponent.x, selectedComponent.y)),
116
+ });
117
+ setDefaultSrc(img.src);
118
+ dispatch({ type: "board/setFlagChange", payload: true });
119
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
120
+ }
121
+ else {
122
+ dispatch({
123
+ type: type === "component"
124
+ ? "board/addComponent"
125
+ : "board/setExtraComponent",
126
+ payload: Object.assign({}, defaultFormatValue(width, height, img.src)),
127
+ });
128
+ }
129
+ setDefaultSrc(img.src);
130
+ dispatch({ type: "board/setFlagChange", payload: true });
131
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
132
+ // message.success(`${info.file.name} uploaded successfully.`);
133
+ };
134
+ // Set img src AFTER onload
135
+ img.src = URL.createObjectURL(file);
136
+ }
137
+ }
138
+ catch (e) {
139
+ // message.error("Upload failed, please try again.");
140
+ }
141
+ }
142
+ }),
143
+ };
144
+ const handleDelete = () => {
145
+ setDefaultSrc(null);
146
+ };
147
+ return (<Form.Item label="" name="src" className="w-full">
148
+ {defaultSrc ? (<>
149
+ <div className="w-full flex flex-col items-center gap-2 max-h-[200px] overflow-y-auto">
150
+ <Image src={defaultSrc}/>
151
+ </div>
152
+ <Button type="primary" onClick={handleDelete}>
153
+ Edit
154
+ </Button>
155
+ </>) : (<Dragger beforeUpload={() => false} {...propsUpload}>
156
+ {loading ? (<div className="w-full flex flex-col items-center gap-2 max-h-[200px]">
157
+ <LoadingOutlined />
158
+ </div>) : (<>
159
+ <p className="ant-upload-drag-icon">
160
+ <InboxOutlined />
161
+ </p>
162
+ <p className="ant-upload-text">
163
+ Click or drag file to this area to upload
164
+ </p>
165
+ <p className="ant-upload-hint">
166
+ Support for a single or bulk upload. Strictly prohibited from
167
+ uploading company data or other banned files.
168
+ </p>
169
+ </>)}
170
+ </Dragger>)}
171
+
172
+ <SectionShape allowChangeShape={type === "component"}/>
173
+ <SectionLabel />
174
+ </Form.Item>);
175
+ };
176
+ export default UploadTool;
@@ -0,0 +1,5 @@
1
+ import { SeatShape } from "../../utils/constant";
2
+ export declare const isSeatShape: (shape: string) => shape is SeatShape;
3
+ export declare const getSeatCount: (shape: string, props: any) => any;
4
+ export declare const getSeatPosition: (shape: string, props: any) => any;
5
+ export declare const adjustHeightWidthForSeatShape: (shape: string, props: any) => any;
@@ -0,0 +1,47 @@
1
+ import { SEAT_SHAPES } from "../../utils/constant";
2
+ import { MIN_HEIGHT, MIN_WIDTH } from "../board-v3/constant";
3
+ export const isSeatShape = (shape) => SEAT_SHAPES.includes(shape);
4
+ export const getSeatCount = (shape, props) => {
5
+ // if (shape === "table-seat-circle") {
6
+ // if (props?.seatCount) {
7
+ // return props.seatCount;
8
+ // } else if (props?.seatPositions) {
9
+ // const { top = 0, bottom = 0, left = 0, right = 0 } = props.seatPositions;
10
+ // return top + bottom + left + right;
11
+ // }
12
+ // }
13
+ return (props === null || props === void 0 ? void 0 : props.seatCount) || 0;
14
+ };
15
+ export const getSeatPosition = (shape, props) => {
16
+ // if (shape === "table-seat-square" || shape === "table-seat-rect-square") {
17
+ // if (props?.seatPositions) {
18
+ // return props.seatPositions;
19
+ // } else if (props?.seatCount) {
20
+ // const totalSeat = props.seatCount;
21
+ // const seatPerSide = Math.floor(totalSeat / 4);
22
+ // return {
23
+ // top: seatPerSide,
24
+ // bottom: seatPerSide,
25
+ // left: seatPerSide,
26
+ // right: seatPerSide,
27
+ // };
28
+ // }
29
+ // }
30
+ if (shape === "table-seat-rect-circle") {
31
+ return {
32
+ top: 1,
33
+ bottom: 1,
34
+ left: 1,
35
+ right: 1,
36
+ };
37
+ }
38
+ return (props === null || props === void 0 ? void 0 : props.seatPositions) || { top: 0, bottom: 0, left: 0, right: 0 };
39
+ };
40
+ export const adjustHeightWidthForSeatShape = (shape, props) => {
41
+ if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
42
+ const sizeDefault = Math.min(props.width, props.height);
43
+ const sizeFinal = sizeDefault < MIN_WIDTH ? MIN_WIDTH : sizeDefault;
44
+ return Object.assign(Object.assign({}, props), { height: isNaN(sizeFinal) ? MIN_WIDTH : sizeFinal, width: isNaN(sizeFinal) ? MIN_HEIGHT : sizeFinal });
45
+ }
46
+ return props;
47
+ };
@@ -0,0 +1,8 @@
1
+ declare const SideTool: ({ dragOnly, deleteAutorized, }: {
2
+ dragOnly?: boolean;
3
+ deleteAutorized?: {
4
+ component: boolean;
5
+ extraComponent: boolean;
6
+ };
7
+ }) => import("react").JSX.Element;
8
+ export default SideTool;