@contrail/documents 1.0.118 → 1.0.119

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.
@@ -8,6 +8,7 @@ export declare class DocumentElementFactory {
8
8
  static createElement(type: string, options?: DocumentElement): DocumentElement;
9
9
  static createImageElement(options: DocumentElement): DocumentElement;
10
10
  static createFrameElement(options: DocumentElement): DocumentElement;
11
+ static createColorComponent(model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
11
12
  static createComponent(componentType: string, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
12
13
  static createComponentFromComponentDefinition(componentDefinition: ComponentDefinition, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
13
14
  static copyElements(elements: DocumentElement[], documentId?: string, commonOptions?: DocumentElement, positionOffset?: PositionDefinition, lastFrameNumber?: number): {
@@ -35,7 +35,7 @@ class DocumentElementFactory {
35
35
  let element = this.initNewElement(type);
36
36
  element = Object.assign(element, options);
37
37
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
38
- element.elements = element.elements.map((e) => {
38
+ element.elements = element.elements.map(e => {
39
39
  e.id = (0, nanoid_1.nanoid)(16);
40
40
  return e;
41
41
  });
@@ -52,6 +52,13 @@ class DocumentElementFactory {
52
52
  element = Object.assign(element, options);
53
53
  return element;
54
54
  }
55
+ static createColorComponent(model, modelBindings, options) {
56
+ var _a;
57
+ return DocumentElementFactory.createComponent(((_a = model === null || model === void 0 ? void 0 : model.color) === null || _a === void 0 ? void 0 : _a.primaryViewableId) ? 'pattern-view' : 'color-view', model, modelBindings, Object.assign({
58
+ size: components_1.COLOR_WIDTH + components_1.COLOR_PADDING * 2,
59
+ height: components_1.COLOR_WIDTH + components_1.COLOR_FONT_SIZE + components_1.COLOR_PADDING * 4,
60
+ }, options));
61
+ }
55
62
  static createComponent(componentType, model, modelBindings, options) {
56
63
  const componentDefinition = components_1.ComponentRegistry.getComponentDefinition(componentType);
57
64
  return this.createComponentFromComponentDefinition(componentDefinition, model, modelBindings, options);
@@ -68,7 +75,7 @@ class DocumentElementFactory {
68
75
  element.elements = elements;
69
76
  element.modelBindings = modelBindings;
70
77
  if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
71
- element.elements = element.elements.map((e) => {
78
+ element.elements = element.elements.map(e => {
72
79
  e.id = (0, nanoid_1.nanoid)(16);
73
80
  return e;
74
81
  });
@@ -100,7 +107,7 @@ class DocumentElementFactory {
100
107
  }
101
108
  const newInnerElements = [];
102
109
  if (newElement.type === 'table') {
103
- const oldChildElements = elements.filter((e) => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
110
+ const oldChildElements = elements.filter(e => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
104
111
  let newTableElement, newChildElements = [];
105
112
  try {
106
113
  [newTableElement, ...newChildElements] = document_table_1.TableCopyService.copy(newElement, oldChildElements);
@@ -111,7 +118,7 @@ class DocumentElementFactory {
111
118
  continue;
112
119
  }
113
120
  newElement = newTableElement;
114
- newChildElements.forEach((newChildElement) => {
121
+ newChildElements.forEach(newChildElement => {
115
122
  var _a;
116
123
  let oldChildId;
117
124
  if (newChildElement.type === 'row') {
@@ -123,7 +130,7 @@ class DocumentElementFactory {
123
130
  else if (newChildElement.type === 'cell') {
124
131
  const oldRowId = element.rowIds[newTableElement.rowIds.indexOf(newChildElement.rowId)];
125
132
  const oldColumnId = element.columnIds[newTableElement.columnIds.indexOf(newChildElement.columnId)];
126
- oldChildId = (_a = elements.find((e) => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
133
+ oldChildId = (_a = elements.find(e => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
127
134
  }
128
135
  if (oldChildId) {
129
136
  newChildElement.documentId = documentId;
@@ -156,15 +163,15 @@ class DocumentElementFactory {
156
163
  if (DocumentElementFactory.isMask(newElement))
157
164
  maskElements.push(newElement);
158
165
  }
159
- groupElements.forEach((groupElement) => {
166
+ groupElements.forEach(groupElement => {
160
167
  groupElement.elementIds = groupElement.elementIds
161
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
162
- .filter((id) => !!id);
168
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
169
+ .filter(id => !!id);
163
170
  });
164
- maskElements.forEach((maskElement) => {
171
+ maskElements.forEach(maskElement => {
165
172
  const newElementIds = maskElement.elementIds
166
- .map((oldElementId) => oldIdToNewId.get(oldElementId))
167
- .filter((id) => !!id);
173
+ .map(oldElementId => oldIdToNewId.get(oldElementId))
174
+ .filter(id => !!id);
168
175
  maskElement.elementIds = (newElementIds === null || newElementIds === void 0 ? void 0 : newElementIds.length) > 0 ? newElementIds : null;
169
176
  });
170
177
  return { oldIdToNewId, newElements };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.0.118",
3
+ "version": "1.0.119",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",