@measured/puck 0.19.0-canary.036267f6 → 0.19.0-canary.046cb9ed

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
@@ -139,6 +139,10 @@
139
139
  height: 1px;
140
140
  min-height: 100vh;
141
141
  }
142
+ [data-puck-entry] {
143
+ position: relative;
144
+ z-index: 0;
145
+ }
142
146
 
143
147
  /* css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css/#css-module-data */
144
148
  ._ActionBar_rvadt_1 {
@@ -225,10 +229,10 @@
225
229
  }
226
230
 
227
231
  /* css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css/#css-module-data */
228
- ._InputWrapper_g5w3n_1 + ._InputWrapper_g5w3n_1 {
232
+ ._InputWrapper_4xor1_1 + ._InputWrapper_4xor1_1 {
229
233
  margin-top: 12px;
230
234
  }
231
- ._Input-label_g5w3n_5 {
235
+ ._Input-label_4xor1_5 {
232
236
  align-items: center;
233
237
  color: var(--puck-color-grey-04);
234
238
  display: flex;
@@ -236,29 +240,30 @@
236
240
  font-size: var(--puck-font-size-xxs);
237
241
  font-weight: 600;
238
242
  }
239
- ._Input-labelIcon_g5w3n_14 {
243
+ ._Input-labelIcon_4xor1_14 {
240
244
  color: var(--puck-color-grey-07);
241
245
  display: flex;
242
246
  margin-inline-end: 4px;
243
247
  padding-inline-start: 4px;
244
248
  }
245
- ._Input-disabledIcon_g5w3n_21 {
249
+ ._Input-disabledIcon_4xor1_21 {
246
250
  color: var(--puck-color-grey-05);
247
251
  margin-inline-start: auto;
248
252
  }
249
- ._Input-input_g5w3n_26 {
253
+ ._Input-input_4xor1_26 {
250
254
  background: var(--puck-color-white);
251
255
  border-width: 1px;
252
256
  border-style: solid;
253
257
  border-color: var(--puck-color-grey-09);
254
258
  border-radius: 4px;
259
+ box-sizing: border-box;
255
260
  font-family: inherit;
256
261
  font-size: 14px;
257
262
  padding: 12px 15px;
258
263
  transition: border-color 50ms ease-in;
259
264
  width: 100%;
260
265
  }
261
- select._Input-input_g5w3n_26 {
266
+ select._Input-input_4xor1_26 {
262
267
  appearance: none;
263
268
  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;
264
269
  background-size: 12px;
@@ -267,29 +272,29 @@ select._Input-input_g5w3n_26 {
267
272
  background-color: var(--puck-color-white);
268
273
  cursor: pointer;
269
274
  }
270
- select._Input-input_g5w3n_26:dir(rtl) {
275
+ select._Input-input_4xor1_26:dir(rtl) {
271
276
  background-position: 12px calc(50% + 3px);
272
277
  }
273
278
  @media (hover: hover) and (pointer: fine) {
274
- ._Input_g5w3n_1:has(> input):hover ._Input-input_g5w3n_26:not([readonly]),
275
- ._Input_g5w3n_1:has(> textarea):hover ._Input-input_g5w3n_26:not([readonly]) {
279
+ ._Input_4xor1_1:has(> input):hover ._Input-input_4xor1_26:not([readonly]),
280
+ ._Input_4xor1_1:has(> textarea):hover ._Input-input_4xor1_26:not([readonly]) {
276
281
  border-color: var(--puck-color-grey-05);
277
282
  transition: none;
278
283
  }
279
- ._Input_g5w3n_1:has(> select):hover ._Input-input_g5w3n_26:not([disabled]) {
284
+ ._Input_4xor1_1:has(> select):hover ._Input-input_4xor1_26:not([disabled]) {
280
285
  background-color: var(--puck-color-azure-12);
281
286
  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>");
282
287
  border-color: var(--puck-color-grey-05);
283
288
  transition: none;
284
289
  }
285
290
  }
286
- ._Input-input_g5w3n_26:focus {
291
+ ._Input-input_4xor1_26:focus {
287
292
  border-color: var(--puck-color-grey-05);
288
293
  outline: 2px solid var(--puck-color-azure-05);
289
294
  transition: none;
290
295
  }
291
- ._Input--readOnly_g5w3n_74 > ._Input-input_g5w3n_26,
292
- ._Input--readOnly_g5w3n_74 > select._Input-input_g5w3n_26 {
296
+ ._Input--readOnly_4xor1_75 > ._Input-input_4xor1_26,
297
+ ._Input--readOnly_4xor1_75 > select._Input-input_4xor1_26 {
293
298
  background-color: var(--puck-color-grey-11);
294
299
  border-color: var(--puck-color-grey-09);
295
300
  color: var(--puck-color-grey-04);
@@ -298,34 +303,34 @@ select._Input-input_g5w3n_26:dir(rtl) {
298
303
  outline: 0;
299
304
  transition: none;
300
305
  }
301
- ._Input-radioGroupItems_g5w3n_85 {
306
+ ._Input-radioGroupItems_4xor1_86 {
302
307
  display: flex;
303
308
  border: 1px solid var(--puck-color-grey-09);
304
309
  border-radius: 4px;
305
310
  flex-wrap: wrap;
306
311
  }
307
- ._Input-radio_g5w3n_85 {
312
+ ._Input-radio_4xor1_86 {
308
313
  border-inline-end: 1px solid var(--puck-color-grey-09);
309
314
  flex-grow: 1;
310
315
  }
311
- ._Input-radio_g5w3n_85:first-of-type {
316
+ ._Input-radio_4xor1_86:first-of-type {
312
317
  border-bottom-left-radius: 4px;
313
318
  border-top-left-radius: 4px;
314
319
  }
315
- ._Input-radio_g5w3n_85:first-of-type ._Input-radioInner_g5w3n_102 {
320
+ ._Input-radio_4xor1_86:first-of-type ._Input-radioInner_4xor1_103 {
316
321
  border-bottom-left-radius: 3px;
317
322
  border-top-left-radius: 3px;
318
323
  }
319
- ._Input-radio_g5w3n_85:last-of-type {
324
+ ._Input-radio_4xor1_86:last-of-type {
320
325
  border-bottom-right-radius: 4px;
321
326
  border-inline-end: 0;
322
327
  border-top-right-radius: 4px;
323
328
  }
324
- ._Input-radio_g5w3n_85:last-of-type ._Input-radioInner_g5w3n_102 {
329
+ ._Input-radio_4xor1_86:last-of-type ._Input-radioInner_4xor1_103 {
325
330
  border-bottom-right-radius: 3px;
326
331
  border-top-right-radius: 3px;
327
332
  }
328
- ._Input-radioInner_g5w3n_102 {
333
+ ._Input-radioInner_4xor1_103 {
329
334
  background-color: var(--puck-color-white);
330
335
  color: var(--puck-color-grey-04);
331
336
  cursor: pointer;
@@ -334,32 +339,32 @@ select._Input-input_g5w3n_26:dir(rtl) {
334
339
  text-align: center;
335
340
  transition: background-color 50ms ease-in;
336
341
  }
337
- ._Input-radio_g5w3n_85:has(:focus-visible) {
342
+ ._Input-radio_4xor1_86:has(:focus-visible) {
338
343
  outline: 2px solid var(--puck-color-azure-05);
339
344
  outline-offset: 2px;
340
345
  position: relative;
341
346
  }
342
347
  @media (hover: hover) and (pointer: fine) {
343
- ._Input-radioInner_g5w3n_102:hover {
348
+ ._Input-radioInner_4xor1_103:hover {
344
349
  background-color: var(--puck-color-azure-12);
345
350
  transition: none;
346
351
  }
347
352
  }
348
- ._Input--readOnly_g5w3n_74 ._Input-radioInner_g5w3n_102 {
353
+ ._Input--readOnly_4xor1_75 ._Input-radioInner_4xor1_103 {
349
354
  background-color: var(--puck-color-white);
350
355
  color: var(--puck-color-grey-04);
351
356
  cursor: default;
352
357
  }
353
- ._Input-radio_g5w3n_85 ._Input-radioInput_g5w3n_147:checked ~ ._Input-radioInner_g5w3n_102 {
358
+ ._Input-radio_4xor1_86 ._Input-radioInput_4xor1_148:checked ~ ._Input-radioInner_4xor1_103 {
354
359
  background-color: var(--puck-color-azure-11);
355
360
  color: var(--puck-color-azure-04);
356
361
  font-weight: 500;
357
362
  }
358
- ._Input--readOnly_g5w3n_74 ._Input-radioInput_g5w3n_147:checked ~ ._Input-radioInner_g5w3n_102 {
363
+ ._Input--readOnly_4xor1_75 ._Input-radioInput_4xor1_148:checked ~ ._Input-radioInner_4xor1_103 {
359
364
  background-color: var(--puck-color-grey-11);
360
365
  color: var(--puck-color-grey-04);
361
366
  }
362
- ._Input-radio_g5w3n_85 ._Input-radioInput_g5w3n_147 {
367
+ ._Input-radio_4xor1_86 ._Input-radioInput_4xor1_148 {
363
368
  clip: rect(0 0 0 0);
364
369
  clip-path: inset(100%);
365
370
  height: 1px;
@@ -368,7 +373,7 @@ select._Input-input_g5w3n_26:dir(rtl) {
368
373
  white-space: nowrap;
369
374
  width: 1px;
370
375
  }
371
- textarea._Input-input_g5w3n_26 {
376
+ textarea._Input-input_4xor1_26 {
372
377
  margin-bottom: -4px;
373
378
  }
374
379
 
@@ -1087,27 +1092,25 @@ textarea._Input-input_g5w3n_26 {
1087
1092
  }
1088
1093
 
1089
1094
  /* css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css/#css-module-data */
1090
- ._Drawer_fkqfo_1 {
1095
+ ._Drawer_pl7z0_1 {
1091
1096
  display: flex;
1092
1097
  flex-direction: column;
1093
1098
  font-family: var(--puck-font-family);
1094
1099
  gap: 12px;
1095
1100
  }
1096
- ._Drawer-draggable_fkqfo_8 {
1101
+ ._Drawer-draggable_pl7z0_8 {
1097
1102
  position: relative;
1098
1103
  }
1099
- ._Drawer-draggableBg_fkqfo_12 {
1104
+ ._Drawer-draggableBg_pl7z0_12 {
1100
1105
  position: absolute;
1101
1106
  top: 0;
1102
1107
  right: 0;
1103
1108
  bottom: 0;
1104
1109
  left: 0;
1105
1110
  pointer-events: none;
1111
+ z-index: -1;
1106
1112
  }
1107
- ._Drawer-draggableFg_fkqfo_21 {
1108
- z-index: 1;
1109
- }
1110
- ._DrawerItem-draggable_fkqfo_25 {
1113
+ ._DrawerItem-draggable_pl7z0_22 {
1111
1114
  background: var(--puck-color-white);
1112
1115
  cursor: grab;
1113
1116
  padding: 12px;
@@ -1119,39 +1122,39 @@ textarea._Input-input_g5w3n_26 {
1119
1122
  align-items: center;
1120
1123
  transition: background-color 50ms ease-in, color 50ms ease-in;
1121
1124
  }
1122
- ._DrawerItem--disabled_fkqfo_38 ._DrawerItem-draggable_fkqfo_25 {
1125
+ ._DrawerItem--disabled_pl7z0_35 ._DrawerItem-draggable_pl7z0_22 {
1123
1126
  background: var(--puck-color-grey-11);
1124
1127
  color: var(--puck-color-grey-05);
1125
1128
  cursor: not-allowed;
1126
1129
  }
1127
- ._DrawerItem_fkqfo_25:focus-visible {
1130
+ ._DrawerItem_pl7z0_22:focus-visible {
1128
1131
  outline: 0;
1129
1132
  }
1130
- ._Drawer_fkqfo_1:not(._Drawer--isDraggingFrom_fkqfo_48) ._DrawerItem_fkqfo_25:focus-visible ._DrawerItem-draggable_fkqfo_25 {
1133
+ ._Drawer_pl7z0_1:not(._Drawer--isDraggingFrom_pl7z0_45) ._DrawerItem_pl7z0_22:focus-visible ._DrawerItem-draggable_pl7z0_22 {
1131
1134
  border-radius: 4px;
1132
1135
  outline: 2px solid var(--puck-color-azure-05);
1133
1136
  outline-offset: 2px;
1134
1137
  }
1135
1138
  @media (hover: hover) and (pointer: fine) {
1136
- ._Drawer_fkqfo_1:not(._Drawer--isDraggingFrom_fkqfo_48) ._DrawerItem_fkqfo_25:not(._DrawerItem--disabled_fkqfo_38) ._DrawerItem-draggable_fkqfo_25:hover {
1139
+ ._Drawer_pl7z0_1:not(._Drawer--isDraggingFrom_pl7z0_45) ._DrawerItem_pl7z0_22:not(._DrawerItem--disabled_pl7z0_35) ._DrawerItem-draggable_pl7z0_22:hover {
1137
1140
  background-color: var(--puck-color-azure-12);
1138
1141
  color: var(--puck-color-azure-04);
1139
1142
  transition: none;
1140
1143
  }
1141
1144
  }
1142
- ._DrawerItem-name_fkqfo_66 {
1145
+ ._DrawerItem-name_pl7z0_63 {
1143
1146
  overflow-x: hidden;
1144
1147
  text-overflow: ellipsis;
1145
1148
  white-space: nowrap;
1146
1149
  }
1147
1150
 
1148
1151
  /* css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css/#css-module-data */
1149
- ._DraggableComponent_1ukn8_1 {
1152
+ ._DraggableComponent_qzbgx_1 {
1150
1153
  position: absolute;
1151
1154
  pointer-events: none;
1152
1155
  --overlay-background: color-mix( in srgb, var(--puck-color-azure-08) 30%, transparent );
1153
1156
  }
1154
- ._DraggableComponent-overlay_1ukn8_12 {
1157
+ ._DraggableComponent-overlay_qzbgx_12 {
1155
1158
  cursor: pointer;
1156
1159
  height: 100%;
1157
1160
  width: 100%;
@@ -1163,10 +1166,10 @@ textarea._Input-input_g5w3n_26 {
1163
1166
  box-sizing: border-box;
1164
1167
  z-index: 1;
1165
1168
  }
1166
- ._DraggableComponent_1ukn8_1:focus-visible > ._DraggableComponent-overlay_1ukn8_12 {
1169
+ ._DraggableComponent_qzbgx_1:focus-visible > ._DraggableComponent-overlay_qzbgx_12 {
1167
1170
  outline: 1px solid var(--puck-color-azure-05);
1168
1171
  }
1169
- ._DraggableComponent-loadingOverlay_1ukn8_29 {
1172
+ ._DraggableComponent-loadingOverlay_qzbgx_29 {
1170
1173
  background: var(--puck-color-white);
1171
1174
  color: var(--puck-color-grey-03);
1172
1175
  border-radius: 4px;
@@ -1181,35 +1184,36 @@ textarea._Input-input_g5w3n_26 {
1181
1184
  opacity: 0.8;
1182
1185
  z-index: 1;
1183
1186
  }
1184
- ._DraggableComponent--hover_1ukn8_45:not(._DraggableComponent--isLocked_1ukn8_45) > ._DraggableComponent-overlay_1ukn8_12 {
1187
+ ._DraggableComponent--hover_qzbgx_45:not(._DraggableComponent--isLocked_qzbgx_45) > ._DraggableComponent-overlay_qzbgx_12 {
1185
1188
  background: var(--overlay-background);
1186
1189
  }
1187
- ._DraggableComponent--hover_1ukn8_45 > ._DraggableComponent-overlay_1ukn8_12 {
1190
+ ._DraggableComponent--hover_qzbgx_45 > ._DraggableComponent-overlay_qzbgx_12 {
1188
1191
  outline: 2px var(--puck-color-azure-09) solid;
1189
1192
  }
1190
- ._DraggableComponent--isSelected_1ukn8_54 > ._DraggableComponent-overlay_1ukn8_12 {
1193
+ ._DraggableComponent--isSelected_qzbgx_54 > ._DraggableComponent-overlay_qzbgx_12 {
1191
1194
  outline-color: var(--puck-color-azure-07);
1192
1195
  }
1193
- ._DraggableComponent_1ukn8_1:has(._DraggableComponent--hover_1ukn8_45 > ._DraggableComponent-overlay_1ukn8_12) > ._DraggableComponent-overlay_1ukn8_12 {
1196
+ ._DraggableComponent_qzbgx_1:has(._DraggableComponent--hover_qzbgx_45 > ._DraggableComponent-overlay_qzbgx_12) > ._DraggableComponent-overlay_qzbgx_12 {
1194
1197
  display: none;
1195
1198
  }
1196
- ._DraggableComponent-actionsOverlay_1ukn8_66 {
1199
+ ._DraggableComponent-actionsOverlay_qzbgx_66 {
1197
1200
  position: sticky;
1198
1201
  opacity: 0;
1199
1202
  pointer-events: none;
1200
1203
  z-index: 2;
1201
1204
  }
1202
- ._DraggableComponent--isSelected_1ukn8_54 ._DraggableComponent-actionsOverlay_1ukn8_66 {
1205
+ ._DraggableComponent--isSelected_qzbgx_54 ._DraggableComponent-actionsOverlay_qzbgx_66 {
1203
1206
  opacity: 1;
1204
1207
  pointer-events: auto;
1205
1208
  }
1206
- ._DraggableComponent-actions_1ukn8_66 {
1209
+ ._DraggableComponent-actions_qzbgx_66 {
1207
1210
  position: absolute;
1208
1211
  width: auto;
1209
1212
  cursor: grab;
1210
1213
  display: flex;
1211
1214
  box-sizing: border-box;
1212
1215
  transform-origin: right top;
1216
+ min-height: 36px;
1213
1217
  }
1214
1218
 
1215
1219
  /* components/DraggableComponent/styles.css */
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as History, C as Config, P as Permissions, U as UserGenerics, a as ComponentData, 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 FieldProps, h as Field, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory } from './resolve-all-data-Cs8PfTrg.mjs';
2
- export { W as Adaptor, L as ArrayField, s as ArrayState, a6 as AsFieldProps, B as BaseData, E as BaseField, y as ComponentDataMap, z as Content, Z as CustomField, a3 as DefaultComponentProps, a0 as DefaultRootFieldProps, a2 as DefaultRootProps, a1 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, a8 as ExtractPropsFromConfig, a9 as ExtractRootPropsFromConfig, q as FieldRenderFunctions, r as ItemWithId, x as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, u as RootConfig, w as RootData, v as RootDataWithoutProps, J as SelectField, S as Slot, _ as SlotField, T as TextField, G as TextareaField, n as Viewport, a7 as WithChildren, a4 as WithId, a5 as WithPuckProps, o as overrideKeys, ab as resolveAllData, aa as transformProps } from './resolve-all-data-Cs8PfTrg.mjs';
1
+ import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-CM-cu7GU.mjs';
2
+ export { Z as Adaptor, X as ArrayField, t as ArrayState, aa as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a1 as CustomField, a0 as CustomFieldRender, a7 as DefaultComponentProps, a4 as DefaultRootFieldProps, a6 as DefaultRootProps, a5 as DefaultRootRenderProps, m as Direction, n as DragAxis, $ as ExternalField, _ as ExternalFieldWithAdaptor, ac as ExtractPropsFromConfig, ad as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Y as ObjectField, q as OverrideKey, u as PuckComponent, a3 as PuckContext, W as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a2 as SlotField, T as TextField, L as TextareaField, o as Viewport, ab as WithChildren, a8 as WithId, a9 as WithPuckProps, p as overrideKeys, af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.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';
@@ -60,6 +60,7 @@ type FieldsSlice = {
60
60
  fields: Fields | Partial<Fields>;
61
61
  loading: boolean;
62
62
  lastResolvedData: Partial<ComponentOrRootData>;
63
+ id: string | undefined;
63
64
  };
64
65
 
65
66
  type Status = "LOADING" | "MOUNTED" | "READY";
@@ -77,9 +78,9 @@ type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserCon
77
78
  config: UserConfig;
78
79
  componentState: ComponentState;
79
80
  setComponentState: (componentState: ComponentState) => void;
80
- setComponentLoading: (id: string, loading?: boolean, defer?: number) => void;
81
+ setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
81
82
  unsetComponentLoading: (id: string) => void;
82
- pendingComponentLoads: Record<string, NodeJS.Timeout>;
83
+ pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
83
84
  resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
84
85
  node: T;
85
86
  didChange: boolean;
@@ -246,18 +247,21 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
246
247
  metadata?: Metadata;
247
248
  }): react_jsx_runtime.JSX.Element;
248
249
 
249
- declare function migrate(data: Data): Data;
250
+ declare function migrate(data: Data, config?: Config): Data;
250
251
 
251
252
  type WithGet<T> = T & {
252
253
  get: () => T;
253
254
  };
254
255
  type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
255
256
  appState: AppState;
256
- config: Config;
257
+ config: UserConfig;
257
258
  dispatch: AppStore["dispatch"];
258
259
  getPermissions: GetPermissions<UserConfig>;
259
260
  refreshPermissions: RefreshPermissions<UserConfig>;
260
261
  selectedItem: G["UserComponentData"] | null;
262
+ getItemBySelector: (selector: ItemSelector) => ComponentData | undefined;
263
+ getItemById: (id: string) => ComponentData | undefined;
264
+ getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
261
265
  history: {
262
266
  back: HistorySlice["back"];
263
267
  forward: HistorySlice["forward"];
@@ -269,7 +273,8 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
269
273
  hasFuture: boolean;
270
274
  };
271
275
  };
272
- type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<UserConfig>>;
276
+ type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
277
+ type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
273
278
  /**
274
279
  * createUsePuck
275
280
  *
@@ -279,7 +284,7 @@ type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<User
279
284
  *
280
285
  * @returns a typed usePuck function
281
286
  */
282
- declare function createUsePuck<UserConfig extends Config = Config>(): <T = UsePuckData<UserConfig, UserGenerics<UserConfig>>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
287
+ declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
283
288
  declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
284
289
 
285
- export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };
290
+ export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as History, C as Config, P as Permissions, U as UserGenerics, a as ComponentData, 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 FieldProps, h as Field, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory } from './resolve-all-data-Cs8PfTrg.js';
2
- export { W as Adaptor, L as ArrayField, s as ArrayState, a6 as AsFieldProps, B as BaseData, E as BaseField, y as ComponentDataMap, z as Content, Z as CustomField, a3 as DefaultComponentProps, a0 as DefaultRootFieldProps, a2 as DefaultRootProps, a1 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, a8 as ExtractPropsFromConfig, a9 as ExtractRootPropsFromConfig, q as FieldRenderFunctions, r as ItemWithId, x as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, u as RootConfig, w as RootData, v as RootDataWithoutProps, J as SelectField, S as Slot, _ as SlotField, T as TextField, G as TextareaField, n as Viewport, a7 as WithChildren, a4 as WithId, a5 as WithPuckProps, o as overrideKeys, ab as resolveAllData, aa as transformProps } from './resolve-all-data-Cs8PfTrg.js';
1
+ import { H as History, P as Permissions, C as ComponentData, a 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 Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-CM-cu7GU.js';
2
+ export { Z as Adaptor, X as ArrayField, t as ArrayState, aa as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a1 as CustomField, a0 as CustomFieldRender, a7 as DefaultComponentProps, a4 as DefaultRootFieldProps, a6 as DefaultRootProps, a5 as DefaultRootRenderProps, m as Direction, n as DragAxis, $ as ExternalField, _ as ExternalFieldWithAdaptor, ac as ExtractPropsFromConfig, ad as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Y as ObjectField, q as OverrideKey, u as PuckComponent, a3 as PuckContext, W as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a2 as SlotField, T as TextField, L as TextareaField, o as Viewport, ab as WithChildren, a8 as WithId, a9 as WithPuckProps, p as overrideKeys, af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.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';
@@ -60,6 +60,7 @@ type FieldsSlice = {
60
60
  fields: Fields | Partial<Fields>;
61
61
  loading: boolean;
62
62
  lastResolvedData: Partial<ComponentOrRootData>;
63
+ id: string | undefined;
63
64
  };
64
65
 
65
66
  type Status = "LOADING" | "MOUNTED" | "READY";
@@ -77,9 +78,9 @@ type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserCon
77
78
  config: UserConfig;
78
79
  componentState: ComponentState;
79
80
  setComponentState: (componentState: ComponentState) => void;
80
- setComponentLoading: (id: string, loading?: boolean, defer?: number) => void;
81
+ setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
81
82
  unsetComponentLoading: (id: string) => void;
82
- pendingComponentLoads: Record<string, NodeJS.Timeout>;
83
+ pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
83
84
  resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
84
85
  node: T;
85
86
  didChange: boolean;
@@ -246,18 +247,21 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
246
247
  metadata?: Metadata;
247
248
  }): react_jsx_runtime.JSX.Element;
248
249
 
249
- declare function migrate(data: Data): Data;
250
+ declare function migrate(data: Data, config?: Config): Data;
250
251
 
251
252
  type WithGet<T> = T & {
252
253
  get: () => T;
253
254
  };
254
255
  type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
255
256
  appState: AppState;
256
- config: Config;
257
+ config: UserConfig;
257
258
  dispatch: AppStore["dispatch"];
258
259
  getPermissions: GetPermissions<UserConfig>;
259
260
  refreshPermissions: RefreshPermissions<UserConfig>;
260
261
  selectedItem: G["UserComponentData"] | null;
262
+ getItemBySelector: (selector: ItemSelector) => ComponentData | undefined;
263
+ getItemById: (id: string) => ComponentData | undefined;
264
+ getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
261
265
  history: {
262
266
  back: HistorySlice["back"];
263
267
  forward: HistorySlice["forward"];
@@ -269,7 +273,8 @@ type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<User
269
273
  hasFuture: boolean;
270
274
  };
271
275
  };
272
- type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<UserConfig>>;
276
+ type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
277
+ type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
273
278
  /**
274
279
  * createUsePuck
275
280
  *
@@ -279,7 +284,7 @@ type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<User
279
284
  *
280
285
  * @returns a typed usePuck function
281
286
  */
282
- declare function createUsePuck<UserConfig extends Config = Config>(): <T = UsePuckData<UserConfig, UserGenerics<UserConfig>>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
287
+ declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
283
288
  declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
284
289
 
285
- export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };
290
+ export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };