@telia-ace/knowledge-widget-ui 1.0.1
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 +6 -0
- package/README.md +3 -0
- package/lib/components/dialog-link.d.ts +12 -0
- package/lib/components/dialog-link.js +40 -0
- package/lib/components/dialog-list.d.ts +7 -0
- package/lib/components/dialog-list.js +72 -0
- package/lib/components/drawer-list.d.ts +5 -0
- package/lib/components/drawer-list.js +43 -0
- package/lib/components/dropdown-actions.d.ts +11 -0
- package/lib/components/dropdown-actions.js +25 -0
- package/lib/components/dropdown-list.d.ts +5 -0
- package/lib/components/dropdown-list.js +66 -0
- package/lib/components/favorite-button.d.ts +17 -0
- package/lib/components/favorite-button.js +65 -0
- package/lib/components/feedback.d.ts +11 -0
- package/lib/components/feedback.js +84 -0
- package/lib/components/guide-list.d.ts +46 -0
- package/lib/components/guide-list.js +202 -0
- package/lib/components/index.d.ts +10 -0
- package/lib/components/index.js +28 -0
- package/lib/components/loader.d.ts +9 -0
- package/lib/components/loader.js +50 -0
- package/lib/components/metadata.d.ts +17 -0
- package/lib/components/metadata.js +35 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +14 -0
- package/lib/hooks/use-arrow-keys.d.ts +3 -0
- package/lib/hooks/use-arrow-keys.js +48 -0
- package/lib/hooks/use-debounce.d.ts +2 -0
- package/lib/hooks/use-debounce.js +41 -0
- package/lib/hooks/use-favorites.d.ts +8 -0
- package/lib/hooks/use-favorites.js +81 -0
- package/lib/hooks/use-hover.d.ts +2 -0
- package/lib/hooks/use-hover.js +29 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +44 -0
- package/lib/missing-type-exports.d.ts +47 -0
- package/lib/missing-type-exports.js +3 -0
- package/lib/styles.d.ts +8 -0
- package/lib/styles.js +50 -0
- package/lib/utils/embedded-link-mapper.d.ts +4 -0
- package/lib/utils/embedded-link-mapper.js +62 -0
- package/lib/utils/guide-render-instructions.d.ts +9 -0
- package/lib/utils/guide-render-instructions.js +56 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +8 -0
- package/lib-esm/components/dialog-link.d.ts +12 -0
- package/lib-esm/components/dialog-link.js +35 -0
- package/lib-esm/components/dialog-list.d.ts +7 -0
- package/lib-esm/components/dialog-list.js +44 -0
- package/lib-esm/components/drawer-list.d.ts +5 -0
- package/lib-esm/components/drawer-list.js +38 -0
- package/lib-esm/components/dropdown-actions.d.ts +11 -0
- package/lib-esm/components/dropdown-actions.js +20 -0
- package/lib-esm/components/dropdown-list.d.ts +5 -0
- package/lib-esm/components/dropdown-list.js +38 -0
- package/lib-esm/components/favorite-button.d.ts +17 -0
- package/lib-esm/components/favorite-button.js +40 -0
- package/lib-esm/components/feedback.d.ts +11 -0
- package/lib-esm/components/feedback.js +59 -0
- package/lib-esm/components/guide-list.d.ts +46 -0
- package/lib-esm/components/guide-list.js +173 -0
- package/lib-esm/components/index.d.ts +10 -0
- package/lib-esm/components/index.js +10 -0
- package/lib-esm/components/loader.d.ts +9 -0
- package/lib-esm/components/loader.js +21 -0
- package/lib-esm/components/metadata.d.ts +17 -0
- package/lib-esm/components/metadata.js +30 -0
- package/lib-esm/hooks/index.d.ts +5 -0
- package/lib-esm/hooks/index.js +4 -0
- package/lib-esm/hooks/use-arrow-keys.d.ts +3 -0
- package/lib-esm/hooks/use-arrow-keys.js +46 -0
- package/lib-esm/hooks/use-debounce.d.ts +2 -0
- package/lib-esm/hooks/use-debounce.js +39 -0
- package/lib-esm/hooks/use-favorites.d.ts +8 -0
- package/lib-esm/hooks/use-favorites.js +79 -0
- package/lib-esm/hooks/use-hover.d.ts +2 -0
- package/lib-esm/hooks/use-hover.js +27 -0
- package/lib-esm/index.d.ts +7 -0
- package/lib-esm/index.js +6 -0
- package/lib-esm/missing-type-exports.d.ts +47 -0
- package/lib-esm/missing-type-exports.js +2 -0
- package/lib-esm/styles.d.ts +8 -0
- package/lib-esm/styles.js +24 -0
- package/lib-esm/utils/embedded-link-mapper.d.ts +4 -0
- package/lib-esm/utils/embedded-link-mapper.js +57 -0
- package/lib-esm/utils/guide-render-instructions.d.ts +9 -0
- package/lib-esm/utils/guide-render-instructions.js +51 -0
- package/lib-esm/utils/index.d.ts +1 -0
- package/lib-esm/utils/index.js +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
+
};
|
|
26
|
+
import { useContainer } from '@telia-ace/widget-ui';
|
|
27
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
28
|
+
var useFavorites = function () {
|
|
29
|
+
var container = useContainer();
|
|
30
|
+
var _a = __read(useState([]), 2), favorites = _a[0], setFavorites = _a[1];
|
|
31
|
+
var platform = container.get('favorites');
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (platform) {
|
|
34
|
+
setFavorites(platform.get());
|
|
35
|
+
var events = container.get('$widget').events;
|
|
36
|
+
var unsubscribe = events.subscribe('widget:favorites-updated', function (_, _a) {
|
|
37
|
+
var updated = _a.updated;
|
|
38
|
+
setFavorites(__spreadArray([], __read(updated), false));
|
|
39
|
+
});
|
|
40
|
+
return unsubscribe;
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
var add = function (guideId) {
|
|
44
|
+
if (!platform) {
|
|
45
|
+
return Promise.resolve([]);
|
|
46
|
+
}
|
|
47
|
+
return platform.add(guideId);
|
|
48
|
+
};
|
|
49
|
+
var remove = function (guideId) {
|
|
50
|
+
if (!platform) {
|
|
51
|
+
return Promise.resolve([]);
|
|
52
|
+
}
|
|
53
|
+
return platform.remove(guideId);
|
|
54
|
+
};
|
|
55
|
+
var clear = function () {
|
|
56
|
+
if (!platform) {
|
|
57
|
+
return Promise.resolve([]);
|
|
58
|
+
}
|
|
59
|
+
return platform.clear();
|
|
60
|
+
};
|
|
61
|
+
var toggle = useCallback(function (guideId) {
|
|
62
|
+
if (favorites.indexOf(guideId) > -1) {
|
|
63
|
+
return remove(guideId);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return add(guideId);
|
|
67
|
+
}
|
|
68
|
+
}, [favorites]);
|
|
69
|
+
return [
|
|
70
|
+
favorites,
|
|
71
|
+
useMemo(function () { return ({
|
|
72
|
+
addFavorite: add,
|
|
73
|
+
removeFavorite: remove,
|
|
74
|
+
clearFavorites: clear,
|
|
75
|
+
toggleFavorite: toggle,
|
|
76
|
+
}); }, [favorites]),
|
|
77
|
+
];
|
|
78
|
+
};
|
|
79
|
+
export default useFavorites;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { useEventListener } from '@telia-ace/widget-ui';
|
|
18
|
+
import { useCallback, useRef, useState } from 'react';
|
|
19
|
+
export default (function () {
|
|
20
|
+
var _a = __read(useState(false), 2), hovering = _a[0], setHovering = _a[1];
|
|
21
|
+
var elem = useRef();
|
|
22
|
+
var onMouseEnter = useCallback(function () { return setHovering(true); }, [setHovering]);
|
|
23
|
+
var onMouseLeave = useCallback(function () { return setHovering(false); }, [setHovering]);
|
|
24
|
+
useEventListener('mouseenter', onMouseEnter, elem.current);
|
|
25
|
+
useEventListener('mouseleave', onMouseLeave, elem.current);
|
|
26
|
+
return [hovering, elem];
|
|
27
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccordionListItem, DialogLink, DialogList, DrawerList, DropdownActions, DropdownList, FavoriteButton, Feedback, GuideList, Loader, LoaderWrapper, Metadata } from './components';
|
|
2
|
+
import { FavoriteActions, useArrowKeys, useDebounce, useFavorites, useHover } from './hooks';
|
|
3
|
+
import { genericHtml, loadingOpacity, SmallCaret, StyledHeaderText, StyledListButton } from './styles';
|
|
4
|
+
import { guideRenderInstructions } from './utils';
|
|
5
|
+
export * from '@telia-ace/widget-ui';
|
|
6
|
+
export { useFavorites, useDebounce, useArrowKeys, useHover, guideRenderInstructions, Metadata, AccordionListItem, GuideList, DialogLink, DialogList, FavoriteButton, Feedback, Loader, LoaderWrapper, DrawerList, DropdownActions, DropdownList, genericHtml, SmallCaret, StyledHeaderText, StyledListButton, loadingOpacity, };
|
|
7
|
+
export type { FavoriteActions };
|
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccordionListItem, DialogLink, DialogList, DrawerList, DropdownActions, DropdownList, FavoriteButton, Feedback, GuideList, Loader, LoaderWrapper, Metadata, } from './components';
|
|
2
|
+
import { useArrowKeys, useDebounce, useFavorites, useHover } from './hooks';
|
|
3
|
+
import { genericHtml, loadingOpacity, SmallCaret, StyledHeaderText, StyledListButton, } from './styles';
|
|
4
|
+
import { guideRenderInstructions } from './utils';
|
|
5
|
+
export * from '@telia-ace/widget-ui';
|
|
6
|
+
export { useFavorites, useDebounce, useArrowKeys, useHover, guideRenderInstructions, Metadata, AccordionListItem, GuideList, DialogLink, DialogList, FavoriteButton, Feedback, Loader, LoaderWrapper, DrawerList, DropdownActions, DropdownList, genericHtml, SmallCaret, StyledHeaderText, StyledListButton, loadingOpacity, };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DrawerAnimationType, HtmlParseInstruction, ItemRenderer } from '@telia-ace/widget-ui';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export declare type LinkProps = Merge<React.ComponentProps<'a'>, {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
routeName?: string;
|
|
6
|
+
params?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
to?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare type DrawerProps = {
|
|
12
|
+
header?: string | React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
animation?: {
|
|
15
|
+
type: DrawerAnimationType;
|
|
16
|
+
duration?: number;
|
|
17
|
+
};
|
|
18
|
+
trigger: React.ReactElement;
|
|
19
|
+
fullScreen?: boolean;
|
|
20
|
+
closeButtonAriaLabel?: string;
|
|
21
|
+
onToggle?: (visible: boolean) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare type ListProps = Merge<React.ComponentProps<'ul'>, {
|
|
24
|
+
renderItem: ItemRenderer;
|
|
25
|
+
items: any[];
|
|
26
|
+
renderLi?: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
export declare type HtmlProps = Merge<React.ComponentProps<'div'>, {
|
|
29
|
+
html: string;
|
|
30
|
+
htmlParseInstruction?: HtmlParseInstruction;
|
|
31
|
+
}>;
|
|
32
|
+
export declare type ParagraphProps = Merge<HtmlProps, {
|
|
33
|
+
text?: string;
|
|
34
|
+
html?: string;
|
|
35
|
+
header?: string;
|
|
36
|
+
symbol?: Symbol;
|
|
37
|
+
}>;
|
|
38
|
+
export declare type ItemListProps = Merge<ListProps, ParagraphProps> & {
|
|
39
|
+
customHeader?: any;
|
|
40
|
+
ulProps?: any;
|
|
41
|
+
};
|
|
42
|
+
export declare type DropdownProps = {
|
|
43
|
+
className?: string;
|
|
44
|
+
children?: any;
|
|
45
|
+
trigger: ReactElement;
|
|
46
|
+
closeButtonAriaLabel?: string;
|
|
47
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const loadingOpacity: import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<{
|
|
3
|
+
'data-loading': boolean;
|
|
4
|
+
}, any>>;
|
|
5
|
+
export declare const genericHtml: import("styled-components").FlattenInterpolation<any>;
|
|
6
|
+
export declare const SmallCaret: import("styled-components").StyledComponent<import("react").FC<import("@telia-ace/widget-ui").IconProps>, any, {}, never>;
|
|
7
|
+
export declare const StyledHeaderText: import("styled-components").StyledComponent<import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>>, any, {}, never>;
|
|
8
|
+
export declare const StyledListButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<Pick<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>> & import("react").RefAttributes<HTMLButtonElement>>, any, any, never>;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { Button, Icon, linkTabStyle, paddedBorderTabStyle, Text } from '@telia-ace/widget-ui';
|
|
6
|
+
import styled, { css } from 'styled-components';
|
|
7
|
+
import { Wrapper as LoaderWrapper } from './components/loader';
|
|
8
|
+
export var loadingOpacity = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n ", "\n > * {\n transition: 200ms ease-out opacity;\n opacity: ", ";\n }\n ", " {\n opacity: ", ";\n }\n"], ["\n ", ";\n ", "\n > * {\n transition: 200ms ease-out opacity;\n opacity: ", ";\n }\n ", " {\n opacity: ", ";\n }\n"])), function (p) { return p['data-loading'] && 'position: relative;'; }, function (p) { return p['data-loading'] && 'min-height: 150px;'; }, function (p) { return (p['data-loading'] ? '0.5' : '1'); }, LoaderWrapper, function (p) { return (p['data-loading'] ? '1' : '0'); });
|
|
9
|
+
export var genericHtml = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: 300;\n line-height: 1.5em;\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n word-break: break-word;\n &:first-child {\n margin-top: 0;\n }\n &:only-child {\n margin: 0;\n }\n &:last-child {\n margin-bottom: 0;\n }\n }\n\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n\n img {\n max-width: 100% !important;\n height: auto !important;\n }\n\n p {\n word-break: break-word;\n margin: ", " 0;\n }\n\n p:first-child {\n margin: 0 0 ", ";\n }\n\n p:last-child {\n margin: ", " 0 0;\n }\n\n p:only-child {\n margin: 0;\n }\n"], ["\n font-size: ", ";\n font-weight: 300;\n line-height: 1.5em;\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n word-break: break-word;\n &:first-child {\n margin-top: 0;\n }\n &:only-child {\n margin: 0;\n }\n &:last-child {\n margin-bottom: 0;\n }\n }\n\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n\n img {\n max-width: 100% !important;\n height: auto !important;\n }\n\n p {\n word-break: break-word;\n margin: ", " 0;\n }\n\n p:first-child {\n margin: 0 0 ", ";\n }\n\n p:last-child {\n margin: ", " 0 0;\n }\n\n p:only-child {\n margin: 0;\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; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && linkTabStyle; }, 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.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
10
|
+
export var SmallCaret = styled(Icon)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n && {\n font-size: ", ";\n }\n width: 1.2em;\n"], ["\n && {\n font-size: ", ";\n }\n width: 1.2em;\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; });
|
|
11
|
+
export var StyledHeaderText = styled(Text)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: normal;\n line-height: 1.2em;\n color: ", ";\n"], ["\n font-size: ", ";\n font-weight: normal;\n line-height: 1.2em;\n color: ", ";\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
12
|
+
export var StyledListButton = styled(Button)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n\n ", "\n\n &:focus {\n ", ";\n }\n\n span {\n flex: 1;\n font-weight: 300;\n }\n"], ["\n display: flex;\n align-items: center;\n\n ", "\n\n &:focus {\n ", ";\n }\n\n span {\n flex: 1;\n font-weight: 300;\n }\n"])), function (p) {
|
|
13
|
+
var _a;
|
|
14
|
+
return p['data-has-label'] === 'true' &&
|
|
15
|
+
p['data-has-symbol'] === 'true' &&
|
|
16
|
+
"\n svg, i {\n margin: 0 ".concat((_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small, " 0 0;\n }\n ");
|
|
17
|
+
}, function (p) {
|
|
18
|
+
var _a;
|
|
19
|
+
return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n\n svg, i {\n ", "\n }\n "], ["\n ", "\n\n svg, i {\n ", "\n }\n "])), function (p) { return p['data-has-label'] === 'true' && paddedBorderTabStyle; }, function (p) {
|
|
20
|
+
return p['data-has-label'] === 'false' &&
|
|
21
|
+
p['data-has-symbol'] === 'true' && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n box-sizing: content-box;\n "], ["\n ", "\n box-sizing: content-box;\n "])), paddedBorderTabStyle);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
import { AnchorLink, WidgetLink } from '@telia-ace/widget-ui';
|
|
24
|
+
import React from 'react';
|
|
25
|
+
// Determine if href starts with a hashtag
|
|
26
|
+
var isAnchorLink = function (href) {
|
|
27
|
+
var re = new RegExp('^#', 'i');
|
|
28
|
+
var match = re.test(href);
|
|
29
|
+
return match;
|
|
30
|
+
};
|
|
31
|
+
var embeddedLinkMapper = function (container) {
|
|
32
|
+
return function (_a) {
|
|
33
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
34
|
+
var _b = container.get('$widget'), implementation = _b.implementation, currentWidgetName = _b.name;
|
|
35
|
+
var _c = props.href, href = _c === void 0 ? '' : _c;
|
|
36
|
+
if (isAnchorLink(href)) {
|
|
37
|
+
return (React.createElement(AnchorLink, { smooth: true, to: href }, children));
|
|
38
|
+
}
|
|
39
|
+
var escapedBindings = implementation.bindings
|
|
40
|
+
.map(function (binding) { return binding.replace(/\./g, '\\.'); })
|
|
41
|
+
.join('|');
|
|
42
|
+
var regexp = new RegExp("^((http[s]?:)?//)?(".concat(escapedBindings, ")/([^\\s]+)"));
|
|
43
|
+
var expArray = regexp.exec(href);
|
|
44
|
+
if (expArray && expArray.length >= 4) {
|
|
45
|
+
var targetWidgetName = expArray[4];
|
|
46
|
+
var targetWidget = implementation.widgets.get(targetWidgetName);
|
|
47
|
+
// blob links should not be treated as a widget link
|
|
48
|
+
if (targetWidget &&
|
|
49
|
+
!targetWidgetName.startsWith('blob?') &&
|
|
50
|
+
!targetWidgetName.startsWith(currentWidgetName)) {
|
|
51
|
+
return React.createElement(WidgetLink, { widgetName: targetWidgetName }, children);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return React.createElement("a", __assign({}, props), children);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export default embeddedLinkMapper;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const guideRenderInstructions: (container: Container, dialog?: any[]) => {
|
|
4
|
+
transform: {
|
|
5
|
+
img: (attrs: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLImageElement>, HTMLImageElement>) => JSX.Element;
|
|
6
|
+
a: (attr: any) => JSX.Element;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default guideRenderInstructions;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import { Lightbox } from '@telia-ace/widget-ui';
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import { DialogLink } from '../components';
|
|
26
|
+
import embeddedLinkMapper from './embedded-link-mapper';
|
|
27
|
+
var imageLightboxRenderer = function (attrs) { return React.createElement(Lightbox, { attrs: attrs }); };
|
|
28
|
+
var guideRenderInstructions = function (container, dialog) {
|
|
29
|
+
if (dialog === void 0) { dialog = []; }
|
|
30
|
+
return {
|
|
31
|
+
transform: {
|
|
32
|
+
img: imageLightboxRenderer,
|
|
33
|
+
a: function (attr) {
|
|
34
|
+
var children = attr.children, otherAttr = __rest(attr, ["children"]);
|
|
35
|
+
var connectionId = otherAttr['data-target'];
|
|
36
|
+
if (connectionId && dialog.length) {
|
|
37
|
+
var item = dialog.find(function (_a) {
|
|
38
|
+
var connection = _a.connection;
|
|
39
|
+
return connection === connectionId;
|
|
40
|
+
});
|
|
41
|
+
if (item) {
|
|
42
|
+
return React.createElement(DialogLink, __assign({}, item), children);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var defaultInstructions = embeddedLinkMapper(container);
|
|
46
|
+
return defaultInstructions(attr);
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default guideRenderInstructions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as guideRenderInstructions } from './guide-render-instructions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as guideRenderInstructions } from './guide-render-instructions';
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/knowledge-widget-ui",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "UI components used by ACE Knowledge Widgets.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telia"
|
|
9
|
+
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "lib-esm/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"README.md",
|
|
15
|
+
"lib/",
|
|
16
|
+
"lib-esm/"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
+
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"typings": "lib/index.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@telia-ace/knowledge-widget-core": "^1.0.1",
|
|
29
|
+
"@telia-ace/widget-routing": "^1.0.1",
|
|
30
|
+
"@telia-ace/widget-ui": "^1.0.1",
|
|
31
|
+
"@telia-ace/widget-utilities": "^1.0.1",
|
|
32
|
+
"@webprovisions/platform": "^1.1.2",
|
|
33
|
+
"htmr": "0.8.8",
|
|
34
|
+
"react": "^17.0.2",
|
|
35
|
+
"react-dom": "^17.0.2",
|
|
36
|
+
"react-router-dom": "^5.0.0",
|
|
37
|
+
"react-transition-group": "^4.0.1",
|
|
38
|
+
"styled-components": "^4.3.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/react": "^17.0.39",
|
|
42
|
+
"@types/react-dom": "^17.0.13",
|
|
43
|
+
"@types/react-router-dom": "^5.1.0",
|
|
44
|
+
"@types/react-transition-group": "^4.2.3",
|
|
45
|
+
"@types/styled-components": "^5.1.7"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "2df7de1fc7344c709b46911133e9e50f7cab8e5c"
|
|
48
|
+
}
|