@brightspace-ui/core 3.196.0 → 3.197.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.
@@ -100,6 +100,20 @@
100
100
  <d2l-test-input-radio-label></d2l-test-input-radio-label>
101
101
  </d2l-demo-snippet>
102
102
 
103
+ <h2>Horizontal Layout</h2>
104
+ <d2l-demo-snippet>
105
+ <d2l-input-radio-group horizontal label="Bread">
106
+ <d2l-input-radio label="Super long label that extends and forces wrapping"></d2l-input-radio>
107
+ <d2l-input-radio style="max-width: 200px;" label="Super long label that extends and forces wrapping with max width"></d2l-input-radio>
108
+ <d2l-input-radio label="Whole wheat"></d2l-input-radio>
109
+ <d2l-input-radio label="Baguette"></d2l-input-radio>
110
+ <d2l-input-radio label="Marble Rye"></d2l-input-radio>
111
+ <d2l-input-radio label="Other" checked supporting-hidden-when-unchecked>
112
+ <d2l-input-text label="Other" label-hidden value="Sourdough" slot="supporting"></d2l-input-text>
113
+ </d2l-input-radio>
114
+ </d2l-input-radio-group>
115
+ </d2l-demo-snippet>
116
+
103
117
  </d2l-demo-page>
104
118
  </body>
105
119
  </html>
@@ -52,6 +52,7 @@ When provided with a `name`, the group will participate in forms with the `value
52
52
 
53
53
  | Property | Type | Description |
54
54
  |---|---|---|
55
+ | `horizontal` | Boolean | Display the radio buttons horizontally |
55
56
  | `label` | String, required | Label for the group of radio inputs |
56
57
  | `label-hidden` | Boolean | Hides the label visually |
57
58
  | `name` | String | Name of the form control. Submitted with the form as part of a name/value pair. |
@@ -15,6 +15,11 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
15
15
 
16
16
  static get properties() {
17
17
  return {
18
+ /**
19
+ * Display the radio buttons horizontally
20
+ * @type {boolean}
21
+ */
22
+ horizontal: { type: Boolean, reflect: true },
18
23
  /**
19
24
  * REQUIRED: Label for the group of radio inputs
20
25
  * @type {string}
@@ -46,6 +51,11 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
46
51
  flex-direction: column;
47
52
  gap: 0.6rem;
48
53
  }
54
+ :host([horizontal]) div[role="radiogroup"] {
55
+ flex-direction: row;
56
+ flex-wrap: wrap;
57
+ }
58
+
49
59
  .d2l-input-label[hidden] {
50
60
  display: none;
51
61
  }
@@ -57,6 +67,7 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
57
67
 
58
68
  constructor() {
59
69
  super();
70
+ this.horizontal = false;
60
71
  this.labelHidden = false;
61
72
  this.required = false;
62
73
  this.setFormValue('');
@@ -88,6 +99,10 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
88
99
  if (changedProperties.has('required')) {
89
100
  this.#recalculateState(true);
90
101
  }
102
+ if (changedProperties.has('horizontal')) {
103
+ const radios = this.#getRadios();
104
+ radios.forEach(el => el._horizontal = this.horizontal);
105
+ }
91
106
  }
92
107
 
93
108
  focus() {
@@ -218,6 +233,7 @@ class InputRadioGroup extends PropertyRequiredMixin(SkeletonMixin(FormElementMix
218
233
  if (el._checked) checkedRadios.push(el);
219
234
  el._isInitFromGroup = true;
220
235
  el._focusable = false;
236
+ el._horizontal = this.horizontal;
221
237
  });
222
238
 
223
239
  // only the last checked radio is actually checked
@@ -8,6 +8,7 @@ import { InputInlineHelpMixin } from './input-inline-help.js';
8
8
  import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
9
9
  import { radioStyles } from './input-radio-styles.js';
10
10
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
11
+ import { styleMap } from 'lit/directives/style-map.js';
11
12
 
12
13
  /**
13
14
  * A radio input within a <d2l-input-radio-group>.
@@ -56,6 +57,7 @@ class InputRadio extends InputInlineHelpMixin(SkeletonMixin(FocusMixin(PropertyR
56
57
  _checked: { state: true },
57
58
  _focusable: { state: true },
58
59
  _hasSupporting: { state: true },
60
+ _horizontal: { state: true },
59
61
  _isHovered: { state: true },
60
62
  _invalid: { state: true }
61
63
  };
@@ -95,6 +97,7 @@ class InputRadio extends InputInlineHelpMixin(SkeletonMixin(FocusMixin(PropertyR
95
97
  this._checked = false;
96
98
  this._focusable = false;
97
99
  this._hasSupporting = false;
100
+ this._horizontal = false;
98
101
  this._isHovered = false;
99
102
  this._isInitFromGroup = false;
100
103
  this._invalid = false;
@@ -126,6 +129,9 @@ class InputRadio extends InputInlineHelpMixin(SkeletonMixin(FocusMixin(PropertyR
126
129
 
127
130
  render() {
128
131
  const allowFocus = !this.focusDisabled && this._focusable;
132
+ const labelStyles = {
133
+ alignItems: this._horizontal ? 'flex-start' : undefined
134
+ };
129
135
  const labelClasses = {
130
136
  'd2l-input-radio-label': true,
131
137
  'd2l-input-radio-label-disabled': this.disabled && !this.skeleton,
@@ -147,7 +153,7 @@ class InputRadio extends InputInlineHelpMixin(SkeletonMixin(FocusMixin(PropertyR
147
153
  html`<d2l-tooltip align="start" class="vdiff-target" for="${this.#inputId}" ?force-show="${this._isHovered}" position="top">${this.disabledTooltip}</d2l-tooltip>` :
148
154
  nothing;
149
155
  return html`
150
- <div class="${classMap(labelClasses)}" @mouseover="${this.#handleMouseOver}" @mouseout="${this.#handleMouseOut}">
156
+ <div class="${classMap(labelClasses)}" style="${styleMap(labelStyles)}" @mouseover="${this.#handleMouseOver}" @mouseout="${this.#handleMouseOut}">
151
157
  <div
152
158
  aria-checked="${this._checked}"
153
159
  aria-describedby="${ifDefined(ariaDescribedByIds.length > 0 ? ariaDescribedByIds : undefined)}"
@@ -7084,6 +7084,12 @@
7084
7084
  "description": "REQUIRED: Label for the group of radio inputs",
7085
7085
  "type": "string"
7086
7086
  },
7087
+ {
7088
+ "name": "horizontal",
7089
+ "description": "Display the radio buttons horizontally",
7090
+ "type": "boolean",
7091
+ "default": "false"
7092
+ },
7087
7093
  {
7088
7094
  "name": "label-hidden",
7089
7095
  "description": "Hides the label visually",
@@ -7114,6 +7120,13 @@
7114
7120
  "description": "REQUIRED: Label for the group of radio inputs",
7115
7121
  "type": "string"
7116
7122
  },
7123
+ {
7124
+ "name": "horizontal",
7125
+ "attribute": "horizontal",
7126
+ "description": "Display the radio buttons horizontally",
7127
+ "type": "boolean",
7128
+ "default": "false"
7129
+ },
7117
7130
  {
7118
7131
  "name": "labelHidden",
7119
7132
  "attribute": "label-hidden",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.196.0",
3
+ "version": "3.197.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",