@brightspace-ui/core 3.101.2 → 3.102.1

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,3 +1,5 @@
1
+ const defaultLines = 2;
2
+
1
3
  export const MenuItemMixin = superclass => class extends superclass {
2
4
 
3
5
  static get properties() {
@@ -24,6 +26,11 @@ export const MenuItemMixin = superclass => class extends superclass {
24
26
  * @ignore
25
27
  */
26
28
  last: { type: String, reflect: true }, // set by d2l-menu
29
+ /**
30
+ * The number of lines to display before truncating text with an ellipsis. Defaults to 2.
31
+ * @type {number}
32
+ */
33
+ lines: { type: Number },
27
34
  /**
28
35
  * @ignore
29
36
  */
@@ -60,6 +67,7 @@ export const MenuItemMixin = superclass => class extends superclass {
60
67
  this.__children = null;
61
68
 
62
69
  this.disabled = false;
70
+ this.lines = defaultLines;
63
71
  /** @ignore */
64
72
  this.role = 'menuitem';
65
73
  /** @ignore */
@@ -83,14 +91,25 @@ export const MenuItemMixin = superclass => class extends superclass {
83
91
 
84
92
  updated(changedProperties) {
85
93
  super.updated(changedProperties);
94
+ if (changedProperties.has('hidden')) this._onHidden();
95
+ }
86
96
 
97
+ willUpdate(changedProperties) {
98
+ super.willUpdate(changedProperties);
87
99
  changedProperties.forEach((oldValue, propName) => {
88
- if (propName === 'hidden') {
89
- this._onHidden();
90
- } else if (propName === 'disabled') {
91
- this._ariaDisabled = this.disabled ? 'true' : 'false';
92
- } else if (propName === 'text' || propName === 'description') {
93
- this._ariaLabel = this.description || this.text;
100
+ switch (propName) {
101
+ case 'text':
102
+ case 'description':
103
+ this._ariaLabel = this.description || this.text;
104
+ break;
105
+ case 'disabled':
106
+ this._ariaDisabled = this.disabled ? 'true' : 'false';
107
+ break;
108
+ case 'lines':
109
+ if (!(changedProperties.get('lines') === undefined && this.lines === defaultLines)) {
110
+ this.style.setProperty('--d2l-menu-item-lines', this.lines);
111
+ }
112
+ break;
94
113
  }
95
114
  });
96
115
  }
@@ -39,9 +39,9 @@ class MenuItemReturn extends RtlMixin(LocalizeCoreElement(MenuItemMixin(LitEleme
39
39
  ];
40
40
  }
41
41
 
42
- firstUpdated() {
43
- super.firstUpdated();
44
- this.setAttribute('aria-label', this.localize('components.menu-item-return.return'));
42
+ constructor() {
43
+ super();
44
+ this.text = null;
45
45
  }
46
46
 
47
47
  render() {
@@ -51,14 +51,15 @@ class MenuItemReturn extends RtlMixin(LocalizeCoreElement(MenuItemMixin(LitEleme
51
51
  `;
52
52
  }
53
53
 
54
- updated(changedProperties) {
55
- super.updated(changedProperties);
56
-
57
- changedProperties.forEach((oldValue, propName) => {
58
- if (propName === 'text') {
54
+ willUpdate(changedProperties) {
55
+ super.willUpdate(changedProperties);
56
+ if (changedProperties.has('text')) {
57
+ if (this.text) {
59
58
  this.setAttribute('aria-label', this.localize('components.menu-item-return.returnCurrentlyShowing', 'menuTitle', this.text));
59
+ } else {
60
+ this.setAttribute('aria-label', this.localize('components.menu-item-return.return'));
60
61
  }
61
- });
62
+ }
62
63
  }
63
64
 
64
65
  }
@@ -4,6 +4,7 @@ import { getFocusPseudoClass } from '../../helpers/focus.js';
4
4
 
5
5
  export const menuItemStyles = css`
6
6
  :host {
7
+ --d2l-menu-item-lines: 2;
7
8
  background-color: var(--d2l-menu-background-color);
8
9
  border-top: 1px solid var(--d2l-menu-border-color);
9
10
  box-sizing: border-box;
@@ -53,7 +54,7 @@ export const menuItemStyles = css`
53
54
  -webkit-box-orient: vertical;
54
55
  display: -webkit-box;
55
56
  flex: auto;
56
- -webkit-line-clamp: 2;
57
+ -webkit-line-clamp: var(--d2l-menu-item-lines, 2);
57
58
  line-height: 1rem;
58
59
  overflow-wrap: anywhere;
59
60
  overflow-x: hidden;
@@ -9539,6 +9539,12 @@
9539
9539
  "description": "Disables the menu item",
9540
9540
  "type": "boolean",
9541
9541
  "default": "false"
9542
+ },
9543
+ {
9544
+ "name": "lines",
9545
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9546
+ "type": "number",
9547
+ "default": "2"
9542
9548
  }
9543
9549
  ],
9544
9550
  "properties": [
@@ -9560,6 +9566,13 @@
9560
9566
  "description": "Disables the menu item",
9561
9567
  "type": "boolean",
9562
9568
  "default": "false"
9569
+ },
9570
+ {
9571
+ "name": "lines",
9572
+ "attribute": "lines",
9573
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9574
+ "type": "number",
9575
+ "default": "2"
9563
9576
  }
9564
9577
  ],
9565
9578
  "events": [
@@ -9608,6 +9621,12 @@
9608
9621
  "description": "Disables the menu item",
9609
9622
  "type": "boolean",
9610
9623
  "default": "false"
9624
+ },
9625
+ {
9626
+ "name": "lines",
9627
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9628
+ "type": "number",
9629
+ "default": "2"
9611
9630
  }
9612
9631
  ],
9613
9632
  "properties": [
@@ -9642,6 +9661,13 @@
9642
9661
  "description": "Disables the menu item",
9643
9662
  "type": "boolean",
9644
9663
  "default": "false"
9664
+ },
9665
+ {
9666
+ "name": "lines",
9667
+ "attribute": "lines",
9668
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9669
+ "type": "number",
9670
+ "default": "2"
9645
9671
  }
9646
9672
  ],
9647
9673
  "events": [
@@ -9700,6 +9726,12 @@
9700
9726
  "description": "Disables the menu item",
9701
9727
  "type": "boolean",
9702
9728
  "default": "false"
9729
+ },
9730
+ {
9731
+ "name": "lines",
9732
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9733
+ "type": "number",
9734
+ "default": "2"
9703
9735
  }
9704
9736
  ],
9705
9737
  "properties": [
@@ -9739,6 +9771,13 @@
9739
9771
  "description": "Disables the menu item",
9740
9772
  "type": "boolean",
9741
9773
  "default": "false"
9774
+ },
9775
+ {
9776
+ "name": "lines",
9777
+ "attribute": "lines",
9778
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9779
+ "type": "number",
9780
+ "default": "2"
9742
9781
  }
9743
9782
  ],
9744
9783
  "events": [
@@ -9793,6 +9832,12 @@
9793
9832
  "description": "Disables the menu item",
9794
9833
  "type": "boolean",
9795
9834
  "default": "false"
9835
+ },
9836
+ {
9837
+ "name": "lines",
9838
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9839
+ "type": "number",
9840
+ "default": "2"
9796
9841
  }
9797
9842
  ],
9798
9843
  "properties": [
@@ -9827,6 +9872,13 @@
9827
9872
  "description": "Disables the menu item",
9828
9873
  "type": "boolean",
9829
9874
  "default": "false"
9875
+ },
9876
+ {
9877
+ "name": "lines",
9878
+ "attribute": "lines",
9879
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9880
+ "type": "number",
9881
+ "default": "2"
9830
9882
  }
9831
9883
  ],
9832
9884
  "events": [
@@ -9869,6 +9921,12 @@
9869
9921
  "description": "Disables the menu item",
9870
9922
  "type": "boolean",
9871
9923
  "default": "false"
9924
+ },
9925
+ {
9926
+ "name": "lines",
9927
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9928
+ "type": "number",
9929
+ "default": "2"
9872
9930
  }
9873
9931
  ],
9874
9932
  "properties": [
@@ -9890,6 +9948,13 @@
9890
9948
  "description": "Disables the menu item",
9891
9949
  "type": "boolean",
9892
9950
  "default": "false"
9951
+ },
9952
+ {
9953
+ "name": "lines",
9954
+ "attribute": "lines",
9955
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
9956
+ "type": "number",
9957
+ "default": "2"
9893
9958
  }
9894
9959
  ],
9895
9960
  "events": [
@@ -9928,6 +9993,12 @@
9928
9993
  "description": "Disables the menu item",
9929
9994
  "type": "boolean",
9930
9995
  "default": "false"
9996
+ },
9997
+ {
9998
+ "name": "lines",
9999
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
10000
+ "type": "number",
10001
+ "default": "2"
9931
10002
  }
9932
10003
  ],
9933
10004
  "properties": [
@@ -9949,6 +10020,13 @@
9949
10020
  "description": "Disables the menu item",
9950
10021
  "type": "boolean",
9951
10022
  "default": "false"
10023
+ },
10024
+ {
10025
+ "name": "lines",
10026
+ "attribute": "lines",
10027
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
10028
+ "type": "number",
10029
+ "default": "2"
9952
10030
  }
9953
10031
  ],
9954
10032
  "events": [
@@ -11139,6 +11217,12 @@
11139
11217
  "description": "Disables the menu item",
11140
11218
  "type": "boolean",
11141
11219
  "default": "false"
11220
+ },
11221
+ {
11222
+ "name": "lines",
11223
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
11224
+ "type": "number",
11225
+ "default": "2"
11142
11226
  }
11143
11227
  ],
11144
11228
  "properties": [
@@ -11183,6 +11267,13 @@
11183
11267
  "description": "Disables the menu item",
11184
11268
  "type": "boolean",
11185
11269
  "default": "false"
11270
+ },
11271
+ {
11272
+ "name": "lines",
11273
+ "attribute": "lines",
11274
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
11275
+ "type": "number",
11276
+ "default": "2"
11186
11277
  }
11187
11278
  ],
11188
11279
  "events": [
@@ -12393,6 +12484,12 @@
12393
12484
  "description": "Disables the menu item",
12394
12485
  "type": "boolean",
12395
12486
  "default": "false"
12487
+ },
12488
+ {
12489
+ "name": "lines",
12490
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
12491
+ "type": "number",
12492
+ "default": "2"
12396
12493
  }
12397
12494
  ],
12398
12495
  "properties": [
@@ -12427,6 +12524,13 @@
12427
12524
  "description": "Disables the menu item",
12428
12525
  "type": "boolean",
12429
12526
  "default": "false"
12527
+ },
12528
+ {
12529
+ "name": "lines",
12530
+ "attribute": "lines",
12531
+ "description": "The number of lines to display before truncating text with an ellipsis. Defaults to 2.",
12532
+ "type": "number",
12533
+ "default": "2"
12430
12534
  }
12431
12535
  ],
12432
12536
  "events": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.101.2",
3
+ "version": "3.102.1",
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",