@contember/bindx-react 0.1.14 → 0.1.16
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/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useField.d.ts +13 -0
- package/dist/hooks/useField.d.ts.map +1 -0
- package/dist/hooks/useHasMany.d.ts +11 -0
- package/dist/hooks/useHasMany.d.ts.map +1 -0
- package/dist/hooks/useHasOne.d.ts +11 -0
- package/dist/hooks/useHasOne.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/jsx/collectorProxy.d.ts.map +1 -1
- package/dist/jsx/componentBuilder.types.d.ts +3 -3
- package/dist/jsx/componentBuilder.types.d.ts.map +1 -1
- package/dist/jsx/components/Field.d.ts.map +1 -1
- package/dist/jsx/components/HasMany.d.ts.map +1 -1
- package/dist/jsx/components/HasOne.d.ts.map +1 -1
- package/dist/jsx/components/If.d.ts.map +1 -1
- package/dist/jsx/components/Show.d.ts.map +1 -1
- package/dist/jsx/conditions.d.ts +7 -7
- package/dist/jsx/conditions.d.ts.map +1 -1
- package/dist/jsx/index.d.ts +1 -1
- package/dist/jsx/index.d.ts.map +1 -1
- package/dist/jsx/proxyShared.d.ts +5 -3
- package/dist/jsx/proxyShared.d.ts.map +1 -1
- package/dist/jsx/types.d.ts +9 -9
- package/dist/jsx/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useEntity.ts +1 -1
- package/src/hooks/useField.ts +30 -0
- package/src/hooks/useHasMany.ts +30 -0
- package/src/hooks/useHasOne.ts +30 -0
- package/src/index.ts +12 -3
- package/src/jsx/collectorProxy.ts +9 -6
- package/src/jsx/componentBuilder.types.ts +4 -5
- package/src/jsx/components/Field.tsx +8 -8
- package/src/jsx/components/HasMany.tsx +8 -8
- package/src/jsx/components/HasOne.tsx +8 -8
- package/src/jsx/components/If.tsx +5 -4
- package/src/jsx/components/Show.tsx +7 -3
- package/src/jsx/conditions.ts +19 -19
- package/src/jsx/index.ts +7 -11
- package/src/jsx/proxyShared.ts +5 -6
- package/src/jsx/types.ts +15 -27
package/dist/hooks/index.d.ts
CHANGED
|
@@ -6,5 +6,8 @@ export { ContemberBindxProvider, schemaNamesToDef, } from './ContemberBindxProvi
|
|
|
6
6
|
export { useUndo, type UndoHookResult } from './useUndo.js';
|
|
7
7
|
export { useOnEvent, useOnEntityEvent, useOnFieldEvent, useIntercept, useInterceptEntity, useInterceptField, } from './useBindxEvents.js';
|
|
8
8
|
export { useEntityBeforePersist } from './useEntityBeforePersist.js';
|
|
9
|
+
export { useField } from './useField.js';
|
|
10
|
+
export { useHasMany } from './useHasMany.js';
|
|
11
|
+
export { useHasOne } from './useHasOne.js';
|
|
9
12
|
export { useEntityErrors, type EntityErrorsState, } from './useErrors.js';
|
|
10
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACvB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACnB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACN,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACpB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACN,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,uB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AAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAE3D,OAAO,EACN,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EACN,eAAe,EACf,KAAK,iBAAiB,GACtB,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldRef, type FieldAccessor } from '@contember/bindx';
|
|
2
|
+
/**
|
|
3
|
+
* Subscribes to a field ref and returns a FieldAccessor with live value access.
|
|
4
|
+
*
|
|
5
|
+
* At runtime, FieldRef proxies already have .value/.serverValue/.isDirty —
|
|
6
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
7
|
+
* and widens the type to FieldAccessor.
|
|
8
|
+
*
|
|
9
|
+
* Accepts null — returns null without subscribing (useful for conditional fields).
|
|
10
|
+
*/
|
|
11
|
+
export declare function useField<T>(ref: FieldRef<T>): FieldAccessor<T>;
|
|
12
|
+
export declare function useField<T>(ref: FieldRef<T> | null): FieldAccessor<T> | null;
|
|
13
|
+
//# sourceMappingURL=useField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAkB,MAAM,kBAAkB,CAAA;AAMpF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;AAC/D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HasManyRef, type HasManyAccessor } from '@contember/bindx';
|
|
2
|
+
import type { AnyBrand } from '@contember/bindx';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribes to a has-many ref and returns a HasManyAccessor with live collection access.
|
|
5
|
+
*
|
|
6
|
+
* At runtime, HasManyRef proxies already have .items/.length/.map —
|
|
7
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
8
|
+
* and widens the type to HasManyAccessor.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useHasMany<TEntity, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>>(ref: HasManyRef<TEntity, TSelected, TBrand, TEntityName, TSchema>): HasManyAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>;
|
|
11
|
+
//# sourceMappingURL=useHasMany.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHasMany.d.ts","sourceRoot":"","sources":["../../src/hooks/useHasMany.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAkB,MAAM,kBAAkB,CAAA;AAExF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,OAAO,EACP,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,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAWtI"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HasOneRef, type HasOneAccessor } from '@contember/bindx';
|
|
2
|
+
import type { AnyBrand } from '@contember/bindx';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribes to a has-one ref and returns a HasOneAccessor with live state access.
|
|
5
|
+
*
|
|
6
|
+
* At runtime, HasOneRef proxies already have .$state/.$data/.$entity/.$fields —
|
|
7
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
8
|
+
* and widens the type to HasOneAccessor.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useHasOne<TEntity, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>>(ref: HasOneRef<TEntity, TSelected, TBrand, TEntityName, TSchema>): HasOneAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>;
|
|
11
|
+
//# sourceMappingURL=useHasOne.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHasOne.d.ts","sourceRoot":"","sources":["../../src/hooks/useHasOne.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAkB,MAAM,kBAAkB,CAAA;AAEtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;;GAMG;AACH,wBAAgB,SAAS,CACxB,OAAO,EACP,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,GAAG,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAWpI"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
export type { RelationType, ScalarFieldDef, HasOneRelationDef, HasManyRelationDef, FieldDef, EntitySchemaDef, SchemaDefinition, InferModel, InferEntityNames, EntityDef, InferEntityDef, UnionToIntersection, RoleNames, CommonEntity, EntityForRoles, ResolveEntity, SingleRoleMap, DefaultRole, SelectionBuilder, SelectionMeta, SelectionFieldMeta, FluentFragment, FluentDefiner, HasManyOptions, InferSelection, QuerySpec, QueryFieldSpec, EntityWhere, EntityOrderBy, ScalarCondition, OrderDirection, TypedHasManyOptions, AliasOptions, HasOneRelationState, InputProps, EntityFields,
|
|
6
|
+
export type { RelationType, ScalarFieldDef, HasOneRelationDef, HasManyRelationDef, FieldDef, EntitySchemaDef, SchemaDefinition, InferModel, InferEntityNames, EntityDef, InferEntityDef, UnionToIntersection, RoleNames, CommonEntity, EntityForRoles, ResolveEntity, SingleRoleMap, DefaultRole, SelectionBuilder, SelectionMeta, SelectionFieldMeta, FluentFragment, FluentDefiner, HasManyOptions, InferSelection, QuerySpec, QueryFieldSpec, EntityWhere, EntityOrderBy, ScalarCondition, OrderDirection, TypedHasManyOptions, AliasOptions, HasOneRelationState, InputProps, EntityFields, EntityFieldsAccessor, EntityFieldsRef, ScalarKeys, HasManyKeys, HasOneKeys, FieldRefMeta, FieldRef, HasManyRef, HasOneRef, EntityRef, FieldAccessor, HasManyAccessor, HasOneAccessor, EntityAccessor, ExtractHasOneEntityName, ExtractHasManyEntityName, ExtractRoleMap, BackendAdapter, QueryOptions, Query, GetQuery, ListQuery, QueryResult, GetQueryResult, ListQueryResult, MockDataStore, MockAdapterOptions, ContemberAdapterOptions, EntityLoadResult, EntityListLoadResult, LoadEntityOptions, LoadEntityListOptions, SelectionInput, CoreFluentDefiner, EntitySnapshot, FieldSnapshot, HasOneRelationSnapshot, HasManySnapshot, EntityState, LoadStatus, UndoManagerConfig, UndoState, UndoEntry, BindxEvent, FieldScopedEvent, FieldChangingEvent, FieldChangedEvent, RelationConnectingEvent, RelationConnectedEvent, RelationDisconnectingEvent, RelationDisconnectedEvent, RelationDeletingEvent, RelationDeletedEvent, HasManyConnectingEvent, HasManyConnectedEvent, HasManyDisconnectingEvent, HasManyDisconnectedEvent, EntityPersistingEvent, EntityPersistedEvent, EntityPersistFailedEvent, EntityResettingEvent, EntityResetEvent, EntityDeletingEvent, EntityDeletedEvent, ErrorAddedEvent, ErrorsClearedEvent, LoadStateChangedEvent, BeforeEvent, AfterEvent, AnyBindxEvent, EventTypeMap, InterceptorResult, Interceptor, EventListener, Unsubscribe, BeforeEventTypes, AfterEventTypes, } from '@contember/bindx';
|
|
7
7
|
export { scalar, hasOne, hasMany, defineSchema, entityDef, roleEntityDef, DEFAULT_ROLE, SchemaRegistry, createFragment, buildQueryFromSelection, EntityHandle, HasOneHandle, HasManyListHandle, FieldHandle, FIELD_REF_META, MockAdapter, ContemberAdapter, createEntityLoader, resolveSelectionMeta, buildQuery, SnapshotStore, ActionDispatcher, isTempId, isPlaceholderId, isPersistedId, generatePlaceholderId, BatchPersister, ChangeRegistry, UndoManager, EventEmitter, __internal, } from '@contember/bindx';
|
|
8
8
|
export type { BindxProviderProps, BindxContextValue, BindxGraphQlClient, UseEntityOptions, UseEntityListOptions, LoadingEntityResult, ErrorEntityResult, NotFoundEntityResult, ReadyEntityResult, UseEntityResult, LoadingEntityListResult, ErrorEntityListResult, ReadyEntityListResult, UseEntityListResult, PersistApi, EntityPersistApi, AnyRefWithMeta, } from './hooks/index.js';
|
|
9
9
|
export type { DirtyEntity, PersistScope, AllScope, EntityScope as EntityPersistScope, FieldsScope, RelationScope, CustomScope, EntityPersistResult, PersistenceResult, BatchPersistOptions, } from '@contember/bindx';
|
|
10
|
-
export type {
|
|
11
|
-
export { BindxProvider, useBackendAdapter, useSnapshotStore, useDispatcher, useBatchPersister, useBindxContext, useSchemaRegistry, useEntity, useEntityList, usePersist, usePersistEntity, useUndo, useOnEvent, useOnEntityEvent, useOnFieldEvent, useIntercept, useInterceptEntity, useInterceptField, ContemberBindxProvider, schemaNamesToDef, } from './hooks/index.js';
|
|
10
|
+
export type { FieldProps, HasManyProps, HasOneProps, IfProps, EntityComponentProps, HasManyComponentOptions, ShowProps, SelectionPropMeta, SelectionProvider, EntityPropKeys, EntityFromProp, SelectionFromProp, ImplicitFragmentProperties, BindxComponentBase, BindxComponent, ComponentBuilder, ComponentBuilderState, CreateComponentOptions, InterfaceEntityPropConfig, ImplicitInterfaceEntityConfig, ExplicitInterfaceEntityConfig, AddInterfaces, InterfaceSelectorsMap, AnyEntityPropConfig, EntityPropConfig, ImplicitEntityConfig, ExplicitEntityConfig, AddImplicitEntity, AddExplicitEntity, AddImplicitInterfaceEntity, AddExplicitInterfaceEntity, SetScalarProps, BuildEntityProps, BuildProps, BuildFragmentProps, InitialBuilderState, } from './jsx/index.js';
|
|
11
|
+
export { BindxProvider, useBackendAdapter, useSnapshotStore, useDispatcher, useBatchPersister, useBindxContext, useSchemaRegistry, useEntity, useEntityList, usePersist, usePersistEntity, useUndo, useOnEvent, useOnEntityEvent, useOnFieldEvent, useIntercept, useInterceptEntity, useInterceptField, useField, useHasMany, useHasOne, ContemberBindxProvider, schemaNamesToDef, } from './hooks/index.js';
|
|
12
12
|
export { RoleProvider, useHasRole, type RoleProviderProps } from './roles/index.js';
|
|
13
13
|
export type { UndoHookResult } from './hooks/useUndo.js';
|
|
14
14
|
export { Field, HasMany, HasOne, If, Show, Entity, type EntityProps, EntityList, type EntityListProps, HasRole, type HasRoleProps, BINDX_COMPONENT, SCOPE_REF, cond, type Condition, createComponent, withCollector, isBindxComponent, mergeFragments, COMPONENT_MARKER, COMPONENT_BRAND, COMPONENT_SELECTIONS, createComponentBuilder, getComponentBrand, setBrandValidation, validateBrand, } from './jsx/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,YAAY,EAEX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,cAAc,EAEd,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EAEX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EAEd,WAAW,EACX,aAAa,EACb,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,YAAY,EAEZ,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,WAAW,EACX,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,YAAY,EAEX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,cAAc,EAEd,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EAEX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EAEd,WAAW,EACX,aAAa,EACb,eAAe,E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gBAAgB,CAAA;AAOvB,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAEjB,SAAS,EACT,aAAa,EAEb,UAAU,EACV,gBAAgB,EAEhB,OAAO,EAEP,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,QAAQ,EACR,UAAU,EACV,SAAS,EAET,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGnF,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAIxD,OAAO,EACN,KAAK,EACL,OAAO,EACP,MAAM,EACN,EAAE,EACF,IAAI,EACJ,MAAM,EACN,KAAK,WAAW,EAChB,UAAU,EACV,KAAK,eAAe,EACpB,OAAO,EACP,KAAK,YAAY,EACjB,eAAe,EACf,SAAS,EAET,IAAI,EACJ,KAAK,SAAS,EAEd,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GACb,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACN,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,KAAK,gBAAgB,GACrB,MAAM,6BAA6B,CAAA;AAMpC,OAAO,EACN,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,GACd,MAAM,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectorProxy.d.ts","sourceRoot":"","sources":["../../src/jsx/collectorProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAyB,MAAM,kBAAkB,CAAA;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"collectorProxy.d.ts","sourceRoot":"","sources":["../../src/jsx/collectorProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAyB,MAAM,kBAAkB,CAAA;AACxE,OAAO,EACN,KAAK,cAAc,EAUnB,MAAM,YAAY,CAAA;AASnB;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,KAAK,EAAE,cAAc,EACrB,UAAU,GAAE,MAAM,GAAG,IAAW,EAChC,cAAc,GAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAW,GAClE,cAAc,CAAC,CAAC,CAAC,CA2CnB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* entity props, scalar props, and optional role constraints.
|
|
7
7
|
*/
|
|
8
8
|
import type { ReactNode, ComponentType } from 'react';
|
|
9
|
-
import type {
|
|
9
|
+
import type { EntityRef, EntityAccessor, FluentFragment, SelectionBuilder, AnyBrand, SelectionMeta, EntityDef, ResolveEntity } from '@contember/bindx';
|
|
10
10
|
import type { SelectionProvider } from './types.js';
|
|
11
11
|
import type { Condition } from './conditions.js';
|
|
12
12
|
export declare const COMPONENT_MARKER: unique symbol;
|
|
@@ -112,13 +112,13 @@ export type SetScalarProps<TState extends ComponentBuilderState, TNewScalarProps
|
|
|
112
112
|
* - Allows direct field access: `entity.fieldName.value`
|
|
113
113
|
* - Allows relation access: `entity.relation.length`, `entity.relation.$entity`
|
|
114
114
|
*
|
|
115
|
-
* For implicit selection (no selector): Returns
|
|
115
|
+
* For implicit selection (no selector): Returns EntityRef with restricted access
|
|
116
116
|
* - Blocks direct field access to enforce declarative patterns
|
|
117
117
|
* - Users must use components: `<Field field={entity.fieldName} />`
|
|
118
118
|
* - Users must use condition DSL: `<If condition={cond.hasItems(entity.relation)} />`
|
|
119
119
|
*/
|
|
120
120
|
export type BuildEntityProps<TEntityProps extends Record<string, AnyEntityPropConfig>, TRoles extends readonly string[]> = {
|
|
121
|
-
readonly [K in keyof TEntityProps]: TEntityProps[K] extends EntityPropConfig<infer TEntity, infer TSelected, infer TIsImplicit> ? TIsImplicit extends true ?
|
|
121
|
+
readonly [K in keyof TEntityProps]: TEntityProps[K] extends EntityPropConfig<infer TEntity, infer TSelected, infer TIsImplicit> ? TIsImplicit extends true ? EntityRef<TEntity, TSelected, AnyBrand, string> : EntityAccessor<TEntity, TSelected, AnyBrand, string> : TEntityProps[K] extends InterfaceEntityPropConfig<infer TInterface, infer TIsImplicit> ? TIsImplicit extends true ? EntityRef<TInterface, TInterface, AnyBrand, string> : EntityAccessor<TInterface, TInterface, AnyBrand, string> : never;
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
124
124
|
* Build complete props type from builder state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentBuilder.types.d.ts","sourceRoot":"","sources":["../../src/jsx/componentBuilder.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"componentBuilder.types.d.ts","sourceRoot":"","sources":["../../src/jsx/componentBuilder.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,KAAK,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,SAAS,EACT,aAAa,EACb,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KA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AAA;IAElG;;;;;;;;;;;;;;;;;;OAkBG;IACH,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAE7H;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;CAClF;AAMD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAC9B,MAAM,SAAS,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,IAEjD,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,MAAM,SAAS,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;IAC3F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAsB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAsB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpF,OAAO,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7D;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,SAAS,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,IAAI,CAuBrF;AAED,eAAO,MAAM,KAAK,EAAsB,OAAO,SAAS,CAAA;AAGxD,QAAA,MAAM,kBAAkB,EAAY,OAAO,KAAK,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AA4BlG,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasMany.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/HasMany.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAqC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"HasMany.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/HasMany.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAqC,iBAAiB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC/G,OAAO,EAAkB,eAAe,EAAa,MAAM,aAAa,CAAA;AAKxE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,WAAW,CACnB,OAAO,EACP,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,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,YAAY,CAQnG;AAED,eAAO,MAAM,OAAO,EAAwB,OAAO,WAAW,CAAA;AAG9D,QAAA,MAAM,oBAAoB,EAAc,OAAO,OAAO,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AA0DxG,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/HasOne.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAqC,iBAAiB,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"HasOne.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/HasOne.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAqC,iBAAiB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC9G,OAAO,EAAkB,eAAe,EAAa,MAAM,aAAa,CAAA;AAKxE;;;;;;;;;;;;;;GAcG;AACH,iBAAS,UAAU,CAClB,OAAO,EACP,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,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,YAAY,CAKlG;AAED,eAAO,MAAM,MAAM,EAAuB,OAAO,UAAU,CAAA;AAG3D,QAAA,MAAM,mBAAmB,EAAa,OAAO,MAAM,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAuCrG,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"If.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/If.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,OAAO,EAAqC,iBAAiB,EAAY,MAAM,aAAa,CAAA;AAC1G,OAAO,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"If.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/If.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAQ,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,OAAO,EAAqC,iBAAiB,EAAY,MAAM,aAAa,CAAA;AAC1G,OAAO,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAA;AAW7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,iBAAS,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAe/F;AAED,eAAO,MAAM,EAAE,0CAAe,CAAA;AAG9B,QAAA,MAAM,eAAe,EAAS,OAAO,EAAE,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAqDzF,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Show.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/Show.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"Show.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/Show.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAQ,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAoD,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7D;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC3B,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,CAAA;IAC9C,QAAQ,CAAC,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,QAAQ,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,IAAI,CASrF;AAED,eAAO,MAAM,IAAI,EAAqB,OAAO,QAAQ,CAAA;AAGrD,QAAA,MAAM,iBAAiB,EAAW,OAAO,IAAI,GAAG,iBAAiB,GAAG;IAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAgB/F,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,CAAA"}
|
package/dist/jsx/conditions.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
*
|
|
29
29
|
* @packageDocumentation
|
|
30
30
|
*/
|
|
31
|
-
import type {
|
|
31
|
+
import type { FieldRef, HasManyRef, HasOneRef } from '@contember/bindx';
|
|
32
32
|
/**
|
|
33
33
|
* Symbol to identify condition objects
|
|
34
34
|
*/
|
|
@@ -54,17 +54,17 @@ export interface Condition {
|
|
|
54
54
|
readonly [CONDITION_META]: ConditionMeta;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Base type for scalar fields - accepts
|
|
57
|
+
* Base type for scalar fields - accepts FieldRef (pointer, no .value).
|
|
58
58
|
*/
|
|
59
|
-
type AnyScalarField<T> =
|
|
59
|
+
type AnyScalarField<T> = FieldRef<T>;
|
|
60
60
|
/**
|
|
61
|
-
* Base type for has-many - accepts
|
|
61
|
+
* Base type for has-many - accepts HasManyRef (pointer, no .items/.length/.map).
|
|
62
62
|
*/
|
|
63
|
-
type AnyHasManyField =
|
|
63
|
+
type AnyHasManyField = HasManyRef<any, any, any, any, any>;
|
|
64
64
|
/**
|
|
65
|
-
* Base type for has-one - accepts
|
|
65
|
+
* Base type for has-one - accepts HasOneRef (pointer).
|
|
66
66
|
*/
|
|
67
|
-
type AnyHasOneField =
|
|
67
|
+
type AnyHasOneField = HasOneRef<any, any, any, any, any>;
|
|
68
68
|
/**
|
|
69
69
|
* Condition builder - single import for all condition operations.
|
|
70
70
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/jsx/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/jsx/conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EACX,QAAQ,EAER,UAAU,EAEV,SAAS,EAET,MAAM,kBAAkB,CAAA;AAMzB;;GAEG;AACH,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAA;IAC1B,oCAA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,CAAC,KAAG,SAAS;IAY/C;;;;;;;;;;;;;;;;OAgBG;kCACgB,SAAS,EAAE,KAAG,SAAS;IAU1C;;;;;;;;;;;;;;;OAeG;iCACe,SAAS,EAAE,KAAG,SAAS;IAUzC;;;;;;;;;;;;OAYG;8BACY,SAAS,KAAG,SAAS;CAS3B,CAAA;AAMV;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,EAAE,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAE/D"}
|
package/dist/jsx/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BINDX_COMPONENT, FIELD_REF_META, SCOPE_REF, type FieldRefMeta, type FieldRef, type HasManyRef, type HasOneRef, type
|
|
1
|
+
export { BINDX_COMPONENT, FIELD_REF_META, SCOPE_REF, type FieldRefMeta, type FieldRef, type HasManyRef, type HasOneRef, type EntityRef, type FieldAccessor, type HasManyAccessor, type HasOneAccessor, type EntityAccessor, type EntityFields, type EntityFieldsAccessor, type EntityFieldsRef, type FieldProps, type HasManyProps, type HasOneProps, type IfProps, type EntityComponentProps, type SelectionMeta, type SelectionFieldMeta, type HasManyComponentOptions, type SelectionProvider, type AnyBrand, } from './types.js';
|
|
2
2
|
export { SelectionMetaCollector, mergeSelections, createEmptySelection, } from './SelectionMeta.js';
|
|
3
3
|
export { createCollectorProxy, } from './proxy.js';
|
|
4
4
|
export { analyzeJsx, collectSelection, convertToQuerySelection, debugSelection, } from './analyzer.js';
|
package/dist/jsx/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,eAAe,EAC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AAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAGpE,OAAO,EACN,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,aAAa,GAClB,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GACb,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,YAAY,EACX,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EAEtB,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EAEnB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EAEpB,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,cAAc,EAEd,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,sBAAsB,CAAA;AAG7B,YAAY,EACX,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EntityAccessor, type EntityFields } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Known properties on entity accessor that should NOT be treated as field access.
|
|
4
4
|
* Properties are accessed with $ prefix for consistency with EntityHandle.
|
|
@@ -6,9 +6,11 @@ import { type EntityRef, type EntityAccessor } from './types.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const ENTITY_ACCESSOR_PROPERTIES: Set<string>;
|
|
8
8
|
/**
|
|
9
|
-
* Wraps an
|
|
9
|
+
* Wraps an object with $fields in a Proxy that supports direct field access.
|
|
10
10
|
* - `entity.fieldName` is equivalent to `entity.$fields.fieldName`
|
|
11
11
|
* - Known accessor properties pass through to the target
|
|
12
12
|
*/
|
|
13
|
-
export declare function wrapEntityRefWithFieldAccessProxy<T>(ref:
|
|
13
|
+
export declare function wrapEntityRefWithFieldAccessProxy<T>(ref: {
|
|
14
|
+
$fields: EntityFields<T>;
|
|
15
|
+
} & Record<string | symbol, unknown>): EntityAccessor<T>;
|
|
14
16
|
//# sourceMappingURL=proxyShared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyShared.d.ts","sourceRoot":"","sources":["../../src/jsx/proxyShared.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,
|
|
1
|
+
{"version":3,"file":"proxyShared.d.ts","sourceRoot":"","sources":["../../src/jsx/proxyShared.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,aAMrC,CAAA;AAEF;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,CAAC,EAAE,GAAG,EAAE;IAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAiB5I"}
|
package/dist/jsx/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { SelectionMeta, SelectionFieldMeta, EntityFields, FieldRefMeta, ScalarKeys, HasManyKeys, HasOneKeys,
|
|
2
|
+
import type { SelectionMeta, SelectionFieldMeta, EntityFields, FieldRefMeta, ScalarKeys, HasManyKeys, HasOneKeys, EntityFieldsAccessor, EntityFieldsRef, FieldRef, FieldAccessor, HasManyRef, HasManyAccessor, HasOneRef, HasOneAccessor, EntityRef, EntityAccessor, AnyBrand } from '@contember/bindx';
|
|
3
3
|
import { Condition } from './conditions.js';
|
|
4
4
|
export type { SelectionMeta, SelectionFieldMeta };
|
|
5
5
|
export { FIELD_REF_META } from '@contember/bindx';
|
|
6
|
-
export type { EntityFields, FieldRefMeta, ScalarKeys, HasManyKeys, HasOneKeys,
|
|
6
|
+
export type { EntityFields, FieldRefMeta, ScalarKeys, HasManyKeys, HasOneKeys, EntityFieldsAccessor, EntityFieldsRef, FieldRef, FieldAccessor, HasManyRef, HasManyAccessor, HasOneRef, HasOneAccessor, EntityRef, EntityAccessor, AnyBrand, };
|
|
7
7
|
/**
|
|
8
8
|
* Marker symbol for identifying bindx components
|
|
9
9
|
*/
|
|
@@ -16,11 +16,11 @@ export declare const BINDX_COMPONENT: unique symbol;
|
|
|
16
16
|
export declare const SCOPE_REF: unique symbol;
|
|
17
17
|
/**
|
|
18
18
|
* Props for Field component.
|
|
19
|
-
* Accepts
|
|
19
|
+
* Accepts FieldRef (pointer, no .value). The component uses useField() to get FieldAccessor.
|
|
20
20
|
*/
|
|
21
21
|
export interface FieldProps<T> {
|
|
22
|
-
field:
|
|
23
|
-
children?: (accessor:
|
|
22
|
+
field: FieldRef<T>;
|
|
23
|
+
children?: (accessor: FieldAccessor<T>) => ReactNode;
|
|
24
24
|
format?: (value: T | null) => ReactNode;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -35,7 +35,7 @@ export interface HasManyComponentOptions {
|
|
|
35
35
|
/**
|
|
36
36
|
* Props for HasMany component.
|
|
37
37
|
* Selection-aware: children callback receives EntityAccessor with direct field access.
|
|
38
|
-
* Accepts
|
|
38
|
+
* Accepts HasManyRef (pointer, no .items/.length/.map). The component uses useHasMany() to get HasManyAccessor.
|
|
39
39
|
*
|
|
40
40
|
* @typeParam TEntity - The full entity type
|
|
41
41
|
* @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
|
|
@@ -44,7 +44,7 @@ export interface HasManyComponentOptions {
|
|
|
44
44
|
* @typeParam TSchema - Schema for entity name lookup in nested relations
|
|
45
45
|
*/
|
|
46
46
|
export interface HasManyProps<TEntity, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>> {
|
|
47
|
-
field:
|
|
47
|
+
field: HasManyRef<TEntity, TSelected, TBrand, TEntityName, TSchema>;
|
|
48
48
|
children: (item: EntityAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>, index: number) => ReactNode;
|
|
49
49
|
filter?: unknown;
|
|
50
50
|
orderBy?: unknown;
|
|
@@ -54,7 +54,7 @@ export interface HasManyProps<TEntity, TSelected = TEntity, TBrand extends AnyBr
|
|
|
54
54
|
/**
|
|
55
55
|
* Props for HasOne component.
|
|
56
56
|
* Selection-aware: children callback receives EntityAccessor with direct field access.
|
|
57
|
-
* Accepts
|
|
57
|
+
* Accepts HasOneRef (pointer). The component uses useHasOne() to get HasOneAccessor.
|
|
58
58
|
*
|
|
59
59
|
* @typeParam TEntity - The full entity type
|
|
60
60
|
* @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
|
|
@@ -63,7 +63,7 @@ export interface HasManyProps<TEntity, TSelected = TEntity, TBrand extends AnyBr
|
|
|
63
63
|
* @typeParam TSchema - Schema for entity name lookup in nested relations
|
|
64
64
|
*/
|
|
65
65
|
export interface HasOneProps<TEntity, TSelected = TEntity, TBrand extends AnyBrand = AnyBrand, TEntityName extends string = string, TSchema extends Record<string, object> = Record<string, object>> {
|
|
66
|
-
field:
|
|
66
|
+
field: HasOneRef<TEntity, TSelected, TBrand, TEntityName, TSchema>;
|
|
67
67
|
children: (entity: EntityAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>) => ReactNode;
|
|
68
68
|
}
|
|
69
69
|
/**
|
package/dist/jsx/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/jsx/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EACX,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/jsx/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EACX,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,SAAS,EACT,cAAc,EACd,SAAS,EACT,cAAc,EACd,QAAQ,EACR,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAA;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,SAAS,EACT,cAAc,EACd,SAAS,EACT,cAAc,EACd,QAAQ,GACR,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,eAA4B,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,SAAS,eAAsB,CAAA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AO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/bindx-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Type-safe React data binding framework",
|
|
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-client": "0.1.
|
|
18
|
+
"@contember/bindx": "0.1.16",
|
|
19
|
+
"@contember/bindx-client": "0.1.16",
|
|
20
20
|
"@contember/graphql-client": "^2.1.0-beta.1",
|
|
21
21
|
"@radix-ui/primitive": "^1.1.3",
|
|
22
22
|
"@radix-ui/react-slot": "^1.2.4"
|
package/src/hooks/index.ts
CHANGED
|
@@ -56,6 +56,10 @@ export {
|
|
|
56
56
|
|
|
57
57
|
export { useEntityBeforePersist } from './useEntityBeforePersist.js'
|
|
58
58
|
|
|
59
|
+
export { useField } from './useField.js'
|
|
60
|
+
export { useHasMany } from './useHasMany.js'
|
|
61
|
+
export { useHasOne } from './useHasOne.js'
|
|
62
|
+
|
|
59
63
|
export {
|
|
60
64
|
useEntityErrors,
|
|
61
65
|
type EntityErrorsState,
|
package/src/hooks/useEntity.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
import { type FieldRef, type FieldAccessor, FIELD_REF_META } from '@contember/bindx'
|
|
3
|
+
import { useSnapshotStore } from './BackendAdapterContext.js'
|
|
4
|
+
|
|
5
|
+
const noopSubscribe = () => () => {}
|
|
6
|
+
const noopSnapshot = () => 0
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Subscribes to a field ref and returns a FieldAccessor with live value access.
|
|
10
|
+
*
|
|
11
|
+
* At runtime, FieldRef proxies already have .value/.serverValue/.isDirty —
|
|
12
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
13
|
+
* and widens the type to FieldAccessor.
|
|
14
|
+
*
|
|
15
|
+
* Accepts null — returns null without subscribing (useful for conditional fields).
|
|
16
|
+
*/
|
|
17
|
+
export function useField<T>(ref: FieldRef<T>): FieldAccessor<T>
|
|
18
|
+
export function useField<T>(ref: FieldRef<T> | null): FieldAccessor<T> | null
|
|
19
|
+
export function useField<T>(ref: FieldRef<T> | null): FieldAccessor<T> | null {
|
|
20
|
+
const store = useSnapshotStore()
|
|
21
|
+
const meta = ref?.[FIELD_REF_META]
|
|
22
|
+
|
|
23
|
+
useSyncExternalStore(
|
|
24
|
+
meta ? (callback) => store.subscribeToEntity(meta.entityType, meta.entityId, callback) : noopSubscribe,
|
|
25
|
+
meta ? () => store.getVersion() : noopSnapshot,
|
|
26
|
+
meta ? () => store.getVersion() : noopSnapshot,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return ref as unknown as FieldAccessor<T> | null
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
import { type HasManyRef, type HasManyAccessor, FIELD_REF_META } from '@contember/bindx'
|
|
3
|
+
import { useSnapshotStore } from './BackendAdapterContext.js'
|
|
4
|
+
import type { AnyBrand } from '@contember/bindx'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Subscribes to a has-many ref and returns a HasManyAccessor with live collection access.
|
|
8
|
+
*
|
|
9
|
+
* At runtime, HasManyRef proxies already have .items/.length/.map —
|
|
10
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
11
|
+
* and widens the type to HasManyAccessor.
|
|
12
|
+
*/
|
|
13
|
+
export function useHasMany<
|
|
14
|
+
TEntity,
|
|
15
|
+
TSelected = TEntity,
|
|
16
|
+
TBrand extends AnyBrand = AnyBrand,
|
|
17
|
+
TEntityName extends string = string,
|
|
18
|
+
TSchema extends Record<string, object> = Record<string, object>,
|
|
19
|
+
>(ref: HasManyRef<TEntity, TSelected, TBrand, TEntityName, TSchema>): HasManyAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema> {
|
|
20
|
+
const store = useSnapshotStore()
|
|
21
|
+
const meta = ref[FIELD_REF_META]
|
|
22
|
+
|
|
23
|
+
useSyncExternalStore(
|
|
24
|
+
(callback) => store.subscribeToEntity(meta.entityType, meta.entityId, callback),
|
|
25
|
+
() => store.getVersion(),
|
|
26
|
+
() => store.getVersion(),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return ref as unknown as HasManyAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
import { type HasOneRef, type HasOneAccessor, FIELD_REF_META } from '@contember/bindx'
|
|
3
|
+
import { useSnapshotStore } from './BackendAdapterContext.js'
|
|
4
|
+
import type { AnyBrand } from '@contember/bindx'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Subscribes to a has-one ref and returns a HasOneAccessor with live state access.
|
|
8
|
+
*
|
|
9
|
+
* At runtime, HasOneRef proxies already have .$state/.$data/.$entity/.$fields —
|
|
10
|
+
* this hook adds a store subscription so the component re-renders on changes,
|
|
11
|
+
* and widens the type to HasOneAccessor.
|
|
12
|
+
*/
|
|
13
|
+
export function useHasOne<
|
|
14
|
+
TEntity,
|
|
15
|
+
TSelected = TEntity,
|
|
16
|
+
TBrand extends AnyBrand = AnyBrand,
|
|
17
|
+
TEntityName extends string = string,
|
|
18
|
+
TSchema extends Record<string, object> = Record<string, object>,
|
|
19
|
+
>(ref: HasOneRef<TEntity, TSelected, TBrand, TEntityName, TSchema>): HasOneAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema> {
|
|
20
|
+
const store = useSnapshotStore()
|
|
21
|
+
const meta = ref[FIELD_REF_META]
|
|
22
|
+
|
|
23
|
+
useSyncExternalStore(
|
|
24
|
+
(callback) => store.subscribeToEntity(meta.entityType, meta.entityId, callback),
|
|
25
|
+
() => store.getVersion(),
|
|
26
|
+
() => store.getVersion(),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return ref as unknown as HasOneAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>
|
|
30
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -50,15 +50,22 @@ export type {
|
|
|
50
50
|
HasOneRelationState,
|
|
51
51
|
InputProps,
|
|
52
52
|
EntityFields,
|
|
53
|
-
|
|
53
|
+
EntityFieldsAccessor,
|
|
54
|
+
EntityFieldsRef,
|
|
54
55
|
ScalarKeys,
|
|
55
56
|
HasManyKeys,
|
|
56
57
|
HasOneKeys,
|
|
57
58
|
FieldRefMeta,
|
|
59
|
+
// Ref types (pointer, no data access)
|
|
58
60
|
FieldRef,
|
|
59
61
|
HasManyRef,
|
|
60
62
|
HasOneRef,
|
|
61
63
|
EntityRef,
|
|
64
|
+
// Accessor types (live data access, extends Ref)
|
|
65
|
+
FieldAccessor,
|
|
66
|
+
HasManyAccessor,
|
|
67
|
+
HasOneAccessor,
|
|
68
|
+
EntityAccessor,
|
|
62
69
|
// Type extraction helpers
|
|
63
70
|
ExtractHasOneEntityName,
|
|
64
71
|
ExtractHasManyEntityName,
|
|
@@ -218,8 +225,6 @@ export type {
|
|
|
218
225
|
|
|
219
226
|
// JSX types
|
|
220
227
|
export type {
|
|
221
|
-
EntityAccessor,
|
|
222
|
-
FieldRefBase,
|
|
223
228
|
FieldProps,
|
|
224
229
|
HasManyProps,
|
|
225
230
|
HasOneProps,
|
|
@@ -291,6 +296,10 @@ export {
|
|
|
291
296
|
useIntercept,
|
|
292
297
|
useInterceptEntity,
|
|
293
298
|
useInterceptField,
|
|
299
|
+
// Ref → Accessor hooks
|
|
300
|
+
useField,
|
|
301
|
+
useHasMany,
|
|
302
|
+
useHasOne,
|
|
294
303
|
// Contember
|
|
295
304
|
ContemberBindxProvider,
|
|
296
305
|
schemaNamesToDef,
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import type { SchemaRegistry } from '@contember/bindx'
|
|
2
2
|
import { SelectionScope, generatePlaceholderId } from '@contember/bindx'
|
|
3
3
|
import {
|
|
4
|
-
type EntityRef,
|
|
5
4
|
type EntityAccessor,
|
|
6
5
|
type EntityFields,
|
|
7
6
|
type FieldRef,
|
|
7
|
+
type FieldAccessor,
|
|
8
8
|
type HasManyRef,
|
|
9
|
+
type HasManyAccessor,
|
|
9
10
|
type HasOneRef,
|
|
11
|
+
type HasOneAccessor,
|
|
10
12
|
FIELD_REF_META,
|
|
11
13
|
SCOPE_REF,
|
|
12
14
|
} from './types.js'
|
|
13
15
|
import { wrapEntityRefWithFieldAccessProxy } from './proxyShared.js'
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
|
-
* Combined ref type for collector that satisfies all
|
|
18
|
+
* Combined ref type for collector that satisfies all accessor interfaces.
|
|
19
|
+
* The collector needs to provide .value, .items, .length, .map, .$state, etc.
|
|
17
20
|
*/
|
|
18
|
-
type CollectorRef =
|
|
21
|
+
type CollectorRef = FieldAccessor<unknown> & HasManyAccessor<unknown> & HasOneAccessor<unknown>
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* Creates a collector proxy for the collection phase.
|
|
@@ -32,7 +35,7 @@ export function createCollectorProxy<T>(
|
|
|
32
35
|
schemaRegistry: SchemaRegistry<Record<string, object>> | null = null,
|
|
33
36
|
): EntityAccessor<T> {
|
|
34
37
|
const fieldsProxy = new Proxy({} as EntityFields<T>, {
|
|
35
|
-
get(_, fieldName: string):
|
|
38
|
+
get(_, fieldName: string): FieldAccessor<unknown> | HasManyAccessor<unknown> | HasOneAccessor<unknown> {
|
|
36
39
|
// Return a collector ref that works for all field types
|
|
37
40
|
// The actual type (scalar/hasMany/hasOne) will be determined
|
|
38
41
|
// by how it's used in components or by schema lookup
|
|
@@ -42,7 +45,7 @@ export function createCollectorProxy<T>(
|
|
|
42
45
|
|
|
43
46
|
const noop = () => () => {}
|
|
44
47
|
|
|
45
|
-
const ref
|
|
48
|
+
const ref = {
|
|
46
49
|
id: '__collector__',
|
|
47
50
|
$fields: fieldsProxy,
|
|
48
51
|
$data: null,
|
|
@@ -55,7 +58,7 @@ export function createCollectorProxy<T>(
|
|
|
55
58
|
|
|
56
59
|
__schema: {} as Record<string, object>,
|
|
57
60
|
// Error properties (stubs for collection phase)
|
|
58
|
-
$errors: [],
|
|
61
|
+
$errors: [] as readonly never[],
|
|
59
62
|
$hasError: false,
|
|
60
63
|
$addError: () => {},
|
|
61
64
|
$clearErrors: () => {},
|
|
@@ -10,7 +10,6 @@ import type { ReactNode, ComponentType } from 'react'
|
|
|
10
10
|
import type {
|
|
11
11
|
EntityRef,
|
|
12
12
|
EntityAccessor,
|
|
13
|
-
EntityAccessorBase,
|
|
14
13
|
FluentFragment,
|
|
15
14
|
SelectionBuilder,
|
|
16
15
|
AnyBrand,
|
|
@@ -229,7 +228,7 @@ export type SetScalarProps<
|
|
|
229
228
|
* - Allows direct field access: `entity.fieldName.value`
|
|
230
229
|
* - Allows relation access: `entity.relation.length`, `entity.relation.$entity`
|
|
231
230
|
*
|
|
232
|
-
* For implicit selection (no selector): Returns
|
|
231
|
+
* For implicit selection (no selector): Returns EntityRef with restricted access
|
|
233
232
|
* - Blocks direct field access to enforce declarative patterns
|
|
234
233
|
* - Users must use components: `<Field field={entity.fieldName} />`
|
|
235
234
|
* - Users must use condition DSL: `<If condition={cond.hasItems(entity.relation)} />`
|
|
@@ -244,14 +243,14 @@ export type BuildEntityProps<
|
|
|
244
243
|
infer TIsImplicit
|
|
245
244
|
>
|
|
246
245
|
? TIsImplicit extends true
|
|
247
|
-
// Implicit selection -> restricted
|
|
248
|
-
?
|
|
246
|
+
// Implicit selection -> restricted EntityRef (no .value, .length access)
|
|
247
|
+
? EntityRef<TEntity, TSelected, AnyBrand, string>
|
|
249
248
|
// Explicit selection -> full EntityAccessor (full access)
|
|
250
249
|
: EntityAccessor<TEntity, TSelected, AnyBrand, string>
|
|
251
250
|
: TEntityProps[K] extends InterfaceEntityPropConfig<infer TInterface, infer TIsImplicit>
|
|
252
251
|
? TIsImplicit extends true
|
|
253
252
|
// Implicit interface -> restricted
|
|
254
|
-
?
|
|
253
|
+
? EntityRef<TInterface, TInterface, AnyBrand, string>
|
|
255
254
|
// Explicit interface -> full access
|
|
256
255
|
: EntityAccessor<TInterface, TInterface, AnyBrand, string>
|
|
257
256
|
: never
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memo, type ReactElement } from 'react'
|
|
2
|
-
import type { FieldProps, SelectionFieldMeta, SelectionProvider
|
|
2
|
+
import type { FieldProps, SelectionFieldMeta, SelectionProvider } from '../types.js'
|
|
3
3
|
import { FIELD_REF_META, BINDX_COMPONENT } from '../types.js'
|
|
4
|
+
import { useField } from '../../hooks/useField.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Field component - renders a scalar field value
|
|
@@ -25,24 +26,23 @@ function FieldImpl<T>({ field, children, format }: FieldProps<T>): ReactElement
|
|
|
25
26
|
return null
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const fullField = field as FieldRef<T>
|
|
29
|
+
// useField() subscribes to store and returns FieldAccessor with .value access
|
|
30
|
+
const accessor = useField(field)
|
|
31
31
|
|
|
32
32
|
if (children) {
|
|
33
|
-
return <>{children(
|
|
33
|
+
return <>{children(accessor)}</>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (format) {
|
|
37
|
-
return <>{format(
|
|
37
|
+
return <>{format(accessor.value)}</>
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// Default: render value as string
|
|
41
|
-
if (
|
|
41
|
+
if (accessor.value === null || accessor.value === undefined) {
|
|
42
42
|
return null
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return <>{String(
|
|
45
|
+
return <>{String(accessor.value)}</>
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export const Field = memo(FieldImpl) as typeof FieldImpl
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo, type ReactElement, type ReactNode } from 'react'
|
|
2
|
-
import type { HasManyProps, SelectionFieldMeta, SelectionMeta, SelectionProvider,
|
|
2
|
+
import type { HasManyProps, SelectionFieldMeta, SelectionMeta, SelectionProvider, AnyBrand } from '../types.js'
|
|
3
3
|
import { FIELD_REF_META, BINDX_COMPONENT, SCOPE_REF } from '../types.js'
|
|
4
4
|
import { mergeSelections } from '../SelectionMeta.js'
|
|
5
|
-
import { SelectionScope, generateHasManyAlias } from '@contember/bindx'
|
|
5
|
+
import { SelectionScope, generateHasManyAlias, type HasManyAccessor } from '@contember/bindx'
|
|
6
|
+
import { useHasMany } from '../../hooks/useHasMany.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* HasMany component - renders a has-many relation
|
|
@@ -35,10 +36,9 @@ function HasManyImpl<
|
|
|
35
36
|
TEntityName extends string = string,
|
|
36
37
|
TSchema extends Record<string, object> = Record<string, object>,
|
|
37
38
|
>({ field, children }: HasManyProps<TEntity, TSelected, TBrand, TEntityName, TSchema>): ReactElement {
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const items = fullField.map((item, index) => {
|
|
39
|
+
// useHasMany() subscribes to store and returns HasManyAccessor with .map()/.items/.length
|
|
40
|
+
const accessor = useHasMany(field)
|
|
41
|
+
const items = accessor.map((item, index) => {
|
|
42
42
|
return <React.Fragment key={item.id}>{children(item, index)}</React.Fragment>
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -55,8 +55,8 @@ hasManyWithSelection.getSelection = (
|
|
|
55
55
|
collectNested: (children: ReactNode) => SelectionMeta,
|
|
56
56
|
): SelectionFieldMeta => {
|
|
57
57
|
const meta = props.field[FIELD_REF_META]
|
|
58
|
-
//
|
|
59
|
-
const fullField = props.field as
|
|
58
|
+
// During collection, field is a collector proxy with all accessor properties
|
|
59
|
+
const fullField = props.field as unknown as HasManyAccessor<unknown>
|
|
60
60
|
|
|
61
61
|
// Use field's map function to get a properly configured collector with schema info
|
|
62
62
|
// The map() creates a collector that knows about entity types and relations
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { memo, type ReactElement, type ReactNode } from 'react'
|
|
2
|
-
import type { HasOneProps, SelectionFieldMeta, SelectionMeta, SelectionProvider, AnyBrand
|
|
2
|
+
import type { HasOneProps, SelectionFieldMeta, SelectionMeta, SelectionProvider, AnyBrand } from '../types.js'
|
|
3
3
|
import { FIELD_REF_META, BINDX_COMPONENT, SCOPE_REF } from '../types.js'
|
|
4
4
|
import { mergeSelections } from '../SelectionMeta.js'
|
|
5
|
-
import { SelectionScope } from '@contember/bindx'
|
|
5
|
+
import { SelectionScope, type HasOneAccessor } from '@contember/bindx'
|
|
6
|
+
import { useHasOne } from '../../hooks/useHasOne.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* HasOne component - renders a has-one relation
|
|
@@ -26,11 +27,10 @@ function HasOneImpl<
|
|
|
26
27
|
TEntityName extends string = string,
|
|
27
28
|
TSchema extends Record<string, object> = Record<string, object>,
|
|
28
29
|
>({ field, children }: HasOneProps<TEntity, TSelected, TBrand, TEntityName, TSchema>): ReactElement {
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
const fullField = field as HasOneRef<TEntity, TSelected, TBrand, TEntityName, TSchema>
|
|
30
|
+
// useHasOne() subscribes to store and returns HasOneAccessor with .$entity
|
|
31
|
+
const accessor = useHasOne(field)
|
|
32
32
|
// Get the related entity reference (always available, may be placeholder with id=null)
|
|
33
|
-
return <>{children(
|
|
33
|
+
return <>{children(accessor.$entity)}</>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export const HasOne = memo(HasOneImpl) as typeof HasOneImpl
|
|
@@ -43,8 +43,8 @@ hasOneWithSelection.getSelection = (
|
|
|
43
43
|
collectNested: (children: ReactNode) => SelectionMeta,
|
|
44
44
|
): SelectionFieldMeta => {
|
|
45
45
|
const meta = props.field[FIELD_REF_META]
|
|
46
|
-
//
|
|
47
|
-
const fullField = props.field as
|
|
46
|
+
// During collection, field is a collector proxy with all accessor properties
|
|
47
|
+
const fullField = props.field as unknown as HasOneAccessor<unknown>
|
|
48
48
|
|
|
49
49
|
// Use field's $entity which has a properly configured scope with schema info
|
|
50
50
|
const nestedCollector = fullField.$entity
|
|
@@ -2,6 +2,7 @@ import React, { memo, type ReactElement, type ReactNode } from 'react'
|
|
|
2
2
|
import type { IfProps, SelectionFieldMeta, SelectionMeta, SelectionProvider, FieldRef } from '../types.js'
|
|
3
3
|
import { FIELD_REF_META, BINDX_COMPONENT } from '../types.js'
|
|
4
4
|
import { mergeSelections, createEmptySelection } from '../SelectionMeta.js'
|
|
5
|
+
import { useField } from '../../hooks/useField.js'
|
|
5
6
|
import {
|
|
6
7
|
type Condition,
|
|
7
8
|
isCondition,
|
|
@@ -52,17 +53,17 @@ import {
|
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
55
|
function IfImpl({ condition, then: thenBranch, else: elseBranch }: IfProps): ReactElement | null {
|
|
56
|
+
const fieldRef = typeof condition !== 'boolean' && !isCondition(condition) ? condition : null
|
|
57
|
+
const fieldAccessor = useField(fieldRef)
|
|
58
|
+
|
|
55
59
|
let conditionValue: boolean
|
|
56
60
|
|
|
57
61
|
if (typeof condition === 'boolean') {
|
|
58
|
-
// Boolean literal
|
|
59
62
|
conditionValue = condition
|
|
60
63
|
} else if (isCondition(condition)) {
|
|
61
|
-
// Condition DSL object
|
|
62
64
|
conditionValue = evaluateCondition(condition)
|
|
63
65
|
} else {
|
|
64
|
-
|
|
65
|
-
conditionValue = (condition as FieldRef<boolean>).value ?? false
|
|
66
|
+
conditionValue = fieldAccessor?.value ?? false
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
return conditionValue ? <>{thenBranch}</> : <>{elseBranch ?? null}</>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { memo, type ReactElement, type ReactNode } from 'react'
|
|
2
|
-
import type { FieldRef, SelectionFieldMeta, SelectionMeta, SelectionProvider } from '../types.js'
|
|
2
|
+
import type { FieldRef, FieldAccessor, SelectionFieldMeta, SelectionMeta, SelectionProvider } from '../types.js'
|
|
3
3
|
import { FIELD_REF_META, BINDX_COMPONENT } from '../types.js'
|
|
4
|
+
import { useField } from '../../hooks/useField.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Props for Show component
|
|
@@ -27,11 +28,14 @@ export interface ShowProps<T> {
|
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
29
30
|
function ShowImpl<T>({ field, children, fallback }: ShowProps<T>): ReactElement | null {
|
|
30
|
-
|
|
31
|
+
// useField() subscribes to store and returns FieldAccessor with .value access
|
|
32
|
+
const accessor = useField(field)
|
|
33
|
+
|
|
34
|
+
if (accessor.value === null || accessor.value === undefined) {
|
|
31
35
|
return fallback ? <>{fallback}</> : null
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
return <>{children(
|
|
38
|
+
return <>{children(accessor.value as NonNullable<T>)}</>
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
export const Show = memo(ShowImpl) as typeof ShowImpl
|
package/src/jsx/conditions.ts
CHANGED
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
|
|
32
32
|
import type {
|
|
33
33
|
FieldRef,
|
|
34
|
-
|
|
34
|
+
FieldAccessor,
|
|
35
35
|
HasManyRef,
|
|
36
|
-
|
|
36
|
+
HasManyAccessor,
|
|
37
37
|
HasOneRef,
|
|
38
|
-
|
|
38
|
+
HasOneAccessor,
|
|
39
39
|
} from '@contember/bindx'
|
|
40
40
|
|
|
41
41
|
// ============================================================================
|
|
@@ -74,19 +74,19 @@ export interface Condition {
|
|
|
74
74
|
// ============================================================================
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Base type for scalar fields - accepts
|
|
77
|
+
* Base type for scalar fields - accepts FieldRef (pointer, no .value).
|
|
78
78
|
*/
|
|
79
|
-
type AnyScalarField<T> =
|
|
79
|
+
type AnyScalarField<T> = FieldRef<T>
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* Base type for has-many - accepts
|
|
82
|
+
* Base type for has-many - accepts HasManyRef (pointer, no .items/.length/.map).
|
|
83
83
|
*/
|
|
84
|
-
type AnyHasManyField =
|
|
84
|
+
type AnyHasManyField = HasManyRef<any, any, any, any, any>
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Base type for has-one - accepts
|
|
87
|
+
* Base type for has-one - accepts HasOneRef (pointer).
|
|
88
88
|
*/
|
|
89
|
-
type AnyHasOneField =
|
|
89
|
+
type AnyHasOneField = HasOneRef<any, any, any, any, any>
|
|
90
90
|
|
|
91
91
|
// ============================================================================
|
|
92
92
|
// Condition Builder Object
|
|
@@ -139,7 +139,7 @@ export const cond = {
|
|
|
139
139
|
[CONDITION_META]: {
|
|
140
140
|
type: 'hasItems',
|
|
141
141
|
fields: [field],
|
|
142
|
-
evaluate: () => (field as
|
|
142
|
+
evaluate: () => (field as unknown as HasManyAccessor<any>).length > 0,
|
|
143
143
|
},
|
|
144
144
|
}
|
|
145
145
|
},
|
|
@@ -162,7 +162,7 @@ export const cond = {
|
|
|
162
162
|
[CONDITION_META]: {
|
|
163
163
|
type: 'isEmpty',
|
|
164
164
|
fields: [field],
|
|
165
|
-
evaluate: () => (field as
|
|
165
|
+
evaluate: () => (field as unknown as HasManyAccessor<any>).length === 0,
|
|
166
166
|
},
|
|
167
167
|
}
|
|
168
168
|
},
|
|
@@ -187,7 +187,7 @@ export const cond = {
|
|
|
187
187
|
[CONDITION_META]: {
|
|
188
188
|
type: 'isConnected',
|
|
189
189
|
fields: [field],
|
|
190
|
-
evaluate: () => (field as
|
|
190
|
+
evaluate: () => (field as unknown as HasOneAccessor<any>).$state === 'connected',
|
|
191
191
|
},
|
|
192
192
|
}
|
|
193
193
|
},
|
|
@@ -210,7 +210,7 @@ export const cond = {
|
|
|
210
210
|
[CONDITION_META]: {
|
|
211
211
|
type: 'isDisconnected',
|
|
212
212
|
fields: [field],
|
|
213
|
-
evaluate: () => (field as
|
|
213
|
+
evaluate: () => (field as unknown as HasOneAccessor<any>).$state === 'disconnected',
|
|
214
214
|
},
|
|
215
215
|
}
|
|
216
216
|
},
|
|
@@ -236,7 +236,7 @@ export const cond = {
|
|
|
236
236
|
[CONDITION_META]: {
|
|
237
237
|
type: 'eq',
|
|
238
238
|
fields: [field],
|
|
239
|
-
evaluate: () => (field as
|
|
239
|
+
evaluate: () => (field as unknown as FieldAccessor<T>).value === value,
|
|
240
240
|
},
|
|
241
241
|
}
|
|
242
242
|
},
|
|
@@ -260,7 +260,7 @@ export const cond = {
|
|
|
260
260
|
[CONDITION_META]: {
|
|
261
261
|
type: 'neq',
|
|
262
262
|
fields: [field],
|
|
263
|
-
evaluate: () => (field as
|
|
263
|
+
evaluate: () => (field as unknown as FieldAccessor<T>).value !== value,
|
|
264
264
|
},
|
|
265
265
|
}
|
|
266
266
|
},
|
|
@@ -283,7 +283,7 @@ export const cond = {
|
|
|
283
283
|
[CONDITION_META]: {
|
|
284
284
|
type: 'isNull',
|
|
285
285
|
fields: [field],
|
|
286
|
-
evaluate: () => (field as
|
|
286
|
+
evaluate: () => (field as unknown as FieldAccessor<T>).value === null,
|
|
287
287
|
},
|
|
288
288
|
}
|
|
289
289
|
},
|
|
@@ -306,7 +306,7 @@ export const cond = {
|
|
|
306
306
|
[CONDITION_META]: {
|
|
307
307
|
type: 'isNotNull',
|
|
308
308
|
fields: [field],
|
|
309
|
-
evaluate: () => (field as
|
|
309
|
+
evaluate: () => (field as unknown as FieldAccessor<T>).value !== null,
|
|
310
310
|
},
|
|
311
311
|
}
|
|
312
312
|
},
|
|
@@ -329,7 +329,7 @@ export const cond = {
|
|
|
329
329
|
[CONDITION_META]: {
|
|
330
330
|
type: 'isTruthy',
|
|
331
331
|
fields: [field],
|
|
332
|
-
evaluate: () => Boolean((field as
|
|
332
|
+
evaluate: () => Boolean((field as unknown as FieldAccessor<T>).value),
|
|
333
333
|
},
|
|
334
334
|
}
|
|
335
335
|
},
|
|
@@ -352,7 +352,7 @@ export const cond = {
|
|
|
352
352
|
[CONDITION_META]: {
|
|
353
353
|
type: 'isFalsy',
|
|
354
354
|
fields: [field],
|
|
355
|
-
evaluate: () => !(field as
|
|
355
|
+
evaluate: () => !(field as unknown as FieldAccessor<T>).value,
|
|
356
356
|
},
|
|
357
357
|
}
|
|
358
358
|
},
|
package/src/jsx/index.ts
CHANGED
|
@@ -4,24 +4,20 @@ export {
|
|
|
4
4
|
FIELD_REF_META,
|
|
5
5
|
SCOPE_REF,
|
|
6
6
|
type FieldRefMeta,
|
|
7
|
-
//
|
|
7
|
+
// Ref types (pointer, no data access)
|
|
8
8
|
type FieldRef,
|
|
9
9
|
type HasManyRef,
|
|
10
10
|
type HasOneRef,
|
|
11
|
-
type HasOneAccessor,
|
|
12
11
|
type EntityRef,
|
|
12
|
+
// Accessor types (live data access, extends Ref)
|
|
13
|
+
type FieldAccessor,
|
|
14
|
+
type HasManyAccessor,
|
|
15
|
+
type HasOneAccessor,
|
|
13
16
|
type EntityAccessor,
|
|
14
|
-
// Base types
|
|
15
|
-
type FieldRefBase,
|
|
16
|
-
type HasManyRefBase,
|
|
17
|
-
type HasOneRefBase,
|
|
18
|
-
type HasOneAccessorBase,
|
|
19
|
-
type EntityRefBase,
|
|
20
|
-
type EntityAccessorBase,
|
|
21
17
|
// Field mapping types
|
|
22
18
|
type EntityFields,
|
|
23
|
-
type
|
|
24
|
-
type
|
|
19
|
+
type EntityFieldsAccessor,
|
|
20
|
+
type EntityFieldsRef,
|
|
25
21
|
// Component props
|
|
26
22
|
type FieldProps,
|
|
27
23
|
type HasManyProps,
|
package/src/jsx/proxyShared.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type EntityRef,
|
|
3
2
|
type EntityAccessor,
|
|
4
3
|
type EntityFields,
|
|
5
4
|
} from './types.js'
|
|
@@ -11,18 +10,18 @@ import {
|
|
|
11
10
|
*/
|
|
12
11
|
export const ENTITY_ACCESSOR_PROPERTIES = new Set([
|
|
13
12
|
'id',
|
|
14
|
-
'$fields', '$data', '$isDirty', '$persistedId', '$isNew',
|
|
13
|
+
'$fields', '$data', '$isDirty', '$isPersisting', '$persistedId', '$isNew',
|
|
15
14
|
'$errors', '$hasError', '$addError', '$clearErrors', '$clearAllErrors',
|
|
16
15
|
'$on', '$intercept', '$onPersisted', '$interceptPersisting',
|
|
17
|
-
'__entityType', '__entityName',
|
|
16
|
+
'__entityType', '__entityName', '__schema',
|
|
18
17
|
])
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
|
-
* Wraps an
|
|
20
|
+
* Wraps an object with $fields in a Proxy that supports direct field access.
|
|
22
21
|
* - `entity.fieldName` is equivalent to `entity.$fields.fieldName`
|
|
23
22
|
* - Known accessor properties pass through to the target
|
|
24
23
|
*/
|
|
25
|
-
export function wrapEntityRefWithFieldAccessProxy<T>(ref:
|
|
24
|
+
export function wrapEntityRefWithFieldAccessProxy<T>(ref: { $fields: EntityFields<T> } & Record<string | symbol, unknown>): EntityAccessor<T> {
|
|
26
25
|
return new Proxy(ref, {
|
|
27
26
|
get(target, prop) {
|
|
28
27
|
// Symbols - pass through
|
|
@@ -36,7 +35,7 @@ export function wrapEntityRefWithFieldAccessProxy<T>(ref: EntityRef<T>): EntityA
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
// Otherwise, treat as field access
|
|
39
|
-
return target.$fields[prop as keyof EntityFields<T>]
|
|
38
|
+
return (target as { $fields: EntityFields<T> }).$fields[prop as keyof EntityFields<T>]
|
|
40
39
|
},
|
|
41
40
|
}) as EntityAccessor<T>
|
|
42
41
|
}
|
package/src/jsx/types.ts
CHANGED
|
@@ -7,22 +7,16 @@ import type {
|
|
|
7
7
|
ScalarKeys,
|
|
8
8
|
HasManyKeys,
|
|
9
9
|
HasOneKeys,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Full types
|
|
10
|
+
EntityFieldsAccessor,
|
|
11
|
+
EntityFieldsRef,
|
|
13
12
|
FieldRef,
|
|
13
|
+
FieldAccessor,
|
|
14
14
|
HasManyRef,
|
|
15
|
+
HasManyAccessor,
|
|
15
16
|
HasOneRef,
|
|
16
17
|
HasOneAccessor,
|
|
17
18
|
EntityRef,
|
|
18
19
|
EntityAccessor,
|
|
19
|
-
// Base types (for component props - accept both)
|
|
20
|
-
FieldRefBase,
|
|
21
|
-
HasManyRefBase,
|
|
22
|
-
HasOneRefBase,
|
|
23
|
-
HasOneAccessorBase,
|
|
24
|
-
EntityRefBase,
|
|
25
|
-
EntityAccessorBase,
|
|
26
20
|
AnyBrand,
|
|
27
21
|
} from '@contember/bindx'
|
|
28
22
|
import { Condition } from './conditions.js'
|
|
@@ -38,22 +32,16 @@ export type {
|
|
|
38
32
|
ScalarKeys,
|
|
39
33
|
HasManyKeys,
|
|
40
34
|
HasOneKeys,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Full types
|
|
35
|
+
EntityFieldsAccessor,
|
|
36
|
+
EntityFieldsRef,
|
|
44
37
|
FieldRef,
|
|
38
|
+
FieldAccessor,
|
|
45
39
|
HasManyRef,
|
|
40
|
+
HasManyAccessor,
|
|
46
41
|
HasOneRef,
|
|
47
42
|
HasOneAccessor,
|
|
48
43
|
EntityRef,
|
|
49
44
|
EntityAccessor,
|
|
50
|
-
// Base types
|
|
51
|
-
FieldRefBase,
|
|
52
|
-
HasManyRefBase,
|
|
53
|
-
HasOneRefBase,
|
|
54
|
-
HasOneAccessorBase,
|
|
55
|
-
EntityRefBase,
|
|
56
|
-
EntityAccessorBase,
|
|
57
45
|
AnyBrand,
|
|
58
46
|
}
|
|
59
47
|
|
|
@@ -72,11 +60,11 @@ export const SCOPE_REF = Symbol('SCOPE_REF')
|
|
|
72
60
|
|
|
73
61
|
/**
|
|
74
62
|
* Props for Field component.
|
|
75
|
-
* Accepts
|
|
63
|
+
* Accepts FieldRef (pointer, no .value). The component uses useField() to get FieldAccessor.
|
|
76
64
|
*/
|
|
77
65
|
export interface FieldProps<T> {
|
|
78
|
-
field:
|
|
79
|
-
children?: (accessor:
|
|
66
|
+
field: FieldRef<T>
|
|
67
|
+
children?: (accessor: FieldAccessor<T>) => ReactNode
|
|
80
68
|
format?: (value: T | null) => ReactNode
|
|
81
69
|
}
|
|
82
70
|
|
|
@@ -93,7 +81,7 @@ export interface HasManyComponentOptions {
|
|
|
93
81
|
/**
|
|
94
82
|
* Props for HasMany component.
|
|
95
83
|
* Selection-aware: children callback receives EntityAccessor with direct field access.
|
|
96
|
-
* Accepts
|
|
84
|
+
* Accepts HasManyRef (pointer, no .items/.length/.map). The component uses useHasMany() to get HasManyAccessor.
|
|
97
85
|
*
|
|
98
86
|
* @typeParam TEntity - The full entity type
|
|
99
87
|
* @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
|
|
@@ -108,7 +96,7 @@ export interface HasManyProps<
|
|
|
108
96
|
TEntityName extends string = string,
|
|
109
97
|
TSchema extends Record<string, object> = Record<string, object>,
|
|
110
98
|
> {
|
|
111
|
-
field:
|
|
99
|
+
field: HasManyRef<TEntity, TSelected, TBrand, TEntityName, TSchema>
|
|
112
100
|
children: (item: EntityAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>, index: number) => ReactNode
|
|
113
101
|
filter?: unknown
|
|
114
102
|
orderBy?: unknown
|
|
@@ -119,7 +107,7 @@ export interface HasManyProps<
|
|
|
119
107
|
/**
|
|
120
108
|
* Props for HasOne component.
|
|
121
109
|
* Selection-aware: children callback receives EntityAccessor with direct field access.
|
|
122
|
-
* Accepts
|
|
110
|
+
* Accepts HasOneRef (pointer). The component uses useHasOne() to get HasOneAccessor.
|
|
123
111
|
*
|
|
124
112
|
* @typeParam TEntity - The full entity type
|
|
125
113
|
* @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
|
|
@@ -134,7 +122,7 @@ export interface HasOneProps<
|
|
|
134
122
|
TEntityName extends string = string,
|
|
135
123
|
TSchema extends Record<string, object> = Record<string, object>,
|
|
136
124
|
> {
|
|
137
|
-
field:
|
|
125
|
+
field: HasOneRef<TEntity, TSelected, TBrand, TEntityName, TSchema>
|
|
138
126
|
children: (entity: EntityAccessor<TEntity, TSelected, TBrand, TEntityName, TSchema>) => ReactNode
|
|
139
127
|
}
|
|
140
128
|
|