@superblocksteam/library 2.0.41-next.19 → 2.0.41-next.2
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/index.js +67 -132
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,8 +15,8 @@ import { trace } from "@opentelemetry/api";
|
|
|
15
15
|
import { observer } from "mobx-react-lite";
|
|
16
16
|
import { compile, middleware, prefixer, serialize, stringify } from "stylis";
|
|
17
17
|
import polyfill from "@oddbird/css-anchor-positioning/fn";
|
|
18
|
-
import { DndContext, DragOverlay, PointerSensor, rectIntersection, useDndMonitor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
19
18
|
import * as Popover from "@radix-ui/react-popover";
|
|
19
|
+
import { DndContext, DragOverlay, PointerSensor, rectIntersection, useDndMonitor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
20
20
|
import { snapCenterToCursor } from "@dnd-kit/modifiers";
|
|
21
21
|
import { Root, TooltipContent, TooltipPortal, TooltipProvider, TooltipTrigger } from "@radix-ui/react-tooltip";
|
|
22
22
|
import tinycolor from "tinycolor2";
|
|
@@ -2200,98 +2200,6 @@ const CSS_CLASSES = {
|
|
|
2200
2200
|
ANCHOR_NAME: "sb-anchor-name"
|
|
2201
2201
|
};
|
|
2202
2202
|
|
|
2203
|
-
//#endregion
|
|
2204
|
-
//#region src/edit-mode/dnd/hooks/use-component-draggable.ts
|
|
2205
|
-
function useComponentDraggable({ instanceId, disableDrag }) {
|
|
2206
|
-
return useDraggable({
|
|
2207
|
-
id: instanceId,
|
|
2208
|
-
disabled: disableDrag,
|
|
2209
|
-
data: { instanceId }
|
|
2210
|
-
});
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
//#endregion
|
|
2214
|
-
//#region src/edit-mode/dnd/use-draggable-widget.ts
|
|
2215
|
-
function useDraggableWidget(props) {
|
|
2216
|
-
const editStore = getEditStore();
|
|
2217
|
-
const disableDrag = props.disableDrag || editStore.ui.dnd.isDraggingNewComponent;
|
|
2218
|
-
const specificWidgetDragDisabled = !editStore.ui.dnd.canDragWidget(props.instanceId);
|
|
2219
|
-
const { setNodeRef, isDragging, listeners, attributes } = useComponentDraggable({
|
|
2220
|
-
instanceId: props.instanceId,
|
|
2221
|
-
disableDrag: disableDrag ?? false
|
|
2222
|
-
});
|
|
2223
|
-
const onPointerDown = useCallback((e) => {
|
|
2224
|
-
if (e.target instanceof HTMLElement && e.target.dataset.ignoreDnd) return;
|
|
2225
|
-
if (specificWidgetDragDisabled) e.stopPropagation();
|
|
2226
|
-
else listeners?.onPointerDown(e);
|
|
2227
|
-
}, [specificWidgetDragDisabled, listeners]);
|
|
2228
|
-
const onPointerMove = useCallback((e) => {
|
|
2229
|
-
if (specificWidgetDragDisabled) e.stopPropagation();
|
|
2230
|
-
else listeners?.onPointerMove(e);
|
|
2231
|
-
}, [specificWidgetDragDisabled, listeners]);
|
|
2232
|
-
return useMemo(() => {
|
|
2233
|
-
return {
|
|
2234
|
-
...listeners,
|
|
2235
|
-
...attributes,
|
|
2236
|
-
className: "sb-draggable-wrapper",
|
|
2237
|
-
"data-is-dragged": isDragging,
|
|
2238
|
-
onPointerDown,
|
|
2239
|
-
onPointerMove,
|
|
2240
|
-
setNodeRef
|
|
2241
|
-
};
|
|
2242
|
-
}, [
|
|
2243
|
-
listeners,
|
|
2244
|
-
attributes,
|
|
2245
|
-
isDragging,
|
|
2246
|
-
onPointerDown,
|
|
2247
|
-
onPointerMove,
|
|
2248
|
-
setNodeRef
|
|
2249
|
-
]);
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
//#endregion
|
|
2253
|
-
//#region src/lib/internal-details/draggable-context-provider.tsx
|
|
2254
|
-
const DraggablePropsContext = createContext({
|
|
2255
|
-
instanceId: void 0,
|
|
2256
|
-
props: {
|
|
2257
|
-
className: void 0,
|
|
2258
|
-
ref: null
|
|
2259
|
-
}
|
|
2260
|
-
});
|
|
2261
|
-
const DraggablePropsProvider = ({ identifier, disableDrag, children }) => {
|
|
2262
|
-
const draggableWidgetProps = useDraggableWidget({
|
|
2263
|
-
instanceId: identifier.instanceId,
|
|
2264
|
-
disableDrag
|
|
2265
|
-
});
|
|
2266
|
-
const setNodeRef = draggableWidgetProps.setNodeRef;
|
|
2267
|
-
const handleRef = useCallback((el) => {
|
|
2268
|
-
setNodeRef(el);
|
|
2269
|
-
}, [setNodeRef]);
|
|
2270
|
-
const value = useMemo(() => {
|
|
2271
|
-
return {
|
|
2272
|
-
instanceId: identifier.instanceId,
|
|
2273
|
-
props: {
|
|
2274
|
-
...draggableWidgetProps,
|
|
2275
|
-
ref: handleRef
|
|
2276
|
-
}
|
|
2277
|
-
};
|
|
2278
|
-
}, [
|
|
2279
|
-
draggableWidgetProps,
|
|
2280
|
-
handleRef,
|
|
2281
|
-
identifier.instanceId
|
|
2282
|
-
]);
|
|
2283
|
-
return /* @__PURE__ */ jsx(DraggablePropsContext.Provider, {
|
|
2284
|
-
value,
|
|
2285
|
-
children
|
|
2286
|
-
});
|
|
2287
|
-
};
|
|
2288
|
-
const EMPTY_PROPS = {};
|
|
2289
|
-
const useMyDraggableProps = (instanceId) => {
|
|
2290
|
-
const contextValue = useContext(DraggablePropsContext);
|
|
2291
|
-
if (contextValue.instanceId !== instanceId) return EMPTY_PROPS;
|
|
2292
|
-
return contextValue.props;
|
|
2293
|
-
};
|
|
2294
|
-
|
|
2295
2203
|
//#endregion
|
|
2296
2204
|
//#region src/lib/user-facing/assets/icons/close.svg
|
|
2297
2205
|
var _path$4;
|
|
@@ -3264,33 +3172,6 @@ const WrappedReactiveComponent = (props) => {
|
|
|
3264
3172
|
};
|
|
3265
3173
|
var reactive_component_default = WrappedReactiveComponent;
|
|
3266
3174
|
|
|
3267
|
-
//#endregion
|
|
3268
|
-
//#region src/lib/internal-details/editor-reactive-component.tsx
|
|
3269
|
-
const mergeProps = (props1, props2) => {
|
|
3270
|
-
const mergedClassName = props1.className && props2.className ? `${props1.className} ${props2.className}` : props1.className || props2.className;
|
|
3271
|
-
const mergedStyle = {
|
|
3272
|
-
...props1.style,
|
|
3273
|
-
...props2.style
|
|
3274
|
-
};
|
|
3275
|
-
return {
|
|
3276
|
-
...props1,
|
|
3277
|
-
...props2,
|
|
3278
|
-
style: mergedStyle,
|
|
3279
|
-
className: mergedClassName
|
|
3280
|
-
};
|
|
3281
|
-
};
|
|
3282
|
-
const EditorReactiveComponent = (props) => {
|
|
3283
|
-
const { editorProps,...restProps } = props;
|
|
3284
|
-
const myDraggableProps = useMyDraggableProps(props.identifier.instanceId);
|
|
3285
|
-
const mergedEditorProps = useMemo(() => {
|
|
3286
|
-
return mergeProps(editorProps ?? {}, myDraggableProps);
|
|
3287
|
-
}, [editorProps, myDraggableProps]);
|
|
3288
|
-
return /* @__PURE__ */ jsx(reactive_component_default, {
|
|
3289
|
-
...restProps,
|
|
3290
|
-
editorProps: mergedEditorProps
|
|
3291
|
-
});
|
|
3292
|
-
};
|
|
3293
|
-
|
|
3294
3175
|
//#endregion
|
|
3295
3176
|
//#region src/lib/utils/is-component-type-detached.ts
|
|
3296
3177
|
function isComponentTypeDetached(componentType) {
|
|
@@ -3518,6 +3399,45 @@ const DroppableWidget = observer((props) => {
|
|
|
3518
3399
|
});
|
|
3519
3400
|
var droppable_widget_default = DroppableWidget;
|
|
3520
3401
|
|
|
3402
|
+
//#endregion
|
|
3403
|
+
//#region src/edit-mode/dnd/hooks/use-component-draggable.ts
|
|
3404
|
+
function useComponentDraggable({ instanceId, disableDrag }) {
|
|
3405
|
+
return useDraggable({
|
|
3406
|
+
id: instanceId,
|
|
3407
|
+
disabled: disableDrag,
|
|
3408
|
+
data: { instanceId }
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
//#endregion
|
|
3413
|
+
//#region src/edit-mode/dnd/use-draggable-widget.ts
|
|
3414
|
+
function useDraggableWidget(props) {
|
|
3415
|
+
const editStore = getEditStore();
|
|
3416
|
+
const disableDrag = props.disableDrag || editStore.ui.dnd.isDraggingNewComponent;
|
|
3417
|
+
const specificWidgetDragDisabled = !editStore.ui.dnd.canDragWidget(props.instanceId);
|
|
3418
|
+
const { setNodeRef, isDragging, listeners, attributes } = useComponentDraggable({
|
|
3419
|
+
instanceId: props.instanceId,
|
|
3420
|
+
disableDrag: disableDrag ?? false
|
|
3421
|
+
});
|
|
3422
|
+
const onPointerDown = useCallback((e) => {
|
|
3423
|
+
if (specificWidgetDragDisabled) e.stopPropagation();
|
|
3424
|
+
else listeners?.onPointerDown(e);
|
|
3425
|
+
}, [specificWidgetDragDisabled, listeners]);
|
|
3426
|
+
const onPointerMove = useCallback((e) => {
|
|
3427
|
+
if (specificWidgetDragDisabled) e.stopPropagation();
|
|
3428
|
+
else listeners?.onPointerMove(e);
|
|
3429
|
+
}, [specificWidgetDragDisabled, listeners]);
|
|
3430
|
+
return {
|
|
3431
|
+
...listeners,
|
|
3432
|
+
...attributes,
|
|
3433
|
+
className: "sb-draggable-wrapper",
|
|
3434
|
+
"data-is-dragged": isDragging,
|
|
3435
|
+
onPointerDown,
|
|
3436
|
+
onPointerMove,
|
|
3437
|
+
setNodeRef
|
|
3438
|
+
};
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3521
3441
|
//#endregion
|
|
3522
3442
|
//#region src/edit-mode/hooks/use-right-click-menu.ts
|
|
3523
3443
|
function useRightClickMenu({ sourceId }) {
|
|
@@ -4641,6 +4561,18 @@ const EditWrapper = observer(function EditWrapper$1(props) {
|
|
|
4641
4561
|
});
|
|
4642
4562
|
const isDroppable = isEntityDroppable({ type: props.type });
|
|
4643
4563
|
const disableDrag = !isDraggable || !isContentDraggable(props.type);
|
|
4564
|
+
const draggableWidgetProps = useDraggableWidget({
|
|
4565
|
+
instanceId: props.identifier.instanceId,
|
|
4566
|
+
disableDrag
|
|
4567
|
+
});
|
|
4568
|
+
const { setDraggableNodeRef, draggableClassName, draggableProps } = useMemo(() => {
|
|
4569
|
+
const { setNodeRef: setDraggableNodeRef$1, className: draggableClassName$1,...draggableProps$1 } = draggableWidgetProps;
|
|
4570
|
+
return {
|
|
4571
|
+
setDraggableNodeRef: setDraggableNodeRef$1,
|
|
4572
|
+
draggableClassName: draggableClassName$1,
|
|
4573
|
+
draggableProps: draggableProps$1
|
|
4574
|
+
};
|
|
4575
|
+
}, [draggableWidgetProps]);
|
|
4644
4576
|
const { onContextMenu } = useRightClickMenu({ sourceId: props.identifier.sourceId });
|
|
4645
4577
|
const showVisibilityBackground = props.widgetProps.isVisible === false && !editStore.ui.getSelectedSourceIds().includes(props.identifier.sourceId);
|
|
4646
4578
|
const handleClick = useCallback((ev) => {
|
|
@@ -4660,10 +4592,13 @@ const EditWrapper = observer(function EditWrapper$1(props) {
|
|
|
4660
4592
|
stopPropagation();
|
|
4661
4593
|
}, [props.identifier.sourceId, props.identifier.instanceId]);
|
|
4662
4594
|
const [dropTargetElem, setDropTargetElem] = useState(null);
|
|
4595
|
+
const handleRef = useCallback((el) => {
|
|
4596
|
+
setDraggableNodeRef(el);
|
|
4597
|
+
}, [setDraggableNodeRef]);
|
|
4663
4598
|
const isEmpty$1 = React.Children.count(children) === 0;
|
|
4664
4599
|
const editorProps = useMemo(() => {
|
|
4665
4600
|
const testProps = identifier.name.isAnonymous ? {} : { "data-test": `component-${identifier.name.value}` };
|
|
4666
|
-
const componentClassName = `${CSS_CLASSES.ANCHOR_NAME}`;
|
|
4601
|
+
const componentClassName = `${CSS_CLASSES.ANCHOR_NAME} ${draggableClassName}`;
|
|
4667
4602
|
const componentStyle = createAnchorNameStyle({ instanceId: props.identifier.instanceId });
|
|
4668
4603
|
return {
|
|
4669
4604
|
[INSTANCE_ID_ATTRIBUTE$1]: identifier.instanceId,
|
|
@@ -4673,18 +4608,23 @@ const EditWrapper = observer(function EditWrapper$1(props) {
|
|
|
4673
4608
|
"data-sb-selector": getEditWrapperId(props.identifier.instanceId),
|
|
4674
4609
|
onClick: handleClick,
|
|
4675
4610
|
onContextMenu,
|
|
4676
|
-
|
|
4611
|
+
ref: handleRef,
|
|
4612
|
+
...testProps,
|
|
4613
|
+
...draggableProps
|
|
4677
4614
|
};
|
|
4678
4615
|
}, [
|
|
4679
4616
|
identifier,
|
|
4617
|
+
draggableProps,
|
|
4618
|
+
draggableClassName,
|
|
4680
4619
|
handleClick,
|
|
4620
|
+
handleRef,
|
|
4681
4621
|
onContextMenu,
|
|
4682
4622
|
props.identifier.instanceId,
|
|
4683
4623
|
isEmpty$1
|
|
4684
4624
|
]);
|
|
4685
4625
|
const node = /* @__PURE__ */ jsx(ParentIdentifierProvider, {
|
|
4686
4626
|
identifier,
|
|
4687
|
-
children: /* @__PURE__ */ jsxs(
|
|
4627
|
+
children: /* @__PURE__ */ jsxs(reactive_component_default, {
|
|
4688
4628
|
Component: props.component,
|
|
4689
4629
|
identifier,
|
|
4690
4630
|
widgetProps: props.widgetProps,
|
|
@@ -4706,11 +4646,6 @@ const EditWrapper = observer(function EditWrapper$1(props) {
|
|
|
4706
4646
|
widgetProps: props.widgetProps,
|
|
4707
4647
|
children: node
|
|
4708
4648
|
}) : node;
|
|
4709
|
-
if (isDraggable) content = /* @__PURE__ */ jsx(DraggablePropsProvider, {
|
|
4710
|
-
identifier: props.identifier,
|
|
4711
|
-
disableDrag,
|
|
4712
|
-
children: content
|
|
4713
|
-
});
|
|
4714
4649
|
if (isDroppable) content = /* @__PURE__ */ jsx(droppable_widget_default, {
|
|
4715
4650
|
instanceId: props.identifier.instanceId,
|
|
4716
4651
|
dropTargetElem,
|
|
@@ -6454,11 +6389,11 @@ const propertiesDefinition$2 = {
|
|
|
6454
6389
|
})
|
|
6455
6390
|
}),
|
|
6456
6391
|
functions: Section.category(PropsPanelCategory.Functions).children({
|
|
6457
|
-
set: Prop.function(function(value) {
|
|
6392
|
+
set: Prop.function(function(_s, value) {
|
|
6458
6393
|
const widget = this;
|
|
6459
6394
|
widget.value = value;
|
|
6460
6395
|
}),
|
|
6461
|
-
reset: Prop.function(function() {
|
|
6396
|
+
reset: Prop.function(function(_s) {
|
|
6462
6397
|
const widget = this;
|
|
6463
6398
|
widget.value = widget.defaultValue;
|
|
6464
6399
|
})
|
|
@@ -6605,7 +6540,7 @@ const propertiesDefinition = {
|
|
|
6605
6540
|
}).readable()
|
|
6606
6541
|
}),
|
|
6607
6542
|
functions: Section.category("Derived").children({
|
|
6608
|
-
run: Prop.function(async function(traceHeaders) {
|
|
6543
|
+
run: Prop.function(async function(_s, traceHeaders) {
|
|
6609
6544
|
const api = this;
|
|
6610
6545
|
try {
|
|
6611
6546
|
const result = await api._suspensibleApi.run(traceHeaders);
|
|
@@ -6616,7 +6551,7 @@ const propertiesDefinition = {
|
|
|
6616
6551
|
throw error;
|
|
6617
6552
|
}
|
|
6618
6553
|
}),
|
|
6619
|
-
cancel: Prop.function(async function() {
|
|
6554
|
+
cancel: Prop.function(async function(_s) {
|
|
6620
6555
|
await this._suspensibleApi.cancel();
|
|
6621
6556
|
})
|
|
6622
6557
|
}),
|