@measured/puck 0.17.0-canary.ccec96e → 0.17.0-canary.f71da6d

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.css CHANGED
@@ -204,27 +204,27 @@
204
204
  }
205
205
 
206
206
  /* css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css/#css-module-data */
207
- ._Input_3pq3z_1 {
207
+ ._InputWrapper_1l5m8_1 {
208
208
  color: var(--puck-color-grey-04);
209
209
  padding: 16px;
210
210
  padding-bottom: 12px;
211
211
  display: block;
212
212
  }
213
- ._Input_3pq3z_1 ._Input_3pq3z_1 {
213
+ ._InputWrapper_1l5m8_1 + ._InputWrapper_1l5m8_1 {
214
+ border-top: 1px solid var(--puck-color-grey-09);
215
+ margin-top: 8px;
216
+ }
217
+ ._Input_1l5m8_1 ._InputWrapper_1l5m8_1 {
214
218
  padding: 0px;
215
219
  }
216
- ._Input_3pq3z_1 * {
220
+ ._Input_1l5m8_1 * {
217
221
  box-sizing: border-box;
218
222
  }
219
- ._Input_3pq3z_1 + ._Input_3pq3z_1 {
220
- border-top: 1px solid var(--puck-color-grey-09);
221
- margin-top: 8px;
222
- }
223
- ._Input_3pq3z_1 ._Input_3pq3z_1 + ._Input_3pq3z_1 {
223
+ ._Input_1l5m8_1 ._InputWrapper_1l5m8_1 + ._InputWrapper_1l5m8_1 {
224
224
  border-top: 0px;
225
225
  margin-top: 12px;
226
226
  }
227
- ._Input-label_3pq3z_26 {
227
+ ._Input-label_1l5m8_26 {
228
228
  align-items: center;
229
229
  color: var(--puck-color-grey-04);
230
230
  display: flex;
@@ -232,17 +232,17 @@
232
232
  font-size: var(--puck-font-size-xxs);
233
233
  font-weight: 600;
234
234
  }
235
- ._Input-labelIcon_3pq3z_35 {
235
+ ._Input-labelIcon_1l5m8_35 {
236
236
  color: var(--puck-color-grey-07);
237
237
  display: flex;
238
238
  margin-right: 4px;
239
239
  padding-left: 4px;
240
240
  }
241
- ._Input-disabledIcon_3pq3z_42 {
241
+ ._Input-disabledIcon_1l5m8_42 {
242
242
  color: var(--puck-color-grey-05);
243
243
  margin-left: auto;
244
244
  }
245
- ._Input-input_3pq3z_47 {
245
+ ._Input-input_1l5m8_47 {
246
246
  background: var(--puck-color-white);
247
247
  border-width: 1px;
248
248
  border-style: solid;
@@ -254,7 +254,7 @@
254
254
  transition: border-color 50ms ease-in;
255
255
  width: 100%;
256
256
  }
257
- select._Input-input_3pq3z_47 {
257
+ select._Input-input_1l5m8_47 {
258
258
  appearance: none;
259
259
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23c3c3c3'><polygon points='0,0 100,0 50,50'/></svg>") no-repeat;
260
260
  background-size: 12px;
@@ -264,25 +264,25 @@ select._Input-input_3pq3z_47 {
264
264
  cursor: pointer;
265
265
  }
266
266
  @media (hover: hover) and (pointer: fine) {
267
- ._Input_3pq3z_1:has(> input):hover ._Input-input_3pq3z_47:not([readonly]),
268
- ._Input_3pq3z_1:has(> textarea):hover ._Input-input_3pq3z_47:not([readonly]) {
267
+ ._Input_1l5m8_1:has(> input):hover ._Input-input_1l5m8_47:not([readonly]),
268
+ ._Input_1l5m8_1:has(> textarea):hover ._Input-input_1l5m8_47:not([readonly]) {
269
269
  border-color: var(--puck-color-grey-05);
270
270
  transition: none;
271
271
  }
272
- ._Input_3pq3z_1:has(> select):hover ._Input-input_3pq3z_47:not([disabled]) {
272
+ ._Input_1l5m8_1:has(> select):hover ._Input-input_1l5m8_47:not([disabled]) {
273
273
  background-color: var(--puck-color-azure-12);
274
274
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%235a5a5a'><polygon points='0,0 100,0 50,50'/></svg>");
275
275
  border-color: var(--puck-color-grey-05);
276
276
  transition: none;
277
277
  }
278
278
  }
279
- ._Input-input_3pq3z_47:focus {
279
+ ._Input-input_1l5m8_47:focus {
280
280
  border-color: var(--puck-color-grey-05);
281
281
  outline: 2px solid var(--puck-color-azure-05);
282
282
  transition: none;
283
283
  }
284
- ._Input--readOnly_3pq3z_91 > ._Input-input_3pq3z_47,
285
- ._Input--readOnly_3pq3z_91 > select._Input-input_3pq3z_47 {
284
+ ._Input--readOnly_1l5m8_91 > ._Input-input_1l5m8_47,
285
+ ._Input--readOnly_1l5m8_91 > select._Input-input_1l5m8_47 {
286
286
  background-color: var(--puck-color-grey-11);
287
287
  border-color: var(--puck-color-grey-09);
288
288
  color: var(--puck-color-grey-04);
@@ -291,34 +291,34 @@ select._Input-input_3pq3z_47 {
291
291
  outline: 0;
292
292
  transition: none;
293
293
  }
294
- ._Input-radioGroupItems_3pq3z_102 {
294
+ ._Input-radioGroupItems_1l5m8_102 {
295
295
  display: flex;
296
296
  border: 1px solid var(--puck-color-grey-09);
297
297
  border-radius: 4px;
298
298
  flex-wrap: wrap;
299
299
  }
300
- ._Input-radio_3pq3z_102 {
300
+ ._Input-radio_1l5m8_102 {
301
301
  border-right: 1px solid var(--puck-color-grey-09);
302
302
  flex-grow: 1;
303
303
  }
304
- ._Input-radio_3pq3z_102:first-of-type {
304
+ ._Input-radio_1l5m8_102:first-of-type {
305
305
  border-bottom-left-radius: 4px;
306
306
  border-top-left-radius: 4px;
307
307
  }
308
- ._Input-radio_3pq3z_102:first-of-type ._Input-radioInner_3pq3z_119 {
308
+ ._Input-radio_1l5m8_102:first-of-type ._Input-radioInner_1l5m8_119 {
309
309
  border-bottom-left-radius: 3px;
310
310
  border-top-left-radius: 3px;
311
311
  }
312
- ._Input-radio_3pq3z_102:last-of-type {
312
+ ._Input-radio_1l5m8_102:last-of-type {
313
313
  border-bottom-right-radius: 4px;
314
314
  border-right: 0;
315
315
  border-top-right-radius: 4px;
316
316
  }
317
- ._Input-radio_3pq3z_102:last-of-type ._Input-radioInner_3pq3z_119 {
317
+ ._Input-radio_1l5m8_102:last-of-type ._Input-radioInner_1l5m8_119 {
318
318
  border-bottom-right-radius: 3px;
319
319
  border-top-right-radius: 3px;
320
320
  }
321
- ._Input-radioInner_3pq3z_119 {
321
+ ._Input-radioInner_1l5m8_119 {
322
322
  background-color: var(--puck-color-white);
323
323
  color: var(--puck-color-grey-04);
324
324
  cursor: pointer;
@@ -327,32 +327,32 @@ select._Input-input_3pq3z_47 {
327
327
  text-align: center;
328
328
  transition: background-color 50ms ease-in;
329
329
  }
330
- ._Input-radio_3pq3z_102:has(:focus-visible) {
330
+ ._Input-radio_1l5m8_102:has(:focus-visible) {
331
331
  outline: 2px solid var(--puck-color-azure-05);
332
332
  outline-offset: 2px;
333
333
  position: relative;
334
334
  }
335
335
  @media (hover: hover) and (pointer: fine) {
336
- ._Input-radioInner_3pq3z_119:hover {
336
+ ._Input-radioInner_1l5m8_119:hover {
337
337
  background-color: var(--puck-color-azure-12);
338
338
  transition: none;
339
339
  }
340
340
  }
341
- ._Input--readOnly_3pq3z_91 ._Input-radioInner_3pq3z_119 {
341
+ ._Input--readOnly_1l5m8_91 ._Input-radioInner_1l5m8_119 {
342
342
  background-color: var(--puck-color-white);
343
343
  color: var(--puck-color-grey-04);
344
344
  cursor: default;
345
345
  }
346
- ._Input-radio_3pq3z_102 ._Input-radioInput_3pq3z_164:checked ~ ._Input-radioInner_3pq3z_119 {
346
+ ._Input-radio_1l5m8_102 ._Input-radioInput_1l5m8_164:checked ~ ._Input-radioInner_1l5m8_119 {
347
347
  background-color: var(--puck-color-azure-11);
348
348
  color: var(--puck-color-azure-04);
349
349
  font-weight: 500;
350
350
  }
351
- ._Input--readOnly_3pq3z_91 ._Input-radioInput_3pq3z_164:checked ~ ._Input-radioInner_3pq3z_119 {
351
+ ._Input--readOnly_1l5m8_91 ._Input-radioInput_1l5m8_164:checked ~ ._Input-radioInner_1l5m8_119 {
352
352
  background-color: var(--puck-color-grey-11);
353
353
  color: var(--puck-color-grey-04);
354
354
  }
355
- ._Input-radio_3pq3z_102 ._Input-radioInput_3pq3z_164 {
355
+ ._Input-radio_1l5m8_102 ._Input-radioInput_1l5m8_164 {
356
356
  clip: rect(0 0 0 0);
357
357
  clip-path: inset(100%);
358
358
  height: 1px;
@@ -361,7 +361,7 @@ select._Input-input_3pq3z_47 {
361
361
  white-space: nowrap;
362
362
  width: 1px;
363
363
  }
364
- textarea._Input-input_3pq3z_47 {
364
+ textarea._Input-input_1l5m8_47 {
365
365
  margin-bottom: -4px;
366
366
  }
367
367
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldProps, a as Field, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-Bd3DnhYE.mjs';
2
- export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-Bd3DnhYE.mjs';
1
+ import { F as FieldProps, a as Field, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-C7aAQCY3.mjs';
2
+ export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-C7aAQCY3.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FieldProps, a as Field, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-Bd3DnhYE.js';
2
- export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-Bd3DnhYE.js';
1
+ import { F as FieldProps, a as Field, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, k as ExtractRootPropsFromConfig, l as ComponentDataMap } from './resolve-all-data-C7aAQCY3.js';
2
+ export { L as Adaptor, J as ArrayField, r as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, t as ComponentConfig, w as ComponentData, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, p as FieldRenderFunctions, Y as Fields, q as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, n as OverrideKey, s as PuckComponent, Z as PuckContext, G as RadioField, v as RootData, R as RootDataWithProps, u as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, m as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys, a4 as resolveAllData } from './resolve-all-data-C7aAQCY3.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
package/dist/index.js CHANGED
@@ -276,7 +276,7 @@ init_react_import();
276
276
 
277
277
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
278
278
  init_react_import();
279
- var styles_module_default2 = { "Input": "_Input_3pq3z_1", "Input-label": "_Input-label_3pq3z_26", "Input-labelIcon": "_Input-labelIcon_3pq3z_35", "Input-disabledIcon": "_Input-disabledIcon_3pq3z_42", "Input-input": "_Input-input_3pq3z_47", "Input--readOnly": "_Input--readOnly_3pq3z_91", "Input-radioGroupItems": "_Input-radioGroupItems_3pq3z_102", "Input-radio": "_Input-radio_3pq3z_102", "Input-radioInner": "_Input-radioInner_3pq3z_119", "Input-radioInput": "_Input-radioInput_3pq3z_164" };
279
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
280
280
 
281
281
  // components/AutoField/index.tsx
282
282
  var import_react13 = require("react");
@@ -1071,7 +1071,8 @@ var defaultAppState = {
1071
1071
  },
1072
1072
  options: [],
1073
1073
  controlsVisible: true
1074
- }
1074
+ },
1075
+ field: { focus: null }
1075
1076
  }
1076
1077
  };
1077
1078
  var defaultContext = {
@@ -1415,11 +1416,13 @@ var ArrayField = ({
1415
1416
  event.source.index,
1416
1417
  (_b = event.destination) == null ? void 0 : _b.index
1417
1418
  );
1418
- onChange(newValue, {
1419
+ const newUi = {
1419
1420
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
1420
1421
  [id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
1421
1422
  })
1422
- });
1423
+ };
1424
+ setUi(newUi, false);
1425
+ onChange(newValue, newUi);
1423
1426
  setLocalState({
1424
1427
  value: newValue,
1425
1428
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
@@ -1485,32 +1488,60 @@ var ArrayField = ({
1485
1488
  children: [
1486
1489
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1487
1490
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
1488
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1489
- IconButton,
1490
- {
1491
- type: "button",
1492
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1493
- onClick: (e) => {
1494
- e.stopPropagation();
1495
- const existingValue = [
1496
- ...value || []
1497
- ];
1498
- const existingItems = [
1499
- ...arrayState.items || []
1500
- ];
1501
- existingValue.splice(i, 1);
1502
- existingItems.splice(i, 1);
1503
- onChange(
1504
- existingValue,
1505
- mapArrayStateToUi({
1506
- items: existingItems
1507
- })
1508
- );
1509
- },
1510
- title: "Delete",
1511
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
1512
- }
1513
- ) }) }),
1491
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("actions"), children: [
1492
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1493
+ IconButton,
1494
+ {
1495
+ type: "button",
1496
+ disabled: !!addDisabled,
1497
+ onClick: (e) => {
1498
+ e.stopPropagation();
1499
+ const existingValue = [
1500
+ ...value || []
1501
+ ];
1502
+ existingValue.splice(
1503
+ i,
1504
+ 0,
1505
+ existingValue[i]
1506
+ );
1507
+ onChange(
1508
+ existingValue,
1509
+ mapArrayStateToUi(
1510
+ regenerateArrayState(existingValue)
1511
+ )
1512
+ );
1513
+ },
1514
+ title: "Duplicate",
1515
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Copy, { size: 16 })
1516
+ }
1517
+ ) }),
1518
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1519
+ IconButton,
1520
+ {
1521
+ type: "button",
1522
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1523
+ onClick: (e) => {
1524
+ e.stopPropagation();
1525
+ const existingValue = [
1526
+ ...value || []
1527
+ ];
1528
+ const existingItems = [
1529
+ ...arrayState.items || []
1530
+ ];
1531
+ existingValue.splice(i, 1);
1532
+ existingItems.splice(i, 1);
1533
+ onChange(
1534
+ existingValue,
1535
+ mapArrayStateToUi({
1536
+ items: existingItems
1537
+ })
1538
+ );
1539
+ },
1540
+ title: "Delete",
1541
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
1542
+ }
1543
+ ) })
1544
+ ] }),
1514
1545
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
1515
1546
  ] })
1516
1547
  ]
@@ -2241,6 +2272,7 @@ var useSafeId = () => {
2241
2272
  // components/AutoField/index.tsx
2242
2273
  var import_jsx_runtime20 = require("react/jsx-runtime");
2243
2274
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2275
+ var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2244
2276
  var FieldLabel = ({
2245
2277
  children,
2246
2278
  icon,
@@ -2288,7 +2320,7 @@ var FieldLabelInternal2 = ({
2288
2320
  };
2289
2321
  function AutoFieldInternal(props) {
2290
2322
  var _a, _b, _c, _d, _e, _f, _g, _h;
2291
- const { overrides } = useAppContext();
2323
+ const { dispatch, overrides } = useAppContext();
2292
2324
  const { id, Label = FieldLabelInternal2 } = props;
2293
2325
  const field = props.field;
2294
2326
  const label = field.label;
@@ -2320,23 +2352,45 @@ function AutoFieldInternal(props) {
2320
2352
  Label,
2321
2353
  id: resolvedId
2322
2354
  });
2355
+ const onFocus = (0, import_react13.useCallback)(
2356
+ (e) => {
2357
+ if (mergedProps.name && e.target.nodeName === "INPUT") {
2358
+ e.stopPropagation();
2359
+ dispatch({
2360
+ type: "setUi",
2361
+ ui: {
2362
+ field: { focus: mergedProps.name }
2363
+ }
2364
+ });
2365
+ }
2366
+ },
2367
+ [mergedProps.name]
2368
+ );
2369
+ const onBlur = (0, import_react13.useCallback)((e) => {
2370
+ if ("name" in e.target) {
2371
+ dispatch({
2372
+ type: "setUi",
2373
+ ui: {
2374
+ field: { focus: null }
2375
+ }
2376
+ });
2377
+ }
2378
+ }, []);
2323
2379
  if (field.type === "custom") {
2324
2380
  if (!field.render) {
2325
2381
  return null;
2326
2382
  }
2327
2383
  const CustomField = field.render;
2328
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) });
2384
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
2329
2385
  }
2330
2386
  const children = defaultFields[field.type](mergedProps);
2331
2387
  const Render2 = render[field.type];
2332
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
2388
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children })) });
2333
2389
  }
2334
- var RECENT_CHANGE_TIMEOUT = 200;
2335
2390
  function AutoFieldPrivate(props) {
2391
+ const { state } = useAppContext();
2336
2392
  const { value, onChange } = props;
2337
2393
  const [localValue, setLocalValue] = (0, import_react13.useState)(value);
2338
- const [recentlyChanged, setRecentlyChanged] = (0, import_react13.useState)(false);
2339
- const timeoutRef = (0, import_react13.useRef)();
2340
2394
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2341
2395
  (val, ui) => {
2342
2396
  onChange(val, ui);
@@ -2346,15 +2400,10 @@ function AutoFieldPrivate(props) {
2346
2400
  );
2347
2401
  const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
2348
2402
  setLocalValue(val);
2349
- setRecentlyChanged(true);
2350
- clearTimeout(timeoutRef.current);
2351
- timeoutRef.current = setTimeout(() => {
2352
- setRecentlyChanged(false);
2353
- }, RECENT_CHANGE_TIMEOUT);
2354
2403
  onChangeDb(val, ui);
2355
2404
  }, []);
2356
2405
  (0, import_react13.useEffect)(() => {
2357
- if (!recentlyChanged) {
2406
+ if (state.ui.field.focus !== props.name) {
2358
2407
  setLocalValue(value);
2359
2408
  }
2360
2409
  }, [value]);
@@ -3079,7 +3128,7 @@ function DropZone(props) {
3079
3128
 
3080
3129
  // components/Puck/index.tsx
3081
3130
  init_react_import();
3082
- var import_react32 = require("react");
3131
+ var import_react33 = require("react");
3083
3132
 
3084
3133
  // lib/use-placeholder-style.ts
3085
3134
  init_react_import();
@@ -3686,7 +3735,23 @@ init_react_import();
3686
3735
  var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
3687
3736
 
3688
3737
  // components/Puck/components/Fields/index.tsx
3738
+ var import_react22 = require("react");
3739
+
3740
+ // lib/use-parent.ts
3741
+ init_react_import();
3689
3742
  var import_react21 = require("react");
3743
+ var useParent = (itemSelector) => {
3744
+ var _a;
3745
+ const { selectedItem, state } = useAppContext();
3746
+ const { pathData } = (0, import_react21.useContext)(dropZoneContext) || {};
3747
+ const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
3748
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
3749
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
3750
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
3751
+ return parent || null;
3752
+ };
3753
+
3754
+ // components/Puck/components/Fields/index.tsx
3690
3755
  var import_jsx_runtime27 = require("react/jsx-runtime");
3691
3756
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
3692
3757
  var defaultPageFields = {
@@ -3700,23 +3765,24 @@ var DefaultFields = ({
3700
3765
  var useResolvedFields = () => {
3701
3766
  var _a, _b;
3702
3767
  const { selectedItem, state, config } = useAppContext();
3768
+ const parent = useParent();
3703
3769
  const { data } = state;
3704
3770
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
3705
3771
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
3706
- const defaultFields = (0, import_react21.useMemo)(
3772
+ const defaultFields = (0, import_react22.useMemo)(
3707
3773
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
3708
3774
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
3709
3775
  );
3710
3776
  const rootProps = data.root.props || data.root;
3711
- const [lastSelectedData, setLastSelectedData] = (0, import_react21.useState)({});
3712
- const [resolvedFields, setResolvedFields] = (0, import_react21.useState)(defaultFields);
3713
- const [fieldsLoading, setFieldsLoading] = (0, import_react21.useState)(false);
3777
+ const [lastSelectedData, setLastSelectedData] = (0, import_react22.useState)({});
3778
+ const [resolvedFields, setResolvedFields] = (0, import_react22.useState)(defaultFields);
3779
+ const [fieldsLoading, setFieldsLoading] = (0, import_react22.useState)(false);
3714
3780
  const defaultResolveFields = (_componentData, _params) => defaultFields;
3715
3781
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
3716
3782
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
3717
3783
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
3718
3784
  const hasResolver = hasComponentResolver || hasRootResolver;
3719
- const resolveFields = (0, import_react21.useCallback)(
3785
+ const resolveFields = (0, import_react22.useCallback)(
3720
3786
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
3721
3787
  var _a2;
3722
3788
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -3730,7 +3796,8 @@ var useResolvedFields = () => {
3730
3796
  fields,
3731
3797
  lastFields: resolvedFields,
3732
3798
  lastData,
3733
- appState: state
3799
+ appState: state,
3800
+ parent
3734
3801
  }
3735
3802
  );
3736
3803
  }
@@ -3740,7 +3807,8 @@ var useResolvedFields = () => {
3740
3807
  fields,
3741
3808
  lastFields: resolvedFields,
3742
3809
  lastData,
3743
- appState: state
3810
+ appState: state,
3811
+ parent
3744
3812
  });
3745
3813
  }
3746
3814
  return defaultResolveFields(componentData, {
@@ -3752,7 +3820,7 @@ var useResolvedFields = () => {
3752
3820
  }),
3753
3821
  [data, config, componentData, selectedItem, resolvedFields, state]
3754
3822
  );
3755
- (0, import_react21.useEffect)(() => {
3823
+ (0, import_react22.useEffect)(() => {
3756
3824
  if (hasResolver) {
3757
3825
  setFieldsLoading(true);
3758
3826
  resolveFields(defaultFields).then((fields) => {
@@ -3762,7 +3830,7 @@ var useResolvedFields = () => {
3762
3830
  } else {
3763
3831
  setResolvedFields(defaultFields);
3764
3832
  }
3765
- }, [data, defaultFields, state.ui.itemSelector, hasResolver]);
3833
+ }, [data, defaultFields, selectedItem, hasResolver]);
3766
3834
  return [resolvedFields, fieldsLoading];
3767
3835
  };
3768
3836
  var Fields = () => {
@@ -3783,7 +3851,7 @@ var Fields = () => {
3783
3851
  const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
3784
3852
  const isLoading = fieldsResolving || componentResolving;
3785
3853
  const rootProps = data.root.props || data.root;
3786
- const Wrapper = (0, import_react21.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3854
+ const Wrapper = (0, import_react22.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3787
3855
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3788
3856
  "form",
3789
3857
  {
@@ -3904,7 +3972,7 @@ init_react_import();
3904
3972
 
3905
3973
  // lib/use-component-list.tsx
3906
3974
  init_react_import();
3907
- var import_react22 = require("react");
3975
+ var import_react23 = require("react");
3908
3976
 
3909
3977
  // components/ComponentList/index.tsx
3910
3978
  init_react_import();
@@ -3982,8 +4050,8 @@ ComponentList.Item = ComponentListItem;
3982
4050
  // lib/use-component-list.tsx
3983
4051
  var import_jsx_runtime29 = require("react/jsx-runtime");
3984
4052
  var useComponentList = (config, ui) => {
3985
- const [componentList, setComponentList] = (0, import_react22.useState)();
3986
- (0, import_react22.useEffect)(() => {
4053
+ const [componentList, setComponentList] = (0, import_react23.useState)();
4054
+ (0, import_react23.useEffect)(() => {
3987
4055
  var _a, _b, _c;
3988
4056
  if (Object.keys(ui.componentList).length > 0) {
3989
4057
  const matchedComponents = [];
@@ -4052,22 +4120,22 @@ var useComponentList = (config, ui) => {
4052
4120
  };
4053
4121
 
4054
4122
  // components/Puck/components/Components/index.tsx
4055
- var import_react23 = require("react");
4123
+ var import_react24 = require("react");
4056
4124
  var import_jsx_runtime30 = require("react/jsx-runtime");
4057
4125
  var Components = () => {
4058
4126
  const { config, state, overrides } = useAppContext();
4059
4127
  const componentList = useComponentList(config, state.ui);
4060
- const Wrapper = (0, import_react23.useMemo)(() => overrides.components || "div", [overrides]);
4128
+ const Wrapper = (0, import_react24.useMemo)(() => overrides.components || "div", [overrides]);
4061
4129
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
4062
4130
  };
4063
4131
 
4064
4132
  // components/Puck/components/Preview/index.tsx
4065
4133
  init_react_import();
4066
- var import_react25 = require("react");
4134
+ var import_react26 = require("react");
4067
4135
 
4068
4136
  // components/AutoFrame/index.tsx
4069
4137
  init_react_import();
4070
- var import_react24 = require("react");
4138
+ var import_react25 = require("react");
4071
4139
  var import_object_hash = __toESM(require("object-hash"));
4072
4140
  var import_react_dom2 = require("react-dom");
4073
4141
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -4113,7 +4181,7 @@ var CopyHostStyles = ({
4113
4181
  onStylesLoaded = () => null
4114
4182
  }) => {
4115
4183
  const { document: doc, window: win } = useFrame();
4116
- (0, import_react24.useEffect)(() => {
4184
+ (0, import_react25.useEffect)(() => {
4117
4185
  if (!win || !doc) {
4118
4186
  return () => {
4119
4187
  };
@@ -4272,8 +4340,8 @@ var CopyHostStyles = ({
4272
4340
  }, []);
4273
4341
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
4274
4342
  };
4275
- var autoFrameContext = (0, import_react24.createContext)({});
4276
- var useFrame = () => (0, import_react24.useContext)(autoFrameContext);
4343
+ var autoFrameContext = (0, import_react25.createContext)({});
4344
+ var useFrame = () => (0, import_react25.useContext)(autoFrameContext);
4277
4345
  function AutoFrame(_a) {
4278
4346
  var _b = _a, {
4279
4347
  children,
@@ -4288,11 +4356,11 @@ function AutoFrame(_a) {
4288
4356
  "id",
4289
4357
  "onStylesLoaded"
4290
4358
  ]);
4291
- const [loaded, setLoaded] = (0, import_react24.useState)(false);
4292
- const [ctx, setCtx] = (0, import_react24.useState)({});
4293
- const ref = (0, import_react24.useRef)(null);
4294
- const [mountTarget, setMountTarget] = (0, import_react24.useState)();
4295
- (0, import_react24.useEffect)(() => {
4359
+ const [loaded, setLoaded] = (0, import_react25.useState)(false);
4360
+ const [ctx, setCtx] = (0, import_react25.useState)({});
4361
+ const ref = (0, import_react25.useRef)(null);
4362
+ const [mountTarget, setMountTarget] = (0, import_react25.useState)();
4363
+ (0, import_react25.useEffect)(() => {
4296
4364
  var _a2;
4297
4365
  if (ref.current) {
4298
4366
  setCtx({
@@ -4328,7 +4396,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
4328
4396
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
4329
4397
  var Preview = ({ id = "puck-preview" }) => {
4330
4398
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
4331
- const Page = (0, import_react25.useCallback)(
4399
+ const Page = (0, import_react26.useCallback)(
4332
4400
  (pageProps) => {
4333
4401
  var _a, _b;
4334
4402
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -4337,7 +4405,7 @@ var Preview = ({ id = "puck-preview" }) => {
4337
4405
  },
4338
4406
  [config.root]
4339
4407
  );
4340
- const Frame = (0, import_react25.useMemo)(() => overrides.iframe, [overrides]);
4408
+ const Frame = (0, import_react26.useMemo)(() => overrides.iframe, [overrides]);
4341
4409
  const rootProps = state.data.root.props || state.data.root;
4342
4410
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4343
4411
  "div",
@@ -4426,7 +4494,7 @@ var scrollIntoView = (el) => {
4426
4494
  };
4427
4495
 
4428
4496
  // components/LayerTree/index.tsx
4429
- var import_react26 = require("react");
4497
+ var import_react27 = require("react");
4430
4498
 
4431
4499
  // lib/is-child-of-zone.ts
4432
4500
  init_react_import();
@@ -4453,7 +4521,7 @@ var LayerTree = ({
4453
4521
  label
4454
4522
  }) => {
4455
4523
  const zones = data.zones || {};
4456
- const ctx = (0, import_react26.useContext)(dropZoneContext);
4524
+ const ctx = (0, import_react27.useContext)(dropZoneContext);
4457
4525
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4458
4526
  label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
4459
4527
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
@@ -4559,13 +4627,13 @@ var LayerTree = ({
4559
4627
  };
4560
4628
 
4561
4629
  // components/Puck/components/Outline/index.tsx
4562
- var import_react27 = require("react");
4630
+ var import_react28 = require("react");
4563
4631
  var import_jsx_runtime34 = require("react/jsx-runtime");
4564
4632
  var Outline = () => {
4565
4633
  const { dispatch, state, overrides, config } = useAppContext();
4566
4634
  const { data, ui } = state;
4567
4635
  const { itemSelector } = ui;
4568
- const setItemSelector = (0, import_react27.useCallback)(
4636
+ const setItemSelector = (0, import_react28.useCallback)(
4569
4637
  (newItemSelector) => {
4570
4638
  dispatch({
4571
4639
  type: "setUi",
@@ -4574,7 +4642,7 @@ var Outline = () => {
4574
4642
  },
4575
4643
  []
4576
4644
  );
4577
- const Wrapper = (0, import_react27.useMemo)(() => overrides.outline || "div", [overrides]);
4645
+ const Wrapper = (0, import_react28.useMemo)(() => overrides.outline || "div", [overrides]);
4578
4646
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
4579
4647
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4580
4648
  LayerTree,
@@ -4663,19 +4731,19 @@ function usePuckHistory({
4663
4731
 
4664
4732
  // lib/use-history-store.ts
4665
4733
  init_react_import();
4666
- var import_react28 = require("react");
4734
+ var import_react29 = require("react");
4667
4735
  var import_use_debounce3 = require("use-debounce");
4668
4736
  var EMPTY_HISTORY_INDEX = 0;
4669
4737
  function useHistoryStore(initialHistory) {
4670
4738
  var _a, _b;
4671
- const [histories, setHistories] = (0, import_react28.useState)(
4739
+ const [histories, setHistories] = (0, import_react29.useState)(
4672
4740
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
4673
4741
  );
4674
4742
  const updateHistories = (histories2) => {
4675
4743
  setHistories(histories2);
4676
4744
  setIndex(histories2.length - 1);
4677
4745
  };
4678
- const [index, setIndex] = (0, import_react28.useState)(
4746
+ const [index, setIndex] = (0, import_react29.useState)(
4679
4747
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
4680
4748
  );
4681
4749
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -4835,11 +4903,11 @@ var getBox = function getBox2(el) {
4835
4903
  };
4836
4904
 
4837
4905
  // components/Puck/components/Canvas/index.tsx
4838
- var import_react30 = require("react");
4906
+ var import_react31 = require("react");
4839
4907
 
4840
4908
  // components/ViewportControls/index.tsx
4841
4909
  init_react_import();
4842
- var import_react29 = require("react");
4910
+ var import_react30 = require("react");
4843
4911
 
4844
4912
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
4845
4913
  init_react_import();
@@ -4862,8 +4930,8 @@ var ViewportButton = ({
4862
4930
  onClick
4863
4931
  }) => {
4864
4932
  const { state } = useAppContext();
4865
- const [isActive, setIsActive] = (0, import_react29.useState)(false);
4866
- (0, import_react29.useEffect)(() => {
4933
+ const [isActive, setIsActive] = (0, import_react30.useState)(false);
4934
+ (0, import_react30.useEffect)(() => {
4867
4935
  setIsActive(width === state.ui.viewports.current.width);
4868
4936
  }, [width, state.ui.viewports.current.width]);
4869
4937
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
@@ -4899,7 +4967,7 @@ var ViewportControls = ({
4899
4967
  const defaultsContainAutoZoom = defaultZoomOptions.find(
4900
4968
  (option) => option.value === autoZoom
4901
4969
  );
4902
- const zoomOptions = (0, import_react29.useMemo)(
4970
+ const zoomOptions = (0, import_react30.useMemo)(
4903
4971
  () => [
4904
4972
  ...defaultZoomOptions,
4905
4973
  ...defaultsContainAutoZoom ? [] : [
@@ -5022,17 +5090,17 @@ var Canvas = () => {
5022
5090
  const { status, iframe } = useAppContext();
5023
5091
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
5024
5092
  const { ui } = state;
5025
- const frameRef = (0, import_react30.useRef)(null);
5026
- const [showTransition, setShowTransition] = (0, import_react30.useState)(false);
5027
- const defaultRender = (0, import_react30.useMemo)(() => {
5093
+ const frameRef = (0, import_react31.useRef)(null);
5094
+ const [showTransition, setShowTransition] = (0, import_react31.useState)(false);
5095
+ const defaultRender = (0, import_react31.useMemo)(() => {
5028
5096
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
5029
5097
  return PuckDefault;
5030
5098
  }, []);
5031
- const CustomPreview = (0, import_react30.useMemo)(
5099
+ const CustomPreview = (0, import_react31.useMemo)(
5032
5100
  () => overrides.preview || defaultRender,
5033
5101
  [overrides]
5034
5102
  );
5035
- const getFrameDimensions = (0, import_react30.useCallback)(() => {
5103
+ const getFrameDimensions = (0, import_react31.useCallback)(() => {
5036
5104
  if (frameRef.current) {
5037
5105
  const frame = frameRef.current;
5038
5106
  const box = getBox(frame);
@@ -5040,7 +5108,7 @@ var Canvas = () => {
5040
5108
  }
5041
5109
  return { width: 0, height: 0 };
5042
5110
  }, [frameRef]);
5043
- const resetAutoZoom = (0, import_react30.useCallback)(
5111
+ const resetAutoZoom = (0, import_react31.useCallback)(
5044
5112
  (ui2 = state.ui) => {
5045
5113
  if (frameRef.current) {
5046
5114
  setZoomConfig(
@@ -5050,11 +5118,11 @@ var Canvas = () => {
5050
5118
  },
5051
5119
  [frameRef, zoomConfig, state.ui]
5052
5120
  );
5053
- (0, import_react30.useEffect)(() => {
5121
+ (0, import_react31.useEffect)(() => {
5054
5122
  setShowTransition(false);
5055
5123
  resetAutoZoom();
5056
5124
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
5057
- (0, import_react30.useEffect)(() => {
5125
+ (0, import_react31.useEffect)(() => {
5058
5126
  const { height: frameHeight } = getFrameDimensions();
5059
5127
  if (ui.viewports.current.height === "auto") {
5060
5128
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -5062,13 +5130,13 @@ var Canvas = () => {
5062
5130
  }));
5063
5131
  }
5064
5132
  }, [zoomConfig.zoom]);
5065
- (0, import_react30.useEffect)(() => {
5133
+ (0, import_react31.useEffect)(() => {
5066
5134
  if (ZOOM_ON_CHANGE) {
5067
5135
  setShowTransition(true);
5068
5136
  resetAutoZoom(ui);
5069
5137
  }
5070
5138
  }, [ui.viewports.current.width]);
5071
- (0, import_react30.useEffect)(() => {
5139
+ (0, import_react31.useEffect)(() => {
5072
5140
  const observer = new ResizeObserver(() => {
5073
5141
  setShowTransition(false);
5074
5142
  resetAutoZoom();
@@ -5080,8 +5148,8 @@ var Canvas = () => {
5080
5148
  observer.disconnect();
5081
5149
  };
5082
5150
  }, []);
5083
- const [showLoader, setShowLoader] = (0, import_react30.useState)(false);
5084
- (0, import_react30.useEffect)(() => {
5151
+ const [showLoader, setShowLoader] = (0, import_react31.useState)(false);
5152
+ (0, import_react31.useEffect)(() => {
5085
5153
  setTimeout(() => {
5086
5154
  setShowLoader(true);
5087
5155
  }, 500);
@@ -5184,7 +5252,7 @@ var insertComponent = (componentType, zone, index, {
5184
5252
 
5185
5253
  // lib/use-loaded-overrides.ts
5186
5254
  init_react_import();
5187
- var import_react31 = require("react");
5255
+ var import_react32 = require("react");
5188
5256
 
5189
5257
  // lib/load-overrides.ts
5190
5258
  init_react_import();
@@ -5223,7 +5291,7 @@ var useLoadedOverrides = ({
5223
5291
  overrides,
5224
5292
  plugins
5225
5293
  }) => {
5226
- return (0, import_react31.useMemo)(() => {
5294
+ return (0, import_react32.useMemo)(() => {
5227
5295
  return loadOverrides({ overrides, plugins });
5228
5296
  }, [plugins, overrides]);
5229
5297
  };
@@ -5262,7 +5330,7 @@ function Puck({
5262
5330
  enabled: true,
5263
5331
  waitForStyles: true
5264
5332
  }, _iframe);
5265
- const [generatedAppState] = (0, import_react32.useState)(() => {
5333
+ const [generatedAppState] = (0, import_react33.useState)(() => {
5266
5334
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
5267
5335
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
5268
5336
  let clientUiState = {};
@@ -5334,22 +5402,22 @@ function Puck({
5334
5402
  histories,
5335
5403
  index: initialHistoryIndex
5336
5404
  });
5337
- const [reducer] = (0, import_react32.useState)(
5405
+ const [reducer] = (0, import_react33.useState)(
5338
5406
  () => createReducer({
5339
5407
  config,
5340
5408
  record: historyStore.record,
5341
5409
  onAction
5342
5410
  })
5343
5411
  );
5344
- const [appState, dispatch] = (0, import_react32.useReducer)(
5412
+ const [appState, dispatch] = (0, import_react33.useReducer)(
5345
5413
  reducer,
5346
5414
  flushZones(initialAppState)
5347
5415
  );
5348
5416
  const { data, ui } = appState;
5349
5417
  const history = usePuckHistory({ dispatch, initialAppState, historyStore });
5350
- const [menuOpen, setMenuOpen] = (0, import_react32.useState)(false);
5418
+ const [menuOpen, setMenuOpen] = (0, import_react33.useState)(false);
5351
5419
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
5352
- const setItemSelector = (0, import_react32.useCallback)(
5420
+ const setItemSelector = (0, import_react33.useCallback)(
5353
5421
  (newItemSelector) => {
5354
5422
  if (newItemSelector === itemSelector) return;
5355
5423
  dispatch({
@@ -5361,13 +5429,13 @@ function Puck({
5361
5429
  [itemSelector]
5362
5430
  );
5363
5431
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
5364
- (0, import_react32.useEffect)(() => {
5432
+ (0, import_react33.useEffect)(() => {
5365
5433
  if (onChange) onChange(data);
5366
5434
  }, [data]);
5367
5435
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
5368
- const [draggedItem, setDraggedItem] = (0, import_react32.useState)();
5436
+ const [draggedItem, setDraggedItem] = (0, import_react33.useState)();
5369
5437
  const rootProps = data.root.props || data.root;
5370
- const toggleSidebars = (0, import_react32.useCallback)(
5438
+ const toggleSidebars = (0, import_react33.useCallback)(
5371
5439
  (sidebar) => {
5372
5440
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
5373
5441
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -5381,7 +5449,7 @@ function Puck({
5381
5449
  },
5382
5450
  [dispatch, leftSideBarVisible, rightSideBarVisible]
5383
5451
  );
5384
- (0, import_react32.useEffect)(() => {
5452
+ (0, import_react33.useEffect)(() => {
5385
5453
  if (!window.matchMedia("(min-width: 638px)").matches) {
5386
5454
  dispatch({
5387
5455
  type: "setUi",
@@ -5404,7 +5472,7 @@ function Puck({
5404
5472
  window.removeEventListener("resize", handleResize);
5405
5473
  };
5406
5474
  }, []);
5407
- const defaultHeaderRender = (0, import_react32.useMemo)(() => {
5475
+ const defaultHeaderRender = (0, import_react33.useMemo)(() => {
5408
5476
  if (renderHeader) {
5409
5477
  console.warn(
5410
5478
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -5418,7 +5486,7 @@ function Puck({
5418
5486
  }
5419
5487
  return DefaultOverride;
5420
5488
  }, [renderHeader]);
5421
- const defaultHeaderActionsRender = (0, import_react32.useMemo)(() => {
5489
+ const defaultHeaderActionsRender = (0, import_react33.useMemo)(() => {
5422
5490
  if (renderHeaderActions) {
5423
5491
  console.warn(
5424
5492
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -5435,20 +5503,20 @@ function Puck({
5435
5503
  overrides,
5436
5504
  plugins
5437
5505
  });
5438
- const CustomPuck = (0, import_react32.useMemo)(
5506
+ const CustomPuck = (0, import_react33.useMemo)(
5439
5507
  () => loadedOverrides.puck || DefaultOverride,
5440
5508
  [loadedOverrides]
5441
5509
  );
5442
- const CustomHeader = (0, import_react32.useMemo)(
5510
+ const CustomHeader = (0, import_react33.useMemo)(
5443
5511
  () => loadedOverrides.header || defaultHeaderRender,
5444
5512
  [loadedOverrides]
5445
5513
  );
5446
- const CustomHeaderActions = (0, import_react32.useMemo)(
5514
+ const CustomHeaderActions = (0, import_react33.useMemo)(
5447
5515
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
5448
5516
  [loadedOverrides]
5449
5517
  );
5450
- const [mounted, setMounted] = (0, import_react32.useState)(false);
5451
- (0, import_react32.useEffect)(() => {
5518
+ const [mounted, setMounted] = (0, import_react33.useState)(false);
5519
+ (0, import_react33.useEffect)(() => {
5452
5520
  setMounted(true);
5453
5521
  }, []);
5454
5522
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
package/dist/index.mjs CHANGED
@@ -178,14 +178,13 @@ init_react_import();
178
178
 
179
179
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
180
180
  init_react_import();
181
- var styles_module_default2 = { "Input": "_Input_3pq3z_1", "Input-label": "_Input-label_3pq3z_26", "Input-labelIcon": "_Input-labelIcon_3pq3z_35", "Input-disabledIcon": "_Input-disabledIcon_3pq3z_42", "Input-input": "_Input-input_3pq3z_47", "Input--readOnly": "_Input--readOnly_3pq3z_91", "Input-radioGroupItems": "_Input-radioGroupItems_3pq3z_102", "Input-radio": "_Input-radio_3pq3z_102", "Input-radioInner": "_Input-radioInner_3pq3z_119", "Input-radioInput": "_Input-radioInput_3pq3z_164" };
181
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
182
182
 
183
183
  // components/AutoField/index.tsx
184
184
  import {
185
185
  useCallback as useCallback5,
186
186
  useEffect as useEffect9,
187
187
  useMemo as useMemo2,
188
- useRef as useRef2,
189
188
  useState as useState10
190
189
  } from "react";
191
190
 
@@ -880,7 +879,8 @@ var defaultAppState = {
880
879
  },
881
880
  options: [],
882
881
  controlsVisible: true
883
- }
882
+ },
883
+ field: { focus: null }
884
884
  }
885
885
  };
886
886
  var defaultContext = {
@@ -1228,11 +1228,13 @@ var ArrayField = ({
1228
1228
  event.source.index,
1229
1229
  (_b = event.destination) == null ? void 0 : _b.index
1230
1230
  );
1231
- onChange(newValue, {
1231
+ const newUi = {
1232
1232
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
1233
1233
  [id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
1234
1234
  })
1235
- });
1235
+ };
1236
+ setUi(newUi, false);
1237
+ onChange(newValue, newUi);
1236
1238
  setLocalState({
1237
1239
  value: newValue,
1238
1240
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
@@ -1298,32 +1300,60 @@ var ArrayField = ({
1298
1300
  children: [
1299
1301
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1300
1302
  /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("rhs"), children: [
1301
- !readOnly && /* @__PURE__ */ jsx9("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
1302
- IconButton,
1303
- {
1304
- type: "button",
1305
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1306
- onClick: (e) => {
1307
- e.stopPropagation();
1308
- const existingValue = [
1309
- ...value || []
1310
- ];
1311
- const existingItems = [
1312
- ...arrayState.items || []
1313
- ];
1314
- existingValue.splice(i, 1);
1315
- existingItems.splice(i, 1);
1316
- onChange(
1317
- existingValue,
1318
- mapArrayStateToUi({
1319
- items: existingItems
1320
- })
1321
- );
1322
- },
1323
- title: "Delete",
1324
- children: /* @__PURE__ */ jsx9(Trash, { size: 16 })
1325
- }
1326
- ) }) }),
1303
+ !readOnly && /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("actions"), children: [
1304
+ /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
1305
+ IconButton,
1306
+ {
1307
+ type: "button",
1308
+ disabled: !!addDisabled,
1309
+ onClick: (e) => {
1310
+ e.stopPropagation();
1311
+ const existingValue = [
1312
+ ...value || []
1313
+ ];
1314
+ existingValue.splice(
1315
+ i,
1316
+ 0,
1317
+ existingValue[i]
1318
+ );
1319
+ onChange(
1320
+ existingValue,
1321
+ mapArrayStateToUi(
1322
+ regenerateArrayState(existingValue)
1323
+ )
1324
+ );
1325
+ },
1326
+ title: "Duplicate",
1327
+ children: /* @__PURE__ */ jsx9(Copy, { size: 16 })
1328
+ }
1329
+ ) }),
1330
+ /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
1331
+ IconButton,
1332
+ {
1333
+ type: "button",
1334
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1335
+ onClick: (e) => {
1336
+ e.stopPropagation();
1337
+ const existingValue = [
1338
+ ...value || []
1339
+ ];
1340
+ const existingItems = [
1341
+ ...arrayState.items || []
1342
+ ];
1343
+ existingValue.splice(i, 1);
1344
+ existingItems.splice(i, 1);
1345
+ onChange(
1346
+ existingValue,
1347
+ mapArrayStateToUi({
1348
+ items: existingItems
1349
+ })
1350
+ );
1351
+ },
1352
+ title: "Delete",
1353
+ children: /* @__PURE__ */ jsx9(Trash, { size: 16 })
1354
+ }
1355
+ ) })
1356
+ ] }),
1327
1357
  /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9(DragIcon, {}) })
1328
1358
  ] })
1329
1359
  ]
@@ -2060,6 +2090,7 @@ var useSafeId = () => {
2060
2090
  // components/AutoField/index.tsx
2061
2091
  import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
2062
2092
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2093
+ var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2063
2094
  var FieldLabel = ({
2064
2095
  children,
2065
2096
  icon,
@@ -2107,7 +2138,7 @@ var FieldLabelInternal2 = ({
2107
2138
  };
2108
2139
  function AutoFieldInternal(props) {
2109
2140
  var _a, _b, _c, _d, _e, _f, _g, _h;
2110
- const { overrides } = useAppContext();
2141
+ const { dispatch, overrides } = useAppContext();
2111
2142
  const { id, Label = FieldLabelInternal2 } = props;
2112
2143
  const field = props.field;
2113
2144
  const label = field.label;
@@ -2139,23 +2170,45 @@ function AutoFieldInternal(props) {
2139
2170
  Label,
2140
2171
  id: resolvedId
2141
2172
  });
2173
+ const onFocus = useCallback5(
2174
+ (e) => {
2175
+ if (mergedProps.name && e.target.nodeName === "INPUT") {
2176
+ e.stopPropagation();
2177
+ dispatch({
2178
+ type: "setUi",
2179
+ ui: {
2180
+ field: { focus: mergedProps.name }
2181
+ }
2182
+ });
2183
+ }
2184
+ },
2185
+ [mergedProps.name]
2186
+ );
2187
+ const onBlur = useCallback5((e) => {
2188
+ if ("name" in e.target) {
2189
+ dispatch({
2190
+ type: "setUi",
2191
+ ui: {
2192
+ field: { focus: null }
2193
+ }
2194
+ });
2195
+ }
2196
+ }, []);
2142
2197
  if (field.type === "custom") {
2143
2198
  if (!field.render) {
2144
2199
  return null;
2145
2200
  }
2146
2201
  const CustomField = field.render;
2147
- return /* @__PURE__ */ jsx20("div", { className: getClassName15(), children: /* @__PURE__ */ jsx20(CustomField, __spreadValues({}, mergedProps)) });
2202
+ return /* @__PURE__ */ jsx20("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx20("div", { className: getClassName15(), children: /* @__PURE__ */ jsx20(CustomField, __spreadValues({}, mergedProps)) }) });
2148
2203
  }
2149
2204
  const children = defaultFields[field.type](mergedProps);
2150
2205
  const Render2 = render[field.type];
2151
- return /* @__PURE__ */ jsx20(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
2206
+ return /* @__PURE__ */ jsx20("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx20(Render2, __spreadProps(__spreadValues({}, mergedProps), { children })) });
2152
2207
  }
2153
- var RECENT_CHANGE_TIMEOUT = 200;
2154
2208
  function AutoFieldPrivate(props) {
2209
+ const { state } = useAppContext();
2155
2210
  const { value, onChange } = props;
2156
2211
  const [localValue, setLocalValue] = useState10(value);
2157
- const [recentlyChanged, setRecentlyChanged] = useState10(false);
2158
- const timeoutRef = useRef2();
2159
2212
  const onChangeDb = useDebouncedCallback(
2160
2213
  (val, ui) => {
2161
2214
  onChange(val, ui);
@@ -2165,15 +2218,10 @@ function AutoFieldPrivate(props) {
2165
2218
  );
2166
2219
  const onChangeLocal = useCallback5((val, ui) => {
2167
2220
  setLocalValue(val);
2168
- setRecentlyChanged(true);
2169
- clearTimeout(timeoutRef.current);
2170
- timeoutRef.current = setTimeout(() => {
2171
- setRecentlyChanged(false);
2172
- }, RECENT_CHANGE_TIMEOUT);
2173
2221
  onChangeDb(val, ui);
2174
2222
  }, []);
2175
2223
  useEffect9(() => {
2176
- if (!recentlyChanged) {
2224
+ if (state.ui.field.focus !== props.name) {
2177
2225
  setLocalValue(value);
2178
2226
  }
2179
2227
  }, [value]);
@@ -3524,6 +3572,22 @@ var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields
3524
3572
 
3525
3573
  // components/Puck/components/Fields/index.tsx
3526
3574
  import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo6, useState as useState15 } from "react";
3575
+
3576
+ // lib/use-parent.ts
3577
+ init_react_import();
3578
+ import { useContext as useContext5 } from "react";
3579
+ var useParent = (itemSelector) => {
3580
+ var _a;
3581
+ const { selectedItem, state } = useAppContext();
3582
+ const { pathData } = useContext5(dropZoneContext) || {};
3583
+ const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
3584
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
3585
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
3586
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
3587
+ return parent || null;
3588
+ };
3589
+
3590
+ // components/Puck/components/Fields/index.tsx
3527
3591
  import { Fragment as Fragment12, jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
3528
3592
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
3529
3593
  var defaultPageFields = {
@@ -3537,6 +3601,7 @@ var DefaultFields = ({
3537
3601
  var useResolvedFields = () => {
3538
3602
  var _a, _b;
3539
3603
  const { selectedItem, state, config } = useAppContext();
3604
+ const parent = useParent();
3540
3605
  const { data } = state;
3541
3606
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
3542
3607
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
@@ -3567,7 +3632,8 @@ var useResolvedFields = () => {
3567
3632
  fields,
3568
3633
  lastFields: resolvedFields,
3569
3634
  lastData,
3570
- appState: state
3635
+ appState: state,
3636
+ parent
3571
3637
  }
3572
3638
  );
3573
3639
  }
@@ -3577,7 +3643,8 @@ var useResolvedFields = () => {
3577
3643
  fields,
3578
3644
  lastFields: resolvedFields,
3579
3645
  lastData,
3580
- appState: state
3646
+ appState: state,
3647
+ parent
3581
3648
  });
3582
3649
  }
3583
3650
  return defaultResolveFields(componentData, {
@@ -3599,7 +3666,7 @@ var useResolvedFields = () => {
3599
3666
  } else {
3600
3667
  setResolvedFields(defaultFields);
3601
3668
  }
3602
- }, [data, defaultFields, state.ui.itemSelector, hasResolver]);
3669
+ }, [data, defaultFields, selectedItem, hasResolver]);
3603
3670
  return [resolvedFields, fieldsLoading];
3604
3671
  };
3605
3672
  var Fields = () => {
@@ -3906,7 +3973,7 @@ import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
3906
3973
  init_react_import();
3907
3974
  import {
3908
3975
  createContext as createContext4,
3909
- useContext as useContext5,
3976
+ useContext as useContext6,
3910
3977
  useEffect as useEffect15,
3911
3978
  useRef as useRef3,
3912
3979
  useState as useState17
@@ -4116,7 +4183,7 @@ var CopyHostStyles = ({
4116
4183
  return /* @__PURE__ */ jsx31(Fragment13, { children });
4117
4184
  };
4118
4185
  var autoFrameContext = createContext4({});
4119
- var useFrame = () => useContext5(autoFrameContext);
4186
+ var useFrame = () => useContext6(autoFrameContext);
4120
4187
  function AutoFrame(_a) {
4121
4188
  var _b = _a, {
4122
4189
  children,
@@ -4269,7 +4336,7 @@ var scrollIntoView = (el) => {
4269
4336
  };
4270
4337
 
4271
4338
  // components/LayerTree/index.tsx
4272
- import { useContext as useContext6 } from "react";
4339
+ import { useContext as useContext7 } from "react";
4273
4340
 
4274
4341
  // lib/is-child-of-zone.ts
4275
4342
  init_react_import();
@@ -4296,7 +4363,7 @@ var LayerTree = ({
4296
4363
  label
4297
4364
  }) => {
4298
4365
  const zones = data.zones || {};
4299
- const ctx = useContext6(dropZoneContext);
4366
+ const ctx = useContext7(dropZoneContext);
4300
4367
  return /* @__PURE__ */ jsxs17(Fragment15, { children: [
4301
4368
  label && /* @__PURE__ */ jsxs17("div", { className: getClassName24("zoneTitle"), children: [
4302
4369
  /* @__PURE__ */ jsx33("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
@@ -145,6 +145,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
145
145
  lastFields: Fields<FieldProps>;
146
146
  lastData: DataShape | null;
147
147
  appState: AppState;
148
+ parent: ComponentData | null;
148
149
  }) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
149
150
  resolveData?: (data: DataShape, params: {
150
151
  changed: Partial<Record<keyof FieldProps, boolean>>;
@@ -274,6 +275,9 @@ type UiState = {
274
275
  controlsVisible: boolean;
275
276
  options: Viewport[];
276
277
  };
278
+ field: {
279
+ focus?: string | null;
280
+ };
277
281
  };
278
282
  type AppState<UserData extends Data = Data> = {
279
283
  data: UserData;
@@ -145,6 +145,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
145
145
  lastFields: Fields<FieldProps>;
146
146
  lastData: DataShape | null;
147
147
  appState: AppState;
148
+ parent: ComponentData | null;
148
149
  }) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
149
150
  resolveData?: (data: DataShape, params: {
150
151
  changed: Partial<Record<keyof FieldProps, boolean>>;
@@ -274,6 +275,9 @@ type UiState = {
274
275
  controlsVisible: boolean;
275
276
  options: Viewport[];
276
277
  };
278
+ field: {
279
+ focus?: string | null;
280
+ };
277
281
  };
278
282
  type AppState<UserData extends Data = Data> = {
279
283
  data: UserData;
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, D as Data } from './resolve-all-data-Bd3DnhYE.mjs';
3
- export { a4 as resolveAllData } from './resolve-all-data-Bd3DnhYE.mjs';
2
+ import { C as Config, D as Data } from './resolve-all-data-C7aAQCY3.mjs';
3
+ export { a4 as resolveAllData } from './resolve-all-data-C7aAQCY3.mjs';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config>({ config, data, }: {
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, D as Data } from './resolve-all-data-Bd3DnhYE.js';
3
- export { a4 as resolveAllData } from './resolve-all-data-Bd3DnhYE.js';
2
+ import { C as Config, D as Data } from './resolve-all-data-C7aAQCY3.js';
3
+ export { a4 as resolveAllData } from './resolve-all-data-C7aAQCY3.js';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config>({ config, data, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.17.0-canary.ccec96e",
3
+ "version": "0.17.0-canary.f71da6d",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",