@salesforcedevs/dx-components 1.2.12 → 1.2.15-alpha.0

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 (46) hide show
  1. package/lwc.config.json +5 -1
  2. package/package.json +2 -3
  3. package/src/assets/icons/salesforcebrand-sprite/svg/symbols.svg +40 -0
  4. package/src/assets/svg/big-moon.svg +1 -0
  5. package/src/assets/svg/blue-circle.svg +3 -0
  6. package/src/assets/svg/trial-left.svg +6 -0
  7. package/src/assets/svg/trial-right.svg +26 -0
  8. package/src/modules/dx/button/button.css +10 -3
  9. package/src/modules/dx/buttonToggle/buttonToggle.css +50 -0
  10. package/src/modules/dx/buttonToggle/buttonToggle.html +17 -0
  11. package/src/modules/dx/buttonToggle/buttonToggle.ts +75 -0
  12. package/src/modules/dx/cardTrial/cardTrial.css +65 -4
  13. package/src/modules/dx/cardTrial/cardTrial.html +95 -12
  14. package/src/modules/dx/cardTrial/cardTrial.ts +69 -2
  15. package/src/modules/dx/cardTrialExpanded/cardTrialExpanded.css +149 -0
  16. package/src/modules/dx/cardTrialExpanded/cardTrialExpanded.html +85 -0
  17. package/src/modules/dx/cardTrialExpanded/cardTrialExpanded.ts +67 -0
  18. package/src/modules/dx/featuredContentHeader/featuredContentHeader.css +60 -2
  19. package/src/modules/dx/featuredContentHeader/featuredContentHeader.html +8 -0
  20. package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +13 -1
  21. package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.css +1 -0
  22. package/src/modules/dx/headerSearch/headerSearch.html +2 -0
  23. package/src/modules/dx/headerSearch/headerSearch.ts +1 -0
  24. package/src/modules/dx/input/input.ts +2 -0
  25. package/src/modules/dx/modal/modal.css +40 -0
  26. package/src/modules/dx/modal/modal.html +10 -0
  27. package/src/modules/dx/modal/modal.ts +50 -0
  28. package/src/modules/dx/modalDrawer/modalDrawer.html +2 -2
  29. package/src/modules/dx/modalDrawer/modalDrawer.ts +7 -1
  30. package/src/modules/dx/popover/popover.css +2 -1
  31. package/src/modules/dx/section/section.css +10 -1
  32. package/src/modules/dx/section/section.ts +1 -1
  33. package/src/modules/dx/sidebarSearch/sidebarSearch.html +1 -0
  34. package/src/modules/dx/sidebarSearch/sidebarSearch.ts +1 -0
  35. package/src/modules/dx/tabPanel/tabPanel.css +20 -0
  36. package/src/modules/dx/tabPanel/tabPanel.html +13 -0
  37. package/src/modules/dx/tabPanel/tabPanel.ts +27 -0
  38. package/src/modules/dx/tabPanelItem/tabPanelItem.css +39 -0
  39. package/src/modules/dx/tabPanelItem/tabPanelItem.html +15 -0
  40. package/src/modules/dx/tabPanelItem/tabPanelItem.ts +39 -0
  41. package/src/modules/dx/tabPanelList/tabPanelList.css +35 -0
  42. package/src/modules/dx/tabPanelList/tabPanelList.html +47 -0
  43. package/src/modules/dx/tabPanelList/tabPanelList.ts +164 -0
  44. package/src/modules/dx/tabPanelList/uniqueId.ts +6 -0
  45. package/yarn-error.log +17934 -0
  46. package/LICENSE +0 -12
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <div class={containerClass}>
3
3
  <slot></slot>
4
- <dx-button onclick={handleCloseModal}>Done</dx-button>
4
+ <dx-button onclick={handleToggleModal}>Done</dx-button>
5
5
  </div>
6
6
  <div
7
7
  if:true={open}
8
8
  class="modal-drawer_overlay"
9
- onclick={handleCloseModal}
9
+ onclick={handleToggleModal}
10
10
  ></div>
11
11
  </template>
@@ -20,7 +20,13 @@ export default class ModalDrawer extends LightningElement {
20
20
  );
21
21
  }
22
22
 
