@measured/puck 0.12.1-canary.9470ff9 → 0.13.0-canary.28f24f9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-35e6eaae.d.ts → Config-ff244704.d.ts} +2 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +45 -14
- package/dist/rsc.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { D as Data, C as Config, I as ItemSelector, U as UiState, A as AppState, M as MappedItem, R as RootDataWithProps, a as DefaultRootProps, b as RootData } from './Config-
|
2
|
-
export { d as Adaptor, c as ArrayField, p as ArrayState, l as BaseData, B as BaseField, k as ComponentConfig, m as ComponentData, i as Content, f as CustomField, g as DefaultComponentProps, q as DropZone, e as ExternalField, E as ExternalFieldWithAdaptor, F as Field, h as Fields, o as ItemWithId, P as PuckComponent, j as PuckContext, n as RootDataWithoutProps, S as SelectField, T as TextField } from './Config-
|
1
|
+
import { D as Data, C as Config, I as ItemSelector, U as UiState, A as AppState, M as MappedItem, R as RootDataWithProps, a as DefaultRootProps, b as RootData } from './Config-ff244704.js';
|
2
|
+
export { d as Adaptor, c as ArrayField, p as ArrayState, l as BaseData, B as BaseField, k as ComponentConfig, m as ComponentData, i as Content, f as CustomField, g as DefaultComponentProps, q as DropZone, e as ExternalField, E as ExternalFieldWithAdaptor, F as Field, h as Fields, o as ItemWithId, P as PuckComponent, j as PuckContext, n as RootDataWithoutProps, S as SelectField, T as TextField } from './Config-ff244704.js';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
5
|
import { ReactNode, CSSProperties, SyntheticEvent, ReactElement } from 'react';
|
@@ -145,7 +145,7 @@ type Plugin = {
|
|
145
145
|
};
|
146
146
|
|
147
147
|
declare function Puck({ config, data: initialData, onChange, onPublish, plugins, renderComponentList, renderHeader, renderHeaderActions, headerTitle, headerPath, }: {
|
148
|
-
config: Config
|
148
|
+
config: Config<any, any, any>;
|
149
149
|
data: Data;
|
150
150
|
onChange?: (data: Data) => void;
|
151
151
|
onPublish: (data: Data) => void;
|
@@ -168,12 +168,12 @@ declare function Puck({ config, data: initialData, onChange, onPublish, plugins,
|
|
168
168
|
headerPath?: string;
|
169
169
|
}): react_jsx_runtime.JSX.Element;
|
170
170
|
|
171
|
-
declare function Render({ config, data }: {
|
172
|
-
config: Config
|
171
|
+
declare function Render({ config, data, }: {
|
172
|
+
config: Config<any, any, any>;
|
173
173
|
data: Data;
|
174
174
|
}): react_jsx_runtime.JSX.Element;
|
175
175
|
|
176
|
-
declare const resolveAllData: (data: Data, config: Config, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
|
176
|
+
declare const resolveAllData: (data: Data, config: Config<any, any, any>, onResolveStart?: ((item: MappedItem) => void) | undefined, onResolveEnd?: ((item: MappedItem) => void) | undefined) => Promise<{
|
177
177
|
root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
|
178
178
|
content: any[];
|
179
179
|
zones: Record<string, MappedItem[]>;
|
package/dist/index.js
CHANGED
@@ -32006,7 +32006,7 @@ var useAppContext = () => {
|
|
32006
32006
|
// components/DropZone/index.tsx
|
32007
32007
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
32008
32008
|
var getClassName3 = get_class_name_factory_default("DropZone", styles_module_default2);
|
32009
|
-
function DropZoneEdit({ zone, style }) {
|
32009
|
+
function DropZoneEdit({ zone, allow, disallow, style }) {
|
32010
32010
|
var _a;
|
32011
32011
|
const appContext2 = useAppContext();
|
32012
32012
|
const ctx = (0, import_react25.useContext)(dropZoneContext);
|
@@ -32076,6 +32076,22 @@ function DropZoneEdit({ zone, style }) {
|
|
32076
32076
|
isEnabled = draggingOverArea && hoveringOverZone;
|
32077
32077
|
}
|
32078
32078
|
}
|
32079
|
+
if (isEnabled && userIsDragging && (allow || disallow)) {
|
32080
|
+
const [_, componentType] = draggedItem.draggableId.split("::");
|
32081
|
+
if (disallow) {
|
32082
|
+
const defaultedAllow = allow || [];
|
32083
|
+
const filteredDisallow = (disallow || []).filter(
|
32084
|
+
(item) => defaultedAllow.indexOf(item) === -1
|
32085
|
+
);
|
32086
|
+
if (filteredDisallow.indexOf(componentType) !== -1) {
|
32087
|
+
isEnabled = false;
|
32088
|
+
}
|
32089
|
+
} else if (allow) {
|
32090
|
+
if (allow.indexOf(componentType) === -1) {
|
32091
|
+
isEnabled = false;
|
32092
|
+
}
|
32093
|
+
}
|
32094
|
+
}
|
32079
32095
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
32080
32096
|
const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
|
32081
32097
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
@@ -32470,8 +32486,7 @@ var ArrayField = ({
|
|
32470
32486
|
items: Array.from(value || []).map((item, idx) => {
|
32471
32487
|
return {
|
32472
32488
|
_originalIndex: idx,
|
32473
|
-
_arrayId: `${id}-${idx}
|
32474
|
-
data: item
|
32489
|
+
_arrayId: `${id}-${idx}`
|
32475
32490
|
};
|
32476
32491
|
}),
|
32477
32492
|
openId: ""
|
@@ -32502,11 +32517,14 @@ var ArrayField = ({
|
|
32502
32517
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
32503
32518
|
var _a;
|
32504
32519
|
const arrayStateItem = arrayState.items[idx];
|
32505
|
-
|
32506
|
-
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex :
|
32507
|
-
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex}
|
32508
|
-
data: item
|
32520
|
+
const newItem = {
|
32521
|
+
_originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
|
32522
|
+
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
|
32509
32523
|
};
|
32524
|
+
if (newItem._originalIndex > highestIndex) {
|
32525
|
+
highestIndex = newItem._originalIndex;
|
32526
|
+
}
|
32527
|
+
return newItem;
|
32510
32528
|
});
|
32511
32529
|
return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
|
32512
32530
|
},
|
@@ -32515,6 +32533,7 @@ var ArrayField = ({
|
|
32515
32533
|
(0, import_react27.useEffect)(() => {
|
32516
32534
|
setUi(mapArrayStateToUi(arrayState));
|
32517
32535
|
}, []);
|
32536
|
+
const [hovering, setHovering] = (0, import_react27.useState)(false);
|
32518
32537
|
if (field.type !== "array" || !field.arrayFields) {
|
32519
32538
|
return null;
|
32520
32539
|
}
|
@@ -32561,6 +32580,14 @@ var ArrayField = ({
|
|
32561
32580
|
isDraggingFrom: !!snapshot.draggingFromThisWith,
|
32562
32581
|
hasItems: Array.isArray(value) && value.length > 0
|
32563
32582
|
}),
|
32583
|
+
onMouseOver: (e) => {
|
32584
|
+
e.stopPropagation();
|
32585
|
+
setHovering(true);
|
32586
|
+
},
|
32587
|
+
onMouseOut: (e) => {
|
32588
|
+
e.stopPropagation();
|
32589
|
+
setHovering(false);
|
32590
|
+
},
|
32564
32591
|
children: [
|
32565
32592
|
localState.arrayState.items.map((item, i) => {
|
32566
32593
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
@@ -32575,7 +32602,7 @@ var ArrayField = ({
|
|
32575
32602
|
isDragging: snapshot2 == null ? void 0 : snapshot2.isDragging,
|
32576
32603
|
readOnly
|
32577
32604
|
}),
|
32578
|
-
isDragDisabled: readOnly,
|
32605
|
+
isDragDisabled: readOnly || !hovering,
|
32579
32606
|
children: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
32580
32607
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
32581
32608
|
"div",
|
@@ -32638,16 +32665,17 @@ var ArrayField = ({
|
|
32638
32665
|
{
|
32639
32666
|
name: subFieldName,
|
32640
32667
|
label: subField.label || fieldName,
|
32641
|
-
id: `${
|
32668
|
+
id: `${_arrayId}_${fieldName}`,
|
32642
32669
|
readOnly: typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName],
|
32643
32670
|
readOnlyFields,
|
32644
32671
|
field: subField,
|
32645
32672
|
value: data[fieldName],
|
32646
|
-
onChange: (val) => {
|
32673
|
+
onChange: (val, ui) => {
|
32647
32674
|
onChange(
|
32648
32675
|
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
32649
32676
|
[fieldName]: val
|
32650
|
-
}))
|
32677
|
+
})),
|
32678
|
+
ui
|
32651
32679
|
);
|
32652
32680
|
}
|
32653
32681
|
},
|
@@ -34633,10 +34661,10 @@ function Puck({
|
|
34633
34661
|
return;
|
34634
34662
|
}
|
34635
34663
|
if (droppedItem.source.droppableId.startsWith("component-list") && droppedItem.destination) {
|
34636
|
-
const [_,
|
34664
|
+
const [_, componentType] = droppedItem.draggableId.split("::");
|
34637
34665
|
dispatch({
|
34638
34666
|
type: "insert",
|
34639
|
-
componentType:
|
34667
|
+
componentType: componentType || droppedItem.draggableId,
|
34640
34668
|
destinationIndex: droppedItem.destination.index,
|
34641
34669
|
destinationZone: droppedItem.destination.droppableId
|
34642
34670
|
});
|
@@ -34951,7 +34979,10 @@ function Puck({
|
|
34951
34979
|
// components/Render/index.tsx
|
34952
34980
|
init_react_import();
|
34953
34981
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
34954
|
-
function Render({
|
34982
|
+
function Render({
|
34983
|
+
config,
|
34984
|
+
data
|
34985
|
+
}) {
|
34955
34986
|
var _a;
|
34956
34987
|
const rootProps = data.root.props || data.root;
|
34957
34988
|
const title = rootProps.title || "";
|
package/dist/rsc.d.ts
CHANGED