@brightspace-ui/core 3.135.0 → 3.135.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/components/form/form.js +15 -3
- package/package.json +1 -1
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]);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.135.
|
3
|
+
"version": "3.135.1",
|
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",
|