@brightspace-ui/core 1.192.1 → 1.193.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.
@@ -112,6 +112,7 @@ If you're looking to emulate native form element submission, `d2l-form-native` m
112
112
  ### Events
113
113
  - `d2l-form-submit`: Dispatched when the form is submitted. The form data can be obtained from the `detail`'s `formData` property.
114
114
  - `d2l-form-invalid`: Dispatched when the form fails validation. The error map can be obtained from the `detail`'s `errors` property.
115
+ - `d2l-form-dirty`: Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
115
116
  <!-- docs: end hidden content -->
116
117
 
117
118
  ### Methods
@@ -234,6 +235,7 @@ If you're looking to submit form data via your own API calls or nest multiple fo
234
235
  ### Events
235
236
  - `submit`: Dispatched when the form is submitted. Cancelling this event will prevent form submission.
236
237
  - `formdata`: Dispatched after the entry list representing the form's data is constructed. This happens when the form is submitted just prior to submission. The form data can be obtained from the `detail`'s `formData` property.
238
+ - `d2l-form-dirty`: Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
237
239
  <!-- docs: end hidden content -->
238
240
 
239
241
  ### Methods
@@ -100,13 +100,19 @@ export const FormMixin = superclass => class extends LocalizeCoreElement(supercl
100
100
  e.stopPropagation();
101
101
  this._updateErrors(e.target, e.detail.errors);
102
102
  }
103
+
103
104
  async _onFormElementChange(e) {
104
105
  const ele = e.target;
106
+
107
+ if ((isNativeFormElement(ele) || isCustomFormElement(ele)) && e.type !== 'focusout') {
108
+ this._dirty = true;
109
+ this.dispatchEvent(new CustomEvent('d2l-form-dirty'));
110
+ }
111
+
105
112
  if (!isNativeFormElement(ele)) {
106
113
  return;
107
114
  }
108
115
  e.stopPropagation();
109
- this._dirty = true;
110
116
  const errors = await this._validateFormElement(ele, e.type === 'focusout');
111
117
  this._updateErrors(ele, errors);
112
118
  }
@@ -8,6 +8,7 @@ import { getUniqueId } from '../../helpers/uniqueId.js';
8
8
  * These interactive controls are submitted using a native HTML form submission.
9
9
  * @slot - The native and custom form elements that participate in validation and submission
10
10
  * @fires submit - Dispatched when the form is submitted. Cancelling this event will prevent form submission.
11
+ * @fires d2l-form-dirty - Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
11
12
  */
12
13
  class FormNative extends FormMixin(LitElement) {
13
14
 
@@ -6,6 +6,7 @@ import { FormMixin } from './form-mixin.js';
6
6
  * A component that can be used to build sections containing interactive controls that are validated and submitted as a group.
7
7
  * Values of these interactive controls are aggregated but the user is responsible for handling submission via the @d2l-form-submit event.
8
8
  * @slot - The native and custom form elements that participate in validation and submission
9
+ * @fires d2l-form-dirty - Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
9
10
  */
10
11
  class Form extends FormMixin(LitElement) {
11
12
 
@@ -3135,6 +3135,10 @@
3135
3135
  "name": "submit",
3136
3136
  "description": "Dispatched when the form is submitted. Cancelling this event will prevent form submission."
3137
3137
  },
3138
+ {
3139
+ "name": "d2l-form-dirty",
3140
+ "description": "Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not."
3141
+ },
3138
3142
  {
3139
3143
  "name": "formdata",
3140
3144
  "description": "Dispatched after the entry list representing the form's data is constructed. This happens when the form is submitted just prior to submission. The form data can be obtained from the `detail`'s `formData` property."
@@ -3180,6 +3184,10 @@
3180
3184
  }
3181
3185
  ],
3182
3186
  "events": [
3187
+ {
3188
+ "name": "d2l-form-dirty",
3189
+ "description": "Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not."
3190
+ },
3183
3191
  {
3184
3192
  "name": "d2l-form-invalid",
3185
3193
  "description": "Dispatched when the form fails validation. The error map can be obtained from the `detail`'s `errors` property."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.192.1",
3
+ "version": "1.193.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "repository": "https://github.com/BrightspaceUI/core.git",
6
6
  "publishConfig": {