@telia-ace/knowledge-widget-components-guide-category-dropdown 1.0.4 → 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.
- package/{lib-esm → dist}/guide-category-dropdown-component.d.ts +0 -0
- package/{lib-esm → dist}/guide-category-dropdown-item.d.ts +0 -0
- package/{lib-esm → dist}/guide-category-dropdown-match-count.d.ts +0 -0
- package/{lib-esm → dist}/guide-category-dropdown.d.ts +0 -0
- package/dist/guide-category-dropdown.js +323 -0
- package/dist/guide-category-dropdown.js.map +1 -0
- package/{lib-esm → dist}/guide-category-dropdown.styles.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/package.json +12 -13
- package/lib/guide-category-dropdown-component.d.ts +0 -16
- package/lib/guide-category-dropdown-component.js +0 -132
- package/lib/guide-category-dropdown-item.d.ts +0 -8
- package/lib/guide-category-dropdown-item.js +0 -50
- package/lib/guide-category-dropdown-match-count.d.ts +0 -4
- package/lib/guide-category-dropdown-match-count.js +0 -20
- package/lib/guide-category-dropdown.d.ts +0 -6
- package/lib/guide-category-dropdown.js +0 -120
- package/lib/guide-category-dropdown.styles.d.ts +0 -10
- package/lib/guide-category-dropdown.styles.js +0 -64
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -7
- package/lib-esm/guide-category-dropdown-component.js +0 -107
- package/lib-esm/guide-category-dropdown-item.js +0 -45
- package/lib-esm/guide-category-dropdown-match-count.js +0 -15
- package/lib-esm/guide-category-dropdown.js +0 -92
- package/lib-esm/guide-category-dropdown.styles.js +0 -39
- package/lib-esm/index.js +0 -2
|
@@ -1,92 +0,0 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
-
if (!m) return o;
|
|
26
|
-
var i = m.call(o), r, ar = [], e;
|
|
27
|
-
try {
|
|
28
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
-
}
|
|
30
|
-
catch (error) { e = { error: error }; }
|
|
31
|
-
finally {
|
|
32
|
-
try {
|
|
33
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
-
}
|
|
35
|
-
finally { if (e) throw e.error; }
|
|
36
|
-
}
|
|
37
|
-
return ar;
|
|
38
|
-
};
|
|
39
|
-
import { createEmptyComponent, SymbolBadge, Text, useContainer, useProperties, useRouteData, } from '@telia-ace/knowledge-widget-ui';
|
|
40
|
-
import { appendClassNames, createParams, formatUrl } from '@telia-ace/widget-utilities';
|
|
41
|
-
import React, { useEffect, useState } from 'react';
|
|
42
|
-
import GuideCategoryDropdownItem from './guide-category-dropdown-item';
|
|
43
|
-
import GuideCategoryDropdownMatchCount from './guide-category-dropdown-match-count';
|
|
44
|
-
import Styled from './guide-category-dropdown.styles';
|
|
45
|
-
var GuideCategoryDropdown = function (_a) {
|
|
46
|
-
var className = _a.className, other = __rest(_a, ["className"]);
|
|
47
|
-
var routeData = useRouteData();
|
|
48
|
-
var _b = __read(useState(false), 2), togglerFocus = _b[0], setTogglerFocus = _b[1];
|
|
49
|
-
var _c = useProperties(), parent = _c.parent, _d = _c.route, route = _d === void 0 ? 'browse' : _d, _e = _c.categories, categories = _e === void 0 ? [] : _e, _f = _c.loading, loading = _f === void 0 ? false : _f;
|
|
50
|
-
var container = useContainer();
|
|
51
|
-
var _g = __read(useState(false), 2), isOpen = _g[0], setIsOpen = _g[1];
|
|
52
|
-
var params = routeData.params;
|
|
53
|
-
var guideCategory = params.guideCategory, tag = params.tag, phrase = params.phrase, sorting = params.sorting;
|
|
54
|
-
useEffect(function () {
|
|
55
|
-
if (isOpen) {
|
|
56
|
-
setIsOpen(false);
|
|
57
|
-
}
|
|
58
|
-
}, [guideCategory]);
|
|
59
|
-
if (loading || !parent || !categories.length) {
|
|
60
|
-
return createEmptyComponent(container, __assign(__assign({}, other), { className: appendClassNames(className, 'humany-guide-category-dropdown') }));
|
|
61
|
-
}
|
|
62
|
-
var selected = categories.find(function (category) { return category.id === guideCategory; }) || parent;
|
|
63
|
-
var selectedSymbol = selected.activeSymbol || selected.symbol;
|
|
64
|
-
return (React.createElement(Styled.Wrapper, __assign({}, other, { "data-loading": false, "data-toggler-in-focus": togglerFocus, "aria-expanded": isOpen, className: appendClassNames(className, 'humany-guide-category-dropdown') }), isOpen ? (React.createElement(React.Fragment, null,
|
|
65
|
-
React.createElement(Styled.TopItem, { className: "humany-guide-category-dropdown-top-item" },
|
|
66
|
-
React.createElement(Styled.Link, { className: "humany-guide-category-dropdown-link", routeName: route, params: createParams({
|
|
67
|
-
tag: tag,
|
|
68
|
-
phrase: phrase,
|
|
69
|
-
sorting: sorting,
|
|
70
|
-
guideCategory: parent.id,
|
|
71
|
-
uriName: formatUrl(parent.title),
|
|
72
|
-
}), selected: false },
|
|
73
|
-
parent.symbol ? React.createElement(SymbolBadge, { symbol: parent.symbol }) : null,
|
|
74
|
-
React.createElement(Text, null, parent.title),
|
|
75
|
-
React.createElement(GuideCategoryDropdownMatchCount, __assign({}, parent))),
|
|
76
|
-
React.createElement(Styled.Toggler, { onBlur: function () { return setTogglerFocus(false); }, onFocus: function () { return setTogglerFocus(true); }, className: "humany-guide-category-dropdown-toggler", onClick: function () {
|
|
77
|
-
setIsOpen(!isOpen);
|
|
78
|
-
}, "aria-expanded": "true", "aria-label": selected.title },
|
|
79
|
-
React.createElement(SymbolBadge, { size: 18, symbol: { type: 'Svg', content: 'caret-up' } }))),
|
|
80
|
-
React.createElement(Styled.List, { className: "humany-guide-category-dropdown-open", items: categories, renderItem: function (item) { return (React.createElement(GuideCategoryDropdownItem, { key: item.id, item: item, guideCategory: guideCategory })); } }))) : (React.createElement(Styled.TopItem, { className: "humany-guide-category-dropdown-top-item" },
|
|
81
|
-
React.createElement(Styled.Item, { className: "humany-guide-category-dropdown-item", onClick: function () {
|
|
82
|
-
setIsOpen(!isOpen);
|
|
83
|
-
}, selected: false },
|
|
84
|
-
selectedSymbol ? React.createElement(SymbolBadge, { symbol: selectedSymbol }) : null,
|
|
85
|
-
React.createElement(Text, null, selected.title),
|
|
86
|
-
React.createElement(GuideCategoryDropdownMatchCount, __assign({}, selected))),
|
|
87
|
-
React.createElement(Styled.Toggler, { onBlur: function () { return setTogglerFocus(false); }, onFocus: function () { return setTogglerFocus(true); }, className: "humany-guide-category-dropdown-toggler", onClick: function () {
|
|
88
|
-
setIsOpen(!isOpen);
|
|
89
|
-
}, "aria-expanded": "false", "aria-label": selected.title },
|
|
90
|
-
React.createElement(SymbolBadge, { size: 18, symbol: { type: 'Svg', content: 'caret-down' } }))))));
|
|
91
|
-
};
|
|
92
|
-
export default GuideCategoryDropdown;
|
|
@@ -1,39 +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
|
-
import { borderTabStyle, contentBox, Link as BaseLink, linkTabStyle, List as BaseList, list, loadingOpacity, Text, } from '@telia-ace/knowledge-widget-ui';
|
|
6
|
-
import styled, { css } from 'styled-components';
|
|
7
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
8
|
-
var Wrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n ", "\n overflow: hidden;\n min-height: 50px;\n ", ";\n"], ["\n ", "\n ", "\n overflow: hidden;\n min-height: 50px;\n ", ";\n"])), loadingOpacity, contentBox, function (p) {
|
|
9
|
-
var _a;
|
|
10
|
-
return p['data-toggler-in-focus'] &&
|
|
11
|
-
((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n ", "\n }\n "], ["\n && {\n ", "\n }\n "])), borderTabStyle);
|
|
12
|
-
});
|
|
13
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
14
|
-
var Toggler = styled.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: none;\n border: 0;\n outline: 0;\n display: block;\n cursor: pointer;\n padding: 0;\n font-size: ", ";\n text-align: end;\n flex: 1 0 auto;\n svg {\n path,\n line {\n stroke: ", ";\n }\n }\n"], ["\n background: none;\n border: 0;\n outline: 0;\n display: block;\n cursor: pointer;\n padding: 0;\n font-size: ", ";\n text-align: end;\n flex: 1 0 auto;\n svg {\n path,\n line {\n stroke: ", ";\n }\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
15
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
16
|
-
var styling = css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n text-align: left;\n text-align: left;\n text-decoration: none;\n font-weight: 300;\n display: flex;\n align-items: center;\n padding: ", ";\n padding-left: ", ";\n cursor: pointer;\n overflow: hidden;\n ", ";\n\n span {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n i {\n margin-right: ", ";\n font-size: ", ";\n min-height: 1em;\n min-width: 1em;\n }\n"], ["\n font-size: ", ";\n text-align: left;\n text-align: left;\n text-decoration: none;\n font-weight: 300;\n display: flex;\n align-items: center;\n padding: ", ";\n padding-left: ", ";\n cursor: pointer;\n overflow: hidden;\n ", ";\n\n span {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n i {\n margin-right: ", ";\n font-size: ", ";\n min-height: 1em;\n min-width: 1em;\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) {
|
|
17
|
-
var _a, _b, _c;
|
|
18
|
-
return p.selected
|
|
19
|
-
? css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-left: 2px solid ", ";\n color: ", ";\n "], ["\n border-left: 2px solid ", ";\n color: ", ";\n "])), (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary, (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.primary) : css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), (_c = p.theme.colors) === null || _c === void 0 ? void 0 : _c.text);
|
|
20
|
-
}, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.medium; });
|
|
21
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
22
|
-
var Item = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styling);
|
|
23
|
-
var Link = styled(BaseLink)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n ", "\n &:focus {\n outline: none;\n span {\n ", ";\n }\n }\n"], ["\n ", "\n &:focus {\n outline: none;\n span {\n ", ";\n }\n }\n"])), styling, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && linkTabStyle; });
|
|
24
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
25
|
-
var TopItem = styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n padding-right: ", ";\n min-height: 52px;\n white-space: nowrap;\n\n && {\n font-weight: normal;\n\n a {\n font-weight: normal;\n }\n }\n ", " {\n font-weight: normal;\n }\n"], ["\n display: flex;\n justify-content: space-between;\n padding-right: ", ";\n min-height: 52px;\n white-space: nowrap;\n\n && {\n font-weight: normal;\n\n a {\n font-weight: normal;\n }\n }\n ", " {\n font-weight: normal;\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, Item);
|
|
26
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
27
|
-
var List = styled(BaseList)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", "\n display: flex;\n justify-content: center;\n flex-direction: column;\n margin-right: ", ";\n margin-left: ", ";\n margin-bottom: 22px;\n border-left: ", ";\n li {\n margin: 0 0 ", " -2px;\n }\n li:last-child {\n margin: 0 0 0 -2px;\n }\n flex-basis: 100%;\n border-width: 2px;\n"], ["\n ", "\n display: flex;\n justify-content: center;\n flex-direction: column;\n margin-right: ", ";\n margin-left: ", ";\n margin-bottom: 22px;\n border-left: ", ";\n li {\n margin: 0 0 ", " -2px;\n }\n li:last-child {\n margin: 0 0 0 -2px;\n }\n flex-basis: 100%;\n border-width: 2px;\n"])), list, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { return p.theme.border; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
28
|
-
// FUTURE TODO: Look into the typescript error when removing ": any".
|
|
29
|
-
var MatchCount = styled(Text)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n margin: 0 0 0 ", ";\n"], ["\n margin: 0 0 0 ", ";\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; });
|
|
30
|
-
export default {
|
|
31
|
-
Wrapper: Wrapper,
|
|
32
|
-
Toggler: Toggler,
|
|
33
|
-
List: List,
|
|
34
|
-
Item: Item,
|
|
35
|
-
Link: Link,
|
|
36
|
-
TopItem: TopItem,
|
|
37
|
-
MatchCount: MatchCount,
|
|
38
|
-
};
|
|
39
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
|
package/lib-esm/index.js
DELETED