lightning-base-components 1.14.6-alpha → 1.15.2-alpha

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 (169) hide show
  1. package/metadata/raptor.json +31 -4
  2. package/package.json +13 -2
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
  6. package/src/lightning/alert/__docs__/alert.md +99 -0
  7. package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
  8. package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
  9. package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
  10. package/src/lightning/alert/alert.html +3 -0
  11. package/src/lightning/alert/alert.js +78 -0
  12. package/src/lightning/alert/alert.js-meta.xml +6 -0
  13. package/src/lightning/baseCombobox/baseCombobox.html +2 -1
  14. package/src/lightning/baseCombobox/baseCombobox.js +41 -6
  15. package/src/lightning/button/__wdio__/utam/utam.html +3 -0
  16. package/src/lightning/button/__wdio__/utam/utam.js +3 -0
  17. package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
  18. package/src/lightning/button/button.js +22 -1
  19. package/src/lightning/buttonMenu/buttonMenu.js +12 -0
  20. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  21. package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
  22. package/src/lightning/combobox/__docs__/combobox.md +3 -1
  23. package/src/lightning/combobox/combobox.js +0 -1
  24. package/src/lightning/confirm/__docs__/confirm.md +98 -0
  25. package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
  26. package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
  27. package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
  28. package/src/lightning/confirm/confirm.html +3 -0
  29. package/src/lightning/confirm/confirm.js +80 -0
  30. package/src/lightning/confirm/confirm.js-meta.xml +6 -0
  31. package/src/lightning/datatable/__docs__/datatable.md +45 -0
  32. package/src/lightning/datatable/__wdio__/utam/utam.html +32 -0
  33. package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
  34. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +214 -0
  35. package/src/lightning/datatable/columns.js +166 -71
  36. package/src/lightning/datatable/datatable.js +103 -20
  37. package/src/lightning/datatable/headerActions.js +2 -2
  38. package/src/lightning/datatable/inlineEdit.js +0 -5
  39. package/src/lightning/datatable/inlineEditShared.js +4 -2
  40. package/src/lightning/datatable/keyboard.js +17 -13
  41. package/src/lightning/datatable/renderManager.js +45 -13
  42. package/src/lightning/datatable/resizeSensor.js +11 -3
  43. package/src/lightning/datatable/rowSelection.js +9 -3
  44. package/src/lightning/datatable/rowSelectionShared.js +33 -20
  45. package/src/lightning/datatable/rows.js +3 -2
  46. package/src/lightning/datatable/sort.js +8 -8
  47. package/src/lightning/datatable/state.js +9 -1
  48. package/src/lightning/datatable/templates/div/div.html +6 -2
  49. package/src/lightning/datatable/templates/table/table.html +7 -4
  50. package/src/lightning/datatable/tree.js +25 -0
  51. package/src/lightning/datatable/types.js +77 -9
  52. package/src/lightning/datatable/utils.js +51 -24
  53. package/src/lightning/datatable/virtualization.js +319 -0
  54. package/src/lightning/datatable/wrapText.js +54 -16
  55. package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
  56. package/src/lightning/datepicker/datepicker.html +1 -0
  57. package/src/lightning/datepicker/datepicker.js +10 -0
  58. package/src/lightning/datetimepicker/datetimepicker.html +2 -0
  59. package/src/lightning/datetimepicker/datetimepicker.js +8 -0
  60. package/src/lightning/dualListbox/dualListbox.js +2 -1
  61. package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
  62. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
  63. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
  64. package/src/lightning/formattedAddress/formattedAddress.js +7 -1
  65. package/src/lightning/groupedCombobox/groupedCombobox.html +2 -1
  66. package/src/lightning/groupedCombobox/groupedCombobox.js +16 -2
  67. package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
  68. package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
  69. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
  70. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  71. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
  72. package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
  73. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
  74. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
  75. package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
  76. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
  77. package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
  78. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
  79. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
  80. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
  81. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  82. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
  83. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
  84. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
  85. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  86. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
  87. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
  88. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
  89. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
  90. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
  91. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
  92. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  93. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
  94. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
  95. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
  96. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
  97. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  98. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
  99. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
  100. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
  101. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
  102. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
  103. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
  104. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
  105. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
  106. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
  107. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
  108. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
  109. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  110. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
  111. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
  112. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
  113. package/src/lightning/input/__docs__/input.md +2 -0
  114. package/src/lightning/input/input.html +6 -0
  115. package/src/lightning/input/input.js +2 -1
  116. package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
  117. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
  118. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
  119. package/src/lightning/inputAddress/inputAddress.html +2 -0
  120. package/src/lightning/inputAddress/inputAddress.js +26 -3
  121. package/src/lightning/inputName/__docs__/inputName.md +2 -0
  122. package/src/lightning/inputName/inputName.html +4 -1
  123. package/src/lightning/inputUtils/inputUtils.js +11 -0
  124. package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
  125. package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
  126. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
  127. package/src/lightning/menuItem/menuItem.js +4 -1
  128. package/src/lightning/modalBase/modalBase.css +20 -0
  129. package/src/lightning/modalBase/modalBase.html +54 -0
  130. package/src/lightning/modalBase/modalBase.js +1039 -0
  131. package/src/lightning/overlay/__docs__/overlay.md +90 -0
  132. package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
  133. package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
  134. package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
  135. package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
  136. package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
  137. package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
  138. package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
  139. package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
  140. package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
  141. package/src/lightning/overlay/overlay.html +3 -0
  142. package/src/lightning/overlay/overlay.js +45 -0
  143. package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
  144. package/src/lightning/overlayContainer/overlayContainer.html +3 -0
  145. package/src/lightning/overlayContainer/overlayContainer.js +138 -0
  146. package/src/lightning/overlayManager/overlayManager.js +54 -0
  147. package/src/lightning/overlayUtils/overlayUtils.js +17 -0
  148. package/src/lightning/picklist/picklist.js +6 -1
  149. package/src/lightning/progressBar/progressBar.html +2 -1
  150. package/src/lightning/progressBar/progressBar.js +18 -1
  151. package/src/lightning/prompt/__docs__/prompt.md +100 -0
  152. package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
  153. package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
  154. package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
  155. package/src/lightning/prompt/prompt.css +81 -0
  156. package/src/lightning/prompt/prompt.html +8 -0
  157. package/src/lightning/prompt/prompt.js +92 -0
  158. package/src/lightning/prompt/prompt.js-meta.xml +6 -0
  159. package/src/lightning/radioGroup/radioGroup.js +9 -0
  160. package/src/lightning/select/select.html +3 -1
  161. package/src/lightning/select/select.js +5 -1
  162. package/src/lightning/textarea/textarea.html +1 -0
  163. package/src/lightning/textarea/textarea.js +5 -0
  164. package/src/lightning/timepicker/timepicker.html +3 -1
  165. package/src/lightning/timepicker/timepicker.js +8 -0
  166. package/src/lightning/utilsPrivate/aria.js +26 -0
  167. package/src/lightning/utilsPrivate/linkify.js +1 -1
  168. package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
  169. package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
