@salesforcedevs/dx-components 0.10.1-alpha.9 → 0.10.1-alpha.93
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/lwc.config.json +3 -1
- package/package.json +1 -1
- package/src/assets/svg/sidebar-loading.svg +34 -0
- package/src/modules/dx/cardGrid/__tests__/cardMockProps.ts +78 -148
- package/src/modules/dx/codeBlock/codeBlock.stories.ts +2 -69
- package/src/modules/dx/codeBlock/codeBlock.ts +5 -1
- package/src/modules/dx/codeBlock/darkTheme.css +0 -1
- package/src/modules/dx/codeBlock/lightTheme.css +0 -1
- package/src/modules/dx/footer/links.ts +3 -5
- package/src/modules/dx/searchResults/coveo.css +314 -111
- package/src/modules/dx/sidebar/sidebar.css +38 -17
- package/src/modules/dx/sidebar/sidebar.html +61 -58
- package/src/modules/dx/sidebar/sidebar.stories.ts +69 -49
- package/src/modules/dx/sidebar/sidebar.ts +89 -11
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +4310 -86
- package/src/modules/dx/sidebarSearch/utils.ts +2 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +11 -1
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.html +1 -1
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +8 -2
- package/src/modules/dx/spinner/__tests__/spinner.test.ts +37 -0
- package/src/modules/dx/spinner/spinner.css +750 -0
- package/src/modules/dx/spinner/spinner.html +6 -0
- package/src/modules/dx/spinner/spinner.stories.ts +69 -0
- package/src/modules/dx/spinner/spinner.ts +20 -0
- package/src/modules/helpers/table/table.css +23 -7
- package/src/modules/utils/coveo/coveo.ts +3 -0
- package/src/modules/utils/highlight/highlight.ts +31 -0
- package/src/modules/utils/recentSearches/recentSearches.ts +8 -4
- package/src/modules/utils/regexps/regexps.ts +5 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { html } from "lit-html";
|
|
2
|
+
import { SpinnerSize, SpinnerVariant } from "typings/custom";
|
|
3
|
+
|
|
4
|
+
type SpinnerStoryArgs = {
|
|
5
|
+
size: SpinnerSize;
|
|
6
|
+
variant: SpinnerVariant;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const sizeOptions: Array<SpinnerSize> = ["medium", "x-small", "small", "large"];
|
|
10
|
+
const variantOptions: Array<SpinnerVariant> = ["base", "brand", "inverse"];
|
|
11
|
+
const variantToBackgroundColor: { [key: string]: string } = {
|
|
12
|
+
inverse: "black"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: "dx/dx-spinner",
|
|
17
|
+
component: "dx-spinner",
|
|
18
|
+
argTypes: {
|
|
19
|
+
size: {
|
|
20
|
+
control: {
|
|
21
|
+
type: "select",
|
|
22
|
+
options: sizeOptions
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
variant: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "select",
|
|
28
|
+
options: variantOptions
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const style = (variant: SpinnerVariant = "base") => html`
|
|
35
|
+
<style>
|
|
36
|
+
.spinner-wrapper {
|
|
37
|
+
position: relative;
|
|
38
|
+
height: 100vh;
|
|
39
|
+
background-color: ${variantToBackgroundColor[variant] || "white"};
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const [defaultSize] = sizeOptions;
|
|
45
|
+
const [defaultVariant] = variantOptions;
|
|
46
|
+
|
|
47
|
+
const Template = ({ size, variant }: SpinnerStoryArgs) => html`
|
|
48
|
+
${style(variant)}
|
|
49
|
+
<div class="spinner-wrapper">
|
|
50
|
+
<dx-spinner
|
|
51
|
+
size="${size || defaultSize}"
|
|
52
|
+
variant="${variant || defaultVariant}"
|
|
53
|
+
></dx-spinner>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const Base = Template;
|
|
58
|
+
|
|
59
|
+
export const BrandLarge = (args: SpinnerStoryArgs) => Template(args);
|
|
60
|
+
BrandLarge.args = {
|
|
61
|
+
size: "large",
|
|
62
|
+
variant: "brand"
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const InverseSmall = (args: SpinnerStoryArgs) => Template(args);
|
|
66
|
+
InverseSmall.args = {
|
|
67
|
+
size: "small",
|
|
68
|
+
variant: "inverse"
|
|
69
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import type { SpinnerSize, SpinnerVariant } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
export default class Spinner extends LightningElement {
|
|
6
|
+
@api size: SpinnerSize = "medium";
|
|
7
|
+
@api variant: SpinnerVariant = "base";
|
|
8
|
+
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.classList.add("spinner_container");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get containerClass(): string {
|
|
14
|
+
return cx(
|
|
15
|
+
"spinner",
|
|
16
|
+
this.size && `spinner_${this.size}`,
|
|
17
|
+
this.variant && this.variant !== "base" && `spinner_${this.variant}`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
table {
|
|
2
2
|
--table-border-radius: 4px;
|
|
3
|
+
--table-cell-text-base: var(--dx-g-text-sm);
|
|
4
|
+
--table-cell-line-height: var(--dx-g-text-lg);
|
|
3
5
|
|
|
4
6
|
display: block;
|
|
5
7
|
overflow-x: scroll;
|
|
@@ -16,13 +18,13 @@ table tr {
|
|
|
16
18
|
th,
|
|
17
19
|
td {
|
|
18
20
|
padding: var(--dx-g-spacing-md);
|
|
19
|
-
font-size: var(--
|
|
20
|
-
line-height: var(--
|
|
21
|
+
font-size: var(--table-cell-text-base);
|
|
22
|
+
line-height: var(--table-cell-line-height);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
th {
|
|
24
26
|
background-color: var(--dx-g-indigo-vibrant-95);
|
|
25
|
-
font-weight:
|
|
27
|
+
font-weight: var(--dx-g-font-bold);
|
|
26
28
|
border-bottom: 3px solid var(--dx-g-indigo-vibrant-30);
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -40,10 +42,6 @@ table tbody tr td {
|
|
|
40
42
|
border-bottom: 1px solid var(--dx-g-gray-90);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
th:first-of-type {
|
|
44
|
-
font-weight: var(--dx-g-font-bold);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
45
|
tr th:first-of-type,
|
|
48
46
|
td:first-of-type {
|
|
49
47
|
min-width: 110px;
|
|
@@ -85,6 +83,24 @@ tr td[colspan]:not([colspan="1"]) {
|
|
|
85
83
|
text-align: center;
|
|
86
84
|
}
|
|
87
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Inside of a <td>, we want font size not to increase as it otherwise would
|
|
88
|
+
* for standard inline/"prose-level" elements (e.g., <p>, <li>). But we *do*
|
|
89
|
+
* want to leave font size increases in place for *other* elements inside <td>,
|
|
90
|
+
* like callouts, headings (<h1>, <h2>, etc.), and so on. In order not to
|
|
91
|
+
* "stomp" on too much -- and because we don't control the markup, so can't
|
|
92
|
+
* easily add new CSS classes, etc. -- we try to pick out the specific
|
|
93
|
+
* structures only here. (See https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE0000081MGTYA2/view)
|
|
94
|
+
*/
|
|
95
|
+
td :is(.li, p, .p, dd) {
|
|
96
|
+
font-size: var(--table-cell-text-base);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
td doc-content-callout :is(.li, p, .p, dd) {
|
|
100
|
+
/* Override/reset for callouts -- see https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE0000081MGTYA2/view */
|
|
101
|
+
font-size: var(--dx-g-text-base);
|
|
102
|
+
}
|
|
103
|
+
|
|
88
104
|
table :not(thead + tbody) tr:first-of-type td:first-of-type {
|
|
89
105
|
border-top-left-radius: var(--table-border-radius);
|
|
90
106
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createSearchRegExp } from "utils/regexps";
|
|
2
|
+
|
|
3
|
+
const MARK_TAGS = /<\/?mark>/gi;
|
|
4
|
+
|
|
5
|
+
export const highlightTerms = (
|
|
6
|
+
elements: Array<HTMLElement>,
|
|
7
|
+
searchTerm: string
|
|
8
|
+
): void => {
|
|
9
|
+
searchTerm = searchTerm.trim();
|
|
10
|
+
const searchExp = createSearchRegExp(searchTerm);
|
|
11
|
+
elements.forEach((element) => {
|
|
12
|
+
if (
|
|
13
|
+
element?.innerHTML.includes("<dx-") ||
|
|
14
|
+
element?.innerHTML.includes("<doc-")
|
|
15
|
+
) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let innerHtml = element.innerHTML.replace(
|
|
20
|
+
// Remove previously added mark tags
|
|
21
|
+
MARK_TAGS,
|
|
22
|
+
""
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (searchTerm) {
|
|
26
|
+
innerHtml = innerHtml.replace(searchExp, "<mark>$&</mark>");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
element.innerHTML = innerHtml;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -14,11 +14,15 @@ export class RecentSearches {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
add(item: string | undefined) {
|
|
17
|
-
if (!item
|
|
17
|
+
if (!item) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const normalized = item.trim();
|
|
21
|
+
if (normalized === "") {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
this._prepend(normalized);
|
|
25
|
+
this._removeDuplicates(normalized);
|
|
22
26
|
this._cutOffExcess();
|
|
23
27
|
this._addToStorage();
|
|
24
28
|
}
|
|
@@ -51,7 +55,7 @@ export class RecentSearches {
|
|
|
51
55
|
);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
_isDuplicate(searchItem: string) {
|
|
55
59
|
return (
|
|
56
60
|
this.items.filter(
|
|
57
61
|
(item: string) =>
|