seat-editor 3.6.9 → 3.6.11

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.
@@ -106,6 +106,11 @@ export interface LayerViewProps<TMeta = undefined> {
106
106
  isSelectNode?: boolean;
107
107
  onMakeSelection?: (component: ComponentProps<TMeta>[]) => void;
108
108
  onDragTable?: (e: React.PointerEvent<SVGSVGElement>, component: ComponentProps<TMeta>) => void;
109
+ groupSelection?: {
110
+ colorGroupSelection: string[];
111
+ dataKey: string;
112
+ selection: Record<number, string[]>;
113
+ };
109
114
  }
110
115
  declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
111
116
  export default LayerView;
@@ -16,19 +16,19 @@ const LayerView = (props) => {
16
16
  const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
17
17
  // iconTags,
18
18
  tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags, loadingRender, actionPrivileged = {
19
- select: true,
20
- move: true,
21
- switch: true,
22
- drop: true,
23
- rightClick: true,
24
- double: true,
25
- selection: true,
26
- grapConnection: true,
27
- viewGraph: true,
28
- dragTable: true,
29
- selectNode: true,
30
- connectingNode: true
31
- }, onMakeSelection, } = props;
19
+ select: false,
20
+ move: false,
21
+ switch: false,
22
+ drop: false,
23
+ rightClick: false,
24
+ double: false,
25
+ selection: false,
26
+ grapConnection: false,
27
+ viewGraph: false,
28
+ dragTable: false,
29
+ selectNode: false,
30
+ connectingNode: false
31
+ }, onMakeSelection } = props;
32
32
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
33
33
  const tableGhost = useRef(null);
34
34
  const hoverUnderghostId = useRef(null);
@@ -15,19 +15,19 @@ const LayerView = (props) => {
15
15
  const { componentProps, extraComponentProps, onSelectComponent, onDoubleClick, mappingKey, statusKey, defaultBackground, defaultBoundingBox,
16
16
  // iconTags,
17
17
  tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags, loadingRender, actionPrivileged = {
18
- select: true,
19
- move: true,
20
- switch: true,
21
- drop: true,
22
- rightClick: true,
23
- double: true,
24
- selection: true,
25
- grapConnection: true,
26
- viewGraph: true,
27
- dragTable: true,
28
- selectNode: true,
29
- connectingNode: true
30
- }, onMakeSelection, } = props;
18
+ select: false,
19
+ move: false,
20
+ switch: false,
21
+ drop: false,
22
+ rightClick: false,
23
+ double: false,
24
+ selection: false,
25
+ grapConnection: false,
26
+ viewGraph: false,
27
+ dragTable: false,
28
+ selectNode: false,
29
+ connectingNode: false
30
+ }, onMakeSelection } = props;
31
31
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
32
32
  const tableGhost = useRef(null);
33
33
  const hoverUnderghostId = useRef(null);
@@ -55,4 +55,8 @@ export declare const renderElements: (elementEditor: ComponentProps[], mappingKe
55
55
  x: number;
56
56
  y: number;
57
57
  };
58
- } | null) => ComponentProps[];
58
+ } | null, groupSelection?: {
59
+ colorGroupSelection: string[];
60
+ dataKey: string;
61
+ selection: Record<number, string[]>;
62
+ }) => ComponentProps[];
@@ -25,9 +25,7 @@ export const getRectEdge = (from, to, width, height) => {
25
25
  const localAngle = angle + rad;
26
26
  const absCos = Math.abs(Math.cos(localAngle));
27
27
  const absSin = Math.abs(Math.sin(localAngle));
28
- const offset = (h / 2) * absCos <= (w / 2) * absSin
29
- ? (h / 2) / absSin
30
- : (w / 2) / absCos;
28
+ const offset = (h / 2) * absCos <= (w / 2) * absSin ? h / 2 / absSin : w / 2 / absCos;
31
29
  const localEdgeX = Math.cos(localAngle) * offset;
32
30
  const localEdgeY = Math.sin(localAngle) * offset;
33
31
  const worldEdge = rotatePoint(localEdgeX, localEdgeY, rotation);
@@ -67,9 +65,15 @@ export const buildPath = (points) => {
67
65
  return d;
68
66
  };
69
67
  // ─── renderElements ──────────────────────────────────────────────────────────
70
- export const renderElements = (elementEditor, mappingKey, tableMatchKey, connecting) => {
68
+ const findIndexByValue = (obj, targetValue) => {
69
+ if (!obj || targetValue)
70
+ return undefined;
71
+ const foundEntry = Object.entries(obj).find(([_, values]) => values.includes(targetValue));
72
+ return foundEntry ? Number(foundEntry[0]) : undefined;
73
+ };
74
+ export const renderElements = (elementEditor, mappingKey, tableMatchKey, connecting, groupSelection) => {
71
75
  return elementEditor.map((editorItem) => {
72
- var _a;
76
+ var _a, _b;
73
77
  const isUsingMapping = mappingKey &&
74
78
  typeof editorItem[mappingKey] === "object" &&
75
79
  editorItem[mappingKey] !== null;
@@ -80,7 +84,22 @@ export const renderElements = (elementEditor, mappingKey, tableMatchKey, connect
80
84
  if (hasKey)
81
85
  return item.value == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[item.key]);
82
86
  });
83
- const fill = (connecting === null || connecting === void 0 ? void 0 : connecting.fromId) == (finalProps === null || finalProps === void 0 ? void 0 : finalProps.id) ? "#7239EA" : (_a = tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties.fill) !== null && _a !== void 0 ? _a : finalProps === null || finalProps === void 0 ? void 0 : finalProps.fill;
87
+ // console.log({ finalProps })
88
+ const findIndexSelection = findIndexByValue(groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.selection, finalProps === null || finalProps === void 0 ? void 0 : finalProps[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]);
89
+ let fill = finalProps === null || finalProps === void 0 ? void 0 : finalProps.fill;
90
+ if (findIndexSelection) {
91
+ fill = groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.colorGroupSelection[findIndexSelection];
92
+ }
93
+ if ((_a = tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties) === null || _a === void 0 ? void 0 : _a.fill) {
94
+ fill = (_b = tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties) === null || _b === void 0 ? void 0 : _b.fill;
95
+ }
96
+ if ((connecting === null || connecting === void 0 ? void 0 : connecting.fromId) == (finalProps === null || finalProps === void 0 ? void 0 : finalProps.id)) {
97
+ fill = "#7239EA";
98
+ }
99
+ // fill =
100
+ // connecting?.fromId == finalProps?.id
101
+ // ? "#7239EA"
102
+ // : tableMatch?.properties?.fill ?? finalProps?.fill;
84
103
  finalProps = Object.assign(Object.assign(Object.assign({}, finalProps), tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties), { fill: fill, className: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.className, element: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.element });
85
104
  }
86
105
  return finalProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.6.9",
3
+ "version": "3.6.11",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",