@telia-ace/knowledge-widget-components-guide 1.0.14 → 1.0.17

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/dist/guide.js DELETED
@@ -1,917 +0,0 @@
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 { ContactList, contactLink } from "@telia-ace/knowledge-widget-adapters";
33
- import { NotFound, Component } from "@telia-ace/knowledge-widget-types-grid";
34
- import { List, TextLink, paddedBorderTabStyle, useRouteData, Feedback as Feedback$1, StyledHeaderText, useDispatch, useProperties, Text, SymbolBadge, useContainer, Tooltip, StyledListButton, DropdownList, useFavorites, StyledText, FavoriteButton, DrawerList, DrawerAnimationType, useChildren, createEmptyComponent, guideRenderInstructions, Loader, loadingOpacity, Paragraph, genericHtml, headingElement, DialogList, contentBox, Metadata, Button, linkTabStyle } from "@telia-ace/knowledge-widget-ui";
35
- import { appendClassNames, buildCategoryTrail, createParams } from "@telia-ace/widget-utilities";
36
- import React, { useMemo, useState, useEffect, useCallback, forwardRef } from "react";
37
- import styled, { css } from "styled-components";
38
- import { PickerTypes } from "@telia-ace/knowledge-widget-core";
39
- const AnswerVersionPicker = ({
40
- className,
41
- defaultAnswerVersionLabel,
42
- guide: { perspective: selectedPerspective, perspectives: guidePerspectives },
43
- availablePerspectives = []
44
- }) => {
45
- const { name, params } = useRouteData();
46
- const perspectives = useMemo(() => {
47
- if (!guidePerspectives || !availablePerspectives.length) {
48
- return [];
49
- }
50
- return availablePerspectives.filter(({ name: name2 }) => !!guidePerspectives[name2]).map(({ name: name2, title }) => {
51
- return { label: title, connection: guidePerspectives[name2] };
52
- });
53
- }, [guidePerspectives, availablePerspectives]);
54
- return /* @__PURE__ */ React.createElement(StyledList, {
55
- className: appendClassNames(className, "humany-guide-answer-version-picker"),
56
- items: perspectives,
57
- renderItem: (perspective) => {
58
- const label = perspective.label === "Default" ? defaultAnswerVersionLabel : perspective.label;
59
- const selected = selectedPerspective === perspective.connection;
60
- const isRoot = selected && (!params.connection || selectedPerspective === params.connection);
61
- return /* @__PURE__ */ React.createElement("li", {
62
- key: perspective.connection,
63
- "data-version": perspective.connection
64
- }, /* @__PURE__ */ React.createElement(VersionLink, {
65
- key: perspective.connection,
66
- forwardedAs: isRoot ? "span" : void 0,
67
- text: label,
68
- routeName: name,
69
- selected,
70
- "aria-label": label,
71
- title: label,
72
- params: __spreadProps(__spreadValues({}, params), {
73
- connection: perspective.connection
74
- })
75
- }));
76
- }
77
- });
78
- };
79
- const StyledList = styled(List)`
80
- display: flex;
81
- align-items: center;
82
- flex-wrap: wrap;
83
-
84
- list-style: none;
85
- padding: 0;
86
- margin: 0;
87
-
88
- li:not(:last-child) {
89
- margin: 0 calc(${(p) => {
90
- var _a;
91
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
92
- }} * 2) 0 0;
93
- }
94
-
95
- li > span {
96
- cursor: default;
97
- }
98
- `;
99
- const VersionLink = styled(TextLink)`
100
- font-weight: 300;
101
- color: ${(p) => {
102
- var _a;
103
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
104
- }};
105
- text-decoration: none;
106
-
107
- ${(p) => p.selected && css`
108
- font-weight: bold;
109
- text-decoration: underline;
110
- `}
111
-
112
- &:focus {
113
- ${(p) => {
114
- var _a;
115
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && paddedBorderTabStyle;
116
- }};
117
- }
118
- `;
119
- const StyledContactList$1 = styled(ContactList)`
120
- border-top: ${(p) => p.theme.border};
121
- ${(p) => p.backButtonShown === "true" && `border-bottom: ${p.theme.border};`}
122
- `;
123
- const StyledFeedback = styled(Feedback$1)`
124
- ${(p) => {
125
- var _a, _b;
126
- return `padding: ${(_a = p.theme.sizes) == null ? void 0 : _a.large} ${(_b = p.theme.sizes) == null ? void 0 : _b.large};`;
127
- }}
128
- `;
129
- const Recognition = styled(StyledHeaderText)`
130
- ${(p) => {
131
- var _a, _b;
132
- return `padding: ${(_a = p.theme.sizes) == null ? void 0 : _a.large} ${(_b = p.theme.sizes) == null ? void 0 : _b.large};`;
133
- }}
134
-
135
- display: block;
136
- font-size: ${(p) => {
137
- var _a;
138
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
139
- }};
140
- font-weight: bold;
141
- `;
142
- const Feedback = ({ backButtonShown = false, accordion = false }) => {
143
- const dispatch = useDispatch();
144
- const {
145
- loading = false,
146
- dialog = [],
147
- guide,
148
- handoverContactMethods = [],
149
- contactHeader,
150
- showFeedback,
151
- feedbackDirection = "horizontal",
152
- feedbackRecognitionLabel,
153
- feedbackGiven,
154
- feedbackHeader,
155
- positiveFeedbackLabel,
156
- negativeFeedbackLabel,
157
- contactFeedbackLabel
158
- } = useProperties();
159
- if (!showFeedback || !guide || !guide.allowFeedback || loading && !feedbackGiven || dialog.length) {
160
- return null;
161
- }
162
- if (feedbackGiven && feedbackRecognitionLabel && !handoverContactMethods.length) {
163
- return /* @__PURE__ */ React.createElement(Recognition, {
164
- accordion: accordion ? "true" : "false"
165
- }, feedbackRecognitionLabel);
166
- }
167
- return guide.hasHandover && handoverContactMethods.length ? /* @__PURE__ */ React.createElement(StyledContactList$1, {
168
- backButtonShown: backButtonShown ? "true" : "false",
169
- accordion: accordion ? "true" : "false",
170
- header: contactHeader,
171
- contactMethods: handoverContactMethods,
172
- dispatch
173
- }) : /* @__PURE__ */ React.createElement(StyledFeedback, {
174
- accordion: accordion ? "true" : "false",
175
- positive: positiveFeedbackLabel,
176
- negative: guide.hasHandover ? contactFeedbackLabel : negativeFeedbackLabel,
177
- header: feedbackHeader,
178
- selected: feedbackGiven,
179
- onFeedback: (feedback) => dispatch("feedback", feedback),
180
- direction: feedbackDirection
181
- });
182
- };
183
- const Categories = ({
184
- guide: { categories = [] },
185
- toolbar: { picker = PickerTypes.NONE }
186
- }) => {
187
- const [trail, setTrail] = useState([]);
188
- const container = useContainer();
189
- useEffect(() => {
190
- buildCategoryTrail("index", categories.map((id) => id.toString()), container).then((result) => {
191
- setTrail(result);
192
- });
193
- }, [categories]);
194
- if (!trail.length) {
195
- return null;
196
- }
197
- return /* @__PURE__ */ React.createElement(Tooltip, {
198
- className: "humany-guide-category-tooltip",
199
- sticky: picker === PickerTypes.DRAWER,
200
- content: /* @__PURE__ */ React.createElement(React.Fragment, null, trail.map((segments) => {
201
- return /* @__PURE__ */ React.createElement(CategoryTrail, {
202
- className: "humany-guide-category-trail",
203
- key: segments.map((c) => c.id).join(".")
204
- }, segments.map((category, index) => {
205
- return /* @__PURE__ */ React.createElement(Text, {
206
- className: "humany-guide-category-trail-segment",
207
- key: category.id
208
- }, category.symbol && index === 0 && /* @__PURE__ */ React.createElement(SymbolBadge, {
209
- size: 14,
210
- symbol: category.symbol
211
- }), category.title, index !== segments.length - 1 && /* @__PURE__ */ React.createElement(CategorySeparator, {
212
- className: "humany-category-separator"
213
- }, "/"));
214
- }));
215
- }))
216
- }, picker === PickerTypes.DRAWER ? /* @__PURE__ */ React.createElement(StyledListButton, {
217
- className: "humany-guide-category-tooltip-button",
218
- "data-has-label": "false",
219
- "data-has-symbol": "true"
220
- }, /* @__PURE__ */ React.createElement(CategoriesSymbolBadge, {
221
- size: 19,
222
- symbol: { type: "Svg", content: "information" }
223
- })) : /* @__PURE__ */ React.createElement(CategoriesSymbolBadge, {
224
- size: 19,
225
- symbol: { type: "Svg", content: "information" }
226
- }));
227
- };
228
- const CategoryTrail = styled.div`
229
- i,
230
- svg {
231
- margin: 0 ${(p) => {
232
- var _a;
233
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
234
- }} 0 0;
235
- }
236
-
237
- &:not(:last-child) {
238
- margin: 0 0 ${(p) => {
239
- var _a;
240
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
241
- }};
242
- }
243
- `;
244
- const CategorySeparator = styled(Text)`
245
- margin: 0 ${(p) => {
246
- var _a;
247
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
248
- }};
249
- `;
250
- const CategoriesSymbolBadge = styled(SymbolBadge)`
251
- display: block;
252
- `;
253
- const Functions = ({
254
- header,
255
- tooltip,
256
- printActionLabel,
257
- copyActionLabel,
258
- addFavoriteTooltip,
259
- removeFavoriteCancelLabel,
260
- removeFavoriteConfirmLabel,
261
- removeFavoriteHeader,
262
- removeFavoriteLabel,
263
- removeFavoriteTooltip,
264
- toolbarFunctionsCloseButtonAriaLabel,
265
- allowCopy = false,
266
- allowPrint = false,
267
- showFavoriteToggle = false,
268
- picker = PickerTypes.NONE,
269
- guide,
270
- dispatch
271
- }) => {
272
- const [favorites, actions] = useFavorites();
273
- const handleCopy = useCallback((event) => {
274
- if (guide) {
275
- dispatch("copy", guide);
276
- }
277
- }, [guide, dispatch]);
278
- const handlePrint = useCallback(() => {
279
- if (guide) {
280
- dispatch("print");
281
- }
282
- }, [guide, dispatch]);
283
- const items = useMemo(() => {
284
- const { id, title } = guide;
285
- const items2 = [];
286
- if (allowCopy) {
287
- items2.push({
288
- type: "copy",
289
- child: /* @__PURE__ */ React.createElement(StyledListButton, {
290
- "data-has-label": copyActionLabel ? "true" : "false",
291
- "data-has-symbol": "true",
292
- title: copyActionLabel,
293
- "aria-label": printActionLabel,
294
- onClick: handleCopy
295
- }, /* @__PURE__ */ React.createElement(ColoredSymbolBadge$1, {
296
- size: 16,
297
- symbol: { type: "Svg", content: "copy" }
298
- }), copyActionLabel && /* @__PURE__ */ React.createElement(StyledText, null, copyActionLabel))
299
- });
300
- }
301
- if (allowPrint) {
302
- items2.push({
303
- type: "print",
304
- child: /* @__PURE__ */ React.createElement(StyledListButton, {
305
- "data-has-label": printActionLabel ? "true" : "false",
306
- "data-has-symbol": "true",
307
- title: printActionLabel,
308
- "aria-label": printActionLabel,
309
- onClick: handlePrint
310
- }, /* @__PURE__ */ React.createElement(ColoredSymbolBadge$1, {
311
- size: 16,
312
- symbol: { type: "Svg", content: "print" }
313
- }), printActionLabel && /* @__PURE__ */ React.createElement(StyledText, null, printActionLabel))
314
- });
315
- }
316
- if (showFavoriteToggle) {
317
- const isFavorite = favorites.indexOf(id) > -1;
318
- items2.push({
319
- type: "favorite",
320
- child: /* @__PURE__ */ React.createElement(FavoriteButton, {
321
- id,
322
- guideTitle: title,
323
- isFavorite,
324
- buttonLabel: isFavorite ? removeFavoriteTooltip : addFavoriteTooltip,
325
- addFavoriteTooltip,
326
- removeFavoriteCancelLabel,
327
- removeFavoriteConfirmLabel,
328
- removeFavoriteHeader,
329
- removeFavoriteLabel,
330
- removeFavoriteTooltip,
331
- actions
332
- })
333
- });
334
- }
335
- return items2;
336
- }, [
337
- favorites,
338
- guide,
339
- allowCopy,
340
- allowPrint,
341
- showFavoriteToggle,
342
- printActionLabel,
343
- copyActionLabel,
344
- addFavoriteTooltip,
345
- removeFavoriteCancelLabel,
346
- removeFavoriteConfirmLabel,
347
- removeFavoriteHeader,
348
- removeFavoriteLabel,
349
- removeFavoriteTooltip
350
- ]);
351
- if (!items.length) {
352
- return null;
353
- }
354
- const trigger = /* @__PURE__ */ React.createElement(StyledTriggerButton, {
355
- tabIndex: 0,
356
- title: tooltip,
357
- "data-has-symbol": "true",
358
- "data-has-label": "false"
359
- }, /* @__PURE__ */ React.createElement(ColoredSymbolBadge$1, {
360
- symbol: { type: "Svg", content: "options" },
361
- size: 18
362
- }));
363
- const renderListItem = ({ type, child }) => {
364
- return /* @__PURE__ */ React.createElement("li", {
365
- key: type,
366
- "data-function-type": type
367
- }, child);
368
- };
369
- if (picker === PickerTypes.DROPDOWN) {
370
- return /* @__PURE__ */ React.createElement(StyledDropdownList$1, {
371
- className: "humany-guide-functions-dropdown-list",
372
- header,
373
- items,
374
- trigger,
375
- renderItem: renderListItem,
376
- closeButtonAriaLabel: toolbarFunctionsCloseButtonAriaLabel
377
- });
378
- }
379
- if (picker === PickerTypes.DRAWER) {
380
- return /* @__PURE__ */ React.createElement(DrawerList, {
381
- className: "humany-guide-functions-drawer-list",
382
- animation: { type: DrawerAnimationType.SlideInBottom },
383
- header,
384
- items,
385
- trigger,
386
- renderItem: renderListItem,
387
- closeButtonAriaLabel: toolbarFunctionsCloseButtonAriaLabel
388
- });
389
- }
390
- return null;
391
- };
392
- const ColoredSymbolBadge$1 = styled(SymbolBadge)`
393
- circle {
394
- fill: ${(p) => {
395
- var _a;
396
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
397
- }};
398
- }
399
-
400
- line,
401
- path,
402
- rect {
403
- stroke: ${(p) => {
404
- var _a;
405
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
406
- }};
407
- }
408
- `;
409
- const StyledDropdownList$1 = styled(DropdownList)`
410
- display: block;
411
- min-height: auto;
412
- `;
413
- const StyledTriggerButton = styled(StyledListButton)`
414
- padding: calc(${(p) => {
415
- var _a;
416
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
417
- }} * 2) 0;
418
- `;
419
- const getCurrentLanguageLabel = (guide, languages) => {
420
- var _a;
421
- return ((_a = languages.find((l) => l.id === guide.id)) == null ? void 0 : _a.label) || "";
422
- };
423
- const Languages = (_a) => {
424
- var _b = _a, {
425
- header,
426
- tooltip,
427
- picker = PickerTypes.NONE,
428
- guide
429
- } = _b, other = __objRest(_b, [
430
- "header",
431
- "tooltip",
432
- "picker",
433
- "guide"
434
- ]);
435
- const { name, params } = useRouteData();
436
- const items = useMemo(() => {
437
- return Object.keys(guide.translations || {}).reduce((acc, key) => {
438
- const item = {};
439
- item.key = key;
440
- item.id = (guide.translations || {})[key];
441
- item.label = other[`${key}LanguageLabel`];
442
- if (item.id || item.label) {
443
- acc.push(item);
444
- }
445
- return acc;
446
- }, []);
447
- }, [guide, other]);
448
- if (!items.length) {
449
- return null;
450
- }
451
- const currentLanguage = getCurrentLanguageLabel(guide, items);
452
- const trigger = /* @__PURE__ */ React.createElement(Trigger, {
453
- tabIndex: 0,
454
- title: tooltip,
455
- "data-has-symbol": "true",
456
- "data-has-label": picker === PickerTypes.DROPDOWN && currentLanguage ? "true" : "false"
457
- }, picker === PickerTypes.DROPDOWN && /* @__PURE__ */ React.createElement(React.Fragment, null, currentLanguage && /* @__PURE__ */ React.createElement(LanguageButtonText, null, currentLanguage), /* @__PURE__ */ React.createElement(LanguageCaretSymbolBadge, {
458
- symbol: { type: "Svg", content: "caret-down" },
459
- size: 11
460
- })), picker === PickerTypes.DRAWER && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ColoredSymbolBadge, {
461
- symbol: { type: "Svg", content: "language" },
462
- size: 20
463
- })));
464
- const renderListItem = ({ label, key, id }) => {
465
- return /* @__PURE__ */ React.createElement("li", {
466
- key,
467
- "data-language": key
468
- }, /* @__PURE__ */ React.createElement(LanguageLink, {
469
- tabIndex: 0,
470
- text: label,
471
- routeName: name,
472
- selected: guide.id === id,
473
- params: createParams(__spreadProps(__spreadValues({}, params), {
474
- connection: void 0,
475
- guide: id
476
- }))
477
- }));
478
- };
479
- if (picker === PickerTypes.DROPDOWN) {
480
- return /* @__PURE__ */ React.createElement(StyledDropdownList, {
481
- className: "humany-guide-languages-dropdown-list",
482
- header,
483
- items,
484
- trigger,
485
- renderItem: renderListItem
486
- });
487
- }
488
- if (picker === PickerTypes.DRAWER) {
489
- return /* @__PURE__ */ React.createElement(DrawerList, {
490
- className: "humany-guide-languages-drawer-list",
491
- animation: { type: DrawerAnimationType.SlideInBottom },
492
- header,
493
- items,
494
- trigger,
495
- renderItem: renderListItem
496
- });
497
- }
498
- return null;
499
- };
500
- const Trigger = styled(StyledListButton)`
501
- &&& {
502
- margin: 0 ${(p) => {
503
- var _a;
504
- return `calc(${(_a = p.theme.sizes) == null ? void 0 : _a.small} * 2)`;
505
- }} 0 0;
506
- }
507
- `;
508
- const ColoredSymbolBadge = styled(SymbolBadge)`
509
- circle {
510
- fill: ${(p) => {
511
- var _a;
512
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
513
- }};
514
- }
515
-
516
- line,
517
- path,
518
- rect {
519
- stroke: ${(p) => {
520
- var _a;
521
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
522
- }};
523
- }
524
- `;
525
- const LanguageButtonText = styled(Text)`
526
- margin: 0 ${(p) => {
527
- var _a;
528
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
529
- }} 0 0;
530
- font-size: ${(p) => {
531
- var _a;
532
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
533
- }};
534
- `;
535
- const LanguageCaretSymbolBadge = styled(SymbolBadge)`
536
- align-self: flex-end;
537
- stroke-width: 2px;
538
- stroke-linecap: round;
539
-
540
- && {
541
- width: 0.6em;
542
- height: 1em;
543
- }
544
- line {
545
- stroke: ${(p) => {
546
- var _a;
547
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
548
- }};
549
- }
550
- `;
551
- const StyledDropdownList = styled(DropdownList)`
552
- display: block;
553
- min-height: auto;
554
- `;
555
- const LanguageLink = styled(TextLink)`
556
- color: ${(p) => {
557
- var _a, _b;
558
- return p.selected ? (_a = p.theme.colors) == null ? void 0 : _a.primary : (_b = p.theme.colors) == null ? void 0 : _b.text;
559
- }};
560
- ${(p) => p.selected && "font-weight: bold;"}
561
-
562
- &:focus {
563
- ${(p) => {
564
- var _a;
565
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) ? css`
566
- ${paddedBorderTabStyle}
567
- text-decoration: underline;
568
- ` : "outline: none;";
569
- }}
570
- }
571
- `;
572
- const isEmpty = (toolbar) => {
573
- const {
574
- allowCopy = false,
575
- allowPrint = false,
576
- guideCategories = false,
577
- language = false,
578
- showFavoriteToggle = false,
579
- picker = PickerTypes.NONE
580
- } = toolbar;
581
- if (!allowCopy && !allowPrint && !language && !showFavoriteToggle && !guideCategories || picker === PickerTypes.NONE) {
582
- return true;
583
- }
584
- return false;
585
- };
586
- const Toolbar = ({ className = "", dispatch }) => {
587
- const _a = useProperties(), {
588
- toolbarLanguageHeader,
589
- toolbarFunctionsHeader,
590
- toolbarLanguageTooltip,
591
- toolbarFunctionsTooltip,
592
- toolbarFunctionsCloseButtonAriaLabel,
593
- printActionLabel,
594
- copyActionLabel,
595
- addFavoriteTooltip,
596
- removeFavoriteCancelLabel,
597
- removeFavoriteConfirmLabel,
598
- removeFavoriteHeader,
599
- removeFavoriteLabel,
600
- removeFavoriteTooltip,
601
- guide,
602
- toolbar
603
- } = _a, other = __objRest(_a, [
604
- "toolbarLanguageHeader",
605
- "toolbarFunctionsHeader",
606
- "toolbarLanguageTooltip",
607
- "toolbarFunctionsTooltip",
608
- "toolbarFunctionsCloseButtonAriaLabel",
609
- "printActionLabel",
610
- "copyActionLabel",
611
- "addFavoriteTooltip",
612
- "removeFavoriteCancelLabel",
613
- "removeFavoriteConfirmLabel",
614
- "removeFavoriteHeader",
615
- "removeFavoriteLabel",
616
- "removeFavoriteTooltip",
617
- "guide",
618
- "toolbar"
619
- ]);
620
- if (!guide || !toolbar || isEmpty(toolbar)) {
621
- return null;
622
- }
623
- const { language, guideCategories, allowCopy, allowPrint, showFavoriteToggle, picker } = toolbar;
624
- return /* @__PURE__ */ React.createElement(Wrapper$1, {
625
- className: appendClassNames("humany-guide-toolbar", className)
626
- }, language && Object.keys(guide.translations || {}).length > 1 && /* @__PURE__ */ React.createElement(Languages, __spreadValues({
627
- guide,
628
- header: toolbarLanguageHeader,
629
- tooltip: toolbarLanguageTooltip,
630
- picker
631
- }, other)), guideCategories && /* @__PURE__ */ React.createElement(Categories, {
632
- guide,
633
- toolbar
634
- }), (allowCopy || allowPrint || showFavoriteToggle) && /* @__PURE__ */ React.createElement(Functions, {
635
- guide,
636
- header: toolbarFunctionsHeader,
637
- tooltip: toolbarFunctionsTooltip,
638
- printActionLabel,
639
- copyActionLabel,
640
- addFavoriteTooltip,
641
- removeFavoriteCancelLabel,
642
- removeFavoriteConfirmLabel,
643
- removeFavoriteHeader,
644
- removeFavoriteLabel,
645
- removeFavoriteTooltip,
646
- toolbarFunctionsCloseButtonAriaLabel,
647
- allowCopy,
648
- allowPrint,
649
- showFavoriteToggle,
650
- picker,
651
- dispatch
652
- }));
653
- };
654
- const Wrapper$1 = styled.div`
655
- display: flex;
656
- align-items: center;
657
- justify-content: space-between;
658
- margin: 0 0 0 auto;
659
-
660
- > :not(:last-child) {
661
- margin: 0 calc(${(p) => {
662
- var _a;
663
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
664
- }} * 2) 0 0;
665
- }
666
- `;
667
- const Guide = forwardRef((_c, ref) => {
668
- var _d = _c, { className, accordion = false } = _d, other = __objRest(_d, ["className", "accordion"]);
669
- const {
670
- loading = false,
671
- dialog = [],
672
- contactMethods = [],
673
- showHeader = true,
674
- showAnswerVersions = false,
675
- defaultAnswerVersionLabel = "Default",
676
- backButtonLabel,
677
- metadataByLabel,
678
- metadataModifiedLabel,
679
- metadataPublishedLabel,
680
- availablePerspectives,
681
- metadata,
682
- toolbar,
683
- guide,
684
- error
685
- } = useProperties();
686
- const {
687
- params: { connection }
688
- } = useRouteData();
689
- const container = useContainer();
690
- const children = useChildren();
691
- const dispatch = useDispatch();
692
- const handleBackButtonClick = useCallback(() => {
693
- dispatch("back");
694
- }, [dispatch]);
695
- if (!guide && !error && !loading) {
696
- return createEmptyComponent(container, __spreadProps(__spreadValues({}, other), {
697
- className: appendClassNames(className, "humany-guide")
698
- }));
699
- }
700
- const { id = "", title = "", body = "", translations = {} } = guide || {};
701
- if (error && error.status === 404) {
702
- return /* @__PURE__ */ React.createElement(NotFound, {
703
- showSearch: false
704
- });
705
- }
706
- const showBackButton = !!accordion && !!connection;
707
- const language = Object.keys(translations).find((key) => translations[key] === `${id}`);
708
- return /* @__PURE__ */ React.createElement(Wrapper, __spreadProps(__spreadValues({
709
- ref
710
- }, other), {
711
- "data-loading": loading,
712
- className: appendClassNames(className, "humany-guide")
713
- }), /* @__PURE__ */ React.createElement(Content, {
714
- "data-loading": loading,
715
- accordion: accordion ? "true" : "false",
716
- className: "humany-guide-content"
717
- }, (showAnswerVersions && guide || !!toolbar) && /* @__PURE__ */ React.createElement(Top, {
718
- className: "humany-guide-top"
719
- }, showAnswerVersions && guide && /* @__PURE__ */ React.createElement(AnswerVersionPicker, {
720
- defaultAnswerVersionLabel,
721
- availablePerspectives,
722
- guide
723
- }), !!toolbar && /* @__PURE__ */ React.createElement(Toolbar, {
724
- dispatch
725
- })), !!(title || body) && /* @__PURE__ */ React.createElement(Body, {
726
- className: "humany-guide-body",
727
- accordion: accordion ? "true" : "false",
728
- header: showHeader && title || void 0,
729
- html: body,
730
- htmlParseInstruction: guideRenderInstructions(container, dialog),
731
- lang: language
732
- }), dialog && body.indexOf("h-option-link") === -1 && /* @__PURE__ */ React.createElement(StyledDialogList, {
733
- dialog
734
- }), /* @__PURE__ */ React.createElement(StyledContactList, {
735
- backButtonShown: showBackButton ? "true" : "false",
736
- contactMethods,
737
- dispatch,
738
- guideId: guide && guide.id
739
- }), !contactMethods.length && /* @__PURE__ */ React.createElement(Feedback, {
740
- backButtonShown: showBackButton,
741
- accordion
742
- }), showBackButton && /* @__PURE__ */ React.createElement(BackButton, {
743
- "aria-label": backButtonLabel,
744
- onClick: handleBackButtonClick
745
- }, /* @__PURE__ */ React.createElement(Caret, {
746
- width: "7",
747
- height: "13",
748
- viewBox: "0 0 7 13",
749
- fill: "none",
750
- xmlns: "http://www.w3.org/2000/svg"
751
- }, /* @__PURE__ */ React.createElement("line", {
752
- x1: "6.64645",
753
- y1: "12.5513",
754
- x2: "0.648357",
755
- y2: "6.55319"
756
- }), /* @__PURE__ */ React.createElement("line", {
757
- x1: "0.646447",
758
- y1: "6.64455",
759
- x2: "6.64454",
760
- y2: "0.646465"
761
- })), backButtonLabel && /* @__PURE__ */ React.createElement("span", null, backButtonLabel)), metadata && /* @__PURE__ */ React.createElement(StyledMetadata, __spreadProps(__spreadValues({}, metadata), {
762
- modified: guide == null ? void 0 : guide.modified,
763
- published: guide == null ? void 0 : guide.published,
764
- modifiedBy: guide == null ? void 0 : guide.modifiedBy,
765
- publishedBy: guide == null ? void 0 : guide.publishedBy,
766
- byLabel: metadataByLabel,
767
- modifiedLabel: metadataModifiedLabel,
768
- publishedLabel: metadataPublishedLabel
769
- })), children.map((child) => /* @__PURE__ */ React.createElement(StyledComponents, __spreadValues({
770
- key: child.id,
771
- id: child.id,
772
- branch: "default"
773
- }, { embedded: true })))), /* @__PURE__ */ React.createElement(Loader, {
774
- loading
775
- }));
776
- });
777
- const Wrapper = styled.div`
778
- ${loadingOpacity}
779
- min-width: 0;
780
- `;
781
- const Body = styled(Paragraph)`
782
- ${genericHtml}
783
- ${(p) => {
784
- var _a;
785
- return `padding: ${(_a = p.theme.sizes) == null ? void 0 : _a.large};`;
786
- }}
787
- display: block;
788
- line-height: 1.6em;
789
- ${headingElement("h1", css`
790
- font-size: ${(p) => {
791
- var _a;
792
- return (_a = p.theme.fonts) == null ? void 0 : _a.large;
793
- }};
794
- font-weight: normal;
795
- line-height: 1.6em;
796
- line-height: 1.6em;
797
- margin: 0 0 ${(p) => {
798
- var _a;
799
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
800
- }};
801
- `)}
802
-
803
- p {
804
- font-weight: 300;
805
- font-size: ${(p) => {
806
- var _a;
807
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
808
- }};
809
- color: ${(p) => {
810
- var _a;
811
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
812
- }};
813
- a {
814
- display: inline;
815
- }
816
- }
817
- `;
818
- const StyledContactList = styled(ContactList)`
819
- border-top: ${(p) => p.theme.border};
820
- ${(p) => p.backButtonShown === "true" && `border-bottom: ${p.theme.border};`}
821
- `;
822
- const StyledDialogList = styled(DialogList)`
823
- ${(p) => {
824
- var _a, _b;
825
- return `padding: 0 ${(_a = p.theme.sizes) == null ? void 0 : _a.large} ${(_b = p.theme.sizes) == null ? void 0 : _b.large};`;
826
- }}
827
- display: block;
828
- `;
829
- const Top = styled.div`
830
- ${(p) => {
831
- var _a, _b;
832
- return `padding: calc(${(_a = p.theme.sizes) == null ? void 0 : _a.normal}*2) ${(_b = p.theme.sizes) == null ? void 0 : _b.large};`;
833
- }}
834
- display: flex;
835
- justify-content: space-between;
836
- align-items: center;
837
- border-bottom: ${(p) => p.theme.border};
838
- border-radius: ${(p) => `${p.theme.borderRadius} ${p.theme.borderRadius}`} 0 0;
839
- background-color: #ffffff;
840
- `;
841
- const Content = styled.div`
842
- ${contentBox}
843
- display: block;
844
- > a {
845
- ${contactLink}
846
- }
847
-
848
- ${(p) => p.accordion === "true" && css`
849
- white-space: normal;
850
- box-shadow: none;
851
- background-color: #fafafa;
852
- `}
853
- `;
854
- const StyledMetadata = styled(Metadata)`
855
- display: block;
856
- ${(p) => {
857
- var _a, _b;
858
- return `padding: calc(${(_a = p.theme.sizes) == null ? void 0 : _a.normal}*2) ${(_b = p.theme.sizes) == null ? void 0 : _b.large};`;
859
- }}
860
- font-weight: 300;
861
- font-size: ${(p) => {
862
- var _a;
863
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
864
- }};
865
- color: ${(p) => {
866
- var _a;
867
- return (_a = p.theme.colors) == null ? void 0 : _a.text;
868
- }};
869
- border-top: ${(p) => p.theme.border};
870
- `;
871
- const StyledComponents = styled(Component)`
872
- border-top: ${(p) => p.theme.border};
873
- `;
874
- const BackButton = styled(Button)`
875
- ${(p) => {
876
- var _a, _b;
877
- return `padding: ${(_a = p.theme.sizes) == null ? void 0 : _a.normal} calc(${(_b = p.theme.sizes) == null ? void 0 : _b.normal} * 2);`;
878
- }}
879
- color: ${(p) => {
880
- var _a;
881
- return (_a = p.theme.colors) == null ? void 0 : _a.primary;
882
- }};
883
- text-decoration: underline;
884
- font-size: ${(p) => {
885
- var _a;
886
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
887
- }};
888
- span {
889
- font-weight: 300;
890
- }
891
- &:focus {
892
- ${(p) => {
893
- var _a;
894
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
895
- ${linkTabStyle}
896
- padding: ${(p2) => {
897
- var _a2, _b;
898
- return `calc(${(_a2 = p2.theme.sizes) == null ? void 0 : _a2.small} / 2) ${(_b = p2.theme.sizes) == null ? void 0 : _b.small}`;
899
- }};
900
- `;
901
- }};
902
- }
903
- `;
904
- const Caret = styled.svg`
905
- margin-right: ${(p) => {
906
- var _a;
907
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
908
- }};
909
- line {
910
- stroke: ${(p) => {
911
- var _a;
912
- return (_a = p.theme.colors) == null ? void 0 : _a.primary;
913
- }};
914
- }
915
- `;
916
- export { Guide as default };
917
- //# sourceMappingURL=guide.js.map