@brightspace-ui/core 3.344.13 → 3.345.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.
@@ -133,9 +133,6 @@ class ButtonIcon extends SlottedIconMixin(PropertyRequiredMixin(ThemeMixin(Butto
133
133
  constructor() {
134
134
  super();
135
135
  this.translucent = false;
136
-
137
- /** @internal */
138
- this._buttonId = getUniqueId();
139
136
  /** @internal */
140
137
  this._describedById = getUniqueId();
141
138
  this._iconRequired = true;
@@ -145,29 +142,31 @@ class ButtonIcon extends SlottedIconMixin(PropertyRequiredMixin(ThemeMixin(Butto
145
142
  return html`
146
143
  <button
147
144
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
148
- aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
145
+ aria-disabled="${this._ariaDisabled}"
149
146
  aria-expanded="${ifDefined(this.expanded)}"
150
147
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
151
148
  aria-label="${this.ariaLabel ? this.ariaLabel : ifDefined(this.text)}"
152
149
  ?autofocus="${this.autofocus}"
153
- ?disabled="${this.disabled && !this.disabledTooltip}"
150
+ ?disabled="${this._disabled}"
154
151
  form="${ifDefined(this.form)}"
155
152
  formaction="${ifDefined(this.formaction)}"
156
153
  formenctype="${ifDefined(this.formenctype)}"
157
154
  formmethod="${ifDefined(this.formmethod)}"
158
155
  ?formnovalidate="${this.formnovalidate}"
159
156
  formtarget="${ifDefined(this.formtarget)}"
160
- id="${this._buttonId}"
157
+ id="${this.#buttonId}"
161
158
  name="${ifDefined(this.name)}"
162
159
  title="${ifDefined(this.text)}"
163
160
  type="${this._getType()}">
164
161
  ${this._renderIcon()}
165
162
  </button>
166
163
  ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
167
- ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip class="vdiff-target" for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
164
+ ${this._renderDisabledTooltip(this.#buttonId)}
168
165
  `;
169
166
  }
170
167
 
168
+ #buttonId = getUniqueId();
169
+
171
170
  }
172
171
 
173
172
  customElements.define('d2l-button-icon', ButtonIcon);
@@ -1,6 +1,7 @@
1
+ import { DisabledTooltipMixin } from '../../mixins/disabled-tooltip/disabled-tooltip-mixin.js';
1
2
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
2
3
 
3
- export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
4
+ export const ButtonMixin = superclass => class extends DisabledTooltipMixin(FocusMixin(superclass)) {
4
5
 
5
6
  static properties = {
6
7
  /**
@@ -25,16 +26,6 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
25
26
  * @type {'true' | 'false'}
26
27
  */
27
28
  expanded: { type: String, reflect: true, attribute: 'expanded' },
28
- /**
29
- * Disables the button
30
- * @type {boolean}
31
- */
32
- disabled: { type: Boolean, reflect: true },
33
- /**
34
- * Tooltip text when disabled
35
- * @type {string}
36
- */
37
- disabledTooltip: { type: String, attribute: 'disabled-tooltip' },
38
29
  /**
39
30
  * @ignore
40
31
  */
@@ -71,7 +62,6 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
71
62
 
72
63
  constructor() {
73
64
  super();
74
- this.disabled = false;
75
65
 
76
66
  /** @ignore */
77
67
  this.autofocus = false;
@@ -80,27 +70,6 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
80
70
  this.type = 'button';
81
71
  }
82
72
 
83
- /**
84
- * @attr disabled - Disables the button
85
- */
86
- get disabled() { return this._disabled; }
87
- set disabled(value) {
88
- const oldValue = this._disabled;
89
- this._disabled = value;
90
- this.requestUpdate('disabled', oldValue);
91
- }
92
-
93
- /**
94
- * @attr disabled-tooltip - Tooltip text when disabled
95
- * @type {string}
96
- */
97
- get disabledTooltip() { return this._disabledTooltip; }
98
- set disabledTooltip(value) {
99
- const oldValue = this._disabledTooltip;
100
- this._disabledTooltip = value;
101
- this.requestUpdate('disabledTooltip', oldValue);
102
- }
103
-
104
73
  static get focusElementSelector() {
105
74
  return 'button';
106
75
  }
@@ -6,6 +6,7 @@ import '../icons/icon.js';
6
6
  import '../menu/menu.js';
7
7
  import { css, html, LitElement } from 'lit';
8
8
  import { classMap } from 'lit/directives/class-map.js';
9
+ import { DisabledTooltipMixin } from '../../mixins/disabled-tooltip/disabled-tooltip-mixin.js';
9
10
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
10
11
  import { ifDefined } from 'lit/directives/if-defined.js';
11
12
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
@@ -14,7 +15,7 @@ import { PropertyRequiredMixin } from '../../mixins/property-required/property-r
14
15
  /**
15
16
  * A split button that provides a main action button and slot for a menu.
16
17
  */
17
- class ButtonSplit extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElement(LitElement))) {
18
+ class ButtonSplit extends DisabledTooltipMixin(FocusMixin(PropertyRequiredMixin(LocalizeCoreElement(LitElement)))) {
18
19
 
19
20
  static properties = {
20
21
  /**
@@ -22,16 +23,6 @@ class ButtonSplit extends FocusMixin(PropertyRequiredMixin(LocalizeCoreElement(L
22
23
  * @type {string}
23
24
  */
24
25
  description: { type: String },
25
- /**
26
- * Disables the main action and dropdown opener buttons
27
- * @type {boolean}
28
- */
29
- disabled: { type: Boolean, reflect: true },
30
- /**
31
- * Tooltip text when disabled
32
- * @type {string}
33
- */
34
- disabledTooltip: { type: String, attribute: 'disabled-tooltip' },
35
26
  /**
36
27
  * REQUIRED: Key of the main action
37
28
  * @type {string}
@@ -166,8 +166,6 @@ class ButtonSubtle extends SlottedIconMixin(ButtonMixin(LitElement)) {
166
166
  super();
167
167
  this.iconRight = false;
168
168
  this.slim = false;
169
-
170
- this._buttonId = getUniqueId();
171
169
  this._describedById = getUniqueId();
172
170
  }
173
171
 
@@ -179,20 +177,20 @@ class ButtonSubtle extends SlottedIconMixin(ButtonMixin(LitElement)) {
179
177
  return html`
180
178
  <button
181
179
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
182
- aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
180
+ aria-disabled="${this._ariaDisabled}"
183
181
  aria-expanded="${ifDefined(this.expanded)}"
184
182
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
185
183
  aria-label="${ifDefined(this.ariaLabel)}"
186
184
  ?autofocus="${this.autofocus}"
187
185
  class="${classMap(buttonClasses)}"
188
- ?disabled="${this.disabled && !this.disabledTooltip}"
186
+ ?disabled="${this._disabled}"
189
187
  form="${ifDefined(this.form)}"
190
188
  formaction="${ifDefined(this.formaction)}"
191
189
  formenctype="${ifDefined(this.formenctype)}"
192
190
  formmethod="${ifDefined(this.formmethod)}"
193
191
  ?formnovalidate="${this.formnovalidate}"
194
192
  formtarget="${ifDefined(this.formtarget)}"
195
- id="${this._buttonId}"
193
+ id="${this.#buttonId}"
196
194
  name="${ifDefined(this.name)}"
197
195
  type="${this._getType()}">
198
196
  ${this._renderIcon()}
@@ -202,10 +200,12 @@ class ButtonSubtle extends SlottedIconMixin(ButtonMixin(LitElement)) {
202
200
  </span>
203
201
  </button>
204
202
  ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
205
- ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip class="vdiff-target" for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
203
+ ${this._renderDisabledTooltip(this.#buttonId)}
206
204
  `;
207
205
  }
208
206
 
207
+ #buttonId = getUniqueId();
208
+
209
209
  }
210
210
 
211
211
  customElements.define('d2l-button-subtle', ButtonSubtle);
@@ -96,8 +96,6 @@ class Button extends ButtonMixin(LitElement) {
96
96
  super();
97
97
  this.primary = false;
98
98
 
99
- /** @internal */
100
- this._buttonId = getUniqueId();
101
99
  /** @internal */
102
100
  this._describedById = getUniqueId();
103
101
  }
@@ -106,27 +104,29 @@ class Button extends ButtonMixin(LitElement) {
106
104
  return html`
107
105
  <button
108
106
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
109
- aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
107
+ aria-disabled="${this._ariaDisabled}"
110
108
  aria-expanded="${ifDefined(this.expanded)}"
111
109
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
112
110
  aria-label="${ifDefined(this.ariaLabel)}"
113
111
  ?autofocus="${this.autofocus}"
114
112
  class="d2l-label-text"
115
- ?disabled="${this.disabled && !this.disabledTooltip}"
113
+ ?disabled="${this._disabled}"
116
114
  form="${ifDefined(this.form)}"
117
115
  formaction="${ifDefined(this.formaction)}"
118
116
  formenctype="${ifDefined(this.formenctype)}"
119
117
  formmethod="${ifDefined(this.formmethod)}"
120
118
  ?formnovalidate="${this.formnovalidate}"
121
119
  formtarget="${ifDefined(this.formtarget)}"
122
- id="${this._buttonId}"
120
+ id="${this.#buttonId}"
123
121
  name="${ifDefined(this.name)}"
124
122
  type="${this._getType()}">
125
123
  <slot></slot>
126
124
  </button>
127
125
  ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
128
- ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip class="vdiff-target" for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
126
+ ${this._renderDisabledTooltip(this.#buttonId)}
129
127
  `;
130
128
  }
129
+
130
+ #buttonId = getUniqueId();
131
131
  }
132
132
  customElements.define('d2l-button', Button);
@@ -619,7 +619,7 @@
619
619
  },
620
620
  {
621
621
  "name": "disabled",
622
- "description": "Disables the button",
622
+ "description": "Disables the control",
623
623
  "type": "boolean",
624
624
  "default": "false"
625
625
  }
@@ -667,20 +667,20 @@
667
667
  "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
668
668
  "type": "'true' | 'false'"
669
669
  },
670
+ {
671
+ "name": "isButtonMixin",
672
+ "type": "boolean"
673
+ },
670
674
  {
671
675
  "name": "disabledTooltip",
672
676
  "attribute": "disabled-tooltip",
673
677
  "description": "Tooltip text when disabled",
674
678
  "type": "string"
675
679
  },
676
- {
677
- "name": "isButtonMixin",
678
- "type": "boolean"
679
- },
680
680
  {
681
681
  "name": "disabled",
682
682
  "attribute": "disabled",
683
- "description": "Disables the button",
683
+ "description": "Disables the control",
684
684
  "type": "boolean",
685
685
  "default": "false"
686
686
  },
@@ -1016,11 +1016,6 @@
1016
1016
  "description": "ACCESSIBILITY: A description to be added to the main action button for accessibility when text does not provide enough context",
1017
1017
  "type": "string"
1018
1018
  },
1019
- {
1020
- "name": "disabled-tooltip",
1021
- "description": "Tooltip text when disabled",
1022
- "type": "string"
1023
- },
1024
1019
  {
1025
1020
  "name": "key",
1026
1021
  "description": "REQUIRED: Key of the main action",
@@ -1032,14 +1027,19 @@
1032
1027
  "type": "string"
1033
1028
  },
1034
1029
  {
1035
- "name": "disabled",
1036
- "description": "Disables the main action and dropdown opener buttons",
1030
+ "name": "primary",
1031
+ "description": "Styles the buttons as a primary buttons",
1037
1032
  "type": "boolean",
1038
1033
  "default": "false"
1039
1034
  },
1040
1035
  {
1041
- "name": "primary",
1042
- "description": "Styles the buttons as a primary buttons",
1036
+ "name": "disabled-tooltip",
1037
+ "description": "Tooltip text when disabled",
1038
+ "type": "string"
1039
+ },
1040
+ {
1041
+ "name": "disabled",
1042
+ "description": "Disables the control",
1043
1043
  "type": "boolean",
1044
1044
  "default": "false"
1045
1045
  }
@@ -1051,12 +1051,6 @@
1051
1051
  "description": "ACCESSIBILITY: A description to be added to the main action button for accessibility when text does not provide enough context",
1052
1052
  "type": "string"
1053
1053
  },
1054
- {
1055
- "name": "disabledTooltip",
1056
- "attribute": "disabled-tooltip",
1057
- "description": "Tooltip text when disabled",
1058
- "type": "string"
1059
- },
1060
1054
  {
1061
1055
  "name": "key",
1062
1056
  "attribute": "key",
@@ -1074,16 +1068,22 @@
1074
1068
  "default": "\"css`\\n\\t\\t:host {\\n\\t\\t\\tdisplay: inline-block;\\n\\t\\t}\\n\\t\\t:host([hidden]) {\\n\\t\\t\\tdisplay: none;\\n\\t\\t}\\n\\t\\t.container {\\n\\t\\t\\tdisplay: flex;\\n\\t\\t\\tgap: 2px;\\n\\t\\t}\\n\\t\\t.main-action {\\n\\t\\t\\t--d2l-button-start-end-radius: 0;\\n\\t\\t\\t--d2l-button-end-end-radius: 0;\\n\\t\\t}\\n\\t\\t.d2l-dropdown-opener {\\n\\t\\t\\t--d2l-button-start-start-radius: 0;\\n\\t\\t\\t--d2l-button-end-start-radius: 0;\\n\\t\\t\\t--d2l-button-padding-inline-end: 0.6rem;\\n\\t\\t\\t--d2l-button-padding-inline-start: 0.6rem;\\n\\t\\t}\\n\\t\\t.d2l-dropdown-opener[primary] > d2l-icon {\\n\\t\\t\\tcolor: #ffffff;\\n\\t\\t}\\n\\t\\t::slotted(:not(d2l-button-split-item)) {\\n\\t\\t\\tdisplay: none;\\n\\t\\t}\\n\\t\\t.main-action-focus-visible .d2l-dropdown-opener {\\n\\t\\t\\t--d2l-button-padding-inline-start: calc(0.6rem - 4px);\\n\\t\\t\\tmargin-inline-start: 4px;\\n\\t\\t}\\n\\t\\t.menu-opener-focus-visible .main-action {\\n\\t\\t\\t--d2l-button-padding-inline-end: calc(1.5rem - 4px);\\n\\t\\t\\tmargin-inline-end: 4px;\\n\\t\\t}\\n\\t`\""
1075
1069
  },
1076
1070
  {
1077
- "name": "disabled",
1078
- "attribute": "disabled",
1079
- "description": "Disables the main action and dropdown opener buttons",
1071
+ "name": "primary",
1072
+ "attribute": "primary",
1073
+ "description": "Styles the buttons as a primary buttons",
1080
1074
  "type": "boolean",
1081
1075
  "default": "false"
1082
1076
  },
1083
1077
  {
1084
- "name": "primary",
1085
- "attribute": "primary",
1086
- "description": "Styles the buttons as a primary buttons",
1078
+ "name": "disabledTooltip",
1079
+ "attribute": "disabled-tooltip",
1080
+ "description": "Tooltip text when disabled",
1081
+ "type": "string"
1082
+ },
1083
+ {
1084
+ "name": "disabled",
1085
+ "attribute": "disabled",
1086
+ "description": "Disables the control",
1087
1087
  "type": "boolean",
1088
1088
  "default": "false"
1089
1089
  }
@@ -1205,7 +1205,7 @@
1205
1205
  },
1206
1206
  {
1207
1207
  "name": "disabled",
1208
- "description": "Disables the button",
1208
+ "description": "Disables the control",
1209
1209
  "type": "boolean",
1210
1210
  "default": "false"
1211
1211
  }
@@ -1260,20 +1260,20 @@
1260
1260
  "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
1261
1261
  "type": "'true' | 'false'"
1262
1262
  },
