@measured/puck 0.20.3-canary.b1a38875 → 0.21.0-canary.20aafb6a
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/{chunk-QIGVND56.mjs → chunk-MSKEXIWC.mjs} +81 -13
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +118 -50
- package/dist/index.mjs +1 -1
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +118 -50
- package/dist/no-external.mjs +1 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/{walk-tree-JdJYB16L.d.mts → walk-tree-Ctf3FZQI.d.mts} +1 -0
- package/dist/{walk-tree-JdJYB16L.d.ts → walk-tree-Ctf3FZQI.d.ts} +1 -0
- package/package.json +1 -1
|
@@ -768,7 +768,9 @@ var keyCodeMap = {
|
|
|
768
768
|
KeyW: "w",
|
|
769
769
|
KeyX: "x",
|
|
770
770
|
KeyY: "y",
|
|
771
|
-
KeyZ: "z"
|
|
771
|
+
KeyZ: "z",
|
|
772
|
+
Delete: "delete",
|
|
773
|
+
Backspace: "backspace"
|
|
772
774
|
};
|
|
773
775
|
var useHotkeyStore = create()(
|
|
774
776
|
subscribeWithSelector((set) => ({
|
|
@@ -792,8 +794,10 @@ var monitorHotkeys = (doc) => {
|
|
|
792
794
|
([key2, value]) => value === !!combo[key2]
|
|
793
795
|
);
|
|
794
796
|
if (conditionMet) {
|
|
795
|
-
e
|
|
796
|
-
|
|
797
|
+
const handled = cb(e);
|
|
798
|
+
if (handled !== false) {
|
|
799
|
+
e.preventDefault();
|
|
800
|
+
}
|
|
797
801
|
}
|
|
798
802
|
});
|
|
799
803
|
if (key !== "meta" && key !== "ctrl" && key !== "shift") {
|
|
@@ -1173,6 +1177,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
1173
1177
|
(reset) => __async(void 0, null, function* () {
|
|
1174
1178
|
var _a, _b;
|
|
1175
1179
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
1180
|
+
const metadata = appStore.getState().metadata;
|
|
1176
1181
|
const nodes = appStore.getState().state.indexes.nodes;
|
|
1177
1182
|
const node = nodes[id || "root"];
|
|
1178
1183
|
const componentData = node == null ? void 0 : node.data;
|
|
@@ -1202,6 +1207,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
1202
1207
|
changed,
|
|
1203
1208
|
fields: defaultFields2,
|
|
1204
1209
|
lastFields,
|
|
1210
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
|
|
1205
1211
|
lastData,
|
|
1206
1212
|
appState: makeStatePublic(state),
|
|
1207
1213
|
parent
|
|
@@ -6419,7 +6425,7 @@ function useGetPuck() {
|
|
|
6419
6425
|
init_react_import();
|
|
6420
6426
|
import {
|
|
6421
6427
|
createContext as createContext8,
|
|
6422
|
-
useCallback as
|
|
6428
|
+
useCallback as useCallback21,
|
|
6423
6429
|
useContext as useContext13,
|
|
6424
6430
|
useEffect as useEffect29,
|
|
6425
6431
|
useMemo as useMemo20,
|
|
@@ -7979,12 +7985,73 @@ var usePreviewModeHotkeys = () => {
|
|
|
7979
7985
|
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
7980
7986
|
};
|
|
7981
7987
|
|
|
7988
|
+
// lib/use-delete-hotkeys.ts
|
|
7989
|
+
init_react_import();
|
|
7990
|
+
import { useCallback as useCallback17 } from "react";
|
|
7991
|
+
var isElementVisible = (element) => {
|
|
7992
|
+
let current = element;
|
|
7993
|
+
while (current && current !== document.body) {
|
|
7994
|
+
const style = window.getComputedStyle(current);
|
|
7995
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
7996
|
+
return false;
|
|
7997
|
+
}
|
|
7998
|
+
current = current.parentElement;
|
|
7999
|
+
}
|
|
8000
|
+
return true;
|
|
8001
|
+
};
|
|
8002
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
8003
|
+
var _a;
|
|
8004
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
8005
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
8006
|
+
if (origin instanceof HTMLElement) {
|
|
8007
|
+
const tag = origin.tagName.toLowerCase();
|
|
8008
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
8009
|
+
if (origin.isContentEditable) return true;
|
|
8010
|
+
const role = origin.getAttribute("role");
|
|
8011
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
8012
|
+
return true;
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8015
|
+
const modal = document.querySelector(
|
|
8016
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
8017
|
+
);
|
|
8018
|
+
if (modal && isElementVisible(modal)) {
|
|
8019
|
+
return true;
|
|
8020
|
+
}
|
|
8021
|
+
return false;
|
|
8022
|
+
};
|
|
8023
|
+
var useDeleteHotkeys = () => {
|
|
8024
|
+
const appStore = useAppStoreApi();
|
|
8025
|
+
const deleteSelectedComponent = useCallback17(
|
|
8026
|
+
(e) => {
|
|
8027
|
+
var _a;
|
|
8028
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
8029
|
+
return false;
|
|
8030
|
+
}
|
|
8031
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
8032
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
8033
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
8034
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
8035
|
+
return true;
|
|
8036
|
+
dispatch({
|
|
8037
|
+
type: "remove",
|
|
8038
|
+
index: sel.index,
|
|
8039
|
+
zone: sel.zone
|
|
8040
|
+
});
|
|
8041
|
+
return true;
|
|
8042
|
+
},
|
|
8043
|
+
[appStore]
|
|
8044
|
+
);
|
|
8045
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8046
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8047
|
+
};
|
|
8048
|
+
|
|
7982
8049
|
// components/Puck/index.tsx
|
|
7983
8050
|
import fdeq from "fast-deep-equal";
|
|
7984
8051
|
|
|
7985
8052
|
// components/Puck/components/Header/index.tsx
|
|
7986
8053
|
init_react_import();
|
|
7987
|
-
import { memo as memo4, useCallback as
|
|
8054
|
+
import { memo as memo4, useCallback as useCallback18, useMemo as useMemo19, useState as useState23 } from "react";
|
|
7988
8055
|
|
|
7989
8056
|
// components/MenuBar/index.tsx
|
|
7990
8057
|
init_react_import();
|
|
@@ -8111,7 +8178,7 @@ var HeaderInner = () => {
|
|
|
8111
8178
|
const rightSideBarVisible = useAppStore(
|
|
8112
8179
|
(s) => s.state.ui.rightSideBarVisible
|
|
8113
8180
|
);
|
|
8114
|
-
const toggleSidebars =
|
|
8181
|
+
const toggleSidebars = useCallback18(
|
|
8115
8182
|
(sidebar) => {
|
|
8116
8183
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8117
8184
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8221,7 +8288,7 @@ init_react_import();
|
|
|
8221
8288
|
|
|
8222
8289
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8223
8290
|
init_react_import();
|
|
8224
|
-
import { useCallback as
|
|
8291
|
+
import { useCallback as useCallback19, useRef as useRef10 } from "react";
|
|
8225
8292
|
|
|
8226
8293
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8227
8294
|
init_react_import();
|
|
@@ -8242,7 +8309,7 @@ var ResizeHandle = ({
|
|
|
8242
8309
|
const isDragging = useRef10(false);
|
|
8243
8310
|
const startX = useRef10(0);
|
|
8244
8311
|
const startWidth = useRef10(0);
|
|
8245
|
-
const handleMouseMove =
|
|
8312
|
+
const handleMouseMove = useCallback19(
|
|
8246
8313
|
(e) => {
|
|
8247
8314
|
if (!isDragging.current) return;
|
|
8248
8315
|
const delta = e.clientX - startX.current;
|
|
@@ -8253,7 +8320,7 @@ var ResizeHandle = ({
|
|
|
8253
8320
|
},
|
|
8254
8321
|
[onResize, position]
|
|
8255
8322
|
);
|
|
8256
|
-
const handleMouseUp =
|
|
8323
|
+
const handleMouseUp = useCallback19(() => {
|
|
8257
8324
|
var _a;
|
|
8258
8325
|
if (!isDragging.current) return;
|
|
8259
8326
|
isDragging.current = false;
|
|
@@ -8269,7 +8336,7 @@ var ResizeHandle = ({
|
|
|
8269
8336
|
onResizeEnd(finalWidth);
|
|
8270
8337
|
resetAutoZoom();
|
|
8271
8338
|
}, [onResizeEnd]);
|
|
8272
|
-
const handleMouseDown =
|
|
8339
|
+
const handleMouseDown = useCallback19(
|
|
8273
8340
|
(e) => {
|
|
8274
8341
|
var _a;
|
|
8275
8342
|
isDragging.current = true;
|
|
@@ -8329,7 +8396,7 @@ var Sidebar = ({
|
|
|
8329
8396
|
|
|
8330
8397
|
// lib/use-sidebar-resize.ts
|
|
8331
8398
|
init_react_import();
|
|
8332
|
-
import { useCallback as
|
|
8399
|
+
import { useCallback as useCallback20, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
|
|
8333
8400
|
function useSidebarResize(position, dispatch) {
|
|
8334
8401
|
const [width, setWidth] = useState24(null);
|
|
8335
8402
|
const sidebarRef = useRef11(null);
|
|
@@ -8366,7 +8433,7 @@ function useSidebarResize(position, dispatch) {
|
|
|
8366
8433
|
setWidth(storeWidth);
|
|
8367
8434
|
}
|
|
8368
8435
|
}, [storeWidth]);
|
|
8369
|
-
const handleResizeEnd =
|
|
8436
|
+
const handleResizeEnd = useCallback20(
|
|
8370
8437
|
(width2) => {
|
|
8371
8438
|
dispatch({
|
|
8372
8439
|
type: "setUi",
|
|
@@ -8537,7 +8604,7 @@ function PuckProvider({ children }) {
|
|
|
8537
8604
|
);
|
|
8538
8605
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
8539
8606
|
}, [fieldTransforms, plugins]);
|
|
8540
|
-
const generateAppStore =
|
|
8607
|
+
const generateAppStore = useCallback21(
|
|
8541
8608
|
(state) => {
|
|
8542
8609
|
return {
|
|
8543
8610
|
state,
|
|
@@ -8666,6 +8733,7 @@ function PuckLayout({ children }) {
|
|
|
8666
8733
|
}, []);
|
|
8667
8734
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8668
8735
|
useMonitorHotkeys();
|
|
8736
|
+
useDeleteHotkeys();
|
|
8669
8737
|
useEffect29(() => {
|
|
8670
8738
|
if (ready && iframe.enabled) {
|
|
8671
8739
|
const frameDoc = getFrame();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-
|
|
2
|
-
export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-Ctf3FZQI.mjs';
|
|
2
|
+
export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-
|
|
2
|
-
export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-Ctf3FZQI.js';
|
|
2
|
+
export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
package/dist/index.js
CHANGED
|
@@ -1661,7 +1661,9 @@ var keyCodeMap = {
|
|
|
1661
1661
|
KeyW: "w",
|
|
1662
1662
|
KeyX: "x",
|
|
1663
1663
|
KeyY: "y",
|
|
1664
|
-
KeyZ: "z"
|
|
1664
|
+
KeyZ: "z",
|
|
1665
|
+
Delete: "delete",
|
|
1666
|
+
Backspace: "backspace"
|
|
1665
1667
|
};
|
|
1666
1668
|
var useHotkeyStore = (0, import_zustand.create)()(
|
|
1667
1669
|
(0, import_middleware.subscribeWithSelector)((set) => ({
|
|
@@ -1685,8 +1687,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1685
1687
|
([key2, value]) => value === !!combo[key2]
|
|
1686
1688
|
);
|
|
1687
1689
|
if (conditionMet) {
|
|
1688
|
-
e
|
|
1689
|
-
|
|
1690
|
+
const handled = cb(e);
|
|
1691
|
+
if (handled !== false) {
|
|
1692
|
+
e.preventDefault();
|
|
1693
|
+
}
|
|
1690
1694
|
}
|
|
1691
1695
|
});
|
|
1692
1696
|
if (key !== "meta" && key !== "ctrl" && key !== "shift") {
|
|
@@ -2079,6 +2083,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2079
2083
|
(reset) => __async(void 0, null, function* () {
|
|
2080
2084
|
var _a, _b;
|
|
2081
2085
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
2086
|
+
const metadata = appStore.getState().metadata;
|
|
2082
2087
|
const nodes = appStore.getState().state.indexes.nodes;
|
|
2083
2088
|
const node = nodes[id || "root"];
|
|
2084
2089
|
const componentData = node == null ? void 0 : node.data;
|
|
@@ -2108,6 +2113,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2108
2113
|
changed,
|
|
2109
2114
|
fields: defaultFields2,
|
|
2110
2115
|
lastFields,
|
|
2116
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
|
|
2111
2117
|
lastData,
|
|
2112
2118
|
appState: makeStatePublic(state),
|
|
2113
2119
|
parent
|
|
@@ -7046,7 +7052,7 @@ Drawer.Item = DrawerItem;
|
|
|
7046
7052
|
|
|
7047
7053
|
// components/Puck/index.tsx
|
|
7048
7054
|
init_react_import();
|
|
7049
|
-
var
|
|
7055
|
+
var import_react60 = require("react");
|
|
7050
7056
|
|
|
7051
7057
|
// components/SidebarSection/index.tsx
|
|
7052
7058
|
init_react_import();
|
|
@@ -8584,9 +8590,70 @@ var usePreviewModeHotkeys = () => {
|
|
|
8584
8590
|
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
8585
8591
|
};
|
|
8586
8592
|
|
|
8587
|
-
// lib/use-
|
|
8593
|
+
// lib/use-delete-hotkeys.ts
|
|
8588
8594
|
init_react_import();
|
|
8589
8595
|
var import_react55 = require("react");
|
|
8596
|
+
var isElementVisible = (element) => {
|
|
8597
|
+
let current = element;
|
|
8598
|
+
while (current && current !== document.body) {
|
|
8599
|
+
const style = window.getComputedStyle(current);
|
|
8600
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
8601
|
+
return false;
|
|
8602
|
+
}
|
|
8603
|
+
current = current.parentElement;
|
|
8604
|
+
}
|
|
8605
|
+
return true;
|
|
8606
|
+
};
|
|
8607
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
8608
|
+
var _a;
|
|
8609
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
8610
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
8611
|
+
if (origin instanceof HTMLElement) {
|
|
8612
|
+
const tag = origin.tagName.toLowerCase();
|
|
8613
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
8614
|
+
if (origin.isContentEditable) return true;
|
|
8615
|
+
const role = origin.getAttribute("role");
|
|
8616
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
8617
|
+
return true;
|
|
8618
|
+
}
|
|
8619
|
+
}
|
|
8620
|
+
const modal = document.querySelector(
|
|
8621
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
8622
|
+
);
|
|
8623
|
+
if (modal && isElementVisible(modal)) {
|
|
8624
|
+
return true;
|
|
8625
|
+
}
|
|
8626
|
+
return false;
|
|
8627
|
+
};
|
|
8628
|
+
var useDeleteHotkeys = () => {
|
|
8629
|
+
const appStore = useAppStoreApi();
|
|
8630
|
+
const deleteSelectedComponent = (0, import_react55.useCallback)(
|
|
8631
|
+
(e) => {
|
|
8632
|
+
var _a;
|
|
8633
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
8634
|
+
return false;
|
|
8635
|
+
}
|
|
8636
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
8637
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
8638
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
8639
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
8640
|
+
return true;
|
|
8641
|
+
dispatch({
|
|
8642
|
+
type: "remove",
|
|
8643
|
+
index: sel.index,
|
|
8644
|
+
zone: sel.zone
|
|
8645
|
+
});
|
|
8646
|
+
return true;
|
|
8647
|
+
},
|
|
8648
|
+
[appStore]
|
|
8649
|
+
);
|
|
8650
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8651
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8652
|
+
};
|
|
8653
|
+
|
|
8654
|
+
// lib/use-puck.ts
|
|
8655
|
+
init_react_import();
|
|
8656
|
+
var import_react56 = require("react");
|
|
8590
8657
|
var import_zustand6 = require("zustand");
|
|
8591
8658
|
var generateUsePuck = (store) => {
|
|
8592
8659
|
const history = {
|
|
@@ -8613,7 +8680,7 @@ var generateUsePuck = (store) => {
|
|
|
8613
8680
|
};
|
|
8614
8681
|
return storeData;
|
|
8615
8682
|
};
|
|
8616
|
-
var UsePuckStoreContext = (0,
|
|
8683
|
+
var UsePuckStoreContext = (0, import_react56.createContext)(
|
|
8617
8684
|
null
|
|
8618
8685
|
);
|
|
8619
8686
|
var convertToPickedStore = (store) => {
|
|
@@ -8627,12 +8694,12 @@ var convertToPickedStore = (store) => {
|
|
|
8627
8694
|
};
|
|
8628
8695
|
};
|
|
8629
8696
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8630
|
-
const [usePuckStore] = (0,
|
|
8697
|
+
const [usePuckStore] = (0, import_react56.useState)(
|
|
8631
8698
|
() => (0, import_zustand6.createStore)(
|
|
8632
8699
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8633
8700
|
)
|
|
8634
8701
|
);
|
|
8635
|
-
(0,
|
|
8702
|
+
(0, import_react56.useEffect)(() => {
|
|
8636
8703
|
return appStore.subscribe(
|
|
8637
8704
|
(store) => convertToPickedStore(store),
|
|
8638
8705
|
(pickedStore) => {
|
|
@@ -8644,7 +8711,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8644
8711
|
};
|
|
8645
8712
|
function createUsePuck() {
|
|
8646
8713
|
return function usePuck2(selector) {
|
|
8647
|
-
const usePuckApi = (0,
|
|
8714
|
+
const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
|
|
8648
8715
|
if (!usePuckApi) {
|
|
8649
8716
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8650
8717
|
}
|
|
@@ -8656,7 +8723,7 @@ function createUsePuck() {
|
|
|
8656
8723
|
};
|
|
8657
8724
|
}
|
|
8658
8725
|
function usePuck() {
|
|
8659
|
-
(0,
|
|
8726
|
+
(0, import_react56.useEffect)(() => {
|
|
8660
8727
|
console.warn(
|
|
8661
8728
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8662
8729
|
);
|
|
@@ -8664,7 +8731,7 @@ function usePuck() {
|
|
|
8664
8731
|
return createUsePuck()((s) => s);
|
|
8665
8732
|
}
|
|
8666
8733
|
function useGetPuck() {
|
|
8667
|
-
const usePuckApi = (0,
|
|
8734
|
+
const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
|
|
8668
8735
|
if (!usePuckApi) {
|
|
8669
8736
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8670
8737
|
}
|
|
@@ -8676,7 +8743,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8676
8743
|
|
|
8677
8744
|
// components/Puck/components/Header/index.tsx
|
|
8678
8745
|
init_react_import();
|
|
8679
|
-
var
|
|
8746
|
+
var import_react57 = require("react");
|
|
8680
8747
|
|
|
8681
8748
|
// components/MenuBar/index.tsx
|
|
8682
8749
|
init_react_import();
|
|
@@ -8758,7 +8825,7 @@ var HeaderInner = () => {
|
|
|
8758
8825
|
} = usePropsContext();
|
|
8759
8826
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8760
8827
|
const appStore = useAppStoreApi();
|
|
8761
|
-
const defaultHeaderRender = (0,
|
|
8828
|
+
const defaultHeaderRender = (0, import_react57.useMemo)(() => {
|
|
8762
8829
|
if (renderHeader) {
|
|
8763
8830
|
console.warn(
|
|
8764
8831
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8773,7 +8840,7 @@ var HeaderInner = () => {
|
|
|
8773
8840
|
}
|
|
8774
8841
|
return DefaultOverride;
|
|
8775
8842
|
}, [renderHeader]);
|
|
8776
|
-
const defaultHeaderActionsRender = (0,
|
|
8843
|
+
const defaultHeaderActionsRender = (0, import_react57.useMemo)(() => {
|
|
8777
8844
|
if (renderHeaderActions) {
|
|
8778
8845
|
console.warn(
|
|
8779
8846
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8793,7 +8860,7 @@ var HeaderInner = () => {
|
|
|
8793
8860
|
const CustomHeaderActions = useAppStore(
|
|
8794
8861
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8795
8862
|
);
|
|
8796
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8863
|
+
const [menuOpen, setMenuOpen] = (0, import_react57.useState)(false);
|
|
8797
8864
|
const rootTitle = useAppStore((s) => {
|
|
8798
8865
|
var _a, _b;
|
|
8799
8866
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8803,7 +8870,7 @@ var HeaderInner = () => {
|
|
|
8803
8870
|
const rightSideBarVisible = useAppStore(
|
|
8804
8871
|
(s) => s.state.ui.rightSideBarVisible
|
|
8805
8872
|
);
|
|
8806
|
-
const toggleSidebars = (0,
|
|
8873
|
+
const toggleSidebars = (0, import_react57.useCallback)(
|
|
8807
8874
|
(sidebar) => {
|
|
8808
8875
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8809
8876
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8906,14 +8973,14 @@ var HeaderInner = () => {
|
|
|
8906
8973
|
}
|
|
8907
8974
|
);
|
|
8908
8975
|
};
|
|
8909
|
-
var Header = (0,
|
|
8976
|
+
var Header = (0, import_react57.memo)(HeaderInner);
|
|
8910
8977
|
|
|
8911
8978
|
// components/Puck/components/Sidebar/index.tsx
|
|
8912
8979
|
init_react_import();
|
|
8913
8980
|
|
|
8914
8981
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8915
8982
|
init_react_import();
|
|
8916
|
-
var
|
|
8983
|
+
var import_react58 = require("react");
|
|
8917
8984
|
|
|
8918
8985
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8919
8986
|
init_react_import();
|
|
@@ -8930,11 +8997,11 @@ var ResizeHandle = ({
|
|
|
8930
8997
|
}) => {
|
|
8931
8998
|
const { frameRef } = useCanvasFrame();
|
|
8932
8999
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8933
|
-
const handleRef = (0,
|
|
8934
|
-
const isDragging = (0,
|
|
8935
|
-
const startX = (0,
|
|
8936
|
-
const startWidth = (0,
|
|
8937
|
-
const handleMouseMove = (0,
|
|
9000
|
+
const handleRef = (0, import_react58.useRef)(null);
|
|
9001
|
+
const isDragging = (0, import_react58.useRef)(false);
|
|
9002
|
+
const startX = (0, import_react58.useRef)(0);
|
|
9003
|
+
const startWidth = (0, import_react58.useRef)(0);
|
|
9004
|
+
const handleMouseMove = (0, import_react58.useCallback)(
|
|
8938
9005
|
(e) => {
|
|
8939
9006
|
if (!isDragging.current) return;
|
|
8940
9007
|
const delta = e.clientX - startX.current;
|
|
@@ -8945,7 +9012,7 @@ var ResizeHandle = ({
|
|
|
8945
9012
|
},
|
|
8946
9013
|
[onResize, position]
|
|
8947
9014
|
);
|
|
8948
|
-
const handleMouseUp = (0,
|
|
9015
|
+
const handleMouseUp = (0, import_react58.useCallback)(() => {
|
|
8949
9016
|
var _a;
|
|
8950
9017
|
if (!isDragging.current) return;
|
|
8951
9018
|
isDragging.current = false;
|
|
@@ -8961,7 +9028,7 @@ var ResizeHandle = ({
|
|
|
8961
9028
|
onResizeEnd(finalWidth);
|
|
8962
9029
|
resetAutoZoom();
|
|
8963
9030
|
}, [onResizeEnd]);
|
|
8964
|
-
const handleMouseDown = (0,
|
|
9031
|
+
const handleMouseDown = (0, import_react58.useCallback)(
|
|
8965
9032
|
(e) => {
|
|
8966
9033
|
var _a;
|
|
8967
9034
|
isDragging.current = true;
|
|
@@ -9021,14 +9088,14 @@ var Sidebar = ({
|
|
|
9021
9088
|
|
|
9022
9089
|
// lib/use-sidebar-resize.ts
|
|
9023
9090
|
init_react_import();
|
|
9024
|
-
var
|
|
9091
|
+
var import_react59 = require("react");
|
|
9025
9092
|
function useSidebarResize(position, dispatch) {
|
|
9026
|
-
const [width, setWidth] = (0,
|
|
9027
|
-
const sidebarRef = (0,
|
|
9093
|
+
const [width, setWidth] = (0, import_react59.useState)(null);
|
|
9094
|
+
const sidebarRef = (0, import_react59.useRef)(null);
|
|
9028
9095
|
const storeWidth = useAppStore(
|
|
9029
9096
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
9030
9097
|
);
|
|
9031
|
-
(0,
|
|
9098
|
+
(0, import_react59.useEffect)(() => {
|
|
9032
9099
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
9033
9100
|
try {
|
|
9034
9101
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
@@ -9053,12 +9120,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
9053
9120
|
}
|
|
9054
9121
|
}
|
|
9055
9122
|
}, [dispatch, position, storeWidth]);
|
|
9056
|
-
(0,
|
|
9123
|
+
(0, import_react59.useEffect)(() => {
|
|
9057
9124
|
if (storeWidth !== void 0) {
|
|
9058
9125
|
setWidth(storeWidth);
|
|
9059
9126
|
}
|
|
9060
9127
|
}, [storeWidth]);
|
|
9061
|
-
const handleResizeEnd = (0,
|
|
9128
|
+
const handleResizeEnd = (0, import_react59.useCallback)(
|
|
9062
9129
|
(width2) => {
|
|
9063
9130
|
dispatch({
|
|
9064
9131
|
type: "setUi",
|
|
@@ -9113,11 +9180,11 @@ var FieldSideBar = () => {
|
|
|
9113
9180
|
);
|
|
9114
9181
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
|
|
9115
9182
|
};
|
|
9116
|
-
var propsContext = (0,
|
|
9183
|
+
var propsContext = (0, import_react60.createContext)({});
|
|
9117
9184
|
function PropsProvider(props) {
|
|
9118
9185
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
9119
9186
|
}
|
|
9120
|
-
var usePropsContext = () => (0,
|
|
9187
|
+
var usePropsContext = () => (0, import_react60.useContext)(propsContext);
|
|
9121
9188
|
function PuckProvider({ children }) {
|
|
9122
9189
|
const {
|
|
9123
9190
|
config,
|
|
@@ -9134,14 +9201,14 @@ function PuckProvider({ children }) {
|
|
|
9134
9201
|
onAction,
|
|
9135
9202
|
fieldTransforms
|
|
9136
9203
|
} = usePropsContext();
|
|
9137
|
-
const iframe = (0,
|
|
9204
|
+
const iframe = (0, import_react60.useMemo)(
|
|
9138
9205
|
() => __spreadValues({
|
|
9139
9206
|
enabled: true,
|
|
9140
9207
|
waitForStyles: true
|
|
9141
9208
|
}, _iframe),
|
|
9142
9209
|
[_iframe]
|
|
9143
9210
|
);
|
|
9144
|
-
const [generatedAppState] = (0,
|
|
9211
|
+
const [generatedAppState] = (0, import_react60.useState)(() => {
|
|
9145
9212
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9146
9213
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
9147
9214
|
let clientUiState = {};
|
|
@@ -9201,7 +9268,7 @@ function PuckProvider({ children }) {
|
|
|
9201
9268
|
return walkAppState(newAppState, config);
|
|
9202
9269
|
});
|
|
9203
9270
|
const { appendData = true } = _initialHistory || {};
|
|
9204
|
-
const [blendedHistories] = (0,
|
|
9271
|
+
const [blendedHistories] = (0, import_react60.useState)(
|
|
9205
9272
|
[
|
|
9206
9273
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
9207
9274
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -9221,7 +9288,7 @@ function PuckProvider({ children }) {
|
|
|
9221
9288
|
overrides,
|
|
9222
9289
|
plugins
|
|
9223
9290
|
});
|
|
9224
|
-
const loadedFieldTransforms = (0,
|
|
9291
|
+
const loadedFieldTransforms = (0, import_react60.useMemo)(() => {
|
|
9225
9292
|
const _plugins = plugins || [];
|
|
9226
9293
|
const pluginFieldTransforms = _plugins.reduce(
|
|
9227
9294
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
@@ -9229,7 +9296,7 @@ function PuckProvider({ children }) {
|
|
|
9229
9296
|
);
|
|
9230
9297
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9231
9298
|
}, [fieldTransforms, plugins]);
|
|
9232
|
-
const generateAppStore = (0,
|
|
9299
|
+
const generateAppStore = (0, import_react60.useCallback)(
|
|
9233
9300
|
(state) => {
|
|
9234
9301
|
return {
|
|
9235
9302
|
state,
|
|
@@ -9255,15 +9322,15 @@ function PuckProvider({ children }) {
|
|
|
9255
9322
|
loadedFieldTransforms
|
|
9256
9323
|
]
|
|
9257
9324
|
);
|
|
9258
|
-
const [appStore] = (0,
|
|
9325
|
+
const [appStore] = (0, import_react60.useState)(
|
|
9259
9326
|
() => createAppStore(generateAppStore(initialAppState))
|
|
9260
9327
|
);
|
|
9261
|
-
(0,
|
|
9328
|
+
(0, import_react60.useEffect)(() => {
|
|
9262
9329
|
if (process.env.NODE_ENV !== "production") {
|
|
9263
9330
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
9264
9331
|
}
|
|
9265
9332
|
}, [appStore]);
|
|
9266
|
-
(0,
|
|
9333
|
+
(0, import_react60.useEffect)(() => {
|
|
9267
9334
|
const state = appStore.getState().state;
|
|
9268
9335
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
9269
9336
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -9272,8 +9339,8 @@ function PuckProvider({ children }) {
|
|
|
9272
9339
|
index: initialHistoryIndex,
|
|
9273
9340
|
initialAppState
|
|
9274
9341
|
});
|
|
9275
|
-
const previousData = (0,
|
|
9276
|
-
(0,
|
|
9342
|
+
const previousData = (0, import_react60.useRef)(null);
|
|
9343
|
+
(0, import_react60.useEffect)(() => {
|
|
9277
9344
|
appStore.subscribe(
|
|
9278
9345
|
(s) => s.state.data,
|
|
9279
9346
|
(data) => {
|
|
@@ -9287,7 +9354,7 @@ function PuckProvider({ children }) {
|
|
|
9287
9354
|
}, []);
|
|
9288
9355
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
9289
9356
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
9290
|
-
(0,
|
|
9357
|
+
(0, import_react60.useEffect)(() => {
|
|
9291
9358
|
const { resolveAndCommitData } = appStore.getState();
|
|
9292
9359
|
resolveAndCommitData();
|
|
9293
9360
|
}, []);
|
|
@@ -9299,7 +9366,7 @@ function PuckLayout({ children }) {
|
|
|
9299
9366
|
dnd,
|
|
9300
9367
|
initialHistory: _initialHistory
|
|
9301
9368
|
} = usePropsContext();
|
|
9302
|
-
const iframe = (0,
|
|
9369
|
+
const iframe = (0, import_react60.useMemo)(
|
|
9303
9370
|
() => __spreadValues({
|
|
9304
9371
|
enabled: true,
|
|
9305
9372
|
waitForStyles: true
|
|
@@ -9324,7 +9391,7 @@ function PuckLayout({ children }) {
|
|
|
9324
9391
|
sidebarRef: rightSidebarRef,
|
|
9325
9392
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9326
9393
|
} = useSidebarResize("right", dispatch);
|
|
9327
|
-
(0,
|
|
9394
|
+
(0, import_react60.useEffect)(() => {
|
|
9328
9395
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9329
9396
|
dispatch({
|
|
9330
9397
|
type: "setUi",
|
|
@@ -9348,17 +9415,18 @@ function PuckLayout({ children }) {
|
|
|
9348
9415
|
};
|
|
9349
9416
|
}, []);
|
|
9350
9417
|
const overrides = useAppStore((s) => s.overrides);
|
|
9351
|
-
const CustomPuck = (0,
|
|
9418
|
+
const CustomPuck = (0, import_react60.useMemo)(
|
|
9352
9419
|
() => overrides.puck || DefaultOverride,
|
|
9353
9420
|
[overrides]
|
|
9354
9421
|
);
|
|
9355
|
-
const [mounted, setMounted] = (0,
|
|
9356
|
-
(0,
|
|
9422
|
+
const [mounted, setMounted] = (0, import_react60.useState)(false);
|
|
9423
|
+
(0, import_react60.useEffect)(() => {
|
|
9357
9424
|
setMounted(true);
|
|
9358
9425
|
}, []);
|
|
9359
9426
|
const ready = useAppStore((s) => s.status === "READY");
|
|
9360
9427
|
useMonitorHotkeys();
|
|
9361
|
-
(
|
|
9428
|
+
useDeleteHotkeys();
|
|
9429
|
+
(0, import_react60.useEffect)(() => {
|
|
9362
9430
|
if (ready && iframe.enabled) {
|
|
9363
9431
|
const frameDoc = getFrame();
|
|
9364
9432
|
if (frameDoc) {
|
package/dist/index.mjs
CHANGED
package/dist/no-external.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
|
|
2
2
|
export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react/jsx-runtime';
|
package/dist/no-external.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
1
|
+
export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
|
|
2
2
|
export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'react/jsx-runtime';
|
package/dist/no-external.js
CHANGED
|
@@ -1661,7 +1661,9 @@ var keyCodeMap = {
|
|
|
1661
1661
|
KeyW: "w",
|
|
1662
1662
|
KeyX: "x",
|
|
1663
1663
|
KeyY: "y",
|
|
1664
|
-
KeyZ: "z"
|
|
1664
|
+
KeyZ: "z",
|
|
1665
|
+
Delete: "delete",
|
|
1666
|
+
Backspace: "backspace"
|
|
1665
1667
|
};
|
|
1666
1668
|
var useHotkeyStore = (0, import_zustand.create)()(
|
|
1667
1669
|
(0, import_middleware.subscribeWithSelector)((set) => ({
|
|
@@ -1685,8 +1687,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1685
1687
|
([key2, value]) => value === !!combo[key2]
|
|
1686
1688
|
);
|
|
1687
1689
|
if (conditionMet) {
|
|
1688
|
-
e
|
|
1689
|
-
|
|
1690
|
+
const handled = cb(e);
|
|
1691
|
+
if (handled !== false) {
|
|
1692
|
+
e.preventDefault();
|
|
1693
|
+
}
|
|
1690
1694
|
}
|
|
1691
1695
|
});
|
|
1692
1696
|
if (key !== "meta" && key !== "ctrl" && key !== "shift") {
|
|
@@ -2079,6 +2083,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2079
2083
|
(reset) => __async(void 0, null, function* () {
|
|
2080
2084
|
var _a, _b;
|
|
2081
2085
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
2086
|
+
const metadata = appStore.getState().metadata;
|
|
2082
2087
|
const nodes = appStore.getState().state.indexes.nodes;
|
|
2083
2088
|
const node = nodes[id || "root"];
|
|
2084
2089
|
const componentData = node == null ? void 0 : node.data;
|
|
@@ -2108,6 +2113,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2108
2113
|
changed,
|
|
2109
2114
|
fields: defaultFields2,
|
|
2110
2115
|
lastFields,
|
|
2116
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
|
|
2111
2117
|
lastData,
|
|
2112
2118
|
appState: makeStatePublic(state),
|
|
2113
2119
|
parent
|
|
@@ -7046,7 +7052,7 @@ Drawer.Item = DrawerItem;
|
|
|
7046
7052
|
|
|
7047
7053
|
// components/Puck/index.tsx
|
|
7048
7054
|
init_react_import();
|
|
7049
|
-
var
|
|
7055
|
+
var import_react60 = require("react");
|
|
7050
7056
|
|
|
7051
7057
|
// components/SidebarSection/index.tsx
|
|
7052
7058
|
init_react_import();
|
|
@@ -8584,9 +8590,70 @@ var usePreviewModeHotkeys = () => {
|
|
|
8584
8590
|
useHotkey({ ctrl: true, i: true }, toggleInteractive);
|
|
8585
8591
|
};
|
|
8586
8592
|
|
|
8587
|
-
// lib/use-
|
|
8593
|
+
// lib/use-delete-hotkeys.ts
|
|
8588
8594
|
init_react_import();
|
|
8589
8595
|
var import_react55 = require("react");
|
|
8596
|
+
var isElementVisible = (element) => {
|
|
8597
|
+
let current = element;
|
|
8598
|
+
while (current && current !== document.body) {
|
|
8599
|
+
const style = window.getComputedStyle(current);
|
|
8600
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
|
|
8601
|
+
return false;
|
|
8602
|
+
}
|
|
8603
|
+
current = current.parentElement;
|
|
8604
|
+
}
|
|
8605
|
+
return true;
|
|
8606
|
+
};
|
|
8607
|
+
var shouldBlockDeleteHotkey = (e) => {
|
|
8608
|
+
var _a;
|
|
8609
|
+
if (e == null ? void 0 : e.defaultPrevented) return true;
|
|
8610
|
+
const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
|
|
8611
|
+
if (origin instanceof HTMLElement) {
|
|
8612
|
+
const tag = origin.tagName.toLowerCase();
|
|
8613
|
+
if (tag === "input" || tag === "textarea" || tag === "select") return true;
|
|
8614
|
+
if (origin.isContentEditable) return true;
|
|
8615
|
+
const role = origin.getAttribute("role");
|
|
8616
|
+
if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
|
|
8617
|
+
return true;
|
|
8618
|
+
}
|
|
8619
|
+
}
|
|
8620
|
+
const modal = document.querySelector(
|
|
8621
|
+
'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
|
|
8622
|
+
);
|
|
8623
|
+
if (modal && isElementVisible(modal)) {
|
|
8624
|
+
return true;
|
|
8625
|
+
}
|
|
8626
|
+
return false;
|
|
8627
|
+
};
|
|
8628
|
+
var useDeleteHotkeys = () => {
|
|
8629
|
+
const appStore = useAppStoreApi();
|
|
8630
|
+
const deleteSelectedComponent = (0, import_react55.useCallback)(
|
|
8631
|
+
(e) => {
|
|
8632
|
+
var _a;
|
|
8633
|
+
if (shouldBlockDeleteHotkey(e)) {
|
|
8634
|
+
return false;
|
|
8635
|
+
}
|
|
8636
|
+
const { state, dispatch, permissions, selectedItem } = appStore.getState();
|
|
8637
|
+
const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
|
|
8638
|
+
if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
|
|
8639
|
+
if (!permissions.getPermissions({ item: selectedItem }).delete)
|
|
8640
|
+
return true;
|
|
8641
|
+
dispatch({
|
|
8642
|
+
type: "remove",
|
|
8643
|
+
index: sel.index,
|
|
8644
|
+
zone: sel.zone
|
|
8645
|
+
});
|
|
8646
|
+
return true;
|
|
8647
|
+
},
|
|
8648
|
+
[appStore]
|
|
8649
|
+
);
|
|
8650
|
+
useHotkey({ delete: true }, deleteSelectedComponent);
|
|
8651
|
+
useHotkey({ backspace: true }, deleteSelectedComponent);
|
|
8652
|
+
};
|
|
8653
|
+
|
|
8654
|
+
// lib/use-puck.ts
|
|
8655
|
+
init_react_import();
|
|
8656
|
+
var import_react56 = require("react");
|
|
8590
8657
|
var import_zustand6 = require("zustand");
|
|
8591
8658
|
var generateUsePuck = (store) => {
|
|
8592
8659
|
const history = {
|
|
@@ -8613,7 +8680,7 @@ var generateUsePuck = (store) => {
|
|
|
8613
8680
|
};
|
|
8614
8681
|
return storeData;
|
|
8615
8682
|
};
|
|
8616
|
-
var UsePuckStoreContext = (0,
|
|
8683
|
+
var UsePuckStoreContext = (0, import_react56.createContext)(
|
|
8617
8684
|
null
|
|
8618
8685
|
);
|
|
8619
8686
|
var convertToPickedStore = (store) => {
|
|
@@ -8627,12 +8694,12 @@ var convertToPickedStore = (store) => {
|
|
|
8627
8694
|
};
|
|
8628
8695
|
};
|
|
8629
8696
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8630
|
-
const [usePuckStore] = (0,
|
|
8697
|
+
const [usePuckStore] = (0, import_react56.useState)(
|
|
8631
8698
|
() => (0, import_zustand6.createStore)(
|
|
8632
8699
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8633
8700
|
)
|
|
8634
8701
|
);
|
|
8635
|
-
(0,
|
|
8702
|
+
(0, import_react56.useEffect)(() => {
|
|
8636
8703
|
return appStore.subscribe(
|
|
8637
8704
|
(store) => convertToPickedStore(store),
|
|
8638
8705
|
(pickedStore) => {
|
|
@@ -8644,7 +8711,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8644
8711
|
};
|
|
8645
8712
|
function createUsePuck() {
|
|
8646
8713
|
return function usePuck2(selector) {
|
|
8647
|
-
const usePuckApi = (0,
|
|
8714
|
+
const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
|
|
8648
8715
|
if (!usePuckApi) {
|
|
8649
8716
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8650
8717
|
}
|
|
@@ -8656,7 +8723,7 @@ function createUsePuck() {
|
|
|
8656
8723
|
};
|
|
8657
8724
|
}
|
|
8658
8725
|
function usePuck() {
|
|
8659
|
-
(0,
|
|
8726
|
+
(0, import_react56.useEffect)(() => {
|
|
8660
8727
|
console.warn(
|
|
8661
8728
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8662
8729
|
);
|
|
@@ -8664,7 +8731,7 @@ function usePuck() {
|
|
|
8664
8731
|
return createUsePuck()((s) => s);
|
|
8665
8732
|
}
|
|
8666
8733
|
function useGetPuck() {
|
|
8667
|
-
const usePuckApi = (0,
|
|
8734
|
+
const usePuckApi = (0, import_react56.useContext)(UsePuckStoreContext);
|
|
8668
8735
|
if (!usePuckApi) {
|
|
8669
8736
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8670
8737
|
}
|
|
@@ -8676,7 +8743,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8676
8743
|
|
|
8677
8744
|
// components/Puck/components/Header/index.tsx
|
|
8678
8745
|
init_react_import();
|
|
8679
|
-
var
|
|
8746
|
+
var import_react57 = require("react");
|
|
8680
8747
|
|
|
8681
8748
|
// components/MenuBar/index.tsx
|
|
8682
8749
|
init_react_import();
|
|
@@ -8758,7 +8825,7 @@ var HeaderInner = () => {
|
|
|
8758
8825
|
} = usePropsContext();
|
|
8759
8826
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8760
8827
|
const appStore = useAppStoreApi();
|
|
8761
|
-
const defaultHeaderRender = (0,
|
|
8828
|
+
const defaultHeaderRender = (0, import_react57.useMemo)(() => {
|
|
8762
8829
|
if (renderHeader) {
|
|
8763
8830
|
console.warn(
|
|
8764
8831
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8773,7 +8840,7 @@ var HeaderInner = () => {
|
|
|
8773
8840
|
}
|
|
8774
8841
|
return DefaultOverride;
|
|
8775
8842
|
}, [renderHeader]);
|
|
8776
|
-
const defaultHeaderActionsRender = (0,
|
|
8843
|
+
const defaultHeaderActionsRender = (0, import_react57.useMemo)(() => {
|
|
8777
8844
|
if (renderHeaderActions) {
|
|
8778
8845
|
console.warn(
|
|
8779
8846
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8793,7 +8860,7 @@ var HeaderInner = () => {
|
|
|
8793
8860
|
const CustomHeaderActions = useAppStore(
|
|
8794
8861
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8795
8862
|
);
|
|
8796
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8863
|
+
const [menuOpen, setMenuOpen] = (0, import_react57.useState)(false);
|
|
8797
8864
|
const rootTitle = useAppStore((s) => {
|
|
8798
8865
|
var _a, _b;
|
|
8799
8866
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8803,7 +8870,7 @@ var HeaderInner = () => {
|
|
|
8803
8870
|
const rightSideBarVisible = useAppStore(
|
|
8804
8871
|
(s) => s.state.ui.rightSideBarVisible
|
|
8805
8872
|
);
|
|
8806
|
-
const toggleSidebars = (0,
|
|
8873
|
+
const toggleSidebars = (0, import_react57.useCallback)(
|
|
8807
8874
|
(sidebar) => {
|
|
8808
8875
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8809
8876
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8906,14 +8973,14 @@ var HeaderInner = () => {
|
|
|
8906
8973
|
}
|
|
8907
8974
|
);
|
|
8908
8975
|
};
|
|
8909
|
-
var Header = (0,
|
|
8976
|
+
var Header = (0, import_react57.memo)(HeaderInner);
|
|
8910
8977
|
|
|
8911
8978
|
// components/Puck/components/Sidebar/index.tsx
|
|
8912
8979
|
init_react_import();
|
|
8913
8980
|
|
|
8914
8981
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
8915
8982
|
init_react_import();
|
|
8916
|
-
var
|
|
8983
|
+
var import_react58 = require("react");
|
|
8917
8984
|
|
|
8918
8985
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8919
8986
|
init_react_import();
|
|
@@ -8930,11 +8997,11 @@ var ResizeHandle = ({
|
|
|
8930
8997
|
}) => {
|
|
8931
8998
|
const { frameRef } = useCanvasFrame();
|
|
8932
8999
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8933
|
-
const handleRef = (0,
|
|
8934
|
-
const isDragging = (0,
|
|
8935
|
-
const startX = (0,
|
|
8936
|
-
const startWidth = (0,
|
|
8937
|
-
const handleMouseMove = (0,
|
|
9000
|
+
const handleRef = (0, import_react58.useRef)(null);
|
|
9001
|
+
const isDragging = (0, import_react58.useRef)(false);
|
|
9002
|
+
const startX = (0, import_react58.useRef)(0);
|
|
9003
|
+
const startWidth = (0, import_react58.useRef)(0);
|
|
9004
|
+
const handleMouseMove = (0, import_react58.useCallback)(
|
|
8938
9005
|
(e) => {
|
|
8939
9006
|
if (!isDragging.current) return;
|
|
8940
9007
|
const delta = e.clientX - startX.current;
|
|
@@ -8945,7 +9012,7 @@ var ResizeHandle = ({
|
|
|
8945
9012
|
},
|
|
8946
9013
|
[onResize, position]
|
|
8947
9014
|
);
|
|
8948
|
-
const handleMouseUp = (0,
|
|
9015
|
+
const handleMouseUp = (0, import_react58.useCallback)(() => {
|
|
8949
9016
|
var _a;
|
|
8950
9017
|
if (!isDragging.current) return;
|
|
8951
9018
|
isDragging.current = false;
|
|
@@ -8961,7 +9028,7 @@ var ResizeHandle = ({
|
|
|
8961
9028
|
onResizeEnd(finalWidth);
|
|
8962
9029
|
resetAutoZoom();
|
|
8963
9030
|
}, [onResizeEnd]);
|
|
8964
|
-
const handleMouseDown = (0,
|
|
9031
|
+
const handleMouseDown = (0, import_react58.useCallback)(
|
|
8965
9032
|
(e) => {
|
|
8966
9033
|
var _a;
|
|
8967
9034
|
isDragging.current = true;
|
|
@@ -9021,14 +9088,14 @@ var Sidebar = ({
|
|
|
9021
9088
|
|
|
9022
9089
|
// lib/use-sidebar-resize.ts
|
|
9023
9090
|
init_react_import();
|
|
9024
|
-
var
|
|
9091
|
+
var import_react59 = require("react");
|
|
9025
9092
|
function useSidebarResize(position, dispatch) {
|
|
9026
|
-
const [width, setWidth] = (0,
|
|
9027
|
-
const sidebarRef = (0,
|
|
9093
|
+
const [width, setWidth] = (0, import_react59.useState)(null);
|
|
9094
|
+
const sidebarRef = (0, import_react59.useRef)(null);
|
|
9028
9095
|
const storeWidth = useAppStore(
|
|
9029
9096
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
9030
9097
|
);
|
|
9031
|
-
(0,
|
|
9098
|
+
(0, import_react59.useEffect)(() => {
|
|
9032
9099
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
9033
9100
|
try {
|
|
9034
9101
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
@@ -9053,12 +9120,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
9053
9120
|
}
|
|
9054
9121
|
}
|
|
9055
9122
|
}, [dispatch, position, storeWidth]);
|
|
9056
|
-
(0,
|
|
9123
|
+
(0, import_react59.useEffect)(() => {
|
|
9057
9124
|
if (storeWidth !== void 0) {
|
|
9058
9125
|
setWidth(storeWidth);
|
|
9059
9126
|
}
|
|
9060
9127
|
}, [storeWidth]);
|
|
9061
|
-
const handleResizeEnd = (0,
|
|
9128
|
+
const handleResizeEnd = (0, import_react59.useCallback)(
|
|
9062
9129
|
(width2) => {
|
|
9063
9130
|
dispatch({
|
|
9064
9131
|
type: "setUi",
|
|
@@ -9113,11 +9180,11 @@ var FieldSideBar = () => {
|
|
|
9113
9180
|
);
|
|
9114
9181
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Fields, {}) });
|
|
9115
9182
|
};
|
|
9116
|
-
var propsContext = (0,
|
|
9183
|
+
var propsContext = (0, import_react60.createContext)({});
|
|
9117
9184
|
function PropsProvider(props) {
|
|
9118
9185
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
9119
9186
|
}
|
|
9120
|
-
var usePropsContext = () => (0,
|
|
9187
|
+
var usePropsContext = () => (0, import_react60.useContext)(propsContext);
|
|
9121
9188
|
function PuckProvider({ children }) {
|
|
9122
9189
|
const {
|
|
9123
9190
|
config,
|
|
@@ -9134,14 +9201,14 @@ function PuckProvider({ children }) {
|
|
|
9134
9201
|
onAction,
|
|
9135
9202
|
fieldTransforms
|
|
9136
9203
|
} = usePropsContext();
|
|
9137
|
-
const iframe = (0,
|
|
9204
|
+
const iframe = (0, import_react60.useMemo)(
|
|
9138
9205
|
() => __spreadValues({
|
|
9139
9206
|
enabled: true,
|
|
9140
9207
|
waitForStyles: true
|
|
9141
9208
|
}, _iframe),
|
|
9142
9209
|
[_iframe]
|
|
9143
9210
|
);
|
|
9144
|
-
const [generatedAppState] = (0,
|
|
9211
|
+
const [generatedAppState] = (0, import_react60.useState)(() => {
|
|
9145
9212
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9146
9213
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
9147
9214
|
let clientUiState = {};
|
|
@@ -9201,7 +9268,7 @@ function PuckProvider({ children }) {
|
|
|
9201
9268
|
return walkAppState(newAppState, config);
|
|
9202
9269
|
});
|
|
9203
9270
|
const { appendData = true } = _initialHistory || {};
|
|
9204
|
-
const [blendedHistories] = (0,
|
|
9271
|
+
const [blendedHistories] = (0, import_react60.useState)(
|
|
9205
9272
|
[
|
|
9206
9273
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
9207
9274
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -9221,7 +9288,7 @@ function PuckProvider({ children }) {
|
|
|
9221
9288
|
overrides,
|
|
9222
9289
|
plugins
|
|
9223
9290
|
});
|
|
9224
|
-
const loadedFieldTransforms = (0,
|
|
9291
|
+
const loadedFieldTransforms = (0, import_react60.useMemo)(() => {
|
|
9225
9292
|
const _plugins = plugins || [];
|
|
9226
9293
|
const pluginFieldTransforms = _plugins.reduce(
|
|
9227
9294
|
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
@@ -9229,7 +9296,7 @@ function PuckProvider({ children }) {
|
|
|
9229
9296
|
);
|
|
9230
9297
|
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
9231
9298
|
}, [fieldTransforms, plugins]);
|
|
9232
|
-
const generateAppStore = (0,
|
|
9299
|
+
const generateAppStore = (0, import_react60.useCallback)(
|
|
9233
9300
|
(state) => {
|
|
9234
9301
|
return {
|
|
9235
9302
|
state,
|
|
@@ -9255,15 +9322,15 @@ function PuckProvider({ children }) {
|
|
|
9255
9322
|
loadedFieldTransforms
|
|
9256
9323
|
]
|
|
9257
9324
|
);
|
|
9258
|
-
const [appStore] = (0,
|
|
9325
|
+
const [appStore] = (0, import_react60.useState)(
|
|
9259
9326
|
() => createAppStore(generateAppStore(initialAppState))
|
|
9260
9327
|
);
|
|
9261
|
-
(0,
|
|
9328
|
+
(0, import_react60.useEffect)(() => {
|
|
9262
9329
|
if (process.env.NODE_ENV !== "production") {
|
|
9263
9330
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
9264
9331
|
}
|
|
9265
9332
|
}, [appStore]);
|
|
9266
|
-
(0,
|
|
9333
|
+
(0, import_react60.useEffect)(() => {
|
|
9267
9334
|
const state = appStore.getState().state;
|
|
9268
9335
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
9269
9336
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -9272,8 +9339,8 @@ function PuckProvider({ children }) {
|
|
|
9272
9339
|
index: initialHistoryIndex,
|
|
9273
9340
|
initialAppState
|
|
9274
9341
|
});
|
|
9275
|
-
const previousData = (0,
|
|
9276
|
-
(0,
|
|
9342
|
+
const previousData = (0, import_react60.useRef)(null);
|
|
9343
|
+
(0, import_react60.useEffect)(() => {
|
|
9277
9344
|
appStore.subscribe(
|
|
9278
9345
|
(s) => s.state.data,
|
|
9279
9346
|
(data) => {
|
|
@@ -9287,7 +9354,7 @@ function PuckProvider({ children }) {
|
|
|
9287
9354
|
}, []);
|
|
9288
9355
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
9289
9356
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
9290
|
-
(0,
|
|
9357
|
+
(0, import_react60.useEffect)(() => {
|
|
9291
9358
|
const { resolveAndCommitData } = appStore.getState();
|
|
9292
9359
|
resolveAndCommitData();
|
|
9293
9360
|
}, []);
|
|
@@ -9299,7 +9366,7 @@ function PuckLayout({ children }) {
|
|
|
9299
9366
|
dnd,
|
|
9300
9367
|
initialHistory: _initialHistory
|
|
9301
9368
|
} = usePropsContext();
|
|
9302
|
-
const iframe = (0,
|
|
9369
|
+
const iframe = (0, import_react60.useMemo)(
|
|
9303
9370
|
() => __spreadValues({
|
|
9304
9371
|
enabled: true,
|
|
9305
9372
|
waitForStyles: true
|
|
@@ -9324,7 +9391,7 @@ function PuckLayout({ children }) {
|
|
|
9324
9391
|
sidebarRef: rightSidebarRef,
|
|
9325
9392
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9326
9393
|
} = useSidebarResize("right", dispatch);
|
|
9327
|
-
(0,
|
|
9394
|
+
(0, import_react60.useEffect)(() => {
|
|
9328
9395
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
9329
9396
|
dispatch({
|
|
9330
9397
|
type: "setUi",
|
|
@@ -9348,17 +9415,18 @@ function PuckLayout({ children }) {
|
|
|
9348
9415
|
};
|
|
9349
9416
|
}, []);
|
|
9350
9417
|
const overrides = useAppStore((s) => s.overrides);
|
|
9351
|
-
const CustomPuck = (0,
|
|
9418
|
+
const CustomPuck = (0, import_react60.useMemo)(
|
|
9352
9419
|
() => overrides.puck || DefaultOverride,
|
|
9353
9420
|
[overrides]
|
|
9354
9421
|
);
|
|
9355
|
-
const [mounted, setMounted] = (0,
|
|
9356
|
-
(0,
|
|
9422
|
+
const [mounted, setMounted] = (0, import_react60.useState)(false);
|
|
9423
|
+
(0, import_react60.useEffect)(() => {
|
|
9357
9424
|
setMounted(true);
|
|
9358
9425
|
}, []);
|
|
9359
9426
|
const ready = useAppStore((s) => s.status === "READY");
|
|
9360
9427
|
useMonitorHotkeys();
|
|
9361
|
-
(
|
|
9428
|
+
useDeleteHotkeys();
|
|
9429
|
+
(0, import_react60.useEffect)(() => {
|
|
9362
9430
|
if (ready && iframe.enabled) {
|
|
9363
9431
|
const frameDoc = getFrame();
|
|
9364
9432
|
if (frameDoc) {
|
package/dist/no-external.mjs
CHANGED
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Ctf3FZQI.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-
|
|
3
|
-
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Ctf3FZQI.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
|
@@ -212,6 +212,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
212
|
fields: Fields<FieldProps>;
|
|
213
213
|
lastFields: Fields<FieldProps>;
|
|
214
214
|
lastData: DataShape | null;
|
|
215
|
+
metadata: Metadata;
|
|
215
216
|
appState: AppState;
|
|
216
217
|
parent: ComponentData | null;
|
|
217
218
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -212,6 +212,7 @@ UserField extends BaseField = {}> = {
|
|
|
212
212
|
fields: Fields<FieldProps>;
|
|
213
213
|
lastFields: Fields<FieldProps>;
|
|
214
214
|
lastData: DataShape | null;
|
|
215
|
+
metadata: Metadata;
|
|
215
216
|
appState: AppState;
|
|
216
217
|
parent: ComponentData | null;
|
|
217
218
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
package/package.json
CHANGED