@contember/react-binding 2.0.0-alpha.16 → 2.0.0-alpha.18
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/development/index.cjs +2 -9
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +1 -8
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/accessorPropagation/AccessorProvider.cjs +1 -1
- package/dist/development/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/AccessorProvider.js +1 -1
- package/dist/development/src/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.js +2 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyContext.js.map +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyProvider.js +1 -1
- package/dist/development/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
- package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
- package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
- package/dist/development/src/accessorPropagation/useEntity.cjs +4 -4
- package/dist/development/src/accessorPropagation/useEntity.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useEntity.js +4 -4
- package/dist/development/src/accessorPropagation/useEntity.js.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityKey.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityKey.js.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityList.cjs +3 -3
- package/dist/development/src/accessorPropagation/useEntityList.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityList.js +3 -3
- package/dist/development/src/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
- package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useEntityListSubTree.js +1 -1
- package/dist/development/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/src/accessorPropagation/useEntitySubTree.cjs +1 -1
- package/dist/development/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useEntitySubTree.js +1 -1
- package/dist/development/src/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/src/accessorPropagation/useField.cjs +3 -3
- package/dist/development/src/accessorPropagation/useField.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/useField.js +3 -3
- package/dist/development/src/accessorPropagation/useField.js.map +1 -1
- package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
- package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
- package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
- package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/src/accessorSorting/addEntityAtIndex.cjs +1 -1
- package/dist/development/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
- package/dist/development/src/accessorSorting/addEntityAtIndex.js +1 -1
- package/dist/development/src/accessorSorting/addEntityAtIndex.js.map +1 -1
- package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
- package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
- package/dist/development/src/accessorSorting/repairEntitiesOrder.js +1 -1
- package/dist/development/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/development/src/accessorSorting/sortEntities.cjs +2 -2
- package/dist/development/src/accessorSorting/sortEntities.cjs.map +1 -1
- package/dist/development/src/accessorSorting/sortEntities.js +2 -2
- package/dist/development/src/accessorSorting/sortEntities.js.map +1 -1
- package/dist/development/src/accessorTree/AccessorTree.cjs +16 -6
- package/dist/development/src/accessorTree/AccessorTree.cjs.map +1 -1
- package/dist/development/src/accessorTree/AccessorTree.js +16 -6
- package/dist/development/src/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/src/accessorTree/useDataBinding.cjs +23 -36
- package/dist/development/src/accessorTree/useDataBinding.cjs.map +1 -1
- package/dist/development/src/accessorTree/useDataBinding.js +26 -39
- package/dist/development/src/accessorTree/useDataBinding.js.map +1 -1
- package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
- package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
- package/dist/development/src/accessorTree/useEnvironmentWithSchema.js +31 -0
- package/dist/development/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
- package/dist/development/src/coreComponents/Component.cjs.map +1 -1
- package/dist/development/src/coreComponents/Component.js.map +1 -1
- package/dist/development/src/coreComponents/DataBindingProvider.cjs +4 -14
- package/dist/development/src/coreComponents/DataBindingProvider.cjs.map +1 -1
- package/dist/development/src/coreComponents/DataBindingProvider.js +4 -14
- package/dist/development/src/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/src/coreComponents/EntityListSubTree.cjs +5 -14
- package/dist/development/src/coreComponents/EntityListSubTree.cjs.map +1 -1
- package/dist/development/src/coreComponents/EntityListSubTree.js +5 -14
- package/dist/development/src/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/src/coreComponents/EntitySubTree.cjs +7 -16
- package/dist/development/src/coreComponents/EntitySubTree.cjs.map +1 -1
- package/dist/development/src/coreComponents/EntitySubTree.js +7 -16
- package/dist/development/src/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/src/entityEvents/useDerivedField.cjs +3 -3
- package/dist/development/src/entityEvents/useDerivedField.cjs.map +1 -1
- package/dist/development/src/entityEvents/useDerivedField.js +3 -3
- package/dist/development/src/entityEvents/useDerivedField.js.map +1 -1
- package/dist/development/src/helperComponents/DeferredSubTrees.cjs +2 -3
- package/dist/development/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
- package/dist/development/src/helperComponents/DeferredSubTrees.js +3 -4
- package/dist/development/src/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/src/helperComponents/FieldView.cjs +1 -1
- package/dist/development/src/helperComponents/FieldView.cjs.map +1 -1
- package/dist/development/src/helperComponents/FieldView.js +1 -1
- package/dist/development/src/helperComponents/FieldView.js.map +1 -1
- package/dist/development/src/markers/IncrementalMarkerBuilder.cjs +56 -0
- package/dist/development/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
- package/dist/development/src/markers/IncrementalMarkerBuilder.js +56 -0
- package/dist/development/src/markers/IncrementalMarkerBuilder.js.map +1 -0
- package/dist/development/src/markers/MarkerStaticAnalyzer.cjs +110 -0
- package/dist/development/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
- package/dist/development/src/markers/MarkerStaticAnalyzer.js +110 -0
- package/dist/development/src/markers/MarkerStaticAnalyzer.js.map +1 -0
- package/dist/development/src/markers/MarkerTreeGenerator.cjs +52 -0
- package/dist/development/src/markers/MarkerTreeGenerator.cjs.map +1 -0
- package/dist/development/src/markers/MarkerTreeGenerator.js +52 -0
- package/dist/development/src/markers/MarkerTreeGenerator.js.map +1 -0
- package/dist/production/index.cjs +2 -9
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +1 -8
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/accessorPropagation/AccessorProvider.cjs +1 -1
- package/dist/production/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/AccessorProvider.js +1 -1
- package/dist/production/src/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.js +2 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/production/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/EntityKeyContext.js.map +1 -1
- package/dist/production/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
- package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
- package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
- package/dist/production/src/accessorPropagation/useEntity.cjs +4 -4
- package/dist/production/src/accessorPropagation/useEntity.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useEntity.js +4 -4
- package/dist/production/src/accessorPropagation/useEntity.js.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityKey.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityKey.js.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityList.cjs +3 -3
- package/dist/production/src/accessorPropagation/useEntityList.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityList.js +3 -3
- package/dist/production/src/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
- package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useEntityListSubTree.js +1 -1
- package/dist/production/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/src/accessorPropagation/useEntitySubTree.cjs +1 -1
- package/dist/production/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useEntitySubTree.js +1 -1
- package/dist/production/src/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/src/accessorPropagation/useField.cjs +3 -3
- package/dist/production/src/accessorPropagation/useField.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/useField.js +3 -3
- package/dist/production/src/accessorPropagation/useField.js.map +1 -1
- package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
- package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
- package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
- package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/src/accessorSorting/addEntityAtIndex.cjs +1 -1
- package/dist/production/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
- package/dist/production/src/accessorSorting/addEntityAtIndex.js +1 -1
- package/dist/production/src/accessorSorting/addEntityAtIndex.js.map +1 -1
- package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
- package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
- package/dist/production/src/accessorSorting/repairEntitiesOrder.js +1 -1
- package/dist/production/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/production/src/accessorSorting/sortEntities.cjs +2 -2
- package/dist/production/src/accessorSorting/sortEntities.cjs.map +1 -1
- package/dist/production/src/accessorSorting/sortEntities.js +2 -2
- package/dist/production/src/accessorSorting/sortEntities.js.map +1 -1
- package/dist/production/src/accessorTree/AccessorTree.cjs +3 -1
- package/dist/production/src/accessorTree/AccessorTree.cjs.map +1 -1
- package/dist/production/src/accessorTree/AccessorTree.js +3 -1
- package/dist/production/src/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/src/accessorTree/useDataBinding.cjs +23 -36
- package/dist/production/src/accessorTree/useDataBinding.cjs.map +1 -1
- package/dist/production/src/accessorTree/useDataBinding.js +26 -39
- package/dist/production/src/accessorTree/useDataBinding.js.map +1 -1
- package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
- package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
- package/dist/production/src/accessorTree/useEnvironmentWithSchema.js +31 -0
- package/dist/production/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
- package/dist/production/src/coreComponents/Component.cjs.map +1 -1
- package/dist/production/src/coreComponents/Component.js.map +1 -1
- package/dist/production/src/coreComponents/DataBindingProvider.cjs +3 -5
- package/dist/production/src/coreComponents/DataBindingProvider.cjs.map +1 -1
- package/dist/production/src/coreComponents/DataBindingProvider.js +3 -5
- package/dist/production/src/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/src/coreComponents/EntityListSubTree.cjs +2 -11
- package/dist/production/src/coreComponents/EntityListSubTree.cjs.map +1 -1
- package/dist/production/src/coreComponents/EntityListSubTree.js +2 -11
- package/dist/production/src/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/src/coreComponents/EntitySubTree.cjs +2 -11
- package/dist/production/src/coreComponents/EntitySubTree.cjs.map +1 -1
- package/dist/production/src/coreComponents/EntitySubTree.js +2 -11
- package/dist/production/src/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/src/entityEvents/useDerivedField.cjs +3 -3
- package/dist/production/src/entityEvents/useDerivedField.cjs.map +1 -1
- package/dist/production/src/entityEvents/useDerivedField.js +3 -3
- package/dist/production/src/entityEvents/useDerivedField.js.map +1 -1
- package/dist/production/src/helperComponents/DeferredSubTrees.cjs +2 -3
- package/dist/production/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
- package/dist/production/src/helperComponents/DeferredSubTrees.js +3 -4
- package/dist/production/src/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/src/helperComponents/FieldView.cjs +1 -1
- package/dist/production/src/helperComponents/FieldView.cjs.map +1 -1
- package/dist/production/src/helperComponents/FieldView.js +1 -1
- package/dist/production/src/helperComponents/FieldView.js.map +1 -1
- package/dist/production/src/markers/IncrementalMarkerBuilder.cjs +56 -0
- package/dist/production/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
- package/dist/production/src/markers/IncrementalMarkerBuilder.js +56 -0
- package/dist/production/src/markers/IncrementalMarkerBuilder.js.map +1 -0
- package/dist/production/src/markers/MarkerStaticAnalyzer.cjs +110 -0
- package/dist/production/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
- package/dist/production/src/markers/MarkerStaticAnalyzer.js +110 -0
- package/dist/production/src/markers/MarkerStaticAnalyzer.js.map +1 -0
- package/dist/production/src/markers/MarkerTreeGenerator.cjs +52 -0
- package/dist/production/src/markers/MarkerTreeGenerator.cjs.map +1 -0
- package/dist/production/src/markers/MarkerTreeGenerator.js +52 -0
- package/dist/production/src/markers/MarkerTreeGenerator.js.map +1 -0
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +2 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyProvider.d.ts +2 -1
- package/dist/types/accessorPropagation/EntityKeyProvider.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts +2 -2
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +7 -12
- package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntityKey.d.ts +2 -1
- package/dist/types/accessorPropagation/useEntityKey.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts +1 -2
- package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorSorting/index.d.ts +0 -2
- package/dist/types/accessorSorting/index.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeState.d.ts +1 -4
- package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -2
- package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/index.d.ts +0 -1
- package/dist/types/accessorTree/index.d.ts.map +1 -1
- package/dist/types/accessorTree/useDataBinding.d.ts +6 -2
- package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
- package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts +3 -0
- package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts.map +1 -0
- package/dist/types/coreComponents/Component.d.ts +1 -1
- package/dist/types/coreComponents/Component.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts +8 -8
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/Entity.d.ts +1 -1
- package/dist/types/coreComponents/Entity.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
- package/dist/types/coreComponents/index.d.ts +0 -1
- package/dist/types/coreComponents/index.d.ts.map +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
- package/dist/types/helperComponents/If.d.ts +1 -1
- package/dist/types/helperComponents/If.d.ts.map +1 -1
- package/dist/types/helperComponents/LabelMiddleware.d.ts +1 -1
- package/dist/types/helperComponents/LabelMiddleware.d.ts.map +1 -1
- package/dist/types/helperComponents/StaticRender.d.ts +1 -1
- package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
- package/dist/types/helperComponents/Variable.d.ts +1 -1
- package/dist/types/helperComponents/Variable.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markers/IncrementalMarkerBuilder.d.ts +5 -0
- package/dist/types/markers/IncrementalMarkerBuilder.d.ts.map +1 -0
- package/dist/types/{coreComponents → markers}/MarkerProvider.d.ts +1 -2
- package/dist/types/markers/MarkerProvider.d.ts.map +1 -0
- package/dist/types/markers/MarkerStaticAnalyzer.d.ts +14 -0
- package/dist/types/markers/MarkerStaticAnalyzer.d.ts.map +1 -0
- package/dist/types/markers/MarkerTreeGenerator.d.ts +10 -0
- package/dist/types/markers/MarkerTreeGenerator.d.ts.map +1 -0
- package/dist/types/markers/index.d.ts +3 -0
- package/dist/types/markers/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/accessorPropagation/AccessorProvider.tsx +1 -1
- package/src/accessorPropagation/BindingOperationsContext.ts +1 -0
- package/src/accessorPropagation/EntityKeyContext.ts +2 -1
- package/src/accessorPropagation/EntityKeyProvider.tsx +2 -1
- package/src/accessorPropagation/useAccessorUpdateSubscription.ts +19 -87
- package/src/accessorPropagation/useEntity.ts +4 -4
- package/src/accessorPropagation/useEntityKey.ts +2 -2
- package/src/accessorPropagation/useEntityList.ts +3 -3
- package/src/accessorPropagation/useEntityListSubTree.ts +1 -1
- package/src/accessorPropagation/useEntitySubTree.ts +3 -4
- package/src/accessorPropagation/useField.ts +3 -3
- package/src/accessorSorting/SetOrderFieldOnCreate.tsx +2 -2
- package/src/accessorSorting/addEntityAtIndex.ts +1 -1
- package/src/accessorSorting/index.ts +0 -2
- package/src/accessorSorting/repairEntitiesOrder.ts +1 -1
- package/src/accessorSorting/sortEntities.ts +2 -2
- package/src/accessorTree/AccessorTree.tsx +17 -12
- package/src/accessorTree/AccessorTreeState.ts +1 -4
- package/src/accessorTree/AccessorTreeStateOptions.ts +0 -2
- package/src/accessorTree/index.ts +0 -1
- package/src/accessorTree/useDataBinding.ts +35 -44
- package/src/accessorTree/useEnvironmentWithSchema.ts +31 -0
- package/src/coreComponents/Component.tsx +2 -2
- package/src/coreComponents/DataBindingProvider.tsx +22 -35
- package/src/coreComponents/EntityListSubTree.tsx +4 -18
- package/src/coreComponents/EntitySubTree.tsx +5 -20
- package/src/coreComponents/index.ts +0 -1
- package/src/entityEvents/useDerivedField.ts +3 -3
- package/src/helperComponents/DeferredSubTrees.tsx +1 -5
- package/src/helperComponents/FieldView.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/markers/IncrementalMarkerBuilder.ts +60 -0
- package/src/{coreComponents → markers}/MarkerProvider.ts +2 -2
- package/src/markers/MarkerStaticAnalyzer.ts +132 -0
- package/src/markers/MarkerTreeGenerator.ts +72 -0
- package/src/markers/index.ts +2 -0
- package/src/tsconfig.json +2 -1
- package/src/typings/react-fix.d.ts +12 -0
- package/tests/cases/unit/model/markerTreeGenerator.spec.tsx +44 -9
- package/tests/lib/bindingFactory.ts +1 -1
- package/dist/development/src/MarkerTreeGenerator.cjs +0 -89
- package/dist/development/src/MarkerTreeGenerator.cjs.map +0 -1
- package/dist/development/src/MarkerTreeGenerator.js +0 -89
- package/dist/development/src/MarkerTreeGenerator.js.map +0 -1
- package/dist/development/src/accessorSorting/errors.cjs +0 -10
- package/dist/development/src/accessorSorting/errors.cjs.map +0 -1
- package/dist/development/src/accessorSorting/errors.js +0 -10
- package/dist/development/src/accessorSorting/errors.js.map +0 -1
- package/dist/development/src/accessorSorting/moveEntity.cjs +0 -42
- package/dist/development/src/accessorSorting/moveEntity.cjs.map +0 -1
- package/dist/development/src/accessorSorting/moveEntity.js +0 -42
- package/dist/development/src/accessorSorting/moveEntity.js.map +0 -1
- package/dist/development/src/accessorSorting/useSortedEntities.cjs +0 -80
- package/dist/development/src/accessorSorting/useSortedEntities.cjs.map +0 -1
- package/dist/development/src/accessorSorting/useSortedEntities.js +0 -80
- package/dist/development/src/accessorSorting/useSortedEntities.js.map +0 -1
- package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
- package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
- package/dist/development/src/accessorTree/accessorTreeStateReducer.js +0 -34
- package/dist/development/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
- package/dist/development/src/core/IncrementalMarkerBuilder.cjs +0 -63
- package/dist/development/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
- package/dist/development/src/core/IncrementalMarkerBuilder.js +0 -63
- package/dist/development/src/core/IncrementalMarkerBuilder.js.map +0 -1
- package/dist/production/src/MarkerTreeGenerator.cjs +0 -89
- package/dist/production/src/MarkerTreeGenerator.cjs.map +0 -1
- package/dist/production/src/MarkerTreeGenerator.js +0 -89
- package/dist/production/src/MarkerTreeGenerator.js.map +0 -1
- package/dist/production/src/accessorSorting/errors.cjs +0 -10
- package/dist/production/src/accessorSorting/errors.cjs.map +0 -1
- package/dist/production/src/accessorSorting/errors.js +0 -10
- package/dist/production/src/accessorSorting/errors.js.map +0 -1
- package/dist/production/src/accessorSorting/moveEntity.cjs +0 -42
- package/dist/production/src/accessorSorting/moveEntity.cjs.map +0 -1
- package/dist/production/src/accessorSorting/moveEntity.js +0 -42
- package/dist/production/src/accessorSorting/moveEntity.js.map +0 -1
- package/dist/production/src/accessorSorting/useSortedEntities.cjs +0 -80
- package/dist/production/src/accessorSorting/useSortedEntities.cjs.map +0 -1
- package/dist/production/src/accessorSorting/useSortedEntities.js +0 -80
- package/dist/production/src/accessorSorting/useSortedEntities.js.map +0 -1
- package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
- package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
- package/dist/production/src/accessorTree/accessorTreeStateReducer.js +0 -34
- package/dist/production/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
- package/dist/production/src/core/IncrementalMarkerBuilder.cjs +0 -63
- package/dist/production/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
- package/dist/production/src/core/IncrementalMarkerBuilder.js +0 -63
- package/dist/production/src/core/IncrementalMarkerBuilder.js.map +0 -1
- package/dist/types/MarkerTreeGenerator.d.ts +0 -14
- package/dist/types/MarkerTreeGenerator.d.ts.map +0 -1
- package/dist/types/accessorSorting/errors.d.ts +0 -3
- package/dist/types/accessorSorting/errors.d.ts.map +0 -1
- package/dist/types/accessorSorting/moveEntity.d.ts +0 -4
- package/dist/types/accessorSorting/moveEntity.d.ts.map +0 -1
- package/dist/types/accessorSorting/useSortedEntities.d.ts +0 -5
- package/dist/types/accessorSorting/useSortedEntities.d.ts.map +0 -1
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts +0 -4
- package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +0 -1
- package/dist/types/core/IncrementalMarkerBuilder.d.ts +0 -7
- package/dist/types/core/IncrementalMarkerBuilder.d.ts.map +0 -1
- package/dist/types/coreComponents/MarkerProvider.d.ts.map +0 -1
- package/src/MarkerTreeGenerator.ts +0 -121
- package/src/accessorSorting/errors.ts +0 -9
- package/src/accessorSorting/moveEntity.ts +0 -65
- package/src/accessorSorting/useSortedEntities.ts +0 -102
- package/src/accessorTree/accessorTreeStateReducer.ts +0 -36
- package/src/core/IncrementalMarkerBuilder.ts +0 -64
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-binding",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
"ae:test": "api-extractor run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@contember/binding": "2.0.0-alpha.
|
|
32
|
-
"@contember/
|
|
33
|
-
"@contember/
|
|
34
|
-
"@contember/
|
|
35
|
-
"@contember/react-
|
|
36
|
-
"@contember/
|
|
31
|
+
"@contember/binding": "2.0.0-alpha.18",
|
|
32
|
+
"@contember/binding-common": "2.0.0-alpha.18",
|
|
33
|
+
"@contember/client": "2.0.0-alpha.18",
|
|
34
|
+
"@contember/graphql-client": "2.0.0-alpha.18",
|
|
35
|
+
"@contember/react-client": "2.0.0-alpha.18",
|
|
36
|
+
"@contember/react-utils": "2.0.0-alpha.18",
|
|
37
|
+
"@contember/utilities": "2.0.0-alpha.18"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"react": "^18 || ^19",
|
|
@@ -10,7 +10,7 @@ export interface EntityProviderProps {
|
|
|
10
10
|
|
|
11
11
|
export function AccessorProvider(props: EntityProviderProps) {
|
|
12
12
|
return (
|
|
13
|
-
<EntityKeyContext.Provider value={props.accessor.key}>
|
|
13
|
+
<EntityKeyContext.Provider value={props.accessor.key ?? props.accessor.getAccessor}>
|
|
14
14
|
<EnvironmentContext.Provider value={props.accessor.environment}>{props.children}</EnvironmentContext.Provider>
|
|
15
15
|
</EntityKeyContext.Provider>
|
|
16
16
|
)
|
|
@@ -27,6 +27,7 @@ export const defaultBindingOperations = Object.freeze<BindingOperations<ReactNod
|
|
|
27
27
|
batchDeferredUpdates: getRejecter('batch deferred updates'),
|
|
28
28
|
extendTree: getRejecter('extendTree'),
|
|
29
29
|
persist: getRejecter('persist'),
|
|
30
|
+
fetchData: getRejecter('fetchData'),
|
|
30
31
|
})
|
|
31
32
|
|
|
32
33
|
export const BindingOperationsContext = createContext<BindingOperations<ReactNode>>(defaultBindingOperations)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { EntityAccessor } from '@contember/binding-common'
|
|
1
2
|
import { createContext } from 'react'
|
|
2
3
|
|
|
3
|
-
export const EntityKeyContext = createContext<undefined | string>(undefined)
|
|
4
|
+
export const EntityKeyContext = createContext<undefined | string | (() => EntityAccessor)>(undefined)
|
|
4
5
|
EntityKeyContext.displayName = 'EntityKeyContext'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
2
|
import { EntityKeyContext } from './EntityKeyContext'
|
|
3
|
+
import { EntityAccessor } from '@contember/binding'
|
|
3
4
|
|
|
4
5
|
export interface EntityKeyProviderProps {
|
|
5
|
-
entityKey: string
|
|
6
|
+
entityKey: string | (() => EntityAccessor)
|
|
6
7
|
children: ReactNode
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -1,96 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback, useEffect, useState } from 'react'
|
|
3
|
-
import type { EntityAccessor, EntityListAccessor, FieldAccessor } from '@contember/binding'
|
|
4
|
-
import type { FieldValue } from '@contember/binding'
|
|
5
|
-
|
|
6
|
-
export type ForceAccessorUpdate = () => void
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
7
2
|
|
|
8
3
|
/**
|
|
9
4
|
* It is VERY IMPORTANT for the parameter to be referentially stable!
|
|
10
5
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function useAccessorUpdateSubscription<Value extends FieldValue = FieldValue>(
|
|
20
|
-
getFieldAccessor: () => FieldAccessor<Value>,
|
|
21
|
-
withForceUpdate: true,
|
|
22
|
-
): [FieldAccessor<Value>, ForceAccessorUpdate]
|
|
23
|
-
function useAccessorUpdateSubscription(
|
|
24
|
-
getEntityAccessor: () => EntityAccessor,
|
|
25
|
-
withForceUpdate: true,
|
|
26
|
-
): [EntityAccessor, ForceAccessorUpdate]
|
|
27
|
-
function useAccessorUpdateSubscription(
|
|
28
|
-
getListAccessor: () => EntityListAccessor,
|
|
29
|
-
withForceUpdate: true,
|
|
30
|
-
): [EntityListAccessor, ForceAccessorUpdate]
|
|
31
|
-
function useAccessorUpdateSubscription(
|
|
32
|
-
getAccessor: () => EntityListAccessor | EntityAccessor,
|
|
33
|
-
withForceUpdate: true,
|
|
34
|
-
): [EntityListAccessor | EntityAccessor, ForceAccessorUpdate]
|
|
35
|
-
function useAccessorUpdateSubscription<
|
|
36
|
-
A extends FieldAccessor<Value> | EntityListAccessor | EntityAccessor,
|
|
37
|
-
Value extends FieldValue = FieldValue,
|
|
38
|
-
>(getAccessor: () => A, withForceUpdate?: true): A | [A, ForceAccessorUpdate] {
|
|
39
|
-
// This is *HEAVILY* adopted from https://github.com/facebook/react/blob/master/packages/use-subscription/src/useSubscription.js
|
|
40
|
-
const [state, setState] = useState<{
|
|
41
|
-
accessor: A
|
|
42
|
-
getAccessor: () => A
|
|
43
|
-
}>(() => ({
|
|
44
|
-
accessor: getAccessor(),
|
|
45
|
-
getAccessor,
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
useConstantValueInvariant(withForceUpdate, 'useAccessorUpdateSubscription: cannot change the withForceUpdate value!')
|
|
49
|
-
|
|
50
|
-
let accessor = state.accessor
|
|
51
|
-
|
|
52
|
-
if (state.getAccessor !== getAccessor) {
|
|
53
|
-
setState({
|
|
54
|
-
accessor: getAccessor(),
|
|
55
|
-
getAccessor,
|
|
56
|
-
})
|
|
6
|
+
export const useAccessorUpdateSubscription = <Accessor extends {
|
|
7
|
+
addEventListener: (event: { type: 'update' }, cb: (accessor: Accessor) => void) => () => void
|
|
8
|
+
}>(getAccessor: () => Accessor): [Accessor, {update: () => void}] => {
|
|
9
|
+
const [state, setState] = useState<Accessor>(() => getAccessor())
|
|
10
|
+
const getterRef = useRef(getAccessor)
|
|
11
|
+
|
|
12
|
+
let accessor = state
|
|
13
|
+
if (getterRef.current !== getAccessor) {
|
|
57
14
|
accessor = getAccessor()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let forceUpdate: ForceAccessorUpdate | undefined = undefined
|
|
61
|
-
if (withForceUpdate) {
|
|
62
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
63
|
-
forceUpdate = useCallback(() => {
|
|
64
|
-
setState({
|
|
65
|
-
accessor: getAccessor(),
|
|
66
|
-
getAccessor,
|
|
67
|
-
})
|
|
68
|
-
}, [getAccessor])
|
|
15
|
+
setState(accessor)
|
|
16
|
+
getterRef.current = getAccessor
|
|
69
17
|
}
|
|
70
18
|
|
|
71
19
|
useEffect(() => {
|
|
72
20
|
let isStillSubscribed = true
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
getAccessor().addEventListener as (
|
|
76
|
-
eventType: { type: 'update' },
|
|
77
|
-
handler: (newAccessor: FieldAccessor<Value> | EntityListAccessor | EntityAccessor) => void,
|
|
78
|
-
) => () => void
|
|
79
|
-
)({ type: 'update' }, newAccessor => {
|
|
80
|
-
if (!isStillSubscribed) {
|
|
21
|
+
const unsubscribe = getAccessor().addEventListener({ type: 'update' }, newAccessor => {
|
|
22
|
+
if (!isStillSubscribed || getterRef.current !== getAccessor) {
|
|
81
23
|
return
|
|
82
24
|
}
|
|
83
|
-
|
|
84
|
-
setState(prevState => {
|
|
85
|
-
if (prevState.getAccessor !== getAccessor || prevState.accessor === newAccessor) {
|
|
86
|
-
return prevState
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
accessor: newAccessor as A,
|
|
91
|
-
getAccessor,
|
|
92
|
-
}
|
|
93
|
-
})
|
|
25
|
+
setState(newAccessor)
|
|
94
26
|
})
|
|
95
27
|
|
|
96
28
|
return () => {
|
|
@@ -99,9 +31,9 @@ function useAccessorUpdateSubscription<
|
|
|
99
31
|
}
|
|
100
32
|
}, [getAccessor])
|
|
101
33
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
34
|
+
const update = useCallback(() => {
|
|
35
|
+
setState(getAccessor())
|
|
36
|
+
}, [getAccessor])
|
|
37
|
+
|
|
38
|
+
return [accessor, { update }]
|
|
106
39
|
}
|
|
107
|
-
export { useAccessorUpdateSubscription }
|
|
@@ -22,7 +22,7 @@ function useEntity(...entity: [] | [string | SugaredRelativeSingleEntity | undef
|
|
|
22
22
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
23
23
|
const getEntityAccessor = useCallback(() => getEntityByKey(entityKey), [entityKey, getEntityByKey])
|
|
24
24
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
25
|
-
return useAccessorUpdateSubscription(getEntityAccessor)
|
|
25
|
+
return useAccessorUpdateSubscription(getEntityAccessor)[0]
|
|
26
26
|
}
|
|
27
27
|
const sugaredRelativeSingleEntity = entity[0]
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ function useEntity(...entity: [] | [string | SugaredRelativeSingleEntity | undef
|
|
|
31
31
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
32
32
|
const getEntity = useCallback(() => {
|
|
33
33
|
const parent = getEntityByKey(entityKey)
|
|
34
|
-
return parent.
|
|
34
|
+
return parent.getEntity(relativeSingleEntity!)
|
|
35
35
|
}, [entityKey, getEntityByKey, relativeSingleEntity])
|
|
36
36
|
|
|
37
37
|
if (relativeSingleEntity) {
|
|
@@ -41,11 +41,11 @@ function useEntity(...entity: [] | [string | SugaredRelativeSingleEntity | undef
|
|
|
41
41
|
'Cannot change the length of the hasOneRelation path!',
|
|
42
42
|
)
|
|
43
43
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
44
|
-
const [entity,
|
|
44
|
+
const [entity, { update }] = useAccessorUpdateSubscription(getEntity)
|
|
45
45
|
|
|
46
46
|
if (relativeSingleEntity.hasOneRelationPath.length) {
|
|
47
47
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
|
-
useOnConnectionUpdate(relativeSingleEntity.hasOneRelationPath[0].field,
|
|
48
|
+
useOnConnectionUpdate(relativeSingleEntity.hasOneRelationPath[0].field, update)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return entity
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
|
-
import { BindingError } from '@contember/binding'
|
|
2
|
+
import { BindingError, EntityAccessor } from '@contember/binding'
|
|
3
3
|
import { EntityKeyContext } from './EntityKeyContext'
|
|
4
4
|
|
|
5
|
-
export const useEntityKey = (): string => {
|
|
5
|
+
export const useEntityKey = (): string | (() => EntityAccessor) => {
|
|
6
6
|
const entityKey = useContext(EntityKeyContext)
|
|
7
7
|
|
|
8
8
|
if (entityKey === undefined) {
|
|
@@ -24,7 +24,7 @@ function useEntityList(
|
|
|
24
24
|
const getEntityByKey = useGetEntityByKey()
|
|
25
25
|
const getEntityList = useCallback(() => {
|
|
26
26
|
const parent = getEntityByKey(entityKey)
|
|
27
|
-
return parent.
|
|
27
|
+
return parent.getEntityList(relativeEntityList!)
|
|
28
28
|
}, [entityKey, getEntityByKey, relativeEntityList])
|
|
29
29
|
|
|
30
30
|
if (relativeEntityList) {
|
|
@@ -34,11 +34,11 @@ function useEntityList(
|
|
|
34
34
|
'Cannot change the length of the hasOneRelation path!',
|
|
35
35
|
)
|
|
36
36
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
37
|
-
const [entityList,
|
|
37
|
+
const [entityList, { update }] = useAccessorUpdateSubscription(getEntityList)
|
|
38
38
|
|
|
39
39
|
if (relativeEntityList.hasOneRelationPath.length) {
|
|
40
40
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
|
-
useOnConnectionUpdate(relativeEntityList.hasOneRelationPath[0].field,
|
|
41
|
+
useOnConnectionUpdate(relativeEntityList.hasOneRelationPath[0].field, update)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return entityList
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
|
-
import type { EntityAccessor } from '@contember/binding'
|
|
3
|
-
import
|
|
2
|
+
import type { Alias, EntityAccessor, SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity } from '@contember/binding'
|
|
3
|
+
import { TreeRootId } from '@contember/binding'
|
|
4
4
|
import { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription'
|
|
5
5
|
import { useEntitySubTreeParameters } from './useEntitySubTreeParameters'
|
|
6
6
|
import { useGetEntitySubTree } from './useGetEntitySubTree'
|
|
7
|
-
import { TreeRootId } from '@contember/binding'
|
|
8
7
|
|
|
9
8
|
export const useEntitySubTree = (
|
|
10
9
|
qualifiedSingleEntity: Alias | SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,
|
|
@@ -22,5 +21,5 @@ export const useEntitySubTree = (
|
|
|
22
21
|
// if (typeof parameters !== 'string' && parameters.hasOneRelationPath.length) {
|
|
23
22
|
// throw new BindingError(`useEntitySubTree: cannot use hasOneRelationPath!`)
|
|
24
23
|
// }
|
|
25
|
-
return useAccessorUpdateSubscription(getAccessor)
|
|
24
|
+
return useAccessorUpdateSubscription(getAccessor)[0]
|
|
26
25
|
}
|
|
@@ -26,7 +26,7 @@ function useField<Value extends FieldValue = FieldValue>(
|
|
|
26
26
|
const getEntityByKey = useGetEntityByKey()
|
|
27
27
|
const getField = useCallback(() => {
|
|
28
28
|
const parent = getEntityByKey(entityKey)
|
|
29
|
-
return parent.
|
|
29
|
+
return parent.getField<Value>(relativeSingleField!)
|
|
30
30
|
}, [entityKey, getEntityByKey, relativeSingleField])
|
|
31
31
|
|
|
32
32
|
if (relativeSingleField) {
|
|
@@ -36,11 +36,11 @@ function useField<Value extends FieldValue = FieldValue>(
|
|
|
36
36
|
'Cannot change the length of the hasOneRelation path!',
|
|
37
37
|
)
|
|
38
38
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
39
|
-
const [field,
|
|
39
|
+
const [field, { update }] = useAccessorUpdateSubscription(getField)
|
|
40
40
|
|
|
41
41
|
if (relativeSingleField.hasOneRelationPath.length) {
|
|
42
42
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
43
|
-
useOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field,
|
|
43
|
+
useOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field, update)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
return field
|
|
@@ -53,8 +53,8 @@ export const SetOrderFieldOnCreate = Component<SetOrderFieldOnCreateProps>(
|
|
|
53
53
|
const entities = Array.from(listSubTree)
|
|
54
54
|
const newOrderFieldValue = !entities.length
|
|
55
55
|
? 0
|
|
56
|
-
: (entities[0].
|
|
57
|
-
getAccessor().
|
|
56
|
+
: (entities[0].getField<number>(desugaredOrderField).value ?? 0) + 1
|
|
57
|
+
getAccessor().getField<number>(desugaredOrderField).updateValue(newOrderFieldValue)
|
|
58
58
|
}}
|
|
59
59
|
>
|
|
60
60
|
<SugaredField field={orderField} />
|
|
@@ -13,7 +13,7 @@ export const addEntityAtIndex = (
|
|
|
13
13
|
entityList.createNewEntity((getNewlyAdded, options) => {
|
|
14
14
|
let newlyAdded = getNewlyAdded()
|
|
15
15
|
|
|
16
|
-
const sortableField = newlyAdded.
|
|
16
|
+
const sortableField = newlyAdded.getField<number>(sortableByField)
|
|
17
17
|
|
|
18
18
|
sortableField.updateValue(index)
|
|
19
19
|
newlyAdded = getNewlyAdded()
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export * from './addEntityAtIndex'
|
|
2
2
|
// Deliberately not exporting errors
|
|
3
|
-
export * from './moveEntity'
|
|
4
3
|
export * from './repairEntitiesOrder'
|
|
5
4
|
export * from './SetOrderFieldOnCreate'
|
|
6
5
|
export * from './sortEntities'
|
|
7
|
-
export * from './useSortedEntities'
|
|
8
6
|
|
|
9
7
|
export type { SortedEntities } from './SortedEntities'
|
|
@@ -3,7 +3,7 @@ import { EntityAccessor, RelativeSingleField } from '@contember/binding'
|
|
|
3
3
|
export const repairEntitiesOrder = (sortableByField: RelativeSingleField, sortedEntities: EntityAccessor[]) => {
|
|
4
4
|
for (let i = 0, len = sortedEntities.length; i < len; i++) {
|
|
5
5
|
const entity = sortedEntities[i]
|
|
6
|
-
const orderField = entity.
|
|
6
|
+
const orderField = entity.getField(sortableByField)
|
|
7
7
|
|
|
8
8
|
if (orderField.value !== i) {
|
|
9
9
|
// TODO ideally, this condition should just be `orderField.value === null`
|
|
@@ -8,8 +8,8 @@ export const sortEntities = (
|
|
|
8
8
|
return entities
|
|
9
9
|
}
|
|
10
10
|
return entities.sort((a, b) => {
|
|
11
|
-
const aField = a.
|
|
12
|
-
const bField = b.
|
|
11
|
+
const aField = a.getField<number>(sortByField)
|
|
12
|
+
const bField = b.getField<number>(sortByField)
|
|
13
13
|
|
|
14
14
|
return (aField.value ?? Number.MAX_SAFE_INTEGER) - (bField.value ?? Number.MAX_SAFE_INTEGER)
|
|
15
15
|
})
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import { BindingOperationsProvider, EnvironmentContext } from '../accessorPropagation'
|
|
2
|
+
import { BindingOperationsProvider, EnvironmentContext, TreeRootIdProvider } from '../accessorPropagation'
|
|
3
3
|
import type { AccessorTreeState } from './AccessorTreeState'
|
|
4
4
|
import { AccessorTreeStateContext } from './AccessorTreeStateContext'
|
|
5
5
|
import { DirtinessContext } from './DirtinessContext'
|
|
6
6
|
import { MutationStateContext } from './MutationStateContext'
|
|
7
|
+
import { EntityKeyContext } from '../accessorPropagation/EntityKeyContext'
|
|
7
8
|
|
|
8
9
|
export interface AccessorTreeProps {
|
|
9
10
|
state: AccessorTreeState
|
|
@@ -20,17 +21,21 @@ export const AccessorTree = ({ state, children }: AccessorTreeProps) => {
|
|
|
20
21
|
bindingOperations: undefined,
|
|
21
22
|
}
|
|
22
23
|
return (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
<
|
|
27
|
-
<
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
<TreeRootIdProvider treeRootId={undefined}>
|
|
25
|
+
<EntityKeyContext.Provider value={undefined}>
|
|
26
|
+
<EnvironmentContext.Provider value={state.environment}>
|
|
27
|
+
<AccessorTreeStateContext.Provider value={state}>
|
|
28
|
+
<DirtinessContext.Provider value={stateData.hasUnpersistedChanges}>
|
|
29
|
+
<MutationStateContext.Provider value={stateData.isMutating}>
|
|
30
|
+
<BindingOperationsProvider bindingOperations={stateData.bindingOperations}>
|
|
31
|
+
{children}
|
|
32
|
+
</BindingOperationsProvider>
|
|
33
|
+
</MutationStateContext.Provider>
|
|
34
|
+
</DirtinessContext.Provider>
|
|
35
|
+
</AccessorTreeStateContext.Provider>
|
|
36
|
+
</EnvironmentContext.Provider>
|
|
37
|
+
</EntityKeyContext.Provider>
|
|
38
|
+
</TreeRootIdProvider>
|
|
34
39
|
)
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import type { TreeRootAccessor } from '@contember/binding'
|
|
2
|
-
import {
|
|
2
|
+
import { Environment } from '@contember/binding'
|
|
3
3
|
import { ReactNode } from 'react'
|
|
4
4
|
import { GraphQlClientError } from '@contember/react-client'
|
|
5
5
|
|
|
6
6
|
export interface InitializingAccessorTreeState {
|
|
7
7
|
name: 'initializing'
|
|
8
8
|
environment: Environment
|
|
9
|
-
binding?: DataBinding<ReactNode>
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export interface InitializedAccessorTreeState {
|
|
13
12
|
name: 'initialized'
|
|
14
13
|
environment: Environment
|
|
15
|
-
binding: DataBinding<ReactNode>
|
|
16
14
|
data: TreeRootAccessor<ReactNode>
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
export interface ErrorAccessorTreeState {
|
|
20
18
|
name: 'error'
|
|
21
19
|
environment: Environment
|
|
22
|
-
binding: DataBinding<ReactNode>
|
|
23
20
|
error: GraphQlClientError
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -3,7 +3,6 @@ export * from './AccessorTreeState'
|
|
|
3
3
|
export * from './AccessorTreeStateAction'
|
|
4
4
|
export * from './AccessorTreeStateMetadata'
|
|
5
5
|
export * from './AccessorTreeStateOptions'
|
|
6
|
-
export * from './accessorTreeStateReducer'
|
|
7
6
|
export * from './DirtinessContext'
|
|
8
7
|
export * from './MutationStateContext'
|
|
9
8
|
export * from './useAccessorTreeState'
|
|
@@ -4,40 +4,60 @@ import {
|
|
|
4
4
|
useCurrentSystemGraphQlClient,
|
|
5
5
|
useTenantGraphQlClient,
|
|
6
6
|
} from '@contember/react-client'
|
|
7
|
-
import { ReactNode, useCallback, useEffect,
|
|
8
|
-
import { useEnvironment } from '../accessorPropagation'
|
|
7
|
+
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
9
8
|
import type { TreeRootAccessor } from '@contember/binding'
|
|
10
|
-
import { DataBinding, Environment,
|
|
9
|
+
import { DataBinding, Environment, TreeStore } from '@contember/binding'
|
|
11
10
|
import type { AccessorTreeState } from './AccessorTreeState'
|
|
12
|
-
import type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'
|
|
13
|
-
import { accessorTreeStateReducer } from './accessorTreeStateReducer'
|
|
14
11
|
import { useIsMounted } from '@contember/react-utils'
|
|
15
|
-
import { MarkerTreeGenerator } from '../
|
|
12
|
+
import { MarkerTreeGenerator } from '../markers'
|
|
16
13
|
import ReactDOM from 'react-dom'
|
|
14
|
+
import { useEnvironmentWithSchema } from './useEnvironmentWithSchema'
|
|
15
|
+
import { useEnvironment } from '../accessorPropagation'
|
|
17
16
|
|
|
18
17
|
export const useDataBinding = ({
|
|
19
18
|
children,
|
|
20
19
|
refreshOnPersist,
|
|
21
20
|
skipStateUpdateAfterPersist,
|
|
22
|
-
}:
|
|
21
|
+
}: {
|
|
22
|
+
children?: ReactNode
|
|
23
|
+
refreshOnPersist?: boolean
|
|
24
|
+
skipStateUpdateAfterPersist?: boolean
|
|
25
|
+
}): AccessorTreeState => {
|
|
23
26
|
const contentClient = useCurrentContentGraphQlClient()
|
|
24
27
|
const systemClient = useCurrentSystemGraphQlClient()
|
|
25
28
|
const tenantClient = useTenantGraphQlClient()
|
|
29
|
+
|
|
26
30
|
const environment = useEnvironment()
|
|
31
|
+
const environmentWithSchema = useEnvironmentWithSchema(environment)
|
|
32
|
+
|
|
27
33
|
const currentTreeStore = useRef<TreeStore>()
|
|
28
34
|
const isMountedRef = useIsMounted()
|
|
29
|
-
|
|
35
|
+
|
|
36
|
+
const [state, setState] = useState<AccessorTreeState & { binding?: DataBinding<ReactNode> }>({
|
|
37
|
+
name: 'initializing',
|
|
38
|
+
environment,
|
|
39
|
+
})
|
|
30
40
|
|
|
31
41
|
const resetDataBinding = useCallback((environment: Environment, newStore: boolean) => {
|
|
32
42
|
const onUpdate = (data: TreeRootAccessor<ReactNode>, binding: DataBinding<ReactNode>) => {
|
|
33
43
|
if (isMountedRef.current) {
|
|
34
|
-
|
|
44
|
+
setState(it => it.name === 'error' || it.binding !== binding ? it : {
|
|
45
|
+
name: 'initialized',
|
|
46
|
+
environment,
|
|
47
|
+
binding,
|
|
48
|
+
data,
|
|
49
|
+
})
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
const onError = (error: GraphQlClientError, binding: DataBinding<ReactNode>) => {
|
|
39
54
|
if (isMountedRef.current) {
|
|
40
|
-
|
|
55
|
+
setState(it => it.binding !== binding ? it : {
|
|
56
|
+
name: 'error',
|
|
57
|
+
environment,
|
|
58
|
+
binding,
|
|
59
|
+
error,
|
|
60
|
+
})
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
|
|
@@ -69,45 +89,16 @@ export const useDataBinding = ({
|
|
|
69
89
|
skipStateUpdateAfterPersist: skipStateUpdateAfterPersist ?? false,
|
|
70
90
|
},
|
|
71
91
|
)
|
|
72
|
-
|
|
73
|
-
}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist, skipStateUpdateAfterPersist])
|
|
92
|
+
setState({ binding, environment, name: 'initializing' })
|
|
74
93
|
|
|
75
|
-
|
|
76
|
-
name: 'initializing',
|
|
77
|
-
environment,
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (schema !== undefined) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
(async () => {
|
|
86
|
-
try {
|
|
87
|
-
setSchema(await SchemaLoader.loadSchema(contentClient))
|
|
94
|
+
}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist, skipStateUpdateAfterPersist])
|
|
88
95
|
|
|
89
|
-
} catch (e) {
|
|
90
|
-
if (e instanceof GraphQlClientError) {
|
|
91
|
-
if (e.type === 'aborted') {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
dispatch({
|
|
95
|
-
type: 'failWithError',
|
|
96
|
-
error: e,
|
|
97
|
-
binding: state.binding!,
|
|
98
|
-
})
|
|
99
|
-
} else {
|
|
100
|
-
throw e
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})()
|
|
104
|
-
}, [contentClient, isMountedRef, schema, state.binding])
|
|
105
96
|
|
|
106
97
|
useEffect(() => {
|
|
107
|
-
if (
|
|
108
|
-
resetDataBinding(
|
|
98
|
+
if (environmentWithSchema) {
|
|
99
|
+
resetDataBinding(environmentWithSchema, false)
|
|
109
100
|
}
|
|
110
|
-
}, [resetDataBinding,
|
|
101
|
+
}, [resetDataBinding, environmentWithSchema])
|
|
111
102
|
|
|
112
103
|
useEffect(() => {
|
|
113
104
|
state.binding?.extendTree(children)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import { Environment, Schema, SchemaLoader } from '@contember/binding'
|
|
3
|
+
import { GraphQlClientError } from '@contember/graphql-client'
|
|
4
|
+
import { useCurrentContentGraphQlClient } from '@contember/react-client'
|
|
5
|
+
|
|
6
|
+
export const useEnvironmentWithSchema = (env: Environment): Environment | undefined => {
|
|
7
|
+
const [schema, setSchema] = useState<Schema | undefined>(() => env.hasSchema() ? env.getSchema() : undefined)
|
|
8
|
+
const contentClient = useCurrentContentGraphQlClient()
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (schema !== undefined) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
try {
|
|
16
|
+
setSchema(await SchemaLoader.loadSchema(contentClient))
|
|
17
|
+
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e instanceof GraphQlClientError) {
|
|
20
|
+
if (e.type === 'aborted') {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
throw e
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
})()
|
|
28
|
+
}, [contentClient, schema])
|
|
29
|
+
|
|
30
|
+
return useMemo(() => schema ? env.withSchema(schema) : undefined, [env, schema])
|
|
31
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { memo, NamedExoticComponent, PropsWithChildren,
|
|
1
|
+
import { memo, NamedExoticComponent, PropsWithChildren, ReactNode } from 'react'
|
|
2
2
|
import { useEnvironment } from '../accessorPropagation'
|
|
3
3
|
import type { Environment } from '@contember/binding'
|
|
4
|
-
import type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from '
|
|
4
|
+
import type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from '../markers'
|
|
5
5
|
import { assertNever } from '@contember/utilities'
|
|
6
6
|
|
|
7
7
|
interface EnvironmentAwareFunctionComponent<P> {
|