@brightspace-ui/core 3.135.0 → 3.135.2
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/components/form/form.js
CHANGED
@@ -5,10 +5,13 @@ import { css, html, LitElement } from 'lit';
|
|
5
5
|
import { findFormElements, flattenMap, getFormElementData, isCustomFormElement, isNativeFormElement } from './form-helper.js';
|
6
6
|
import { findComposedAncestor } from '../../helpers/dom.js';
|
7
7
|
import { getComposedActiveElement } from '../../helpers/focus.js';
|
8
|
+
import { getFlag } from '../../helpers/flags.js';
|
8
9
|
import { getUniqueId } from '../../helpers/uniqueId.js';
|
9
10
|
import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
|
10
11
|
import { localizeFormElement } from './form-element-localize-helper.js';
|
11
12
|
|
13
|
+
const formElementMixinWithNestedFormsParticipates = getFlag('form-element-mixin-nested-forms', true);
|
14
|
+
|
12
15
|
/**
|
13
16
|
* A component that can be used to build sections containing interactive controls that are validated and submitted as a group.
|
14
17
|
* Values of these interactive controls are aggregated but the user is responsible for handling submission via the @d2l-form-submit event.
|
@@ -165,7 +168,13 @@ class Form extends LocalizeCoreElement(LitElement) {
|
|
165
168
|
}
|
166
169
|
}
|
167
170
|
}
|
168
|
-
} else {
|
171
|
+
} else if (!formElementMixinWithNestedFormsParticipates) {
|
172
|
+
const eleErrors = await this._validateFormElement(ele, true);
|
173
|
+
if (eleErrors.length > 0) {
|
174
|
+
errorMap.set(ele, eleErrors);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
if (formElementMixinWithNestedFormsParticipates) {
|
169
178
|
const eleErrors = await this._validateFormElement(ele, true);
|
170
179
|
if (eleErrors.length > 0) {
|
171
180
|
errorMap.set(ele, eleErrors);
|
@@ -354,13 +363,16 @@ class Form extends LocalizeCoreElement(LitElement) {
|
|
354
363
|
}
|
355
364
|
|
356
365
|
async _validateFormElement(ele, showNewErrors) {
|
366
|
+
const isCustom = isCustomFormElement(ele);
|
367
|
+
const isNative = isNativeFormElement(ele);
|
368
|
+
if (!isCustom && !isNative) return [];
|
357
369
|
// if validation occurs before we've rendered,
|
358
370
|
// localization may not have loaded yet
|
359
371
|
await this._firstUpdatePromise;
|
360
372
|
ele.id = ele.id || getUniqueId();
|
361
|
-
if (
|
373
|
+
if (isCustom) {
|
362
374
|
return ele.validate(showNewErrors);
|
363
|
-
} else if (
|
375
|
+
} else if (isNative) {
|
364
376
|
const customs = [...this._validationCustoms].filter(custom => custom.forElement === ele);
|
365
377
|
const results = await Promise.all(customs.map(custom => custom.validate()));
|
366
378
|
const errors = customs.map(custom => custom.failureText).filter((_, i) => !results[i]);
|
@@ -26,6 +26,14 @@ A loading spinner indicates that something is happening and we don't know how lo
|
|
26
26
|
<!-- docs: end donts -->
|
27
27
|
<!-- docs: end best practices -->
|
28
28
|
|
29
|
+
### When should I use the Skeleton Loader pattern vs. a Loading Spinner?
|
30
|
+
The skeleton loader pattern has a feeling of "an existing structure coming into focus", whereas the spinner has a feeling of progression. Because of this, we say that Skeleton Loaders are for loading page chrome, whereas Spinners are for loading data.
|
31
|
+
* If the page is loading for the first time and different parts of the page are coming in asynchronously, use Skeleton Loader pattern.
|
32
|
+
* If your design is progressively disclosing new components (new form fields for example) because the user has expanded or opened a panel, use Skeleton Loader pattern.
|
33
|
+
* If the data on a page changes as a result of a user action, ie: sorting or filtering a table, paginating, etc -- use a Loading Spinner.
|
34
|
+
* If you need to communicate that part of the page is processing data, use a spinner.
|
35
|
+
* If the whole page is about to refresh (ie: the user has pressed submit on a form), you do NOT need to show a loading spinner ... the browser's native "loading" affordances are enough.
|
36
|
+
|
29
37
|
## Loading Spinner [d2l-loading-spinner]
|
30
38
|
|
31
39
|
<!-- docs: demo code properties name:d2l-loading-spinner sandboxTitle:'Loading Spinner' -->
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.135.
|
3
|
+
"version": "3.135.2",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|