@salesforce/storefront-next-runtime 0.1.1 → 0.2.0-alpha.0
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/DesignComponent.js +150 -0
- package/dist/DesignComponent.js.map +1 -0
- package/dist/DesignFrame.js +196 -0
- package/dist/DesignFrame.js.map +1 -0
- package/dist/DesignRegion.js +83 -0
- package/dist/DesignRegion.js.map +1 -0
- package/dist/apply-url-config.js +130 -0
- package/dist/apply-url-config.js.map +1 -0
- package/dist/component.types.d.ts +87 -0
- package/dist/component.types.d.ts.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +0 -0
- package/dist/design-data.d.ts +983 -0
- package/dist/design-data.d.ts.map +1 -0
- package/dist/design-data.js +908 -0
- package/dist/design-data.js.map +1 -0
- package/dist/design-messaging.d.ts +2 -2
- package/dist/design-react-core.d.ts +50 -5
- package/dist/design-react-core.d.ts.map +1 -1
- package/dist/design-react-core.js +81 -2
- package/dist/design-react-core.js.map +1 -1
- package/dist/design-react.d.ts +20 -95
- package/dist/design-react.d.ts.map +1 -1
- package/dist/design-react.js +3 -485
- package/dist/design-styles.css +2 -1
- package/dist/design.d.ts +110 -2
- package/dist/design.d.ts.map +1 -0
- package/dist/events.d.ts +1 -1
- package/dist/index.d.ts +1110 -154
- package/dist/index.d.ts.map +1 -1
- package/dist/multi-site.d.ts +154 -0
- package/dist/multi-site.d.ts.map +1 -0
- package/dist/multi-site.js +393 -0
- package/dist/multi-site.js.map +1 -0
- package/dist/routing-app-wrapper.d.ts +18 -0
- package/dist/routing-app-wrapper.d.ts.map +1 -0
- package/dist/routing-app-wrapper.js +21 -0
- package/dist/routing-app-wrapper.js.map +1 -0
- package/dist/routing.d.ts +42 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +171 -0
- package/dist/routing.js.map +1 -0
- package/dist/scapi.d.ts +69 -5
- package/dist/scapi.d.ts.map +1 -1
- package/dist/scapi.js +1 -1
- package/dist/scapi.js.map +1 -1
- package/dist/types.d.ts +40 -13289
- package/dist/types.d.ts.map +1 -1
- package/dist/types2.d.ts +13293 -0
- package/dist/types2.d.ts.map +1 -0
- package/dist/types3.d.ts +110 -0
- package/dist/types3.d.ts.map +1 -0
- package/dist/workspace.d.ts +46 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +52 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +44 -2
- package/dist/design-react.js.map +0 -1
- package/dist/index2.d.ts +0 -1171
- package/dist/index2.d.ts.map +0 -1
- /package/{LICENSE.txt → LICENSE} +0 -0
package/dist/design-react.js
CHANGED
|
@@ -1,488 +1,6 @@
|
|
|
1
1
|
import "./messaging-api.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as useDesignContext } from "./DesignContext.js";
|
|
3
3
|
import "./modeDetection.js";
|
|
4
|
-
import
|
|
5
|
-
import { i as useRegionContext, n as useComponentContext, r as RegionContext, t as ComponentContext } from "./ComponentContext.js";
|
|
6
|
-
import React, { useCallback, useMemo, useRef } from "react";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import "./PageDesignerProvider.js";
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
function useComponentDecoratorClasses({ componentId, isFragment, isLocalized }) {
|
|
11
|
-
const { selectedComponentId, hoveredComponentId, dragState } = useDesignState();
|
|
12
|
-
const isSelected = selectedComponentId === componentId;
|
|
13
|
-
const isHovered = !dragState.isDragging && hoveredComponentId === componentId;
|
|
14
|
-
const showFrame = (isSelected || isHovered) && !dragState.isDragging;
|
|
15
|
-
const isMoving = dragState.isDragging && dragState.sourceComponentId === componentId;
|
|
16
|
-
const isDropTarget = dragState.currentDropTarget?.componentId === componentId;
|
|
17
|
-
const dropTargetInsertType = dragState.currentDropTarget?.insertType;
|
|
18
|
-
const dropTargetAxis = dropTargetInsertType?.axis;
|
|
19
|
-
return [
|
|
20
|
-
"pd-design__decorator",
|
|
21
|
-
isFragment ? "pd-design__fragment" : "pd-design__component",
|
|
22
|
-
showFrame && "pd-design__frame--visible",
|
|
23
|
-
isSelected && "pd-design__decorator--selected",
|
|
24
|
-
isHovered && "pd-design__decorator--hovered",
|
|
25
|
-
isMoving && "pd-design__decorator--moving",
|
|
26
|
-
!isLocalized && "pd-design__component--unlocalized",
|
|
27
|
-
isDropTarget && dropTargetAxis && dropTargetInsertType && `pd-design__drop-target__${dropTargetAxis}-${dropTargetInsertType.type}`
|
|
28
|
-
].filter(Boolean).join(" ");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/design/react/hooks/useFocusedComponentHandler.ts
|
|
33
|
-
/**
|
|
34
|
-
* Focuses a component when the focused component id matches the component id.
|
|
35
|
-
* @param componentId - The id of the component to focus.
|
|
36
|
-
* @param nodeRef - The ref object to the node to focus.
|
|
37
|
-
*/
|
|
38
|
-
function useFocusedComponentHandler(componentId, nodeRef) {
|
|
39
|
-
const { focusedComponentId, focusComponent } = useDesignState();
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
if (focusedComponentId === componentId && nodeRef.current) focusComponent(nodeRef.current);
|
|
42
|
-
}, [
|
|
43
|
-
focusedComponentId,
|
|
44
|
-
componentId,
|
|
45
|
-
focusComponent,
|
|
46
|
-
nodeRef
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/design/react/hooks/useNodeToTargetStore.ts
|
|
52
|
-
function useNodeToTargetStore({ parentId, componentId, regionId, nodeRef, type, componentIds, componentTypeInclusions, componentTypeExclusions }) {
|
|
53
|
-
const { nodeToTargetMap } = useDesignState();
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
if (nodeRef.current) nodeToTargetMap.set(nodeRef.current, {
|
|
56
|
-
parentId,
|
|
57
|
-
componentId,
|
|
58
|
-
regionId,
|
|
59
|
-
type,
|
|
60
|
-
componentIds,
|
|
61
|
-
componentTypeInclusions,
|
|
62
|
-
componentTypeExclusions
|
|
63
|
-
});
|
|
64
|
-
}, [
|
|
65
|
-
nodeRef,
|
|
66
|
-
parentId,
|
|
67
|
-
componentId,
|
|
68
|
-
regionId,
|
|
69
|
-
type,
|
|
70
|
-
componentIds,
|
|
71
|
-
nodeToTargetMap,
|
|
72
|
-
componentTypeInclusions,
|
|
73
|
-
componentTypeExclusions
|
|
74
|
-
]);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/design/react/hooks/useComponentType.ts
|
|
79
|
-
function useComponentType(componentId) {
|
|
80
|
-
const { pageDesignerConfig } = useDesignContext();
|
|
81
|
-
const { type = "" } = pageDesignerConfig?.components[componentId] ?? {};
|
|
82
|
-
return pageDesignerConfig?.componentTypes[type] ?? null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/design/react/components/DeleteToolboxButton.tsx
|
|
87
|
-
const DeleteToolboxButton = ({ title, onClick, onMouseDown = () => {} }) => /* @__PURE__ */ jsx("button", {
|
|
88
|
-
className: "pd-design__frame__toolbox-button",
|
|
89
|
-
title,
|
|
90
|
-
type: "button",
|
|
91
|
-
onMouseDown,
|
|
92
|
-
onClick,
|
|
93
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
94
|
-
className: "pd-design__frame__delete-icon",
|
|
95
|
-
viewBox: "0 0 24 24",
|
|
96
|
-
fill: "none",
|
|
97
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
98
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
99
|
-
d: "M18 6L6 18M6 6l12 12",
|
|
100
|
-
stroke: "currentColor",
|
|
101
|
-
strokeWidth: "2",
|
|
102
|
-
strokeLinecap: "round",
|
|
103
|
-
strokeLinejoin: "round"
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/design/react/components/MoveToolboxButton.tsx
|
|
110
|
-
const MoveToolboxButton = ({ title }) => /* @__PURE__ */ jsx("button", {
|
|
111
|
-
className: "pd-design__frame__toolbox-button",
|
|
112
|
-
title,
|
|
113
|
-
type: "button",
|
|
114
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
115
|
-
className: "pd-design__frame__move-icon",
|
|
116
|
-
viewBox: "0 0 24 24",
|
|
117
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
118
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
119
|
-
d: "M22.9 11.7l-3.8-4.2c-.3-.3-.6 0-.6.4v2.7h-4.7c-.2 0-.4-.2-.4-.4V5.5h2.7c.5 0 .7-.4.4-.6l-4.1-3.8c-.2-.2-.5-.2-.7 0L7.6 4.9c-.3.3-.1.6.4.6h2.6v4.7c0 .2-.2.4-.4.4H5.5V7.9c0-.5-.4-.7-.6-.4l-3.8 4.1c-.2.2-.2.5 0 .7l3.8 4.1c.3.3.6.1.6-.4v-2.6h4.7c.2 0 .4.2.4.4v4.7H7.9c-.5 0-.7.4-.4.6l4.1 3.8c.2.2.5.2.7 0l4.1-3.8c.3-.3.1-.6-.4-.6h-2.6v-4.7c0-.2.2-.4.4-.4h4.7v2.7c0 .5.4.7.6.4l3.8-4.1c.2-.3.2-.5 0-.7z",
|
|
120
|
-
stroke: "currentColor",
|
|
121
|
-
strokeWidth: "2",
|
|
122
|
-
strokeLinecap: "round",
|
|
123
|
-
strokeLinejoin: "round"
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/design/react/hooks/useLabels.ts
|
|
130
|
-
function useLabels() {
|
|
131
|
-
const { pageDesignerConfig } = useDesignContext();
|
|
132
|
-
return pageDesignerConfig?.labels ?? {};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/design/react/components/DesignOverlay.tsx
|
|
137
|
-
/**
|
|
138
|
-
* Copyright 2026 Salesforce, Inc.
|
|
139
|
-
*
|
|
140
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
141
|
-
* you may not use this file except in compliance with the License.
|
|
142
|
-
* You may obtain a copy of the License at
|
|
143
|
-
*
|
|
144
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
145
|
-
*
|
|
146
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
147
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
148
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
149
|
-
* See the License for the specific language governing permissions and
|
|
150
|
-
* limitations under the License.
|
|
151
|
-
*/
|
|
152
|
-
const DesignOverlay = () => {
|
|
153
|
-
return /* @__PURE__ */ jsx("div", {
|
|
154
|
-
className: "pd-design__frame__overlay",
|
|
155
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
156
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
157
|
-
x: "0px",
|
|
158
|
-
y: "0px",
|
|
159
|
-
width: "52px",
|
|
160
|
-
height: "52px",
|
|
161
|
-
viewBox: "0 0 52 52",
|
|
162
|
-
enableBackground: "new 0 0 52 52",
|
|
163
|
-
xmlSpace: "preserve",
|
|
164
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
165
|
-
fill: "#FFFFFF",
|
|
166
|
-
d: "M26,2C12.7,2,2,12.7,2,26s10.7,24,24,24s24-10.7,24-24S39.3,2,26,2z M26,7C26,7,26,7,26,7C26,7,26,7,26,7\n C26,7,26,7,26,7z M28,7.1c-0.1,0-0.1,0-0.2,0C27.9,7.1,28,7.1,28,7.1z M26,45C15.5,45,7,36.5,7,26c0-1,0.1-2.1,0.3-3\n c1.3,0.2,2.9,0.7,3.7,1.5c1.7,1.8,3.6,3.9,5.4,4.3c0,0-0.2,0.1-0.4,0.4c-0.2,0.3-0.4,0.9-0.4,1.9c0,4.7,4.4,1.9,4.4,6.6\n c0,4.7,5.3,6.6,5.3,2.8s3.5-5.6,3.5-8.5s-2.7-2.8-4.4-3.8c-1.8-0.9-2.7-2.4-6.1-1.9c-1.8-1.7-2.8-3.1-2-4.7c0.9-1.7,4.6-2,4.6-4.6\n s-2.5-3.1-4.3-3.1c-0.8,0-2.5-0.6-3.9-1.3c1.7-1.7,3.8-3.1,6-4.1c1.6,0.7,4.3,1.8,6.6,1.8c2.7,0,4.1-1.9,3.7-3.1\n c4.5,0.7,8.5,3,11.4,6.2c-1.5,0.9-3.5,1.9-7,1.9c-4.6,0-4.6,4.7-1.9,5.6c2.8,0.9,5.6-1.8,6.5,0c0.9,1.8-6.5,1.8-4.6,6.4\n c1.9,4.6,3.7-0.1,5.6,4.5c1.9,4.6,5.6-0.7,2.8-4.3c-1.2-1.6-0.9-6.5,1.9-6.5h0.9c0.4,1.6,0.7,3.3,0.7,5C45,36.5,36.5,45,26,45z"
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/design/react/components/DesignFrame.tsx
|
|
174
|
-
const DesignFrame = ({ componentId, children, name, parentId, regionId, localized = false, showFrame = false, showToolbox = true, isMoveable = true }) => {
|
|
175
|
-
const componentType = useComponentType(componentId ?? "");
|
|
176
|
-
const { deleteComponent } = useDesignState();
|
|
177
|
-
const labels = useLabels();
|
|
178
|
-
const nodeRef = React.useRef(null);
|
|
179
|
-
const handleDelete = React.useCallback((event) => {
|
|
180
|
-
event.stopPropagation();
|
|
181
|
-
if (componentId) deleteComponent({
|
|
182
|
-
componentId,
|
|
183
|
-
sourceComponentId: parentId ?? "",
|
|
184
|
-
sourceRegionId: regionId ?? ""
|
|
185
|
-
});
|
|
186
|
-
}, [
|
|
187
|
-
deleteComponent,
|
|
188
|
-
componentId,
|
|
189
|
-
parentId,
|
|
190
|
-
regionId
|
|
191
|
-
]);
|
|
192
|
-
const stopPropagation = (event) => event.stopPropagation();
|
|
193
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
194
|
-
className: ["pd-design__frame", showFrame && "pd-design__frame--visible"].filter(Boolean).join(" "),
|
|
195
|
-
ref: nodeRef,
|
|
196
|
-
children: [
|
|
197
|
-
showFrame && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "pd-design__frame--x" }), /* @__PURE__ */ jsx("div", { className: "pd-design__frame--y" })] }),
|
|
198
|
-
/* @__PURE__ */ jsxs("div", {
|
|
199
|
-
className: "pd-design__frame__label",
|
|
200
|
-
onMouseDown: stopPropagation,
|
|
201
|
-
children: [
|
|
202
|
-
componentType?.image && /* @__PURE__ */ jsx("span", {
|
|
203
|
-
className: "pd-design__icon",
|
|
204
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
205
|
-
src: componentType.image,
|
|
206
|
-
alt: ""
|
|
207
|
-
})
|
|
208
|
-
}),
|
|
209
|
-
/* @__PURE__ */ jsx("span", {
|
|
210
|
-
className: "pd-design__frame__name",
|
|
211
|
-
children: name
|
|
212
|
-
}),
|
|
213
|
-
!localized && /* @__PURE__ */ jsx("span", {
|
|
214
|
-
className: "pd-design__frame__fallback-badge",
|
|
215
|
-
children: labels.fallback ?? "Fallback"
|
|
216
|
-
})
|
|
217
|
-
]
|
|
218
|
-
}),
|
|
219
|
-
showToolbox && /* @__PURE__ */ jsxs("div", {
|
|
220
|
-
className: "pd-design__frame__toolbox",
|
|
221
|
-
children: [isMoveable && /* @__PURE__ */ jsx(MoveToolboxButton, { title: labels.moveComponent ?? "Move component" }), /* @__PURE__ */ jsx(DeleteToolboxButton, {
|
|
222
|
-
title: labels.deleteComponent ?? "Delete component",
|
|
223
|
-
onMouseDown: stopPropagation,
|
|
224
|
-
onClick: handleDelete
|
|
225
|
-
})]
|
|
226
|
-
}),
|
|
227
|
-
/* @__PURE__ */ jsx(DesignOverlay, {}),
|
|
228
|
-
children
|
|
229
|
-
]
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
DesignFrame.defaultProps = {
|
|
233
|
-
parentId: void 0,
|
|
234
|
-
componentId: void 0,
|
|
235
|
-
showToolbox: true,
|
|
236
|
-
regionId: void 0,
|
|
237
|
-
showFrame: false
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/design/react/components/DesignComponent.tsx
|
|
242
|
-
function DesignComponent(props) {
|
|
243
|
-
const { designMetadata, children } = props;
|
|
244
|
-
const { id, name, isFragment, isVisible, isLocalized } = designMetadata;
|
|
245
|
-
const componentId = id;
|
|
246
|
-
const componentType = useComponentType(componentId);
|
|
247
|
-
const componentName = componentType?.label || name || "Component";
|
|
248
|
-
const dragRef = useRef(null);
|
|
249
|
-
const { regionId } = useRegionContext() ?? {};
|
|
250
|
-
const { componentId: parentComponentId } = useComponentContext() ?? {};
|
|
251
|
-
const { nodeToTargetMap } = useDesignState();
|
|
252
|
-
const { selectedComponentId, hoveredComponentId, setSelectedComponent, setHoveredComponent, startComponentMove, setPendingComponentDragId, dragState: { pendingComponentDragId, isDragging, sourceComponentId: draggingSourceComponentId } } = useDesignState();
|
|
253
|
-
useFocusedComponentHandler(componentId, dragRef);
|
|
254
|
-
useNodeToTargetStore({
|
|
255
|
-
type: "component",
|
|
256
|
-
nodeRef: dragRef,
|
|
257
|
-
parentId: parentComponentId,
|
|
258
|
-
regionId,
|
|
259
|
-
componentId
|
|
260
|
-
});
|
|
261
|
-
const discoverComponents = useComponentDiscovery({ nodeToTargetMap });
|
|
262
|
-
const isPendingDrag = pendingComponentDragId === componentId;
|
|
263
|
-
const handleMouseEnter = useCallback((event) => {
|
|
264
|
-
event.stopPropagation();
|
|
265
|
-
setHoveredComponent(componentId);
|
|
266
|
-
}, [setHoveredComponent, componentId]);
|
|
267
|
-
const handleMouseLeave = useCallback((event) => {
|
|
268
|
-
event.stopPropagation();
|
|
269
|
-
setHoveredComponent(discoverComponents({
|
|
270
|
-
x: event.clientX,
|
|
271
|
-
y: event.clientY,
|
|
272
|
-
filter: (entry) => entry.type === "component"
|
|
273
|
-
})[0]?.componentId ?? null);
|
|
274
|
-
}, [setHoveredComponent, discoverComponents]);
|
|
275
|
-
const handleClick = useCallback((e) => {
|
|
276
|
-
e.stopPropagation();
|
|
277
|
-
setSelectedComponent(componentId);
|
|
278
|
-
}, [setSelectedComponent, componentId]);
|
|
279
|
-
const showFrame = [selectedComponentId, hoveredComponentId].includes(componentId) && !isDragging;
|
|
280
|
-
const isDraggable = Boolean(componentId && regionId && componentType?.id);
|
|
281
|
-
const classes = useComponentDecoratorClasses({
|
|
282
|
-
componentId,
|
|
283
|
-
isLocalized,
|
|
284
|
-
isFragment: Boolean(isFragment)
|
|
285
|
-
});
|
|
286
|
-
const context = React.useMemo(() => ({
|
|
287
|
-
componentId: id,
|
|
288
|
-
name
|
|
289
|
-
}), [id, name]);
|
|
290
|
-
const handleDragOver = React.useCallback((event) => {
|
|
291
|
-
if (draggingSourceComponentId !== componentId) event.preventDefault();
|
|
292
|
-
}, [draggingSourceComponentId, componentId]);
|
|
293
|
-
const handleMouseDown = React.useCallback((event) => {
|
|
294
|
-
if (componentId) {
|
|
295
|
-
event.stopPropagation();
|
|
296
|
-
setPendingComponentDragId(componentId);
|
|
297
|
-
}
|
|
298
|
-
}, [componentId, setPendingComponentDragId]);
|
|
299
|
-
const handleDragStart = React.useCallback((event) => {
|
|
300
|
-
event.stopPropagation();
|
|
301
|
-
if (componentId && regionId && componentType?.id) startComponentMove(componentId, regionId, componentType.id);
|
|
302
|
-
}, [
|
|
303
|
-
componentId,
|
|
304
|
-
regionId,
|
|
305
|
-
componentType?.id,
|
|
306
|
-
startComponentMove
|
|
307
|
-
]);
|
|
308
|
-
if (!isVisible) return /* @__PURE__ */ jsx(Fragment, {});
|
|
309
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
310
|
-
ref: dragRef,
|
|
311
|
-
className: classes,
|
|
312
|
-
draggable: isPendingDrag && isDraggable,
|
|
313
|
-
onClick: handleClick,
|
|
314
|
-
onDragOver: handleDragOver,
|
|
315
|
-
onDragStart: handleDragStart,
|
|
316
|
-
onMouseEnter: handleMouseEnter,
|
|
317
|
-
onMouseLeave: handleMouseLeave,
|
|
318
|
-
onMouseDown: handleMouseDown,
|
|
319
|
-
"data-component-type": componentType?.id,
|
|
320
|
-
"data-testid": `design-component-${componentId}`,
|
|
321
|
-
children: [/* @__PURE__ */ jsx("div", { className: "pd-design__component__drop-target" }), /* @__PURE__ */ jsx(DesignFrame, {
|
|
322
|
-
showFrame,
|
|
323
|
-
componentId,
|
|
324
|
-
localized: isLocalized,
|
|
325
|
-
name: componentName,
|
|
326
|
-
parentId: parentComponentId,
|
|
327
|
-
isMoveable: isDraggable,
|
|
328
|
-
regionId,
|
|
329
|
-
children: /* @__PURE__ */ jsx(ComponentContext.Provider, {
|
|
330
|
-
value: context,
|
|
331
|
-
children
|
|
332
|
-
})
|
|
333
|
-
})]
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/design/react/components/ComponentDecorator.tsx
|
|
339
|
-
/**
|
|
340
|
-
* Creates a higher-order component that wraps React components with design-time functionality.
|
|
341
|
-
* In design mode, adds visual indicators, selection handling, and host communication.
|
|
342
|
-
* In normal mode, renders the component unchanged for optimal performance.
|
|
343
|
-
*
|
|
344
|
-
* @template TProps - The props type of the component being decorated
|
|
345
|
-
* @param Component - The React component to wrap with design functionality
|
|
346
|
-
* @returns A new component with design-time capabilities
|
|
347
|
-
*/
|
|
348
|
-
function createReactComponentDesignDecorator(Component) {
|
|
349
|
-
return function DesignDecoratedComponent(props) {
|
|
350
|
-
const { designMetadata, children,...componentProps } = props;
|
|
351
|
-
const { isDesignMode } = usePageDesignerMode();
|
|
352
|
-
return isDesignMode ? /* @__PURE__ */ jsx(DesignComponent, {
|
|
353
|
-
designMetadata,
|
|
354
|
-
children: /* @__PURE__ */ jsx(Component, {
|
|
355
|
-
...componentProps,
|
|
356
|
-
children
|
|
357
|
-
})
|
|
358
|
-
}) : /* @__PURE__ */ jsx(Component, {
|
|
359
|
-
...componentProps,
|
|
360
|
-
children
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region src/design/react/hooks/useRegionDecoratorClasses.ts
|
|
367
|
-
function useRegionDecoratorClasses({ regionId, componentTypeInclusions, componentTypeExclusions }) {
|
|
368
|
-
const { dragState: { currentDropTarget, componentType } } = useDesignState();
|
|
369
|
-
const isHovered = regionId && currentDropTarget?.regionId === regionId;
|
|
370
|
-
const isComponentAllowed = useMemo(() => isComponentTypeAllowedInRegion(componentType, componentTypeInclusions, componentTypeExclusions), [
|
|
371
|
-
componentType,
|
|
372
|
-
componentTypeInclusions,
|
|
373
|
-
componentTypeExclusions
|
|
374
|
-
]);
|
|
375
|
-
return [
|
|
376
|
-
"pd-design__decorator",
|
|
377
|
-
"pd-design__region",
|
|
378
|
-
isHovered && isComponentAllowed && "pd-design__region--hovered pd-design__frame--visible"
|
|
379
|
-
].filter(Boolean).join(" ");
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
//#endregion
|
|
383
|
-
//#region src/design/react/components/DesignRegion.tsx
|
|
384
|
-
function DesignRegion(props) {
|
|
385
|
-
const { designMetadata, children } = props;
|
|
386
|
-
const { name, id, componentIds, componentTypeInclusions, componentTypeExclusions } = designMetadata;
|
|
387
|
-
const nodeRef = React.useRef(null);
|
|
388
|
-
const classes = useRegionDecoratorClasses({
|
|
389
|
-
regionId: id,
|
|
390
|
-
componentTypeInclusions,
|
|
391
|
-
componentTypeExclusions
|
|
392
|
-
});
|
|
393
|
-
const { dragState } = useDesignState();
|
|
394
|
-
const labels = useLabels();
|
|
395
|
-
const showFrame = Boolean(id && dragState.currentDropTarget?.regionId === id);
|
|
396
|
-
const { componentId: parentComponentId } = useComponentContext() ?? {};
|
|
397
|
-
useNodeToTargetStore({
|
|
398
|
-
type: "region",
|
|
399
|
-
nodeRef,
|
|
400
|
-
parentId: parentComponentId,
|
|
401
|
-
componentIds,
|
|
402
|
-
componentId: parentComponentId ?? "",
|
|
403
|
-
regionId: id,
|
|
404
|
-
componentTypeInclusions,
|
|
405
|
-
componentTypeExclusions
|
|
406
|
-
});
|
|
407
|
-
const context = React.useMemo(() => ({
|
|
408
|
-
regionId: id,
|
|
409
|
-
componentIds
|
|
410
|
-
}), [id, componentIds]);
|
|
411
|
-
return /* @__PURE__ */ jsx("div", {
|
|
412
|
-
className: classes,
|
|
413
|
-
ref: nodeRef,
|
|
414
|
-
onDragOver: useCallback((event) => {
|
|
415
|
-
if (isComponentTypeAllowedInRegion(dragState.componentType, componentTypeInclusions, componentTypeExclusions)) event.preventDefault();
|
|
416
|
-
}, [
|
|
417
|
-
dragState.componentType,
|
|
418
|
-
componentTypeInclusions,
|
|
419
|
-
componentTypeExclusions
|
|
420
|
-
]),
|
|
421
|
-
"data-region-id": id,
|
|
422
|
-
children: /* @__PURE__ */ jsx(DesignFrame, {
|
|
423
|
-
name: name ?? labels.defaultRegionName ?? "Region",
|
|
424
|
-
parentId: parentComponentId,
|
|
425
|
-
regionId: id,
|
|
426
|
-
localized: true,
|
|
427
|
-
showFrame,
|
|
428
|
-
showToolbox: false,
|
|
429
|
-
children: /* @__PURE__ */ jsx(RegionContext.Provider, {
|
|
430
|
-
value: context,
|
|
431
|
-
children
|
|
432
|
-
})
|
|
433
|
-
})
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/design/react/components/RegionDecorator.tsx
|
|
439
|
-
function createReactRegionDesignDecorator(Region) {
|
|
440
|
-
return function DesignDecoratedRegion(props) {
|
|
441
|
-
const { designMetadata, children,...componentProps } = props;
|
|
442
|
-
const { isDesignMode } = usePageDesignerMode();
|
|
443
|
-
return isDesignMode ? /* @__PURE__ */ jsx(DesignRegion, {
|
|
444
|
-
designMetadata,
|
|
445
|
-
children: /* @__PURE__ */ jsx(Region, {
|
|
446
|
-
...componentProps,
|
|
447
|
-
children
|
|
448
|
-
})
|
|
449
|
-
}) : /* @__PURE__ */ jsx(Region, {
|
|
450
|
-
...componentProps,
|
|
451
|
-
children
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
//#endregion
|
|
457
|
-
//#region src/design/react/registry/adapter.ts
|
|
458
|
-
/**
|
|
459
|
-
* React framework adapter that implements React-specific behavior
|
|
460
|
-
* for the framework-agnostic component registry.
|
|
461
|
-
*/
|
|
462
|
-
var ReactAdapter = class {
|
|
463
|
-
/**
|
|
464
|
-
* Creates a React lazy component from an importer function.
|
|
465
|
-
*/
|
|
466
|
-
createLazyComponent(importer) {
|
|
467
|
-
return React.lazy(async () => {
|
|
468
|
-
return { default: (await importer()).default };
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Decorates a React component with design-time capabilities.
|
|
473
|
-
* Uses the React-specific design decorator directly.
|
|
474
|
-
*/
|
|
475
|
-
decorateComponent(component) {
|
|
476
|
-
return createReactComponentDesignDecorator(component);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
/**
|
|
480
|
-
* Creates a React adapter instance with optional configuration.
|
|
481
|
-
*/
|
|
482
|
-
function createReactAdapter() {
|
|
483
|
-
return new ReactAdapter();
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
//#endregion
|
|
487
|
-
export { createReactAdapter, createReactComponentDesignDecorator, createReactRegionDesignDecorator, useDesignContext };
|
|
488
|
-
//# sourceMappingURL=design-react.js.map
|
|
6
|
+
export { useDesignContext };
|
package/dist/design-styles.css
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
--pd-design-fallback-badge-color: rgb(172, 47, 109);
|
|
16
16
|
--pd-design-region-border-color: #3e3e3c;
|
|
17
17
|
--pd-design-drop-target-offset: 10px;
|
|
18
|
-
--pd-design-base-z-index:
|
|
18
|
+
--pd-design-base-z-index: 50;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.pd-design__component,
|
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
|
|
135
135
|
.pd-design__frame.pd-design__frame--visible > .pd-design__frame__label {
|
|
136
136
|
display: inline-flex;
|
|
137
|
+
z-index: calc(var(--pd-design-base-z-index) + 3);
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
.pd-design__component.pd-design__decorator--selected {
|
package/dist/design.d.ts
CHANGED
|
@@ -1,2 +1,110 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
1
|
+
import { a as Entry, i as DesignMetadata, n as ComponentModule, o as FrameworkAdapter, r as ComponentRegistryOptions, s as LoaderNames, t as ComponentId } from "./types3.js";
|
|
2
|
+
|
|
3
|
+
//#region src/design/registry/registry.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Framework-agnostic ComponentRegistry manages component loading with static registration.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Framework agnostic core with adapter pattern
|
|
10
|
+
* - Lazy loading via framework adapters for code splitting
|
|
11
|
+
* - Static component registration via build plugins (no dynamic discovery)
|
|
12
|
+
* - Design mode decoration via framework adapters
|
|
13
|
+
* - Request deduplication for concurrent component loads
|
|
14
|
+
* - Component metadata handled via API (not stored in registry)
|
|
15
|
+
*
|
|
16
|
+
* @template TProps - Component props type
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const registry = new ComponentRegistry({
|
|
21
|
+
* adapter: new ReactAdapter(),
|
|
22
|
+
* designDecorator: createDesignDecorator,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Components are pre-registered via static registry plugin
|
|
26
|
+
* // Get a component
|
|
27
|
+
* const Hero = registry.getComponent('hero');
|
|
28
|
+
*
|
|
29
|
+
* // Preload for SSR
|
|
30
|
+
* await registry.preload('hero');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class ComponentRegistry<TProps, TFrameworkComponent = unknown> {
|
|
34
|
+
private readonly registry;
|
|
35
|
+
private readonly pending;
|
|
36
|
+
private readonly cancelled;
|
|
37
|
+
private readonly adapter;
|
|
38
|
+
constructor({
|
|
39
|
+
adapter
|
|
40
|
+
}: ComponentRegistryOptions<TProps, TFrameworkComponent>);
|
|
41
|
+
/**
|
|
42
|
+
* Registers a component in the registry with the specified id.
|
|
43
|
+
* If a component with the same id already exists, it will be overwritten.
|
|
44
|
+
*/
|
|
45
|
+
registerComponent(id: ComponentId, component: TFrameworkComponent): void;
|
|
46
|
+
/**
|
|
47
|
+
* Registers a dynamic importer for a component id. Useful if you don't want to rely on scanning.
|
|
48
|
+
*/
|
|
49
|
+
registerImporter(id: ComponentId, importer: () => Promise<ComponentModule<TProps, TFrameworkComponent>>, loaderNames?: LoaderNames): void;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves a component by id. Returns a framework-specific component type.
|
|
52
|
+
* In lazy loading scenarios, this will be a lazy component if the component
|
|
53
|
+
* is discovered via dynamic import. In design mode, the returned component
|
|
54
|
+
* is decorated via `designDecorator`.
|
|
55
|
+
*/
|
|
56
|
+
getComponent(id: ComponentId): TFrameworkComponent | null;
|
|
57
|
+
/**
|
|
58
|
+
* Preload the JS chunk for a component id (use in route loaders/SSR to avoid waterfalls).
|
|
59
|
+
*
|
|
60
|
+
* This method ensures the component module is loaded and cached. Concurrent calls
|
|
61
|
+
* for the same component ID are automatically deduplicated via the pending map
|
|
62
|
+
* in ensureDiscovered().
|
|
63
|
+
*
|
|
64
|
+
* @throws Error if the component cannot be discovered
|
|
65
|
+
*/
|
|
66
|
+
preload(id: ComponentId): Promise<void>;
|
|
67
|
+
/** Get loader function names for external invocation. */
|
|
68
|
+
getLoaderNames(id: ComponentId): LoaderNames | undefined;
|
|
69
|
+
hasLoaders(id: ComponentId): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Call a loader function for a component externally.
|
|
72
|
+
*
|
|
73
|
+
* @param id - Component ID
|
|
74
|
+
* @param loaderArgs - Arguments to pass to the loader function
|
|
75
|
+
* @param loaderType - Type of loader to call ('loader' or 'clientLoader')
|
|
76
|
+
* @returns Promise resolving to the loader result
|
|
77
|
+
*/
|
|
78
|
+
callLoader(id: ComponentId, loaderArgs: unknown, loaderType?: keyof LoaderNames): Promise<unknown>;
|
|
79
|
+
/** Get fallback component if available. */
|
|
80
|
+
getFallback(id: ComponentId): TFrameworkComponent | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Returns all registered component IDs.
|
|
83
|
+
* Useful for debugging and introspection.
|
|
84
|
+
*/
|
|
85
|
+
getRegisteredIds(): ComponentId[];
|
|
86
|
+
/**
|
|
87
|
+
* Checks if a component is registered.
|
|
88
|
+
*/
|
|
89
|
+
has(id: ComponentId): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Clears all cached components and cancels pending discoveries.
|
|
92
|
+
* In-flight async operations will be cancelled and their promises will reject.
|
|
93
|
+
* Useful for testing or hot module replacement.
|
|
94
|
+
*/
|
|
95
|
+
clear(): void;
|
|
96
|
+
private ensureLocalEntry;
|
|
97
|
+
/**
|
|
98
|
+
* Ensures a component is discovered and cached.
|
|
99
|
+
* Only returns early if a raw (eagerly loaded) component exists.
|
|
100
|
+
* Otherwise, attempts to discover via registered importer.
|
|
101
|
+
*
|
|
102
|
+
* @throws Error if the discovery is cancelled via clear()
|
|
103
|
+
*/
|
|
104
|
+
private ensureDiscovered;
|
|
105
|
+
private buildFromImporter;
|
|
106
|
+
private buildFromLoadedModule;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { ComponentId, ComponentModule, ComponentRegistry, ComponentRegistryOptions, DesignMetadata, Entry, FrameworkAdapter, LoaderNames };
|
|
110
|
+
//# sourceMappingURL=design.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design.d.ts","names":[],"sources":["../src/design/registry/registry.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqDa;;;;;;;KAOgB,yBAAyB,QAAQ;;;;;wBAQpC,wBAAwB;;;;uBAStC,6BACY,QAAQ,gBAAgB,QAAQ,qCAClC;;;;;;;mBAYD,cAAc;;;;;;;;;;cAmBb,cAAc;;qBAgBb,cAAc;iBAIlB;;;;;;;;;iBAYM,qDAAoD,cAAyB;;kBAgClF,cAAc;;;;;sBAQV;;;;UAOZ"}
|
package/dist/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ShopperSearch, i as ShopperProducts, n as ShopperBasketsV2, t as ShopperBasketsV1 } from "./
|
|
1
|
+
import { a as ShopperSearch, i as ShopperProducts, n as ShopperBasketsV2, t as ShopperBasketsV1 } from "./types2.js";
|
|
2
2
|
import "openapi-fetch";
|
|
3
3
|
|
|
4
4
|
//#region src/events/types.d.ts
|