@telia-ace/widget-components-grid 1.0.3 → 1.0.4
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/lib/grid-area.d.ts +3 -0
- package/lib/grid-area.js +2 -2
- package/lib/grid-component.d.ts +9 -0
- package/lib/grid.js +1 -1
- package/lib/handler.d.ts +2 -0
- package/lib/handler.js +107 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/nested-grid-area.js +9 -7
- package/lib-esm/grid-area.d.ts +3 -0
- package/lib-esm/grid-area.js +2 -2
- package/lib-esm/grid-component.d.ts +9 -0
- package/lib-esm/grid.js +1 -1
- package/lib-esm/handler.d.ts +2 -0
- package/lib-esm/handler.js +103 -0
- package/lib-esm/index.d.ts +1 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/nested-grid-area.js +9 -4
- package/package.json +8 -5
package/lib/grid-area.d.ts
CHANGED
package/lib/grid-area.js
CHANGED
|
@@ -37,7 +37,7 @@ var toCSSProps = (0, styled_components_1.css)(templateObject_1 || (templateObjec
|
|
|
37
37
|
}, '');
|
|
38
38
|
});
|
|
39
39
|
var GridArea = function (_a) {
|
|
40
|
-
var gridArea = _a.gridArea, areaSettings = _a.areaSettings, componentName = _a.componentName;
|
|
40
|
+
var gridArea = _a.gridArea, areaSettings = _a.areaSettings, componentName = _a.componentName, context = _a.context;
|
|
41
41
|
var children = (0, widget_ui_1.useChildren)();
|
|
42
42
|
var child = (0, react_1.useMemo)(function () {
|
|
43
43
|
return children.find(function (i) { return i.name === componentName; });
|
|
@@ -46,7 +46,7 @@ var GridArea = function (_a) {
|
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
return (react_1.default.createElement(StyledGridArea, { "data-grid-area": gridArea, gridArea: gridArea, settings: areaSettings },
|
|
49
|
-
react_1.default.createElement(widget_types_grid_1.Component, { key: child.id, id: child.id, branch: "default" })));
|
|
49
|
+
react_1.default.createElement(widget_types_grid_1.Component, { key: child.id, id: child.id, branch: "default", context: context })));
|
|
50
50
|
};
|
|
51
51
|
exports.default = GridArea;
|
|
52
52
|
var StyledGridArea = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n grid-area: ", ";\n ", "\n"], ["\n grid-area: ", ";\n ", "\n"])), function (p) { return p.gridArea; }, toCSSProps);
|
package/lib/grid-component.d.ts
CHANGED
|
@@ -4,8 +4,14 @@ declare type AreaWithChild = {
|
|
|
4
4
|
areaSettings: {
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
};
|
|
7
|
+
context: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
7
10
|
};
|
|
8
11
|
export declare type NestedArea = {
|
|
12
|
+
context: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
9
15
|
template: string[];
|
|
10
16
|
areaSettings: {
|
|
11
17
|
[key: string]: string;
|
|
@@ -27,6 +33,9 @@ export declare type GridComponentProps = {
|
|
|
27
33
|
[key: string]: GridAreaProps;
|
|
28
34
|
};
|
|
29
35
|
child: string;
|
|
36
|
+
context: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
30
39
|
};
|
|
31
40
|
export declare const GridComponent: (container: Container) => Promise<void>;
|
|
32
41
|
export default GridComponent;
|
package/lib/grid.js
CHANGED
|
@@ -9,6 +9,6 @@ var nested_grid_area_1 = __importDefault(require("./nested-grid-area"));
|
|
|
9
9
|
var Grid = function (_a) {
|
|
10
10
|
var className = _a.className;
|
|
11
11
|
var properties = (0, widget_ui_1.useProperties)();
|
|
12
|
-
return (react_1.default.createElement(nested_grid_area_1.default, { template: properties.template, areas: properties.areas, gap: properties.gap, areaSettings: properties.areaSettings }));
|
|
12
|
+
return (react_1.default.createElement(nested_grid_area_1.default, { template: properties.template, areas: properties.areas, gap: properties.gap, areaSettings: properties.areaSettings, context: properties.context }));
|
|
13
13
|
};
|
|
14
14
|
exports.default = Grid;
|
package/lib/handler.d.ts
ADDED
package/lib/handler.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.gridComponentHandler = void 0;
|
|
31
|
+
var widget_core_1 = require("@telia-ace/widget-core");
|
|
32
|
+
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
33
|
+
var gridComponentHandler = function (childRef, options) {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
var platform = options.platform, node = options.node, references = options.references, definitions = options.definitions, views = options.views, branch = options.branch;
|
|
36
|
+
var childDef = definitions[childRef.definitionId];
|
|
37
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
38
|
+
if (!childDef) {
|
|
39
|
+
widget_utilities_1.Logger.error("No definition found for component type '".concat(childRef.definitionId, "'."));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var childNode = platform.createNode(childDef.type);
|
|
44
|
+
childNode.name = childRef.definitionId;
|
|
45
|
+
childNode.tags = childDef.tags || [];
|
|
46
|
+
if (childDef.properties) {
|
|
47
|
+
childNode.writeProperties(childDef.properties);
|
|
48
|
+
}
|
|
49
|
+
if (childDef.context) {
|
|
50
|
+
childNode.writeContext(childDef.context);
|
|
51
|
+
}
|
|
52
|
+
if (childDef.layout) {
|
|
53
|
+
childNode.writeLayout(childDef.layout);
|
|
54
|
+
}
|
|
55
|
+
node.appendChild(childNode, branch);
|
|
56
|
+
childRef.overrides.forEach(function (override) {
|
|
57
|
+
var options = { breakpoints: override.breakpoints };
|
|
58
|
+
if (override.properties) {
|
|
59
|
+
childNode.writeProperties(override.properties, options);
|
|
60
|
+
}
|
|
61
|
+
if (override.context) {
|
|
62
|
+
childNode.writeContext(override.context, options);
|
|
63
|
+
}
|
|
64
|
+
if (override.layout) {
|
|
65
|
+
childNode.writeLayout(override.layout, options);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (((_a = childDef.properties) === null || _a === void 0 ? void 0 : _a.areas) && !!((_b = childDef.properties) === null || _b === void 0 ? void 0 : _b.areas)) {
|
|
69
|
+
var mergedDefinitons = Object.entries(childDef.properties.areas).reduce(function (acc, _a) {
|
|
70
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
71
|
+
if (value.child) {
|
|
72
|
+
var cssProps = Object.entries(value.areaSettings || {}).reduce(function (acc, _a) {
|
|
73
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
74
|
+
acc["css-".concat(key)] = value;
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
acc[key] = {
|
|
78
|
+
type: 'area',
|
|
79
|
+
context: value.context || {},
|
|
80
|
+
children: [value.child],
|
|
81
|
+
properties: __assign({ 'css-grid-area': key }, cssProps),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var subgrid = {
|
|
86
|
+
type: 'grid',
|
|
87
|
+
context: {},
|
|
88
|
+
properties: {
|
|
89
|
+
areaSettings: {},
|
|
90
|
+
areas: value.areas,
|
|
91
|
+
context: value.context,
|
|
92
|
+
gap: value.gap,
|
|
93
|
+
gridArea: value.gridArea,
|
|
94
|
+
template: value.template,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
acc[key] = subgrid;
|
|
98
|
+
}
|
|
99
|
+
return acc;
|
|
100
|
+
}, definitions);
|
|
101
|
+
(0, widget_core_1.createChildren)(platform, childNode, Object.keys(childDef.properties.areas), mergedDefinitons, views);
|
|
102
|
+
}
|
|
103
|
+
else if ((_c = childDef.properties) === null || _c === void 0 ? void 0 : _c.child) {
|
|
104
|
+
(0, widget_core_1.createChildren)(platform, childNode, [(_d = childDef.properties) === null || _d === void 0 ? void 0 : _d.child], definitions, views);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.gridComponentHandler = gridComponentHandler;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,5 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.gridComponentHandler = void 0;
|
|
6
7
|
var grid_component_1 = __importDefault(require("./grid-component"));
|
|
8
|
+
var handler_1 = require("./handler");
|
|
9
|
+
Object.defineProperty(exports, "gridComponentHandler", { enumerable: true, get: function () { return handler_1.gridComponentHandler; } });
|
|
7
10
|
exports.default = grid_component_1.default;
|
package/lib/nested-grid-area.js
CHANGED
|
@@ -42,15 +42,12 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
42
42
|
}
|
|
43
43
|
return ar;
|
|
44
44
|
};
|
|
45
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
-
};
|
|
48
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
var widget_types_grid_1 = require("@telia-ace/widget-types-grid");
|
|
49
47
|
var widget_ui_1 = require("@telia-ace/widget-ui");
|
|
50
48
|
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
51
49
|
var react_1 = __importStar(require("react"));
|
|
52
50
|
var styled_components_1 = __importStar(require("styled-components"));
|
|
53
|
-
var grid_area_1 = __importDefault(require("./grid-area"));
|
|
54
51
|
var grid_component_1 = require("./grid-component");
|
|
55
52
|
var utils_1 = require("./utils");
|
|
56
53
|
var NestedGridArea = function (props) {
|
|
@@ -58,15 +55,20 @@ var NestedGridArea = function (props) {
|
|
|
58
55
|
var areas = (0, react_1.useMemo)(function () {
|
|
59
56
|
return Object.entries(props.areas).map(function (_a) {
|
|
60
57
|
var _b = __read(_a, 2), key = _b[0], area = _b[1];
|
|
58
|
+
var componentDef = children.find(function (child) { return child.name === key; });
|
|
61
59
|
if (!(0, grid_component_1.isNestedGrid)(area)) {
|
|
62
60
|
return {
|
|
63
61
|
name: key,
|
|
62
|
+
componentDef: componentDef,
|
|
64
63
|
areaSettings: area.areaSettings,
|
|
65
64
|
child: area.child,
|
|
65
|
+
context: area.context,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
return {
|
|
69
69
|
name: key,
|
|
70
|
+
componentDef: componentDef,
|
|
71
|
+
context: area.context,
|
|
70
72
|
areaSettings: area.areaSettings,
|
|
71
73
|
template: area.template,
|
|
72
74
|
areas: area.areas,
|
|
@@ -75,10 +77,10 @@ var NestedGridArea = function (props) {
|
|
|
75
77
|
});
|
|
76
78
|
}, [props, children]);
|
|
77
79
|
return (react_1.default.createElement(Wrapper, { "data-grid-area": props.gridArea, gridArea: props.gridArea, gap: props.gap, template: props.template, className: (0, widget_utilities_1.appendClassNames)(props.className, 'humany-grid') }, areas.map(function (area) {
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
+
if (!area.componentDef) {
|
|
81
|
+
return null;
|
|
80
82
|
}
|
|
81
|
-
return (react_1.default.createElement(
|
|
83
|
+
return (react_1.default.createElement(widget_types_grid_1.Component, { key: area.componentDef.id, id: area.componentDef.id, branch: "default", context: {} }));
|
|
82
84
|
})));
|
|
83
85
|
};
|
|
84
86
|
exports.default = NestedGridArea;
|
package/lib-esm/grid-area.d.ts
CHANGED
package/lib-esm/grid-area.js
CHANGED
|
@@ -12,7 +12,7 @@ var toCSSProps = css(templateObject_1 || (templateObject_1 = __makeTemplateObjec
|
|
|
12
12
|
}, '');
|
|
13
13
|
});
|
|
14
14
|
var GridArea = function (_a) {
|
|
15
|
-
var gridArea = _a.gridArea, areaSettings = _a.areaSettings, componentName = _a.componentName;
|
|
15
|
+
var gridArea = _a.gridArea, areaSettings = _a.areaSettings, componentName = _a.componentName, context = _a.context;
|
|
16
16
|
var children = useChildren();
|
|
17
17
|
var child = useMemo(function () {
|
|
18
18
|
return children.find(function (i) { return i.name === componentName; });
|
|
@@ -21,7 +21,7 @@ var GridArea = function (_a) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
return (React.createElement(StyledGridArea, { "data-grid-area": gridArea, gridArea: gridArea, settings: areaSettings },
|
|
24
|
-
React.createElement(Component, { key: child.id, id: child.id, branch: "default" })));
|
|
24
|
+
React.createElement(Component, { key: child.id, id: child.id, branch: "default", context: context })));
|
|
25
25
|
};
|
|
26
26
|
export default GridArea;
|
|
27
27
|
var StyledGridArea = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n grid-area: ", ";\n ", "\n"], ["\n grid-area: ", ";\n ", "\n"])), function (p) { return p.gridArea; }, toCSSProps);
|
|
@@ -4,8 +4,14 @@ declare type AreaWithChild = {
|
|
|
4
4
|
areaSettings: {
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
};
|
|
7
|
+
context: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
7
10
|
};
|
|
8
11
|
export declare type NestedArea = {
|
|
12
|
+
context: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
9
15
|
template: string[];
|
|
10
16
|
areaSettings: {
|
|
11
17
|
[key: string]: string;
|
|
@@ -27,6 +33,9 @@ export declare type GridComponentProps = {
|
|
|
27
33
|
[key: string]: GridAreaProps;
|
|
28
34
|
};
|
|
29
35
|
child: string;
|
|
36
|
+
context: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
30
39
|
};
|
|
31
40
|
export declare const GridComponent: (container: Container) => Promise<void>;
|
|
32
41
|
export default GridComponent;
|
package/lib-esm/grid.js
CHANGED
|
@@ -4,6 +4,6 @@ import NestedGridArea from './nested-grid-area';
|
|
|
4
4
|
var Grid = function (_a) {
|
|
5
5
|
var className = _a.className;
|
|
6
6
|
var properties = useProperties();
|
|
7
|
-
return (React.createElement(NestedGridArea, { template: properties.template, areas: properties.areas, gap: properties.gap, areaSettings: properties.areaSettings }));
|
|
7
|
+
return (React.createElement(NestedGridArea, { template: properties.template, areas: properties.areas, gap: properties.gap, areaSettings: properties.areaSettings, context: properties.context }));
|
|
8
8
|
};
|
|
9
9
|
export default Grid;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import { createChildren, } from '@telia-ace/widget-core';
|
|
29
|
+
import { Logger } from '@telia-ace/widget-utilities';
|
|
30
|
+
export var gridComponentHandler = function (childRef, options) {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
var platform = options.platform, node = options.node, references = options.references, definitions = options.definitions, views = options.views, branch = options.branch;
|
|
33
|
+
var childDef = definitions[childRef.definitionId];
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
if (!childDef) {
|
|
36
|
+
Logger.error("No definition found for component type '".concat(childRef.definitionId, "'."));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
var childNode = platform.createNode(childDef.type);
|
|
41
|
+
childNode.name = childRef.definitionId;
|
|
42
|
+
childNode.tags = childDef.tags || [];
|
|
43
|
+
if (childDef.properties) {
|
|
44
|
+
childNode.writeProperties(childDef.properties);
|
|
45
|
+
}
|
|
46
|
+
if (childDef.context) {
|
|
47
|
+
childNode.writeContext(childDef.context);
|
|
48
|
+
}
|
|
49
|
+
if (childDef.layout) {
|
|
50
|
+
childNode.writeLayout(childDef.layout);
|
|
51
|
+
}
|
|
52
|
+
node.appendChild(childNode, branch);
|
|
53
|
+
childRef.overrides.forEach(function (override) {
|
|
54
|
+
var options = { breakpoints: override.breakpoints };
|
|
55
|
+
if (override.properties) {
|
|
56
|
+
childNode.writeProperties(override.properties, options);
|
|
57
|
+
}
|
|
58
|
+
if (override.context) {
|
|
59
|
+
childNode.writeContext(override.context, options);
|
|
60
|
+
}
|
|
61
|
+
if (override.layout) {
|
|
62
|
+
childNode.writeLayout(override.layout, options);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (((_a = childDef.properties) === null || _a === void 0 ? void 0 : _a.areas) && !!((_b = childDef.properties) === null || _b === void 0 ? void 0 : _b.areas)) {
|
|
66
|
+
var mergedDefinitons = Object.entries(childDef.properties.areas).reduce(function (acc, _a) {
|
|
67
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
68
|
+
if (value.child) {
|
|
69
|
+
var cssProps = Object.entries(value.areaSettings || {}).reduce(function (acc, _a) {
|
|
70
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
71
|
+
acc["css-".concat(key)] = value;
|
|
72
|
+
return acc;
|
|
73
|
+
}, {});
|
|
74
|
+
acc[key] = {
|
|
75
|
+
type: 'area',
|
|
76
|
+
context: value.context || {},
|
|
77
|
+
children: [value.child],
|
|
78
|
+
properties: __assign({ 'css-grid-area': key }, cssProps),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
var subgrid = {
|
|
83
|
+
type: 'grid',
|
|
84
|
+
context: {},
|
|
85
|
+
properties: {
|
|
86
|
+
areaSettings: {},
|
|
87
|
+
areas: value.areas,
|
|
88
|
+
context: value.context,
|
|
89
|
+
gap: value.gap,
|
|
90
|
+
gridArea: value.gridArea,
|
|
91
|
+
template: value.template,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
acc[key] = subgrid;
|
|
95
|
+
}
|
|
96
|
+
return acc;
|
|
97
|
+
}, definitions);
|
|
98
|
+
createChildren(platform, childNode, Object.keys(childDef.properties.areas), mergedDefinitons, views);
|
|
99
|
+
}
|
|
100
|
+
else if ((_c = childDef.properties) === null || _c === void 0 ? void 0 : _c.child) {
|
|
101
|
+
createChildren(platform, childNode, [(_d = childDef.properties) === null || _d === void 0 ? void 0 : _d.child], definitions, views);
|
|
102
|
+
}
|
|
103
|
+
};
|
package/lib-esm/index.d.ts
CHANGED
package/lib-esm/index.js
CHANGED
|
@@ -18,11 +18,11 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
18
18
|
}
|
|
19
19
|
return ar;
|
|
20
20
|
};
|
|
21
|
+
import { Component } from '@telia-ace/widget-types-grid';
|
|
21
22
|
import { useChildren } from '@telia-ace/widget-ui';
|
|
22
23
|
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
23
24
|
import React, { useMemo } from 'react';
|
|
24
25
|
import styled, { css } from 'styled-components';
|
|
25
|
-
import GridArea from './grid-area';
|
|
26
26
|
import { isNestedGrid } from './grid-component';
|
|
27
27
|
import { generateGridTemplateAreasValue } from './utils';
|
|
28
28
|
var NestedGridArea = function (props) {
|
|
@@ -30,15 +30,20 @@ var NestedGridArea = function (props) {
|
|
|
30
30
|
var areas = useMemo(function () {
|
|
31
31
|
return Object.entries(props.areas).map(function (_a) {
|
|
32
32
|
var _b = __read(_a, 2), key = _b[0], area = _b[1];
|
|
33
|
+
var componentDef = children.find(function (child) { return child.name === key; });
|
|
33
34
|
if (!isNestedGrid(area)) {
|
|
34
35
|
return {
|
|
35
36
|
name: key,
|
|
37
|
+
componentDef: componentDef,
|
|
36
38
|
areaSettings: area.areaSettings,
|
|
37
39
|
child: area.child,
|
|
40
|
+
context: area.context,
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
return {
|
|
41
44
|
name: key,
|
|
45
|
+
componentDef: componentDef,
|
|
46
|
+
context: area.context,
|
|
42
47
|
areaSettings: area.areaSettings,
|
|
43
48
|
template: area.template,
|
|
44
49
|
areas: area.areas,
|
|
@@ -47,10 +52,10 @@ var NestedGridArea = function (props) {
|
|
|
47
52
|
});
|
|
48
53
|
}, [props, children]);
|
|
49
54
|
return (React.createElement(Wrapper, { "data-grid-area": props.gridArea, gridArea: props.gridArea, gap: props.gap, template: props.template, className: appendClassNames(props.className, 'humany-grid') }, areas.map(function (area) {
|
|
50
|
-
if (
|
|
51
|
-
return
|
|
55
|
+
if (!area.componentDef) {
|
|
56
|
+
return null;
|
|
52
57
|
}
|
|
53
|
-
return (React.createElement(
|
|
58
|
+
return (React.createElement(Component, { key: area.componentDef.id, id: area.componentDef.id, branch: "default", context: {} }));
|
|
54
59
|
})));
|
|
55
60
|
};
|
|
56
61
|
export default NestedGridArea;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-components-grid",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Grid component for ACE Widgets.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Telia Company AB",
|
|
@@ -25,10 +25,13 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"typings": "lib/index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@telia-ace/widget-
|
|
29
|
-
"@telia-ace/widget-
|
|
28
|
+
"@telia-ace/widget-core": "^1.0.4",
|
|
29
|
+
"@telia-ace/widget-types-grid": "^1.0.6",
|
|
30
|
+
"@telia-ace/widget-ui": "^1.0.6",
|
|
30
31
|
"@telia-ace/widget-utilities": "^1.0.1",
|
|
31
|
-
"@webprovisions/platform": "^1.1.2"
|
|
32
|
+
"@webprovisions/platform": "^1.1.2"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
32
35
|
"react": "^16.8.0",
|
|
33
36
|
"react-dom": "^16.8.0",
|
|
34
37
|
"styled-components": "^4.3.2"
|
|
@@ -38,5 +41,5 @@
|
|
|
38
41
|
"@types/react-dom": "^16.8.0",
|
|
39
42
|
"@types/styled-components": "^5.1.7"
|
|
40
43
|
},
|
|
41
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "993320b5ff4692cf9cb896b0011acf5f42734a74"
|
|
42
45
|
}
|