@contember/binding 1.1.0 → 1.2.0-alpha.1
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/accessorPropagation/AccessorProvider.js +2 -10
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js +2 -6
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js +2 -6
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js +5 -21
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js +2 -6
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js +1 -0
- package/dist/development/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/development/accessorPropagation/useEntity.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useField.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/development/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +13 -57
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorSorting/moveEntity.js.map +1 -1
- package/dist/development/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js +4 -24
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessorTree/RuntimeId.js +1 -1
- package/dist/development/accessorTree/RuntimeId.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +15 -2
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/accessors/EntityListAccessor.js +9 -0
- package/dist/development/accessors/EntityListAccessor.js.map +1 -1
- package/dist/development/accessors/FieldAccessor.js +1 -0
- package/dist/development/accessors/FieldAccessor.js.map +1 -1
- package/dist/development/accessors/TreeRootAccessor.js +3 -0
- package/dist/development/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/development/core/AccessorErrorManager.js +6 -6
- package/dist/development/core/AccessorErrorManager.js.map +1 -1
- package/dist/development/core/Config.js.map +1 -1
- package/dist/development/core/DataBinding.js +25 -16
- package/dist/development/core/DataBinding.js.map +1 -1
- package/dist/development/core/DirtinessTracker.js.map +1 -1
- package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/development/core/EventManager.js +14 -38
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/IncrementalMarkerBuilder.js +5 -5
- package/dist/development/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/development/core/MarkerComparator.js +1 -0
- package/dist/development/core/MarkerComparator.js.map +1 -1
- package/dist/development/core/MarkerMerger.js +1 -0
- package/dist/development/core/MarkerMerger.js.map +1 -1
- package/dist/development/core/MarkerTreeGenerator.js +6 -6
- package/dist/development/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/development/core/MutationGenerator.js +7 -7
- package/dist/development/core/MutationGenerator.js.map +1 -1
- package/dist/development/core/QueryGenerator.js +1 -0
- package/dist/development/core/QueryGenerator.js.map +1 -1
- package/dist/development/core/RealmKeyGenerator.js +4 -2
- package/dist/development/core/RealmKeyGenerator.js.map +1 -1
- package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/development/core/StateInitializer.js +11 -8
- package/dist/development/core/StateInitializer.js.map +1 -1
- package/dist/development/core/TreeAugmenter.js +6 -1
- package/dist/development/core/TreeAugmenter.js.map +1 -1
- package/dist/development/core/TreeParameterMerger.js +26 -0
- package/dist/development/core/TreeParameterMerger.js.map +1 -1
- package/dist/development/core/TreeStore.js +9 -7
- package/dist/development/core/TreeStore.js.map +1 -1
- package/dist/development/core/exceptions/ErrorLocator.js +3 -3
- package/dist/development/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/development/core/exceptions/TreeParameterSugarer.js +2 -2
- package/dist/development/core/operations/EntityOperations.js +3 -1
- package/dist/development/core/operations/EntityOperations.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +1 -21
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/core/schema/SchemaLoader.js +2 -2
- package/dist/development/core/schema/SchemaLoader.js.map +1 -1
- package/dist/development/core/state/StateIterator.js +1 -0
- package/dist/development/core/state/StateIterator.js.map +1 -1
- package/dist/development/coreComponents/Component.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +2 -6
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +5 -6
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +5 -17
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +5 -17
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +9 -33
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +3 -11
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +5 -17
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +5 -17
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js +2 -6
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/Environment.js +3 -0
- package/dist/development/dao/Environment.js.map +1 -1
- package/dist/development/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/FieldHelper.js +1 -1
- package/dist/development/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js +4 -1
- package/dist/development/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +6 -22
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js +2 -6
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js +5 -17
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/If.js +8 -40
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js +2 -6
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js +3 -11
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -1
- package/dist/development/helperComponents/helpers/evaluateCondition.js +1 -0
- package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/development/markers/EntityFieldMarkersContainer.js +1 -0
- package/dist/development/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/development/markers/EntityListSubTreeMarker.js +2 -2
- package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/development/markers/EntitySubTreeMarker.js +2 -2
- package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/development/markers/FieldMarker.js +2 -2
- package/dist/development/markers/FieldMarker.js.map +1 -1
- package/dist/development/markers/HasManyRelationMarker.js +2 -8
- package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/development/markers/HasOneRelationMarker.js +2 -2
- package/dist/development/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/development/queryLanguage/CacheStore.js +1 -1
- package/dist/development/queryLanguage/CacheStore.js.map +1 -1
- package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/development/queryLanguage/Parser.js +9 -10
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +19 -11
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/structures/BijectiveIndexedMap.js +3 -1
- package/dist/development/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/development/structures/LRUCache.js +1 -1
- package/dist/development/structures/LRUCache.js.map +1 -1
- package/dist/development/structures/WeakIdCache.js.map +1 -1
- package/dist/development/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/development/treeParameters/EntityCreationParameters.js +1 -0
- package/dist/development/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/development/treeParameters/LeafField.js.map +1 -1
- package/dist/development/utils/Hashing.js +1 -0
- package/dist/development/utils/Hashing.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeEntityList.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleEntity.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleField.js +1 -0
- package/dist/production/accessorPropagation/useDesugaredRelativeSingleField.js.map +1 -1
- package/dist/production/accessorPropagation/useEntity.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityList.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useField.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntityListSubTree.js.map +1 -1
- package/dist/production/accessorPropagation/useGetEntitySubTree.js.map +1 -1
- package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/production/accessorSorting/moveEntity.js.map +1 -1
- package/dist/production/accessorSorting/repairEntitiesOrder.js.map +1 -1
- package/dist/production/accessorTree/AccessorTree.js +2 -2
- package/dist/production/accessorTree/AccessorTree.js.map +1 -1
- package/dist/production/accessorTree/RuntimeId.js +1 -1
- package/dist/production/accessorTree/RuntimeId.js.map +1 -1
- package/dist/production/accessors/EntityAccessor.js +15 -2
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/accessors/EntityListAccessor.js +9 -0
- package/dist/production/accessors/EntityListAccessor.js.map +1 -1
- package/dist/production/accessors/FieldAccessor.js +1 -0
- package/dist/production/accessors/FieldAccessor.js.map +1 -1
- package/dist/production/accessors/TreeRootAccessor.js +3 -0
- package/dist/production/accessors/TreeRootAccessor.js.map +1 -1
- package/dist/production/core/AccessorErrorManager.js +6 -6
- package/dist/production/core/AccessorErrorManager.js.map +1 -1
- package/dist/production/core/Config.js.map +1 -1
- package/dist/production/core/DataBinding.js +25 -16
- package/dist/production/core/DataBinding.js.map +1 -1
- package/dist/production/core/DirtinessTracker.js.map +1 -1
- package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
- package/dist/production/core/EventManager.js +13 -11
- package/dist/production/core/EventManager.js.map +1 -1
- package/dist/production/core/IncrementalMarkerBuilder.js +5 -5
- package/dist/production/core/IncrementalMarkerBuilder.js.map +1 -1
- package/dist/production/core/MarkerComparator.js +1 -0
- package/dist/production/core/MarkerComparator.js.map +1 -1
- package/dist/production/core/MarkerMerger.js +1 -0
- package/dist/production/core/MarkerMerger.js.map +1 -1
- package/dist/production/core/MarkerTreeGenerator.js +6 -6
- package/dist/production/core/MarkerTreeGenerator.js.map +1 -1
- package/dist/production/core/MutationGenerator.js +7 -7
- package/dist/production/core/MutationGenerator.js.map +1 -1
- package/dist/production/core/QueryGenerator.js +1 -0
- package/dist/production/core/QueryGenerator.js.map +1 -1
- package/dist/production/core/RealmKeyGenerator.js +4 -2
- package/dist/production/core/RealmKeyGenerator.js.map +1 -1
- package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
- package/dist/production/core/StateInitializer.js +11 -8
- package/dist/production/core/StateInitializer.js.map +1 -1
- package/dist/production/core/TreeAugmenter.js +6 -1
- package/dist/production/core/TreeAugmenter.js.map +1 -1
- package/dist/production/core/TreeParameterMerger.js +26 -0
- package/dist/production/core/TreeParameterMerger.js.map +1 -1
- package/dist/production/core/TreeStore.js +9 -7
- package/dist/production/core/TreeStore.js.map +1 -1
- package/dist/production/core/exceptions/ErrorLocator.js +3 -3
- package/dist/production/core/exceptions/ErrorLocator.js.map +1 -1
- package/dist/production/core/exceptions/TreeParameterSugarer.js +2 -2
- package/dist/production/core/operations/EntityOperations.js +3 -1
- package/dist/production/core/operations/EntityOperations.js.map +1 -1
- package/dist/production/core/schema/SchemaLoader.js +2 -2
- package/dist/production/core/schema/SchemaLoader.js.map +1 -1
- package/dist/production/core/state/StateIterator.js +1 -0
- package/dist/production/core/state/StateIterator.js.map +1 -1
- package/dist/production/coreComponents/Component.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/coreComponents/Entity.js +4 -1
- package/dist/production/coreComponents/Entity.js.map +1 -1
- package/dist/production/coreComponents/EntityList.js.map +1 -1
- package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/production/coreComponents/Field.js.map +1 -1
- package/dist/production/coreComponents/HasMany.js.map +1 -1
- package/dist/production/coreComponents/HasOne.js.map +1 -1
- package/dist/production/coreComponents/ParentEntity.js.map +1 -1
- package/dist/production/dao/Environment.js +3 -0
- package/dist/production/dao/Environment.js.map +1 -1
- package/dist/production/entityEvents/useEntityEvent.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/FieldHelper.js +1 -1
- package/dist/production/fieldHelpers/helpers/FieldHelper.js.map +1 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js +4 -1
- package/dist/production/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/production/helperComponents/EntityView.js.map +1 -1
- package/dist/production/helperComponents/FieldView.js.map +1 -1
- package/dist/production/helperComponents/If.js.map +1 -1
- package/dist/production/helperComponents/StaticRender.js.map +1 -1
- package/dist/production/helperComponents/SugaredField.js.map +1 -1
- package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -1
- package/dist/production/helperComponents/helpers/evaluateCondition.js +1 -0
- package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/production/markers/EntityFieldMarkersContainer.js +1 -0
- package/dist/production/markers/EntityFieldMarkersContainer.js.map +1 -1
- package/dist/production/markers/EntityListSubTreeMarker.js +2 -2
- package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
- package/dist/production/markers/EntitySubTreeMarker.js +2 -2
- package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
- package/dist/production/markers/FieldMarker.js +2 -2
- package/dist/production/markers/FieldMarker.js.map +1 -1
- package/dist/production/markers/HasManyRelationMarker.js +2 -2
- package/dist/production/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/production/markers/HasOneRelationMarker.js +2 -2
- package/dist/production/markers/HasOneRelationMarker.js.map +1 -1
- package/dist/production/queryLanguage/CacheStore.js +1 -1
- package/dist/production/queryLanguage/CacheStore.js.map +1 -1
- package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
- package/dist/production/queryLanguage/Parser.js +9 -7
- package/dist/production/queryLanguage/Parser.js.map +1 -1
- package/dist/production/queryLanguage/QueryLanguage.js +19 -8
- package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/production/structures/BijectiveIndexedMap.js +3 -1
- package/dist/production/structures/BijectiveIndexedMap.js.map +1 -1
- package/dist/production/structures/LRUCache.js +1 -1
- package/dist/production/structures/LRUCache.js.map +1 -1
- package/dist/production/structures/WeakIdCache.js.map +1 -1
- package/dist/production/treeParameterHelpers/wrapFilterInHasOnes.js.map +1 -1
- package/dist/production/treeParameters/EntityCreationParameters.js +1 -0
- package/dist/production/treeParameters/EntityCreationParameters.js.map +1 -1
- package/dist/production/treeParameters/LeafField.js.map +1 -1
- package/dist/production/utils/Hashing.js +1 -0
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +0 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts +0 -1
- package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +0 -1
- package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +0 -1
- package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTree.d.ts +7 -4
- package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +0 -1
- package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts +0 -1
- package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts +0 -1
- package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts +10 -0
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/Entity.d.ts +3 -0
- package/dist/types/coreComponents/Entity.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityList.d.ts +3 -0
- package/dist/types/coreComponents/EntityList.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts +10 -0
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts +10 -0
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts +3 -0
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/coreComponents/HasMany.d.ts +3 -0
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
- package/dist/types/coreComponents/HasOne.d.ts +3 -0
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
- package/dist/types/coreComponents/ParentEntity.d.ts +3 -0
- package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
- package/dist/types/helperComponents/DeferredSubTrees.d.ts +3 -0
- package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
- package/dist/types/helperComponents/EntityView.d.ts +3 -0
- package/dist/types/helperComponents/EntityView.d.ts.map +1 -1
- package/dist/types/helperComponents/FieldView.d.ts +13 -0
- package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
- package/dist/types/helperComponents/If.d.ts +3 -0
- package/dist/types/helperComponents/If.d.ts.map +1 -1
- package/dist/types/helperComponents/StaticRender.d.ts +3 -0
- package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts +3 -0
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
- package/dist/types/treeParameters/FieldEventListeners.d.ts +5 -2
- package/dist/types/treeParameters/FieldEventListeners.d.ts.map +1 -1
- package/dist/types/treeParameters/LeafField.d.ts +2 -2
- package/dist/types/treeParameters/LeafField.d.ts.map +1 -1
- package/dist/types/treeParameters/QualifiedFieldList.d.ts +7 -8
- package/dist/types/treeParameters/QualifiedFieldList.d.ts.map +1 -1
- package/dist/types/treeParameters/RelativeSingleField.d.ts +8 -8
- package/dist/types/treeParameters/RelativeSingleField.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/accessorTree/AccessorTree.tsx +4 -1
- package/src/coreComponents/DataBindingProvider.tsx +10 -0
- package/src/coreComponents/Entity.tsx +3 -0
- package/src/coreComponents/EntityList.tsx +3 -0
- package/src/coreComponents/EntityListSubTree.tsx +10 -0
- package/src/coreComponents/EntitySubTree.tsx +10 -0
- package/src/coreComponents/Field.tsx +3 -0
- package/src/coreComponents/HasMany.tsx +3 -0
- package/src/coreComponents/HasOne.tsx +3 -0
- package/src/coreComponents/ParentEntity.tsx +3 -0
- package/src/helperComponents/DeferredSubTrees.tsx +3 -0
- package/src/helperComponents/EntityView.tsx +3 -0
- package/src/helperComponents/FieldView.tsx +13 -0
- package/src/helperComponents/If.tsx +3 -0
- package/src/helperComponents/StaticRender.tsx +3 -0
- package/src/helperComponents/SugaredField.tsx +3 -0
- package/src/helperComponents/helpers/evaluateCondition.ts +1 -1
- package/src/treeParameters/FieldEventListeners.ts +15 -5
- package/src/treeParameters/LeafField.ts +6 -4
- package/src/treeParameters/QualifiedFieldList.ts +24 -17
- package/src/treeParameters/RelativeSingleField.ts +19 -12
- package/src/ambient.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateIterator.js","sources":["../../../../src/core/state/StateIterator.ts"],"sourcesContent":["import { FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../../markers'\nimport type { FieldValue, PlaceholderName } from '../../treeParameters'\nimport { assertNever } from '../../utils'\nimport type { TreeStore } from '../TreeStore'\nimport type { EntityListState } from './EntityListState'\nimport type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState'\nimport type { FieldState } from './FieldState'\nimport { getEntityMarker } from './getEntityMarker'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAUO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAC9C,UAAA,MAAM,SAAS,mBAAmB;AACjC,YAAA,wBAAwB,UAAa,gBAAgB,KAAK,EAAE,OAAO,aAAa,IA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A;AAAA,MACD,KAAK;AACJ;AAAA,MACD;AACC,eAAO,YAAgB;AAAA,IACzB;AACM,UAAA;AAAA,EACP;AAAA,EAEA,QAAe,iBACd,MACA,OAC+B;AAC/B,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAK;AAAA,MACL,KAAK;AACJ,mBAAW,cAAc,KAAK,SAAS,OAAA,GAAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AACnE,mBAAA,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAO,YAAgB;AAAA,IACzB;AACA,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACjC,YAAA;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW;IACnB;AAAA,EACD;AACD;"}
|
|
1
|
+
{"version":3,"file":"StateIterator.js","sources":["../../../../src/core/state/StateIterator.ts"],"sourcesContent":["import { FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '../../markers'\nimport type { FieldValue, PlaceholderName } from '../../treeParameters'\nimport { assertNever } from '../../utils'\nimport type { TreeStore } from '../TreeStore'\nimport type { EntityListState } from './EntityListState'\nimport type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState'\nimport type { FieldState } from './FieldState'\nimport { getEntityMarker } from './getEntityMarker'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAUO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAC9C,UAAA,MAAM,SAAS,mBAAmB;AACjC,YAAA,wBAAwB,UAAa,gBAAgB,KAAK,EAAE,OAAO,aAAa,IAAI,mBAAmB,GAAG;AAC7G,gBAAM,YAAY;AAClB,kBAAQ,MAAM,OAAO,OAAO,IAA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M,UAAA;AAAA,EACP;AAAA,EAEA,QAAe,iBACd,MACA,OAC+B;AAC/B,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAK;AAAA,MACL,KAAK;AACJ,mBAAW,cAAc,KAAK,SAAS,OAAA,GAAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AACnE,mBAAA,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAO,YAAgB;AAAA,IACzB;AACA,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACjC,YAAA;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW;IACnB;AAAA,EACD;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactElement } from 'react'\nimport { useEnvironment } from '../accessorPropagation/useEnvironment'\nimport type { Environment } from '../dao'\nimport { assertNever } from '../utils'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from './MarkerProvider'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactElement<any, any> | null;\n\tdisplayName?: string | undefined;\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (\n\t\tprops: StaticRenderProviderProps<Props, NonStaticPropNames>,\n\t\tenvironment: Environment,\n\t) => ReactElement | null,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactElement | null)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["augmentedRender"],"mappings":";;;AA+BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAO,gBAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfA,UAAAA,mBAAuE,KAAY,aAAa;AACtGA,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2F,KAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../src/coreComponents/Component.tsx"],"sourcesContent":["import { memo, NamedExoticComponent, PropsWithChildren, ReactElement } from 'react'\nimport { useEnvironment } from '../accessorPropagation/useEnvironment'\nimport type { Environment } from '../dao'\nimport { assertNever } from '../utils'\nimport type { MarkerProvider, StaticRenderProvider, StaticRenderProviderProps } from './MarkerProvider'\n\ninterface EnvironmentAwareFunctionComponent<P> {\n\t(props: PropsWithChildren<P>, environment: Environment): ReactElement<any, any> | null;\n\tdisplayName?: string | undefined;\n}\n\nfunction Component<Props extends {}>(\n\tstatelessRender: EnvironmentAwareFunctionComponent<Props>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tstaticRender: (\n\t\tprops: StaticRenderProviderProps<Props, NonStaticPropNames>,\n\t\tenvironment: Environment,\n\t) => ReactElement | null,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\tstatefulRender: EnvironmentAwareFunctionComponent<Props>,\n\tmarkerProvisions: MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n): NamedExoticComponent<Props>\n\nfunction Component<Props extends {}, NonStaticPropNames extends keyof Props = never>(\n\trender: EnvironmentAwareFunctionComponent<Props>,\n\tdecider?:\n\t\t| string\n\t\t| ((props: StaticRenderProviderProps<Props, NonStaticPropNames>, environment: Environment) => ReactElement | null)\n\t\t| MarkerProvider<Props, NonStaticPropNames>,\n\tdisplayName?: string,\n) {\n\tconst RenderWithEnv = (props: Props) => render(props, useEnvironment())\n\tconst renderWithEnv = typeof render !== 'function' || render.length < 2 ? render : RenderWithEnv\n\n\tif (decider === undefined || typeof decider === 'string') {\n\t\trender.displayName = decider\n\t\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props> = memo<Props>(renderWithEnv)\n\t\taugmentedRender.staticRender = render as StaticRenderProvider<Props>['staticRender']\n\t\taugmentedRender.displayName = decider\n\n\t\treturn augmentedRender\n\t}\n\n\trender.displayName = displayName\n\tconst augmentedRender: NamedExoticComponent<Props> & MarkerProvider<Props, NonStaticPropNames> = memo<Props>(renderWithEnv)\n\taugmentedRender.displayName = displayName\n\n\tif (typeof decider === 'function') {\n\t\taugmentedRender.staticRender = decider\n\n\t\treturn augmentedRender\n\t}\n\tif (typeof decider === 'object') {\n\t\tfor (const provisionName in decider) {\n\t\t\tconst methodName = provisionName as keyof MarkerProvider<Props, NonStaticPropNames>\n\t\t\t;(augmentedRender[methodName] as MarkerProvider<Props, NonStaticPropNames>[typeof methodName]) =\n\t\t\t\tdecider[methodName]\n\t\t}\n\n\t\treturn augmentedRender\n\t}\n\tassertNever(decider)\n}\n\nexport type { EnvironmentAwareFunctionComponent }\nexport { Component }\n"],"names":["augmentedRender"],"mappings":";;;AA+BA,SAAS,UACR,QACA,SAIA,aACC;AACD,QAAM,gBAAgB,CAAC,UAAiB,OAAO,OAAO,gBAAgB;AACtE,QAAM,gBAAgB,OAAO,WAAW,cAAc,OAAO,SAAS,IAAI,SAAS;AAEnF,MAAI,YAAY,UAAa,OAAO,YAAY,UAAU;AACzD,WAAO,cAAc;AACfA,UAAAA,mBAAuE,KAAY,aAAa;AACtGA,qBAAgB,eAAe;AAC/BA,qBAAgB,cAAc;AAEvBA,WAAAA;AAAAA,EACR;AAEA,SAAO,cAAc;AACf,QAAA,kBAA2F,KAAY,aAAa;AAC1H,kBAAgB,cAAc;AAE1B,MAAA,OAAO,YAAY,YAAY;AAClC,oBAAgB,eAAe;AAExB,WAAA;AAAA,EACR;AACI,MAAA,OAAO,YAAY,UAAU;AAChC,eAAW,iBAAiB,SAAS;AACpC,YAAM,aAAa;AACjB,sBAAgB,UAAU,IAC3B,QAAQ,UAAU;AAAA,IACpB;AAEO,WAAA;AAAA,EACR;AACA,cAAmB;AACpB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataBindingProvider.js","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> = DataBindingProviderBaseProps &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\t\t\tstateProps?: StateProps\n\t\t }\n\t)\n\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn <AccessorTree state={accessorTreeState}>{children}</AccessorTree>\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["DataBindingProvider"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"DataBindingProvider.js","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> = DataBindingProviderBaseProps &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\t\t\tstateProps?: StateProps\n\t\t }\n\t)\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn <AccessorTree state={accessorTreeState}>{children}</AccessorTree>\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["DataBindingProvider"],"mappings":";;;;AA8BO,MAAM,sBAAsB,KAAK,SAASA,qBAChD,OACC;AACK,QAAA,oBAAoB,eAAe,KAAK;AAE9C,QAAM,WACL,oBAAoB,SAAS,MAAM,iBAChC;AAAA,IACA,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA,IAEN,MAAM;AACV,SAAQ,oBAAA,cAAA,EAAa,OAAO,mBAAoB,SAAS,CAAA;AAC1D,CAAC;"}
|
|
@@ -3,7 +3,10 @@ import { Component } from "./Component.js";
|
|
|
3
3
|
import { AccessorProvider } from "../accessorPropagation/AccessorProvider.js";
|
|
4
4
|
const Entity = Component(
|
|
5
5
|
({ children, accessor }) => {
|
|
6
|
-
return
|
|
6
|
+
return (
|
|
7
|
+
// HACK: the ?. is actually important, despite the typings.
|
|
8
|
+
/* @__PURE__ */ jsx(AccessorProvider, { accessor, children }, accessor?.key)
|
|
9
|
+
);
|
|
7
10
|
},
|
|
8
11
|
"Entity"
|
|
9
12
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sources":["../../../src/coreComponents/Entity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { AccessorProvider } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport { Component } from './Component'\n\nexport interface EntityBaseProps {\n\taccessor: EntityAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityProps = EntityBaseProps\n\nexport const Entity = Component(\n\t({ children, accessor }: EntityProps) => {\n\treturn (\n\t\t// HACK: the ?. is actually important, despite the typings.\n\t\t<AccessorProvider accessor={accessor} key={accessor?.key}>\n\t\t\t{children}\n\t\t</AccessorProvider>\n\t)\n\t},\n\t'Entity',\n)\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Entity.js","sources":["../../../src/coreComponents/Entity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { AccessorProvider } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport { Component } from './Component'\n\nexport interface EntityBaseProps {\n\taccessor: EntityAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityProps = EntityBaseProps\n\n/**\n * @group Data binding\n */\nexport const Entity = Component(\n\t({ children, accessor }: EntityProps) => {\n\treturn (\n\t\t// HACK: the ?. is actually important, despite the typings.\n\t\t<AccessorProvider accessor={accessor} key={accessor?.key}>\n\t\t\t{children}\n\t\t</AccessorProvider>\n\t)\n\t},\n\t'Entity',\n)\n"],"names":[],"mappings":";;;AAeO,MAAM,SAAS;AAAA,EACrB,CAAC,EAAE,UAAU,eAA4B;AACzC;AAAA;AAAA,MAEE,oBAAA,kBAAA,EAAiB,UAChB,SAAA,GADyC,UAAU,GAErD;AAAA;AAAA,EAED;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityList.js","sources":["../../../src/coreComponents/EntityList.tsx"],"sourcesContent":["import { ComponentType, createElement, ReactElement, ReactNode } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\n\nexport interface EntityListBaseProps {\n\taccessor: EntityListAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityListProps<ListProps> = EntityListBaseProps &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityList = Component(\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: props.accessor,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{Array.from(props.accessor, entity => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Entity key={entity.key} accessor={entity}>\n\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t</Entity>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</>\n\t\t)\n\t},\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: undefined as any,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn <>{props.children}</>\n\t},\n\t'EntityList',\n) as <ListProps>(props: EntityListProps<ListProps>) => ReactElement\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"EntityList.js","sources":["../../../src/coreComponents/EntityList.tsx"],"sourcesContent":["import { ComponentType, createElement, ReactElement, ReactNode } from 'react'\nimport type { EntityListAccessor } from '../accessors'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\n\nexport interface EntityListBaseProps {\n\taccessor: EntityListAccessor\n\tchildren?: ReactNode\n}\n\nexport type EntityListProps<ListProps> = EntityListBaseProps &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\n/**\n * @group Data binding\n */\nexport const EntityList = Component(\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: props.accessor,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{Array.from(props.accessor, entity => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Entity key={entity.key} accessor={entity}>\n\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t</Entity>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</>\n\t\t)\n\t},\n\t<ListProps extends {}>(props: EntityListProps<ListProps>) => {\n\t\tif ('listComponent' in props && props.listComponent) {\n\t\t\treturn createElement(props.listComponent, {\n\t\t\t\t...props.listProps!,\n\t\t\t\taccessor: undefined as any,\n\t\t\t\tchildren: props.children,\n\t\t\t})\n\t\t}\n\t\treturn <>{props.children}</>\n\t},\n\t'EntityList',\n) as <ListProps>(props: EntityListProps<ListProps>) => ReactElement\n"],"names":[],"mappings":";;;;AAsBO,MAAM,aAAa;AAAA,EACzB,CAAuB,UAAsC;AACxD,QAAA,mBAAmB,SAAS,MAAM,eAAe;AAC7C,aAAA,cAAc,MAAM,eAAe;AAAA,QACzC,GAAG,MAAM;AAAA,QACT,UAAU,MAAM;AAAA,QAChB,UAAU,MAAM;AAAA,MAAA,CAChB;AAAA,IACF;AACA,WAEG,oBAAA,UAAA,EAAA,UAAA,MAAM,KAAK,MAAM,UAAU,CAAU,WAAA;AACrC,iCACE,QAAwB,EAAA,UAAU,QACjC,UAAM,MAAA,SAAA,GADK,OAAO,GAEpB;AAAA,IAED,CAAA,EACF,CAAA;AAAA,EAEF;AAAA,EACA,CAAuB,UAAsC;AACxD,QAAA,mBAAmB,SAAS,MAAM,eAAe;AAC7C,aAAA,cAAc,MAAM,eAAe;AAAA,QACzC,GAAG,MAAM;AAAA,QACT,UAAU;AAAA,QACV,UAAU,MAAM;AAAA,MAAA,CAChB;AAAA,IACF;AACO,WAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAAA,EAC1B;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n\t(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n\t(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;AA2CO,MAAM,oBAAoB;AAAA,EAChC,CAAyB,UAA0D;AACxD,8BAAA,MAAM,YAAY,6CAA6C;AAEzF,UAAM,aAAa;AACb,UAAA,aAAa,+BAA+B,KAAK;AACvD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,oBAAA,YAAA,EAAY,GAAG,OAAO,SAAoB,CAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,cAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;;;;;;AA4CO,MAAM,gBAAgB;AAAA,EAC5B,CAAyB,UAA2C;AACzC,8BAAA,MAAM,YAAY,yCAAyC;AAErF,UAAM,aAAa;AACb,UAAA,aAAa,2BAA2B,KAAK;AACnD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,SAAoB,CAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAO,cAAc,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZ,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA,qBAAC,QAAQ,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,GACR;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpC;AAAA,QAAC;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,MACf;AAAA,IAAA,GAEF;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\n/**\n * @group Data binding\n */\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;;;;AAqBO,MAAM,QAAQ;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQ,SAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAAE,CAAA;AAAA,IACrC;AAGC,QAAA,MAAM,iBAAiB,eAAe,kBACtC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAA,oBAAA,UAAA,EAAG,gBAAM,MAAM,CAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAA,2BAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\n/**\n * @group Data binding\n */\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAyBO,MAAM,UAAU;AAAA,EACtB,CAAyB,UAAgD;AAClE,UAAA,aAAa,cAAc,KAAK;AAEtC,WAAQ,oBAAA,YAAA,EAAY,GAAG,OAAO,UAAU,WAAY,CAAA;AAAA,EACrD;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,+BAA+B,aAAa,KAAK;AAAA,IACpF;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,cAAY,GAAG,OAAO,UAAU,QAChC,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,+BAA+B,OAAO,aAAa,MAAM;AAAA,EACzE;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\n/**\n * @group Data binding\n */\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAmBO,MAAM,SAAS;AAAA,EACrB,CAAyB,UAAoC;AACtD,UAAA,SAAS,UAAU,KAAK;AAE9B,WAAQ,oBAAA,QAAA,EAAQ,GAAG,OAAO,UAAU,OAAQ,CAAA;AAAA,EAC7C;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,2BAA2B,aAAa,KAAK;AAAA,IAChF;AAAA,IACA,cAAc,CACb,UAAA,qBAAC,UAAQ,GAAG,OAAO,UAAU,QAC5B,UAAA;AAAA,MAAC,oBAAA,OAAA,EAAM,OAAO,iBAAkB,CAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,GACR;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa,MAAM;AAAA,EAC3E;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":[],"mappings":";;;AAYO,MAAM,eAAe;AAAA,EAC3B,CAAA,UAAY,oBAAA,UAAA,EAAA,UAAA,MAAM,UAAS;AAAA,EAC3B;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,yBAAyB,OAAO,QAAQ,WAAW;AAAA,EACnE;AAAA,EACA;AACD;"}
|
|
@@ -59,14 +59,17 @@ class Environment {
|
|
|
59
59
|
getVariableOrElse(key, fallback) {
|
|
60
60
|
return this.options.variables[key] ?? fallback;
|
|
61
61
|
}
|
|
62
|
+
/** @deprecated use getVariable or getParameter */
|
|
62
63
|
getValue(key) {
|
|
63
64
|
console.warn("Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.");
|
|
64
65
|
return this.getVariableOrElse(key, void 0) ?? this.getParameterOrElse(key, void 0);
|
|
65
66
|
}
|
|
67
|
+
/** @deprecated use getVariableOrElse or getParameterOrElse */
|
|
66
68
|
getValueOrElse(key, fallback) {
|
|
67
69
|
console.warn("Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.");
|
|
68
70
|
return this.getVariableOrElse(key, void 0) ?? this.getParameterOrElse(key, fallback);
|
|
69
71
|
}
|
|
72
|
+
/** @deprecated */
|
|
70
73
|
hasName(key) {
|
|
71
74
|
console.warn("Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.");
|
|
72
75
|
return key in this.options.variables || key in this.options.parameters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport type { Filter } from '../treeParameters'\nimport equal from 'fast-deep-equal/es6/index.js'\nimport { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'\nimport { GraphQlLiteral } from '@contember/client'\n\nclass Environment {\n\tprivate constructor(\n\t\tprivate readonly options: Environment.Options,\n\t) {\n\t}\n\n\tpublic static create() {\n\t\treturn new Environment({\n\t\t\tdimensions: {},\n\t\t\tvariables: {},\n\t\t\tparameters: {},\n\t\t\textensions: new Map(),\n\t\t})\n\t}\n\n\tpublic getSubTree(): Environment.SubTreeNode {\n\t\tfor (let env: Environment = this; env.options.node; env = env.getParent()) {\n\t\t\tconst node = env.options.node\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t\tthrow new BindingError('Not in a SubTree')\n\t}\n\n\tpublic getSubTreeNode(): Environment.AnyNode {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn this.options.node\n\t}\n\n\tpublic withSubTree(SubTree: Environment.SubTreeNode) {\n\t\tconst { parent, ...options } = this.options\n\t\treturn new Environment({\n\t\t\t...options,\n\t\t\tnode: SubTree,\n\t\t})\n\t}\n\n\tpublic withSubTreeChild(node: Environment.InnerNode) {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`)\n\t\t}\n\t\tif (this.options.node.entity.fields.get(node.field.name) !== node.field) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tnode,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\n\tpublic hasVariable(key: string): boolean {\n\t\treturn key in this.options.variables\n\t}\n\n\tpublic getVariable<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tif (!(key in this.options.variables)) {\n\t\t\tthrow new BindingError(`Variable ${key} not found`)\n\t\t}\n\t\treturn this.options.variables[key] as V\n\t}\n\n\tpublic getVariableOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\treturn (this.options.variables[key] as V) ?? fallback\n\t}\n\n\t/** @deprecated use getVariable or getParameter */\n\tpublic getValue<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tconsole.warn('Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, undefined) as V\n\t}\n\n\t/** @deprecated use getVariableOrElse or getParameterOrElse */\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\tconsole.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as any\n\t}\n\n\t/** @deprecated */\n\tpublic hasName(key: string): boolean {\n\t\tconsole.warn('Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.')\n\t\treturn key in this.options.variables || key in this.options.parameters\n\t}\n\n\tpublic withVariables(variables: Environment.ValuesMapWithFactory | undefined): Environment {\n\t\tif (variables === undefined) {\n\t\t\treturn this\n\t\t}\n\t\tconst newVariables = { ...this.options.variables }\n\t\tfor (const [newName, newValue] of Object.entries(variables)) {\n\t\t\tif (newName === 'labelMiddleware') {\n\t\t\t\tthrow new BindingError('You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.')\n\t\t\t}\n\t\t\tconst resolvedValue = typeof newValue === 'function' ? newValue(this) : newValue\n\t\t\tif (resolvedValue === undefined) {\n\t\t\t\tdelete newVariables[newName]\n\t\t\t} else {\n\t\t\t\tnewVariables[newName] = resolvedValue\n\t\t\t}\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tvariables: newVariables,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\tpublic getAllVariables() {\n\t\treturn this.options.variables\n\t}\n\n\tpublic hasParameter(key: string): boolean {\n\t\treturn key in this.options.parameters\n\t}\n\n\tpublic getParameter<F>(key: string): string | number {\n\t\tif (!(key in this.options.parameters)) {\n\t\t\tthrow new BindingError(`Parameter ${key} not found`)\n\t\t}\n\t\treturn this.options.parameters[key] as string | number\n\t}\n\n\tpublic getParameterOrElse<F>(key: string, fallback: F): string | number | F {\n\t\treturn this.options.parameters[key] ?? fallback\n\t}\n\n\tpublic getAllParameters() {\n\t\treturn this.options.parameters\n\t}\n\n\tpublic withParameters(parameters: Environment.Parameters): Environment {\n\t\treturn new Environment({ ...this.options, parameters })\n\t}\n\n\tpublic hasDimension(dimensionName: string): boolean {\n\t\treturn dimensionName in this.options.dimensions\n\t}\n\n\tpublic getDimension<F>(dimensionName: string): string[] {\n\t\tif (!(dimensionName in this.options.dimensions)) {\n\t\t\tthrow new BindingError(`Dimension ${dimensionName} does not exist.`)\n\t\t}\n\t\treturn this.options.dimensions[dimensionName]\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: string, fallback: F): string[] | F {\n\t\treturn this.options.dimensions[dimensionName] ?? fallback\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn this.options.dimensions\n\t}\n\n\tpublic withDimensions(dimensions: Environment.SelectedDimensions): Environment {\n\t\tconst newDimensions = {\n\t\t\t...this.options.dimensions,\n\t\t\t...dimensions,\n\t\t}\n\t\tif (equal(newDimensions, this.options.dimensions)) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Environment({ ...this.options, dimensions: newDimensions })\n\t}\n\n\tpublic getSchema(): Schema {\n\t\tif (!this.options.schema) {\n\t\t\tthrow new BindingError('Schema is not set')\n\t\t}\n\t\treturn this.options.schema\n\t}\n\n\tpublic withSchema(schema: Schema): Environment {\n\t\treturn new Environment({ ...this.options, schema })\n\t}\n\n\tpublic getParent(): Environment {\n\t\tif (!this.options.parent) {\n\t\t\tthrow new BindingError('There is no parent environment')\n\t\t}\n\t\treturn this.options.parent\n\t}\n\n\tpublic withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\textensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),\n\t\t})\n\t}\n\n\tpublic getExtension<S, R>(extension: Environment.Extension<S, R>): R {\n\t\tconst state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)\n\t\treturn extension.create(state as S, this)\n\t}\n\n\tpublic merge(other: Environment): Environment {\n\t\tif (other === this) {\n\t\t\treturn this\n\t\t}\n\t\tif (!equal(this.options.node, other.options.node)) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different tree position.`)\n\t\t}\n\t\tif (this.options.parameters !== other.options.parameters) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different parameters.`)\n\t\t}\n\t\tif (this.options.dimensions !== other.options.dimensions) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different dimensions.`)\n\t\t}\n\t\tif (this.options.extensions !== other.options.extensions) {\n\t\t\t// todo: deep compare?\n\t\t\tthrow new BindingError(`Cannot merge two environments with different extensions.`)\n\t\t}\n\n\t\tif (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {\n\t\t\treturn this\n\t\t}\n\t\tfor (const key in other.options.variables) {\n\t\t\tif (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {\n\t\t\t\tthrow new BindingError(`Cannot merge two environments with different value of variable ${key}:\\n`\n\t\t\t\t\t+ JSON.stringify(this.options.variables[key]) + '\\n'\n\t\t\t\t\t+ JSON.stringify(other.options.variables[key]))\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tparent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : undefined,\n\t\t\tvariables: { ...this.options.variables, ...other.options.variables },\n\t\t})\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string\n\n\texport type Value = ReactNode | GraphQlLiteral | Filter\n\n\texport type ResolvedValue = Value\n\n\texport interface Options {\n\t\tnode?: AnyNode\n\t\tschema?: Schema\n\t\tdimensions: SelectedDimensions\n\t\tparameters: Parameters\n\t\tvariables: CustomVariables\n\t\tparent?: Environment\n\t\textensions: Map<Extension<unknown, unknown>, unknown>\n\t}\n\n\texport type SubTreeNode =\n\t\t| SubTreeEntityNode\n\t\t| SubTreeEntityListNode\n\n\texport type InnerNode =\n\t\t| EntityNode\n\t\t| EntityListNode\n\t\t| ColumnNode\n\n\texport type AnyNode =\n\t\t| SubTreeNode\n\t\t| InnerNode\n\n\texport interface SubTreeEntityNode {\n\t\ttype: 'subtree-entity'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero' | 'one' | 'zero-or-one'\n\t\tfilter: Filter\n\t}\n\n\texport interface SubTreeEntityListNode {\n\t\ttype: 'subtree-entity-list'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero-to-many' | 'zero'\n\t\tfilter: Filter\n\t}\n\n\texport interface EntityNode {\n\t\ttype: 'entity'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface EntityListNode {\n\t\ttype: 'entity-list'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface ColumnNode {\n\t\ttype: 'column'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaColumn\n\t}\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport type Parameters = {\n\t\t[K in string]?: string | number\n\t}\n\n\texport interface CustomVariables {\n\t\t[key: string]: Value\n\t}\n\n\texport interface ValuesMapWithFactory {\n\t\t[key: string]:\n\t\t\t| ((environment: Environment) => Value)\n\t\t\t| Value\n\t}\n\n\texport type Extension<State, Result> = {\n\t\tcreate: (state: State | undefined, environment: Environment) => Result\n\t}\n\n\texport const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {\n\t\treturn {\n\t\t\tcreate,\n\t\t\t...otherMethods,\n\t\t}\n\t}\n\n\t/** @deprecated */\n\texport type DeltaFactory = ValuesMapWithFactory\n}\n\nexport { Environment }\n"],"names":["Environment"],"mappings":";;AAOA,MAAM,YAAY;AAAA,EACT,YACU,SAChB;AADgB,SAAA,UAAA;AAAA,EAElB;AAAA,EAEA,OAAc,SAAS;AACtB,WAAO,IAAI,YAAY;AAAA,MACtB,YAAY,CAAC;AAAA,MACb,WAAW,CAAC;AAAA,MACZ,YAAY,CAAC;AAAA,MACb,gCAAgB,IAAI;AAAA,IAAA,CACpB;AAAA,EACF;AAAA,EAEO,aAAsC;AACnC,aAAA,MAAmB,MAAM,IAAI,QAAQ,MAAM,MAAM,IAAI,aAAa;AACpE,YAAA,OAAO,IAAI,QAAQ;AACzB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AACnE,eAAA;AAAA,MACR;AAAA,IACD;AACM,UAAA,IAAI,aAAa,kBAAkB;AAAA,EAC1C;AAAA,EAEO,iBAAsC;AACxC,QAAA,CAAC,KAAK,QAAQ,MAAM;AACvB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EAEO,YAAY,SAAkC;AACpD,UAAM,EAAE,WAAW,QAAQ,IAAI,KAAK;AACpC,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG;AAAA,MACH,MAAM;AAAA,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AY;AACnD,YAAA,IAAI,aAAa,0DAA0D;AAAA,IAClF;AACA,QAAI,KAAK,QAAQ,eAAe,MAAM,QAAQ,YAAY;AACnD,YAAA,IAAI,aAAa,0DAA0D;AAAA,IAClF;AACA,QAAI,KAAK,QAAQ,eAAe,MAAM,QAAQ,YAAY;AAEnD,YAAA,IAAI,aAAa,0DAA0D;AAAA,IAClF;AAEA,QAAI,MAAM,KAAK,QAAQ,WAAW,MAAM,QAAQ,SAAS,KAAK,KAAK,QAAQ,WAAW,MAAM,QAAQ,QAAQ;AACpG,aAAA;AAAA,IACR;AACW,eAAA,OAAO,MAAM,QAAQ,WAAW;AAC1C,UAAI,OAAO,KAAK,QAAQ,aAAa,CAAC,MAAM,KAAK,QAAQ,UAAU,MAAM,MAAM,QAAQ,UAAU,IAAI,GAAG;AACjG,cAAA,IAAI,aAAa,kEAAkE;AAAA,IACtF,KAAK,UAAU,KAAK,QAAQ,UAAU,IAAI,IAAI,OAC9C,KAAK,UAAU,MAAM,QAAQ,UAAU,IAAI,CAAC;AAAA,MAChD;AAAA,IACD;AAEA,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,QAAQ,KAAK,QAAQ,UAAU,MAAM,QAAQ,SAAS,KAAK,QAAQ,OAAO,MAAM,MAAM,QAAQ,MAAM,IAAI;AAAA,MACxG,WAAW,EAAE,GAAG,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAQ,UAAU;AAAA,IAAA,CACnE;AAAA,EACF;AACD;AAAA,CAEA,CAAUA,iBAAV;AAoFcA,eAAA,kBAAkB,CAAO,QAAmC,iBAAoE;AACrI,WAAA;AAAA,MACN;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EACJ;AACD,GAzFS,gBAAA,cAAA,CAAA,EAAA;"}
|
|
1
|
+
{"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport type { Filter } from '../treeParameters'\nimport equal from 'fast-deep-equal/es6/index.js'\nimport { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'\nimport { GraphQlLiteral } from '@contember/client'\n\nclass Environment {\n\tprivate constructor(\n\t\tprivate readonly options: Environment.Options,\n\t) {\n\t}\n\n\tpublic static create() {\n\t\treturn new Environment({\n\t\t\tdimensions: {},\n\t\t\tvariables: {},\n\t\t\tparameters: {},\n\t\t\textensions: new Map(),\n\t\t})\n\t}\n\n\tpublic getSubTree(): Environment.SubTreeNode {\n\t\tfor (let env: Environment = this; env.options.node; env = env.getParent()) {\n\t\t\tconst node = env.options.node\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t\tthrow new BindingError('Not in a SubTree')\n\t}\n\n\tpublic getSubTreeNode(): Environment.AnyNode {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn this.options.node\n\t}\n\n\tpublic withSubTree(SubTree: Environment.SubTreeNode) {\n\t\tconst { parent, ...options } = this.options\n\t\treturn new Environment({\n\t\t\t...options,\n\t\t\tnode: SubTree,\n\t\t})\n\t}\n\n\tpublic withSubTreeChild(node: Environment.InnerNode) {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`)\n\t\t}\n\t\tif (this.options.node.entity.fields.get(node.field.name) !== node.field) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tnode,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\n\tpublic hasVariable(key: string): boolean {\n\t\treturn key in this.options.variables\n\t}\n\n\tpublic getVariable<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tif (!(key in this.options.variables)) {\n\t\t\tthrow new BindingError(`Variable ${key} not found`)\n\t\t}\n\t\treturn this.options.variables[key] as V\n\t}\n\n\tpublic getVariableOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\treturn (this.options.variables[key] as V) ?? fallback\n\t}\n\n\t/** @deprecated use getVariable or getParameter */\n\tpublic getValue<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tconsole.warn('Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, undefined) as V\n\t}\n\n\t/** @deprecated use getVariableOrElse or getParameterOrElse */\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\tconsole.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as any\n\t}\n\n\t/** @deprecated */\n\tpublic hasName(key: string): boolean {\n\t\tconsole.warn('Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.')\n\t\treturn key in this.options.variables || key in this.options.parameters\n\t}\n\n\tpublic withVariables(variables: Environment.ValuesMapWithFactory | undefined): Environment {\n\t\tif (variables === undefined) {\n\t\t\treturn this\n\t\t}\n\t\tconst newVariables = { ...this.options.variables }\n\t\tfor (const [newName, newValue] of Object.entries(variables)) {\n\t\t\tif (newName === 'labelMiddleware') {\n\t\t\t\tthrow new BindingError('You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.')\n\t\t\t}\n\t\t\tconst resolvedValue = typeof newValue === 'function' ? newValue(this) : newValue\n\t\t\tif (resolvedValue === undefined) {\n\t\t\t\tdelete newVariables[newName]\n\t\t\t} else {\n\t\t\t\tnewVariables[newName] = resolvedValue\n\t\t\t}\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tvariables: newVariables,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\tpublic getAllVariables() {\n\t\treturn this.options.variables\n\t}\n\n\tpublic hasParameter(key: string): boolean {\n\t\treturn key in this.options.parameters\n\t}\n\n\tpublic getParameter<F>(key: string): string | number {\n\t\tif (!(key in this.options.parameters)) {\n\t\t\tthrow new BindingError(`Parameter ${key} not found`)\n\t\t}\n\t\treturn this.options.parameters[key] as string | number\n\t}\n\n\tpublic getParameterOrElse<F>(key: string, fallback: F): string | number | F {\n\t\treturn this.options.parameters[key] ?? fallback\n\t}\n\n\tpublic getAllParameters() {\n\t\treturn this.options.parameters\n\t}\n\n\tpublic withParameters(parameters: Environment.Parameters): Environment {\n\t\treturn new Environment({ ...this.options, parameters })\n\t}\n\n\tpublic hasDimension(dimensionName: string): boolean {\n\t\treturn dimensionName in this.options.dimensions\n\t}\n\n\tpublic getDimension<F>(dimensionName: string): string[] {\n\t\tif (!(dimensionName in this.options.dimensions)) {\n\t\t\tthrow new BindingError(`Dimension ${dimensionName} does not exist.`)\n\t\t}\n\t\treturn this.options.dimensions[dimensionName]\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: string, fallback: F): string[] | F {\n\t\treturn this.options.dimensions[dimensionName] ?? fallback\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn this.options.dimensions\n\t}\n\n\tpublic withDimensions(dimensions: Environment.SelectedDimensions): Environment {\n\t\tconst newDimensions = {\n\t\t\t...this.options.dimensions,\n\t\t\t...dimensions,\n\t\t}\n\t\tif (equal(newDimensions, this.options.dimensions)) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Environment({ ...this.options, dimensions: newDimensions })\n\t}\n\n\tpublic getSchema(): Schema {\n\t\tif (!this.options.schema) {\n\t\t\tthrow new BindingError('Schema is not set')\n\t\t}\n\t\treturn this.options.schema\n\t}\n\n\tpublic withSchema(schema: Schema): Environment {\n\t\treturn new Environment({ ...this.options, schema })\n\t}\n\n\tpublic getParent(): Environment {\n\t\tif (!this.options.parent) {\n\t\t\tthrow new BindingError('There is no parent environment')\n\t\t}\n\t\treturn this.options.parent\n\t}\n\n\tpublic withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\textensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),\n\t\t})\n\t}\n\n\tpublic getExtension<S, R>(extension: Environment.Extension<S, R>): R {\n\t\tconst state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)\n\t\treturn extension.create(state as S, this)\n\t}\n\n\tpublic merge(other: Environment): Environment {\n\t\tif (other === this) {\n\t\t\treturn this\n\t\t}\n\t\tif (!equal(this.options.node, other.options.node)) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different tree position.`)\n\t\t}\n\t\tif (this.options.parameters !== other.options.parameters) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different parameters.`)\n\t\t}\n\t\tif (this.options.dimensions !== other.options.dimensions) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different dimensions.`)\n\t\t}\n\t\tif (this.options.extensions !== other.options.extensions) {\n\t\t\t// todo: deep compare?\n\t\t\tthrow new BindingError(`Cannot merge two environments with different extensions.`)\n\t\t}\n\n\t\tif (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {\n\t\t\treturn this\n\t\t}\n\t\tfor (const key in other.options.variables) {\n\t\t\tif (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {\n\t\t\t\tthrow new BindingError(`Cannot merge two environments with different value of variable ${key}:\\n`\n\t\t\t\t\t+ JSON.stringify(this.options.variables[key]) + '\\n'\n\t\t\t\t\t+ JSON.stringify(other.options.variables[key]))\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tparent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : undefined,\n\t\t\tvariables: { ...this.options.variables, ...other.options.variables },\n\t\t})\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string\n\n\texport type Value = ReactNode | GraphQlLiteral | Filter\n\n\texport type ResolvedValue = Value\n\n\texport interface Options {\n\t\tnode?: AnyNode\n\t\tschema?: Schema\n\t\tdimensions: SelectedDimensions\n\t\tparameters: Parameters\n\t\tvariables: CustomVariables\n\t\tparent?: Environment\n\t\textensions: Map<Extension<unknown, unknown>, unknown>\n\t}\n\n\texport type SubTreeNode =\n\t\t| SubTreeEntityNode\n\t\t| SubTreeEntityListNode\n\n\texport type InnerNode =\n\t\t| EntityNode\n\t\t| EntityListNode\n\t\t| ColumnNode\n\n\texport type AnyNode =\n\t\t| SubTreeNode\n\t\t| InnerNode\n\n\texport interface SubTreeEntityNode {\n\t\ttype: 'subtree-entity'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero' | 'one' | 'zero-or-one'\n\t\tfilter: Filter\n\t}\n\n\texport interface SubTreeEntityListNode {\n\t\ttype: 'subtree-entity-list'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero-to-many' | 'zero'\n\t\tfilter: Filter\n\t}\n\n\texport interface EntityNode {\n\t\ttype: 'entity'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface EntityListNode {\n\t\ttype: 'entity-list'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface ColumnNode {\n\t\ttype: 'column'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaColumn\n\t}\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport type Parameters = {\n\t\t[K in string]?: string | number\n\t}\n\n\texport interface CustomVariables {\n\t\t[key: string]: Value\n\t}\n\n\texport interface ValuesMapWithFactory {\n\t\t[key: string]:\n\t\t\t| ((environment: Environment) => Value)\n\t\t\t| Value\n\t}\n\n\texport type Extension<State, Result> = {\n\t\tcreate: (state: State | undefined, environment: Environment) => Result\n\t}\n\n\texport const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {\n\t\treturn {\n\t\t\tcreate,\n\t\t\t...otherMethods,\n\t\t}\n\t}\n\n\t/** @deprecated */\n\texport type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G,aAAA;AAAA,IACR;AACW,eAAA,OAAO,MAAM,QAAQ,WAAW;AAC1C,UAAI,OAAO,KAAK,QAAQ,aAAa,CAAC,MAAM,KAAK,QAAQ,UAAU,GAAG,GAAG,MAAM,QAAQ,UAAU,GAAG,CAAC,GAAG;AACjG,cAAA,IAAI,aAAa,kEAAkE;AAAA,IACtF,KAAK,UAAU,KAAK,QAAQ,UAAU,GAAG,CAAC,IAAI,OAC9C,KAAK,UAAU,MAAM,QAAQ,UAAU,GAAG,CAAC,CAAC;AAAA,MAChD;AAAA,IACD;AAEA,WAAO,IAAI,YAAY;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,QAAQ,KAAK,QAAQ,UAAU,MAAM,QAAQ,SAAS,KAAK,QAAQ,OAAO,MAAM,MAAM,QAAQ,MAAM,IAAI;AAAA,MACxG,WAAW,EAAE,GAAG,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAQ,UAAU;AAAA,IAAA,CACnE;AAAA,EACF;AACD;AAAA,CAEA,CAAUA,iBAAV;AAoFcA,eAAA,kBAAkB,CAAO,QAAmC,iBAAoE;AACrI,WAAA;AAAA,MACN;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EACJ;AACD,GAzFS,gBAAA,cAAA,CAAA,EAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityEvent.js","sources":["../../../src/entityEvents/useEntityEvent.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { FieldName } from '../treeParameters'\n\nexport function useEntityEvent(\n\ttype: 'beforePersist',\n\tlistener: EntityAccessor.EntityEventListenerMap['beforePersist'],\n): void\nexport function useEntityEvent(\n\ttype: 'beforeUpdate',\n\tlistener: EntityAccessor.EntityEventListenerMap['beforeUpdate'],\n): void\nexport function useEntityEvent(\n\ttype: 'connectionUpdate',\n\thasOneField: FieldName,\n\tlistener: EntityAccessor.EntityEventListenerMap['connectionUpdate'],\n): void\nexport function useEntityEvent(\n\ttype: 'persistError',\n\tlistener: EntityAccessor.EntityEventListenerMap['persistError'],\n): void\nexport function useEntityEvent(\n\ttype: 'persistSuccess',\n\tlistener: EntityAccessor.EntityEventListenerMap['persistSuccess'],\n): void\nexport function useEntityEvent(type: 'update', listener: EntityAccessor.EntityEventListenerMap['update']): void\nexport function useEntityEvent(type: keyof EntityAccessor.RuntimeEntityEventListenerMap, ...args: unknown[]): void {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\n\t// The identity of this function is guaranteed to be stable\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tuseEffect(() => {\n\t\t// addEventListener returns an unsubscribe function, which we're deliberately re-returning from here.\n\t\tconst entityAccessor = stableGetEntityReference()\n\t\tif (type === 'connectionUpdate') {\n\t\t\treturn entityAccessor.addEventListener(\n\t\t\t\t{\n\t\t\t\t\ttype,\n\t\t\t\t\tkey: args[0] as string,\n\t\t\t\t},\n\t\t\t\targs[1] as any,\n\t\t\t)\n\t\t} else {\n\t\t\treturn entityAccessor.addEventListener(\n\t\t\t\t{\n\t\t\t\t\ttype,\n\t\t\t\t},\n\t\t\t\targs[0] as any,\n\t\t\t)\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [...args, stableGetEntityReference])\n}\n"],"names":[],"mappings":";;;AA2BgB,SAAA,eAAe,SAA6D,MAAuB;AAClH,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AAGvD,QAAM,2BAA2B,uBAAuB;AAExD,YAAU,MAAM;AAEf,UAAM,iBAAiB;AACvB,QAAI,SAAS,oBAAoB;AAChC,aAAO,eAAe;AAAA,QACrB;AAAA,UACC;AAAA,UACA,KAAK,KAAK;AAAA,
|
|
1
|
+
{"version":3,"file":"useEntityEvent.js","sources":["../../../src/entityEvents/useEntityEvent.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { FieldName } from '../treeParameters'\n\nexport function useEntityEvent(\n\ttype: 'beforePersist',\n\tlistener: EntityAccessor.EntityEventListenerMap['beforePersist'],\n): void\nexport function useEntityEvent(\n\ttype: 'beforeUpdate',\n\tlistener: EntityAccessor.EntityEventListenerMap['beforeUpdate'],\n): void\nexport function useEntityEvent(\n\ttype: 'connectionUpdate',\n\thasOneField: FieldName,\n\tlistener: EntityAccessor.EntityEventListenerMap['connectionUpdate'],\n): void\nexport function useEntityEvent(\n\ttype: 'persistError',\n\tlistener: EntityAccessor.EntityEventListenerMap['persistError'],\n): void\nexport function useEntityEvent(\n\ttype: 'persistSuccess',\n\tlistener: EntityAccessor.EntityEventListenerMap['persistSuccess'],\n): void\nexport function useEntityEvent(type: 'update', listener: EntityAccessor.EntityEventListenerMap['update']): void\nexport function useEntityEvent(type: keyof EntityAccessor.RuntimeEntityEventListenerMap, ...args: unknown[]): void {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\n\t// The identity of this function is guaranteed to be stable\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tuseEffect(() => {\n\t\t// addEventListener returns an unsubscribe function, which we're deliberately re-returning from here.\n\t\tconst entityAccessor = stableGetEntityReference()\n\t\tif (type === 'connectionUpdate') {\n\t\t\treturn entityAccessor.addEventListener(\n\t\t\t\t{\n\t\t\t\t\ttype,\n\t\t\t\t\tkey: args[0] as string,\n\t\t\t\t},\n\t\t\t\targs[1] as any,\n\t\t\t)\n\t\t} else {\n\t\t\treturn entityAccessor.addEventListener(\n\t\t\t\t{\n\t\t\t\t\ttype,\n\t\t\t\t},\n\t\t\t\targs[0] as any,\n\t\t\t)\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [...args, stableGetEntityReference])\n}\n"],"names":[],"mappings":";;;AA2BgB,SAAA,eAAe,SAA6D,MAAuB;AAClH,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AAGvD,QAAM,2BAA2B,uBAAuB;AAExD,YAAU,MAAM;AAEf,UAAM,iBAAiB;AACvB,QAAI,SAAS,oBAAoB;AAChC,aAAO,eAAe;AAAA,QACrB;AAAA,UACC;AAAA,UACA,KAAK,KAAK,CAAC;AAAA,QACZ;AAAA,QACA,KAAK,CAAC;AAAA,MAAA;AAAA,IACP,OACM;AACN,aAAO,eAAe;AAAA,QACrB;AAAA,UACC;AAAA,QACD;AAAA,QACA,KAAK,CAAC;AAAA,MAAA;AAAA,IAER;AAAA,EAEE,GAAA,CAAC,GAAG,MAAM,wBAAwB,CAAC;AACvC;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { FieldAccessor } from "../../accessors/FieldAccessor.js";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => {
|
|
5
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
5
|
return value;
|
|
7
6
|
};
|
|
7
|
+
import { FieldAccessor } from "../../accessors/FieldAccessor.js";
|
|
8
8
|
class FieldHelper {
|
|
9
9
|
constructor(field) {
|
|
10
10
|
__publicField(this, "getAccessor");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import { FieldAccessor } from '../../accessors'\nimport type { FieldValue } from '../../treeParameters'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = field instanceof FieldAccessor ? field.getAccessor : field\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE
|
|
1
|
+
{"version":3,"file":"FieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import { FieldAccessor } from '../../accessors'\nimport type { FieldValue } from '../../treeParameters'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = field instanceof FieldAccessor ? field.getAccessor : field\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE;AAGlB,SAAK,cAAc,iBAAiB,gBAAgB,MAAM,cAAc;AAAA,EACzE;AACD;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { FieldHelper } from "./FieldHelper.js";
|
|
2
2
|
class TemporalFieldHelper extends FieldHelper {
|
|
3
3
|
setToNow(options) {
|
|
4
|
-
this.getAccessor().updateValue(new Date().toISOString(), options);
|
|
4
|
+
this.getAccessor().updateValue((/* @__PURE__ */ new Date()).toISOString(), options);
|
|
5
5
|
}
|
|
6
|
+
//public setToDate() TODO
|
|
7
|
+
//public setToTime() TODO
|
|
8
|
+
//public setToDateTime() TODO
|
|
6
9
|
}
|
|
7
10
|
((TemporalFieldHelper2) => {
|
|
8
11
|
TemporalFieldHelper2.setToNow = (field, options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t//public setToDate() TODO\n\t//public setToTime() TODO\n\t//public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["TemporalFieldHelper"],"mappings":";AAGA,MAAM,4BAA4B,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACjD,SAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '../../accessors'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t//public setToDate() TODO\n\t//public setToTime() TODO\n\t//public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["TemporalFieldHelper"],"mappings":";AAGA,MAAM,4BAA4B,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACjD,SAAA,cAAc,aAAY,oBAAI,QAAO,eAAe,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAKD;AAAA,CACA,CAAUA,yBAAV;AACcA,uBAAA,WAAW,CACvB,OACA,YACI;AACJ,QAAIA,qBAAoB,KAAK,EAAE,SAAS,OAAO;AAAA,EAAA;AAChD,GANS,wBAAA,sBAAA,CAAA,EAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AA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AElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\n/**\n * @group Data binding\n */\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;AAaO,SAAS,WAAW,OAAwB;AAElD,QAAM,SAAS,WAAW,QAAQ,UAAU,MAAM,KAAK,IAAK;AAE5D,SAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,EAAE,CAAA;AAChC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":[],"mappings":";;;;;;;;AA8CO,MAAM,YAAY;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QAC1B,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAE5F;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAID,UAAM,iBAAiB;AACvB,UAAM,cAAc,eAAe;AAEnC,UAAM,eAAe;AAAA,MACpB,CAAC,QAAc,cAAc,2BAA2B,KAAK,WAAW;AAAA,MACxE,CAAC,WAAW;AAAA,IAAA;AAEP,UAAA,kBAAkB,gBAAgB,QAAQ,YAAY;AAE5D,UAAM,gBAAgB;AAAA,MACrB,CAAC,iBAAsC,eAAe,uBAAuB,YAAY;AAAA,MACzF,CAAC,cAAc;AAAA,IAAA;AAEV,UAAA,YAAY,gBAAgB,iBAAiB,aAAa;AAI1D,UAAA,SAAS,QAAQ,MAAM;AAC5B,UAAI,CAAC,eAAe,kBAAkB,0BAA0B,QAAW;AACnE,eAAA;AAAA,MACR;AACO,aAAA,OAAO,GAAG,SAAS;AAAA,IAAA,GACxB,CAAC,WAAW,eAAe,gBAAgB,uBAAuB,MAAM,CAAC;AAE5E,2CAAU,UAAO,OAAA,CAAA;AAAA,EAClB;AAAA,EACA,CAAS,UAAA;AACR,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QAC1B,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAC5F,WAEG,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,OAAO,IAAI,CAAC,OAAO,MAClB,oBAAA,cAAA,EAAqB,SAAH,CAAiB,CACpC;AAAA,IACF,EAAA,CAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\n/**\n * @group Logic Components\n */\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":[],"mappings":";;;;;;;;;AA2BO,MAAM,KAAK;AAAA,EAAmB,CAAS,UAAA;AAC5C,WAAO,OAAO,MAAM,cAAc,aAC9B,oBAAA,UAAA,EAAS,WAAW,MAAM,WAAY,UAAM,MAAA,SAAA,CAAS,IACrD,oBAAA,YAAA,EAAW,WAAW,MAAM,WAAY,gBAAM,SAAS,CAAA;AAAA,EAC5D;AAAA,EACA;AACD;AAEA,MAAM,aAAa;AAAA,EAClB,CAAC,EAAE,UAAU,gBAAgB;AAC5B,UAAM,SAAS;AACT,UAAA,YAAY,QAAQ,MAAM,UAAU,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAE/D,WAAA,YAAe,oBAAA,UAAA,EAAA,SAAA,CAAS,IAAM;AAAA,EACtC;AAAA,EACA,CAAC,EAAE,SAAA,MAAe;AACjB,2CAAU,SAAS,CAAA;AAAA,EACpB;AAAA,EACA;AACD;AAEA,MAAM,WAAW;AAAA,EAChB,CAAC,EAAE,UAAU,gBAAgB;AAC5B,UAAM,MAAM;AACZ,UAAM,SAAS;AAET,UAAA,SAAS,IAAI;AACnB,UAAM,YAAY;AAAA,MACjB,MAAM,IAAI,gBAAgB,MAAM,EAAE,eAAe,QAAQ,cAAc,cAAc,WAAW,GAAG,CAAC;AAAA,MACpG,CAAC,WAAW,QAAQ,KAAK,MAAM;AAAA,IAAA;AAGzB,WAAA,YAAe,oBAAA,UAAA,EAAA,SAAA,CAAS,IAAM;AAAA,EACtC;AAAA,EACA,CAAC,EAAE,UAAU,aAAa,QAAQ;AACjC,UAAM,kBAAkB,cAAc,cAAc,WAAW,GAAG;AAClE,UAAM,kBAAkB,IAAI,sBAAsB,IAAI,UAAU,GAAG,eAAe,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM;AAC7H,UAAM,mBAAmB,oBAAA,UAAA,EAAG,UAAM,MAAA,KAAK,eAAe,EAAE,IAAI,CAAM,OAAA,oBAAC,OAAM,EAAA,OAAO,MAAS,EAAI,CAAE,EAAE,CAAA;AAEjG,WACE,qBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,IACF,EAAA,CAAA;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":[],"mappings":";;AAUO,MAAM,eAAe;AAAA,EAC3B,MAAM;AAAA,EACN,CAAC,EAAE,SAAS,sCAAS,SAAS,CAAA;AAAA,EAC9B;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\n/**\n * @group Data binding\n */\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;AAYa,MAAA,eAAe,UAAU,CAA4C,UAAwC;AACrH,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,+BAAQ,OAAO,EAAA,GAAG,OAAO,OAAO,MAAM,MAAO,CAAA;AAAA,EAC9C;AACA,6BAAQ,OAAO,EAAA,GAAG,OAAQ,GAAG,MAAM,MAAO,CAAA;AAC3C,GAAG,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterEvaluator.js","sources":["../../../../src/helperComponents/helpers/FilterEvaluator.ts"],"sourcesContent":["import { Schema } from '../../core/schema'\nimport { Input } from '@contember/client'\nimport { EntityAccessor } from '../../accessors'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\nimport { evaluateCondition } from './evaluateCondition'\n\n\nexport class FilterEvaluator {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t) {\n\t}\n\n\tevaluateFilter(entity: EntityAccessor, filter: Filter): boolean {\n\t\tconst entitySchema = this.schema.getEntity(entity.name)\n\n\t\tlet acc = true\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tconst operation = key === 'and' ? 'every' : 'some' as const\n\t\t\t\t\tacc &&= value[operation](it => this.evaluateFilter(entity, it))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tacc &&= !this.evaluateFilter(entity, value as Filter)\n\n\t\t\t} else {\n\t\t\t\tconst field = entitySchema.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tacc &&= evaluateCondition(entity.getField(key).value, value as Input.Condition)\n\t\t\t\t} else {\n\t\t\t\t\tacc &&= this.evaluateFilter(entity.getEntity(key), value as Filter)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn acc\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,eAAe,QAAwB,QAAyB;AAC/D,UAAM,eAAe,KAAK,OAAO,UAAU,OAAO,IAAI;AAEtD,QAAI,MAAM;AACV,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEM,cAAA,YAAY,QAAQ,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"FilterEvaluator.js","sources":["../../../../src/helperComponents/helpers/FilterEvaluator.ts"],"sourcesContent":["import { Schema } from '../../core/schema'\nimport { Input } from '@contember/client'\nimport { EntityAccessor } from '../../accessors'\nimport { Filter } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\nimport { evaluateCondition } from './evaluateCondition'\n\n\nexport class FilterEvaluator {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t) {\n\t}\n\n\tevaluateFilter(entity: EntityAccessor, filter: Filter): boolean {\n\t\tconst entitySchema = this.schema.getEntity(entity.name)\n\n\t\tlet acc = true\n\t\tfor (const [key, value] of Object.entries(filter)) {\n\t\t\tif (key === 'and' || key === 'or') {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\n\t\t\t\t\tconst operation = key === 'and' ? 'every' : 'some' as const\n\t\t\t\t\tacc &&= value[operation](it => this.evaluateFilter(entity, it))\n\n\t\t\t} else if (key === 'not') {\n\t\t\t\t\tacc &&= !this.evaluateFilter(entity, value as Filter)\n\n\t\t\t} else {\n\t\t\t\tconst field = entitySchema.fields.get(key)\n\t\t\t\tif (!field) {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\n\t\t\t\tif (field.__typename === '_Column') {\n\t\t\t\t\tacc &&= evaluateCondition(entity.getField(key).value, value as Input.Condition)\n\t\t\t\t} else {\n\t\t\t\t\tacc &&= this.evaluateFilter(entity.getEntity(key), value as Filter)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn acc\n\t}\n}\n"],"names":[],"mappings":";;AAQO,MAAM,gBAAgB;AAAA,EAC5B,YACkB,QAChB;AADgB,SAAA,SAAA;AAAA,EAElB;AAAA,EAEA,eAAe,QAAwB,QAAyB;AAC/D,UAAM,eAAe,KAAK,OAAO,UAAU,OAAO,IAAI;AAEtD,QAAI,MAAM;AACV,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,QAAQ,SAAS,QAAQ,MAAM;AACjC,YAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC1B,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEM,cAAA,YAAY,QAAQ,QAAQ,UAAU;AACpC,sBAAA,MAAM,SAAS,EAAE,CAAA,OAAM,KAAK,eAAe,QAAQ,EAAE,CAAC;AAAA,MAAA,WAErD,QAAQ,OAAO;AACxB,sBAAQ,CAAC,KAAK,eAAe,QAAQ,KAAe;AAAA,MAAA,OAE/C;AACN,cAAM,QAAQ,aAAa,OAAO,IAAI,GAAG;AACzC,YAAI,CAAC,OAAO;AACX,gBAAM,IAAI,aAAa;AAAA,QACxB;AAEI,YAAA,MAAM,eAAe,WAAW;AACnC,wBAAQ,kBAAkB,OAAO,SAAS,GAAG,EAAE,OAAO,KAAwB;AAAA,QAAA,OACxE;AACN,wBAAQ,KAAK,eAAe,OAAO,UAAU,GAAG,GAAG,KAAe;AAAA,QACnE;AAAA,MACD;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -28,6 +28,7 @@ const evaluateCondition = (value, condition) => {
|
|
|
28
28
|
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),
|
|
29
29
|
never: () => false,
|
|
30
30
|
always: () => true,
|
|
31
|
+
// deprecated
|
|
31
32
|
null: (expr) => value === null === expr
|
|
32
33
|
};
|
|
33
34
|
return Object.entries(condition).every(([operator, argument]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateCondition.js","sources":["../../../../src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { GraphQlLiteral, Input } from '@contember/client'\nimport { FieldValue } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nconst unwrapGraphqlLiteral = (value: Input.ColumnValue<GraphQlLiteral>): any => {\n\tif (value instanceof GraphQlLiteral) {\n\t\treturn value.value\n\t}\n\treturn value\n}\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue<GraphQlLiteral>>) => {\n\t\tconst handlers: {\n\t\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t\t) => boolean\n\t\t} = {\n\t\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\t\tnot: expr => !evaluateCondition(value, expr),\n\t\t\teq: expr => value === unwrapGraphqlLiteral(expr),\n\t\t\tnotEq: expr => value !== unwrapGraphqlLiteral(expr),\n\t\t\tisNull: expr => (value === null) === expr,\n\t\t\tin: expr => expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tnotIn: expr => !expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tlt: expr => value !== null && value < unwrapGraphqlLiteral(expr),\n\t\t\tlte: expr => value !== null && value <= unwrapGraphqlLiteral(expr),\n\t\t\tgt: expr => value !== null && value > unwrapGraphqlLiteral(expr),\n\t\t\tgte: expr => value !== null && value >= unwrapGraphqlLiteral(expr),\n\t\t\tcontains: expr => typeof value === 'string' && value.includes(unwrapGraphqlLiteral(expr)),\n\t\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tendsWith: expr => typeof value === 'string' && value.endsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tnever: () => false,\n\t\t\talways: () => true,\n\t\t\t// deprecated\n\t\t\tnull: expr => (value === null) === expr,\n\t\t}\n\t\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\t\tif (value === undefined) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst handlerKey = operator as keyof typeof handlers\n\t\t\tconst handler = handlers[handlerKey]\n\t\t\tif (!handler) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn handler(argument)\n\t\t})\n\t}\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,CAAC,UAAkD;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACd;AACO,SAAA;AACR;AAEa,MAAA,oBAAoB,CAAC,OAA0B,cAAkE;AAC5H,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAC/C,OAAO,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAClD,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI,CAAQ,SAAA,KAAK,I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lLiteral, Input } from '@contember/client'\nimport { FieldValue } from '../../treeParameters'\nimport { BindingError } from '../../BindingError'\n\nconst unwrapGraphqlLiteral = (value: Input.ColumnValue<GraphQlLiteral>): any => {\n\tif (value instanceof GraphQlLiteral) {\n\t\treturn value.value\n\t}\n\treturn value\n}\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue<GraphQlLiteral>>) => {\n\t\tconst handlers: {\n\t\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t\t) => boolean\n\t\t} = {\n\t\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\t\tnot: expr => !evaluateCondition(value, expr),\n\t\t\teq: expr => value === unwrapGraphqlLiteral(expr),\n\t\t\tnotEq: expr => value !== unwrapGraphqlLiteral(expr),\n\t\t\tisNull: expr => (value === null) === expr,\n\t\t\tin: expr => expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tnotIn: expr => !expr.map(unwrapGraphqlLiteral).includes(value),\n\t\t\tlt: expr => value !== null && value < unwrapGraphqlLiteral(expr),\n\t\t\tlte: expr => value !== null && value <= unwrapGraphqlLiteral(expr),\n\t\t\tgt: expr => value !== null && value > unwrapGraphqlLiteral(expr),\n\t\t\tgte: expr => value !== null && value >= unwrapGraphqlLiteral(expr),\n\t\t\tcontains: expr => typeof value === 'string' && value.includes(unwrapGraphqlLiteral(expr)),\n\t\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tendsWith: expr => typeof value === 'string' && value.endsWith(unwrapGraphqlLiteral(expr)),\n\t\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(unwrapGraphqlLiteral(expr).toLowerCase()),\n\t\t\tnever: () => false,\n\t\t\talways: () => true,\n\t\t\t// deprecated\n\t\t\tnull: expr => (value === null) === expr,\n\t\t}\n\t\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\t\tif (value === undefined) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst handlerKey = operator as keyof typeof handlers\n\t\t\tconst handler = handlers[handlerKey]\n\t\t\tif (!handler) {\n\t\t\t\tthrow new BindingError()\n\t\t\t}\n\t\t\treturn (handler as any)(argument)\n\t\t})\n\t}\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,CAAC,UAAkD;AAC/E,MAAI,iBAAiB,gBAAgB;AACpC,WAAO,MAAM;AAAA,EACd;AACO,SAAA;AACR;AAEa,MAAA,oBAAoB,CAAC,OAA0B,cAAkE;AAC5H,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAC/C,OAAO,CAAA,SAAQ,UAAU,qBAAqB,IAAI;AAAA,IAClD,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI,CAAQ,SAAA,KAAK,IAAI,oBAAoB,EAAE,SAAS,KAAK;AAAA,IACzD,OAAO,UAAQ,CAAC,KAAK,IAAI,oBAAoB,EAAE,SAAS,KAAK;AAAA,IAC7D,IAAI,CAAQ,SAAA,UAAU,QAAQ,QAAQ,qBAAqB,IAAI;AAAA,IAC/D,KAAK,CAAQ,SAAA,UAAU,QAAQ,SAAS,qBAAqB,IAAI;AAAA,IACjE,IAAI,CAAQ,SAAA,UAAU,QAAQ,QAAQ,qBAAqB,IAAI;AAAA,IAC/D,KAAK,CAAQ,SAAA,UAAU,QAAQ,SAAS,qBAAqB,IAAI;AAAA,IACjE,UAAU,UAAQ,OAAO,UAAU,YAAY,MAAM,SAAS,qBAAqB,IAAI,CAAC;AAAA,IACxF,YAAY,UAAQ,OAAO,UAAU,YAAY,MAAM,WAAW,qBAAqB,IAAI,CAAC;AAAA,IAC5F,UAAU,UAAQ,OAAO,UAAU,YAAY,MAAM,SAAS,qBAAqB,IAAI,CAAC;AAAA,IACxF,YAAY,CAAA,SAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,EAAE,SAAS,qBAAqB,IAAI,EAAE,aAAa;AAAA,IACtH,cAAc,CAAA,SAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,EAAE,WAAW,qBAAqB,IAAI,EAAE,aAAa;AAAA,IAC1H,YAAY,CAAA,SAAQ,OAAO,UAAU,YAAY,MAAM,YAAY,EAAE,SAAS,qBAAqB,IAAI,EAAE,aAAa;AAAA,IACtH,OAAO,MAAM;AAAA,IACb,QAAQ,MAAM;AAAA;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;AACb,UAAA,UAAU,SAAS,UAAU;AACnC,QAAI,CAAC,SAAS;AACb,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAQ,QAAgB,QAAQ;AAAA,EAAA,CAChC;AACF;"}
|
|
@@ -9,6 +9,7 @@ class EntityFieldMarkersContainer {
|
|
|
9
9
|
this.markers = markers;
|
|
10
10
|
this.placeholders = placeholders;
|
|
11
11
|
}
|
|
12
|
+
// …asserting that it's present
|
|
12
13
|
getFieldByPlaceholder(placeholder) {
|
|
13
14
|
const marker = this.markers.get(placeholder);
|
|
14
15
|
if (marker instanceof FieldMarker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFieldMarkersContainer.js","sources":["../../../src/markers/EntityFieldMarkersContainer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityFieldMarkers } from './EntityFieldMarkers'\nimport type { EntityFieldPlaceholders } from './EntityFieldPlaceholders'\nimport { FieldMarker } from './FieldMarker'\nimport { HasManyRelationMarker } from './HasManyRelationMarker'\nimport { HasOneRelationMarker } from './HasOneRelationMarker'\n\nexport class EntityFieldMarkersContainer {\n\tpublic constructor(\n\t\tpublic readonly hasAtLeastOneBearingField: boolean,\n\t\tpublic readonly markers: EntityFieldMarkers, // Indexed by placeholder names\n\t\tpublic readonly placeholders: EntityFieldPlaceholders, // Indexed by field names\n\t) {}\n\n\t// …asserting that it's present\n\tpublic getFieldByPlaceholder(placeholder: PlaceholderName): FieldName {\n\t\tconst marker = this.markers.get(placeholder)\n\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn marker.fieldName\n\t\t}\n\t\tif (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn marker.parameters.field\n\t\t}\n\t\tif (marker === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn assertNever(marker)\n\t}\n\n\tpublic *getPlaceholdersByField(field: FieldName): IterableIterator<PlaceholderName> {\n\t\tconst placeholders = this.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof placeholders === 'string') {\n\t\t\tyield placeholders\n\t\t\treturn\n\t\t}\n\t\tyield* placeholders.values()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,4BAA4B;AAAA,EACjC,YACU,2BACA,SACA,cACf;AAHe,SAAA,4BAAA;AACA,SAAA,UAAA;AACA,SAAA,eAAA;AAAA,EACd;AAAA,EAGI,sBAAsB,aAAyC;AACrE,UAAM,SAAS,KAAK,QAAQ,IAAI,WAAW;AAE3C,QAAI,kBAAkB,aAAa;AAClC,aAAO,OAAO;AAAA,IACf;AACI,QAAA,kBAAkB,wBAAwB,kBAAkB,uBAAuB;AACtF,aAAO,OAAO,WAAW;AAAA,IAC1B;AACA,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,YAAkB;AAAA,EAC1B;AAAA,EAEA,CAAQ,uBAAuB,OAAqD;AACnF,UAAM,eAAe,KAAK,aAAa,IAAI,KAAK;AAEhD,QAAI,iBAAiB,QAAW;AAC/B;AAAA,IACD;AACI,QAAA,OAAO,iBAAiB,UAAU;AAC/B,YAAA;AACN;AAAA,IACD;AACA,WAAO,aAAa;EACrB;AACD;"}
|
|
1
|
+
{"version":3,"file":"EntityFieldMarkersContainer.js","sources":["../../../src/markers/EntityFieldMarkersContainer.ts"],"sourcesContent":["import { BindingError } from '../BindingError'\nimport type { FieldName, PlaceholderName } from '../treeParameters'\nimport { assertNever } from '../utils'\nimport type { EntityFieldMarkers } from './EntityFieldMarkers'\nimport type { EntityFieldPlaceholders } from './EntityFieldPlaceholders'\nimport { FieldMarker } from './FieldMarker'\nimport { HasManyRelationMarker } from './HasManyRelationMarker'\nimport { HasOneRelationMarker } from './HasOneRelationMarker'\n\nexport class EntityFieldMarkersContainer {\n\tpublic constructor(\n\t\tpublic readonly hasAtLeastOneBearingField: boolean,\n\t\tpublic readonly markers: EntityFieldMarkers, // Indexed by placeholder names\n\t\tpublic readonly placeholders: EntityFieldPlaceholders, // Indexed by field names\n\t) {}\n\n\t// …asserting that it's present\n\tpublic getFieldByPlaceholder(placeholder: PlaceholderName): FieldName {\n\t\tconst marker = this.markers.get(placeholder)\n\n\t\tif (marker instanceof FieldMarker) {\n\t\t\treturn marker.fieldName\n\t\t}\n\t\tif (marker instanceof HasOneRelationMarker || marker instanceof HasManyRelationMarker) {\n\t\t\treturn marker.parameters.field\n\t\t}\n\t\tif (marker === undefined) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn assertNever(marker)\n\t}\n\n\tpublic *getPlaceholdersByField(field: FieldName): IterableIterator<PlaceholderName> {\n\t\tconst placeholders = this.placeholders.get(field)\n\n\t\tif (placeholders === undefined) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof placeholders === 'string') {\n\t\t\tyield placeholders\n\t\t\treturn\n\t\t}\n\t\tyield* placeholders.values()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,4BAA4B;AAAA,EACjC,YACU,2BACA,SACA,cACf;AAHe,SAAA,4BAAA;AACA,SAAA,UAAA;AACA,SAAA,eAAA;AAAA,EACd;AAAA;AAAA,EAGI,sBAAsB,aAAyC;AACrE,UAAM,SAAS,KAAK,QAAQ,IAAI,WAAW;AAE3C,QAAI,kBAAkB,aAAa;AAClC,aAAO,OAAO;AAAA,IACf;AACI,QAAA,kBAAkB,wBAAwB,kBAAkB,uBAAuB;AACtF,aAAO,OAAO,WAAW;AAAA,IAC1B;AACA,QAAI,WAAW,QAAW;AACzB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,YAAkB;AAAA,EAC1B;AAAA,EAEA,CAAQ,uBAAuB,OAAqD;AACnF,UAAM,eAAe,KAAK,aAAa,IAAI,KAAK;AAEhD,QAAI,iBAAiB,QAAW;AAC/B;AAAA,IACD;AACI,QAAA,OAAO,iBAAiB,UAAU;AAC/B,YAAA;AACN;AAAA,IACD;AACA,WAAO,aAAa;EACrB;AACD;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { PlaceholderGenerator } from "./PlaceholderGenerator.js";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => {
|
|
5
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
5
|
return value;
|
|
7
6
|
};
|
|
7
|
+
import { PlaceholderGenerator } from "./PlaceholderGenerator.js";
|
|
8
8
|
class EntityListSubTreeMarker {
|
|
9
9
|
constructor(parameters, fields, environment) {
|
|
10
|
+
__publicField(this, "placeholderName");
|
|
10
11
|
this.parameters = parameters;
|
|
11
12
|
this.fields = fields;
|
|
12
13
|
this.environment = environment;
|
|
13
|
-
__publicField(this, "placeholderName");
|
|
14
14
|
this.placeholderName = PlaceholderGenerator.getEntityListSubTreePlaceholder(this.parameters, this.environment);
|
|
15
15
|
}
|
|
16
16
|
get entityName() {
|