@brightspace-ui/core 3.119.1 → 3.121.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.
@@ -192,7 +192,13 @@ class DemoSnippet extends LitElement {
192
192
  text = text.replace(/^[\t]*<template>[\n]*/, '').replace(/[\n]*[\t]*<\/template>$/, '');
193
193
 
194
194
  // fix script whitespace (for some reason brower keeps <script> indent but not the rest)
195
- let lines = text.replace(/\t/g, ' ').replace(/<\/script>/g, '\n</script>').replace(/<script>/g, '<script>\n').replace(/<script type="module">/g, '<script type="module">\n').split('\n');
195
+ let lines = text
196
+ .replace(/\t/g, ' ')
197
+ .replace(/<\/script>/g, '\n</script>')
198
+ .replace(/<script>/g, '<script>\n')
199
+ .replace(/<script type="module">/g, '<script type="module">\n')
200
+ .replace(/<script data-demo-hide(.+?)<\/script>/gis, '')
201
+ .split('\n');
196
202
  let scriptIndent = 0;
197
203
  lines = lines.map((l) => {
198
204
  if (l.indexOf('<script') > -1) {
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { cssEscape } from '../../helpers/dom.js';
3
+ import { getFlag } from '../../helpers/flags.js';
3
4
 
4
5
  const formElements = {
5
6
  button: true,
@@ -152,6 +153,12 @@ const _hasFormData = (node, submitter) => {
152
153
  return false;
153
154
  }
154
155
  }
156
+ if (tagName === 'd2l-input-checkbox') {
157
+ const useFormElementMixin = getFlag('input-checkbox-form-element', true);
158
+ if (!useFormElementMixin || !node.checked) {
159
+ return false;
160
+ }
161
+ }
155
162
  if (tagName === 'object' || tagName === 'output') {
156
163
  return false;
157
164
  }
@@ -3,6 +3,7 @@ import '../tooltip/tooltip.js';
3
3
  import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
5
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
6
+ import { FormElementMixin } from '../form/form-element-mixin.js';
6
7
  import { getFlag } from '../../helpers/flags.js';
7
8
  import { getUniqueId } from '../../helpers/uniqueId.js';
8
9
  import { ifDefined } from 'lit/directives/if-defined.js';
@@ -68,7 +69,7 @@ export const checkboxStyles = css`
68
69
  * @slot supporting - Supporting information which will appear below and be aligned with the checkbox.
69
70
  * @fires change - Dispatched when the checkbox's state changes
70
71
  */
71
- class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitElement))) {
72
+ class InputCheckbox extends FormElementMixin(InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitElement)))) {
72
73
 
73
74
  static get properties() {
74
75
  return {
@@ -111,11 +112,6 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
111
112
  * @type {boolean}
112
113
  */
113
114
  labelHidden: { attribute: 'label-hidden', reflect: true, type: Boolean },
114
- /**
115
- * Name of the input
116
- * @type {string}
117
- */
118
- name: { type: String },
119
115
  /**
120
116
  * ACCESSIBILITY: ADVANCED: Sets "tabindex="-1"" on the checkbox. Note that an alternative method of focusing is necessary to implement if using this property.
121
117
  * @type {boolean}
@@ -257,6 +253,13 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
257
253
  `;
258
254
  }
259
255
 
256
+ updated(changedProperties) {
257
+ super.updated(changedProperties);
258
+ if (changedProperties.has('value')) {
259
+ this.setFormValue(this.value); // d2l-form handles not using value when unchecked
260
+ }
261
+ }
262
+
260
263
  willUpdate(changedProperties) {
261
264
  super.willUpdate(changedProperties);
262
265
  if (changedProperties.has('ariaLabel') && this.ariaLabel !== undefined) {
@@ -5254,12 +5254,6 @@
5254
5254
  "type": "boolean",
5255
5255
  "default": "false"
5256
5256
  },
5257
- {
5258
- "name": "name",
5259
- "description": "Name of the input",
5260
- "type": "string",
5261
- "default": "\"\""
5262
- },
5263
5257
  {
5264
5258
  "name": "not-tabbable",
5265
5259
  "description": "ACCESSIBILITY: ADVANCED: Sets \"tabindex=\"-1\"\" on the checkbox. Note that an alternative method of focusing is necessary to implement if using this property.",
@@ -5272,6 +5266,12 @@
5272
5266
  "type": "string",
5273
5267
  "default": "\"on\""
5274
5268
  },
5269
+ {
5270
+ "name": "name",
5271
+ "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
5272
+ "type": "string",
5273
+ "default": "\"\""
5274
+ },
5275
5275
  {
5276
5276
  "name": "skeleton",
5277
5277
  "description": "Render the component as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton).",
@@ -5326,13 +5326,6 @@
5326
5326
  "type": "boolean",
5327
5327
  "default": "false"
5328
5328
  },
5329
- {
5330
- "name": "name",
5331
- "attribute": "name",
5332
- "description": "Name of the input",
5333
- "type": "string",
5334
- "default": "\"\""
5335
- },
5336
5329
  {
5337
5330
  "name": "notTabbable",
5338
5331
  "attribute": "not-tabbable",
@@ -5347,6 +5340,13 @@
5347
5340
  "type": "string",
5348
5341
  "default": "\"on\""
5349
5342
  },
5343
+ {
5344
+ "name": "name",
5345
+ "attribute": "name",
5346
+ "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
5347
+ "type": "string",
5348
+ "default": "\"\""
5349
+ },
5350
5350
  {
5351
5351
  "name": "skeleton",
5352
5352
  "attribute": "skeleton",
package/helpers/flags.js CHANGED
@@ -1 +1,16 @@
1
- export const getFlag = (key, defaultValue) => window.D2L?.LP?.Web?.UI?.Flags.Flag(key, defaultValue) ?? defaultValue;
1
+ const flagOverrides = new Map();
2
+
3
+ export function getFlag(key, defaultValue) {
4
+ if (flagOverrides.has(key)) {
5
+ return flagOverrides.get(key);
6
+ }
7
+ return window.D2L?.LP?.Web?.UI?.Flags.Flag(key, defaultValue) ?? defaultValue;
8
+ }
9
+
10
+ export function mockFlag(key, value) {
11
+ flagOverrides.set(key, value);
12
+ }
13
+
14
+ export function resetFlag(key) {
15
+ flagOverrides.delete(key);
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.119.1",
3
+ "version": "3.121.0",
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",