@salesforcedevs/dw-components 0.53.5-alpha → 0.54.0-alpha01

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 (34) hide show
  1. package/lwc.config.json +10 -1
  2. package/package.json +8 -2
  3. package/src/modules/base-elements/postsGrid/postsGrid.ts +76 -0
  4. package/src/modules/dw/blogsGrid/blogsGrid.css +80 -0
  5. package/src/modules/dw/blogsGrid/blogsGrid.html +57 -0
  6. package/src/modules/dw/blogsGrid/blogsGrid.ts +27 -0
  7. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +171 -0
  8. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +133 -0
  9. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +429 -0
  10. package/src/modules/dw/deSignupForm/deSignupForm.css +70 -0
  11. package/src/modules/dw/deSignupForm/deSignupForm.html +99 -0
  12. package/src/modules/dw/deSignupForm/deSignupForm.ts +268 -0
  13. package/src/modules/dw/deSignupForm/submitForm.ts +90 -0
  14. package/src/modules/dw/docsGrid/docsGrid.css +86 -0
  15. package/src/modules/dw/docsGrid/docsGrid.html +84 -0
  16. package/src/modules/dw/docsGrid/docsGrid.ts +522 -0
  17. package/src/modules/dw/eventsList/eventsList.css +109 -0
  18. package/src/modules/dw/eventsList/eventsList.html +91 -0
  19. package/src/modules/dw/eventsList/eventsList.ts +180 -0
  20. package/src/modules/dw/podcastsGrid/podcastsGrid.css +5 -0
  21. package/src/modules/dw/podcastsGrid/podcastsGrid.html +29 -0
  22. package/src/modules/dw/podcastsGrid/podcastsGrid.ts +9 -0
  23. package/src/modules/dw/podcastsPromo/podcastsPromo.css +32 -0
  24. package/src/modules/dw/podcastsPromo/podcastsPromo.html +30 -0
  25. package/src/modules/dw/podcastsPromo/podcastsPromo.ts +3 -0
  26. package/src/modules/dw/rcgTable/altData.ts +78 -0
  27. package/src/modules/dw/rcgTable/getTableData.ts +10 -0
  28. package/src/modules/dw/rcgTable/rcgTable.css +39 -0
  29. package/src/modules/dw/rcgTable/rcgTable.html +31 -0
  30. package/src/modules/dw/rcgTable/rcgTable.ts +34 -0
  31. package/src/modules/dw/slackSuccess/slackSuccess.css +65 -0
  32. package/src/modules/dw/slackSuccess/slackSuccess.html +32 -0
  33. package/src/modules/dw/slackSuccess/slackSuccess.ts +32 -0
  34. package/src/modules/helpers/postsGrid/postsGrid.css +9 -0
