@salesforcedevs/arch-components 1.20.17-alpha9 → 1.25.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/lwc.config.json +42 -3
  2. package/package.json +34 -45
  3. package/src/assets/css/arch-variables.css +512 -0
  4. package/src/modules/arch/badge/badge.css +22 -0
  5. package/src/modules/arch/badge/badge.html +5 -0
  6. package/src/modules/arch/badge/badge.ts +9 -0
  7. package/src/modules/arch/button/button.css +1 -0
  8. package/src/modules/arch/button/button.html +20 -0
  9. package/src/modules/arch/button/button.ts +67 -0
  10. package/src/modules/arch/buttonLink/buttonLink.css +1 -0
  11. package/src/modules/arch/buttonLink/buttonLink.html +19 -0
  12. package/src/modules/arch/buttonLink/buttonLink.stories.js +34 -0
  13. package/src/modules/arch/buttonLink/buttonLink.ts +8 -0
  14. package/src/modules/arch/buttonStyles/buttonStyles.css +220 -0
  15. package/src/modules/arch/card/card.css +128 -0
  16. package/src/modules/arch/card/card.html +85 -0
  17. package/src/modules/arch/card/card.ts +277 -0
  18. package/src/modules/arch/cardBase/cardBase.css +11 -0
  19. package/src/modules/arch/cardBase/cardBase.html +2 -0
  20. package/src/modules/arch/cardGridA/cardGridA.css +11 -0
  21. package/src/modules/arch/cardGridA/cardGridA.html +21 -0
  22. package/src/modules/arch/cardGridA/cardGridA.stories.js +118 -0
  23. package/src/modules/arch/cardGridA/cardGridA.ts +24 -0
  24. package/src/modules/arch/cardGridC/cardGridC.css +24 -0
  25. package/src/modules/arch/cardGridC/cardGridC.html +22 -0
  26. package/src/modules/arch/cardGridC/cardGridC.stories.js +51 -0
  27. package/src/modules/arch/cardGridC/cardGridC.ts +11 -0
  28. package/src/modules/arch/cardGridD/cardGridD.css +17 -0
  29. package/src/modules/arch/cardGridD/cardGridD.html +20 -0
  30. package/src/modules/arch/cardGridD/cardGridD.stories.js +43 -0
  31. package/src/modules/arch/cardGridD/cardGridD.ts +7 -0
  32. package/src/modules/arch/cardNew/cardNew.css +31 -0
  33. package/src/modules/arch/cardNew/cardNew.html +32 -0
  34. package/src/modules/arch/cardNew/cardNew.ts +66 -0
  35. package/src/modules/arch/children/children.html +2 -0
  36. package/src/modules/arch/children/children.ts +31 -0
  37. package/src/modules/arch/color/color.ts +59 -0
  38. package/src/modules/arch/content/__fixtures__/index.ts +884 -0
  39. package/src/modules/arch/content/content.css +643 -0
  40. package/src/modules/arch/content/content.html +65 -0
  41. package/src/modules/arch/content/content.stories.js +21 -0
  42. package/src/modules/arch/content/content.ts +169 -0
  43. package/src/modules/arch/contentIcon/contentIcon.css +48 -0
  44. package/src/modules/arch/contentIcon/contentIcon.html +15 -0
  45. package/src/modules/arch/contentIcon/contentIcon.stories.js +130 -0
  46. package/src/modules/arch/contentIcon/contentIcon.ts +68 -0
  47. package/src/{common → modules/arch}/context/context.ts +21 -19
  48. package/src/modules/arch/contextAdapter/constants.ts +1 -0
  49. package/src/modules/arch/contextAdapter/contextAdapter.ts +54 -0
  50. package/src/modules/arch/debounce/debounce.ts +32 -0
  51. package/src/modules/arch/dialog/dialog.ts +154 -0
  52. package/src/modules/arch/dialogStyles/dialogStyles.css +90 -0
  53. package/src/modules/arch/effectAdapter/effectAdapter.html +1 -0
  54. package/src/modules/arch/effectAdapter/effectAdapter.ts +28 -0
  55. package/src/modules/arch/explorer/explorer.css +301 -0
  56. package/src/modules/arch/explorer/explorer.html +418 -0
  57. package/src/modules/arch/explorer/explorer.ts +718 -0
  58. package/src/modules/arch/explorer/types.d.ts +60 -0
  59. package/src/modules/arch/fetch/fetch.ts +55 -0
  60. package/src/modules/arch/footerMfe/footerMfe.html +3 -0
  61. package/src/modules/arch/footerMfe/footerMfe.ts +19 -0
  62. package/src/modules/arch/gallery/gallery.css +365 -0
  63. package/src/modules/arch/gallery/gallery.html +71 -0
  64. package/src/modules/arch/gallery/gallery.ts +366 -0
  65. package/src/modules/arch/gallery/types.d.ts +35 -0
  66. package/src/modules/arch/heading/heading.css +1 -0
  67. package/src/modules/arch/heading/heading.html +9 -0
  68. package/src/modules/arch/heading/heading.ts +36 -0
  69. package/src/modules/arch/helpers/helpers.ts +141 -0
  70. package/src/modules/arch/heroA/heroA.css +116 -0
  71. package/src/modules/arch/heroA/heroA.html +28 -0
  72. package/src/modules/arch/heroA/heroA.stories.js +60 -0
  73. package/src/modules/arch/heroA/heroA.ts +53 -0
  74. package/src/modules/arch/heroB/heroB.css +79 -0
  75. package/src/modules/arch/heroB/heroB.html +27 -0
  76. package/src/modules/arch/heroB/heroB.stories.js +55 -0
  77. package/src/modules/arch/heroB/heroB.ts +26 -0
  78. package/src/modules/arch/i18n/i18n.ts +78 -0
  79. package/src/modules/arch/icon/icon.css +28 -0
  80. package/src/modules/arch/icon/icon.html +17 -0
  81. package/src/modules/arch/icon/icon.stories.js +26 -0
  82. package/src/modules/arch/icon/icon.ts +92 -0
  83. package/src/modules/arch/instrumentation/instrumentation.css +1 -0
  84. package/src/modules/arch/instrumentation/instrumentation.html +1 -0
  85. package/src/modules/arch/instrumentation/instrumentation.ts +113 -0
  86. package/src/modules/arch/labels/helpers.ts +25 -0
  87. package/src/modules/arch/labels/pointHelpers.ts +47 -0
  88. package/src/modules/arch/labels/timeHelpers.ts +182 -0
  89. package/src/modules/arch/labels/types.d.ts +5 -0
  90. package/src/modules/arch/logger/logger.ts +33 -0
  91. package/src/modules/arch/menu/menu.ts +260 -0
  92. package/src/modules/arch/overflow/overflow.ts +71 -0
  93. package/src/modules/arch/page/page.css +3 -0
  94. package/src/modules/arch/page/page.html +3 -0
  95. package/src/modules/arch/page/page.stories.js +19 -0
  96. package/src/modules/arch/page/page.ts +3 -0
  97. package/src/modules/arch/pageHeaderA/pageHeaderA.css +82 -0
  98. package/src/modules/arch/pageHeaderA/pageHeaderA.html +24 -0
  99. package/src/modules/arch/pageHeaderA/pageHeaderA.stories.js +25 -0
  100. package/src/modules/arch/pageHeaderA/pageHeaderA.ts +51 -0
  101. package/src/modules/arch/pill/pill.css +70 -0
  102. package/src/modules/arch/pill/pill.html +17 -0
  103. package/src/modules/arch/pill/pill.ts +34 -0
  104. package/src/modules/arch/polling-request.ts +97 -0
  105. package/src/modules/arch/reflectedElement/reflectedElement.html +2 -0
  106. package/src/{common → modules/arch}/reflectedElement/reflectedElement.ts +5 -3
  107. package/src/modules/arch/reset/reset.css +39 -0
  108. package/src/modules/arch/searchList/searchList.css +120 -0
  109. package/src/modules/arch/searchList/searchList.html +42 -0
  110. package/src/modules/arch/searchList/searchList.ts +53 -0
  111. package/src/modules/arch/sectionA/sectionA.css +64 -0
  112. package/src/modules/arch/sectionA/sectionA.html +21 -0
  113. package/src/modules/arch/sectionA/sectionA.stories.js +25 -0
  114. package/src/modules/arch/sectionA/sectionA.ts +27 -0
  115. package/src/modules/arch/select/select.css +40 -0
  116. package/src/modules/arch/select/select.html +24 -0
  117. package/src/modules/arch/select/select.ts +64 -0
  118. package/src/modules/arch/socialShare/socialShare.css +50 -0
  119. package/src/modules/arch/socialShare/socialShare.html +56 -0
  120. package/src/modules/arch/socialShare/socialShare.ts +29 -0
  121. package/src/modules/arch/spinner/spinner.css +195 -0
  122. package/src/modules/arch/spinner/spinner.html +9 -0
  123. package/src/modules/arch/spinner/spinner.ts +15 -0
  124. package/src/modules/arch/styles/styles.css +24 -0
  125. package/src/modules/arch/summary/summary.css +134 -0
  126. package/src/modules/arch/summary/summary.html +71 -0
  127. package/src/modules/arch/summary/summary.stories.js +163 -0
  128. package/src/modules/arch/summary/summary.ts +96 -0
  129. package/src/modules/arch/tab/tab.css +3 -0
  130. package/src/modules/arch/tab/tab.html +5 -0
  131. package/src/modules/arch/tab/tab.ts +46 -0
  132. package/src/modules/arch/tabset/tabset.css +112 -0
  133. package/src/modules/arch/tabset/tabset.html +62 -0
  134. package/src/modules/arch/tabset/tabset.ts +244 -0
  135. package/src/modules/arch/testutils.ts +118 -0
  136. package/src/modules/arch/threeCardGrid/threeCardGrid.css +6 -0
  137. package/src/modules/arch/threeCardGrid/threeCardGrid.html +5 -0
  138. package/src/modules/arch/threeCardGrid/threeCardGrid.ts +3 -0
  139. package/src/modules/arch/track/track.ts +23 -0
  140. package/src/modules/arch/trailhead.ts +120 -0
  141. package/src/modules/arch/types.d.ts +1 -0
  142. package/src/modules/arch/useEffectAttr.ts +16 -0
  143. package/src/modules/arch/utils/utils.ts +20 -0
  144. package/src/modules/arch/withState.ts +21 -0
  145. package/src/modules/arch/xsfMfeEvents/xsfMfeEvents.html +1 -0
  146. package/src/modules/arch/xsfMfeEvents/xsfMfeEvents.ts +47 -0
  147. package/src/common/effectAdapter/__tests__/effectAdapter.test.ts +0 -12
  148. package/src/common/effectAdapter/effectAdapter.ts +0 -18
  149. package/src/common/reflectedElement/__tests__/modules/test/select/select.html +0 -3
  150. package/src/common/reflectedElement/__tests__/modules/test/select/select.ts +0 -7
  151. package/src/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.html +0 -3
  152. package/src/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.ts +0 -18
  153. package/src/common/reflectedElement/__tests__/reflectedElement.test.ts +0 -75
  154. package/src/common/slot/__tests__/slot.test.ts +0 -96
  155. package/src/common/slot/slot.ts +0 -20
  156. /package/src/{common → modules/arch}/context/context.html +0 -0
  157. /package/src/{common/effectAdapter/effectAdapter.html → modules/arch/contextAdapter/contextAdapter.html} +0 -0
