@contember/bindx-repeater 0.1.20 → 0.1.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockRepeater.d.ts","sourceRoot":"","sources":["../../src/components/BlockRepeater.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAW,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAGX,QAAQ,EAIR,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAyC,eAAe,EAAa,KAAK,iBAAiB,EAAwB,MAAM,wBAAwB,CAAA;AACxJ,OAAO,KAAK,EACX,kBAAkB,EAMlB,MAAM,aAAa,CAAA;AAMpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,aAAa,CAC5B,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,SAAS,GAAG,OAAO,EACnB,MAAM,SAAS,QAAQ,GAAG,QAAQ,EAClC,WAAW,SAAS,MAAM,GAAG,MAAM,EACnC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,WAAW,SAAS,MAAM,GAAG,MAAM,EAClC,EACD,KAAK,EACL,mBAAmB,EACnB,UAAU,EACV,MAAM,EACN,QAAQ,GACR,EAAE,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,YAAY,CAgIlG;
|
|
1
|
+
{"version":3,"file":"BlockRepeater.d.ts","sourceRoot":"","sources":["../../src/components/BlockRepeater.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAW,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAGX,QAAQ,EAIR,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAyC,eAAe,EAAa,KAAK,iBAAiB,EAAwB,MAAM,wBAAwB,CAAA;AACxJ,OAAO,KAAK,EACX,kBAAkB,EAMlB,MAAM,aAAa,CAAA;AAMpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,aAAa,CAC5B,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,SAAS,GAAG,OAAO,EACnB,MAAM,SAAS,QAAQ,GAAG,QAAQ,EAClC,WAAW,SAAS,MAAM,GAAG,MAAM,EACnC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/D,WAAW,SAAS,MAAM,GAAG,MAAM,EAClC,EACD,KAAK,EACL,mBAAmB,EACnB,UAAU,EACV,MAAM,EACN,QAAQ,GACR,EAAE,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,YAAY,CAgIlG;AAsGD,QAAA,MAAM,0BAA0B;uBAhGoE,IAAI;CAgGnC,CAAA;AAErE,OAAO,EAAE,0BAA0B,IAAI,qBAAqB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/bindx-repeater",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Repeater components for has-many list management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"react": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@contember/bindx": "0.1.
|
|
19
|
-
"@contember/bindx-react": "0.1.
|
|
18
|
+
"@contember/bindx": "0.1.22",
|
|
19
|
+
"@contember/bindx-react": "0.1.22"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
@@ -201,13 +201,16 @@ export function BlockRepeater<
|
|
|
201
201
|
return <>{children(items, methods)}</>
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
//
|
|
205
|
-
|
|
204
|
+
// Wrap BlockRepeater with selection extraction inside a factory function
|
|
205
|
+
// so the property assignments are not module-level side effects
|
|
206
|
+
// (Vite dep optimizer marks module-level side effects for DCE).
|
|
207
|
+
function createBlockRepeaterWithSelection() {
|
|
208
|
+
const component = BlockRepeater as typeof BlockRepeater & SelectionProvider & { [BINDX_COMPONENT]: true }
|
|
206
209
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
): SelectionFieldMeta | null => {
|
|
210
|
+
component.getSelection = (
|
|
211
|
+
props: BlockRepeaterProps<unknown>,
|
|
212
|
+
collectNested: (children: ReactNode) => SelectionMeta,
|
|
213
|
+
): SelectionFieldMeta | null => {
|
|
211
214
|
// Check if the field is a collector proxy with a scope reference (collection phase).
|
|
212
215
|
// When present, we merge the collected selection directly into the scope tree,
|
|
213
216
|
// which correctly handles deeply nested relations (e.g., page.blocks.items).
|
|
@@ -218,15 +221,6 @@ blockRepeaterWithSelection.getSelection = (
|
|
|
218
221
|
const scope = new SelectionScope()
|
|
219
222
|
const collectorEntity = createCollectorProxy<unknown>(scope)
|
|
220
223
|
|
|
221
|
-
// Collect block render/form JSX so the collector proxy records field accesses.
|
|
222
|
-
// Done inside mockItems.map callback to survive Rolldown dead-code elimination
|
|
223
|
-
// (the callback is invoked by props.children which Rolldown cannot analyze).
|
|
224
|
-
const blockJsx: ReactNode[] = []
|
|
225
|
-
for (const blockDef of Object.values(props.blocks) as BlockDefinition[]) {
|
|
226
|
-
if (blockDef.render) blockJsx.push(blockDef.render(collectorEntity as EntityAccessor<object>))
|
|
227
|
-
if (blockDef.form) blockJsx.push(blockDef.form(collectorEntity as EntityAccessor<object>))
|
|
228
|
-
}
|
|
229
|
-
|
|
230
224
|
const mockItems: BlockRepeaterItems<unknown> = {
|
|
231
225
|
map: (fn) => {
|
|
232
226
|
fn(collectorEntity, {
|
|
@@ -251,6 +245,14 @@ blockRepeaterWithSelection.getSelection = (
|
|
|
251
245
|
}
|
|
252
246
|
|
|
253
247
|
const syntheticChildren = props.children(mockItems, mockMethods)
|
|
248
|
+
|
|
249
|
+
// Call block render/form functions so the collector proxy records field accesses
|
|
250
|
+
const blockJsx: ReactNode[] = []
|
|
251
|
+
for (const blockDef of Object.values(props.blocks) as BlockDefinition[]) {
|
|
252
|
+
if (blockDef.render) blockJsx.push(blockDef.render(collectorEntity as EntityAccessor<object>))
|
|
253
|
+
if (blockDef.form) blockJsx.push(blockDef.form(collectorEntity as EntityAccessor<object>))
|
|
254
|
+
}
|
|
255
|
+
|
|
254
256
|
const jsxSelection = collectNested([syntheticChildren, ...blockJsx])
|
|
255
257
|
|
|
256
258
|
const nestedSelection = scope.toSelectionMeta()
|
|
@@ -295,6 +297,10 @@ blockRepeaterWithSelection.getSelection = (
|
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
299
|
|
|
298
|
-
|
|
300
|
+
component[BINDX_COMPONENT] = true
|
|
301
|
+
return component
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const blockRepeaterWithSelection = createBlockRepeaterWithSelection()
|
|
299
305
|
|
|
300
306
|
export { blockRepeaterWithSelection as BlockRepeaterWithMeta }
|