@telia-ace/widget-components-widget-header 1.0.5 → 1.0.8

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.
Files changed (43) hide show
  1. package/{lib-esm → dist}/avatar.d.ts +0 -0
  2. package/{lib-esm → dist}/back.d.ts +0 -0
  3. package/{lib-esm → dist}/close.d.ts +0 -0
  4. package/{lib-esm → dist}/index.d.ts +0 -0
  5. package/dist/index.js +5 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index2.js +114 -0
  8. package/dist/index2.js.map +1 -0
  9. package/{lib-esm → dist}/minimize.d.ts +0 -0
  10. package/{lib-esm → dist}/node.d.ts +0 -0
  11. package/{lib-esm → dist}/utils.d.ts +0 -0
  12. package/{lib-esm → dist}/widget-header-component.d.ts +0 -0
  13. package/{lib-esm → dist}/widget-header.d.ts +0 -0
  14. package/dist/widget-header.js +291 -0
  15. package/dist/widget-header.js.map +1 -0
  16. package/package.json +12 -13
  17. package/lib/avatar.d.ts +0 -7
  18. package/lib/avatar.js +0 -80
  19. package/lib/back.d.ts +0 -7
  20. package/lib/back.js +0 -13
  21. package/lib/close.d.ts +0 -7
  22. package/lib/close.js +0 -14
  23. package/lib/index.d.ts +0 -2
  24. package/lib/index.js +0 -7
  25. package/lib/minimize.d.ts +0 -7
  26. package/lib/minimize.js +0 -14
  27. package/lib/node.d.ts +0 -7
  28. package/lib/node.js +0 -91
  29. package/lib/utils.d.ts +0 -9
  30. package/lib/utils.js +0 -90
  31. package/lib/widget-header-component.d.ts +0 -28
  32. package/lib/widget-header-component.js +0 -102
  33. package/lib/widget-header.d.ts +0 -7
  34. package/lib/widget-header.js +0 -99
  35. package/lib-esm/avatar.js +0 -52
  36. package/lib-esm/back.js +0 -8
  37. package/lib-esm/close.js +0 -9
  38. package/lib-esm/index.js +0 -2
  39. package/lib-esm/minimize.js +0 -9
  40. package/lib-esm/node.js +0 -63
  41. package/lib-esm/utils.js +0 -84
  42. package/lib-esm/widget-header-component.js +0 -77
  43. package/lib-esm/widget-header.js +0 -71
