@measured/puck 0.17.0-canary.229cbdd → 0.17.0-canary.35170f8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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-Ch-Pcasj.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-Ch-Pcasj.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-Ch-Pcasj.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-Ch-Pcasj.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 })
@@ -2269,6 +2272,7 @@ var useSafeId = () => {
2269
2272
  // components/AutoField/index.tsx
2270
2273
  var import_jsx_runtime20 = require("react/jsx-runtime");
2271
2274
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2275
+ var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2272
2276
  var FieldLabel = ({
2273
2277
  children,
2274
2278
  icon,
@@ -2316,7 +2320,7 @@ var FieldLabelInternal2 = ({
2316
2320
  };
2317
2321
  function AutoFieldInternal(props) {
2318
2322
  var _a, _b, _c, _d, _e, _f, _g, _h;
2319
- const { overrides } = useAppContext();
2323
+ const { dispatch, overrides } = useAppContext();
2320
2324
  const { id, Label = FieldLabelInternal2 } = props;
2321
2325
  const field = props.field;
2322
2326
  const label = field.label;
@@ -2348,23 +2352,45 @@ function AutoFieldInternal(props) {
2348
2352
  Label,
2349
2353
  id: resolvedId
2350
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
+ }, []);
2351
2379
  if (field.type === "custom") {
2352
2380
  if (!field.render) {
2353
2381
  return null;
2354
2382
  }
2355
2383
  const CustomField = field.render;
2356
- 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)) }) });
2357
2385
  }
2358
2386
  const children = defaultFields[field.type](mergedProps);
2359
2387
  const Render2 = render[field.type];
2360
- 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 })) });
2361
2389
  }
2362
- var RECENT_CHANGE_TIMEOUT = 200;
2363
2390
  function AutoFieldPrivate(props) {
2391
+ const { state } = useAppContext();
2364
2392
  const { value, onChange } = props;
2365
2393
  const [localValue, setLocalValue] = (0, import_react13.useState)(value);
2366
- const [recentlyChanged, setRecentlyChanged] = (0, import_react13.useState)(false);
2367
- const timeoutRef = (0, import_react13.useRef)();
2368
2394
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2369
2395
  (val, ui) => {
2370
2396
  onChange(val, ui);
@@ -2374,15 +2400,10 @@ function AutoFieldPrivate(props) {
2374
2400
  );
2375
2401
  const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
2376
2402
  setLocalValue(val);
2377
- setRecentlyChanged(true);
2378
- clearTimeout(timeoutRef.current);
2379
- timeoutRef.current = setTimeout(() => {
2380
- setRecentlyChanged(false);
2381
- }, RECENT_CHANGE_TIMEOUT);
2382
2403
  onChangeDb(val, ui);
2383
2404
  }, []);
2384
2405
  (0, import_react13.useEffect)(() => {
2385
- if (!recentlyChanged) {
2406
+ if (state.ui.field.focus !== props.name) {
2386
2407
  setLocalValue(value);
2387
2408
  }
2388
2409
  }, [value]);
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 })
@@ -2088,6 +2090,7 @@ var useSafeId = () => {
2088
2090
  // components/AutoField/index.tsx
2089
2091
  import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
2090
2092
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2093
+ var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2091
2094
  var FieldLabel = ({
2092
2095
  children,
2093
2096
  icon,
@@ -2135,7 +2138,7 @@ var FieldLabelInternal2 = ({
2135
2138
  };
2136
2139
  function AutoFieldInternal(props) {
2137
2140
  var _a, _b, _c, _d, _e, _f, _g, _h;
2138
- const { overrides } = useAppContext();
2141
+ const { dispatch, overrides } = useAppContext();
2139
2142
  const { id, Label = FieldLabelInternal2 } = props;
2140
2143
  const field = props.field;
2141
2144
  const label = field.label;
@@ -2167,23 +2170,45 @@ function AutoFieldInternal(props) {
2167
2170
  Label,
2168
2171
  id: resolvedId
2169
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
+ }, []);
2170
2197
  if (field.type === "custom") {
2171
2198
  if (!field.render) {
2172
2199
  return null;
2173
2200
  }
2174
2201
  const CustomField = field.render;
2175
- 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)) }) });
2176
2203
  }
2177
2204
  const children = defaultFields[field.type](mergedProps);
2178
2205
  const Render2 = render[field.type];
2179
- 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 })) });
2180
2207
  }
2181
- var RECENT_CHANGE_TIMEOUT = 200;
2182
2208
  function AutoFieldPrivate(props) {
2209
+ const { state } = useAppContext();
2183
2210
  const { value, onChange } = props;
2184
2211
  const [localValue, setLocalValue] = useState10(value);
2185
- const [recentlyChanged, setRecentlyChanged] = useState10(false);
2186
- const timeoutRef = useRef2();
2187
2212
  const onChangeDb = useDebouncedCallback(
2188
2213
  (val, ui) => {
2189
2214
  onChange(val, ui);
@@ -2193,15 +2218,10 @@ function AutoFieldPrivate(props) {
2193
2218
  );
2194
2219
  const onChangeLocal = useCallback5((val, ui) => {
2195
2220
  setLocalValue(val);
2196
- setRecentlyChanged(true);
2197
- clearTimeout(timeoutRef.current);
2198
- timeoutRef.current = setTimeout(() => {
2199
- setRecentlyChanged(false);
2200
- }, RECENT_CHANGE_TIMEOUT);
2201
2221
  onChangeDb(val, ui);
2202
2222
  }, []);
2203
2223
  useEffect9(() => {
2204
- if (!recentlyChanged) {
2224
+ if (state.ui.field.focus !== props.name) {
2205
2225
  setLocalValue(value);
2206
2226
  }
2207
2227
  }, [value]);
@@ -274,6 +274,9 @@ type UiState = {
274
274
  controlsVisible: boolean;
275
275
  options: Viewport[];
276
276
  };
277
+ field: {
278
+ focus?: string | null;
279
+ };
277
280
  };
278
281
  type AppState<UserData extends Data = Data> = {
279
282
  data: UserData;
@@ -274,6 +274,9 @@ type UiState = {
274
274
  controlsVisible: boolean;
275
275
  options: Viewport[];
276
276
  };
277
+ field: {
278
+ focus?: string | null;
279
+ };
277
280
  };
278
281
  type AppState<UserData extends Data = Data> = {
279
282
  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-Ch-Pcasj.mjs';
3
+ export { a4 as resolveAllData } from './resolve-all-data-Ch-Pcasj.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-Ch-Pcasj.js';
3
+ export { a4 as resolveAllData } from './resolve-all-data-Ch-Pcasj.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.229cbdd",
3
+ "version": "0.17.0-canary.35170f8",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",