1263
+ {
1264
+ "name": "isButtonMixin",
1265
+ "type": "boolean"
1266
+ },
1263
1267
  {
1264
1268
  "name": "disabledTooltip",
1265
1269
  "attribute": "disabled-tooltip",
1266
1270
  "description": "Tooltip text when disabled",
1267
1271
  "type": "string"
1268
1272
  },
1269
- {
1270
- "name": "isButtonMixin",
1271
- "type": "boolean"
1272
- },
1273
1273
  {
1274
1274
  "name": "disabled",
1275
1275
  "attribute": "disabled",
1276
- "description": "Disables the button",
1276
+ "description": "Disables the control",
1277
1277
  "type": "boolean",
1278
1278
  "default": "false"
1279
1279
  }
@@ -1353,7 +1353,7 @@
1353
1353
  },
1354
1354
  {
1355
1355
  "name": "disabled",
1356
- "description": "Disables the button",
1356
+ "description": "Disables the control",
1357
1357
  "type": "boolean",
1358
1358
  "default": "false"
1359
1359
  }
@@ -1383,20 +1383,20 @@
1383
1383
  "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
1384
1384
  "type": "'true' | 'false'"
1385
1385
  },
1386
+ {
1387
+ "name": "isButtonMixin",
1388
+ "type": "boolean"
1389
+ },
1386
1390
  {
1387
1391
  "name": "disabledTooltip",
1388
1392
  "attribute": "disabled-tooltip",
1389
1393
  "description": "Tooltip text when disabled",
1390
1394
  "type": "string"
1391
1395
  },