@@ -0,0 +1,90 @@
1
+ # Overlay
2
+
3
+ > Note: This component is not exposed for use by internal or external developers.
4
+
5
+ This is as low level in the overlay library as one can get. For this reason the documentation below is aimed at primarily `Lightning*` developers or those creating new overlay types. The overview examples would need much more to be fully accessible.
6
+
7
+ - Simple: Contains no wrapping HTML only a host element.
8
+ - `<c-custom-overlay>`
9
+ - Advanced: Contains a wrapping Component. Example: `LightningModal`.
10
+
11
+ ## Creating a Simple Overlay
12
+
13
+ ```js
14
+ import LightningOverlay from 'lightning/overlay';
15
+ import { instanceName } from 'lightning/overlayUtils';
16
+
17
+ class MyOverlay extends LightningOverlay {
18
+ static [instanceName] = 'my-overlay';
19
+
20
+ @api customProperty = 'Default';
21
+ }
22
+ ```
23
+
24
+ Usage for the `MyOverlay` in a custom app would like like below.
25
+
26
+ ```js
27
+ import { LightningElement } from 'lwc';
28
+ import MyOverlay from 'my/overlay';
29
+
30
+ class MyApp extends LightningElement {
31
+ async handleClick() {
32
+ const result = await MyOverlay.open({
33
+ customProperty: 'Hello World!';
34
+ });
35
+ console.log(result);
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Creating an Wrapping Component
41
+
42
+ Other scenarios require wrapping HTML around the overlay component. Most commonly this is used to position an element. A common example is `LightningModal`, but alternatively this can be used for writing a shared `LightningMenu`.
43
+
44
+ The `LightningMenuBase` component works as a wrapper.
45
+
46
+ ```html
47
+ <template>
48
+ <ul data-slot lwc:dom="manual"></ul>
49
+ </template>
50
+ ```
51
+
52
+ ```js
53
+
54
+ ```
55
+
56
+ The `LightningMenu` now looks like...
57
+
58
+ ```html
59
+
60
+ ```
61
+
62
+ ```js
63
+
64
+ ```
65
+
66
+ Usage for the `MyMenu` in a custom app would like like below.
67
+
68
+ ```html
69
+ <template>
70
+ <button click="{handleClick}">{label}</button>
71
+ </template>
72
+ ```
73
+
74
+ ```js
75
+ import { LightningElement, api } from 'lwc';
76
+ import MyMenu from 'my/overlay';
77
+
78
+ class MyButtonMenu extends LightningElement {
79
+ @api label = 'Dropdown';
80
+
81
+ async handleClick(e) {
82
+ const result = await MyMenu.open({
83
+ source: e.target,
84
+ options: ['Item 1'];
85
+ });
86
+ // The selected item
87
+ console.log(result);
88
+ }
89
+ }
90
+ ```
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <lightning-focus-trap>
3
+ <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
4
+ aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open slds-modal_small">
5
+ <div class="slds-modal__container">
6
+ <header class="slds-modal__header">
7
+ <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
8
+ title="Close" onclick={handleDismiss}>
9
+ <svg class="slds-button__icon slds-button__icon_large" aria-hidden="true">
10
+ <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
11
+ </svg>
12
+ <span class="slds-assistive-text">Close</span>
13
+ </button>
14
+ <h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">{header}</h2>
15
+ </header>
16
+ <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
17
+ <p>{body}</p>
18
+ </div>
19
+ <footer class="slds-modal__footer">
20
+ <button class="slds-button slds-button_neutral" onclick={handleCancel}>{cancelText}</button>
21
+ <button class="slds-button slds-button_brand" onclick={handleOkay}>{okayText}</button>
22
+ </footer>
23
+ </div>
24
+ </section>
25
+ </lightning-focus-trap>
26
+ <div class="slds-backdrop slds-backdrop_open"></div>
27
+ </template>
@@ -0,0 +1,33 @@
1
+ import { api } from 'lwc';
2
+ import LightningOverlay from 'lightning/overlay';
3
+
4
+ export default class OverlayAlert extends LightningOverlay {
5
+ @api header = 'Header';
6
+
7
+ @api body = 'Body';
8
+
9
+ @api okayText = 'Okay';
10
+
11
+ @api cancelText = 'Cancel';
12
+
13
+ handleOkay() {
14
+ this.close('okay');
15
+ }
16
+
17
+ handleCancel() {
18
+ this.close('cancel');
19
+ }
20
+
21
+ handleDismiss() {
22
+ this.close('dismiss');
23
+ }
24
+
25
+ hasFocus = false;
26
+ renderedCallback() {
27
+ if (!this.hasFocus) {
28
+ const close = this.template.querySelector('header > button');
29
+ close.focus();
30
+ this.hasFocus = true;
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,7 @@
1
+ .example {
2
+ margin: 0.5rem;
3
+ border-radius: 0.5rem;
4
+ background: #FFF;
5
+ box-shadow: 0 1px 0.25rem rgba(0, 0, 0, 0.2);
6
+ padding: 1rem;
7
+ }
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div class="example">
3
+ <button onclick={handleConfirmModal}>Open a Confirm Modal</button>
4
+ <p>Result: <code>{confirmResult}</code></p>
5
+ </div>
6
+ <div class="example">
7
+ <button onclick={handleConfirmAltModal}>Open a Confirm Modal Alt</button>
8
+ <p>Result: <code>{confirmAltResult}</code></p>
9
+ </div>
10
+ <div class="example">
11
+ <button onclick={handleDemoModal}>Open a Demo Modal</button>
12
+ <p>Result: <code>{demoResult}</code></p>
13
+ </div>
14
+ <div class="example">
15
+ <button onclick={handlePanel}>Open a Panel</button>
16
+ <p>Result: <code>{panelResult}</code></p>
17
+ </div>
18
+ </template>
@@ -0,0 +1,61 @@
1
+ import { LightningElement } from 'lwc';
2
+
3
+ import OverlayAlert from 'overlay/alert';
4
+ import OverlayDemo from 'overlay/demo';
5
+ import OverlayPanel from 'overlay/panel';
6
+
7
+ export default class OverlayBasic extends LightningElement {
8
+ confirmResult = 'unset';
9
+
10
+ handleConfirmModal() {
11
+ OverlayAlert.open({
12
+ header: 'Are you sure?',
13
+ body: 'Click cancel or okay below to get a string result.',
14
+ }).then((result) => {
15
+ this.confirmResult = result;
16
+ });
17
+ }
18
+
19
+ confirmAltResult = 'unset';
20
+
21
+ handleConfirmAltModal() {
22
+ OverlayAlert.open({
23
+ header: 'Do you like this demo?',
24
+ body: '...',
25
+ okayText: 'Yes',
26
+ cancelText: 'Also Yes',
27
+ }).then((result) => {
28
+ this.confirmAltResult = result;
29
+ });
30
+ }
31
+
32
+ demoResult = 'unset';
33
+
34
+ handleDemoModal() {
35
+ OverlayDemo.open({
36
+ header: 'Select an Option',
37
+ body: 'From the list below select an item',
38
+ options: [
39
+ { id: 1, label: 'Option 1' },
40
+ { id: 2, label: 'Option 2' },
41
+ ],
42
+ }).then((result) => {
43
+ if (result === 0) {
44
+ this.demoResult = 'dismiss';
45
+ } else {
46
+ this.demoResult = result;
47
+ }
48
+ });
49
+ }
50
+
51
+ panelResult = 'unset';
52
+
53
+ handlePanel() {
54
+ OverlayPanel.open({
55
+ header: 'Select an Option',
56
+ body: 'From the list below select an item',
57
+ }).then((result) => {
58
+ this.demoResult = result;
59
+ });
60
+ }
61
+ }
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
3
+ aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
4
+ <div class="slds-modal__container">
5
+ <header class="slds-modal__header">
6
+ <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={handleDismiss}>
7
+ <svg class="slds-button__icon slds-button__icon_large" aria-hidden="true">
8
+ <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
9
+ </svg>
10
+ <span class="slds-assistive-text">Close</span>
11
+ </button>
12
+ <h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">{header}</h2>
13
+ </header>
14
+ <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
15
+ <p>{body}</p>
16
+ <ul>
17
+ <template for:each={options} for:item="option">
18
+ <li key={option.id}>
19
+ <button onclick={handleOptionClick} data-id={option.id}>
20
+ {option.label}
21
+ </button>
22
+ </li>
23
+ </template>
24
+ </ul>
25
+ </div>
26
+ </div>
27
+ </section>
28
+ <div class="slds-backdrop slds-backdrop_open"></div>
29
+ </template>
@@ -0,0 +1,40 @@
1
+ import { api } from 'lwc';
2
+
3
+ import LightningOverlay from 'lightning/overlay';
4
+ import OverlayAlert from 'overlay/alert';
5
+
6
+ export default class OverlayDemo extends LightningOverlay {
7
+ @api header = 'Header';
8
+
9
+ @api body = 'Body';
10
+
11
+ @api options = [];
12
+
13
+ handleOptionClick(e) {
14
+ const { target } = e;
15
+ const id = parseInt(target.dataset.id, 10);
16
+ const option = this.options.find((x) => x.id === id);
17
+ OverlayAlert.open({
18
+ header: 'Are you sure?',
19
+ body: `You selected "${option.label}".`,
20
+ okayText: `Yes, ${option.label}`,
21
+ }).then((result) => {
22
+ if (result === 'okay') {
23
+ this.close(parseInt(target.dataset.id, 10));
24
+ }
25
+ });
26
+ }
27
+
28
+ handleDismiss() {
29
+ this.close(0);
30
+ }
31
+
32
+ hasFocus = false;
33
+ renderedCallback() {
34
+ if (!this.hasFocus) {
35
+ const close = this.template.querySelector('header > button');
36
+ close.focus();
37
+ this.hasFocus = true;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <lightning-focus-trap>
3
+ <div class="slds-panel slds-size_medium slds-panel_docked slds-panel_docked-left slds-is-open" aria-hidden="false">
4
+ <div class="slds-panel__header">
5
+ <h2 class="slds-panel__header-title slds-text-heading_small slds-truncate" title="Panel Header">{header}</h2>
6
+ <button class="slds-button slds-button_icon slds-button_icon-small slds-panel__close" title="Collapse Panel Header" onclick={handleDismiss}>
7
+ <svg class="slds-button__icon" aria-hidden="true">
8
+ <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
9
+ </svg>
10
+ <span class="slds-assistive-text">Collapse Panel Header</span>
11
+ </button>
12
+ </div>
13
+ <div class="slds-panel__body">{body}</div>
14
+ </div>
15
+ </lightning-focus-trap>
16
+ <!-- <div class="slds-backdrop slds-backdrop_open"></div>-->
17
+ </template>
@@ -0,0 +1,21 @@
1
+ import { api } from 'lwc';
2
+ import LightningOverlay from 'lightning/overlay';
3
+
4
+ export default class OverlayPanel extends LightningOverlay {
5
+ @api header = 'Header';
6
+
7
+ @api body = 'Body';
8
+
9
+ handleDismiss() {
10
+ this.close('dismiss');
11
+ }
12
+
13
+ hasFocus = false;
14
+ renderedCallback() {
15
+ if (!this.hasFocus) {
16
+ const close = this.template.querySelector('div > button');
17
+ close.focus();
18
+ this.hasFocus = true;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <!-- This template is overridden when the class is extended. -->
3
+ </template>
@@ -0,0 +1,45 @@
1
+ import { LightningElement, createElement, api } from 'lwc';
2
+ import { instanceName } from 'lightning/overlayUtils';
3
+ import OverlayContainer from 'lightning/overlayContainer';
4
+
5
+ const ROOT = 'body';
6
+ const OVERLAY_CONTAINER = 'lightning-overlay-container';
7
+
8
+ function container() {
9
+ // eslint-disable-next-line @lwc/lwc/no-document-query
10
+ let element = document.querySelector(`${ROOT} > ${OVERLAY_CONTAINER}`);
11
+ if (!element) {
12
+ element = createElement(OVERLAY_CONTAINER, { is: OverlayContainer });
13
+ document.body.appendChild(element);
14
+ }
15
+ return element;
16
+ }
17
+
18
+ /**
19
+ * Extend this component for open/close apis.
20
+ */
21
+ export default class LightningOverlay extends LightningElement {
22
+ /**
23
+ * Easier to debug when dynamically created.
24
+ */
25
+ static [instanceName] = 'lightning-overlay';
26
+
27
+ /**
28
+ * Open a modal instance
29
+ *
30
+ * @param {Object} apis Set apis directly on the modal instance
31
+ */
32
+ static open(apis) {
33
+ return container().push(this, apis);
34
+ }
35
+
36
+ /**
37
+ * The close api is public for testing only.
38
+ *
39
+ * @param {any} result Returned in the promise.
40
+ */
41
+ @api
42
+ close(result, promise) {
43
+ container().pop(this.template.host, result, promise);
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div lwc:dom="manual"></div>
3
+ </template>
@@ -0,0 +1,138 @@
1
+ import { LightningElement, api, createElement } from 'lwc';
2
+ import { parent, instanceName } from 'lightning/overlayUtils';
3
+ import {
4
+ addOverlay,
5
+ LwcOverlayType,
6
+ subscribeOverlay,
7
+ } from 'lightning/overlayManager';
8
+
9
+ export default class LightningOverlayContainer extends LightningElement {
10
+ // [{ element, parentElement, resolve }, ...]
11
+ stack = [];
12
+
13
+ get root() {
14
+ return this.template.querySelector('div');
15
+ }
16
+
17
+ /**
18
+ * Generate a new modal with params and return promise.
19
+ *
20
+ * @param {LightningModal} scope LightningOverlay extended class
21
+ * @param {Object} apis key value pair of apis to assign
22
+ */
23
+ @api
24
+ push(scope, apis) {
25
+ apis = apis || {};
26
+
27
+ if (typeof apis !== 'object') {
28
+ throw new Error('Invalid .open() or .open({}) argument.');
29
+ }
30
+ const { [instanceName]: overlayInstanceName, [parent]: overlayParent } =
31
+ scope;
32
+ const element = createElement(overlayInstanceName, { is: scope });
33
+
34
+ Object.entries(apis).forEach(([key, value]) => {
35
+ const keyLower = key.toLowerCase();
36
+ const match = keyLower.match(/^on(.+)/);
37
+ if (match) {
38
+ const eventName = match[1];
39
+ element.addEventListener(eventName, value);
40
+ } else {
41
+ element[key] = value;
42
+ }
43
+ });
44
+
45
+ let promise = null;
46
+ if (overlayParent) {
47
+ // Ex: extends LightningModal with wrapping LightningModalBase
48
+ const parentElement = createElement(overlayParent[instanceName], {
49
+ is: overlayParent,
50
+ });
51
+ this.root.appendChild(parentElement);
52
+ parentElement.defaultSlot.appendChild(element);
53
+ promise = new Promise((resolve) => {
54
+ this.stack.push({ resolve, element, parentElement });
55
+ });
56
+ } else {
57
+ this.root.appendChild(element);
58
+ promise = new Promise((resolve) => {
59
+ this.stack.push({ resolve, element });
60
+ });
61
+ }
62
+ // Aura Compatability
63
+ addOverlay(LwcOverlayType);
64
+ return promise;
65
+ }
66
+
67
+ /**
68
+ * Remove the last added popover.
69
+ */
70
+ @api
71
+ pop(ele, result, promise) {
72
+ // element = `extends LightningOverlay`
73
+ // parentElement = Ex: LightningModalBase
74
+ const { element, parentElement, resolve } = this.stack.find(
75
+ ({ element: e }) => e === ele
76
+ );
77
+ // Resolve immediately
78
+ resolve(result);
79
+ // Animate out. Ex: LightningModal slide up animation
80
+ if (promise) {
81
+ promise.then(() => {
82
+ this.removeOverlay(element, parentElement);
83
+ });
84
+ } else {
85
+ this.removeOverlay(element, parentElement);
86
+ }
87
+ // Remove from stack
88
+ this.stack = this.stack.filter(({ element: e }) => e !== ele);
89
+ }
90
+
91
+ /**
92
+ * Remove overlay (with IE11 support)
93
+ *
94
+ * @param {LightningModal} element Required
95
+ * @param {LightningElement} parentElement Optional
96
+ */
97
+ removeOverlay(element, parentElement) {
98
+ if (parentElement && parentElement.remove) {
99
+ parentElement.remove();
100
+ } else if (parentElement) {
101
+ parentElement.parentNode.removeChild(parentElement);
102
+ } else if (element.remove) {
103
+ element.remove();
104
+ } else {
105
+ element.parentNode.removeChild(element);
106
+ }
107
+ }
108
+
109
+ connectedCallback() {
110
+ // Notified anytime a overlay is added/removed
111
+ // zIndex assumes aura modals stack every other
112
+ subscribeOverlay((stack) => {
113
+ // LWC Overlays are always on odd zIndexes, aura even
114
+ let zIndex = 9001;
115
+ let modalCount = 0;
116
+
117
+ stack.forEach((overlayType) => {
118
+ if (overlayType === LwcOverlayType) {
119
+ const overlay = this.root.childNodes[modalCount];
120
+ if (overlay) {
121
+ overlay.style.zIndex = zIndex;
122
+ // ToDo: Refactor for LightningPanel
123
+ overlay.style.position = 'absolute';
124
+ }
125
+ modalCount += 1;
126
+ } else {
127
+ zIndex += 2;
128
+ }
129
+ });
130
+ });
131
+ }
132
+
133
+ // After this is fixed jest tests do not need clearOverlays()
134
+ // https://github.com/salesforce/lwc/issues/1102
135
+ // disconnectedCallback() {
136
+ // clearOverlays();
137
+ // }
138
+ }
@@ -0,0 +1,54 @@
1
+ // Track order of modals opening
2
+ const state = {
3
+ stack: [],
4
+ callback: null,
5
+ hasAura: false,
6
+ };
7
+
8
+ export const LwcOverlayType = 'lwc';
9
+ export const AuraOverlayType = 'aura';
10
+
11
+ function triggerCallback() {
12
+ // Not triggered in pure LWC environment
13
+ if (state.callback) {
14
+ state.callback(state.stack);
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Add an overlay to the stack
20
+ */
21
+ export function addOverlay(overlayType) {
22
+ // Prevent unnecessary z-index in pure LWC
23
+ if (overlayType === AuraOverlayType) {
24
+ state.hasAura = true;
25
+ }
26
+ state.stack.push(overlayType);
27
+ triggerCallback();
28
+ }
29
+
30
+ /**
31
+ * Remove overlay from the stack
32
+ */
33
+ export function removeOverlay() {
34
+ state.stack.pop();
35
+ triggerCallback();
36
+ }
37
+
38
+ /**
39
+ * LightningOverlayContainer listener
40
+ *
41
+ * Only for LightningContainer usage
42
+ */
43
+ export function subscribeOverlay(callback) {
44
+ state.callback = callback;
45
+ triggerCallback();
46
+ }
47
+
48
+ /**
49
+ * TEST ONLY! Clear stack and reset hasAura
50
+ */
51
+ export function clearOverlays() {
52
+ state.stack = [];
53
+ state.hasAura = false;
54
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Optional static parent definition on extended LightningOverlay
3
+ * Ex: static [parent] = CustomOverlayBase;
4
+ */
5
+ export const parent = Symbol('parent');
6
+
7
+ /**
8
+ * Optional static instanceName for CustomOverlayBase;
9
+ * Ex: static [instanceName] = 'custom-overlay';
10
+ * This makes it easier to debug in the dom.
11
+ */
12
+ export const instanceName = Symbol('instanceName');
13
+
14
+ /**
15
+ * Secure access to events
16
+ */
17
+ export const secure = Symbol('secure event');
@@ -31,6 +31,7 @@ export default class LightningPicklist extends LightningElement {
31
31
  @api placeholder;
32
32
  @api variant;
33
33
  @api autocomplete = 'off';
34
+ @api suppressNoneOption;
34
35
 
35
36
  set fieldLevelHelp(value) {
36
37
  this._fieldLevelHelp = value;
@@ -86,6 +87,7 @@ export default class LightningPicklist extends LightningElement {
86
87
  // reset the flag that hides the required indicator when we have no options
87
88
  this._requiredButDisabled = false;
88
89
  }
90
+
89
91
  @api
90
92
  get required() {
91
93
  return this._required;
@@ -293,7 +295,10 @@ export default class LightningPicklist extends LightningElement {
293
295
  // We could have set required=false if the picklist had no options, see updateDisabledState and updateRequiredState
294
296
  const isRequiredPicklist = this.required || this._requiredButDisabled;
295
297
 
296
- if (isRequiredPicklist && numberOfOptions === 1) {
298
+ if (
299
+ this.suppressNoneOption ||
300
+ (isRequiredPicklist && numberOfOptions === 1)
301
+ ) {
297
302
  return false;
298
303
  }
299
304
 
@@ -4,7 +4,8 @@
4
4
  aria-valuemax="100"
5
5
  aria-valuenow={percentValue}
6
6
  aria-busy={ariaBusy}
7
- role="progressbar">
7
+ role="progressbar"
8
+ aria-label={computeAriaLabel}>
8
9
  <span class="slds-progress-bar__value" style={computedStyle}>
9
10
  <span class="slds-assistive-text">{assistiveText}</span>
10
11
  </span>