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.
- package/metadata/raptor.json +31 -4
- package/package.json +13 -2
- package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
- package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
- package/src/lightning/alert/__docs__/alert.md +99 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/alert/alert.html +3 -0
- package/src/lightning/alert/alert.js +78 -0
- package/src/lightning/alert/alert.js-meta.xml +6 -0
- package/src/lightning/baseCombobox/baseCombobox.html +2 -1
- package/src/lightning/baseCombobox/baseCombobox.js +41 -6
- package/src/lightning/button/__wdio__/utam/utam.html +3 -0
- package/src/lightning/button/__wdio__/utam/utam.js +3 -0
- package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
- package/src/lightning/button/button.js +22 -1
- package/src/lightning/buttonMenu/buttonMenu.js +12 -0
- package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
- package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
- package/src/lightning/combobox/__docs__/combobox.md +3 -1
- package/src/lightning/combobox/combobox.js +0 -1
- package/src/lightning/confirm/__docs__/confirm.md +98 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/confirm/confirm.html +3 -0
- package/src/lightning/confirm/confirm.js +80 -0
- package/src/lightning/confirm/confirm.js-meta.xml +6 -0
- package/src/lightning/datatable/__docs__/datatable.md +45 -0
- package/src/lightning/datatable/__wdio__/utam/utam.html +32 -0
- package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
- package/src/lightning/datatable/__wdio__/utam/utam.spec.js +214 -0
- package/src/lightning/datatable/columns.js +166 -71
- package/src/lightning/datatable/datatable.js +103 -20
- package/src/lightning/datatable/headerActions.js +2 -2
- package/src/lightning/datatable/inlineEdit.js +0 -5
- package/src/lightning/datatable/inlineEditShared.js +4 -2
- package/src/lightning/datatable/keyboard.js +17 -13
- package/src/lightning/datatable/renderManager.js +45 -13
- package/src/lightning/datatable/resizeSensor.js +11 -3
- package/src/lightning/datatable/rowSelection.js +9 -3
- package/src/lightning/datatable/rowSelectionShared.js +33 -20
- package/src/lightning/datatable/rows.js +3 -2
- package/src/lightning/datatable/sort.js +8 -8
- package/src/lightning/datatable/state.js +9 -1
- package/src/lightning/datatable/templates/div/div.html +6 -2
- package/src/lightning/datatable/templates/table/table.html +7 -4
- package/src/lightning/datatable/tree.js +25 -0
- package/src/lightning/datatable/types.js +77 -9
- package/src/lightning/datatable/utils.js +51 -24
- package/src/lightning/datatable/virtualization.js +319 -0
- package/src/lightning/datatable/wrapText.js +54 -16
- package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
- package/src/lightning/datepicker/datepicker.html +1 -0
- package/src/lightning/datepicker/datepicker.js +10 -0
- package/src/lightning/datetimepicker/datetimepicker.html +2 -0
- package/src/lightning/datetimepicker/datetimepicker.js +8 -0
- package/src/lightning/dualListbox/dualListbox.js +2 -1
- package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/formattedAddress/formattedAddress.js +7 -1
- package/src/lightning/groupedCombobox/groupedCombobox.html +2 -1
- package/src/lightning/groupedCombobox/groupedCombobox.js +16 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/input/__docs__/input.md +2 -0
- package/src/lightning/input/input.html +6 -0
- package/src/lightning/input/input.js +2 -1
- package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/inputAddress/inputAddress.html +2 -0
- package/src/lightning/inputAddress/inputAddress.js +26 -3
- package/src/lightning/inputName/__docs__/inputName.md +2 -0
- package/src/lightning/inputName/inputName.html +4 -1
- package/src/lightning/inputUtils/inputUtils.js +11 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
- package/src/lightning/menuItem/menuItem.js +4 -1
- package/src/lightning/modalBase/modalBase.css +20 -0
- package/src/lightning/modalBase/modalBase.html +54 -0
- package/src/lightning/modalBase/modalBase.js +1039 -0
- package/src/lightning/overlay/__docs__/overlay.md +90 -0
- package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
- package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
- package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
- package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
- package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
- package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
- package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
- package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
- package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
- package/src/lightning/overlay/overlay.html +3 -0
- package/src/lightning/overlay/overlay.js +45 -0
- package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
- package/src/lightning/overlayContainer/overlayContainer.html +3 -0
- package/src/lightning/overlayContainer/overlayContainer.js +138 -0
- package/src/lightning/overlayManager/overlayManager.js +54 -0
- package/src/lightning/overlayUtils/overlayUtils.js +17 -0
- package/src/lightning/picklist/picklist.js +6 -1
- package/src/lightning/progressBar/progressBar.html +2 -1
- package/src/lightning/progressBar/progressBar.js +18 -1
- package/src/lightning/prompt/__docs__/prompt.md +100 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
- package/src/lightning/prompt/prompt.css +81 -0
- package/src/lightning/prompt/prompt.html +8 -0
- package/src/lightning/prompt/prompt.js +92 -0
- package/src/lightning/prompt/prompt.js-meta.xml +6 -0
- package/src/lightning/radioGroup/radioGroup.js +9 -0
- package/src/lightning/select/select.html +3 -1
- package/src/lightning/select/select.js +5 -1
- package/src/lightning/textarea/textarea.html +1 -0
- package/src/lightning/textarea/textarea.js +5 -0
- package/src/lightning/timepicker/timepicker.html +3 -1
- package/src/lightning/timepicker/timepicker.js +8 -0
- package/src/lightning/utilsPrivate/aria.js +26 -0
- package/src/lightning/utilsPrivate/linkify.js +1 -1
- package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
- package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import labelProgress from '@salesforce/label/LightningProgressBar.progress';
|
|
2
|
+
import labelProgressBar from '@salesforce/label/LightningProgressBar.progressBar';
|
|
2
3
|
|
|
3
4
|
import { LightningElement, track, api } from 'lwc';
|
|
4
5
|
import { classSet } from 'lightning/utils';
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
normalizeString as normalize,
|
|
8
|
+
isUndefinedOrNull,
|
|
9
|
+
} from 'lightning/utilsPrivate';
|
|
6
10
|
import { numberFormat } from 'lightning/internationalizationLibrary';
|
|
7
11
|
|
|
8
12
|
// Temporary workaround until we get real label support. New label entries must
|
|
@@ -10,6 +14,7 @@ import { numberFormat } from 'lightning/internationalizationLibrary';
|
|
|
10
14
|
// https://git.soma.salesforce.com/raptor/raptor/issues/196
|
|
11
15
|
const i18n = {
|
|
12
16
|
progress: labelProgress,
|
|
17
|
+
progressBar: labelProgressBar,
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
const DEFAULT_SIZE = 'medium';
|
|
@@ -29,6 +34,12 @@ export default class LightningProgressBar extends LightningElement {
|
|
|
29
34
|
*/
|
|
30
35
|
@api value = 0;
|
|
31
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Describes the input to assistive technologies.
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
@api ariaLabel;
|
|
42
|
+
|
|
32
43
|
/**
|
|
33
44
|
* The variant changes the appearance of the progress bar.
|
|
34
45
|
* Accepted variants include base or circular.
|
|
@@ -109,4 +120,10 @@ export default class LightningProgressBar extends LightningElement {
|
|
|
109
120
|
|
|
110
121
|
return `${i18n.progress} ${formattedPercent}`;
|
|
111
122
|
}
|
|
123
|
+
|
|
124
|
+
get computeAriaLabel() {
|
|
125
|
+
return isUndefinedOrNull(this.ariaLabel)
|
|
126
|
+
? i18n.progressBar
|
|
127
|
+
: this.ariaLabel;
|
|
128
|
+
}
|
|
112
129
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
The `lightning/prompt` module lets you create an prompt modal within your component. Use `LightningPrompt` on your components to ask the user to provide information before they continue.
|
|
2
|
+
|
|
3
|
+
Use `LightningPrompt.open()` instead of the native `window.prompt()` for a more consistent user experience. They have similar functions, but `LightningPrompt.open()` works in cross-origin iframes, where the `.prompt()` method is no longer supported in Chrome and Safari. Unlike `window.prompt()`, `LightningPrompt.open()` doesn't halt execution on the page, it returns a Promise. Use `async`/`await` or `.then()` for any code you want to execute after the prompt has closed.
|
|
4
|
+
|
|
5
|
+
Import `LightningPrompt` from the `lightning/prompt` module in the component that will launch the prompt modal, and call `LightningPrompt.open()` with your desired attributes.
|
|
6
|
+
|
|
7
|
+
This example creates a prompt modal with a header, message, and two buttons. If you enter text and click **OK** in the prompt, the `.open()` function returns a promise that resolves to the input value. If you click **Cancel**, the function returns a promise that resolves to `null`.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<!-- c/myApp.html -->
|
|
11
|
+
<template>
|
|
12
|
+
<lightning-button onclick="{handlePromptClick}" label="Open Prompt Modal">
|
|
13
|
+
</lightning-button>
|
|
14
|
+
</template>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { LightningElement } from 'lwc';
|
|
19
|
+
import LightningPrompt from 'lightning/prompt';
|
|
20
|
+
|
|
21
|
+
export default class MyApp extends LightningElement {
|
|
22
|
+
handlePromptClick() {
|
|
23
|
+
LightningPrompt.open({
|
|
24
|
+
message: 'this is the prompt message',
|
|
25
|
+
//theme defaults to "default"
|
|
26
|
+
label: 'Please Respond', // this is the header text
|
|
27
|
+
defaultValue: 'initial input value', //this is optional
|
|
28
|
+
}).then((result) => {
|
|
29
|
+
//Prompt has been closed
|
|
30
|
+
//result is input text if OK clicked
|
|
31
|
+
//and null if cancel was clicked
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Component Styling
|
|
38
|
+
|
|
39
|
+
This component uses the Salesforce Lightning Design System (SLDS) [`prompt` blueprint](https://www.lightningdesignsystem.com/components/prompt/#site-main-content).
|
|
40
|
+
|
|
41
|
+
`LightningPrompt` supports the following attributes:
|
|
42
|
+
|
|
43
|
+
- `message`: Message text that displays in the prompt.
|
|
44
|
+
- `defaultValue`: Optional. Initial leading text for the input text box.
|
|
45
|
+
- `label`: Header text, also used as the `aria-label`. Default string is `Prompt`.
|
|
46
|
+
- `variant`: Two values, `header` and `headerless`. Default value is `header`.
|
|
47
|
+
- `theme`: Color theme for the header. The `theme` attribute supports the following [options](https://www.lightningdesignsystem.com/utilities/themes/#site-main-content) from SLDS:
|
|
48
|
+
- `default`: white
|
|
49
|
+
- `shade`: gray
|
|
50
|
+
- `inverse`: dark blue
|
|
51
|
+
- `alt-inverse`: darker blue
|
|
52
|
+
- `success`: green
|
|
53
|
+
- `info`: gray-ish blue
|
|
54
|
+
- `warning`: yellow
|
|
55
|
+
- `error`: red
|
|
56
|
+
- `offline`: black
|
|
57
|
+
|
|
58
|
+
If an invalid value is provided, `LightningPrompt` uses the `default` theme.
|
|
59
|
+
|
|
60
|
+
#### Testing Your Component's Prompt
|
|
61
|
+
|
|
62
|
+
Code using `LightningPrompt` can be tested by mocking the `LightningPrompt.open()` method.
|
|
63
|
+
|
|
64
|
+
The example below uses a button to open a prompt dialog and sets the result in a template.
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<button data-button onclick="{handleClick}">Open Prompt</button>
|
|
68
|
+
<div data-result>{result}</div>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
import LightningPrompt from 'lightning/prompt';
|
|
73
|
+
jest.mock('lightning/prompt');
|
|
74
|
+
|
|
75
|
+
test(() => {
|
|
76
|
+
// Create and appendChild(element)
|
|
77
|
+
|
|
78
|
+
const buttonEle = element.shadowRoot.querySelector('[data-button]');
|
|
79
|
+
const resultEle = element.shadowRoot.querySelector('[data-result]');
|
|
80
|
+
|
|
81
|
+
// Mock .open()
|
|
82
|
+
// Pass string representing input text if testing when user clicks "OK"
|
|
83
|
+
// Pass null if testing when user clicks "Cancel"
|
|
84
|
+
LightningPrompt.open = jest.fn().mockResolvedValue('test value');
|
|
85
|
+
// Initial value
|
|
86
|
+
expect(resultEle.textContent).toBe('unknown');
|
|
87
|
+
// Click modal open button
|
|
88
|
+
buttonEle.click();
|
|
89
|
+
|
|
90
|
+
// Click handler render cycle
|
|
91
|
+
await Promise.resolve();
|
|
92
|
+
// Render cycle triggered by tracked value {result}
|
|
93
|
+
await Promise.resolve();
|
|
94
|
+
|
|
95
|
+
// Verify result is set in the template
|
|
96
|
+
expect(resultEle.textContent).toBe('test value');
|
|
97
|
+
// Open triggered once
|
|
98
|
+
expect(LightningPrompt.open.mock.calls).toHaveLength(1);
|
|
99
|
+
})
|
|
100
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LightningElement } from 'lwc';
|
|
2
|
+
import LightningPrompt from 'lightning/prompt';
|
|
3
|
+
|
|
4
|
+
export default class PromptBasic extends LightningElement {
|
|
5
|
+
handlePromptModal() {
|
|
6
|
+
LightningPrompt.open({
|
|
7
|
+
message: 'this is the prompt message',
|
|
8
|
+
defaultValue: 'test',
|
|
9
|
+
label: 'Please Respond',
|
|
10
|
+
// use default theme
|
|
11
|
+
}).then((result) => {
|
|
12
|
+
console.log('prompt result', result);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.slds-form-element__label {
|
|
2
|
+
overflow-wrap: break-word;
|
|
3
|
+
word-wrap: break-word;
|
|
4
|
+
-webkit-hyphens: auto;
|
|
5
|
+
-ms-hyphens: auto;
|
|
6
|
+
hyphens: auto;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
color: #444444;
|
|
9
|
+
font-size: 0.75rem;
|
|
10
|
+
padding-right: 0.5rem;
|
|
11
|
+
padding-top: 0.25rem;
|
|
12
|
+
margin-bottom: 0.125rem;
|
|
13
|
+
}
|
|
14
|
+
.slds-form-element__label:empty {
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.slds-no-flex {
|
|
19
|
+
-webkit-box-flex: 0;
|
|
20
|
+
-ms-flex: none;
|
|
21
|
+
flex: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.slds-form-element__control {
|
|
25
|
+
clear: left;
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.slds-grow {
|
|
30
|
+
-webkit-box-flex: 1;
|
|
31
|
+
-ms-flex-positive: 1;
|
|
32
|
+
flex-grow: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.slds-input {
|
|
36
|
+
padding-top: 0;
|
|
37
|
+
padding-right: var(--slds-c-input-spacing-horizontal-end, var(--sds-c-input-spacing-horizontal-end, 1rem));
|
|
38
|
+
padding-bottom: 0;
|
|
39
|
+
padding-left: var(--slds-c-input-spacing-horizontal-start, var(--sds-c-input-spacing-horizontal-start, 0.75rem));
|
|
40
|
+
width: 100%;
|
|
41
|
+
min-height: calc(1.875rem + (1px * 2));
|
|
42
|
+
line-height: 1.875rem;
|
|
43
|
+
border: 1px solid var(--slds-c-input-color-border, var(--sds-c-input-color-border, #c9c9c9));
|
|
44
|
+
border-radius: var(--slds-c-input-radius-border, var(--sds-c-input-radius-border, 0.25rem));
|
|
45
|
+
background-color: var(--slds-c-input-color-background, var(--sds-c-input-color-background, white));
|
|
46
|
+
color: var(--slds-c-input-text-color, var(--sds-c-input-text-color));
|
|
47
|
+
-webkit-box-shadow: var(--slds-c-input-shadow, var(--sds-c-input-shadow));
|
|
48
|
+
box-shadow: var(--slds-c-input-shadow, var(--sds-c-input-shadow));
|
|
49
|
+
-webkit-transition: border 0.1s linear, background-color 0.1s linear;
|
|
50
|
+
transition: border 0.1s linear, background-color 0.1s linear;
|
|
51
|
+
display: inline-block;
|
|
52
|
+
}
|
|
53
|
+
.slds-input:focus,
|
|
54
|
+
.slds-input:active {
|
|
55
|
+
/*! @css-var-fallback border-color */
|
|
56
|
+
border-color: var(--sds-c-input-color-border-focus, #1b96ff);
|
|
57
|
+
/*! @css-var-fallback background-color */
|
|
58
|
+
background-color: var(
|
|
59
|
+
--sds-c-input-color-background-focus,
|
|
60
|
+
var(--sds-c-input-color-background, white)
|
|
61
|
+
);
|
|
62
|
+
color: var(--sds-c-input-text-color-focus);
|
|
63
|
+
/*! @css-var-fallback box-shadow */
|
|
64
|
+
-webkit-box-shadow: var(--sds-c-input-shadow-focus, 0 0 3px #0176d3);
|
|
65
|
+
box-shadow: var(--sds-c-input-shadow-focus, 0 0 3px #0176d3);
|
|
66
|
+
outline: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
input {
|
|
70
|
+
line-height: normal;
|
|
71
|
+
color: inherit;
|
|
72
|
+
font: inherit;
|
|
73
|
+
margin: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
*,
|
|
77
|
+
*:before,
|
|
78
|
+
*:after {
|
|
79
|
+
-webkit-box-sizing: border-box;
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { api } from 'lwc';
|
|
2
|
+
import LightningInteractiveDialogBase from 'lightning/interactiveDialogBase';
|
|
3
|
+
import { parent, instanceName, secure } from 'lightning/overlayUtils';
|
|
4
|
+
import LightningOverlay from 'lightning/overlay';
|
|
5
|
+
import labelDefault from '@salesforce/label/LightningPrompt.defaultLabel';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a prompt modal within your component that asks the
|
|
9
|
+
* user to provide information before they continue.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export default class LightningPrompt extends LightningOverlay {
|
|
13
|
+
static [instanceName] = 'lightning-prompt';
|
|
14
|
+
static [parent] = LightningInteractiveDialogBase;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* value to use for header text in "header" variant
|
|
18
|
+
* or aria-label in "headerless" variant
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @default "Prompt" (translated accordingly)
|
|
21
|
+
*/
|
|
22
|
+
@api label = labelDefault;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* text to display in modal
|
|
26
|
+
*/
|
|
27
|
+
@api message = '';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* default value for input
|
|
31
|
+
*/
|
|
32
|
+
@api defaultValue = '';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* variant to use for alert; may be
|
|
36
|
+
* set to "header" or "headerless"
|
|
37
|
+
*/
|
|
38
|
+
@api variant = 'header';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* theme to use when variant is "header"
|
|
42
|
+
* valid values are based on SLDS themes and are
|
|
43
|
+
* listed in "themeOptions" of interactiveDialogBase.js
|
|
44
|
+
*/
|
|
45
|
+
@api theme = 'default';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Dispatches privateclose event
|
|
49
|
+
* and closes dialog
|
|
50
|
+
*/
|
|
51
|
+
close(result) {
|
|
52
|
+
const promise = new Promise((resolve) => {
|
|
53
|
+
this.dispatchEvent(
|
|
54
|
+
new CustomEvent('privateclose', {
|
|
55
|
+
detail: {
|
|
56
|
+
resolve,
|
|
57
|
+
[secure]: true,
|
|
58
|
+
},
|
|
59
|
+
bubbles: true,
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
super.close(result, promise);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Dispatches privatechildrender event
|
|
68
|
+
* with data parent needs to correctly render
|
|
69
|
+
*/
|
|
70
|
+
renderedCallback() {
|
|
71
|
+
const evt = new CustomEvent('privatechildrender', {
|
|
72
|
+
bubbles: true,
|
|
73
|
+
detail: {
|
|
74
|
+
message: this.message,
|
|
75
|
+
label: this.label,
|
|
76
|
+
hideCancel: false,
|
|
77
|
+
showDescription: false,
|
|
78
|
+
getOkValue: this.getOkValue.bind(this),
|
|
79
|
+
getCancelValue: () => null,
|
|
80
|
+
role: 'dialog',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
this.dispatchEvent(evt);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getOkValue() {
|
|
87
|
+
if (this.template.querySelector('input')) {
|
|
88
|
+
return this.template.querySelector('input').value;
|
|
89
|
+
}
|
|
90
|
+
return this.defaultValue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -90,8 +90,17 @@ export default class LightningRadioGroup extends LightningElement {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
get fieldsetElement() {
|
|
94
|
+
return this.template.querySelector('fieldset');
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
renderedCallback() {
|
|
94
98
|
this.synchronizeA11y();
|
|
99
|
+
synchronizeAttrs(this.fieldsetElement, {
|
|
100
|
+
'aria-describedby': getRealDOMId(
|
|
101
|
+
this.template.querySelector('[data-help-message]')
|
|
102
|
+
),
|
|
103
|
+
});
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
/**
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
onfocus={handleFocus}
|
|
22
22
|
required={required}
|
|
23
23
|
accesskey={accessKey}
|
|
24
|
-
size={size}
|
|
24
|
+
size={size}
|
|
25
|
+
aria-invalid={computedAriaInvalid}
|
|
26
|
+
>
|
|
25
27
|
<template for:each={options} for:item="option">
|
|
26
28
|
<template if:true={option.disabled}>
|
|
27
29
|
<option disabled key={option.value} value={option.value}>{option.label}</option>
|
|
@@ -80,11 +80,15 @@ export default class LightningSelect extends LightningElement {
|
|
|
80
80
|
}
|
|
81
81
|
synchronizeAttrs(this.selectElement, {
|
|
82
82
|
'aria-describedby': getRealDOMId(
|
|
83
|
-
this.template.querySelector('
|
|
83
|
+
this.template.querySelector('[data-help-message]')
|
|
84
84
|
),
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
get computedAriaInvalid() {
|
|
89
|
+
return !!this._helpMessage || undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
88
92
|
/**
|
|
89
93
|
* Help text detailing the purpose and function of the menu of options.
|
|
90
94
|
* The text is displayed in a tooltip above the menu.
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
<div class="slds-form-element__control slds-grow textarea-container">
|
|
10
10
|
<textarea id="input" class="slds-textarea"
|
|
11
11
|
aria-describedby={computedUniqueHelpElementId}
|
|
12
|
+
aria-invalid={computedAriaInvalid}
|
|
12
13
|
autocomplete={autocomplete}
|
|
13
14
|
oninput={handleInput}
|
|
14
15
|
onchange={handleChange}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
classListMutation,
|
|
11
11
|
decorateInputForDragon,
|
|
12
12
|
setDecoratedDragonInputValueWithoutEvent,
|
|
13
|
+
computeAriaInvalid,
|
|
13
14
|
} from 'lightning/utilsPrivate';
|
|
14
15
|
import {
|
|
15
16
|
InteractingState,
|
|
@@ -478,6 +479,10 @@ export default class LightningTextarea extends LightningElement {
|
|
|
478
479
|
}
|
|
479
480
|
return this._constraintApi;
|
|
480
481
|
}
|
|
482
|
+
|
|
483
|
+
get computedAriaInvalid() {
|
|
484
|
+
return computeAriaInvalid(this._helpMessage, this.value);
|
|
485
|
+
}
|
|
481
486
|
}
|
|
482
487
|
|
|
483
488
|
LightningTextarea.interopMap = {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
normalizeBoolean,
|
|
24
24
|
synchronizeAttrs,
|
|
25
25
|
normalizeString,
|
|
26
|
+
computeAriaInvalid,
|
|
26
27
|
} from 'lightning/utilsPrivate';
|
|
27
28
|
import { normalizeVariant, VARIANT } from 'lightning/inputUtils';
|
|
28
29
|
|
|
@@ -543,4 +544,11 @@ export default class LightningTimePicker extends LightningElement {
|
|
|
543
544
|
this.ariaLabelledByElement.length
|
|
544
545
|
);
|
|
545
546
|
}
|
|
547
|
+
|
|
548
|
+
get computedAriaInvalid() {
|
|
549
|
+
const isAriaInvalid =
|
|
550
|
+
this.template.host.getAttribute('data-aria-invalid') ||
|
|
551
|
+
this._errorMessage;
|
|
552
|
+
return computeAriaInvalid(isAriaInvalid, this.value);
|
|
553
|
+
}
|
|
546
554
|
}
|
|
@@ -135,3 +135,29 @@ export function isAriaDescriptionSupported() {
|
|
|
135
135
|
}
|
|
136
136
|
return ariaDescriptionSupported;
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
export function updateAriaInvalidOnElement(element, isInvalid) {
|
|
140
|
+
if (isInvalid) {
|
|
141
|
+
element.setAttribute('aria-invalid', true);
|
|
142
|
+
} else {
|
|
143
|
+
element.removeAttribute('aria-invalid');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* If value is empty, then do no calculate aria-invalid. This is intentional for 240.
|
|
149
|
+
* In the future, we may be removing emptiness this check.
|
|
150
|
+
*
|
|
151
|
+
* Then if isInvalid is truthy, return true else return undefined to remove
|
|
152
|
+
* aria-invalid attribute.
|
|
153
|
+
*
|
|
154
|
+
* @param isInvalid
|
|
155
|
+
* @param value
|
|
156
|
+
* @returns {boolean|undefined}
|
|
157
|
+
*/
|
|
158
|
+
export function computeAriaInvalid(isInvalid, value) {
|
|
159
|
+
if (value === undefined || value === null || value === '') {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return !!isInvalid || undefined;
|
|
163
|
+
}
|
|
@@ -107,6 +107,6 @@ export function parseToFormattedLinkifiedParts(text, ignoreNewLines = false) {
|
|
|
107
107
|
*/
|
|
108
108
|
export function parseToFormattedParts(text) {
|
|
109
109
|
return text.split(newLineRegex).map((part, index) => {
|
|
110
|
-
return index % 2 === 0 ? getTextPart(part) : getNewlinePart();
|
|
110
|
+
return index % 2 === 0 ? getTextPart(part) : getNewlinePart(index);
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { assert } from './assert';
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
ARIA,
|
|
4
|
+
ARIA_TO_CAMEL,
|
|
5
|
+
isAriaDescriptionSupported,
|
|
6
|
+
updateAriaInvalidOnElement,
|
|
7
|
+
computeAriaInvalid,
|
|
8
|
+
} from './aria';
|
|
3
9
|
export { EventEmitter } from './eventEmitter';
|
|
4
10
|
export { toNorthAmericanPhoneNumber } from './phonify';
|
|
5
11
|
export * from './linkUtils';
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createElement } from 'lwc';
|
|
2
|
-
import Element from 'lightning/icon';
|
|
3
|
-
|
|
4
|
-
function createIcon(props = {}) {
|
|
5
|
-
const element = createElement('lightning-icon', { is: Element });
|
|
6
|
-
|
|
7
|
-
Object.assign(element, props);
|
|
8
|
-
document.body.appendChild(element);
|
|
9
|
-
return element;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function verifySvgDataKey(element, value) {
|
|
13
|
-
const primitiveIcon = element.shadowRoot.querySelector(
|
|
14
|
-
'lightning-primitive-icon'
|
|
15
|
-
);
|
|
16
|
-
const svg = primitiveIcon.shadowRoot.querySelector('svg');
|
|
17
|
-
expect(svg.getAttribute('data-key')).toBe(value);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('lightning-icon', () => {
|
|
21
|
-
it('should render with prebuilt icon for utility', () => {
|
|
22
|
-
const element = createIcon({
|
|
23
|
-
iconName: 'utility:check',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
verifySvgDataKey(element, 'check');
|
|
27
|
-
});
|
|
28
|
-
it('should render with prebuilt icon for standard', () => {
|
|
29
|
-
const element = createIcon({
|
|
30
|
-
iconName: 'standard:account',
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
verifySvgDataKey(element, 'account');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should render with prebuilt icon for action', () => {
|
|
37
|
-
const element = createIcon({
|
|
38
|
-
iconName: 'action:back',
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
verifySvgDataKey(element, 'back');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should render with prebuilt icon for doctype', () => {
|
|
45
|
-
const element = createIcon({
|
|
46
|
-
iconName: 'doctype:image',
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
verifySvgDataKey(element, 'image');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should render with prebuilt icon for custom', () => {
|
|
53
|
-
const element = createIcon({
|
|
54
|
-
iconName: 'custom:custom1',
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
verifySvgDataKey(element, 'custom1');
|
|
58
|
-
});
|
|
59
|
-
});
|