@telia-ace/widget-types-grid 1.0.8 → 1.0.11
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/LICENSE.txt +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/component-platform-factory.d.ts +13 -13
- package/{lib → dist}/index.d.ts +5 -4
- package/dist/index.js +1416 -0
- package/dist/index.js.map +1 -0
- package/dist/render.js +95 -0
- package/dist/render.js.map +1 -0
- package/{lib-esm → dist}/services.d.ts +7 -7
- package/{lib-esm → dist}/site-provider.d.ts +5 -5
- package/{lib → dist}/ui/animated-view.d.ts +6 -6
- package/{lib-esm → dist}/ui/component.d.ts +16 -21
- package/{lib → dist}/ui/detached-component.d.ts +7 -7
- package/{lib → dist}/ui/determine-slide-direction.d.ts +26 -26
- package/{lib → dist}/ui/html-element-handlers.d.ts +18 -18
- package/{lib-esm → dist}/ui/index.d.ts +6 -6
- package/{lib → dist}/ui/not-found.d.ts +6 -6
- package/{lib-esm → dist}/ui/prepare-dom.d.ts +20 -20
- package/{lib-esm → dist}/ui/render.d.ts +3 -3
- package/{lib-esm → dist}/ui/resolvable-component.d.ts +7 -7
- package/dist/ui/styles.d.ts +17 -0
- package/{lib-esm → dist}/ui/switch.d.ts +11 -11
- package/{lib → dist}/ui/unmount.d.ts +2 -2
- package/{lib-esm → dist}/ui/use-component-node-properties.d.ts +3 -3
- package/{lib-esm → dist}/ui/use-router.d.ts +4 -4
- package/{lib-esm → dist}/ui/view-outlet.d.ts +32 -32
- package/{lib → dist}/ui/view.d.ts +6 -6
- package/{lib-esm → dist}/ui/wrapper.d.ts +7 -7
- package/dist/unmount.js +4 -0
- package/dist/unmount.js.map +1 -0
- package/{lib-esm → dist}/widget.d.ts +54 -54
- package/package.json +18 -17
- package/lib/component-platform-factory.d.ts +0 -13
- package/lib/component-platform-factory.js +0 -105
- package/lib/index.js +0 -16
- package/lib/services.d.ts +0 -7
- package/lib/services.js +0 -99
- package/lib/site-provider.d.ts +0 -5
- package/lib/site-provider.js +0 -18
- package/lib/ui/animated-view.js +0 -142
- package/lib/ui/component.d.ts +0 -21
- package/lib/ui/component.js +0 -180
- package/lib/ui/detached-component.js +0 -73
- package/lib/ui/determine-slide-direction.js +0 -51
- package/lib/ui/html-element-handlers.js +0 -128
- package/lib/ui/index.d.ts +0 -6
- package/lib/ui/index.js +0 -19
- package/lib/ui/not-found.js +0 -83
- package/lib/ui/prepare-dom.d.ts +0 -20
- package/lib/ui/prepare-dom.js +0 -122
- package/lib/ui/render.d.ts +0 -3
- package/lib/ui/render.js +0 -11
- package/lib/ui/resolvable-component.d.ts +0 -7
- package/lib/ui/resolvable-component.js +0 -87
- package/lib/ui/switch.d.ts +0 -11
- package/lib/ui/switch.js +0 -58
- package/lib/ui/unmount.js +0 -4
- package/lib/ui/use-component-node-properties.d.ts +0 -3
- package/lib/ui/use-component-node-properties.js +0 -44
- package/lib/ui/use-router.d.ts +0 -4
- package/lib/ui/use-router.js +0 -32
- package/lib/ui/view-outlet.d.ts +0 -32
- package/lib/ui/view-outlet.js +0 -151
- package/lib/ui/view.js +0 -75
- package/lib/ui/wrapper.d.ts +0 -7
- package/lib/ui/wrapper.js +0 -108
- package/lib/widget.d.ts +0 -54
- package/lib/widget.js +0 -554
- package/lib-esm/component-platform-factory.js +0 -101
- package/lib-esm/index.d.ts +0 -4
- package/lib-esm/index.js +0 -4
- package/lib-esm/services.js +0 -67
- package/lib-esm/site-provider.js +0 -14
- package/lib-esm/ui/animated-view.d.ts +0 -6
- package/lib-esm/ui/animated-view.js +0 -114
- package/lib-esm/ui/component.js +0 -151
- package/lib-esm/ui/detached-component.d.ts +0 -7
- package/lib-esm/ui/detached-component.js +0 -45
- package/lib-esm/ui/determine-slide-direction.d.ts +0 -26
- package/lib-esm/ui/determine-slide-direction.js +0 -46
- package/lib-esm/ui/html-element-handlers.d.ts +0 -18
- package/lib-esm/ui/html-element-handlers.js +0 -120
- package/lib-esm/ui/index.js +0 -6
- package/lib-esm/ui/not-found.d.ts +0 -6
- package/lib-esm/ui/not-found.js +0 -58
- package/lib-esm/ui/prepare-dom.js +0 -116
- package/lib-esm/ui/render.js +0 -6
- package/lib-esm/ui/resolvable-component.js +0 -62
- package/lib-esm/ui/switch.js +0 -53
- package/lib-esm/ui/unmount.d.ts +0 -2
- package/lib-esm/ui/unmount.js +0 -2
- package/lib-esm/ui/use-component-node-properties.js +0 -42
- package/lib-esm/ui/use-router.js +0 -30
- package/lib-esm/ui/view-outlet.js +0 -126
- package/lib-esm/ui/view.d.ts +0 -6
- package/lib-esm/ui/view.js +0 -70
- package/lib-esm/ui/wrapper.js +0 -80
- package/lib-esm/widget.js +0 -551
package/lib-esm/services.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createPlatform } from './component-platform-factory';
|
|
2
|
-
import { createSiteProvider } from './site-provider';
|
|
3
|
-
export var createRoutingService = function (container) {
|
|
4
|
-
return import('@telia-ace/widget-routing').then(function (_a) {
|
|
5
|
-
var RoutingService = _a.RoutingService, HistoryMode = _a.HistoryMode;
|
|
6
|
-
return container.get('settings').then(function (settings) {
|
|
7
|
-
var _a = settings.routing, _b = _a.initialPath, initialPath = _b === void 0 ? '/' : _b, _c = _a.mode, mode = _c === void 0 ? HistoryMode.scopedHash : _c, basePath = _a.basePath, views = settings.views;
|
|
8
|
-
var routingService = new RoutingService(container, {
|
|
9
|
-
initialPath: initialPath,
|
|
10
|
-
mode: mode,
|
|
11
|
-
routes: Object.keys(views).map(function (name) { return ({
|
|
12
|
-
name: name,
|
|
13
|
-
path: views[name].path,
|
|
14
|
-
}); }),
|
|
15
|
-
basePath: basePath,
|
|
16
|
-
});
|
|
17
|
-
return routingService;
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
export var createStorageService = function (container) {
|
|
22
|
-
return import('@telia-ace/widget-services').then(function (_a) {
|
|
23
|
-
var StorageProvider = _a.StorageProvider;
|
|
24
|
-
return new StorageProvider();
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export var createServiceClient = function (container) {
|
|
28
|
-
return import('@telia-ace/knowledge-serviceclient').then(function (_a) {
|
|
29
|
-
var ServiceClient = _a.ServiceClient, ServiceProxy = _a.ServiceProxy;
|
|
30
|
-
return container.get('settings').then(function (settings) {
|
|
31
|
-
var _a = container.get('$widget'), name = _a.name, events = _a.events;
|
|
32
|
-
var _b = settings.data, _c = _b.projection, projection = _c === void 0 ? '' : _c, _d = _b.site, site = _d === void 0 ? 'current' : _d, _e = _b.forceHttps, forceHttps = _e === void 0 ? false : _e;
|
|
33
|
-
var proxy = new ServiceProxy(projection, { credentials: 'same-origin' });
|
|
34
|
-
// Replacing '_contact' & '_contact-method' while
|
|
35
|
-
// still using the shadow widget concept
|
|
36
|
-
var client = new ServiceClient(proxy, {
|
|
37
|
-
funnel: name.replace('_contact-method', '').replace('_contact', ''),
|
|
38
|
-
site: createSiteProvider(site, forceHttps),
|
|
39
|
-
});
|
|
40
|
-
events.subscribe('widget:settings-updated', function (event, _a) {
|
|
41
|
-
var data = _a.data;
|
|
42
|
-
if (data && data.projection !== projection) {
|
|
43
|
-
client.proxy.setBaseUrl(data.projection);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return client;
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
export var createActionResolver = function (container) {
|
|
51
|
-
return import('@telia-ace/widget-core').then(function (_a) {
|
|
52
|
-
var ActionResolver = _a.ActionResolver;
|
|
53
|
-
return new ActionResolver(container);
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
export var createComponentResolver = function (container) {
|
|
57
|
-
return import('@telia-ace/widget-core').then(function (_a) {
|
|
58
|
-
var ComponentResolver = _a.ComponentResolver;
|
|
59
|
-
return new ComponentResolver(container);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
export var createComponentPlatform = function (container) {
|
|
63
|
-
return import('@telia-ace/widget-core').then(function (_a) {
|
|
64
|
-
var ComponentPlatform = _a.ComponentPlatform, createComponentModel = _a.createComponentModel;
|
|
65
|
-
return createPlatform(container.get('$widget'));
|
|
66
|
-
});
|
|
67
|
-
};
|
package/lib-esm/site-provider.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export var createSiteProvider = function (site, forceHttps) {
|
|
2
|
-
return function () {
|
|
3
|
-
var parseLocation = function (href) {
|
|
4
|
-
var link = document.createElement('a');
|
|
5
|
-
link.href = href;
|
|
6
|
-
return link;
|
|
7
|
-
};
|
|
8
|
-
var location = window.location;
|
|
9
|
-
if (site === 'referrer' && document.referrer) {
|
|
10
|
-
location = parseLocation(document.referrer);
|
|
11
|
-
}
|
|
12
|
-
return [forceHttps ? 'https:' : '', '//', location.host, location.pathname].join('');
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
28
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
|
-
if (!m) return o;
|
|
30
|
-
var i = m.call(o), r, ar = [], e;
|
|
31
|
-
try {
|
|
32
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
33
|
-
}
|
|
34
|
-
catch (error) { e = { error: error }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
-
}
|
|
39
|
-
finally { if (e) throw e.error; }
|
|
40
|
-
}
|
|
41
|
-
return ar;
|
|
42
|
-
};
|
|
43
|
-
import { Grid, transitionComposer, useComponentNode, useContainer, useContext, useProperties, useRouteData, useRouter, useScroll, } from '@telia-ace/widget-ui';
|
|
44
|
-
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
45
|
-
import React, { useState } from 'react';
|
|
46
|
-
import { Transition, TransitionGroup } from 'react-transition-group';
|
|
47
|
-
import styled from 'styled-components';
|
|
48
|
-
import Component from './component';
|
|
49
|
-
import { determineSlideDirection, SlideDirection } from './determine-slide-direction';
|
|
50
|
-
import Switch from './switch';
|
|
51
|
-
var StyledViewContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n flex: 1;\n"], ["\n position: relative;\n width: 100%;\n flex: 1;\n"])));
|
|
52
|
-
var StyledView = styled(Grid)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n left: 0;\n right: 0;\n ", "\n ", "\n"], ["\n position: absolute;\n left: 0;\n right: 0;\n ", "\n ", "\n"])), function (p) { return !!p.animationCss && p.animationCss; }, function (p) { return !!p.scrollableCss && p.scrollableCss; });
|
|
53
|
-
var routeHierarchy = {
|
|
54
|
-
index: 1,
|
|
55
|
-
search: 2,
|
|
56
|
-
browse: 3,
|
|
57
|
-
guide: 4,
|
|
58
|
-
contact: 5,
|
|
59
|
-
'contact-method': 6,
|
|
60
|
-
conversation: 7,
|
|
61
|
-
};
|
|
62
|
-
var AnimatedView = function (_a) {
|
|
63
|
-
var _b = _a.className, className = _b === void 0 ? '' : _b, other = __rest(_a, ["className"]);
|
|
64
|
-
var _c = __read(useState('index'), 2), routeName = _c[0], setRouteName = _c[1];
|
|
65
|
-
var _d = __read(useState(SlideDirection.forth), 2), transitionDirection = _d[0], setTransitionDirection = _d[1];
|
|
66
|
-
var nextRoute = useRouteData();
|
|
67
|
-
var router = useRouter();
|
|
68
|
-
var properties = useProperties();
|
|
69
|
-
var context = useContext();
|
|
70
|
-
var container = useContainer();
|
|
71
|
-
var node = useComponentNode();
|
|
72
|
-
var _e = context.gap, gap = _e === void 0 ? '0' : _e;
|
|
73
|
-
var _f = properties.columns, columns = _f === void 0 ? 1 : _f, _g = properties.animation, animation = _g === void 0 ? 'none' : _g, _h = properties.scrollable, scrollable = _h === void 0 ? false : _h, areaProperties = __rest(properties, ["columns", "animation", "scrollable"]);
|
|
74
|
-
var _j = __read(useScroll(scrollable), 2), scrollableCss = _j[0], elem = _j[1];
|
|
75
|
-
if (!node || !router) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
var location = router.location;
|
|
79
|
-
if (nextRoute.name !== routeName && nextRoute.name !== '' && animation) {
|
|
80
|
-
setTransitionDirection(determineSlideDirection(routeName, nextRoute.name, routeHierarchy));
|
|
81
|
-
setRouteName(nextRoute.name);
|
|
82
|
-
}
|
|
83
|
-
var views = container.get('$settings').views;
|
|
84
|
-
if (!Object.keys(views).length) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
var renderView = function (name, transitionState, direction) {
|
|
88
|
-
var animationStyles = getAnimation(transitionState, direction);
|
|
89
|
-
var childNode = node.getChildren(name)[0];
|
|
90
|
-
return (React.createElement(StyledView, __assign({}, other, areaProperties, { scrollableCss: scrollableCss, ref: elem, columns: columns, gap: gap }, animationStyles, { className: appendClassNames(className, 'humany-view') }),
|
|
91
|
-
React.createElement(Component, { id: childNode.id, branch: "default" })));
|
|
92
|
-
};
|
|
93
|
-
var getAnimation = function (transitionState, direction) {
|
|
94
|
-
var _a;
|
|
95
|
-
if (animation === 'slide' || animation === 'fade') {
|
|
96
|
-
return _a = {
|
|
97
|
-
animationCss: transitionComposer.composeViewTransition(transitionState, animation, direction)
|
|
98
|
-
},
|
|
99
|
-
_a['data-state'] = transitionState,
|
|
100
|
-
_a;
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
};
|
|
104
|
-
return (React.createElement(StyledViewContainer, { className: "humany-animated-view" },
|
|
105
|
-
React.createElement(TransitionGroup, { component: null, childFactory: function (child) {
|
|
106
|
-
return React.cloneElement(child, { direction: transitionDirection });
|
|
107
|
-
} },
|
|
108
|
-
React.createElement(Transition, { key: routeName, timeout: { enter: 500, exit: 500 }, onEnter: function (node) { return node === null || node === void 0 ? void 0 : node.clientHeight; }, unmountOnExit: true, direction: SlideDirection.forth }, function (state, _a) {
|
|
109
|
-
var direction = _a.direction;
|
|
110
|
-
return (React.createElement(Switch, { views: views, location: location, render: function (name) { return renderView(name, state, direction); } }));
|
|
111
|
-
}))));
|
|
112
|
-
};
|
|
113
|
-
export default AnimatedView;
|
|
114
|
-
var templateObject_1, templateObject_2;
|
package/lib-esm/ui/component.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
28
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
|
-
if (!m) return o;
|
|
30
|
-
var i = m.call(o), r, ar = [], e;
|
|
31
|
-
try {
|
|
32
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
33
|
-
}
|
|
34
|
-
catch (error) { e = { error: error }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
38
|
-
}
|
|
39
|
-
finally { if (e) throw e.error; }
|
|
40
|
-
}
|
|
41
|
-
return ar;
|
|
42
|
-
};
|
|
43
|
-
import { asDescriptor } from '@telia-ace/widget-core';
|
|
44
|
-
import { ComponentNodeContext, ComponentPropertyContext, filterCssProps, paddedBorderTabStyle, useColumns, useComponentPlatform, useContainer, useContext, useLayout, } from '@telia-ace/widget-ui';
|
|
45
|
-
import React, { forwardRef, useEffect, useState } from 'react';
|
|
46
|
-
import styled, { css, ThemeContext, ThemeProvider } from 'styled-components';
|
|
47
|
-
import AnimatedView from './animated-view';
|
|
48
|
-
import ResolvableComponent from './resolvable-component';
|
|
49
|
-
import useComponentNodeProperties from './use-component-node-properties';
|
|
50
|
-
import View from './view';
|
|
51
|
-
var isVisible = function (size, node) {
|
|
52
|
-
if (node) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
if (typeof size === 'string') {
|
|
56
|
-
return size === 'full';
|
|
57
|
-
}
|
|
58
|
-
return size > 0;
|
|
59
|
-
};
|
|
60
|
-
var Component = forwardRef(function (_a, ref) {
|
|
61
|
-
var _b;
|
|
62
|
-
var _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.isTabbing, isTabbing = _d === void 0 ? false : _d, id = _a.id, branch = _a.branch, node = _a.node, ariaLabel = _a.ariaLabel, tabIndex = _a.tabIndex, extraContext = _a.context, other = __rest(_a, ["className", "isTabbing", "id", "branch", "node", "ariaLabel", "tabIndex", "context"]);
|
|
63
|
-
var components = useComponentPlatform();
|
|
64
|
-
var container = useContainer();
|
|
65
|
-
var _e = __read(useState(), 2), descriptor = _e[0], setDescriptor = _e[1];
|
|
66
|
-
var themeContext = React.useContext(ThemeContext) || {};
|
|
67
|
-
var columns = useColumns();
|
|
68
|
-
var context = useContext(id);
|
|
69
|
-
var properties = useComponentNodeProperties(id);
|
|
70
|
-
var _f = useLayout(id), _g = _f.size, size = _g === void 0 ? 'none' : _g, _h = _f.indent, indent = _h === void 0 ? 0 : _h;
|
|
71
|
-
var visible = isVisible(size, node);
|
|
72
|
-
useEffect(function () {
|
|
73
|
-
if (components) {
|
|
74
|
-
if (id && !node) {
|
|
75
|
-
var componentNode = components.nodes.get(id);
|
|
76
|
-
if (componentNode) {
|
|
77
|
-
setDescriptor(asDescriptor(componentNode, branch));
|
|
78
|
-
if (visible) {
|
|
79
|
-
var unmount_1 = componentNode.mount(container);
|
|
80
|
-
return function () {
|
|
81
|
-
unmount_1();
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (node) {
|
|
87
|
-
setDescriptor(asDescriptor(node, branch));
|
|
88
|
-
var unmount_2 = node.mount(container);
|
|
89
|
-
return function () {
|
|
90
|
-
unmount_2();
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}, [components, id, node, visible]);
|
|
95
|
-
if (!descriptor || !visible) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
var mergedContexts = __assign(__assign({}, context), (extraContext || {}));
|
|
99
|
-
var cardinal = mergedContexts.cardinal, _j = mergedContexts.fonts, contextFonts = _j === void 0 ? {} : _j, _k = mergedContexts.accessibility, accessibility = _k === void 0 ? {} : _k, restContext = __rest(mergedContexts, ["cardinal", "fonts", "accessibility"]);
|
|
100
|
-
var fonts = {
|
|
101
|
-
type: contextFonts.type,
|
|
102
|
-
base: contextFonts.base || '16px',
|
|
103
|
-
small: contextFonts.small || '0.8em',
|
|
104
|
-
normal: contextFonts.normal || '1em',
|
|
105
|
-
medium: contextFonts.medium || '1.2em',
|
|
106
|
-
large: contextFonts.large || '1.6em',
|
|
107
|
-
huge: contextFonts.huge || '2.5em',
|
|
108
|
-
};
|
|
109
|
-
var theme = __assign(__assign({}, restContext), { fonts: fonts, accessibility: __assign(__assign({}, accessibility), { isTabbing: ((_b = themeContext.accessibility) === null || _b === void 0 ? void 0 : _b.isTabbing) || isTabbing }) });
|
|
110
|
-
if (typeof cardinal === 'number') {
|
|
111
|
-
theme.sizes = {
|
|
112
|
-
cardinal: cardinal,
|
|
113
|
-
small: "".concat(cardinal, "px"),
|
|
114
|
-
normal: "".concat(cardinal * 3, "px"),
|
|
115
|
-
medium: "".concat(cardinal * 5, "px"),
|
|
116
|
-
large: "".concat(cardinal * 8, "px"),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return (React.createElement(ThemeProvider, { theme: theme },
|
|
120
|
-
React.createElement(ComponentNodeContext.Provider, { value: descriptor },
|
|
121
|
-
React.createElement(ComponentPropertyContext.Provider, { value: properties }, (function () {
|
|
122
|
-
var props = __assign({ 'data-width': size === 'full' ? columns : Math.min(size, columns), 'data-indent': indent, 'data-name': descriptor.name, 'data-node-id': descriptor.id, 'data-component-type': descriptor.type, 'aria-label': ariaLabel, tabIndex: tabIndex, id: descriptor.id, role: properties && properties.role }, other);
|
|
123
|
-
switch (descriptor.type) {
|
|
124
|
-
case 'view': {
|
|
125
|
-
return typeof properties.animation === 'string' &&
|
|
126
|
-
properties.animation !== 'none' ? (React.createElement(StyledAnimatedView, __assign({}, props, { className: className }))) : (React.createElement(StyledView, __assign({}, props, { className: className })));
|
|
127
|
-
}
|
|
128
|
-
default: {
|
|
129
|
-
var cssProps = filterCssProps(properties);
|
|
130
|
-
return (React.createElement(ResolvableComponent, __assign({ ref: ref }, props, cssProps, { className: className })));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
})()))));
|
|
134
|
-
});
|
|
135
|
-
export var styling = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n outline: none;\n box-sizing: border-box;\n * {\n ", "\n box-sizing: border-box;\n }\n\n grid-column: ", ";\n\n ", "\n\n ", "\n\n &:focus {\n ", ";\n }\n"], ["\n outline: none;\n box-sizing: border-box;\n * {\n ", "\n box-sizing: border-box;\n }\n\n grid-column: ", ";\n\n ", "\n\n ", "\n\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return !((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && 'outline: none;'; }, function (p) {
|
|
136
|
-
return p['data-indent']
|
|
137
|
-
? "".concat(p['data-indent'] + 1, " / ").concat(p['data-indent'] + p['data-width'] + 1)
|
|
138
|
-
: "span ".concat(p['data-width']);
|
|
139
|
-
}, function (p) {
|
|
140
|
-
var _a;
|
|
141
|
-
return ((_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.type) &&
|
|
142
|
-
"\n font-family: ".concat(p.theme.fonts.type, ";\n\n input, textarea {\n font-family: ").concat(p.theme.fonts.type, ";\n }\n ");
|
|
143
|
-
}, function (p) {
|
|
144
|
-
var _a;
|
|
145
|
-
return ((_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.base) &&
|
|
146
|
-
"\n font-size: ".concat(p.theme.fonts.base, ";\n ");
|
|
147
|
-
}, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && paddedBorderTabStyle; });
|
|
148
|
-
var StyledView = styled(View)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styling);
|
|
149
|
-
var StyledAnimatedView = styled(AnimatedView)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styling);
|
|
150
|
-
export default Component;
|
|
151
|
-
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ComponentNode, ComponentPlatform } from '@telia-ace/widget-core';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
builder: (components: ComponentPlatform) => Promise<ComponentNode>;
|
|
5
|
-
};
|
|
6
|
-
declare const DetachedComponent: React.FC<Props>;
|
|
7
|
-
export default DetachedComponent;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
import { useContainer } from '@telia-ace/widget-ui';
|
|
18
|
-
import React, { useEffect, useState } from 'react';
|
|
19
|
-
import Component from './component';
|
|
20
|
-
var DetachedComponent = function (_a) {
|
|
21
|
-
var builder = _a.builder;
|
|
22
|
-
var container = useContainer();
|
|
23
|
-
var _b = __read(useState(null), 2), node = _b[0], setNode = _b[1];
|
|
24
|
-
useEffect(function () {
|
|
25
|
-
container.getAsync('components').then(function (components) {
|
|
26
|
-
return builder(components).then(function (createdNode) {
|
|
27
|
-
setNode(createdNode);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}, []);
|
|
31
|
-
useEffect(function () {
|
|
32
|
-
return function () {
|
|
33
|
-
if (node) {
|
|
34
|
-
container.getAsync('components').then(function (components) {
|
|
35
|
-
components.nodes.detached = components.nodes.detached.filter(function (n) { return n.id !== node.id; });
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}, [node]);
|
|
40
|
-
if (!node) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return React.createElement(Component, { id: node.id, node: node, branch: "default" });
|
|
44
|
-
};
|
|
45
|
-
export default DetachedComponent;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare enum SlideDirection {
|
|
2
|
-
back = "back",
|
|
3
|
-
forth = "forth"
|
|
4
|
-
}
|
|
5
|
-
export interface RouteStructure {
|
|
6
|
-
name: string;
|
|
7
|
-
children: RouteStructure[];
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Recursively find the parents of a nested route
|
|
11
|
-
* @param routeName Name of route to find
|
|
12
|
-
* @param routes Routes to look in
|
|
13
|
-
* @param trail Trail of parents
|
|
14
|
-
* @param level Level of the array currently looking in
|
|
15
|
-
*/
|
|
16
|
-
export declare const findParentRoutes: (routeName: string, routes: RouteStructure[], trail?: string[], level?: number) => string[] | null;
|
|
17
|
-
/**
|
|
18
|
-
* Determine if the sliding animation should back or forth
|
|
19
|
-
* @param currentRouteName Name of current route
|
|
20
|
-
* @param nextRouteName Name of route to transition to
|
|
21
|
-
* @param routeRanking Hierarchical route ranking for the widget
|
|
22
|
-
*/
|
|
23
|
-
export declare const determineSlideDirection: (currentRouteName: string, nextRouteName: string, routeRanking: RouteRanking) => SlideDirection;
|
|
24
|
-
export declare type RouteRanking = {
|
|
25
|
-
[key: string]: number;
|
|
26
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export var SlideDirection;
|
|
2
|
-
(function (SlideDirection) {
|
|
3
|
-
SlideDirection["back"] = "back";
|
|
4
|
-
SlideDirection["forth"] = "forth";
|
|
5
|
-
})(SlideDirection || (SlideDirection = {}));
|
|
6
|
-
/**
|
|
7
|
-
* Recursively find the parents of a nested route
|
|
8
|
-
* @param routeName Name of route to find
|
|
9
|
-
* @param routes Routes to look in
|
|
10
|
-
* @param trail Trail of parents
|
|
11
|
-
* @param level Level of the array currently looking in
|
|
12
|
-
*/
|
|
13
|
-
export var findParentRoutes = function (routeName, routes, trail, level) {
|
|
14
|
-
if (trail === void 0) { trail = []; }
|
|
15
|
-
if (level === void 0) { level = 0; }
|
|
16
|
-
var found = null;
|
|
17
|
-
routes.forEach(function (route, index) {
|
|
18
|
-
if (!found) {
|
|
19
|
-
if (route.name === routeName) {
|
|
20
|
-
found = route;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
trail[level] = route.name;
|
|
24
|
-
found = findParentRoutes(routeName, route.children, trail, level + 1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
if (!found) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return trail;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Determine if the sliding animation should back or forth
|
|
35
|
-
* @param currentRouteName Name of current route
|
|
36
|
-
* @param nextRouteName Name of route to transition to
|
|
37
|
-
* @param routeRanking Hierarchical route ranking for the widget
|
|
38
|
-
*/
|
|
39
|
-
export var determineSlideDirection = function (currentRouteName, nextRouteName, routeRanking) {
|
|
40
|
-
if (typeof routeRanking[currentRouteName] === 'number' &&
|
|
41
|
-
typeof routeRanking[nextRouteName] === 'number' &&
|
|
42
|
-
routeRanking[currentRouteName] > routeRanking[nextRouteName]) {
|
|
43
|
-
return SlideDirection.back;
|
|
44
|
-
}
|
|
45
|
-
return SlideDirection.forth;
|
|
46
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const renderSymbol: (symbol?: {
|
|
2
|
-
type: string;
|
|
3
|
-
content: string;
|
|
4
|
-
} | undefined) => string | undefined;
|
|
5
|
-
export declare type TriggerElementOptions = {
|
|
6
|
-
symbol?: {
|
|
7
|
-
type: string;
|
|
8
|
-
content: string;
|
|
9
|
-
};
|
|
10
|
-
widgetName: string;
|
|
11
|
-
label?: string;
|
|
12
|
-
ariaLabel?: string;
|
|
13
|
-
tooltip?: string;
|
|
14
|
-
};
|
|
15
|
-
export declare function createTriggerElement(element: HTMLElement, options: TriggerElementOptions): () => void;
|
|
16
|
-
export declare function setInactive(elements: HTMLElement | HTMLElement[], title?: string): void;
|
|
17
|
-
export declare function setLoading(elements: HTMLElement | HTMLElement[]): void;
|
|
18
|
-
export declare function setActive(elements: HTMLElement | HTMLElement[], title?: string): void;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// tslint:disable max-line-length
|
|
2
|
-
export var renderSymbol = function (symbol) {
|
|
3
|
-
if (symbol) {
|
|
4
|
-
var type = symbol.type, content = symbol.content;
|
|
5
|
-
switch (type) {
|
|
6
|
-
case 'FontAwesome':
|
|
7
|
-
return "<i class=\"humany-icon fa fa-".concat(content, "\"></i>");
|
|
8
|
-
case 'Uri':
|
|
9
|
-
return "<i class=\"humany-icon humany-custom-icon\" style=\"background: url(".concat(content, ") no-repeat center center;background-size: contain;\"></i>");
|
|
10
|
-
default:
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var triggerTabHandler = function (triggerDOMElement) {
|
|
16
|
-
var toggleTabbing = function (element, tabbing) {
|
|
17
|
-
if (!element) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (tabbing) {
|
|
21
|
-
element.classList.add('humany-tabbing');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
element.classList.remove('humany-tabbing');
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var handleKeydown = function (e) {
|
|
28
|
-
if (e.key === 'Tab') {
|
|
29
|
-
toggleTabbing(triggerDOMElement, true);
|
|
30
|
-
}
|
|
31
|
-
else if (!(e.key === 'Enter' &&
|
|
32
|
-
document.activeElement &&
|
|
33
|
-
document.activeElement.classList.contains('humany-trigger'))) {
|
|
34
|
-
toggleTabbing(triggerDOMElement, false);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var handleClick = function (e) {
|
|
38
|
-
if (document.activeElement &&
|
|
39
|
-
document.activeElement.classList.contains('humany-trigger') &&
|
|
40
|
-
document.activeElement.classList.contains('humany-tabbing')) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
toggleTabbing(triggerDOMElement, false);
|
|
44
|
-
};
|
|
45
|
-
document.addEventListener('keydown', handleKeydown);
|
|
46
|
-
document.addEventListener('click', handleClick);
|
|
47
|
-
return function () {
|
|
48
|
-
document.removeEventListener('keydown', handleKeydown);
|
|
49
|
-
document.removeEventListener('click', handleClick);
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export function createTriggerElement(element, options) {
|
|
53
|
-
var symbol = options.symbol, widgetName = options.widgetName, _a = options.label, label = _a === void 0 ? '' : _a, _b = options.ariaLabel, ariaLabel = _b === void 0 ? '' : _b, _c = options.tooltip, tooltip = _c === void 0 ? '' : _c;
|
|
54
|
-
element.classList.add('humany-trigger');
|
|
55
|
-
element.classList.add("humany_".concat(widgetName));
|
|
56
|
-
if (label.length) {
|
|
57
|
-
element.classList.add('humany-has-text');
|
|
58
|
-
}
|
|
59
|
-
if (ariaLabel.length && !element.getAttribute('aria-label')) {
|
|
60
|
-
element.setAttribute('aria-label', ariaLabel);
|
|
61
|
-
}
|
|
62
|
-
if (ariaLabel.length && !element.getAttribute('tabindex')) {
|
|
63
|
-
element.setAttribute('tabindex', '0');
|
|
64
|
-
}
|
|
65
|
-
if (tooltip.length && !element.getAttribute('title')) {
|
|
66
|
-
element.setAttribute('title', tooltip);
|
|
67
|
-
}
|
|
68
|
-
var symbolHtml = renderSymbol(symbol) || '';
|
|
69
|
-
element.innerHTML = "".concat(symbolHtml, "\n <span class=\"humany-close\">\n <svg width=\"18\" height=\"9\" viewBox=\"0 0 18 9\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9 9C8.81794 9.00045 8.63759 8.96634 8.46939 8.89965C8.3012 8.83295 8.14851 8.735 8.02015 8.61145L0.194523 1.12367C0.068294 0.99862 -0.00155266 0.831133 2.61958e-05 0.657285C0.00160506 0.483436 0.0744832 0.317136 0.202964 0.194202C0.331445 0.0712675 0.505249 0.00153576 0.686941 2.50649e-05C0.868634 -0.00148563 1.04368 0.0653456 1.17437 0.186125L9 7.6739L16.8256 0.186125C16.9563 0.0653456 17.1314 -0.00148563 17.3131 2.50649e-05C17.4948 0.00153576 17.6686 0.0712675 17.797 0.194202C17.9255 0.317136 17.9984 0.483436 18 0.657285C18.0016 0.831133 17.9317 0.99862 17.8055 1.12367L9.97985 8.61145C9.85149 8.735 9.6988 8.83295 9.53061 8.89965C9.36241 8.96634 9.18206 9.00045 9 9Z\" fill=\"white\"/>\n </svg>\n </span>\n <span class=\"humany-loader\">\n <svg viewBox=\"25 25 50 50\">\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"20\"\n fill=\"none\"\n stroke=\"#000\"\n stroke-width=\"2\"\n stroke-miterlimit=\"10\" />\n </svg>\n </span>\n ").concat(label.length ? "<span>".concat(label, "</span>") : '');
|
|
70
|
-
setTimeout(function () { return element && element.classList.add('humany-rendered'); });
|
|
71
|
-
return triggerTabHandler(element);
|
|
72
|
-
}
|
|
73
|
-
export function setInactive(elements, title) {
|
|
74
|
-
if (elements instanceof HTMLElement) {
|
|
75
|
-
if (title) {
|
|
76
|
-
elements.setAttribute('title', title);
|
|
77
|
-
}
|
|
78
|
-
elements.classList.remove('humany-active');
|
|
79
|
-
elements.classList.remove('humany-loading');
|
|
80
|
-
}
|
|
81
|
-
else if (elements instanceof Array) {
|
|
82
|
-
elements.forEach(function (e) {
|
|
83
|
-
if (title) {
|
|
84
|
-
e.setAttribute('title', title);
|
|
85
|
-
}
|
|
86
|
-
e.classList.remove('humany-active');
|
|
87
|
-
e.classList.remove('humany-loading');
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export function setLoading(elements) {
|
|
92
|
-
if (elements instanceof HTMLElement) {
|
|
93
|
-
elements.classList.remove('humany-active');
|
|
94
|
-
elements.classList.add('humany-loading');
|
|
95
|
-
}
|
|
96
|
-
else if (elements instanceof Array) {
|
|
97
|
-
elements.forEach(function (e) {
|
|
98
|
-
e.classList.remove('humany-active');
|
|
99
|
-
e.classList.add('humany-loading');
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export function setActive(elements, title) {
|
|
104
|
-
if (elements instanceof HTMLElement) {
|
|
105
|
-
if (title) {
|
|
106
|
-
elements.setAttribute('title', title);
|
|
107
|
-
}
|
|
108
|
-
elements.classList.add('humany-active');
|
|
109
|
-
elements.classList.remove('humany-loading');
|
|
110
|
-
}
|
|
111
|
-
else if (elements instanceof Array) {
|
|
112
|
-
elements.forEach(function (e) {
|
|
113
|
-
if (title) {
|
|
114
|
-
e.setAttribute('title', title);
|
|
115
|
-
}
|
|
116
|
-
e.classList.add('humany-active');
|
|
117
|
-
e.classList.remove('humany-loading');
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
package/lib-esm/ui/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default as AnimatedView } from './animated-view';
|
|
2
|
-
export { default as Component } from './component';
|
|
3
|
-
export { prepareDOMElements, TriggerType } from './prepare-dom';
|
|
4
|
-
export { default as ResolvableComponent } from './resolvable-component';
|
|
5
|
-
export { default as View } from './view';
|
|
6
|
-
export { default as Wrapper } from './wrapper';
|