1392
- {
1393
- "name": "isButtonMixin",
1394
- "type": "boolean"
1395
- },
1396
1396
  {
1397
1397
  "name": "disabled",
1398
1398
  "attribute": "disabled",
1399
- "description": "Disables the button",
1399
+ "description": "Disables the control",
1400
1400
  "type": "boolean",
1401
1401
  "default": "false"
1402
1402
  }
@@ -14767,7 +14767,7 @@
14767
14767
  },
14768
14768
  {
14769
14769
  "name": "disabled",
14770
- "description": "Disables the button",
14770
+ "description": "Disables the control",
14771
14771
  "type": "boolean",
14772
14772
  "default": "false"
14773
14773
  }
@@ -14823,20 +14823,20 @@
14823
14823
  "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
14824
14824
  "type": "'true' | 'false'"
14825
14825
  },
14826
+ {
14827
+ "name": "isButtonMixin",
14828
+ "type": "boolean"
14829
+ },
14826
14830
  {
14827
14831
  "name": "disabledTooltip",
14828
14832
  "attribute": "disabled-tooltip",
14829
14833
  "description": "Tooltip text when disabled",
14830
14834
  "type": "string"
14831
14835
  },
14832
- {
14833
- "name": "isButtonMixin",
14834
- "type": "boolean"
14835
- },
14836
14836
  {
14837
14837
  "name": "disabled",
14838
14838
  "attribute": "disabled",
14839
- "description": "Disables the button",
14839
+ "description": "Disables the control",
14840
14840
  "type": "boolean",
14841
14841
  "default": "false"
14842
14842
  }