23
- handleCloseModal() {
23
+ handleKeyDown(event: KeyboardEvent): void {
24
+ if (event.key === "Escape") {
25
+ this.handleToggleModal();
26
+ }
27
+ }
28
+
29
+ handleToggleModal() {
24
30
  this._open = !this._open;
25
31
  this.dispatchEvent(new CustomEvent("clickclose"));
26
32
  }
@@ -6,6 +6,7 @@
6
6
  var(--dx-g-spacing-sm)
7
7
  );
8
8
  --popover-border: var(--dx-c-popover-border, 1px solid var(--dx-g-gray-90));
9
+ --popover-padding: var(--dx-g-spacing-sm);
9
10
  }
10
11
 
11
12
  .popover-container {
@@ -25,7 +26,7 @@
25
26
  width: 168px;
26
27
  max-width: calc(100vw - var(--dx-g-spacing-lg));
27
28
  max-height: 65vh;
28
- padding: var(--dx-g-spacing-sm);
29
+ padding: var(--popover-padding);
29
30
  overflow-y: auto;
30
31
  transition: opacity 0.2s linear, transform 0.2s linear;
31
32
  transition-delay: 0.02s;
@@ -8,6 +8,7 @@
8
8
  --dx-c-section-padding-right: var(--dx-c-section-padding-horizontal);
9
9
  --dx-c-section-padding-top: var(--dx-c-section-padding-vertical);
10
10
  --dx-c-section-padding-bottom: var(--dx-c-section-padding-vertical);
11
+ --dx-c-section-heading-margin-bottom: var(--dx-g-spacing-2xl);
11
12
  }
12
13
 
13
14
  .section {
@@ -58,10 +59,18 @@
58
59
  max-width: 800px;
59
60
  }
60
61
 
62
+ .dx-text-heading-custom {
63
+ color: var(--dx-c-section-heading-font-color, --dx-g-text-heading-color);
64
+ font-family: var(--dx-c-section-heading-font-family, --dx-g-font-display);
65
+ font-size: var(--dx-c-section-heading-font-size, --dx-g-text-3xl);
66
+ letter-spacing: var(--dx-c-section-heading-letter-spacing, -0.4px);
67
+ line-height: var(--dx-c-section-heading-line-height, 40px);
68
+ }
69
+
61
70
  .text {
62
71
  display: flex;
63
72
  flex-direction: column;
64
- margin-bottom: var(--dx-g-spacing-2xl);
73
+ margin-bottom: var(--dx-c-section-heading-margin-bottom);
65
74
  z-index: 100;
66
75
  }
67
76
 
