@salesforcedevs/docs-components 1.34.0 → 1.34.1-proj-ver-picker-1
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/package.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@salesforcedevs/docs-components",
|
|
3
|
+
"version": "1.34.1-proj-ver-picker-1",
|
|
4
|
+
"description": "Docs Lightning web components for DSC",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": "22.x"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@api-components/amf-helper-mixin": "4.5.29",
|
|
15
|
+
"classnames": "2.5.1",
|
|
16
|
+
"dompurify": "3.2.4",
|
|
17
|
+
"kagekiri": "1.4.2",
|
|
18
|
+
"lodash.orderby": "4.6.0",
|
|
19
|
+
"lodash.uniqby": "4.7.0",
|
|
20
|
+
"query-string": "7.1.3",
|
|
21
|
+
"sentence-case": "3.0.4"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/classnames": "2.3.1",
|
|
25
|
+
"@types/lodash.orderby": "4.6.9",
|
|
26
|
+
"@types/lodash.uniqby": "4.7.9"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
|
|
29
|
+
"stableVersion": "1.34.0"
|
|
30
|
+
}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
:host {
|
|
5
5
|
--dx-c-dropdown-option-font-weight: normal;
|
|
6
6
|
--dx-c-dropdown-option-label-color: var(--dx-g-gray-10);
|
|
7
|
+
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
8
|
+
var(--dx-g-spacing-lg);
|
|
9
|
+
--dx-c-popover-padding: var(--dx-g-spacing-sm) 0;
|
|
7
10
|
--popover-container-open-transform: translateY(4px);
|
|
8
11
|
}
|
|
9
12
|
|
|
@@ -17,13 +20,15 @@
|
|
|
17
20
|
.version-picker-button {
|
|
18
21
|
display: flex;
|
|
19
22
|
width: var(--doc-version-picker-width, 296px);
|
|
23
|
+
|
|
24
|
+
--dx-c-button-horizontal-spacing: var(--dx-g-spacing-sm);
|
|
25
|
+
--dx-g-button-icon-color: var(--dx-g-gray-50);
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
.version-picker-button:hover,
|
|
23
|
-
.version-picker-button:
|
|
24
|
-
.version-picker-button
|
|
25
|
-
--dx-
|
|
26
|
-
--dx-c-button-primary-color: var(--dx-g-blue-vibrant-40);
|
|
29
|
+
.version-picker-button:focus-within,
|
|
30
|
+
.version-picker-button[aria-expanded="true"] {
|
|
31
|
+
--dx-g-button-icon-color: var(--dx-g-blue-vibrant-20);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
/**
|
|
@@ -35,6 +40,27 @@ dx-button::part(content) {
|
|
|
35
40
|
overflow: hidden;
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
/* The border is an inset box-shadow so thickening it on hover/focus doesn't
|
|
44
|
+
resize the small variant's fit-content box. */
|
|
45
|
+
.version-picker-button::part(container) {
|
|
46
|
+
background: white;
|
|
47
|
+
box-shadow: inset 0 0 0 1px var(--dx-g-gray-50);
|
|
48
|
+
color: var(--dx-g-gray-10);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.version-picker-button::part(container):hover {
|
|
52
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
53
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* aria-expanded keeps the focus ring while the menu is open. */
|
|
57
|
+
.version-picker-button:focus-within::part(container),
|
|
58
|
+
.version-picker-button[aria-expanded="true"]::part(container) {
|
|
59
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
60
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20), 0 0 0 2px white,
|
|
61
|
+
0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
62
|
+
}
|
|
63
|
+
|
|
38
64
|
.selected-version {
|
|
39
65
|
display: flex;
|
|
40
66
|
flex-direction: row;
|
|
@@ -49,16 +75,100 @@ dx-button::part(content) {
|
|
|
49
75
|
white-space: nowrap;
|
|
50
76
|
}
|
|
51
77
|
|
|
52
|
-
dx-type-badge.latest-badge
|
|
53
|
-
|
|
54
|
-
--dx-c-type-badge-background: var(--dx-g-green-vibrant-95);
|
|
55
|
-
|
|
78
|
+
dx-type-badge.latest-badge,
|
|
79
|
+
dx-type-badge.not-latest-badge {
|
|
56
80
|
margin-left: var(--dx-g-spacing-sm);
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
/* ------------------------------------------------------------------ *
|
|
84
|
+
* Small "dot" variant (opt-in via `small`). Additive
|
|
85
|
+
* ------------------------------------------------------------------ */
|
|
62
86
|
|
|
63
|
-
|
|
87
|
+
/* Option padding is sm both axes: the small menu tracks the ~104px trigger, so
|
|
88
|
+
the default 24px horizontal would crowd the labels. */
|
|
89
|
+
.version-picker-dropdown-small {
|
|
90
|
+
--dx-c-dropdown-option-font-size: var(--dx-g-text-xs);
|
|
91
|
+
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
92
|
+
var(--dx-g-spacing-sm);
|
|
93
|
+
--dx-c-dropdown-option-border-radius: 0;
|
|
94
|
+
--dx-c-popover-border: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.version-picker-button-small {
|
|
98
|
+
width: fit-content;
|
|
99
|
+
max-width: 104px;
|
|
100
|
+
|
|
101
|
+
--dx-c-button-font-size: var(--dx-g-text-xs);
|
|
102
|
+
--dx-c-button-font-weight: var(--dx-g-font-normal);
|
|
103
|
+
--dx-c-button-line-height: var(--dx-g-spacing-lg);
|
|
104
|
+
--dx-c-button-icon-gap: var(--dx-g-spacing-2xs);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* min-width: 0 on each flex ancestor lets the label truncate: a flex item's
|
|
108
|
+
default min-width: auto refuses to shrink below its content and overrides the
|
|
109
|
+
host's max-width, so without this the trigger overflows instead. */
|
|
110
|
+
.version-picker-button-small::part(content) {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex: 1;
|
|
113
|
+
min-width: 0;
|
|
114
|
+
width: auto;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* width:100% re-ties to the 104px-capped host (container is width:inherit,
|
|
119
|
+
which copies width but not max-width). Border/bg/states are shared above. */
|
|
120
|
+
.version-picker-button-small::part(container) {
|
|
121
|
+
width: 100%;
|
|
122
|
+
height: var(--dx-g-spacing-lg);
|
|
123
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.selected-version-small {
|
|
127
|
+
flex: 1;
|
|
128
|
+
min-width: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.version-picker-dot {
|
|
132
|
+
flex: 0 0 auto;
|
|
133
|
+
width: var(--dx-g-spacing-sm);
|
|
134
|
+
height: var(--dx-g-spacing-sm);
|
|
135
|
+
margin-right: var(--dx-g-spacing-xs);
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.version-picker-dot-latest {
|
|
140
|
+
background: var(--dx-g-green-vibrant-60);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.version-picker-dot-not-latest {
|
|
144
|
+
background: var(--dx-g-yellow-vibrant-80);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* inline-block (not flex) so the label can truncate; line-height centers it. */
|
|
148
|
+
.version-picker-readonly {
|
|
149
|
+
box-sizing: border-box;
|
|
150
|
+
display: inline-block;
|
|
151
|
+
width: var(--doc-version-picker-width, 296px);
|
|
152
|
+
height: var(--dx-g-spacing-xl);
|
|
153
|
+
margin: 0;
|
|
154
|
+
padding: 0 var(--dx-g-spacing-sm);
|
|
155
|
+
border: 1px solid var(--dx-g-gray-80);
|
|
156
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
color: var(--dx-g-gray-10);
|
|
159
|
+
text-overflow: ellipsis;
|
|
160
|
+
white-space: nowrap;
|
|
161
|
+
font: var(--dx-g-font-normal) var(--dx-g-text-sm) / var(--dx-g-spacing-xl)
|
|
162
|
+
var(--dx-g-font-sans),
|
|
163
|
+
sans-serif;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.version-picker-readonly-small {
|
|
167
|
+
width: fit-content;
|
|
168
|
+
max-width: 104px;
|
|
169
|
+
height: var(--dx-g-spacing-lg);
|
|
170
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
171
|
+
font: var(--dx-g-font-normal) var(--dx-g-text-xs) / var(--dx-g-spacing-lg)
|
|
172
|
+
var(--dx-g-font-sans),
|
|
173
|
+
sans-serif;
|
|
64
174
|
}
|
|
@@ -1,37 +1,70 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div lwc:if={showVersionPicker} class="version-picker-container">
|
|
3
|
+
<!-- Small read-only: plain value, no dropdown -->
|
|
4
|
+
<p
|
|
5
|
+
lwc:if={readOnly}
|
|
6
|
+
class={readOnlyClass}
|
|
7
|
+
title={selectedVersion.label}
|
|
8
|
+
>
|
|
9
|
+
{selectedVersion.label}
|
|
10
|
+
</p>
|
|
11
|
+
|
|
3
12
|
<dx-dropdown
|
|
13
|
+
lwc:else
|
|
14
|
+
class={dropdownClass}
|
|
4
15
|
options={versions}
|
|
5
16
|
analytics-event="custEv_docVersionSelect"
|
|
6
17
|
analytics-payload={analyticsPayload}
|
|
7
18
|
value={selectedVersion.id}
|
|
8
|
-
width="
|
|
19
|
+
full-width="true"
|
|
9
20
|
onchange={onVersionChange}
|
|
10
21
|
>
|
|
11
22
|
<dx-button
|
|
12
|
-
class=
|
|
23
|
+
class={triggerClass}
|
|
13
24
|
variant="tertiary"
|
|
14
25
|
size="small"
|
|
26
|
+
font="sans"
|
|
15
27
|
icon-symbol="chevrondown"
|
|
16
|
-
icon-size=
|
|
28
|
+
icon-size={triggerIconSize}
|
|
29
|
+
aria-label={triggerAriaLabel}
|
|
17
30
|
>
|
|
18
|
-
<div class=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
<div class={selectedVersionClass}>
|
|
32
|
+
<!-- Small: leading colored dot -->
|
|
33
|
+
<template lwc:if={small}>
|
|
34
|
+
<template lwc:if={showLatestTag}>
|
|
35
|
+
<span class={dotClass} aria-hidden="true"></span>
|
|
36
|
+
</template>
|
|
37
|
+
<p
|
|
38
|
+
class="selected-version-label"
|
|
39
|
+
title={selectedVersion.label}
|
|
40
|
+
>
|
|
41
|
+
{selectedVersion.label}
|
|
42
|
+
</p>
|
|
43
|
+
</template>
|
|
44
|
+
<!-- Default: trailing Latest/Not-Latest badge -->
|
|
45
|
+
<template lwc:else>
|
|
46
|
+
<p
|
|
47
|
+
class="selected-version-label"
|
|
48
|
+
title={selectedVersion.label}
|
|
49
|
+
>
|
|
50
|
+
{selectedVersion.label}
|
|
51
|
+
</p>
|
|
52
|
+
<template lwc:if={showLatestTag}>
|
|
53
|
+
<dx-type-badge
|
|
54
|
+
class="latest-badge"
|
|
55
|
+
lwc:if={latestVersion}
|
|
56
|
+
variant="status-success"
|
|
57
|
+
value="Latest"
|
|
58
|
+
size="small"
|
|
59
|
+
></dx-type-badge>
|
|
60
|
+
<dx-type-badge
|
|
61
|
+
class="not-latest-badge"
|
|
62
|
+
lwc:else
|
|
63
|
+
variant="status-warning"
|
|
64
|
+
value="Not Latest"
|
|
65
|
+
size="small"
|
|
66
|
+
></dx-type-badge>
|
|
67
|
+
</template>
|
|
35
68
|
</template>
|
|
36
69
|
</div>
|
|
37
70
|
</dx-button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
2
3
|
|
|
3
4
|
import { AnalyticsPayload, OptionWithNested } from "typings/custom";
|
|
4
5
|
|
|
@@ -12,6 +13,8 @@ export default class VersionPicker extends LightningElement {
|
|
|
12
13
|
private _selectedVersion?: OptionWithNested;
|
|
13
14
|
private _latestVersion: boolean = false;
|
|
14
15
|
private _hideBadge: boolean = false;
|
|
16
|
+
private _small: boolean = false;
|
|
17
|
+
private _readOnly: boolean = false;
|
|
15
18
|
|
|
16
19
|
@api
|
|
17
20
|
get versions() {
|
|
@@ -51,6 +54,27 @@ export default class VersionPicker extends LightningElement {
|
|
|
51
54
|
this._hideBadge = normalizeBoolean(value);
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
// Opt-in compact "dot" variant (24px, abbreviated label). Off by default so
|
|
58
|
+
// existing consumers render the default trigger unchanged.
|
|
59
|
+
@api
|
|
60
|
+
get small() {
|
|
61
|
+
return this._small;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set small(value) {
|
|
65
|
+
this._small = normalizeBoolean(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Opt-in read-only state: plain value, no dropdown menu.
|
|
69
|
+
@api
|
|
70
|
+
get readOnly() {
|
|
71
|
+
return this._readOnly;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set readOnly(value) {
|
|
75
|
+
this._readOnly = normalizeBoolean(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
54
78
|
private get showVersionPicker() {
|
|
55
79
|
return this._versions && this._versions.length !== 0;
|
|
56
80
|
}
|
|
@@ -59,6 +83,62 @@ export default class VersionPicker extends LightningElement {
|
|
|
59
83
|
return !this.hideBadge;
|
|
60
84
|
}
|
|
61
85
|
|
|
86
|
+
private get readOnlyClass(): string {
|
|
87
|
+
return cx(
|
|
88
|
+
"version-picker-readonly",
|
|
89
|
+
this.small && "version-picker-readonly-small"
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private get dotClass(): string {
|
|
94
|
+
return `version-picker-dot ${
|
|
95
|
+
this.latestVersion
|
|
96
|
+
? "version-picker-dot-latest"
|
|
97
|
+
: "version-picker-dot-not-latest"
|
|
98
|
+
}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Accessible name for the small trigger: includes the latest state so it
|
|
102
|
+
// isn't conveyed by the dot's color alone (WCAG 1.4.1). Omits the state
|
|
103
|
+
// when the indicator is hidden.
|
|
104
|
+
private get smallTriggerAriaLabel(): string {
|
|
105
|
+
const label = this.selectedVersion?.label ?? "";
|
|
106
|
+
if (!this.showLatestTag) {
|
|
107
|
+
return label;
|
|
108
|
+
}
|
|
109
|
+
return `${label}, ${this.latestVersion ? "Latest" : "Not Latest"}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// --- Per-variant values for the shared dropdown/button markup below. The
|
|
113
|
+
// small variant opts into extra classes and a compact chevron.
|
|
114
|
+
|
|
115
|
+
// Not cx(): the default must have NO class attribute (cx returns "", which
|
|
116
|
+
// would render class="" and break the frozen consumer snapshots).
|
|
117
|
+
private get dropdownClass(): string | undefined {
|
|
118
|
+
return this.small ? "version-picker-dropdown-small" : undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private get triggerClass(): string {
|
|
122
|
+
return cx(
|
|
123
|
+
"version-picker-button",
|
|
124
|
+
this.small && "version-picker-button-small"
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private get triggerIconSize(): string {
|
|
129
|
+
return this.small ? "xsmall" : "medium";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Default returns "" (dx-button's own default) so the trigger's rendered
|
|
133
|
+
// aria-label is unchanged for the default variant.
|
|
134
|
+
private get triggerAriaLabel(): string {
|
|
135
|
+
return this.small ? this.smallTriggerAriaLabel : "";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private get selectedVersionClass(): string {
|
|
139
|
+
return cx("selected-version", this.small && "selected-version-small");
|
|
140
|
+
}
|
|
141
|
+
|
|
62
142
|
private onVersionChange(e: CustomEvent) {
|
|
63
143
|
this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
|
|
64
144
|
}
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|