@telia-ace/knowledge-widget-ui 1.0.10 → 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/{lib-esm → dist}/components/dialog-link.d.ts +0 -0
- package/{lib-esm → dist}/components/dialog-list.d.ts +0 -0
- package/{lib-esm → dist}/components/drawer-list.d.ts +0 -0
- package/{lib-esm → dist}/components/dropdown-actions.d.ts +0 -0
- package/{lib-esm → dist}/components/dropdown-list.d.ts +0 -0
- package/{lib-esm → dist}/components/favorite-button.d.ts +0 -0
- package/{lib-esm → dist}/components/feedback.d.ts +0 -0
- package/{lib-esm → dist}/components/guide-list.d.ts +0 -0
- package/{lib-esm → dist}/components/index.d.ts +0 -0
- package/{lib-esm → dist}/components/loader.d.ts +0 -0
- package/{lib-esm → dist}/components/metadata.d.ts +0 -0
- package/{lib-esm → dist}/hooks/index.d.ts +0 -0
- package/{lib-esm → dist}/hooks/use-arrow-keys.d.ts +0 -0
- package/{lib-esm → dist}/hooks/use-debounce.d.ts +0 -0
- package/{lib-esm → dist}/hooks/use-favorites.d.ts +0 -0
- package/{lib-esm → dist}/hooks/use-hover.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +1385 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/missing-type-exports.d.ts +0 -0
- package/{lib-esm → dist}/styles.d.ts +0 -0
- package/{lib-esm → dist}/utils/embedded-link-mapper.d.ts +0 -0
- package/{lib-esm → dist}/utils/guide-render-instructions.d.ts +0 -0
- package/{lib-esm → dist}/utils/index.d.ts +0 -0
- package/package.json +11 -12
- package/lib/components/dialog-link.d.ts +0 -12
- package/lib/components/dialog-link.js +0 -40
- package/lib/components/dialog-list.d.ts +0 -7
- package/lib/components/dialog-list.js +0 -72
- package/lib/components/drawer-list.d.ts +0 -5
- package/lib/components/drawer-list.js +0 -43
- package/lib/components/dropdown-actions.d.ts +0 -11
- package/lib/components/dropdown-actions.js +0 -25
- package/lib/components/dropdown-list.d.ts +0 -5
- package/lib/components/dropdown-list.js +0 -66
- package/lib/components/favorite-button.d.ts +0 -17
- package/lib/components/favorite-button.js +0 -65
- package/lib/components/feedback.d.ts +0 -11
- package/lib/components/feedback.js +0 -84
- package/lib/components/guide-list.d.ts +0 -46
- package/lib/components/guide-list.js +0 -202
- package/lib/components/index.d.ts +0 -10
- package/lib/components/index.js +0 -28
- package/lib/components/loader.d.ts +0 -9
- package/lib/components/loader.js +0 -50
- package/lib/components/metadata.d.ts +0 -17
- package/lib/components/metadata.js +0 -35
- package/lib/hooks/index.d.ts +0 -5
- package/lib/hooks/index.js +0 -14
- package/lib/hooks/use-arrow-keys.d.ts +0 -3
- package/lib/hooks/use-arrow-keys.js +0 -48
- package/lib/hooks/use-debounce.d.ts +0 -2
- package/lib/hooks/use-debounce.js +0 -41
- package/lib/hooks/use-favorites.d.ts +0 -8
- package/lib/hooks/use-favorites.js +0 -81
- package/lib/hooks/use-hover.d.ts +0 -2
- package/lib/hooks/use-hover.js +0 -29
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -44
- package/lib/missing-type-exports.d.ts +0 -47
- package/lib/missing-type-exports.js +0 -3
- package/lib/styles.d.ts +0 -7
- package/lib/styles.js +0 -50
- package/lib/utils/embedded-link-mapper.d.ts +0 -3
- package/lib/utils/embedded-link-mapper.js +0 -62
- package/lib/utils/guide-render-instructions.d.ts +0 -9
- package/lib/utils/guide-render-instructions.js +0 -56
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -8
- package/lib-esm/components/dialog-link.js +0 -35
- package/lib-esm/components/dialog-list.js +0 -44
- package/lib-esm/components/drawer-list.js +0 -38
- package/lib-esm/components/dropdown-actions.js +0 -20
- package/lib-esm/components/dropdown-list.js +0 -38
- package/lib-esm/components/favorite-button.js +0 -40
- package/lib-esm/components/feedback.js +0 -59
- package/lib-esm/components/guide-list.js +0 -173
- package/lib-esm/components/index.js +0 -10
- package/lib-esm/components/loader.js +0 -21
- package/lib-esm/components/metadata.js +0 -30
- package/lib-esm/hooks/index.js +0 -4
- package/lib-esm/hooks/use-arrow-keys.js +0 -46
- package/lib-esm/hooks/use-debounce.js +0 -39
- package/lib-esm/hooks/use-favorites.js +0 -79
- package/lib-esm/hooks/use-hover.js +0 -27
- package/lib-esm/index.js +0 -6
- package/lib-esm/missing-type-exports.js +0 -2
- package/lib-esm/styles.js +0 -24
- package/lib-esm/utils/embedded-link-mapper.js +0 -57
- package/lib-esm/utils/guide-render-instructions.js +0 -51
- package/lib-esm/utils/index.js +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,1385 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { useRouteData, Link, Icon, List, list, invertedHoverButton, ItemList, itemList, Drawer, Dropdown, headingElement, linkTabStyle, Text, Button, paddedBorderTabStyle, Confirm, SymbolBadge, StyledText as StyledText$1, convertToStringAttributes, useKeyPress, useContainer, useEventListener, Timestamp, DateFormats, TextLink, usePrevious, borderTabStyle, AnchorLink, WidgetLink, Lightbox } from "@telia-ace/widget-ui";
|
|
33
|
+
export * from "@telia-ace/widget-ui";
|
|
34
|
+
import { createParams, formatUrl, appendClassNames, htmlParentContains } from "@telia-ace/widget-utilities";
|
|
35
|
+
import React, { forwardRef, useCallback, useState, useEffect, useMemo, useRef, useContext, useImperativeHandle } from "react";
|
|
36
|
+
import styled, { css, keyframes, ThemeContext } from "styled-components";
|
|
37
|
+
const DialogLink = ({
|
|
38
|
+
title = "",
|
|
39
|
+
className,
|
|
40
|
+
id,
|
|
41
|
+
parent,
|
|
42
|
+
connection,
|
|
43
|
+
type,
|
|
44
|
+
target,
|
|
45
|
+
href,
|
|
46
|
+
children
|
|
47
|
+
}) => {
|
|
48
|
+
const props = {};
|
|
49
|
+
const { name, params } = useRouteData();
|
|
50
|
+
switch (type) {
|
|
51
|
+
case "default":
|
|
52
|
+
case "guide":
|
|
53
|
+
const { id: parentId, title: parentTitle } = parent;
|
|
54
|
+
props.routeName = name;
|
|
55
|
+
props.params = createParams(__spreadProps(__spreadValues({}, params), {
|
|
56
|
+
guide: id,
|
|
57
|
+
connection: id === parentId ? connection : void 0,
|
|
58
|
+
uriName: id === parentId ? formatUrl(parentTitle) : formatUrl(title)
|
|
59
|
+
}));
|
|
60
|
+
break;
|
|
61
|
+
case "link":
|
|
62
|
+
props.href = href;
|
|
63
|
+
props.target = target;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ React.createElement(Link, __spreadValues({
|
|
67
|
+
className: appendClassNames(className, "humany-dialog-link")
|
|
68
|
+
}, props), children || /* @__PURE__ */ React.createElement(React.Fragment, null, type === "link" && /* @__PURE__ */ React.createElement(Icon, {
|
|
69
|
+
faIcon: "link"
|
|
70
|
+
}), /* @__PURE__ */ React.createElement("span", null, title)));
|
|
71
|
+
};
|
|
72
|
+
var dialogList = forwardRef((_a, ref) => {
|
|
73
|
+
var _b = _a, { className, dialog } = _b, other = __objRest(_b, ["className", "dialog"]);
|
|
74
|
+
return !!dialog.length ? /* @__PURE__ */ React.createElement(StyledList$1, __spreadProps(__spreadValues({
|
|
75
|
+
className: appendClassNames(className, "humany-dialog"),
|
|
76
|
+
items: dialog,
|
|
77
|
+
renderItem: (item) => /* @__PURE__ */ React.createElement("li", {
|
|
78
|
+
key: item.connection,
|
|
79
|
+
"data-dialog": item.connection
|
|
80
|
+
}, /* @__PURE__ */ React.createElement(DialogLink, __spreadValues({}, item)))
|
|
81
|
+
}, other), {
|
|
82
|
+
ref
|
|
83
|
+
})) : null;
|
|
84
|
+
});
|
|
85
|
+
const StyledList$1 = styled(List)`
|
|
86
|
+
${list}
|
|
87
|
+
a {
|
|
88
|
+
min-width: 150px;
|
|
89
|
+
max-width: 400px;
|
|
90
|
+
display: block;
|
|
91
|
+
white-space: normal;
|
|
92
|
+
${(p) => {
|
|
93
|
+
var _a;
|
|
94
|
+
return invertedHoverButton({
|
|
95
|
+
primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
|
|
96
|
+
secondaryColor: "#FFFFFF"
|
|
97
|
+
});
|
|
98
|
+
}}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
i {
|
|
102
|
+
margin: 0 ${(p) => {
|
|
103
|
+
var _a;
|
|
104
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
105
|
+
}} 0 0;
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
const DrawerList = (_c) => {
|
|
109
|
+
var _d = _c, {
|
|
110
|
+
trigger,
|
|
111
|
+
header,
|
|
112
|
+
className,
|
|
113
|
+
animation,
|
|
114
|
+
fullScreen,
|
|
115
|
+
onToggle,
|
|
116
|
+
children,
|
|
117
|
+
ref,
|
|
118
|
+
closeButtonAriaLabel
|
|
119
|
+
} = _d, other = __objRest(_d, [
|
|
120
|
+
"trigger",
|
|
121
|
+
"header",
|
|
122
|
+
"className",
|
|
123
|
+
"animation",
|
|
124
|
+
"fullScreen",
|
|
125
|
+
"onToggle",
|
|
126
|
+
"children",
|
|
127
|
+
"ref",
|
|
128
|
+
"closeButtonAriaLabel"
|
|
129
|
+
]);
|
|
130
|
+
return /* @__PURE__ */ React.createElement(Drawer, {
|
|
131
|
+
className: appendClassNames(className, "humany-drawer-list"),
|
|
132
|
+
trigger,
|
|
133
|
+
header,
|
|
134
|
+
animation,
|
|
135
|
+
fullScreen,
|
|
136
|
+
onToggle,
|
|
137
|
+
closeButtonAriaLabel
|
|
138
|
+
}, /* @__PURE__ */ React.createElement(StyledItemList$2, __spreadValues({}, other), children));
|
|
139
|
+
};
|
|
140
|
+
const StyledItemList$2 = styled(ItemList)`
|
|
141
|
+
${itemList}
|
|
142
|
+
font-family: ${(p) => {
|
|
143
|
+
var _a;
|
|
144
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.type;
|
|
145
|
+
}};
|
|
146
|
+
padding: ${(p) => {
|
|
147
|
+
var _a;
|
|
148
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
149
|
+
}};
|
|
150
|
+
> ul > li {
|
|
151
|
+
overflow: visible;
|
|
152
|
+
font-weight: 300;
|
|
153
|
+
font-size: ${(p) => {
|
|
154
|
+
var _a;
|
|
155
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
156
|
+
}};
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
159
|
+
const DropdownActions = ({ items, renderItem, trigger, header, children }) => {
|
|
160
|
+
return /* @__PURE__ */ React.createElement(Dropdown, {
|
|
161
|
+
className: "humany-dropdown-actions",
|
|
162
|
+
trigger
|
|
163
|
+
}, /* @__PURE__ */ React.createElement(Wrapper$2, null, !!header && /* @__PURE__ */ React.createElement(Header$1, null, header), items && renderItem && /* @__PURE__ */ React.createElement(StyledList, {
|
|
164
|
+
items,
|
|
165
|
+
renderItem
|
|
166
|
+
}), children));
|
|
167
|
+
};
|
|
168
|
+
const Wrapper$2 = styled.div`
|
|
169
|
+
background: #fff;
|
|
170
|
+
border: #ccc 1px solid;
|
|
171
|
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
|
172
|
+
font-family: ${(p) => {
|
|
173
|
+
var _a;
|
|
174
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.type;
|
|
175
|
+
}};
|
|
176
|
+
font-size: ${(p) => {
|
|
177
|
+
var _a;
|
|
178
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
179
|
+
}};
|
|
180
|
+
`;
|
|
181
|
+
const Header$1 = styled.div`
|
|
182
|
+
padding: ${(p) => p.theme.sizes.normal};
|
|
183
|
+
padding-bottom: 0;
|
|
184
|
+
font-size: ${(p) => {
|
|
185
|
+
var _a;
|
|
186
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
187
|
+
}};
|
|
188
|
+
font-weight: normal;
|
|
189
|
+
white-space: nowrap;
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
|
|
193
|
+
h1,
|
|
194
|
+
h2,
|
|
195
|
+
h3,
|
|
196
|
+
h4,
|
|
197
|
+
h5,
|
|
198
|
+
h6 {
|
|
199
|
+
margin: 0;
|
|
200
|
+
font-weight: normal;
|
|
201
|
+
padding-bottom: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
svg,
|
|
205
|
+
i {
|
|
206
|
+
margin-right: ${(p) => p.theme.sizes.small};
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
const StyledList = styled(List)`
|
|
210
|
+
list-style: none;
|
|
211
|
+
padding: 0;
|
|
212
|
+
margin: 0;
|
|
213
|
+
padding: ${(p) => p.theme.sizes.small} 0;
|
|
214
|
+
|
|
215
|
+
li {
|
|
216
|
+
background: #fff;
|
|
217
|
+
|
|
218
|
+
a {
|
|
219
|
+
display: block;
|
|
220
|
+
font-size: ${(p) => {
|
|
221
|
+
var _a;
|
|
222
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.small;
|
|
223
|
+
}};
|
|
224
|
+
padding: ${(p) => {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
return `${(_a = p.theme.sizes) == null ? void 0 : _a.small} ${(_b = p.theme.sizes) == null ? void 0 : _b.normal}`;
|
|
227
|
+
}};
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
color: #555;
|
|
230
|
+
text-decoration: none;
|
|
231
|
+
|
|
232
|
+
&:hover {
|
|
233
|
+
background: #f9f9f9;
|
|
234
|
+
color: ${(p) => {
|
|
235
|
+
var _a;
|
|
236
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
237
|
+
}};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
const DropdownList = (_e) => {
|
|
243
|
+
var _f = _e, {
|
|
244
|
+
trigger,
|
|
245
|
+
className,
|
|
246
|
+
children,
|
|
247
|
+
closeButtonAriaLabel
|
|
248
|
+
} = _f, other = __objRest(_f, [
|
|
249
|
+
"trigger",
|
|
250
|
+
"className",
|
|
251
|
+
"children",
|
|
252
|
+
"closeButtonAriaLabel"
|
|
253
|
+
]);
|
|
254
|
+
return /* @__PURE__ */ React.createElement(Dropdown, {
|
|
255
|
+
className: appendClassNames(className, "humany-dropdown-list"),
|
|
256
|
+
closeButtonAriaLabel,
|
|
257
|
+
trigger
|
|
258
|
+
}, /* @__PURE__ */ React.createElement(StyledItemList$1, __spreadValues({}, other), children));
|
|
259
|
+
};
|
|
260
|
+
const StyledItemList$1 = styled(ItemList)`
|
|
261
|
+
${itemList}
|
|
262
|
+
font-family: ${(p) => {
|
|
263
|
+
var _a;
|
|
264
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.type;
|
|
265
|
+
}};
|
|
266
|
+
> div {
|
|
267
|
+
${headingElement("> h1", css`
|
|
268
|
+
font-size: ${(p) => {
|
|
269
|
+
var _a;
|
|
270
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
271
|
+
}};
|
|
272
|
+
line-height: 1.2em;
|
|
273
|
+
`)}
|
|
274
|
+
}
|
|
275
|
+
> ul > li {
|
|
276
|
+
overflow: visible;
|
|
277
|
+
font-weight: 300;
|
|
278
|
+
font-size: ${(p) => {
|
|
279
|
+
var _a;
|
|
280
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
281
|
+
}};
|
|
282
|
+
|
|
283
|
+
a {
|
|
284
|
+
display: inline-block;
|
|
285
|
+
|
|
286
|
+
@media (hover: hover) {
|
|
287
|
+
&:hover {
|
|
288
|
+
text-decoration: underline;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
`;
|
|
294
|
+
const spin = keyframes`
|
|
295
|
+
100% {
|
|
296
|
+
transform: rotate(360deg);
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
const dash = keyframes`
|
|
300
|
+
0% {
|
|
301
|
+
stroke-dasharray: 1, 200;
|
|
302
|
+
stroke-dashoffset: 0;
|
|
303
|
+
}
|
|
304
|
+
50% {
|
|
305
|
+
stroke-dasharray: 89, 200;
|
|
306
|
+
stroke-dashoffset: -35px;
|
|
307
|
+
}
|
|
308
|
+
100% {
|
|
309
|
+
stroke-dasharray: 89, 200;
|
|
310
|
+
stroke-dashoffset: -124px;
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
const SpinnerSvg = styled.svg`
|
|
314
|
+
animation: ${spin} 2s linear infinite;
|
|
315
|
+
height: 100%;
|
|
316
|
+
transform-origin: center center;
|
|
317
|
+
width: 100%;
|
|
318
|
+
position: absolute;
|
|
319
|
+
top: 0;
|
|
320
|
+
bottom: 0;
|
|
321
|
+
left: 0;
|
|
322
|
+
right: 0;
|
|
323
|
+
margin: auto;
|
|
324
|
+
transition: 200ms ease-out opacity;
|
|
325
|
+
`;
|
|
326
|
+
const Wrapper$1 = styled.div`
|
|
327
|
+
position: absolute;
|
|
328
|
+
top: 0;
|
|
329
|
+
bottom: 0;
|
|
330
|
+
left: 0;
|
|
331
|
+
right: 0;
|
|
332
|
+
height: 100%;
|
|
333
|
+
width: 100%;
|
|
334
|
+
pointer-events: ${(p) => p["data-loading"] ? "all" : "none"}
|
|
335
|
+
display: flex;
|
|
336
|
+
flex-direction: column;
|
|
337
|
+
justify-content: center;
|
|
338
|
+
transition: 200ms ease-out opacity;
|
|
339
|
+
box-sizing: border-box;
|
|
340
|
+
overflow: hidden;
|
|
341
|
+
${SpinnerSvg} {
|
|
342
|
+
opacity: ${(p) => p["data-loading"] ? "1" : "0"}
|
|
343
|
+
}
|
|
344
|
+
`;
|
|
345
|
+
const Spinner = styled.div`
|
|
346
|
+
position: relative;
|
|
347
|
+
margin: 0 auto;
|
|
348
|
+
width: 100px;
|
|
349
|
+
&:before {
|
|
350
|
+
content: '';
|
|
351
|
+
display: block;
|
|
352
|
+
padding-top: 100%;
|
|
353
|
+
}
|
|
354
|
+
`;
|
|
355
|
+
const SpinnerCircle = styled.circle`
|
|
356
|
+
stroke-dasharray: 1, 200;
|
|
357
|
+
stroke-dashoffset: 0;
|
|
358
|
+
animation: ${dash} 1.5s ease-in-out infinite;
|
|
359
|
+
stroke-linecap: round;
|
|
360
|
+
stroke: ${(p) => {
|
|
361
|
+
var _a;
|
|
362
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
363
|
+
}};
|
|
364
|
+
stroke-width: 2px;
|
|
365
|
+
`;
|
|
366
|
+
const Loader = ({ loading = false }) => {
|
|
367
|
+
return /* @__PURE__ */ React.createElement(Wrapper$1, {
|
|
368
|
+
className: "humany-loader",
|
|
369
|
+
"data-loading": loading
|
|
370
|
+
}, /* @__PURE__ */ React.createElement(Spinner, {
|
|
371
|
+
className: "humany-spinner"
|
|
372
|
+
}, /* @__PURE__ */ React.createElement(SpinnerSvg, {
|
|
373
|
+
viewBox: "25 25 50 50"
|
|
374
|
+
}, /* @__PURE__ */ React.createElement(SpinnerCircle, {
|
|
375
|
+
cx: "50",
|
|
376
|
+
cy: "50",
|
|
377
|
+
r: "20",
|
|
378
|
+
fill: "none",
|
|
379
|
+
"stroke-width": "2",
|
|
380
|
+
"stroke-miterlimit": "10"
|
|
381
|
+
}))));
|
|
382
|
+
};
|
|
383
|
+
const loadingOpacity = css`
|
|
384
|
+
${(p) => p["data-loading"] && "position: relative;"};
|
|
385
|
+
${(p) => p["data-loading"] && "min-height: 150px;"}
|
|
386
|
+
> * {
|
|
387
|
+
transition: 200ms ease-out opacity;
|
|
388
|
+
opacity: ${(p) => p["data-loading"] ? "0.5" : "1"};
|
|
389
|
+
}
|
|
390
|
+
${Wrapper$1} {
|
|
391
|
+
opacity: ${(p) => p["data-loading"] ? "1" : "0"};
|
|
392
|
+
}
|
|
393
|
+
`;
|
|
394
|
+
const genericHtml = css`
|
|
395
|
+
font-size: ${(p) => {
|
|
396
|
+
var _a;
|
|
397
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
398
|
+
}};
|
|
399
|
+
font-weight: 300;
|
|
400
|
+
line-height: 1.5em;
|
|
401
|
+
color: ${(p) => {
|
|
402
|
+
var _a;
|
|
403
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
404
|
+
}};
|
|
405
|
+
|
|
406
|
+
h1,
|
|
407
|
+
h2,
|
|
408
|
+
h3,
|
|
409
|
+
h4,
|
|
410
|
+
h5,
|
|
411
|
+
h6 {
|
|
412
|
+
word-break: break-word;
|
|
413
|
+
&:first-child {
|
|
414
|
+
margin-top: 0;
|
|
415
|
+
}
|
|
416
|
+
&:only-child {
|
|
417
|
+
margin: 0;
|
|
418
|
+
}
|
|
419
|
+
&:last-child {
|
|
420
|
+
margin-bottom: 0;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
a {
|
|
425
|
+
color: ${(p) => {
|
|
426
|
+
var _a;
|
|
427
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.link;
|
|
428
|
+
}};
|
|
429
|
+
&:focus {
|
|
430
|
+
${(p) => {
|
|
431
|
+
var _a;
|
|
432
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && linkTabStyle;
|
|
433
|
+
}};
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
img {
|
|
438
|
+
max-width: 100% !important;
|
|
439
|
+
height: auto !important;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
p {
|
|
443
|
+
word-break: break-word;
|
|
444
|
+
margin: ${(p) => {
|
|
445
|
+
var _a;
|
|
446
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
447
|
+
}} 0;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
p:first-child {
|
|
451
|
+
margin: 0 0 ${(p) => {
|
|
452
|
+
var _a;
|
|
453
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
454
|
+
}};
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
p:last-child {
|
|
458
|
+
margin: ${(p) => {
|
|
459
|
+
var _a;
|
|
460
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
461
|
+
}} 0 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
p:only-child {
|
|
465
|
+
margin: 0;
|
|
466
|
+
}
|
|
467
|
+
`;
|
|
468
|
+
const SmallCaret = styled(Icon)`
|
|
469
|
+
&& {
|
|
470
|
+
font-size: ${(p) => {
|
|
471
|
+
var _a;
|
|
472
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.small;
|
|
473
|
+
}};
|
|
474
|
+
}
|
|
475
|
+
width: 1.2em;
|
|
476
|
+
`;
|
|
477
|
+
const StyledHeaderText = styled(Text)`
|
|
478
|
+
font-size: ${(p) => {
|
|
479
|
+
var _a;
|
|
480
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.medium;
|
|
481
|
+
}};
|
|
482
|
+
font-weight: normal;
|
|
483
|
+
line-height: 1.2em;
|
|
484
|
+
color: ${(p) => {
|
|
485
|
+
var _a;
|
|
486
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
487
|
+
}};
|
|
488
|
+
`;
|
|
489
|
+
const StyledListButton = styled(Button)`
|
|
490
|
+
display: flex;
|
|
491
|
+
align-items: center;
|
|
492
|
+
|
|
493
|
+
${(p) => {
|
|
494
|
+
var _a;
|
|
495
|
+
return p["data-has-label"] === "true" && p["data-has-symbol"] === "true" && `
|
|
496
|
+
svg, i {
|
|
497
|
+
margin: 0 ${(_a = p.theme.sizes) == null ? void 0 : _a.small} 0 0;
|
|
498
|
+
}
|
|
499
|
+
`;
|
|
500
|
+
}}
|
|
501
|
+
|
|
502
|
+
&:focus {
|
|
503
|
+
${(p) => {
|
|
504
|
+
var _a;
|
|
505
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
506
|
+
${(p2) => p2["data-has-label"] === "true" && paddedBorderTabStyle}
|
|
507
|
+
|
|
508
|
+
svg, i {
|
|
509
|
+
${(p2) => p2["data-has-label"] === "false" && p2["data-has-symbol"] === "true" && css`
|
|
510
|
+
${paddedBorderTabStyle}
|
|
511
|
+
box-sizing: content-box;
|
|
512
|
+
`}
|
|
513
|
+
}
|
|
514
|
+
`;
|
|
515
|
+
}};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
span {
|
|
519
|
+
flex: 1;
|
|
520
|
+
font-weight: 300;
|
|
521
|
+
}
|
|
522
|
+
`;
|
|
523
|
+
const FavoriteButton = ({
|
|
524
|
+
addFavoriteTooltip,
|
|
525
|
+
removeFavoriteCancelLabel,
|
|
526
|
+
removeFavoriteConfirmLabel,
|
|
527
|
+
removeFavoriteHeader,
|
|
528
|
+
removeFavoriteLabel,
|
|
529
|
+
removeFavoriteTooltip,
|
|
530
|
+
id,
|
|
531
|
+
isFavorite,
|
|
532
|
+
guideTitle,
|
|
533
|
+
buttonLabel = "",
|
|
534
|
+
actions: { addFavorite, removeFavorite }
|
|
535
|
+
}) => {
|
|
536
|
+
const remove = useCallback(() => {
|
|
537
|
+
removeFavorite(id);
|
|
538
|
+
}, [id, removeFavorite]);
|
|
539
|
+
const add = useCallback(() => {
|
|
540
|
+
addFavorite(id);
|
|
541
|
+
}, [id, addFavorite]);
|
|
542
|
+
const tooltip = `${isFavorite ? removeFavoriteTooltip : addFavoriteTooltip}${guideTitle ? `: "${guideTitle}"` : ""}`;
|
|
543
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isFavorite ? /* @__PURE__ */ React.createElement(Confirm, {
|
|
544
|
+
trigger: /* @__PURE__ */ React.createElement(StyledButton, {
|
|
545
|
+
className: "humany-favorite-button",
|
|
546
|
+
title: tooltip,
|
|
547
|
+
"aria-label": tooltip,
|
|
548
|
+
"data-favorite": "true",
|
|
549
|
+
"data-has-label": buttonLabel ? "true" : "false",
|
|
550
|
+
"data-has-symbol": "true"
|
|
551
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
552
|
+
size: 16,
|
|
553
|
+
symbol: { type: "Svg", content: "star-empty" }
|
|
554
|
+
}), buttonLabel && /* @__PURE__ */ React.createElement(StyledText$1, null, buttonLabel)),
|
|
555
|
+
onConfirm: remove,
|
|
556
|
+
cancelLabel: removeFavoriteCancelLabel,
|
|
557
|
+
confirmLabel: removeFavoriteConfirmLabel,
|
|
558
|
+
header: removeFavoriteHeader,
|
|
559
|
+
text: removeFavoriteLabel
|
|
560
|
+
}) : /* @__PURE__ */ React.createElement(StyledButton, {
|
|
561
|
+
className: "humany-favorite-button",
|
|
562
|
+
title: tooltip,
|
|
563
|
+
"aria-label": tooltip,
|
|
564
|
+
onClick: add,
|
|
565
|
+
"data-favorite": "false",
|
|
566
|
+
"data-has-label": buttonLabel ? "true" : "false",
|
|
567
|
+
"data-has-symbol": "true"
|
|
568
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
569
|
+
size: 16,
|
|
570
|
+
symbol: { type: "Svg", content: "star-empty" }
|
|
571
|
+
}), buttonLabel && /* @__PURE__ */ React.createElement(StyledText$1, null, buttonLabel)));
|
|
572
|
+
};
|
|
573
|
+
const StyledButton = styled(StyledListButton)`
|
|
574
|
+
grid-area: favorite;
|
|
575
|
+
|
|
576
|
+
&:focus {
|
|
577
|
+
${(p) => {
|
|
578
|
+
var _a;
|
|
579
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
580
|
+
svg {
|
|
581
|
+
${(p2) => {
|
|
582
|
+
var _a2, _b;
|
|
583
|
+
return p2["data-favorite"] === "true" ? `
|
|
584
|
+
fill: transparent;
|
|
585
|
+
|
|
586
|
+
path {
|
|
587
|
+
fill: transparent;
|
|
588
|
+
}
|
|
589
|
+
` : `
|
|
590
|
+
fill: ${(_a2 = p2.theme.colors) == null ? void 0 : _a2.text};
|
|
591
|
+
|
|
592
|
+
path {
|
|
593
|
+
fill: ${(_b = p2.theme.colors) == null ? void 0 : _b.text};
|
|
594
|
+
}
|
|
595
|
+
`;
|
|
596
|
+
}}
|
|
597
|
+
}
|
|
598
|
+
`;
|
|
599
|
+
}};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
${(p) => {
|
|
603
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
604
|
+
return ((_a = p.theme.colors) == null ? void 0 : _a.text) && css`
|
|
605
|
+
svg {
|
|
606
|
+
stroke: ${(_b = p.theme.colors) == null ? void 0 : _b.text};
|
|
607
|
+
|
|
608
|
+
path {
|
|
609
|
+
stroke: ${(_c = p.theme.colors) == null ? void 0 : _c.text};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
${p["data-favorite"] === "true" && `
|
|
613
|
+
fill: ${(_d = p.theme.colors) == null ? void 0 : _d.text};
|
|
614
|
+
|
|
615
|
+
path {
|
|
616
|
+
fill: ${(_e = p.theme.colors) == null ? void 0 : _e.text};
|
|
617
|
+
}
|
|
618
|
+
`}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
&:hover {
|
|
622
|
+
svg {
|
|
623
|
+
${p["data-favorite"] === "true" ? `
|
|
624
|
+
fill: transparent;
|
|
625
|
+
|
|
626
|
+
path {
|
|
627
|
+
fill: transparent;
|
|
628
|
+
}
|
|
629
|
+
` : `
|
|
630
|
+
fill: ${(_f = p.theme.colors) == null ? void 0 : _f.text};
|
|
631
|
+
|
|
632
|
+
path {
|
|
633
|
+
fill: ${(_g = p.theme.colors) == null ? void 0 : _g.text};
|
|
634
|
+
}
|
|
635
|
+
`}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
`;
|
|
639
|
+
}}
|
|
640
|
+
`;
|
|
641
|
+
var feedback = forwardRef((_g, ref) => {
|
|
642
|
+
var _h = _g, {
|
|
643
|
+
onFeedback = () => {
|
|
644
|
+
},
|
|
645
|
+
direction = "horizontal",
|
|
646
|
+
className,
|
|
647
|
+
header,
|
|
648
|
+
positive,
|
|
649
|
+
negative,
|
|
650
|
+
selected
|
|
651
|
+
} = _h, other = __objRest(_h, [
|
|
652
|
+
"onFeedback",
|
|
653
|
+
"direction",
|
|
654
|
+
"className",
|
|
655
|
+
"header",
|
|
656
|
+
"positive",
|
|
657
|
+
"negative",
|
|
658
|
+
"selected"
|
|
659
|
+
]);
|
|
660
|
+
return /* @__PURE__ */ React.createElement(Wrapper, __spreadProps(__spreadValues({
|
|
661
|
+
className: appendClassNames(className, "humany-feedback"),
|
|
662
|
+
"data-direction": direction
|
|
663
|
+
}, convertToStringAttributes(other)), {
|
|
664
|
+
ref
|
|
665
|
+
}), !!header && /* @__PURE__ */ React.createElement(Header, null, header), /* @__PURE__ */ React.createElement(FeedbackButton, {
|
|
666
|
+
className: "humany-feedback-button",
|
|
667
|
+
disabled: !!selected,
|
|
668
|
+
"aria-pressed": selected === "positive",
|
|
669
|
+
"data-selected": selected === "positive",
|
|
670
|
+
"data-direction": direction,
|
|
671
|
+
onClick: () => onFeedback("positive")
|
|
672
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
673
|
+
faIcon: "smile-o"
|
|
674
|
+
}), /* @__PURE__ */ React.createElement("span", null, positive)), /* @__PURE__ */ React.createElement(FeedbackButton, {
|
|
675
|
+
className: "humany-feedback-button",
|
|
676
|
+
disabled: !!selected,
|
|
677
|
+
"aria-pressed": selected === "negative",
|
|
678
|
+
"data-selected": selected === "negative",
|
|
679
|
+
"data-direction": direction,
|
|
680
|
+
onClick: () => onFeedback("negative")
|
|
681
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
682
|
+
faIcon: "frown-o"
|
|
683
|
+
}), /* @__PURE__ */ React.createElement("span", null, negative)));
|
|
684
|
+
});
|
|
685
|
+
const Header = styled(StyledText$1)`
|
|
686
|
+
font-weight: normal;
|
|
687
|
+
margin: 0 0 ${(p) => {
|
|
688
|
+
var _a;
|
|
689
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
690
|
+
}};
|
|
691
|
+
font-size: ${(p) => {
|
|
692
|
+
var _a;
|
|
693
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
694
|
+
}};
|
|
695
|
+
display: block;
|
|
696
|
+
`;
|
|
697
|
+
const FeedbackButton = styled(Button)`
|
|
698
|
+
display: inline-block;
|
|
699
|
+
font-size: ${(p) => {
|
|
700
|
+
var _a;
|
|
701
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
702
|
+
}};
|
|
703
|
+
font-weight: 300;
|
|
704
|
+
&& {
|
|
705
|
+
margin-right: ${(p) => {
|
|
706
|
+
var _a;
|
|
707
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.large;
|
|
708
|
+
}};
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
${(p) => {
|
|
712
|
+
var _a, _b;
|
|
713
|
+
return p["data-direction"] === "horizontal" && css`
|
|
714
|
+
width: 225px;
|
|
715
|
+
max-width: calc(50% - ${(_a = p.theme.sizes) == null ? void 0 : _a.large} - ${(_b = p.theme.sizes) == null ? void 0 : _b.small});
|
|
716
|
+
`;
|
|
717
|
+
}}
|
|
718
|
+
|
|
719
|
+
${(p) => p["data-direction"] === "vertical" && css`
|
|
720
|
+
min-width: 190px;
|
|
721
|
+
`}
|
|
722
|
+
|
|
723
|
+
${(p) => {
|
|
724
|
+
var _a;
|
|
725
|
+
return invertedHoverButton({
|
|
726
|
+
active: p["data-selected"],
|
|
727
|
+
primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
|
|
728
|
+
secondaryColor: "#FFFFFF"
|
|
729
|
+
});
|
|
730
|
+
}}
|
|
731
|
+
|
|
732
|
+
i {
|
|
733
|
+
margin: 0 ${(p) => {
|
|
734
|
+
var _a;
|
|
735
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
736
|
+
}} 0 0;
|
|
737
|
+
}
|
|
738
|
+
`;
|
|
739
|
+
const Wrapper = styled.div`
|
|
740
|
+
${(p) => p["data-direction"] === "vertical" && css`
|
|
741
|
+
> button {
|
|
742
|
+
width: 100%;
|
|
743
|
+
&:not(:last-child) {
|
|
744
|
+
margin-bottom: ${(p2) => {
|
|
745
|
+
var _a;
|
|
746
|
+
return (_a = p2.theme.sizes) == null ? void 0 : _a.normal;
|
|
747
|
+
}};
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
`}
|
|
751
|
+
`;
|
|
752
|
+
const useArrowKeys = () => {
|
|
753
|
+
const [keyPressed, setKeyPressed] = useState(null);
|
|
754
|
+
const left = useKeyPress("ArrowLeft");
|
|
755
|
+
const right = useKeyPress("ArrowRight");
|
|
756
|
+
const up = useKeyPress("ArrowUp");
|
|
757
|
+
const down = useKeyPress("ArrowDown");
|
|
758
|
+
const effect = () => {
|
|
759
|
+
if (left) {
|
|
760
|
+
setKeyPressed("left");
|
|
761
|
+
} else if (right) {
|
|
762
|
+
setKeyPressed("right");
|
|
763
|
+
} else if (up) {
|
|
764
|
+
setKeyPressed("up");
|
|
765
|
+
} else if (down) {
|
|
766
|
+
setKeyPressed("down");
|
|
767
|
+
} else {
|
|
768
|
+
setKeyPressed(null);
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
useEffect(effect, [left, right, up, down]);
|
|
772
|
+
return keyPressed;
|
|
773
|
+
};
|
|
774
|
+
const useDebounce = (value, delay) => {
|
|
775
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
776
|
+
const handler = useCallback(() => {
|
|
777
|
+
return setTimeout(() => {
|
|
778
|
+
setDebouncedValue(value);
|
|
779
|
+
}, delay);
|
|
780
|
+
}, [delay, setDebouncedValue, value]);
|
|
781
|
+
useEffect(() => {
|
|
782
|
+
const timeout = handler();
|
|
783
|
+
return () => {
|
|
784
|
+
clearTimeout(timeout);
|
|
785
|
+
};
|
|
786
|
+
}, [handler]);
|
|
787
|
+
return debouncedValue;
|
|
788
|
+
};
|
|
789
|
+
const useFavorites = () => {
|
|
790
|
+
const container = useContainer();
|
|
791
|
+
const [favorites, setFavorites] = useState([]);
|
|
792
|
+
const platform = container.get("favorites");
|
|
793
|
+
useEffect(() => {
|
|
794
|
+
if (platform) {
|
|
795
|
+
setFavorites(platform.get());
|
|
796
|
+
const { events } = container.get("$widget");
|
|
797
|
+
const unsubscribe = events.subscribe("widget:favorites-updated", (_, { updated }) => {
|
|
798
|
+
setFavorites([...updated]);
|
|
799
|
+
});
|
|
800
|
+
return unsubscribe;
|
|
801
|
+
}
|
|
802
|
+
}, []);
|
|
803
|
+
const add = (guideId) => {
|
|
804
|
+
if (!platform) {
|
|
805
|
+
return Promise.resolve([]);
|
|
806
|
+
}
|
|
807
|
+
return platform.add(guideId);
|
|
808
|
+
};
|
|
809
|
+
const remove = (guideId) => {
|
|
810
|
+
if (!platform) {
|
|
811
|
+
return Promise.resolve([]);
|
|
812
|
+
}
|
|
813
|
+
return platform.remove(guideId);
|
|
814
|
+
};
|
|
815
|
+
const clear = () => {
|
|
816
|
+
if (!platform) {
|
|
817
|
+
return Promise.resolve([]);
|
|
818
|
+
}
|
|
819
|
+
return platform.clear();
|
|
820
|
+
};
|
|
821
|
+
const toggle = useCallback((guideId) => {
|
|
822
|
+
if (favorites.indexOf(guideId) > -1) {
|
|
823
|
+
return remove(guideId);
|
|
824
|
+
} else {
|
|
825
|
+
return add(guideId);
|
|
826
|
+
}
|
|
827
|
+
}, [favorites]);
|
|
828
|
+
return [
|
|
829
|
+
favorites,
|
|
830
|
+
useMemo(() => ({
|
|
831
|
+
addFavorite: add,
|
|
832
|
+
removeFavorite: remove,
|
|
833
|
+
clearFavorites: clear,
|
|
834
|
+
toggleFavorite: toggle
|
|
835
|
+
}), [favorites])
|
|
836
|
+
];
|
|
837
|
+
};
|
|
838
|
+
var useHover = () => {
|
|
839
|
+
const [hovering, setHovering] = useState(false);
|
|
840
|
+
const elem = useRef();
|
|
841
|
+
const onMouseEnter = useCallback(() => setHovering(true), [setHovering]);
|
|
842
|
+
const onMouseLeave = useCallback(() => setHovering(false), [setHovering]);
|
|
843
|
+
useEventListener("mouseenter", onMouseEnter, elem.current);
|
|
844
|
+
useEventListener("mouseleave", onMouseLeave, elem.current);
|
|
845
|
+
return [hovering, elem];
|
|
846
|
+
};
|
|
847
|
+
const Metadata = ({
|
|
848
|
+
format = DateFormats.YYYY_MM_DD_HH_MM,
|
|
849
|
+
className = "",
|
|
850
|
+
byLabel = "",
|
|
851
|
+
modifiedLabel = "",
|
|
852
|
+
publishedLabel = "",
|
|
853
|
+
modifiedBy = "",
|
|
854
|
+
publishedBy = "",
|
|
855
|
+
showModified = false,
|
|
856
|
+
showPublished = false,
|
|
857
|
+
modified,
|
|
858
|
+
published
|
|
859
|
+
}) => {
|
|
860
|
+
const publishedTimestamp = showPublished && published ? /* @__PURE__ */ React.createElement(StyledTimestamp, {
|
|
861
|
+
format,
|
|
862
|
+
timestamp: published
|
|
863
|
+
}) : null;
|
|
864
|
+
const modifiedTimestamp = showModified && modified ? /* @__PURE__ */ React.createElement(StyledTimestamp, {
|
|
865
|
+
format,
|
|
866
|
+
timestamp: modified
|
|
867
|
+
}) : null;
|
|
868
|
+
if (!publishedTimestamp && !modifiedTimestamp) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
return /* @__PURE__ */ React.createElement(StyledText, {
|
|
872
|
+
className: appendClassNames(className, "humany-metadata")
|
|
873
|
+
}, publishedTimestamp && /* @__PURE__ */ React.createElement(StyledText, {
|
|
874
|
+
className: "humany-published"
|
|
875
|
+
}, publishedLabel, publishedTimestamp, byLabel && publishedBy && ` ${byLabel.replace("{{editor}}", publishedBy)}`), modifiedTimestamp && /* @__PURE__ */ React.createElement(StyledText, {
|
|
876
|
+
className: "humany-modified"
|
|
877
|
+
}, publishedTimestamp && ", ", modifiedLabel, modifiedTimestamp, byLabel && modifiedBy && ` ${byLabel.replace("{{editor}}", modifiedBy)}`));
|
|
878
|
+
};
|
|
879
|
+
const StyledTimestamp = styled(Timestamp)`
|
|
880
|
+
&:not(:first-child) {
|
|
881
|
+
margin-left: 4px;
|
|
882
|
+
}
|
|
883
|
+
&:not(:last-child) {
|
|
884
|
+
margin-right: 4px;
|
|
885
|
+
}
|
|
886
|
+
`;
|
|
887
|
+
const StyledText = styled(Text)`
|
|
888
|
+
font-style: italic;
|
|
889
|
+
`;
|
|
890
|
+
const Tags = ({ tags }) => {
|
|
891
|
+
if (!tags.filter((t) => t.symbol).length) {
|
|
892
|
+
return null;
|
|
893
|
+
}
|
|
894
|
+
return /* @__PURE__ */ React.createElement(StyledTagList, {
|
|
895
|
+
className: "humany-guide-list-tags",
|
|
896
|
+
items: tags,
|
|
897
|
+
renderItem: ({ id, symbol, title }) => symbol && /* @__PURE__ */ React.createElement("li", {
|
|
898
|
+
key: id,
|
|
899
|
+
"data-tag": id
|
|
900
|
+
}, /* @__PURE__ */ React.createElement(StyledTagIcon, {
|
|
901
|
+
size: 18,
|
|
902
|
+
symbol,
|
|
903
|
+
title
|
|
904
|
+
}))
|
|
905
|
+
});
|
|
906
|
+
};
|
|
907
|
+
const AccordionListItem = forwardRef(({ title, id, route, symbolSize, collapseUri, children }, ref) => {
|
|
908
|
+
const { params } = useRouteData();
|
|
909
|
+
return /* @__PURE__ */ React.createElement(ActiveAccordionListItem, {
|
|
910
|
+
ref,
|
|
911
|
+
"data-guide": id
|
|
912
|
+
}, /* @__PURE__ */ React.createElement(TextLink, {
|
|
913
|
+
title,
|
|
914
|
+
"aria-label": title,
|
|
915
|
+
routeName: route,
|
|
916
|
+
params: createParams(__spreadProps(__spreadValues({}, params), {
|
|
917
|
+
uriName: collapseUri ? collapseUri : void 0,
|
|
918
|
+
id: void 0,
|
|
919
|
+
guide: void 0,
|
|
920
|
+
accordion: void 0
|
|
921
|
+
})),
|
|
922
|
+
text: title
|
|
923
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
924
|
+
size: symbolSize,
|
|
925
|
+
symbol: { type: "Svg", content: "caret-up" }
|
|
926
|
+
})), children);
|
|
927
|
+
});
|
|
928
|
+
const ActiveAccordionListItem = styled.li`
|
|
929
|
+
> a {
|
|
930
|
+
grid-column: 1 / -1
|
|
931
|
+
font-weight: bold;
|
|
932
|
+
margin: 0 0 ${(p) => {
|
|
933
|
+
var _a;
|
|
934
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
935
|
+
}} 0;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
> div {
|
|
939
|
+
grid-column: 1 / -1
|
|
940
|
+
}
|
|
941
|
+
`;
|
|
942
|
+
var guideList = forwardRef((_i, ref) => {
|
|
943
|
+
var _j = _i, {
|
|
944
|
+
expandable = false,
|
|
945
|
+
routing = {},
|
|
946
|
+
paramMappers = {},
|
|
947
|
+
symbolSize = 11,
|
|
948
|
+
pageRole = "link",
|
|
949
|
+
pageCaret = "down",
|
|
950
|
+
showTags = false,
|
|
951
|
+
showFavoriteToggle = false,
|
|
952
|
+
localPaging = false,
|
|
953
|
+
onItemClick = () => {
|
|
954
|
+
},
|
|
955
|
+
dispatch = () => {
|
|
956
|
+
},
|
|
957
|
+
metadata = {},
|
|
958
|
+
pageLabel,
|
|
959
|
+
className,
|
|
960
|
+
children,
|
|
961
|
+
items,
|
|
962
|
+
renderItem,
|
|
963
|
+
addFavoriteTooltip,
|
|
964
|
+
removeFavoriteCancelLabel,
|
|
965
|
+
removeFavoriteConfirmLabel,
|
|
966
|
+
removeFavoriteHeader,
|
|
967
|
+
removeFavoriteLabel,
|
|
968
|
+
removeFavoriteTooltip
|
|
969
|
+
} = _j, other = __objRest(_j, [
|
|
970
|
+
"expandable",
|
|
971
|
+
"routing",
|
|
972
|
+
"paramMappers",
|
|
973
|
+
"symbolSize",
|
|
974
|
+
"pageRole",
|
|
975
|
+
"pageCaret",
|
|
976
|
+
"showTags",
|
|
977
|
+
"showFavoriteToggle",
|
|
978
|
+
"localPaging",
|
|
979
|
+
"onItemClick",
|
|
980
|
+
"dispatch",
|
|
981
|
+
"metadata",
|
|
982
|
+
"pageLabel",
|
|
983
|
+
"className",
|
|
984
|
+
"children",
|
|
985
|
+
"items",
|
|
986
|
+
"renderItem",
|
|
987
|
+
"addFavoriteTooltip",
|
|
988
|
+
"removeFavoriteCancelLabel",
|
|
989
|
+
"removeFavoriteConfirmLabel",
|
|
990
|
+
"removeFavoriteHeader",
|
|
991
|
+
"removeFavoriteLabel",
|
|
992
|
+
"removeFavoriteTooltip"
|
|
993
|
+
]);
|
|
994
|
+
const {
|
|
995
|
+
accessibility: { isTabbing = false }
|
|
996
|
+
} = useContext(ThemeContext);
|
|
997
|
+
const innerRef = useRef();
|
|
998
|
+
const prevItems = usePrevious(items);
|
|
999
|
+
const { guide: guideRoute = "guide", page: pageRoute = "index" } = routing;
|
|
1000
|
+
const {
|
|
1001
|
+
guide: mapGuideParams = ({ id }) => createParams({ guide: id }),
|
|
1002
|
+
page: mapPageParams = () => createParams()
|
|
1003
|
+
} = paramMappers;
|
|
1004
|
+
const [favorites, actions] = useFavorites();
|
|
1005
|
+
useImperativeHandle(ref, () => innerRef.current);
|
|
1006
|
+
const defaultRenderer = (guide) => {
|
|
1007
|
+
const { id, title, tags, published, modified, publishedBy, modifiedBy } = guide;
|
|
1008
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
1009
|
+
key: id,
|
|
1010
|
+
"data-guide": id,
|
|
1011
|
+
"has-metadata": (!!(metadata == null ? void 0 : metadata.showPublished) && !!published || !!(metadata == null ? void 0 : metadata.showModified) && !!modified).toString()
|
|
1012
|
+
}, /* @__PURE__ */ React.createElement(TextLink, {
|
|
1013
|
+
className: "humany-guide-link",
|
|
1014
|
+
title,
|
|
1015
|
+
"aria-label": title,
|
|
1016
|
+
routeName: guideRoute,
|
|
1017
|
+
onClick: (e) => onItemClick(e, guide),
|
|
1018
|
+
params: mapGuideParams(guide),
|
|
1019
|
+
text: title
|
|
1020
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
1021
|
+
size: symbolSize,
|
|
1022
|
+
symbol: {
|
|
1023
|
+
type: "Svg",
|
|
1024
|
+
content: expandable ? "caret-down" : "caret-right"
|
|
1025
|
+
}
|
|
1026
|
+
})), showFavoriteToggle && /* @__PURE__ */ React.createElement(FavoriteButton, {
|
|
1027
|
+
guideTitle: title,
|
|
1028
|
+
addFavoriteTooltip,
|
|
1029
|
+
removeFavoriteCancelLabel,
|
|
1030
|
+
removeFavoriteConfirmLabel,
|
|
1031
|
+
removeFavoriteHeader,
|
|
1032
|
+
removeFavoriteLabel,
|
|
1033
|
+
removeFavoriteTooltip,
|
|
1034
|
+
isFavorite: favorites.indexOf(id) > -1,
|
|
1035
|
+
actions,
|
|
1036
|
+
id
|
|
1037
|
+
}), showTags && /* @__PURE__ */ React.createElement(Tags, {
|
|
1038
|
+
tags
|
|
1039
|
+
}), /* @__PURE__ */ React.createElement(StyledMetadata, __spreadProps(__spreadValues({}, metadata), {
|
|
1040
|
+
indent: expandable ? void 0 : symbolSize,
|
|
1041
|
+
modified,
|
|
1042
|
+
published,
|
|
1043
|
+
publishedBy,
|
|
1044
|
+
modifiedBy
|
|
1045
|
+
})));
|
|
1046
|
+
};
|
|
1047
|
+
const renderer = useCallback((guide, index, items2) => {
|
|
1048
|
+
if (renderItem) {
|
|
1049
|
+
return renderItem(guide, index, items2, defaultRenderer);
|
|
1050
|
+
}
|
|
1051
|
+
return defaultRenderer(guide);
|
|
1052
|
+
}, [renderItem, defaultRenderer]);
|
|
1053
|
+
const onPageClick = useCallback((e) => {
|
|
1054
|
+
if (localPaging) {
|
|
1055
|
+
e.preventDefault();
|
|
1056
|
+
dispatch("page", mapPageParams());
|
|
1057
|
+
}
|
|
1058
|
+
}, [dispatch, localPaging]);
|
|
1059
|
+
useEffect(() => {
|
|
1060
|
+
if (isTabbing && prevItems && prevItems.length < items.length && innerRef.current) {
|
|
1061
|
+
const elements = innerRef.current.querySelectorAll(".humany-guide-list > ul > li");
|
|
1062
|
+
const listItemElem = elements[prevItems.length];
|
|
1063
|
+
if (elements.length === items.length && prevItems.length) {
|
|
1064
|
+
const nextListItem = elements[prevItems.length];
|
|
1065
|
+
if (nextListItem) {
|
|
1066
|
+
const focusNext = nextListItem.querySelector(".humany-guide-link");
|
|
1067
|
+
focusNext && focusNext.focus();
|
|
1068
|
+
}
|
|
1069
|
+
} else if (listItemElem) {
|
|
1070
|
+
const observer = new MutationObserver((mutations, observer2) => {
|
|
1071
|
+
mutations.forEach((mutation) => {
|
|
1072
|
+
if (mutation.addedNodes) {
|
|
1073
|
+
const found = Array.from(mutation.addedNodes).find((node) => node.tagName === "A");
|
|
1074
|
+
if (found && htmlParentContains(innerRef.current, document.activeElement)) {
|
|
1075
|
+
isTabbing && found.focus();
|
|
1076
|
+
observer2.disconnect();
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
1081
|
+
observer.observe(listItemElem, {
|
|
1082
|
+
attributes: false,
|
|
1083
|
+
characterData: false,
|
|
1084
|
+
childList: true,
|
|
1085
|
+
subtree: true,
|
|
1086
|
+
attributeOldValue: false,
|
|
1087
|
+
characterDataOldValue: false
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
const hasMetaData = !!Object.keys(metadata).filter((k) => typeof metadata[k] !== "undefined").length;
|
|
1093
|
+
return /* @__PURE__ */ React.createElement(StyledItemList, __spreadProps(__spreadValues({
|
|
1094
|
+
className: appendClassNames(className, "humany-guide-list"),
|
|
1095
|
+
"data-item-count": items.length,
|
|
1096
|
+
items,
|
|
1097
|
+
renderItem: renderer,
|
|
1098
|
+
expandable: expandable ? "true" : "false",
|
|
1099
|
+
"grid-items": showTags || showFavoriteToggle || hasMetaData ? "true" : "false"
|
|
1100
|
+
}, convertToStringAttributes(other)), {
|
|
1101
|
+
ref: innerRef
|
|
1102
|
+
}), pageLabel ? /* @__PURE__ */ React.createElement(TextLink, {
|
|
1103
|
+
text: pageLabel,
|
|
1104
|
+
title: pageLabel,
|
|
1105
|
+
"aria-label": pageLabel,
|
|
1106
|
+
routeName: pageRoute,
|
|
1107
|
+
role: pageRole,
|
|
1108
|
+
params: mapPageParams(),
|
|
1109
|
+
onClick: onPageClick
|
|
1110
|
+
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
1111
|
+
size: symbolSize,
|
|
1112
|
+
symbol: { type: "Svg", content: `caret-${pageCaret}` }
|
|
1113
|
+
})) : null, children);
|
|
1114
|
+
});
|
|
1115
|
+
const StyledItemList = styled(ItemList)`
|
|
1116
|
+
${itemList}
|
|
1117
|
+
padding: ${(p) => {
|
|
1118
|
+
var _a;
|
|
1119
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.large;
|
|
1120
|
+
}};
|
|
1121
|
+
overflow: auto;
|
|
1122
|
+
justify-content: flex-start;
|
|
1123
|
+
white-space: nowrap;
|
|
1124
|
+
font-weight: 300;
|
|
1125
|
+
text-decoration: none;
|
|
1126
|
+
|
|
1127
|
+
> div {
|
|
1128
|
+
${headingElement("> h1", css`
|
|
1129
|
+
white-space: pre-wrap;
|
|
1130
|
+
`)}
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
> ul > li {
|
|
1134
|
+
${(p) => p["grid-items"] === "true" && css`
|
|
1135
|
+
display: grid;
|
|
1136
|
+
grid-template-columns: auto 1fr 1fr;
|
|
1137
|
+
gap: 0px 0px;
|
|
1138
|
+
grid-template-areas: '. favorite tags';
|
|
1139
|
+
align-items: center;
|
|
1140
|
+
|
|
1141
|
+
> button {
|
|
1142
|
+
margin: 0 0 0 ${(p2) => {
|
|
1143
|
+
var _a;
|
|
1144
|
+
return (_a = p2.theme.sizes) == null ? void 0 : _a.small;
|
|
1145
|
+
}};
|
|
1146
|
+
|
|
1147
|
+
&[data-favorite='false'] {
|
|
1148
|
+
${(p2) => {
|
|
1149
|
+
var _a;
|
|
1150
|
+
return ((_a = p2.theme.accessibility) == null ? void 0 : _a.isTabbing) ? "opacity: 0;" : "display: none;";
|
|
1151
|
+
}};
|
|
1152
|
+
&:focus {
|
|
1153
|
+
opacity: 1;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
> span {
|
|
1159
|
+
font-size: ${(p2) => {
|
|
1160
|
+
var _a;
|
|
1161
|
+
return (_a = p2.theme.fonts) == null ? void 0 : _a.small;
|
|
1162
|
+
}};
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
&:hover {
|
|
1166
|
+
button[data-favorite='false'] {
|
|
1167
|
+
display: flex;
|
|
1168
|
+
justify-self: flex-start;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
&[has-metadata='true'] {
|
|
1173
|
+
grid-template-rows: 1fr 1fr;
|
|
1174
|
+
grid-template-areas:
|
|
1175
|
+
'. favorite tags'
|
|
1176
|
+
'metadata metadata metadata';
|
|
1177
|
+
}
|
|
1178
|
+
`}
|
|
1179
|
+
> a {
|
|
1180
|
+
color: ${(p) => {
|
|
1181
|
+
var _a;
|
|
1182
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
1183
|
+
}};
|
|
1184
|
+
overflow: hidden;
|
|
1185
|
+
text-overflow: ellipsis;
|
|
1186
|
+
max-width: 100%;
|
|
1187
|
+
display: inline-block;
|
|
1188
|
+
|
|
1189
|
+
svg {
|
|
1190
|
+
margin: 0 calc(${(p) => {
|
|
1191
|
+
var _a;
|
|
1192
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
1193
|
+
}}*2) 0 0;
|
|
1194
|
+
line {
|
|
1195
|
+
stroke: ${(p) => {
|
|
1196
|
+
var _a;
|
|
1197
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
1198
|
+
}};
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
${(p) => p.expandable === "true" && css`
|
|
1203
|
+
display: flex;
|
|
1204
|
+
flex-direction: row-reverse;
|
|
1205
|
+
justify-content: flex-end;
|
|
1206
|
+
align-items: center;
|
|
1207
|
+
|
|
1208
|
+
span {
|
|
1209
|
+
overflow: hidden;
|
|
1210
|
+
text-overflow: ellipsis;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
svg {
|
|
1214
|
+
margin: 0 0 0 ${(p2) => {
|
|
1215
|
+
var _a;
|
|
1216
|
+
return (_a = p2.theme.sizes) == null ? void 0 : _a.small;
|
|
1217
|
+
}};
|
|
1218
|
+
}
|
|
1219
|
+
`}
|
|
1220
|
+
|
|
1221
|
+
&:focus {
|
|
1222
|
+
${(p) => {
|
|
1223
|
+
var _a;
|
|
1224
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
1225
|
+
${borderTabStyle}
|
|
1226
|
+
text-decoration: underline;
|
|
1227
|
+
`;
|
|
1228
|
+
}};
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
@media (hover: hover) {
|
|
1232
|
+
&:hover {
|
|
1233
|
+
text-decoration: underline;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
> a {
|
|
1240
|
+
color: ${(p) => {
|
|
1241
|
+
var _a;
|
|
1242
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
1243
|
+
}};
|
|
1244
|
+
margin: ${(p) => {
|
|
1245
|
+
var _a;
|
|
1246
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
1247
|
+
}} 0 0;
|
|
1248
|
+
align-self: flex-start;
|
|
1249
|
+
align-items: center;
|
|
1250
|
+
display: flex;
|
|
1251
|
+
|
|
1252
|
+
span {
|
|
1253
|
+
text-decoration: underline;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
svg {
|
|
1257
|
+
margin: 0 calc(${(p) => {
|
|
1258
|
+
var _a;
|
|
1259
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
1260
|
+
}}*2) 0 0;
|
|
1261
|
+
line {
|
|
1262
|
+
stroke: ${(p) => {
|
|
1263
|
+
var _a;
|
|
1264
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
1265
|
+
}};
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
&:focus {
|
|
1270
|
+
${(p) => {
|
|
1271
|
+
var _a;
|
|
1272
|
+
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
1273
|
+
${borderTabStyle}
|
|
1274
|
+
text-decoration: underline;
|
|
1275
|
+
`;
|
|
1276
|
+
}};
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
`;
|
|
1280
|
+
const StyledTagList = styled(List)`
|
|
1281
|
+
${list}
|
|
1282
|
+
display: flex;
|
|
1283
|
+
margin: 0 0 0 auto;
|
|
1284
|
+
grid-area: tags;
|
|
1285
|
+
|
|
1286
|
+
li,
|
|
1287
|
+
li:last-child {
|
|
1288
|
+
margin: 0 0 0 ${(p) => {
|
|
1289
|
+
var _a;
|
|
1290
|
+
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
1291
|
+
}};
|
|
1292
|
+
display: flex;
|
|
1293
|
+
align-items: center;
|
|
1294
|
+
justify-content: space-between;
|
|
1295
|
+
}
|
|
1296
|
+
`;
|
|
1297
|
+
const StyledTagIcon = styled(SymbolBadge)`
|
|
1298
|
+
display: block;
|
|
1299
|
+
color: ${(p) => {
|
|
1300
|
+
var _a;
|
|
1301
|
+
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
1302
|
+
}};
|
|
1303
|
+
${(p) => {
|
|
1304
|
+
if (p.symbol.type === "Uri") {
|
|
1305
|
+
return `
|
|
1306
|
+
width: ${p.size}px;
|
|
1307
|
+
height: ${p.size}px;
|
|
1308
|
+
`;
|
|
1309
|
+
}
|
|
1310
|
+
if (p.symbol.type === "FontAwesome") {
|
|
1311
|
+
return `
|
|
1312
|
+
font-size: ${p.size}px;
|
|
1313
|
+
`;
|
|
1314
|
+
}
|
|
1315
|
+
}}
|
|
1316
|
+
`;
|
|
1317
|
+
const StyledMetadata = styled(Metadata)`
|
|
1318
|
+
grid-area: metadata;
|
|
1319
|
+
text-overflow: ellipsis;
|
|
1320
|
+
overflow: hidden;
|
|
1321
|
+
font-size: ${(p) => {
|
|
1322
|
+
var _a;
|
|
1323
|
+
return (_a = p.theme.fonts) == null ? void 0 : _a.small;
|
|
1324
|
+
}};
|
|
1325
|
+
${(p) => {
|
|
1326
|
+
var _a;
|
|
1327
|
+
return typeof p.indent === "number" && `text-indent: calc(${(_a = p.theme.sizes) == null ? void 0 : _a.small} * 2 + ${p.indent}px);`;
|
|
1328
|
+
}}
|
|
1329
|
+
`;
|
|
1330
|
+
const isAnchorLink = (href) => {
|
|
1331
|
+
const re = new RegExp("^#", "i");
|
|
1332
|
+
const match = re.test(href);
|
|
1333
|
+
return match;
|
|
1334
|
+
};
|
|
1335
|
+
const embeddedLinkMapper = (container) => (_a) => {
|
|
1336
|
+
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
1337
|
+
const {
|
|
1338
|
+
implementation,
|
|
1339
|
+
name: currentWidgetName
|
|
1340
|
+
} = container.get("$widget");
|
|
1341
|
+
const { href = "" } = props;
|
|
1342
|
+
if (isAnchorLink(href)) {
|
|
1343
|
+
return /* @__PURE__ */ React.createElement(AnchorLink, {
|
|
1344
|
+
smooth: true,
|
|
1345
|
+
to: href
|
|
1346
|
+
}, children);
|
|
1347
|
+
}
|
|
1348
|
+
const escapedBindings = implementation.bindings.map((binding) => binding.replace(/\./g, "\\.")).join("|");
|
|
1349
|
+
const regexp = new RegExp(`^((http[s]?:)?//)?(${escapedBindings})/([^\\s]+)`);
|
|
1350
|
+
const expArray = regexp.exec(href);
|
|
1351
|
+
if (expArray && expArray.length >= 4) {
|
|
1352
|
+
const targetWidgetName = expArray[4];
|
|
1353
|
+
const targetWidget = implementation.widgets.get(targetWidgetName);
|
|
1354
|
+
if (targetWidget && !targetWidgetName.startsWith("blob?") && !targetWidgetName.startsWith(currentWidgetName)) {
|
|
1355
|
+
return /* @__PURE__ */ React.createElement(WidgetLink, {
|
|
1356
|
+
widgetName: targetWidgetName
|
|
1357
|
+
}, children);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
return /* @__PURE__ */ React.createElement("a", __spreadValues({}, props), children);
|
|
1361
|
+
};
|
|
1362
|
+
const imageLightboxRenderer = (attrs) => /* @__PURE__ */ React.createElement(Lightbox, {
|
|
1363
|
+
attrs
|
|
1364
|
+
});
|
|
1365
|
+
const guideRenderInstructions = (container, dialog = []) => {
|
|
1366
|
+
return {
|
|
1367
|
+
transform: {
|
|
1368
|
+
img: imageLightboxRenderer,
|
|
1369
|
+
a: (attr) => {
|
|
1370
|
+
const _a = attr, { children } = _a, otherAttr = __objRest(_a, ["children"]);
|
|
1371
|
+
const connectionId = otherAttr["data-target"];
|
|
1372
|
+
if (connectionId && dialog.length) {
|
|
1373
|
+
const item = dialog.find(({ connection }) => connection === connectionId);
|
|
1374
|
+
if (item) {
|
|
1375
|
+
return /* @__PURE__ */ React.createElement(DialogLink, __spreadValues({}, item), children);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
const defaultInstructions = embeddedLinkMapper(container);
|
|
1379
|
+
return defaultInstructions(attr);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
};
|
|
1384
|
+
export { AccordionListItem, DialogLink, dialogList as DialogList, DrawerList, DropdownActions, DropdownList, FavoriteButton, feedback as Feedback, guideList as GuideList, Loader, Wrapper$1 as LoaderWrapper, Metadata, SmallCaret, StyledHeaderText, StyledListButton, genericHtml, guideRenderInstructions, loadingOpacity, useArrowKeys, useDebounce, useFavorites, useHover };
|
|
1385
|
+
//# sourceMappingURL=index.js.map
|