@@ -18371,6 +18371,38 @@
18371
18371
  }
18372
18372
  ]
18373
18373
  },
18374
+ {
18375
+ "name": "disabled-tooltip-test",
18376
+ "path": "./mixins/disabled-tooltip/test/disabled-tooltip-mixin-test.js",
18377
+ "attributes": [
18378
+ {
18379
+ "name": "disabled-tooltip",
18380
+ "description": "Tooltip text when disabled",
18381
+ "type": "string"
18382
+ },
18383
+ {
18384
+ "name": "disabled",
18385
+ "description": "Disables the control",
18386
+ "type": "boolean",
18387
+ "default": "false"
18388
+ }
18389
+ ],
18390
+ "properties": [
18391
+ {
18392
+ "name": "disabledTooltip",
18393
+ "attribute": "disabled-tooltip",
18394
+ "description": "Tooltip text when disabled",
18395
+ "type": "string"
18396
+ },
18397
+ {
18398
+ "name": "disabled",
18399
+ "attribute": "disabled",
18400
+ "description": "Disables the control",
18401
+ "type": "boolean",
18402
+ "default": "false"
18403
+ }
18404
+ ]
18405
+ },
18374
18406
  {
18375
18407
  "name": "d2l-greeting",
18376
18408
  "path": "./mixins/localize/demo/localize-mixin-greeting.js",
@@ -0,0 +1,42 @@
1
+ import { html, nothing } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+
4
+ export const DisabledTooltipMixin = superclass => class extends superclass {
5
+ static properties = {
6
+ /**
7
+ * Disables the control
8
+ * @type {boolean}
9
+ */
10
+ disabled: { type: Boolean, reflect: true },
11
+ /**
12
+ * Tooltip text when disabled
13
+ * @type {string}
14
+ */
15
+ disabledTooltip: { type: String, attribute: 'disabled-tooltip' }
16
+ };
17
+
18
+ constructor() {
19
+ super();
20
+ this.disabled = false;
21
+ }
22
+
23
+ get _ariaDisabled() {
24
+ return ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined);
25
+ }
26
+
27
+ get _disabled() {
28
+ return this.disabled && !this.disabledTooltip;
29
+ }
30
+
31
+ _renderDisabledTooltip(controlId, { align = undefined, forceShow = false, position = undefined } = {}) {
32
+ if (!this.disabled || !this.disabledTooltip) return nothing;
33
+ return html`<d2l-tooltip
34
+ align=${ifDefined(align)}
35
+ class="vdiff-target"
36
+ for="${controlId}"
37
+ ?force-show=${forceShow}
38
+ position=${ifDefined(position)}>
39
+ ${this.disabledTooltip}
40
+ </d2l-tooltip>`;
41
+ }
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.344.13",
3
+ "version": "3.345.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",