@contrail/documents 2.1.0-alpha.ab97680 → 2.1.0-alpha.c922865
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/CHANGELOG.md
CHANGED
|
@@ -20,11 +20,6 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
20
20
|
- `SECTION_ELEMENT_TYPE`, `FRAME_ELEMENT_TYPE` and `SHAPE_ELEMENT_TYPES` in
|
|
21
21
|
`document-element-constants`, so the rule above has one definition rather than one per app.
|
|
22
22
|
|
|
23
|
-
### Changed (breaking)
|
|
24
|
-
|
|
25
|
-
- `isContainerBinding()` becomes `DynamicTextUtil.takesValueFromContainer()`. Same rule, named for
|
|
26
|
-
what it decides: whether the binding's value comes from the container rather than a type property.
|
|
27
|
-
|
|
28
23
|
### Fixed
|
|
29
24
|
|
|
30
25
|
- `DynamicTextUtil.calculateSize` threw on an element that reached it without a `size`, which on
|
|
@@ -12,13 +12,12 @@ export declare class DocumentContainerIndex {
|
|
|
12
12
|
});
|
|
13
13
|
getContainer(containerId: string): DocumentContainer | null;
|
|
14
14
|
containersOf(documentElementId: string, elementType: ContainerElementType): DocumentContainer[];
|
|
15
|
-
containerIdsOf(documentElementId: string, elementType: ContainerElementType):
|
|
15
|
+
containerIdsOf(documentElementId: string, elementType: ContainerElementType): string[];
|
|
16
16
|
innermostContainerIdOf(documentElementId: string, elementType: ContainerElementType): string | null;
|
|
17
|
-
memberIdsOf(containerId: string):
|
|
17
|
+
memberIdsOf(containerId: string): string[];
|
|
18
18
|
memberDocumentElementsOf(containerId: string): DocumentElement[];
|
|
19
|
-
containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType):
|
|
19
|
+
containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType): string[];
|
|
20
20
|
maxDepth(elementType: ContainerElementType): number;
|
|
21
21
|
private containersOfType;
|
|
22
|
-
private resolveAll;
|
|
23
22
|
private containerPath;
|
|
24
23
|
}
|
|
@@ -11,7 +11,9 @@ class DocumentContainerIndex {
|
|
|
11
11
|
return (_a = this.data.containersById.get(containerId)) !== null && _a !== void 0 ? _a : null;
|
|
12
12
|
}
|
|
13
13
|
containersOf(documentElementId, elementType) {
|
|
14
|
-
return this.
|
|
14
|
+
return this.containerIdsOf(documentElementId, elementType)
|
|
15
|
+
.map((containerId) => this.data.containersById.get(containerId))
|
|
16
|
+
.filter(Boolean);
|
|
15
17
|
}
|
|
16
18
|
containerIdsOf(documentElementId, elementType) {
|
|
17
19
|
return this.containerPath(documentElementId, elementType);
|
|
@@ -25,14 +27,9 @@ class DocumentContainerIndex {
|
|
|
25
27
|
return (_a = this.data.memberIdsByContainerId.get(containerId)) !== null && _a !== void 0 ? _a : [];
|
|
26
28
|
}
|
|
27
29
|
memberDocumentElementsOf(containerId) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (member) {
|
|
32
|
-
members.push(member);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return members;
|
|
30
|
+
return this.memberIdsOf(containerId)
|
|
31
|
+
.map((memberId) => this.data.documentElementsById.get(memberId))
|
|
32
|
+
.filter(Boolean);
|
|
36
33
|
}
|
|
37
34
|
containerPathAtPoint(point, elementType) {
|
|
38
35
|
const covering = this.containersOfType(elementType).filter((container) => (0, document_container_1.containsPoint)(container.box, point));
|
|
@@ -43,17 +40,9 @@ class DocumentContainerIndex {
|
|
|
43
40
|
}
|
|
44
41
|
containersOfType(elementType) {
|
|
45
42
|
var _a;
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const containers = [];
|
|
50
|
-
for (const containerId of containerIds) {
|
|
51
|
-
const container = this.data.containersById.get(containerId);
|
|
52
|
-
if (container) {
|
|
53
|
-
containers.push(container);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return containers;
|
|
43
|
+
return ((_a = this.data.containerIdsByElementType.get(elementType)) !== null && _a !== void 0 ? _a : [])
|
|
44
|
+
.map((containerId) => this.data.containersById.get(containerId))
|
|
45
|
+
.filter(Boolean);
|
|
57
46
|
}
|
|
58
47
|
containerPath(documentElementId, elementType) {
|
|
59
48
|
var _a, _b;
|
|
@@ -48,8 +48,8 @@ export declare const HARD_CODED_TEXT: {
|
|
|
48
48
|
'section.itemOptionCount': string;
|
|
49
49
|
'section.colorCount': string;
|
|
50
50
|
};
|
|
51
|
+
export declare function isContainerBinding(bindingProperty: string | null | undefined): boolean;
|
|
51
52
|
export declare class DynamicTextUtil {
|
|
52
|
-
static takesValueFromContainer(bindingProperty: string | null | undefined): boolean;
|
|
53
53
|
static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, container: DynamicTextContainer | null, componentModels: any[], ownerReferenceModel?: any): string;
|
|
54
54
|
static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string): import("../..").SizeDefinition;
|
|
55
55
|
static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DynamicTextUtil = exports.HARD_CODED_TEXT = exports.CLICK_TO_CONFIGURE = exports.MOVE_TO_SECTION_TEXT = exports.MOVE_TO_FRAME_TEXT = exports.DynamicTextDisplayFunction = exports.DYNAMIC_TEXT_DATA_SOURCE = void 0;
|
|
4
|
+
exports.isContainerBinding = isContainerBinding;
|
|
4
5
|
const types_1 = require("@contrail/types");
|
|
5
6
|
const util_1 = require("@contrail/util");
|
|
6
7
|
const document_util_1 = require("@contrail/document-util");
|
|
@@ -50,14 +51,14 @@ exports.HARD_CODED_TEXT = {
|
|
|
50
51
|
};
|
|
51
52
|
const CONTAINER_PROPERTY_SLUGS = ['name', 'count', 'itemFamilyCount', 'itemOptionCount', 'colorCount'];
|
|
52
53
|
const CONTAINER_SOURCES = [DYNAMIC_TEXT_DATA_SOURCE.FRAME, DYNAMIC_TEXT_DATA_SOURCE.SECTION];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
const [entityType, propertySlug] = bindingProperty.split('.');
|
|
59
|
-
return CONTAINER_SOURCES.includes(entityType) && CONTAINER_PROPERTY_SLUGS.includes(propertySlug);
|
|
54
|
+
function isContainerBinding(bindingProperty) {
|
|
55
|
+
if (!bindingProperty) {
|
|
56
|
+
return false;
|
|
60
57
|
}
|
|
58
|
+
const [entityType, propertySlug] = bindingProperty.split('.');
|
|
59
|
+
return CONTAINER_SOURCES.includes(entityType) && CONTAINER_PROPERTY_SLUGS.includes(propertySlug);
|
|
60
|
+
}
|
|
61
|
+
class DynamicTextUtil {
|
|
61
62
|
static getDynamicTextValue(dynamicTextElement, property, propertyLevel, container, componentModels, ownerReferenceModel = null) {
|
|
62
63
|
var _a, _b, _c, _d;
|
|
63
64
|
if (!dynamicTextElement.propertyBindings || !dynamicTextElement.propertyBindings.text) {
|