@brightspace-ui/core 3.333.5 → 3.334.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.
@@ -104,9 +104,7 @@ export const DialogMixin = superclass => class extends superclass {
104
104
  window.removeEventListener('d2l-mvc-dialog-open', this.#handleMvcDialogOpen);
105
105
 
106
106
  // If the dialog is disconnected before the close animation finishes
107
- if (!this.#closeHandled) {
108
- this._handleClose();
109
- }
107
+ this._handleClose();
110
108
  }
111
109
 
112
110
  async updated(changedProperties) {
@@ -376,6 +374,8 @@ export const DialogMixin = superclass => class extends superclass {
376
374
  }
377
375
 
378
376
  _handleClose() {
377
+ if (this.#closeHandled) return;
378
+ this.#closeHandled = true;
379
379
  /* reset state if native dialog closes unexpectedly. ex. user highlights
380
380
  text and then hits escape key - this is not caught by our key handler */
381
381
  this._removeHandlers();
@@ -392,7 +392,6 @@ export const DialogMixin = superclass => class extends superclass {
392
392
  detail: { action: this._action }
393
393
  }
394
394
  ));
395
- this.#closeHandled = true;
396
395
  }
397
396
 
398
397
  _handleDialogCloseWithinNative(e) {
@@ -45,6 +45,8 @@ A segmented component to switch between views. Use a view switcher to change bet
45
45
  |---|---|---|
46
46
  |`key` | String, required | Key for the button. |
47
47
  |`text`| String, required | Text for the button. |
48
+ |`text-hidden`| Boolean, default: `false` | Hides the text visually. Will reset to false unless an icon is set |
49
+ | `icon` | String | [Preset icon key](../../components/icons#preset-icons) (e.g. `tier1:gear`) |
48
50
  |`selected`| Boolean, default: `false` | Indicates if the item is selected. |
49
51
 
50
52
  ### Events
@@ -1,16 +1,20 @@
1
1
  import '../colors/colors.js';
2
- import { css, html, LitElement, unsafeCSS } from 'lit';
2
+ import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
3
3
  import { buttonStyles } from '../button/button-styles.js';
4
4
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
5
5
  import { getFocusPseudoClass } from '../../helpers/focus.js';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
7
  import { labelStyles } from '../typography/styles.js';
7
8
  import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
9
+ import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
8
11
 
9
12
  /**
10
13
  * A button component to be used in d2l-view-switcher.
11
14
  * @fires d2l-view-switcher-select - Dispatched when the item is selected
15
+ * @slot icon - Optional slot for a custom icon
12
16
  */
13
- class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
17
+ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(SlottedIconMixin(LitElement))) {
14
18
 
15
19
  static properties = {
16
20
  /**
@@ -28,6 +32,11 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
28
32
  * @type {boolean}
29
33
  */
30
34
  selected: { type: Boolean, reflect: true },
35
+ /**
36
+ * Hides the text visually
37
+ * @type {boolean}
38
+ */
39
+ textHidden: { type: Boolean, attribute: 'text-hidden' }
31
40
  };
32
41
 
33
42
  static styles = [labelStyles, buttonStyles, css`
@@ -39,7 +48,8 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
39
48
  button {
40
49
  background-color: transparent;
41
50
  border-radius: 0.2rem;
42
- display: block;
51
+ column-gap: 0.3rem;
52
+ display: inline-flex;
43
53
  font-family: inherit;
44
54
  min-height: auto;
45
55
  padding-block: 0.3rem;
@@ -58,11 +68,16 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
58
68
  background-color: var(--d2l-color-tungsten);
59
69
  color: #ffffff;
60
70
  }
71
+ :host([selected]) d2l-icon,
72
+ :host([selected]) ::slotted(d2l-icon-custom) {
73
+ color: #ffffff;
74
+ }
61
75
  `];
62
76
 
63
77
  constructor() {
64
78
  super();
65
79
  this.selected = false;
80
+ this.textHidden = false;
66
81
  }
67
82
 
68
83
  static get focusElementSelector() {
@@ -70,13 +85,21 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
70
85
  }
71
86
 
72
87
  render() {
88
+ const hideText = this.textHidden && this.hasIcon();
89
+ const label = hideText ? this.text : undefined;
90
+ const iconPaddingOverride = {
91
+ paddingInline: hideText ? '0.3rem' : (this.hasIcon() ? '0.6rem' : undefined)
92
+ };
73
93
  return html`
74
94
  <button
95
+ aria-label="${ifDefined(label)}"
75
96
  aria-pressed="${this.selected ? 'true' : 'false'}"
76
97
  class="d2l-label-text"
77
98
  @click="${this.#handleClick}"
99
+ style="${styleMap(iconPaddingOverride)}"
78
100
  type="button">
79
- ${this.text}
101
+ ${this._renderIcon()}
102
+ ${hideText ? nothing : this.text}
80
103
  </button>
81
104
  `;
82
105
  }
@@ -18159,6 +18159,17 @@
18159
18159
  "description": "Indicates if the item is selected",
18160
18160
  "type": "boolean",
18161
18161
  "default": "false"
18162
+ },
18163
+ {
18164
+ "name": "text-hidden",
18165
+ "description": "Hides the text visually",
18166
+ "type": "boolean",
18167
+ "default": "false"
18168
+ },
18169
+ {
18170
+ "name": "icon",
18171
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
18172
+ "type": "string"
18162
18173
  }
18163
18174
  ],
18164
18175
  "properties": [
@@ -18185,6 +18196,19 @@
18185
18196
  "description": "Indicates if the item is selected",
18186
18197
  "type": "boolean",
18187
18198
  "default": "false"
18199
+ },
18200
+ {
18201
+ "name": "textHidden",
18202
+ "attribute": "text-hidden",
18203
+ "description": "Hides the text visually",
18204
+ "type": "boolean",
18205
+ "default": "false"
18206
+ },
18207
+ {
18208
+ "name": "icon",
18209
+ "attribute": "icon",
18210
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
18211
+ "type": "string"
18188
18212
  }
18189
18213
  ],
18190
18214
  "events": [
@@ -18192,6 +18216,12 @@
18192
18216
  "name": "d2l-view-switcher-select",
18193
18217
  "description": "Dispatched when the item is selected"
18194
18218
  }
18219
+ ],
18220
+ "slots": [
18221
+ {
18222
+ "name": "icon",
18223
+ "description": "Optional slot for a custom icon"
18224
+ }
18195
18225
  ]
18196
18226
  },
18197
18227
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.333.5",
3
+ "version": "3.334.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",