@brightspace-ui/core 2.104.2 → 2.105.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.
@@ -1,12 +1,14 @@
1
1
  import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import '../tooltip/tooltip.js';
4
- import { css, html, LitElement } from 'lit';
4
+ import { css, html, LitElement, unsafeCSS } from 'lit';
5
5
  import { buttonStyles } from './button-styles.js';
6
6
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
7
+ import { getFocusPseudoClass } from '../../helpers/focus.js';
7
8
  import { getUniqueId } from '../../helpers/uniqueId.js';
8
9
  import { ifDefined } from 'lit/directives/if-defined.js';
9
10
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
11
+ import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
10
12
 
11
13
  const keyCodes = Object.freeze({
12
14
  DOWN: 40,
@@ -31,7 +33,7 @@ export const moveActions = Object.freeze({
31
33
  /**
32
34
  * A button component that provides a move action via a single button.
33
35
  */
34
- class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
36
+ class ButtonMove extends ThemeMixin(FocusMixin(RtlMixin(LitElement))) {
35
37
 
36
38
  static get properties() {
37
39
  return {
@@ -45,15 +47,35 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
45
47
  */
46
48
  description: { type: String },
47
49
  /**
48
- * Disables the button
50
+ * Disables the down interaction
49
51
  * @type {boolean}
50
52
  */
51
- disabled: { type: Boolean, reflect: true },
53
+ disabledDown: { type: Boolean, attribute: 'disabled-down', reflect: true },
52
54
  /**
53
- * Tooltip text when disabled
54
- * @type {string}
55
+ * Disables the end interaction
56
+ * @type {boolean}
57
+ */
58
+ disabledEnd: { type: Boolean, attribute: 'disabled-end', reflect: true },
59
+ /**
60
+ * Disables the home interaction
61
+ * @type {boolean}
62
+ */
63
+ disabledHome: { type: Boolean, attribute: 'disabled-home', reflect: true },
64
+ /**
65
+ * Disables the left interaction
66
+ * @type {boolean}
55
67
  */
56
- disabledTooltip: { type: String, attribute: 'disabled-tooltip' },
68
+ disabledLeft: { type: Boolean, attribute: 'disabled-left', reflect: true },
69
+ /**
70
+ * Disables the right interaction
71
+ * @type {boolean}
72
+ */
73
+ disabledRight: { type: Boolean, attribute: 'disabled-right', reflect: true },
74
+ /**
75
+ * Disables the up interaction
76
+ * @type {boolean}
77
+ */
78
+ disabledUp: { type: Boolean, attribute: 'disabled-up', reflect: true },
57
79
  /**
58
80
  * REQUIRED: Accessible text for the button
59
81
  * @type {string}
@@ -67,12 +89,22 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
67
89
  return [ buttonStyles,
68
90
  css`
69
91
  :host {
92
+ --d2l-button-move-background-color-focus: #ffffff;
93
+ --d2l-button-move-icon-background-color-hover: var(--d2l-color-mica);
94
+ --d2l-button-move-box-shadow-focus: 0 0 0 2px #ffffff, 0 0 0 4px var(--d2l-color-celestine);
95
+ --d2l-icon-fill-color: var(--d2l-color-tungsten);
70
96
  display: inline-block;
71
97
  line-height: 0;
72
98
  }
73
99
  :host([hidden]) {
74
100
  display: none;
75
101
  }
102
+ :host([theme="dark"]) {
103
+ --d2l-button-move-background-color-focus: #000000;
104
+ --d2l-button-move-icon-background-color-hover: rgba(51, 53, 54, 0.9); /* tungsten @70% @90% */
105
+ --d2l-button-move-box-shadow-focus: 0 0 0 2px black, 0 0 0 4px var(--d2l-color-celestine-plus-1);
106
+ --d2l-icon-fill-color: var(--d2l-color-sylvite);
107
+ }
76
108
  button {
77
109
  background-color: transparent;
78
110
  display: flex;
@@ -90,11 +122,14 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
90
122
  width: 0.9rem;
91
123
  }
92
124
  button:focus {
93
- background-color: #ffffff;
125
+ background-color: var(--d2l-button-move-background-color-focus);
94
126
  }
95
127
  button:hover > d2l-icon,
96
128
  button:focus > d2l-icon {
97
- background-color: var(--d2l-color-mica);
129
+ background-color: var(--d2l-button-move-icon-background-color-hover);
130
+ }
131
+ button:${unsafeCSS(getFocusPseudoClass())} {
132
+ box-shadow: var(--d2l-button-move-box-shadow-focus);
98
133
  }
99
134
  .up-icon {
100
135
  border-top-left-radius: 0.3rem;
@@ -124,25 +159,27 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
124
159
  right: -0.2rem;
125
160
  }
126
161
 
127
-
128
162
  /* Firefox includes a hidden border which messes up button dimensions */
129
163
  button::-moz-focus-inner {
130
164
  border: 0;
131
165
  }
132
- :host([disabled]) button {
133
- cursor: default;
134
- opacity: 0.5;
135
- }
136
166
  button[disabled]:hover > d2l-icon {
137
167
  background-color: transparent;
138
168
  }
169
+ :host([disabled-up]) .up-icon,
170
+ :host([disabled-down]) .down-icon {
171
+ opacity: 0.5;
172
+ }
173
+ :host([disabled-up]) .up-layer,
174
+ :host([disabled-down]) .down-layer {
175
+ cursor: default;
176
+ }
139
177
  `
140
178
  ];
141
179
  }
142
180
 
143
181
  constructor() {
144
182
  super();
145
- this.disabled = false;
146
183
  /** @ignore */
147
184
  this.autofocus = false;
148
185
  /** @internal */
@@ -155,24 +192,13 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
155
192
  return 'button';
156
193
  }
157
194
 
158
- connectedCallback() {
159
- super.connectedCallback();
160
- this.addEventListener('click', this._handleClick, true);
161
- }
162
-
163
- disconnectedCallback() {
164
- super.disconnectedCallback();
165
- this.removeEventListener('click', this._handleClick, true);
166
- }
167
-
168
195
  render() {
169
196
  return html`
170
197
  <button
171
198
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
172
- aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
173
199
  aria-label="${ifDefined(this.text)}"
174
200
  ?autofocus="${this.autofocus}"
175
- ?disabled="${this.disabled && !this.disabledTooltip}"
201
+ ?disabled="${this.disabledUp && this.disabledDown && this.disabledLeft && this.disabledRight && this.disabledHome && this.disabledEnd}"
176
202
  id="${this._buttonId}"
177
203
  @keydown="${this._handleKeydown}"
178
204
  title="${ifDefined(this.text)}"
@@ -183,7 +209,6 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
183
209
  <div class="down-layer" @click="${this._handleDownClick}"></div>
184
210
  </button>
185
211
  ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
186
- ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
187
212
  `;
188
213
  }
189
214
 
@@ -195,48 +220,45 @@ class ButtonMove extends FocusMixin(RtlMixin(LitElement)) {
195
220
  }));
196
221
  }
197
222
 
198
- _handleClick(e) {
199
- if (this.disabled) {
200
- e.stopPropagation();
201
- }
202
- }
203
-
204
223
  _handleDownClick() {
224
+ if (this.disabledDown) return;
205
225
  this._dispatchAction(moveActions.down);
206
226
  }
207
227
 
208
228
  _handleKeydown(e) {
229
+
209
230
  let action;
210
231
  switch (e.keyCode) {
211
232
  case keyCodes.UP:
212
- action = moveActions.up;
233
+ if (!this.disabledUp) action = moveActions.up;
213
234
  break;
214
235
  case keyCodes.DOWN:
215
- action = moveActions.down;
236
+ if (!this.disabledDown) action = moveActions.down;
216
237
  break;
217
238
  case keyCodes.LEFT:
218
- action = moveActions.left;
239
+ if (!this.disabledLeft) action = moveActions.left;
219
240
  break;
220
241
  case keyCodes.RIGHT:
221
- action = moveActions.right;
242
+ if (!this.disabledRight) action = moveActions.right;
222
243
  break;
223
244
  case keyCodes.HOME:
224
- action = (e.ctrlKey ? moveActions.rootHome : moveActions.home);
245
+ if (!this.disabledHome) action = (e.ctrlKey ? moveActions.rootHome : moveActions.home);
225
246
  break;
226
247
  case keyCodes.END:
227
- action = (e.ctrlKey ? moveActions.rootEnd : moveActions.end);
248
+ if (!this.disabledEnd) action = (e.ctrlKey ? moveActions.rootEnd : moveActions.end);
228
249
  break;
229
250
  default:
230
251
  return;
231
252
  }
232
253
 
233
- this._dispatchAction(action);
254
+ if (action) this._dispatchAction(action);
234
255
  e.preventDefault();
235
256
  e.stopPropagation();
236
257
 
237
258
  }
238
259
 
239
260
  _handleUpClick() {
261
+ if (this.disabledUp) return;
240
262
  this._dispatchAction(moveActions.up);
241
263
  }
242
264
 
@@ -30,15 +30,7 @@
30
30
 
31
31
  <d2l-demo-snippet>
32
32
  <template>
33
- <d2l-button-move text="Reorder Item" disabled></d2l-button-move>
34
- </template>
35
- </d2l-demo-snippet>
36
-
37
- <h2>Move Button Disabled with Tooltip</h2>
38
-
39
- <d2l-demo-snippet>
40
- <template>
41
- <d2l-button-move text="Reorder Item" disabled disabled-tooltip="Optional disabled tooltip"></d2l-button-move>
33
+ <d2l-button-move text="Reorder Item" disabled-up disabled-down disabled-left disabled-right disabled-home disabled-end></d2l-button-move>
42
34
  </template>
43
35
  </d2l-demo-snippet>
44
36
 
@@ -449,20 +449,39 @@
449
449
  "type": "string"
450
450
  },
451
451
  {
452
- "name": "disabled-tooltip",
453
- "description": "Tooltip text when disabled",
454
- "type": "string"
452
+ "name": "disabled-down",
453
+ "description": "Disables the down interaction",
454
+ "type": "boolean"
455
+ },
456
+ {
457
+ "name": "disabled-end",
458
+ "description": "Disables the end interaction",
459
+ "type": "boolean"
460
+ },
461
+ {
462
+ "name": "disabled-home",
463
+ "description": "Disables the home interaction",
464
+ "type": "boolean"
465
+ },
466
+ {
467
+ "name": "disabled-left",
468
+ "description": "Disables the left interaction",
469
+ "type": "boolean"
470
+ },
471
+ {
472
+ "name": "disabled-right",
473
+ "description": "Disables the right interaction",
474
+ "type": "boolean"
475
+ },
476
+ {
477
+ "name": "disabled-up",
478
+ "description": "Disables the up interaction",
479
+ "type": "boolean"
455
480
  },
456
481
  {
457
482
  "name": "text",
458
483
  "description": "REQUIRED: Accessible text for the button",
459
484
  "type": "string"
460
- },
461
- {
462
- "name": "disabled",
463
- "description": "Disables the button",
464
- "type": "boolean",
465
- "default": "false"
466
485
  }
467
486
  ],
468
487
  "properties": [
@@ -473,23 +492,46 @@
473
492
  "type": "string"
474
493
  },
475
494
  {
476
- "name": "disabledTooltip",
477
- "attribute": "disabled-tooltip",
478
- "description": "Tooltip text when disabled",
479
- "type": "string"
495
+ "name": "disabledDown",
496
+ "attribute": "disabled-down",
497
+ "description": "Disables the down interaction",
498
+ "type": "boolean"
499
+ },
500
+ {
501
+ "name": "disabledEnd",
502
+ "attribute": "disabled-end",
503
+ "description": "Disables the end interaction",
504
+ "type": "boolean"
505
+ },
506
+ {
507
+ "name": "disabledHome",
508
+ "attribute": "disabled-home",
509
+ "description": "Disables the home interaction",
510
+ "type": "boolean"
511
+ },
512
+ {
513
+ "name": "disabledLeft",
514
+ "attribute": "disabled-left",
515
+ "description": "Disables the left interaction",
516
+ "type": "boolean"
517
+ },
518
+ {
519
+ "name": "disabledRight",
520
+ "attribute": "disabled-right",
521
+ "description": "Disables the right interaction",
522
+ "type": "boolean"
523
+ },
524
+ {
525
+ "name": "disabledUp",
526
+ "attribute": "disabled-up",
527
+ "description": "Disables the up interaction",
528
+ "type": "boolean"
480
529
  },
481
530
  {
482
531
  "name": "text",
483
532
  "attribute": "text",
484
533
  "description": "REQUIRED: Accessible text for the button",
485
534
  "type": "string"
486
- },
487
- {
488
- "name": "disabled",
489
- "attribute": "disabled",
490
- "description": "Disables the button",
491
- "type": "boolean",
492
- "default": "false"
493
535
  }
494
536
  ],
495
537
  "events": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.104.2",
3
+ "version": "2.105.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",