@@ -0,0 +1,82 @@
1
+ @import 'arch/reset';
2
+
3
+ .root {
4
+ align-items: center;
5
+ display: flex;
6
+ justify-content: space-between;
7
+ padding: var(--arch-spacing-12) 0;
8
+ padding-left: 1rem;
9
+ }
10
+
11
+ @media screen and (max-width: 800px) {
12
+ .root {
13
+ padding-top: 1.25rem;
14
+ display: block;
15
+ }
16
+ }
17
+
18
+ .pretitle {
19
+ color: var(--arch-colors-meteorite);
20
+ }
21
+
22
+ h1 {
23
+ font-size: var(--arch-font-size-4xl);
24
+ margin: 0;
25
+ padding: 0;
26
+ }
27
+
28
+ .actions {
29
+ align-items: center;
30
+ display: grid;
31
+ grid-auto-flow: column;
32
+ grid-column-gap: var(--arch-spacing-2);
33
+ }
34
+
35
+ @media screen and (max-width: 800px) {
36
+ .root,
37
+ .actions {
38
+ padding-top: 1.25rem;
39
+ }
40
+
41
+ .actions {
42
+ width: 120px;
43
+ }
44
+ }
45
+
46
+ .actions a,
47
+ .actions a:visited {
48
+ padding-right: 1rem;
49
+ color: var(--arch-color-black);
50
+ text-decoration: none;
51
+ }
52
+
53
+ .actions a:hover {
54
+ color: var(--arch-color-brand);
55
+ }
56
+
57
+ .actions img {
58
+ width: 18px;
59
+ margin-right: 1rem;
60
+ }
61
+
62
+ .actions svg {
63
+ height: 1rem;
64
+ }
65
+
66
+ .actions svg.fill {
67
+ fill: var(--arch-color-meteorite);
68
+ }
69
+
70
+ .actions svg.fill:hover {
71
+ fill: var(--arch-color-brand);
72
+ }
73
+
74
+ .actions svg.stroke {
75
+ stroke: var(--arch-color-meteorite);
76
+ fill: var(--arch-color-meteorite);
77
+ }
78
+
79
+ .actions svg.stroke:hover {
80
+ stroke: var(--arch-color-brand);
81
+ fill: var(--arch-color-brand);
82
+ }
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <div class="root">
3
+ <div class="heading">
4
+ <span class="pretitle" if:true={pretitle}>{pretitle}</span>
5
+ <h1>{title}</h1>
6
+ </div>
7
+ <div class="actions">
8
+ <!--
9
+ <template if:false={isJpTranslationBlank}>
10
+ <a
11
+ href={jptranslation}
12
+ class="jp-translation"
13
+ target="_blank"
14
+ rel="noopener noreferrer"
15
+ aria-label="日本語版はここからダウンロード"
16
+ >
17
+ <img src="https://a.sfdcstatic.com/developer-website/images/architect/icons/globe.png" />
18
+ 日本語版はここからダウンロード</a>
19
+ </template>
20
+ -->
21
+ <arch-social-share title={title} url={location}></arch-social-share>
22
+ </div>
23
+ </div>
24
+ </template>
@@ -0,0 +1,25 @@
1
+ import { html } from "lit-html";
2
+
3
+ export default {
4
+ title: "arch/arch-page-header-a",
5
+ component: "sb-arch-page-header-a"
6
+ };
7
+
8
+ // prettier-ignore
9
+ const createStyles = () => html `
10
+ <style>
11
+ sb-arch-page-header-a {
12
+ display: block;
13
+ }
14
+ </style>`;
15
+
16
+ // prettier-ignore
17
+ export const Base = () => html` ${createStyles()}
18
+ <sb-arch-page-header-a
19
+ pretitle="Reference Architecture"
20
+ title="Content Lifecycle Management and Modeling"
21
+ >
22
+ <sb-arch-cta title="Download" variant="brand"></sb-arch-cta>
23
+ <sb-arch-cta title="Share"></sb-arch-cta>
24
+ </sb-arch-page-header-a>
25
+ `;
@@ -0,0 +1,51 @@
1
+ import { api } from 'lwc';
2
+ import { ChildrenElement } from 'arch/children';
3
+
4
+ export type CTA = {
5
+ href: string;
6
+ target?: string;
7
+ title: string;
8
+ variant: string;
9
+ };
10
+
11
+ export default class extends ChildrenElement<CTA> {
12
+ @api pretitle: string | null = null;
13
+ @api title: string = '';
14
+ @api url: string = '';
15
+ @api jptranslation: string | null = null;
16
+
17
+ childTagName = 'arch-CTA';
18
+
19
+ location: string=window.location.href;
20
+
21
+ extractor = (element: Element) => {
22
+ return {
23
+ href: element.getAttribute('href')!,
24
+ target: element.getAttribute('target') || undefined,
25
+ title: element.getAttribute('title')!,
26
+ variant: element.getAttribute('variant') || 'neutral'
27
+ };
28
+ };
29
+
30
+ private get shareTwitter() {
31
+ return decodeURI(
32
+ `https://twitter.com/intent/tweet/?text=${this.title}&url=${window.location.href}&via=SalesforceArchs`
33
+ );
34
+ }
35
+
36
+ private get shareLinkedIn() {
37
+ return `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURI(
38
+ window.location.href
39
+ )}`;
40
+ }
41
+
42
+ private get shareFacebook() {
43
+ return `https://www.facebook.com/sharer/sharer.php?u=${encodeURI(
44
+ window.location.href
45
+ )}`;
46
+ }
47
+
48
+ get isJpTranslationBlank() {
49
+ return !this.jptranslation || this.jptranslation.trim() === '';
50
+ }
51
+ }
@@ -0,0 +1,70 @@
1
+ @import "arch/reset";
2
+
3
+ :host {
4
+ display: inline-flex;
5
+ max-width: 100%;
6
+ }
7
+
8
+ .pill {
9
+ display: flex;
10
+ align-items: center;
11
+ position: relative;
12
+ color: var(--arch-color-meteorite);
13
+ border: 1px solid var(--arch-color-granite);
14
+ border-radius: var(--arch-radius-md);
15
+ padding-left: var(--arch-spacing-3);
16
+ padding-right: var(--arch-spacing-8);
17
+ height: var(--arch-spacing-10);
18
+ max-width: 100%;
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ .pill:not(.pill-bare):hover {
23
+ background-color: var(--arch-color-sand);
24
+ }
25
+
26
+ .pill-link {
27
+ cursor: pointer;
28
+ color: var(--arch-color-brand);
29
+ }
30
+
31
+ .pill-bare {
32
+ border-color: transparent;
33
+ }
34
+
35
+ .pill-label {
36
+ font-size: var(--arch-font-size-sm);
37
+ white-space: nowrap;
38
+ overflow: hidden;
39
+ text-overflow: ellipsis;
40
+ }
41
+
42
+ .pill-remove {
43
+ color: var(--arch-color-meteorite);
44
+ border: none;
45
+ background-color: transparent;
46
+ padding: 2px;
47
+ cursor: pointer;
48
+ position: absolute;
49
+ right: var(--arch-spacing-2);
50
+ top: 50%;
51
+ transform: translateY(-50%);
52
+ }
53
+
54
+ .pill-remove:hover,
55
+ .pill-remove:focus {
56
+ color: var(--arch-color-black);
57
+ }
58
+
59
+ .assistive-text {
60
+ position: absolute !important;
61
+ margin: -1px !important;
62
+ border: 0 !important;
63
+ padding: 0 !important;
64
+ width: 1px !important;
65
+ height: 1px !important;
66
+ overflow: hidden !important;
67
+ clip: rect(0 0 0 0) !important;
68
+ text-transform: none !important;
69
+ white-space: nowrap !important;
70
+ }
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div class={className} role="option" aria-selected="true">
3
+ <div class="pill-label" title={titleWithFallback}>
4
+ <slot onslotchange={setTitle}></slot>
5
+ </div>
6
+
7
+ <button
8
+ class="pill-remove"
9
+ title={removeButtonTitle}
10
+ onclick={handleRemove}
11
+ >
12
+ <arch-icon symbol="close" size="x-small"></arch-icon>
13
+
14
+ <div class="assistive-text">{removeButtonTitle}</div>
15
+ </button>
16
+ </div>
17
+ </template>
@@ -0,0 +1,34 @@
1
+ import { LightningElement, api } from 'lwc';
2
+
3
+ export default class extends LightningElement {
4
+ @api label: string = '';
5
+ @api removeButtonTitle: string = 'Remove';
6
+ @api variant: 'link' | 'bare' | null = null;
7
+
8
+ private titleWithFallback: string | null = null;
9
+
10
+ private get className() {
11
+ return ['pill', this.variant ? `pill--${this.variant}` : false]
12
+ .filter(Boolean)
13
+ .join(' ');
14
+ }
15
+
16
+ // Use slot node text as a title if the title attribute isn't provided
17
+ private setTitle() {
18
+ const slot = this.template.querySelector('slot') as HTMLSlotElement;
19
+
20
+ this.titleWithFallback =
21
+ this.title ||
22
+ (slot
23
+ ? slot
24
+ .assignedNodes()
25
+ .map((n) => n.textContent)
26
+ .join('')
27
+ : '');
28
+ }
29
+
30
+ private handleRemove(e: MouseEvent) {
31
+ e.stopPropagation();
32
+ this.dispatchEvent(new CustomEvent('remove'));
33
+ }
34
+ }
@@ -0,0 +1,97 @@
1
+ const DEFAULT_INTERVAL = 3000;
2
+ const DEFAULT_RETRIES = 10;
3
+
4
+ export type PollingRequestInit<T> = {
5
+ request: () => Promise<T>;
6
+ done?: (res: T) => boolean;
7
+ interval?: number;
8
+ retries?: number;
9
+ };
10
+
11
+ /**
12
+ * Creates a Promise-like polling request
13
+ * @class PollingRequest
14
+ * @example
15
+ * const res = await new PollingRequest({ ... });
16
+ */
17
+ export class PollingRequest<T> {
18
+ // Internals
19
+ private resolve: (value?: T) => void = () => {};
20
+ private reject: (reason?: any) => void = () => {};
21
+ private readonly promise: Promise<T>;
22
+ private timer: ReturnType<typeof setTimeout> | null = null;
23
+ private attempt: number = 0;
24
+
25
+ // Arguments
26
+ private request: () => Promise<T>;
27
+ private done: (res: T) => boolean;
28
+ private interval: number;
29
+ private retries: number;
30
+
31
+ constructor({ request, done, interval, retries }: PollingRequestInit<T>) {
32
+ this.promise = new Promise<T>((resolve, reject) => {
33
+ this.resolve = resolve;
34
+ this.reject = reject;
35
+ });
36
+
37
+ this.request = request;
38
+ this.done = done || (() => true);
39
+ this.interval = interval || DEFAULT_INTERVAL;
40
+ this.retries = retries || DEFAULT_RETRIES;
41
+
42
+ this.start();
43
+ }
44
+
45
+ async then(
46
+ onfulfilled?: (value: T) => T | PromiseLike<T>,
47
+ onrejected?: (reason: any) => PromiseLike<never>
48
+ ): Promise<T> {
49
+ return this.promise.then(onfulfilled, onrejected);
50
+ }
51
+
52
+ async catch(onRejected?: (reason: any) => PromiseLike<never>): Promise<T> {
53
+ return this.promise.catch(onRejected);
54
+ }
55
+
56
+ private start() {
57
+ this.poll();
58
+ }
59
+
60
+ private stop() {
61
+ if (this.timer) {
62
+ clearTimeout(this.timer);
63
+ }
64
+
65
+ this.retries = 0;
66
+ this.attempt = 0;
67
+ this.timer = null;
68
+ }
69
+
70
+ private async poll() {
71
+ const currentAttempt = (this.attempt = this.attempt + 1);
72
+
73
+ try {
74
+ const res = await this.request();
75
+
76
+ // If polling was stopped before the request could complete
77
+ if (currentAttempt !== this.attempt) {return;}
78
+
79
+ if (this.done(res)) {
80
+ this.stop();
81
+ this.resolve(res);
82
+ }
83
+
84
+ if (this.attempt < this.retries) {
85
+ this.timer = setTimeout(this.poll.bind(this), this.interval);
86
+ } else {
87
+ throw new Error('timeout');
88
+ }
89
+ } catch (err) {
90
+ // If polling was stopped before the request could complete
91
+ if (currentAttempt !== this.attempt) {return;}
92
+
93
+ this.stop();
94
+ this.reject(err);
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,2 @@
1
+ <template></template>
2
+
@@ -4,18 +4,18 @@
4
4
  * to the innerHTML of the element (Shadow DOM) returned by
5
5
  * contentElement() (which must use the lwc:dom="manual" directive).
6
6
  */
7
- import { LightningElement } from 'lwc';
7
+ import { LightningElement } from "lwc";
8
8
 
9
9
  export class ReflectedElement extends LightningElement {
10
10
  private observer!: MutationObserver;
11
11
  private didSetContent = false;
12
12
 
13
13
  get contentElement(): Element {
14
- throw new Error('Not Implemented');
14
+ throw new Error("Not Implemented");
15
15
  }
16
16
 
17
17
  connectedCallback() {
18
- this.observer = new MutationObserver((e) => {
18
+ this.observer = new MutationObserver(() => {
19
19
  this.setContent();
20
20
  });
21
21
  this.observer.observe(this.template.host, {
@@ -48,3 +48,5 @@ export class ReflectedElement extends LightningElement {
48
48
  this.innerHTMLSetCallback();
49
49
  }
50
50
  }
51
+
52
+ export default ReflectedElement;
@@ -0,0 +1,39 @@
1
+ :host {
2
+ display: block;
3
+ line-height: normal;
4
+ }
5
+
6
+ * {
7
+ box-sizing: border-box;
8
+ font-family: inherit;
9
+ margin: 0;
10
+ padding: 0;
11
+ }
12
+
13
+ ul {
14
+ list-style: none;
15
+ }
16
+
17
+ h1,
18
+ h2,
19
+ h3,
20
+ h4,
21
+ h5 {
22
+ font-size: inherit;
23
+ }
24
+
25
+ [tabindex]:not([tabindex='-1']),
26
+ a,
27
+ button,
28
+ input,
29
+ select,
30
+ textarea {
31
+ outline: 2px solid transparent;
32
+ outline-offset: 5px;
33
+ transition: outline-offset var(--arch-duration-short) linear;
34
+ }
35
+
36
+ *:not(:disabled):focus {
37
+ outline-color: var(--arch-color-brand);
38
+ outline-offset: 2px;
39
+ }
@@ -0,0 +1,120 @@
1
+ @import "arch/reset";
2
+
3
+ :host {
4
+ font-size: var(--arch-font-size-md);
5
+ position: relative;
6
+ width: 100%;
7
+ z-index: 10;
8
+ }
9
+
10
+ .search-input-wrapper {
11
+ align-items: stretch;
12
+ display: flex;
13
+ position: relative;
14
+ }
15
+
16
+ .search-input-label {
17
+ position: absolute !important;
18
+ height: 1px;
19
+ width: 1px;
20
+ overflow: hidden;
21
+ clip: rect(1px, 1px, 1px, 1px);
22
+ white-space: nowrap;
23
+ }
24
+
25
+ .search-input-input {
26
+ border-radius: var(--arch-radius-md);
27
+ border: 1px solid var(--arch-color-fog);
28
+ color: var(--arch-color-black);
29
+ flex: 1;
30
+ font-family: inherit;
31
+ font-size: var(--arch-font-size-md);
32
+ line-height: 1.875;
33
+ overflow: hidden;
34
+ padding: 0.4rem 0;
35
+ padding-left: var(--arch-spacing-8);
36
+ position: relative;
37
+ text-overflow: ellipsis;
38
+ transition: border 0.1s linear, background-color 0.1s linear;
39
+ white-space: nowrap;
40
+ }
41
+
42
+ .search-input-icon {
43
+ color: var(--arch-color-granite);
44
+ left: 10px;
45
+ position: absolute;
46
+ top: 13px;
47
+ z-index: 1;
48
+ }
49
+
50
+ .search-results {
51
+ background-color: white;
52
+ border-radius: var(--arch-radius-lg);
53
+ box-shadow: var(--arch-shadow-lg);
54
+ left: 0;
55
+ position: absolute;
56
+ top: 100%;
57
+ width: 100%;
58
+ padding: var(--arch-spacing-6);
59
+ box-sizing: border-box;
60
+ margin-top: var(--arch-spacing-1);
61
+ }
62
+
63
+ .search-result:hover,
64
+ .search-result[aria-selected="true"] {
65
+ background-color: var(--arch-color-sand);
66
+ cursor: pointer;
67
+ border-radius: var(--arch-radius-lg);
68
+ }
69
+
70
+ .search-result,
71
+ .search-result-heading {
72
+ color: var(--arch-color-black);
73
+ font-size: var(--arch-font-size-sm);
74
+ line-height: var(--arch-line-height-snug);
75
+ padding-left: var(--arch-spacing-2);
76
+ padding-right: var(--arch-spacing-2);
77
+ }
78
+
79
+ .search-result-heading {
80
+ font-weight: bold;
81
+ margin: var(--arch-spacing-5) 0 var(--arch-spacing-1) 0;
82
+ }
83
+
84
+ .search-result-group:first-child .search-result-heading {
85
+ font-weight: bold;
86
+ margin: 0 0 var(--arch-spacing-1) 0;
87
+ }
88
+
89
+ .search-result {
90
+ align-items: center;
91
+ display: flex;
92
+ padding: var(--arch-spacing-2);
93
+ }
94
+
95
+ .search-result-icon {
96
+ color: #b0adab; /* TODO: token */
97
+ margin-right: var(--arch-spacing-2);
98
+ }
99
+
100
+ .search-result-image {
101
+ border-radius: var(--arch-radius-lg);
102
+ margin-right: var(--arch-spacing-2);
103
+ max-width: 40px;
104
+ }
105
+
106
+ .search-result-pretitle {
107
+ color: var(--arch-color-meteorite);
108
+ font-size: var(--arch-font-size-sm);
109
+ line-height: var(--arch-line-height-snug);
110
+ }
111
+
112
+ .search-result-title {
113
+ color: var(--arch-color-black);
114
+ font-size: var(--arch-font-size-md);
115
+ font-weight: bold;
116
+ }
117
+
118
+ [data-listbox="options"][aria-hidden="true"] {
119
+ display: none;
120
+ }
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <arch-section-a background="white" title={titleSearchResults}>
3
+ <template if:true={results}>
4
+ <template for:each={results} for:item="result">
5
+ <div key={result.title}>
6
+ <arch-summary
7
+ description={result.description}
8
+ compact
9
+ display-mode="brick-tile"
10
+ path={result.url}
11
+ title={result.title}
12
+ >
13
+ <dx-icon-badge sprite="brand" symbol="knowledge_base" background-color="blue-vibrant-20" size="small"></dx-icon-badge>
14
+
15
+ <div slot="pretitle"></div>
16
+ <span slot="meta-right"></span>
17
+ <span slot="meta-left">{result.description}</span>
18
+ </arch-summary>
19
+ <!-- prettier-ignore -->
20
+ <hr>
21
+ </div>
22
+ </template>
23
+ </template>
24
+ <template if:true={showSearchSuggestions}>
25
+ <div style="display: block">
26
+ <center>
27
+ <img
28
+ src="https://a.sfdcstatic.com/developer-website/images/architect/ruth_search.png"
29
+ alt="Search tips illustration"
30
+ />
31
+ <h4 style="padding-top: 8px">Here are some search tips</h4>
32
+ <span style="display: block">
33
+ Check the spelling of your keywords.
34
+ </span>
35
+ <span style="display: block">
36
+ Try using fewer, different, or more general words.
37
+ </span>
38
+ </center>
39
+ </div>
40
+ </template>
41
+ </arch-section-a>
42
+ </template>
@@ -0,0 +1,53 @@
1
+ import { LightningElement, api, track } from "lwc";
2
+
3
+ export default class SearchList extends LightningElement {
4
+ queryString?: string = "";
5
+ titleSearchResults: string = "";
6
+ showSearchSuggestions = false;
7
+
8
+ @api algoliaIndex: string = "";
9
+ @api algoliaAppId: string = "";
10
+ @api algoliaApiKey: string = "";
11
+
12
+ @track results: any;
13
+
14
+ connectedCallback() {
15
+ const params = new URLSearchParams(window.location.search);
16
+ if (params && params.get("keywords")) {
17
+ const keywords = params.get("keywords") || "";
18
+ fetch(
19
+ `https://${this.algoliaAppId}-dsn.algolia.net/1/indexes/${this.algoliaIndex}?query=${keywords}&hitsPerPage=20`,
20
+ {
21
+ headers: {
22
+ "X-Algolia-Application-Id": this.algoliaAppId,
23
+ "X-Algolia-API-Key": this.algoliaApiKey
24
+ }
25
+ }
26
+ )
27
+ .then((result) => {
28
+ return result.json();
29
+ })
30
+ .then((json) => {
31
+ if (json.hits && json.hits.length) {
32
+ this.titleSearchResults = `Search results for "${decodeURIComponent(
33
+ keywords
34
+ )}"`;
35
+ this.results = json.hits;
36
+ this.showSearchSuggestions = false;
37
+ } else {
38
+ this.titleSearchResults = `No results for "${decodeURIComponent(
39
+ keywords
40
+ )}"`;
41
+ this.showSearchSuggestions = true;
42
+ }
43
+ })
44
+ .catch(() => {
45
+ this.titleSearchResults = `An error occured`;
46
+ this.showSearchSuggestions = false;
47
+ });
48
+ } else {
49
+ this.titleSearchResults = "No keywords provided";
50
+ this.showSearchSuggestions = false;
51
+ }
52
+ }
53
+ }