@@ -0,0 +1,268 @@
1
+ import { LightningElement, api, track } from "lwc";
2
+ import { toJson } from "utils/normalizers";
3
+ import { track as trackGtm } from "utils/analytics";
4
+ import {
5
+ submitForm,
6
+ ErrorCode,
7
+ SignupForm,
8
+ UserData,
9
+ OptIn
10
+ } from "./submitForm";
11
+
12
+ type SelectOption = { value: string; label: string };
13
+ type Country = SelectOption & {
14
+ showMarketingField: boolean;
15
+ showLegalCheckbox: boolean;
16
+ checkboxTextSet?: string;
17
+ };
18
+
19
+ type CheckboxSet = {
20
+ marketingText: string;
21
+ legalText: string;
22
+ learnMore?: string;
23
+ };
24
+ type CheckboxTextMap = {
25
+ [key: string]: CheckboxSet;
26
+ };
27
+
28
+ const DEFAULT_DRIVER = "7013000000005wb";
29
+ const DUPLICATE_USERNAME_MESSAGE =
30
+ "You are already using that username in another Salesforce login credential. Your username needs to be unique and in the form of an email address.";
31
+ const ACCEPTED = "accepted";
32
+ const SIGN_UP_LABEL = "Sign me Up";
33
+
34
+ const ANALYTICS_INFO = {
35
+ clickText: "Sign me Up",
36
+ itemTitle: "Dev Edition Sign Up Button",
37
+ formType: "Dev Edition Sign Up",
38
+ formName: "Developer Edition",
39
+ method: "email",
40
+ clickUrl: "/signup/success",
41
+ elementType: "button",
42
+ destinationType: "internal",
43
+ ctaClick: true
44
+ };
45
+ export default class DeSignupForm extends LightningElement {
46
+ @api
47
+ get countries() {
48
+ return this._countries;
49
+ }
50
+
51
+ set countries(value) {
52
+ this._countries = toJson(value);
53
+ }
54
+
55
+ @api
56
+ get roles() {
57
+ return this._roles;
58
+ }
59
+
60
+ set roles(value) {
61
+ this._roles = toJson(value);
62
+ }
63
+
64
+ @api
65
+ get checkboxTextMap() {
66
+ return this._checkboxTextMap;
67
+ }
68
+
69
+ set checkboxTextMap(value) {
70
+ this._checkboxTextMap = toJson(value);
71
+ }
72
+
73
+ private country: Country = null;
74
+ private disableSubmit = false;
75
+ private username = "";
76
+ private updateCheckboxLabels = true;
77
+ private _checkboxTextMap: CheckboxTextMap = null;
78
+ private _countries: Array<Country>;
79
+ private _roles: Array<SelectOption>;
80
+ @track knownDuplicateUsers = [];
81
+
82
+ get usernameError(): string {
83
+ return this.knownDuplicateUsers.includes(this.username)
84
+ ? DUPLICATE_USERNAME_MESSAGE
85
+ : "";
86
+ }
87
+
88
+ get checkUsernameValidity(): boolean {
89
+ return !this.knownDuplicateUsers.includes(this.username);
90
+ }
91
+
92
+ get showMarketingField(): boolean {
93
+ return this.country && this.country.showMarketingField;
94
+ }
95
+
96
+ get marketingText(): string {
97
+ return (
98
+ this.checkboxSetByCountry && this.checkboxSetByCountry.marketingText
99
+ );
100
+ }
101
+
102
+ get showLegalCheckbox(): boolean {
103
+ return this.country && this.country.showLegalCheckbox;
104
+ }
105
+
106
+ get legalText(): string {
107
+ return this.checkboxSetByCountry && this.checkboxSetByCountry.legalText;
108
+ }
109
+
110
+ get learnMore(): string | undefined {
111
+ return this.checkboxSetByCountry && this.checkboxSetByCountry.learnMore;
112
+ }
113
+
114
+ get checkboxSetByCountry(): CheckboxSet {
115
+ return (
116
+ (this.country &&
117
+ this.country.checkboxTextSet &&
118
+ this.checkboxTextMap[this.country.checkboxTextSet]) ||
119
+ this.checkboxTextMap.default
120
+ );
121
+ }
122
+
123
+ get buttonLabel(): string {
124
+ return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
125
+ }
126
+
127
+ renderedCallback(): void {
128
+ if (!this.updateCheckboxLabels) {
129
+ return;
130
+ }
131
+
132
+ this.updateCheckboxLabels =
133
+ this.updateInnerHtml("span.legal-terms", this.legalText) ||
134
+ this.updateInnerHtml(
135
+ "span.marketing-terms",
136
+ this.marketingText,
137
+ this.showMarketingField
138
+ ) ||
139
+ this.updateInnerHtml(
140
+ "span.learn-more",
141
+ this.learnMore,
142
+ !!this.learnMore
143
+ );
144
+ }
145
+
146
+ handleSubmit(event: Event): void {
147
+ event.preventDefault();
148
+
149
+ if (
150
+ this.disableSubmit ||
151
+ this.knownDuplicateUsers.includes(this.username)
152
+ ) {
153
+ return;
154
+ }
155
+
156
+ const formData = this.prepareUserData();
157
+ if (!formData) {
158
+ return;
159
+ }
160
+
161
+ this.disableSubmit = true;
162
+ submitForm(formData)
163
+ .then(() => {
164
+ trackGtm(event.target!, "custEv_signUp", {
165
+ ...ANALYTICS_INFO,
166
+ formId: formData.user.username
167
+ });
168
+ window.location.href = ANALYTICS_INFO.clickUrl;
169
+ })
170
+ .catch((error) => {
171
+ if (error.message === ErrorCode.DUPLICATE) {
172
+ this.knownDuplicateUsers.push(formData.user.username);
173
+ return;
174
+ }
175
+
176
+ console.log("Oops, something went wrong", error.message);
177
+ })
178
+ .finally(() => (this.disableSubmit = false));
179
+ }
180
+
181
+ handleKeyDown(e: KeyboardEvent): void {
182
+ if (e.key === "Enter") {
183
+ this.handleSubmit(e);
184
+ }
185
+ }
186
+
187
+ handleUsernameChange(event: CustomEvent<string>): void {
188
+ this.username = event.detail;
189
+ }
190
+
191
+ handleCountryChange(event: CustomEvent<{ value: string }>): void {
192
+ this.country = this.countries.find(
193
+ ({ value }) => value === event.detail.value
194
+ );
195
+ this.updateCheckboxLabels = true;
196
+ }
197
+
198
+ private prepareUserData(): SignupForm | null {
199
+ const fields = Array.from(
200
+ this.template.querySelectorAll<HTMLFormElement>(
201
+ "dx-input, dx-select"
202
+ )
203
+ ).map((element) => ({
204
+ valid: element.reportValidity(),
205
+ name: element.name,
206
+ value: element.value
207
+ }));
208
+
209
+ const checkboxes = this.getCheckboxesResult();
210
+
211
+ if (fields.some((field) => !field.valid) || !checkboxes.valid) {
212
+ return null;
213
+ }
214
+
215
+ const userData = {};
216
+ fields.forEach((field) => {
217
+ userData[field.name] = field.value;
218
+ });
219
+
220
+ (userData as UserData).opt_in = this.country.showMarketingField
221
+ ? checkboxes.values.opt_in
222
+ : "implied";
223
+
224
+ const formData: SignupForm = {
225
+ user: userData as UserData,
226
+ eula: this.showLegalCheckbox ? checkboxes.values.eula : ACCEPTED,
227
+ default_driver: DEFAULT_DRIVER
228
+ };
229
+
230
+ return formData;
231
+ }
232
+
233
+ private getCheckboxesResult(): {
234
+ valid: boolean;
235
+ values: { eula: string; opt_in: OptIn };
236
+ } {
237
+ let valid = true;
238
+ const values: { eula: string; opt_in: OptIn } = {
239
+ eula: "",
240
+ opt_in: ""
241
+ };
242
+
243
+ Array.from(
244
+ this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
245
+ ).forEach((checkbox) => {
246
+ valid = valid && checkbox.reportValidity();
247
+ values[checkbox.name] = (checkbox.checked && checkbox.value) || "";
248
+ });
249
+
250
+ return { valid, values };
251
+ }
252
+
253
+ private updateInnerHtml(
254
+ selector: string,
255
+ html: string,
256
+ shouldUpdate = true
257
+ ): boolean {
258
+ let element: HTMLElement;
259
+ if (shouldUpdate) {
260
+ element = this.template.querySelector(selector);
261
+ if (element) {
262
+ element.innerHTML = html;
263
+ }
264
+ }
265
+
266
+ return !element && shouldUpdate;
267
+ }
268
+ }
@@ -0,0 +1,90 @@
1
+ const CREATE_PATH = `/deorgs/trialforce`;
2
+ const BASE_STATUS_PATH = `/deorgs/check_org_status`;
3
+ const WAIT_TIME = 200;
4
+
5
+ export type OptIn = "" | "implied" | "explicit";
6
+
7
+ export type UserData = {
8
+ company: string;
9
+ country: string;
10
+ email: string;
11
+ first_name: string;
12
+ job_role: string;
13
+ last_name: string;
14
+ opt_in: OptIn;
15
+ postal_code: string;
16
+ username: string;
17
+ };
18
+
19
+ export type SignupForm = {
20
+ user: UserData;
21
+ eula: string;
22
+ default_driver: string;
23
+ };
24
+
25
+ type OrgStatus = "New" | "In Progress" | "Error";
26
+
27
+ type OrgStatusResponse = {
28
+ Status: OrgStatus;
29
+ Message: string;
30
+ ErrorCode?: "C-1007" | string;
31
+ };
32
+
33
+ export enum ErrorCode {
34
+ GENERIC = "generic",
35
+ DUPLICATE = "duplicate"
36
+ }
37
+
38
+ const fetchOrgStatus = async (id: string): Promise<OrgStatus> => {
39
+ const response = await fetch(`${BASE_STATUS_PATH}/${id}`);
40
+ if (!response.ok) {
41
+ throw new Error("Something went wrong");
42
+ }
43
+
44
+ const { Status: status, ErrorCode: errorCode }: OrgStatusResponse = await response.json();
45
+
46
+ if (status === "Error") {
47
+ throw new Error(errorCode === "C-1007" ? ErrorCode.DUPLICATE : ErrorCode.GENERIC);
48
+ }
49
+
50
+ return status;
51
+ };
52
+
53
+ const checkOrgStatus = (id: string, retries = 0): Promise<void> => {
54
+ return new Promise<void>((resolve, reject) => {
55
+ if (retries > 5) {
56
+ // it assumes the org will be created
57
+ resolve();
58
+ return;
59
+ }
60
+ setTimeout(() => {
61
+ fetchOrgStatus(id)
62
+ .then((status) => {
63
+ if (status !== "New") {
64
+ resolve();
65
+ return;
66
+ }
67
+
68
+ resolve(checkOrgStatus(id, ++retries));
69
+ })
70
+ .catch(reject);
71
+ }, WAIT_TIME);
72
+ });
73
+ };
74
+
75
+ export const submitForm = async (formData: SignupForm): Promise<void> => {
76
+ const response = await fetch(CREATE_PATH, {
77
+ method: "POST",
78
+ headers: {
79
+ "Content-Type": "application/json"
80
+ },
81
+ body: JSON.stringify(formData)
82
+ });
83
+
84
+ if (!response.ok) {
85
+ throw new Error(ErrorCode.GENERIC);
86
+ }
87
+
88
+ const { Id: trackId } = await response.json();
89
+ await checkOrgStatus(trackId);
90
+ };
@@ -0,0 +1,86 @@
1
+ .docs-action-bar {
2
+ display: flex;
3
+ justify-content: space-between;
4
+ align-items: flex-end;
5
+ padding: var(--dx-g-spacing-md) 0 var(--dx-g-spacing-lg);
6
+ }
7
+
8
+ .docs-action-bar > .records-container {
9
+ margin-right: auto;
10
+ }
11
+
12
+ .docs-action-bar .filters-container {
13
+ display: flex;
14
+ }
15
+
16
+ .filter-checkbox-group,
17
+ .filter-button::part(container) {
18
+ --dx-c-checkbox-text-transform: capitalize;
19
+
20
+ text-transform: var(--dx-c-checkbox-text-transform);
21
+ }
22
+
23
+ .docs-action-bar .filters-container > *:not(:first-child),
24
+ .docs-search-input {
25
+ margin-left: var(--dx-g-spacing-sm);
26
+ }
27
+
28
+ .docs-search-input {
29
+ --dx-c-input-width: 285px;
30
+ }
31
+
32
+ .docs-card {
33
+ --dx-c-body-max-lines: 4;
34
+ --dx-c-heading-max-lines: 2;
35
+ }
36
+
37
+ .pagination-container {
38
+ max-width: fit-content;
39
+ max-width: -moz-fit-content;
40
+ margin: var(--dx-g-spacing-lg) auto;
41
+ }
42
+
43
+ @media screen and (max-width: 1024px) {
44
+ .docs-card {
45
+ --dx-c-body-max-lines: 3;
46
+ }
47
+ }
48
+
49
+ @media screen and (max-width: 768px) {
50
+ .docs-action-bar {
51
+ flex-direction: column-reverse;
52
+ width: 100%;
53
+ padding: 0;
54
+ }
55
+
56
+ .docs-search-input {
57
+ --dx-c-input-width: 100%;
58
+
59
+ width: 100%;
60
+ margin-bottom: var(--dx-g-spacing-md);
61
+ }
62
+
63
+ .docs-action-bar .records-container {
64
+ transform: translateY(-100%);
65
+ }
66
+ }
67
+
68
+ @media screen and (max-width: 600px) {
69
+ .pagination-container {
70
+ width: 100%;
71
+ overflow: hidden;
72
+ }
73
+
74
+ .pagination-container > * {
75
+ position: absolute;
76
+ left: 50%;
77
+ transform: translateX(-50%);
78
+ }
79
+ }
80
+
81
+ @media screen and (max-width: 460px) {
82
+ .docs-action-bar .records-container {
83
+ transform: initial;
84
+ padding: var(--dx-g-spacing-md) 0;
85
+ }
86
+ }
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="docs-grid-container">
3
+ <div class="docs-action-bar">
4
+ <div class="records-container">
5
+ <span if:true={endingRecord}>
6
+ Showing { startingRecord } to { endingRecord } of { filteredDocs.length }
7
+ </span>
8
+ </div>
9
+ <div class="filters-container">
10
+ <dx-popover width="max-content">
11
+ <dx-button
12
+ class="filter-button"
13
+ variant="tertiary"
14
+ icon-symbol="chevrondown"
15
+ slot="control"
16
+ >
17
+ Products
18
+ </dx-button>
19
+ <template if:true={showProductFilters}>
20
+ <dx-checkbox-group
21
+ legend="Products"
22
+ options={productFiltersList}
23
+ slot="content"
24
+ onchange={handleProductFilterChange}
25
+ value={selectedProductFilters}
26
+ class="filter-checkbox-group"
27
+ ></dx-checkbox-group>
28
+ </template>
29
+ </dx-popover>
30
+ </div>
31
+ <dx-input
32
+ size="small"
33
+ placeholder="Search..."
34
+ icon-symbol="search"
35
+ shortcut-key="j"
36
+ class="docs-search-input"
37
+ onchange={handleSearchChange}
38
+ value={searchTerm}
39
+ ></dx-input>
40
+ </div>
41
+ <dx-grid columns={tileColumns} if:false={showEmptyState}>
42
+ <dx-card-docs
43
+ for:each={currentPageDocs}
44
+ for:item="item"
45
+ for:index="i"
46
+ key={item.id}
47
+ title={item.title}
48
+ body={item.description}
49
+ href={item.guidesHref}
50
+ class="docs-card"
51
+ target={item.target}
52
+ >
53
+ <dx-button variant="inline" href={item.guidesHref} if:false={item.links}>
54
+ Read It
55
+ </dx-button>
56
+ <template if:true={item.links}>
57
+ <dx-button
58
+ for:each={item.links}
59
+ for:item="link"
60
+ key={link.id}
61
+ href={link.href}
62
+ variant="inline"
63
+ >
64
+ { link.title }
65
+ </dx-button>
66
+ </template>
67
+ </dx-card-docs>
68
+ </dx-grid>
69
+ <div class="pagination-container" if:false={showEmptyState}>
70
+ <dx-pagination
71
+ current-page={page}
72
+ total-pages={totalPages}
73
+ pages-to-show={pagesToShow}
74
+ onpagechange={goToPage}
75
+ if:false={hidePagination}
76
+ ></dx-pagination>
77
+ </div>
78
+ </div>
79
+ <dx-empty-state
80
+ title="Beep boop. That did not compute."
81
+ subtitle={emptyStateSubtitle}
82
+ if:true={showEmptyState}
83
+ ></dx-empty-state>
84
+ </template>