@@ -5,7 +5,7 @@ import { toDxColor } from "dxUtils/css";
5
5
  export default class Section extends LightningElement {
6
6
  @api backgroundColor: string = "transparent";
7
7
  @api dark: boolean = false;
8
- @api headingLevel: "1" | "2" | "3" | "4" | "5" = "3";
8
+ @api headingLevel: "1" | "2" | "3" | "4" | "5" | "custom" = "3";
9
9
  @api label?: string;
10
10
  @api subtitle?: string;
11
11
  @api textAlign: "center" | "left" = "left";
@@ -18,6 +18,7 @@
18
18
  value={value}
19
19
  onchange={onInputChange}
20
20
  onfocus={onInputFocus}
21
+ onblur={onDropdownRequestClose}
21
22
  onclear={onInputClear}
22
23
  shortcut-key="j"
23
24
  clearable
@@ -422,6 +422,7 @@ export default class SidebarSearch extends LightningElement {
422
422
  switch (e.detail as PopoverRequestCloseType) {
423
423
  case "interact-outside":
424
424
  case "keypress-escape":
425
+ case "input-blur":
425
426
  this.dropdownRequestedOpen = false;
426
427
  break;
427
428
  default:
@@ -0,0 +1,20 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ :host {
4
+ --dx-c-tab-panel-margin-top: var(--dx-g-spacing-3xl);
5
+ --dx-c-tab-panel-gap: var(--dx-g-spacing-md);
6
+ }
7
+
8
+ .tabpanel {
9
+ display: none;
10
+ }
11
+
12
+ .tabpanel-active {
13
+ display: block;
14
+ }
15
+
16
+ @media screen and (max-width: 640px) {
17
+ .tabpanel-active {
18
+ --dx-c-tab-panel-margin-top: 36px;
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <div
3
+ role="tabpanel"
4
+ part="tabpanel"
5
+ id={panelId}
6
+ class={className}
7
+ tabindex={activeTabIndex}
8
+ aria-labelledby={tabId}
9
+ hidden={panelHidden}
10
+ >
11
+ <slot></slot>
12
+ </div>
13
+ </template>
@@ -0,0 +1,27 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import cx from "classnames";
3
+ export default class TabPanel extends LightningElement {
4
+ @api index!: number;
5
+ @api groupId!: string;
6
+ @api active: boolean = false;
7
+
8
+ private get tabId() {
9
+ return `tabs--${this.groupId}--tab--${this.index}`;
10
+ }
11
+
12
+ private get panelId() {
13
+ return `tabs--${this.groupId}--panel--${this.index}`;
14
+ }
15
+
16
+ private get activeTabIndex() {
17
+ return this.active ? 0 : -1;
18
+ }
19
+
20
+ private get className() {
21
+ return cx("tabpanel", this.active && "tabpanel-active");
22
+ }
23
+
24
+ private get panelHidden() {
25
+ return !this.active;
26
+ }
27
+ }
@@ -0,0 +1,39 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ .tab {
4
+ color: var(--dx-g-blue-vibrant-20);
5
+ font-family: var(--dx-g-font-display);
6
+ font-size: var(--dx-g-text-lg);
7
+ font-weight: var(--dx-g-font-bold);
8
+ padding: var(--dx-g-spacing-smd) var(--dx-g-spacing-xl)
9
+ var(--dx-g-spacing-sm);
10
+ border-top-left-radius: var(--dx-g-spacing-sm);
11
+ border-top-right-radius: var(--dx-g-spacing-sm);
12
+ border-bottom: var(--dx-g-spacing-xs) solid transparent;
13
+ }
14
+
15
+ .tab:hover {
16
+ background-color: var(--dx-g-blue-vibrant-95);
17
+ }
18
+
19
+ .tab-active {
20
+ color: var(--dx-g-blue-vibrant-50);
21
+ border-bottom: var(--dx-g-spacing-xs) solid var(--dx-g-blue-vibrant-50);
22
+ }
23
+
24
+ .tab:hover,
25
+ .tab-active {
26
+ font-weight: var(--dx-g-font-bold);
27
+ }
28
+
29
+ @media screen and (max-width: 640px) {
30
+ .tab {
31
+ font-size: var(--dx-g-text-base);
32
+ font-family: var(--dx-g-font-sans);
33
+ font-weight: var(--dx-g-font-normal);
34
+ }
35
+
36
+ .tab-active {
37
+ font-weight: var(--dx-g-font-bold);
38
+ }
39
+ }
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <button
3
+ role="tab"
4
+ part="tab"
5
+ id={tabId}
6
+ onclick={onClick}
7
+ class={className}
8
+ aria-controls={panelId}
9
+ aria-label="Tab button"
10
+ aria-selected={active}
11
+ tabindex={index}
12
+ >
13
+ <slot></slot>
14
+ </button>
15
+ </template>
@@ -0,0 +1,39 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import cx from "classnames";
3
+ export default class TabPanelItem extends LightningElement {
4
+ @api groupId!: string;
5
+ @api index!: number;
6
+ @api active: boolean = false;
7
+
8
+ @api focus() {
9
+ const button = this.template.querySelector("button");
10
+ if (!button) {
11
+ return;
12
+ }
13
+ button.focus();
14
+ }
15
+
16
+ private get activeTabIndex() {
17
+ return this.active ? 0 : -1;
18
+ }
19
+
20
+ private get panelId() {
21
+ return `tabs--${this.groupId}--panel--${this.index}`;
22
+ }
23
+
24
+ private get tabId() {
25
+ return `tabs--${this.groupId}--tab--${this.index}`;
26
+ }
27
+
28
+ private get className() {
29
+ return cx("tab", this.active && "tab-active");
30
+ }
31
+
32
+ private onClick() {
33
+ this.dispatchEvent(
34
+ new CustomEvent("select", {
35
+ detail: this.index
36
+ })
37
+ );
38
+ }
39
+ }
@@ -0,0 +1,35 @@
1
+ :host {
2
+ --dx-c-tab-panel-list-horizontal-padding: var(--dx-g-spacing-3xl);
3
+ }
4
+
5
+ .tablist-container {
6
+ padding: 0 var(--dx-c-tab-panel-list-horizontal-padding);
7
+ }
8
+
9
+ .tablist {
10
+ border-bottom: 1px solid var(--dx-g-gray-80);
11
+ }
12
+
13
+ dx-popover {
14
+ --popover-padding: none;
15
+ }
16
+
17
+ .dropdown-item {
18
+ padding: var(--dx-g-spacing-sm);
19
+ }
20
+
21
+ .dropdown-item:hover {
22
+ cursor: pointer;
23
+ font-weight: var(--dx-g-font-bold);
24
+ background-color: var(--dx-g-blue-vibrant-95);
25
+ }
26
+
27
+ .more-btn {
28
+ display: flex;
29
+ align-items: center;
30
+ gap: var(--dx-g-spacing-sm);
31
+ }
32
+
33
+ .hidden {
34
+ display: none;
35
+ }
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <div class="tablist-container">
3
+ <div class="tablist" role="tablist" part="tablist">
4
+ <template for:each={tabs} for:item="tab">
5
+ <dx-tab-panel-item
6
+ key={tab.index}
7
+ onselect={onTabClick}
8
+ group-id={groupId}
9
+ index={tab.index}
10
+ active={tab.active}
11
+ >
12
+ {tab.label}
13
+ </dx-tab-panel-item>
14
+ </template>
15
+ <dx-popover offset="medium" placement="bottom-center">
16
+ <dx-tab-panel-item class="more-btn-container" slot="control">
17
+ <div class="more-btn">
18
+ More
19
+ <dx-icon
20
+ sprite="utility"
21
+ symbol="threedots"
22
+ size="large"
23
+ ></dx-icon>
24
+ </div>
25
+ </dx-tab-panel-item>
26
+ <div slot="content">
27
+ <template for:each={dropdownItems} for:item="dropdownItem">
28
+ <div
29
+ role="button"
30
+ onclick={onDropdownItemClick}
31
+ onkeydown={onDropdownItemClick}
32
+ data-value={dropdownItem.index}
33
+ key={dropdownItem.label}
34
+ class="dropdown-item"
35
+ tabindex="0"
36
+ >
37
+ {dropdownItem.label}
38
+ </div>
39
+ </template>
40
+ </div>
41
+ </dx-popover>
42
+ </div>
43
+ <div part="tabpanels">
44
+ <slot onslotchange={onSlotChange}></slot>
45
+ </div>
46
+ </div>
47
+ </template>
@@ -0,0 +1,164 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { LightningSlotElement, Tab } from "typings/custom";
3
+ import { toJson } from "dxUtils/normalizers";
4
+ import { uniqueId } from "./uniqueId";
5
+ export default class TabPanelList extends LightningElement {
6
+ @api
7
+ get initialIndex() {
8
+ return +this._initialIndex;
9
+ }
10
+ set initialIndex(value) {
11
+ this._initialIndex = +value;
12
+ }
13
+
14
+ @api
15
+ get tabs() {
16
+ return this._tabs.map((tab: Tab, index) => ({
17
+ ...tab,
18
+ index,
19
+ groupId: this.groupId,
20
+ active: this.activeIndex === index
21
+ }));
22
+ }
23
+ set tabs(value: Tab[]) {
24
+ this._tabs = toJson(value);
25
+ }
26
+
27
+ private _initialIndex: number = 0;
28
+ private _tabs: Tab[] = [];
29
+ private _activeIndex?: number;
30
+ private groupId: string = uniqueId();
31
+ private tabSlotPanels?: LightningSlotElement;
32
+ private showPopover: boolean = true;
33
+ private dropdownItems: Tab[] = [];
34
+ private hasRendered: boolean = false;
35
+
36
+ private get tabElements() {
37
+ return this.template.querySelectorAll("dx-tab-panel-item");
38
+ }
39
+
40
+ private get activeIndex() {
41
+ return this._activeIndex == null
42
+ ? this.initialIndex
43
+ : this._activeIndex;
44
+ }
45
+
46
+ private set activeIndex(value: number) {
47
+ this._activeIndex = value;
48
+ this.updateTabs();
49
+ }
50
+
51
+ connectedCallback() {
52
+ this.addListeners();
53
+ }
54
+
55
+ renderedCallback(): void {
56
+ if (!this.hasRendered) {
57
+ this.onResize();
58
+ this.hasRendered = true;
59
+ }
60
+ }
61
+
62
+ disconnectedCallback() {
63
+ this.removeListeners();
64
+ }
65
+
66
+ private onTabClick(e: { detail: number }) {
67
+ if (e.detail !== this.activeIndex) {
68
+ this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
69
+ }
70
+ this.activeIndex = e.detail;
71
+ }
72
+
73
+ private onDropdownItemClick(e: CustomEvent) {
74
+ this.onTabClick({ detail: +e.currentTarget!.dataset.value });
75
+ }
76
+
77
+ private onSlotChange(e: Event) {
78
+ this.tabSlotPanels = <LightningSlotElement>e.target;
79
+ this.updateTabs();
80
+ }
81
+
82
+ private updateTabs() {
83
+ if (this.tabSlotPanels) {
84
+ this.tabSlotPanels.assignedElements().forEach((tabPanel, index) => {
85
+ tabPanel.index = index;
86
+ tabPanel.groupId = this.groupId;
87
+ tabPanel.active = this.activeIndex === index;
88
+ });
89
+ }
90
+ this.tabElements.forEach((tab, index) => {
91
+ tab.active = this.activeIndex === index;
92
+ });
93
+ }
94
+
95
+ private focusActiveTab() {
96
+ this.tabElements[this.activeIndex].focus();
97
+ }
98
+
99
+ private onKeydown = (e: KeyboardEvent) => {
100
+ switch (e.key) {
101
+ case "ArrowLeft": {
102
+ e.preventDefault();
103
+ const prev = this.activeIndex - 1;
104
+ this.activeIndex = prev < 0 ? this.tabs.length - 1 : prev;
105
+ this.focusActiveTab();
106
+ break;
107
+ }
108
+ case "ArrowRight": {
109
+ e.preventDefault();
110
+ const next = this.activeIndex + 1;
111
+ this.activeIndex = next === this.tabs.length ? 0 : next;
112
+ this.focusActiveTab();
113
+ break;
114
+ }
115
+ default:
116
+ }
117
+ };
118
+
119
+ private onResize = () => {
120
+ const allItems = this.template.querySelectorAll("dx-tab-panel-item");
121
+ const hiddenItems: number[] = [];
122
+ const primaryItems = this.template.querySelectorAll(
123
+ "dx-tab-panel-item:not(.more-btn-container)"
124
+ );
125
+ const moreBtn = this.template.querySelector(".more-btn-container")!;
126
+ const containerWidth =
127
+ this.template.querySelector(".tablist")!.offsetWidth;
128
+ let stopWidth = this.template.querySelector(
129
+ "dx-tab-panel-item.more-btn-container"
130
+ )!.offsetWidth;
131
+
132
+ this.dropdownItems = [];
133
+ allItems.forEach((item) => {
134
+ item.classList.remove("hidden");
135
+ });
136
+
137
+ primaryItems.forEach((item, i) => {
138
+ if (containerWidth >= stopWidth + item.offsetWidth) {
139
+ stopWidth += item.offsetWidth;
140
+ } else {
141
+ item.classList.add("hidden");
142
+ hiddenItems.push(i);
143
+ }
144
+ });
145
+
146
+ if (!hiddenItems.length) {
147
+ moreBtn.classList.add("hidden");
148
+ } else {
149
+ hiddenItems.forEach((i) => {
150
+ this.dropdownItems.push({ ...this._tabs[i], index: i });
151
+ });
152
+ }
153
+ };
154
+
155
+ private addListeners() {
156
+ this.template.addEventListener("keydown", this.onKeydown);
157
+ window.addEventListener("resize", this.onResize.bind(this));
158
+ }
159
+
160
+ private removeListeners() {
161
+ this.template.removeEventListener("keydown", this.onKeydown);
162
+ window.removeEventListener("resize", this.onResize.bind(this));
163
+ }
164
+ }
@@ -0,0 +1,6 @@
1
+ let idCounter = 0;
2
+
3
+ export const uniqueId = (prefix: string = "") => {
4
+ const id = ++idCounter;
5
+ return prefix + id;
6
+ };