@contember/bindx-repeater 0.1.21 → 0.1.23

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.
@@ -39,8 +39,7 @@ import type { BlockRepeaterProps } from '../types.js';
39
39
  * ```
40
40
  */
41
41
  export declare function BlockRepeater<TEntity extends object = object, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>, TBlockNames extends string = string>({ field, discriminationField, sortableBy, blocks, children, }: BlockRepeaterProps<TEntity, TSelected, TBrand, TEntityName, TSchema, TBlockNames>): ReactElement;
42
- declare const blockRepeaterWithSelection: typeof BlockRepeater & SelectionProvider & {
42
+ export declare const BlockRepeaterWithMeta: typeof BlockRepeater & SelectionProvider & {
43
43
  [BINDX_COMPONENT]: true;
44
44
  };
45
- export { blockRepeaterWithSelection as BlockRepeaterWithMeta };
46
45
  //# sourceMappingURL=BlockRepeater.d.ts.map
@@ -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,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AE,OAAO,EAAE,WAAW,CAAC,GAAG,YAAY,CAgIlG;AAqGD,eAAO,MAAM,qBAAqB;uBAhGkE,IAAI;CAgGjC,CAAA"}
@@ -31,8 +31,7 @@ import type { RepeaterProps } from '../types.js';
31
31
  * ```
32
32
  */
33
33
  export declare function Repeater<TEntity extends object = object, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>>({ field, sortableBy, children, }: RepeaterProps<TEntity, TSelected, TBrand, TEntityName, TSchema>): ReactElement;
34
- declare const repeaterWithSelection: typeof Repeater & SelectionProvider & {
34
+ export declare const RepeaterWithMeta: typeof Repeater & SelectionProvider & {
35
35
  [BINDX_COMPONENT]: true;
36
36
  };
37
- export { repeaterWithSelection as RepeaterWithMeta };
38
37
  //# sourceMappingURL=Repeater.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Repeater.d.ts","sourceRoot":"","sources":["../../src/components/Repeater.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAW,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAGX,QAAQ,EAGR,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAyC,eAAe,EAAa,KAAK,iBAAiB,EAAc,MAAM,wBAAwB,CAAA;AAC9I,OAAO,KAAK,EACX,aAAa,EAMb,MAAM,aAAa,CAAA;AAMpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CACvB,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,EAC9D,EACD,KAAK,EACL,UAAU,EACV,QAAQ,GACR,EAAE,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,YAAY,CAwHhF;AAGD,QAAA,MAAM,qBAAqB,EAAe,OAAO,QAAQ,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AA+E3G,OAAO,EAAE,qBAAqB,IAAI,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"Repeater.d.ts","sourceRoot":"","sources":["../../src/components/Repeater.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAW,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAGX,QAAQ,EAGR,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAyC,eAAe,EAAa,KAAK,iBAAiB,EAAc,MAAM,wBAAwB,CAAA;AAC9I,OAAO,KAAK,EACX,aAAa,EAMb,MAAM,aAAa,CAAA;AAMpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,QAAQ,CACvB,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,EAC9D,EACD,KAAK,EACL,UAAU,EACV,QAAQ,GACR,EAAE,aAAa,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,YAAY,CAwHhF;AAoFD,eAAO,MAAM,gBAAgB;uBAjF6D,IAAI;CAiFjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/bindx-repeater",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
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.21",
19
- "@contember/bindx-react": "0.1.21"
18
+ "@contember/bindx": "0.1.23",
19
+ "@contember/bindx-react": "0.1.23"
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
- // Static method for selection extraction
205
- const blockRepeaterWithSelection = BlockRepeater as typeof BlockRepeater & SelectionProvider & { [BINDX_COMPONENT]: true }
204
+ // Factory wraps getSelection assignment to avoid module-level side effects
205
+ // which Vite dep optimizer (Rolldown with moduleSideEffects: false) would strip.
206
+ function createBlockRepeaterWithSelection() {
207
+ const component = BlockRepeater as typeof BlockRepeater & SelectionProvider & { [BINDX_COMPONENT]: true }
208
+ component[BINDX_COMPONENT] = true
206
209
 
207
- blockRepeaterWithSelection.getSelection = (
208
- props: BlockRepeaterProps<unknown>,
209
- collectNested: (children: ReactNode) => SelectionMeta,
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,8 +221,6 @@ blockRepeaterWithSelection.getSelection = (
218
221
  const scope = new SelectionScope()
219
222
  const collectorEntity = createCollectorProxy<unknown>(scope)
220
223
 
221
- const blockJsx: ReactNode[] = []
222
-
223
224
  const mockItems: BlockRepeaterItems<unknown> = {
224
225
  map: (fn) => {
225
226
  fn(collectorEntity, {
@@ -232,13 +233,6 @@ blockRepeaterWithSelection.getSelection = (
232
233
  blockType: null,
233
234
  block: undefined,
234
235
  })
235
- // Call block render/form functions inside the map callback so the
236
- // collector proxy records field accesses. This code must execute inside
237
- // a callback passed through props.children() to survive Rolldown DCE.
238
- for (const blockDef of Object.values(props.blocks) as BlockDefinition[]) {
239
- if (blockDef.render) blockJsx.push(blockDef.render(collectorEntity as EntityAccessor<object>))
240
- if (blockDef.form) blockJsx.push(blockDef.form(collectorEntity as EntityAccessor<object>))
241
- }
242
236
  return []
243
237
  },
244
238
  length: 0,
@@ -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,7 @@ blockRepeaterWithSelection.getSelection = (
295
297
  }
296
298
  }
297
299
 
298
- blockRepeaterWithSelection[BINDX_COMPONENT] = true
300
+ return component
301
+ }
299
302
 
300
- export { blockRepeaterWithSelection as BlockRepeaterWithMeta }
303
+ export const BlockRepeaterWithMeta = createBlockRepeaterWithSelection()
@@ -181,10 +181,11 @@ export function Repeater<
181
181
  return <>{children(items, methods)}</>
182
182
  }
183
183
 
184
- // Static method for selection extraction
185
- const repeaterWithSelection = Repeater as typeof Repeater & SelectionProvider & { [BINDX_COMPONENT]: true }
184
+ function createRepeaterWithSelection() {
185
+ const component = Repeater as typeof Repeater & SelectionProvider & { [BINDX_COMPONENT]: true }
186
+ component[BINDX_COMPONENT] = true
186
187
 
187
- repeaterWithSelection.getSelection = (
188
+ component.getSelection = (
188
189
  props: RepeaterProps<unknown>,
189
190
  collectNested: (children: ReactNode) => SelectionMeta,
190
191
  ): SelectionFieldMeta | null => {
@@ -259,6 +260,7 @@ repeaterWithSelection.getSelection = (
259
260
  }
260
261
  }
261
262
 
262
- repeaterWithSelection[BINDX_COMPONENT] = true
263
+ return component
264
+ }
263
265
 
264
- export { repeaterWithSelection as RepeaterWithMeta }
266
+ export const RepeaterWithMeta = createRepeaterWithSelection()