@salesforcedevs/docs-components
Advanced tools
Comparing version 1.3.221 to 1.3.227-dh-alpha1
@@ -20,2 +20,3 @@ { | ||
"doc/phase", | ||
"doc/versionPicker", | ||
"doc/xmlContent", | ||
@@ -22,0 +23,0 @@ "docUtils/utils" |
{ | ||
"name": "@salesforcedevs/docs-components", | ||
"version": "1.3.221", | ||
"version": "1.3.227-dh-alpha1", | ||
"description": "Docs Lightning web components for DSC", | ||
@@ -27,3 +27,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "eca6f0494621686d4b7c408a316e8b230b09b6dc" | ||
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad" | ||
} |
@@ -6,3 +6,4 @@ import { LightningElement, api, track } from "lwc"; | ||
import { AmfModelParser } from "doc/amfModelParser"; | ||
import { normalizeBoolean } from "dxUtils/normalizers"; | ||
import { normalizeBoolean, toJson } from "dxUtils/normalizers"; | ||
import type { OptionWithLink } from "typings/custom"; | ||
import type { | ||
@@ -47,3 +48,2 @@ AmfConfig, | ||
@api coveoAnalyticsToken!: string; | ||
@api coveoAdvancedQueryConfig!: string; | ||
@api coveoSearchHub!: string; | ||
@@ -53,5 +53,8 @@ @api useOldSidebar: boolean = false; | ||
@api tocOptions?: string; | ||
@api languages!: OptionWithLink[]; | ||
@api language!: string; | ||
@track navigation = [] as NavigationItem[]; | ||
@track versions: Array<ReferenceVersion> = []; | ||
@track showVersionBanner = false; | ||
@track _coveoAdvancedQueryConfig!: { [key: string]: any }; | ||
@@ -120,8 +123,12 @@ // Update this to update what component gets rendered in the content block | ||
this.selectedVersion = selectedVersion; | ||
if ( | ||
this.isSpecBasedReference(this._currentReferenceId) && | ||
this.oldVersionInfo | ||
) { | ||
this.showVersionBanner = true; | ||
if (this.isSpecBasedReference(this._currentReferenceId)) { | ||
this.isVersionFetched = true; | ||
if (this.oldVersionInfo) { | ||
this.showVersionBanner = true; | ||
} else { | ||
this.latestVersion = true; | ||
} | ||
} | ||
} else { | ||
this.isVersionFetched = true; | ||
} | ||
@@ -159,2 +166,27 @@ | ||
/* | ||
* The get coveoAdvancedQueryConfig() method returns this._coveoAdvancedQueryConfig, | ||
* but before returning it, it checks if there are multiple versions (this.versions.length > 1) | ||
* and if a version is selected (this.selectedVersion). If both conditions are met, | ||
* it updates the version property of this._coveoAdvancedQueryConfig with the selected version. | ||
*/ | ||
@api | ||
get coveoAdvancedQueryConfig(): { [key: string]: any } { | ||
const coveoConfig = this._coveoAdvancedQueryConfig; | ||
if (this.versions.length > 1 && this.selectedVersion) { | ||
const currentGAVersionRef = this.versions[0]; | ||
if (this.selectedVersion.id !== currentGAVersionRef.id) { | ||
// Currently Coveo only supports query without "v" | ||
const version = this.selectedVersion.id.replace("v", ""); | ||
coveoConfig.version = version; | ||
this._coveoAdvancedQueryConfig = coveoConfig; | ||
} | ||
} | ||
return this._coveoAdvancedQueryConfig; | ||
} | ||
set coveoAdvancedQueryConfig(config) { | ||
this._coveoAdvancedQueryConfig = toJson(config); | ||
} | ||
// model | ||
@@ -180,2 +212,4 @@ protected _amfConfigList: AmfConfig[] = []; | ||
private _expandChildren?: boolean = false; | ||
private isVersionFetched = false; | ||
private latestVersion = false; | ||
@@ -1291,4 +1325,7 @@ /** | ||
this.showVersionBanner = true; | ||
} else { | ||
this.latestVersion = true; | ||
} | ||
this.isVersionFetched = true; | ||
this.updateDocPhase(); | ||
@@ -1295,0 +1332,0 @@ this.selectedSidebarValue = window.location.pathname; |
@@ -7,2 +7,3 @@ /* eslint-disable @lwc/lwc/no-document-query */ | ||
import { SearchSyncer } from "docUtils/searchSyncer"; | ||
import type { OptionWithLink } from "typings/custom"; | ||
@@ -40,2 +41,6 @@ type AnchorMap = { [key: string]: { intersect: boolean; id: string } }; | ||
@api useOldSidebar?: boolean = false; | ||
@api languages!: OptionWithLink[]; | ||
@api language!: string; | ||
@api bailHref!: string; | ||
@api bailLabel!: string; | ||
@@ -42,0 +47,0 @@ @api |
import { api } from "lwc"; | ||
import cx from "classnames"; | ||
import type { OptionWithNested, OptionWithLink } from "typings/custom"; | ||
import type { OptionWithNested } from "typings/custom"; | ||
import { HeaderBase } from "dxBaseElements/headerBase"; | ||
import { toJson } from "dxUtils/normalizers"; | ||
import get from "lodash.get"; | ||
import { track } from "dxUtils/analytics"; | ||
const TABLET_MATCH = "980px"; | ||
const MOBILE_MATCH = "880px"; | ||
const SMALL_MOBILE_MATCH = "768px"; | ||
const MOBILE_MATCH = "768px"; | ||
@@ -26,30 +23,7 @@ export default class Header extends HeaderBase { | ||
@api | ||
get languages() { | ||
return this._languages; | ||
} | ||
set languages(value) { | ||
this._languages = toJson(value); | ||
} | ||
@api | ||
get language() { | ||
return this._language; | ||
} | ||
set language(value) { | ||
if (this._language !== value) { | ||
this._language = value; | ||
} | ||
} | ||
private _language: string | null = null; | ||
private _languages!: OptionWithLink[]; | ||
private _scopedNavItems!: OptionWithNested[]; | ||
private smallMobile = false; | ||
private smallMobileMatchMedia!: MediaQueryList; | ||
private tablet = false; | ||
private tabletMatchMedia!: MediaQueryList; | ||
private shouldRender = false; | ||
private shouldRender: boolean = false; | ||
private showDocDivider: boolean = false; | ||
@@ -64,20 +38,2 @@ protected mobileBreakpoint(): string { | ||
private get hasLanguages(): boolean { | ||
return !!(this.languages && this.languages.length); | ||
} | ||
private get showMobileLanguages(): boolean { | ||
return this.smallMobile && this.hasLanguages; | ||
} | ||
private get languageLabel(): string { | ||
return ( | ||
(this.language && | ||
this.languages.find( | ||
(lang) => get(lang, this.langValuePath) === this.language | ||
)?.label) || | ||
this.languages[0].label | ||
); | ||
} | ||
connectedCallback(): void { | ||
@@ -91,10 +47,2 @@ super.connectedCallback(); | ||
this.smallMobileMatchMedia = window.matchMedia( | ||
`(max-width: ${SMALL_MOBILE_MATCH})` | ||
); | ||
this.onSmallMobileChange(this.smallMobileMatchMedia); | ||
this.smallMobileMatchMedia.addEventListener( | ||
"change", | ||
this.onSmallMobileChange | ||
); | ||
if ( | ||
@@ -110,2 +58,9 @@ (window.location.pathname.includes("/docs/") && | ||
} | ||
if (this.shouldRender && window.location.pathname.includes("/docs/")) { | ||
if (!this.brand && !this.mobile) { | ||
this.shouldRender = false; | ||
this.showDocDivider = true; | ||
} | ||
} | ||
} | ||
@@ -119,7 +74,2 @@ | ||
); | ||
this.smallMobileMatchMedia.removeEventListener( | ||
"change", | ||
this.onSmallMobileChange | ||
); | ||
} | ||
@@ -130,5 +80,2 @@ | ||
private onSmallMobileChange = (e: MediaQueryListEvent | MediaQueryList) => | ||
(this.smallMobile = e.matches); | ||
protected additionalClasses(): string { | ||
@@ -140,32 +87,2 @@ return cx( | ||
} | ||
private onLangChange(event: CustomEvent<string>): void { | ||
const { detail } = event; | ||
this._language = detail; | ||
this.dispatchEvent(new CustomEvent("langchange", { detail })); | ||
} | ||
private handleBailClick(event: Event) { | ||
const payload = { | ||
click_text: "pdf", | ||
click_url: this.bailHref, | ||
element_title: "pdf", | ||
element_type: "link", | ||
content_category: "download" | ||
}; | ||
track(event.target!, "custEv_pdfDownload", { | ||
...payload, | ||
file_name: this.getFilename(this.bailHref!), | ||
file_extension: "pdf" | ||
}); | ||
track(event.target!, "custEv_linkClick", { | ||
...payload | ||
}); | ||
} | ||
private getFilename = function (path: string) { | ||
return path.substring(path.lastIndexOf("/") + 1); | ||
}; | ||
} |
@@ -64,2 +64,6 @@ export type CoveoAdvancedQueryXMLConfig = { | ||
subtitle: string; | ||
headerHref: string; | ||
} | ||
export type SiderbarFooter = { | ||
bailHref: string; | ||
@@ -69,4 +73,3 @@ bailLabel: string; | ||
language?: string; | ||
headerHref: string; | ||
} | ||
}; | ||
@@ -73,0 +76,0 @@ export type ApiNavItem = { |
@@ -11,2 +11,3 @@ /* eslint-disable @lwc/lwc/no-document-query */ | ||
Header, | ||
SiderbarFooter, | ||
HistoryState, | ||
@@ -30,2 +31,8 @@ PageReference, | ||
const defaultSidebarFooter: SiderbarFooter = { | ||
bailHref: "", | ||
bailLabel: "", | ||
languages: [], | ||
language: "" | ||
}; | ||
export default class DocXmlContent extends LightningElementWithState<{ | ||
@@ -69,2 +76,3 @@ isFetchingDocument: boolean; | ||
private loaded = false; | ||
private _pageHeader?: Header; | ||
private pdfUrl = ""; | ||
@@ -76,5 +84,7 @@ private tocMap: TocMap = {}; | ||
private _pathName = ""; | ||
private _pageHeader?: Header; | ||
private listenerAttached = false; | ||
private _enableCoveo?: boolean = false; | ||
private sidebarFooterContent: SiderbarFooter = { ...defaultSidebarFooter }; | ||
private latestVersion = false; | ||
private previewVersion = false; | ||
@@ -134,2 +144,6 @@ private searchSyncer = new SearchSyncer({ | ||
info = oldVersionDocInfo(currentGAVersion.link.href); | ||
} else if ( | ||
parseFloat(this.version.id) > parseFloat(versionNo) | ||
) { | ||
this.previewVersion = true; | ||
} | ||
@@ -222,9 +236,2 @@ } catch (exception) { | ||
this.searchSyncer.dispose(); | ||
if (this.listenerAttached) { | ||
this.pageHeader.removeEventListener( | ||
"langchange", | ||
this.handleLanguageChange | ||
); | ||
this.listenerAttached = false; | ||
} | ||
} | ||
@@ -423,8 +430,4 @@ | ||
getReferenceFromUrl(): PageReference { | ||
const [ | ||
page, | ||
docId, | ||
deliverable, | ||
contentDocumentId | ||
] = window.location.pathname.substr(1).split("/"); | ||
const [page, docId, deliverable, contentDocumentId] = | ||
window.location.pathname.substr(1).split("/"); | ||
@@ -479,3 +482,3 @@ const { origin: domain, hash, search } = window.location; | ||
this.updateHeader(); | ||
this.updateHeaderAndSidebarFooter(); | ||
@@ -491,2 +494,4 @@ this.buildBreadcrumbs(); | ||
this.showVersionBanner = true; | ||
} else { | ||
this.latestVersion = true; | ||
} | ||
@@ -545,3 +550,3 @@ | ||
updateHeader(): void { | ||
updateHeaderAndSidebarFooter(): void { | ||
if (!this.pageHeader) { | ||
@@ -556,17 +561,9 @@ return; | ||
if (this.pdfUrl) { | ||
this.pageHeader.bailHref = this.pdfUrl; | ||
this.pageHeader.bailLabel = "PDF"; | ||
this.sidebarFooterContent.bailHref = this.pdfUrl; | ||
this.sidebarFooterContent.bailLabel = "PDF"; | ||
} | ||
if (!this.listenerAttached) { | ||
this.pageHeader.addEventListener( | ||
"langchange", | ||
this.handleLanguageChange | ||
); | ||
this.listenerAttached = true; | ||
} | ||
this.sidebarFooterContent.languages = this.availableLanguages; | ||
this.sidebarFooterContent.language = this.language?.id; | ||
this.pageHeader.languages = this.availableLanguages; | ||
this.pageHeader.language = this.language?.id; | ||
if (this.pageReference) { | ||
@@ -595,16 +592,10 @@ const { docId, deliverable, page } = this.pageReference; | ||
private updateSearchInput(searchParam: string): void { | ||
(this.template.querySelector( | ||
"doc-content-layout" | ||
) as any)?.setSidebarInputValue(searchParam); | ||
( | ||
this.template.querySelector("doc-content-layout") as any | ||
)?.setSidebarInputValue(searchParam); | ||
} | ||
private pageReferenceToString(reference: PageReference): string { | ||
const { | ||
page, | ||
docId, | ||
deliverable, | ||
contentDocumentId, | ||
hash, | ||
search | ||
} = reference; | ||
const { page, docId, deliverable, contentDocumentId, hash, search } = | ||
reference; | ||
return `/${page}/${docId}/${deliverable}/${contentDocumentId}${this.normalizeSearch( | ||
@@ -611,0 +602,0 @@ search! |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
252575
75
0
6477
2