package/lib-esm/node.js DELETED
@@ -1,63 +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 __rest = (this && this.__rest) || function (s, e) {
6
- var t = {};
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
8
- t[p] = s[p];
9
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
10
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
12
- t[p[i]] = s[p[i]];
13
- }
14
- return t;
15
- };
16
- import { borderTabStyle, TransitionComponent, useDispatch } from '@telia-ace/widget-ui';
17
- import React from 'react';
18
- import styled, { css } from 'styled-components';
19
- import Avatar from './avatar';
20
- import Back from './back';
21
- import Close from './close';
22
- import Minimize from './minimize';
23
- var Node = function (_a) {
24
- var _b = _a.className, className = _b === void 0 ? '' : _b, node = __rest(_a, ["className"]);
25
- var dispatch = useDispatch();
26
- var size = node.size, padding = node.padding, type = node.type, tooltip = node.tooltip, _c = node.show, show = _c === void 0 ? true : _c;
27
- if (type === 'back') {
28
- return (React.createElement(NodeWrapper, { size: size || '64px', padding: padding || '10px' },
29
- React.createElement(TransitionComponent, { in: show, timeout: 300, transitions: {
30
- enter: {
31
- type: 'scale',
32
- easing: 'cubic-bezier(.08,.84,.74,1.84)',
33
- },
34
- exit: {
35
- type: 'scale',
36
- easing: 'ease-out',
37
- },
38
- } }, function (state, css) { return (React.createElement(ActionButton, { title: tooltip, "aria-label": tooltip, animationCss: css, onClick: function () {
39
- dispatch('back');
40
- } },
41
- React.createElement(Back, { node: node }))); })));
42
- }
43
- if (!show) {
44
- return null;
45
- }
46
- return (React.createElement(NodeWrapper, { size: size || '64px', padding: padding || '10px', squareRatio: type === 'avatar' },
47
- type === 'avatar' && React.createElement(Avatar, { node: node }),
48
- type === 'close' && (React.createElement(ActionButton, { title: tooltip, "aria-label": tooltip, onClick: function () {
49
- dispatch('close');
50
- } },
51
- React.createElement(Close, { node: node }))),
52
- type === 'minimize' && (React.createElement(ActionButton, { title: tooltip, "aria-label": tooltip, onClick: function () {
53
- dispatch('minimize');
54
- } },
55
- React.createElement(Minimize, { node: node })))));
56
- };
57
- export default Node;
58
- var NodeWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex: 1;\n max-width: ", ";\n ", "\n text-align: center;\n padding: 0 ", ";\n && {\n box-sizing: content-box;\n }\n\n svg {\n vertical-align: middle;\n }\n\n i {\n color: ", ";\n font-size: ", ";\n min-width: 1em;\n min-height: 1em;\n display: inline-block;\n }\n"], ["\n flex: 1;\n max-width: ", ";\n ", "\n text-align: center;\n padding: 0 ", ";\n && {\n box-sizing: content-box;\n }\n\n svg {\n vertical-align: middle;\n }\n\n i {\n color: ", ";\n font-size: ", ";\n min-width: 1em;\n min-height: 1em;\n display: inline-block;\n }\n"])), function (p) { return p.size; }, function (p) { return p.squareRatio && "max-height: ".concat(p.size, ";"); }, function (p) { return p.padding; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { return p.size; });
59
- var ActionButton = styled.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", ";\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n &:focus {\n ", ";\n }\n"], ["\n ", ";\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n &:focus {\n ", ";\n }\n"])), function (p) { return !!p.animationCss && p.animationCss; }, function (p) {
60
- var _a, _b, _c;
61
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n border-color: ", ";\n "], ["\n ", ";\n border-color: ", ";\n "])), borderTabStyle, (_c = (_b = p.theme.accessibility) === null || _b === void 0 ? void 0 : _b.colors) === null || _c === void 0 ? void 0 : _c.inactiveText);
62
- });
63
- var templateObject_1, templateObject_2, templateObject_3;
package/lib-esm/utils.js DELETED
@@ -1,84 +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 { removeNullAndUndefinedValues } from '@telia-ace/widget-utilities';
18
- export var calculateMargin = function (leftNodes, rightNodes, textAlign) {
19
- var _a;
20
- if (textAlign !== 'center') {
21
- return {};
22
- }
23
- var calculate = function (nodes) {
24
- return nodes.reduce(function (acc, node) {
25
- var _a = __read(node.padding.split('px'), 1), padding = _a[0];
26
- var _b = __read(node.size.split('px'), 1), size = _b[0];
27
- return acc + (+size + +padding * 2);
28
- }, 0);
29
- };
30
- var leftSize = calculate(leftNodes);
31
- var rightSize = calculate(rightNodes);
32
- var total = leftSize - rightSize;
33
- if (total === 0) {
34
- return {};
35
- }
36
- var direction = leftSize > rightSize ? 'right' : 'left';
37
- return _a = {},
38
- _a[direction] = "".concat(Math.abs(total), "px"),
39
- _a;
40
- };
41
- export var createNodes = function (actions) {
42
- return Object.keys(actions).reduce(function (acc, key) {
43
- var node = actions[key];
44
- if (!node) {
45
- return acc;
46
- }
47
- var _a = __read(acc, 2), left = _a[0], right = _a[1];
48
- var arr = node.position === 'left' ? left : right;
49
- var symbol = actions[key].symbol;
50
- if (symbol && typeof symbol === 'string') {
51
- symbol = {
52
- type: 'Uri',
53
- content: symbol,
54
- };
55
- }
56
- arr.push({
57
- symbol: node.symbol && typeof node.symbol === 'string'
58
- ? { type: 'Uri', content: node.symbol }
59
- : node.symbol,
60
- type: key,
61
- padding: node.padding || '10px',
62
- label: node.label,
63
- size: node.size || '64px',
64
- tooltip: node.tooltip,
65
- order: node.order || 0,
66
- show: node.show,
67
- });
68
- return acc;
69
- }, [[], []]);
70
- };
71
- export var isOnInitialRoute = function (container) {
72
- return container.getAsync('router').then(function (router) {
73
- if (!router) {
74
- return true;
75
- }
76
- var initialRoute = router.getInitialRoute();
77
- var _a = router.getRouteData(), name = _a.name, params = _a.params;
78
- removeNullAndUndefinedValues(params);
79
- if ((initialRoute === null || initialRoute === void 0 ? void 0 : initialRoute.name) !== name || Object.keys(params).length > 0) {
80
- return false;
81
- }
82
- return true;
83
- });
84
- };
@@ -1,77 +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 { createEventSubscriber } from '@telia-ace/widget-core';
18
- import { createReactComponent } from '@telia-ace/widget-ui';
19
- import { isOnInitialRoute } from './utils';
20
- var WidgetHeaderComponent = function (container) {
21
- return createReactComponent(container, 'widget-header', import('./widget-header'), function (component) {
22
- var events = container.get('$widget').events;
23
- var _a = __read(createEventSubscriber(events), 2), subscribe = _a[0], unsubscribe = _a[1];
24
- var _b = component.properties().actions, actions = _b === void 0 ? {} : _b;
25
- component.actions.create('close', function (data, options) {
26
- if (options.preventDefault) {
27
- return;
28
- }
29
- var widget = container.get('$widget');
30
- return widget.invoke('close');
31
- });
32
- component.actions.create('back', function (data, options) {
33
- if (options.preventDefault) {
34
- return;
35
- }
36
- return container.getAsync('router').then(function (router) {
37
- router.goBack();
38
- });
39
- });
40
- component.properties(function (properties) {
41
- var _a = properties.actions, actions = _a === void 0 ? {} : _a;
42
- if (!actions.back) {
43
- return;
44
- }
45
- Object.keys(actions).forEach(function (key) {
46
- var node = actions[key];
47
- if (key === 'back') {
48
- node.show = properties.showBack;
49
- }
50
- });
51
- return { actions: actions };
52
- });
53
- component.actions.create('show-back', function (showBack) {
54
- component.writeProperties({ showBack: showBack });
55
- });
56
- if (actions.back) {
57
- var showBack = function () {
58
- return isOnInitialRoute(container).then(function (onInitialRoute) {
59
- return component.actions.dispatch('show-back', !onInitialRoute);
60
- });
61
- };
62
- showBack();
63
- subscribe('router:changed', showBack);
64
- }
65
- component.actions.create('minimize', function (data, options) {
66
- if (options.preventDefault) {
67
- return;
68
- }
69
- var widget = container.get('$widget');
70
- return widget.invoke('hide');
71
- });
72
- return function () {
73
- unsubscribe();
74
- };
75
- });
76
- };
77
- export default WidgetHeaderComponent;
@@ -1,71 +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 { headingElement, Link, linkTabStyle, Typography, useProperties, } from '@telia-ace/widget-ui';
44
- import { appendClassNames } from '@telia-ace/widget-utilities';
45
- import React from 'react';
46
- import styled, { css } from 'styled-components';
47
- import Node from './node';
48
- import { calculateMargin, createNodes } from './utils';
49
- var WidgetHeader = function (_a) {
50
- var className = _a.className, other = __rest(_a, ["className"]);
51
- var _b = useProperties(), header = _b.header, tagline = _b.tagline, route = _b.route, _c = _b.tooltip, tooltip = _c === void 0 ? '' : _c, _d = _b.actions, actions = _d === void 0 ? {} : _d, _e = _b.textAlign, textAlign = _e === void 0 ? 'center' : _e;
52
- var _f = __read(createNodes(actions), 2), leftNodes = _f[0], rightNodes = _f[1];
53
- leftNodes.sort(function (a, b) { return (a.order || 0) - (b.order || 0); });
54
- rightNodes.sort(function (a, b) { return (a.order || 0) - (b.order || 0); });
55
- return (React.createElement(Wrapper, __assign({}, other, { className: appendClassNames(className, 'humany-widget-header') }),
56
- leftNodes.map(function (node, key) { return (React.createElement(Node, __assign({ key: "".concat(node.type, "+_").concat(key) }, node))); }),
57
- React.createElement(MainNode, { textAlign: textAlign, margin: calculateMargin(leftNodes, rightNodes, textAlign) },
58
- route ? (React.createElement(StyledLink, { routeName: route, title: tooltip, "aria-label": tooltip },
59
- React.createElement(Typography, { variant: "h1" }, header))) : (React.createElement(Typography, { variant: "h1" }, header)),
60
- tagline && React.createElement(Tagline, null, tagline)),
61
- rightNodes.map(function (node, key) { return (React.createElement(Node, __assign({ key: "".concat(node.type, "+_").concat(key) }, node))); })));
62
- };
63
- export default WidgetHeader;
64
- var Wrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ", "\n\n p {\n color: ", ";\n margin: 0;\n }\n\n svg {\n line,\n path,\n circle {\n stroke: ", ";\n }\n }\n"], ["\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ", "\n\n p {\n color: ", ";\n margin: 0;\n }\n\n svg {\n line,\n path,\n circle {\n stroke: ", ";\n }\n }\n"])), headingElement('h1', css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-size: ", ";\n margin: 0;\n font-weight: 300;\n color: ", ";\n "], ["\n font-size: ", ";\n margin: 0;\n font-weight: 300;\n color: ", ";\n "])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.huge; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; })), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
65
- var Tagline = styled.p(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 300;\n"], ["\n font-size: ", ";\n font-weight: 300;\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; });
66
- var MainNode = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n flex: 1;\n text-align: ", ";\n\n margin-right: ", ";\n margin-left: ", ";\n"], ["\n flex: 1;\n text-align: ", ";\n\n margin-right: ", ";\n margin-left: ", ";\n"])), function (p) { return p.textAlign; }, function (p) { return p.margin.right || 0; }, function (p) { return p.margin.left || 0; });
67
- var StyledLink = styled(Link)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n text-decoration: none;\n &:focus {\n ", "\n }\n"], ["\n text-decoration: none;\n &:focus {\n ", "\n }\n"])), headingElement('h1', css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), function (p) {
68
- var _a;
69
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n display: inline-block;\n "], ["\n ", "\n display: inline-block;\n "])), linkTabStyle);
70
- })));
71
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;