@brightspace-ui/core 1.197.0 → 1.197.4
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.
- package/components/dropdown/README.md +4 -0
- package/components/dropdown/demo/dropdown-button.html +30 -0
- package/components/dropdown/dropdown-content-styles.js +13 -0
- package/components/dropdown/dropdown-opener-mixin.js +235 -24
- package/components/filter/README.md +15 -6
- package/components/filter/filter-dimension-set-value.js +3 -0
- package/components/filter/filter-dimension-set.js +5 -1
- package/components/filter/screenshots/filter-mobile.png +0 -0
- package/components/filter/screenshots/filter-multi-dim.png +0 -0
- package/components/filter/screenshots/filter.png +0 -0
- package/components/form/form-mixin.js +1 -0
- package/components/form/form-native.js +0 -1
- package/components/form/form.js +0 -1
- package/components/html-block/html-block.js +8 -0
- package/components/inputs/docs/input-date-time.md +7 -7
- package/components/inputs/input-date-range.js +9 -1
- package/components/inputs/input-date-time-range-to.js +3 -0
- package/components/inputs/input-date-time-range.js +10 -1
- package/components/inputs/input-date-time.js +7 -1
- package/components/inputs/input-date.js +7 -1
- package/components/inputs/input-fieldset.js +3 -0
- package/components/inputs/input-time-range.js +10 -1
- package/components/inputs/input-time.js +6 -1
- package/components/link/README.md +1 -1
- package/components/list/README.md +10 -10
- package/components/list/list-item-button-mixin.js +1 -0
- package/components/list/list-item-button.js +0 -3
- package/components/list/list-item-checkbox-mixin.js +1 -0
- package/components/list/list-item-drag-drop-mixin.js +2 -0
- package/components/list/list-item-link-mixin.js +1 -0
- package/components/list/list-item.js +0 -3
- package/components/list/list.js +2 -0
- package/components/menu/menu-item-checkbox.js +0 -4
- package/components/menu/menu-item-link.js +0 -2
- package/components/menu/menu-item-mixin.js +3 -0
- package/components/menu/menu-item-radio.js +0 -3
- package/components/menu/menu-item-selectable-mixin.js +2 -0
- package/components/menu/menu-item.js +0 -2
- package/components/overflow-group/overflow-group.js +4 -3
- package/components/scroll-wrapper/scroll-wrapper.js +1 -2
- package/components/selection/selection-action.js +4 -0
- package/components/selection/selection-input.js +5 -0
- package/components/selection/selection-mixin.js +2 -1
- package/components/selection/selection-observer-mixin.js +3 -1
- package/components/selection/selection-select-all.js +2 -0
- package/components/selection/selection-summary.js +3 -1
- package/components/skeleton/skeleton-mixin.js +1 -0
- package/components/status-indicator/status-indicator.js +2 -0
- package/components/switch/switch-visibility.js +3 -0
- package/components/switch/switch.js +3 -0
- package/components/table/table-col-sort-button.js +0 -2
- package/components/table/table-wrapper.js +0 -2
- package/components/tabs/tab-panel-mixin.js +2 -0
- package/components/tabs/tab-panel.js +0 -2
- package/custom-elements.json +118 -48
- package/lang/ar.js +7 -7
- package/lang/cy.js +7 -7
- package/lang/da.js +7 -7
- package/lang/de.js +7 -7
- package/lang/es-es.js +7 -7
- package/lang/es.js +8 -8
- package/lang/fr-fr.js +8 -8
- package/lang/fr.js +7 -7
- package/lang/ja.js +8 -8
- package/lang/ko.js +7 -7
- package/lang/nl.js +8 -8
- package/lang/pt.js +7 -7
- package/lang/sv.js +7 -7
- package/lang/tr.js +7 -7
- package/lang/zh-tw.js +7 -7
- package/lang/zh.js +8 -8
- package/package.json +1 -1
- package/templates/primary-secondary/primary-secondary.js +2 -0
|
@@ -117,6 +117,7 @@ If the dropdown is initially empty when it's opened, the dropdown pointer will n
|
|
|
117
117
|
| `disabled` | Boolean, default: `false` | Disables the dropdown opener |
|
|
118
118
|
| `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from opening automatically on click or on key press |
|
|
119
119
|
| `primary` | Boolean, default: `false` | Optionally render button as primary button |
|
|
120
|
+
| `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
|
|
120
121
|
<!-- docs: end hidden content -->
|
|
121
122
|
|
|
122
123
|
## Opener: Button Subtle [d2l-dropdown-button-subtle]
|
|
@@ -160,6 +161,7 @@ If the dropdown is initially empty when it's opened, the dropdown pointer will n
|
|
|
160
161
|
| `description` | String | A description to be added to the inner `button` opener for accessibility |
|
|
161
162
|
| `disabled` | Boolean, default: `false` | Disables the dropdown opener |
|
|
162
163
|
| `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from automatically on click or on key press |
|
|
164
|
+
| `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
|
|
163
165
|
<!-- docs: end hidden content -->
|
|
164
166
|
|
|
165
167
|
### Accessibility Properties
|
|
@@ -209,6 +211,7 @@ To make your `d2l-dropdown-button-subtle` accessible, use the following properti
|
|
|
209
211
|
|---|---|---|
|
|
210
212
|
| `disabled` | Boolean, default: `false` | Disables the dropdown opener |
|
|
211
213
|
| `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from opening automatically on click or on key press |
|
|
214
|
+
| `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
|
|
212
215
|
| `text` | String | Used as `aria-label` for the button |
|
|
213
216
|
| `translucent` | Boolean, default: `false` | Attribute for busy/rich backgrounds |
|
|
214
217
|
| `visible-on-ancestor` | Boolean, default: `false` | See [visible-on-ancestor-mixin](../../mixins/visible-on-ancestor-mixin.md) for more details on configuring that behavior |
|
|
@@ -261,6 +264,7 @@ To make your usage of `d2l-dropdown-context-menu` accessible, use the following
|
|
|
261
264
|
|---|---|---|
|
|
262
265
|
| `disabled` | Boolean, default: `false` | Disables the dropdown opener |
|
|
263
266
|
| `no-auto-open` | Boolean, default: `false` | Prevents the dropdown from opening automatically on click or key press |
|
|
267
|
+
| `open-on-hover` | Boolean, default: `false` | Optionally open dropdown on click or hover action |
|
|
264
268
|
| `text` | String | Used as `aria-label` for the button |
|
|
265
269
|
| `translucent` | Boolean, default: `false` | Attribute for busy/rich backgrounds |
|
|
266
270
|
| `visible-on-ancestor` | Boolean, default: `false` | See [visible-on-ancestor-mixin](../../mixins/visible-on-ancestor-mixin.md) for more details on configuring that behavior |
|
|
@@ -65,6 +65,36 @@
|
|
|
65
65
|
</template>
|
|
66
66
|
</d2l-demo-snippet>
|
|
67
67
|
|
|
68
|
+
<h2>Dropdown Button Opener (open-on-hover Option)</h2>
|
|
69
|
+
<d2l-demo-snippet>
|
|
70
|
+
<template>
|
|
71
|
+
<d2l-dropdown-button text="Open!" open-on-hover>
|
|
72
|
+
<d2l-dropdown-content mobile-tray="right">
|
|
73
|
+
<div slot="header">
|
|
74
|
+
<h3>Scrolling is Fun</h3>
|
|
75
|
+
</div>
|
|
76
|
+
<a href="https://youtu.be/9ze87zQFSak">Google</a>
|
|
77
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
78
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
|
79
|
+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
80
|
+
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
81
|
+
anim id est laborum.Vestibulum vel sem non orci pretium fringilla sed eget augue. Vestibulum malesuada tortor
|
|
82
|
+
vitae odio elementum eleifend. Quisque ligula quam, ornare id malesuada ut, malesuada eleifend sem. Nulla porta
|
|
83
|
+
in arcu quis gravida. Duis ac sagittis felis, in condimentum libero. In dolor risus, semper vel iaculis vitae,
|
|
84
|
+
pellentesque efficitur lorem. Nunc a lacus malesuada, rhoncus risus aliquam, sodales nulla. Sed in varius elit.
|
|
85
|
+
Duis sagittis, turpis ut vehicula elementum, velit mi tincidunt turpis, sit amet sagittis quam urna ut justo.
|
|
86
|
+
Nunc interdum urna augue, ac pretium dui pulvinar eu. Proin vehicula placerat est, sed venenatis purus viverra
|
|
87
|
+
eget. Suspendisse imperdiet nulla eget velit sodales, sit amet tempus metus dignissim. Sed ac luctus leo, a
|
|
88
|
+
ornare nisl. Proin non sapien eu orci gravida aliquam. Praesent placerat auctor lacus sit amet faucibus.
|
|
89
|
+
Suspendisse sit amet dui sed turpis vestibulum dignissim.</p>
|
|
90
|
+
<div slot="footer">
|
|
91
|
+
<a href="http://www.desire2learn.com">D2L</a>
|
|
92
|
+
</div>
|
|
93
|
+
</d2l-dropdown-content>
|
|
94
|
+
</d2l-dropdown-button>
|
|
95
|
+
</template>
|
|
96
|
+
</d2l-demo-snippet>
|
|
97
|
+
|
|
68
98
|
</d2l-demo-page>
|
|
69
99
|
|
|
70
100
|
</body>
|
|
@@ -172,6 +172,19 @@ export const dropdownContentStyles = css`
|
|
|
172
172
|
text-align: right;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
:host(.d2l-dropdown-content-fading) {
|
|
176
|
+
opacity: 0;
|
|
177
|
+
/* matches DropdownOpenerMixin _closeTimerStart function */
|
|
178
|
+
transition: opacity 0.4s ease-out 0.3s;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@media (prefers-reduced-motion: reduce) {
|
|
182
|
+
:host(.d2l-dropdown-content-fading) {
|
|
183
|
+
opacity: 1;
|
|
184
|
+
transition: none;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
@media (prefers-reduced-motion: reduce) {
|
|
176
189
|
:host([opened]), :host([opened-above]) {
|
|
177
190
|
animation: none !important;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
2
|
+
import { isComposedAncestor } from '../../helpers/dom.js';
|
|
3
|
+
|
|
1
4
|
export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
2
5
|
|
|
3
6
|
static get properties() {
|
|
@@ -27,6 +30,19 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
27
30
|
reflect: true,
|
|
28
31
|
attribute: 'no-auto-open'
|
|
29
32
|
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Optionally open dropdown on click or hover action
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
openOnHover: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
attribute: 'open-on-hover'
|
|
41
|
+
},
|
|
42
|
+
_isHovering: { type: Boolean },
|
|
43
|
+
_isOpen: { type: Boolean },
|
|
44
|
+
_isOpenedViaClick: { type: Boolean },
|
|
45
|
+
_isFading: { type: Boolean }
|
|
30
46
|
};
|
|
31
47
|
}
|
|
32
48
|
|
|
@@ -34,36 +50,52 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
34
50
|
super();
|
|
35
51
|
this.dropdownOpener = true;
|
|
36
52
|
this.noAutoOpen = false;
|
|
53
|
+
this.openOnHover = false;
|
|
37
54
|
this.disabled = false;
|
|
38
55
|
|
|
39
|
-
|
|
56
|
+
// hover option
|
|
57
|
+
this._dismissTimerId = getUniqueId();
|
|
58
|
+
this._isOpen = false;
|
|
59
|
+
this._isOpenedViaClick = false;
|
|
60
|
+
this._isHovering = false;
|
|
61
|
+
this._isFading = false;
|
|
62
|
+
|
|
63
|
+
this.__onWholeKeypress = this.__onKeypress.bind(this);
|
|
40
64
|
this.__onMouseUp = this.__onMouseUp.bind(this);
|
|
65
|
+
this.__onMouseEnter = this.__onMouseEnter.bind(this);
|
|
66
|
+
this.__onMouseLeave = this.__onMouseLeave.bind(this);
|
|
67
|
+
this.__onTouchStart = this.__onTouchStart.bind(this);
|
|
68
|
+
this._contentRendered = null;
|
|
69
|
+
this._openerRendered = null;
|
|
41
70
|
}
|
|
42
71
|
|
|
43
72
|
connectedCallback() {
|
|
44
73
|
super.connectedCallback();
|
|
45
74
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
75
|
+
// listeners
|
|
76
|
+
this.addEventListener('keypress', this.__onKeypress);
|
|
77
|
+
this.addEventListener('mouseup', this.__onMouseUp);
|
|
78
|
+
this.addEventListener('mouseenter', this.__onMouseEnter);
|
|
79
|
+
this.addEventListener('mouseleave', this.__onMouseLeave);
|
|
80
|
+
this.addEventListener('touchstart', this.__onTouchStart);
|
|
81
|
+
|
|
82
|
+
if (this.openOnHover) {
|
|
83
|
+
document.body.addEventListener('mouseup', this._onOutsideClick);
|
|
84
|
+
}
|
|
57
85
|
}
|
|
58
86
|
|
|
59
87
|
disconnectedCallback() {
|
|
60
88
|
super.disconnectedCallback();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
89
|
+
|
|
90
|
+
this.removeEventListener('keypress', this.__onKeypress);
|
|
91
|
+
this.removeEventListener('mouseup', this.__onMouseUp);
|
|
92
|
+
this.removeEventListener('mouseenter', this.__onMouseEnter);
|
|
93
|
+
this.removeEventListener('mouseleave', this.__onMouseLeave);
|
|
94
|
+
this.removeEventListener('touchstart', this.__onTouchStart);
|
|
95
|
+
|
|
96
|
+
if (this.openOnHover) {
|
|
97
|
+
document.body.removeEventListener('mouseup', this._onOutsideClick);
|
|
64
98
|
}
|
|
65
|
-
opener.removeEventListener('keypress', this.__onKeyPress);
|
|
66
|
-
opener.removeEventListener('mouseup', this.__onMouseUp);
|
|
67
99
|
}
|
|
68
100
|
|
|
69
101
|
firstUpdated(changedProperties) {
|
|
@@ -71,6 +103,38 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
71
103
|
|
|
72
104
|
this.addEventListener('d2l-dropdown-open', this.__onOpened);
|
|
73
105
|
this.addEventListener('d2l-dropdown-close', this.__onClosed);
|
|
106
|
+
|
|
107
|
+
const opener = this.getOpenerElement();
|
|
108
|
+
const content = this.__getContentElement();
|
|
109
|
+
if (!opener) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
opener.setAttribute('aria-haspopup', 'true');
|
|
113
|
+
opener.setAttribute('aria-expanded', (content && content.opened || false).toString());
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updated(changedProperties) {
|
|
117
|
+
super.updated(changedProperties);
|
|
118
|
+
if (!this.openOnHover || !changedProperties.has('_isFading')) return;
|
|
119
|
+
|
|
120
|
+
if (this._isFading) {
|
|
121
|
+
this.__getContentElement()?.classList.add('d2l-dropdown-content-fading');
|
|
122
|
+
} else {
|
|
123
|
+
this.__getContentElement()?.classList.remove('d2l-dropdown-content-fading');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* used by open-on-hover option */
|
|
128
|
+
async closeDropdown(fadeOut) {
|
|
129
|
+
this._isOpen = false;
|
|
130
|
+
this._isHovering = false;
|
|
131
|
+
this._isOpenedViaClick = false;
|
|
132
|
+
if (fadeOut) {
|
|
133
|
+
this._closeTimerStart();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const dropdownContent = this.__getContentElement();
|
|
137
|
+
await dropdownContent.close();
|
|
74
138
|
}
|
|
75
139
|
|
|
76
140
|
focus() {
|
|
@@ -89,6 +153,15 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
89
153
|
return this;
|
|
90
154
|
}
|
|
91
155
|
|
|
156
|
+
/* used by open-on-hover option */
|
|
157
|
+
async openDropdown(applyFocus) {
|
|
158
|
+
this._isOpen = true;
|
|
159
|
+
const dropdownContent = this.__getContentElement();
|
|
160
|
+
if (!dropdownContent) return;
|
|
161
|
+
await dropdownContent.open(applyFocus);
|
|
162
|
+
await dropdownContent.updateComplete;
|
|
163
|
+
}
|
|
164
|
+
|
|
92
165
|
toggleOpen(applyFocus) {
|
|
93
166
|
if (this.disabled) {
|
|
94
167
|
return;
|
|
@@ -113,17 +186,52 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
113
186
|
}
|
|
114
187
|
opener.setAttribute('aria-expanded', 'false');
|
|
115
188
|
opener.removeAttribute('active');
|
|
189
|
+
this._isOpen = false;
|
|
190
|
+
this._isOpenedViaClick = false;
|
|
116
191
|
}
|
|
117
192
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
193
|
+
/* used by open-on-hover option */
|
|
194
|
+
__onDropdownMouseEnter() {
|
|
195
|
+
this._isOpen = true;
|
|
196
|
+
this._isFading = false;
|
|
197
|
+
this._closeTimerStop();
|
|
122
198
|
}
|
|
123
199
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.
|
|
200
|
+
/* used by open-on-hover option */
|
|
201
|
+
__onDropdownMouseLeave(e) {
|
|
202
|
+
if (this.__getContentElement() !== e.target) return;
|
|
203
|
+
if (!this._isOpenedViaClick) this._isOpen = false;
|
|
204
|
+
this._closeTimerStart();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
__onKeypress(e) {
|
|
208
|
+
if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
|
|
209
|
+
this.__onOpenerKeyPress(e);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
__onMouseEnter(e) {
|
|
214
|
+
if (!this.openOnHover) return;
|
|
215
|
+
if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
|
|
216
|
+
this.__onOpenerMouseEnter(e);
|
|
217
|
+
} else if (isComposedAncestor(this.__getContentElement(), e.srcElement)) {
|
|
218
|
+
this.__onDropdownMouseEnter(e);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
__onMouseLeave(e) {
|
|
223
|
+
if (!this.openOnHover) return;
|
|
224
|
+
if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
|
|
225
|
+
this.__onOpenerMouseLeave(e);
|
|
226
|
+
} else if (isComposedAncestor(this.__getContentElement(), e.srcElement)) {
|
|
227
|
+
this.__onDropdownMouseLeave(e);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
__onMouseUp(e) {
|
|
232
|
+
if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
|
|
233
|
+
this.__onOpenerMouseUp(e);
|
|
234
|
+
}
|
|
127
235
|
}
|
|
128
236
|
|
|
129
237
|
__onOpened() {
|
|
@@ -133,6 +241,109 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
|
|
|
133
241
|
}
|
|
134
242
|
opener.setAttribute('aria-expanded', 'true');
|
|
135
243
|
opener.setAttribute('active', 'true');
|
|
244
|
+
this._isFading = false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
__onOpenerKeyPress(e) {
|
|
248
|
+
if (e.keyCode !== 13 && e.keyCode !== 32) return;
|
|
249
|
+
if (this.noAutoOpen) return;
|
|
250
|
+
if (!this.openOnHover) {
|
|
251
|
+
this.toggleOpen(true);
|
|
252
|
+
} else {
|
|
253
|
+
this._closeTimerStop();
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
this._isOpenedViaClick = true;
|
|
256
|
+
this.openDropdown(true);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* used by open-on-hover option */
|
|
261
|
+
async __onOpenerMouseEnter() {
|
|
262
|
+
// do not respond to hover events on mobile screens
|
|
263
|
+
const dropdownContent = this.__getContentElement();
|
|
264
|
+
if (dropdownContent._useMobileStyling) return;
|
|
265
|
+
clearTimeout(this._dismissTimerId);
|
|
266
|
+
if (!this._isOpen) await this.openDropdown(false);
|
|
267
|
+
this._closeTimerStop();
|
|
268
|
+
this._isHovering = true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* used by open-on-hover option */
|
|
272
|
+
async __onOpenerMouseLeave() {
|
|
273
|
+
// do not respond to hover events on mobile screens
|
|
274
|
+
const dropdownContent = this.__getContentElement();
|
|
275
|
+
if (dropdownContent._useMobileStyling) return;
|
|
276
|
+
this._isHovering = false;
|
|
277
|
+
if (this._isOpenedViaClick) return;
|
|
278
|
+
//Wait before closing so we don't lose hover when we jump from opener to card
|
|
279
|
+
clearTimeout(this._dismissTimerId);
|
|
280
|
+
await this.closeDropdown(true);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
__onOpenerMouseUp(e) {
|
|
284
|
+
if (this.noAutoOpen) return;
|
|
285
|
+
if (this.openOnHover) {
|
|
286
|
+
// prevent propogation to window and triggering _onOutsideClick
|
|
287
|
+
e?.stopPropagation();
|
|
288
|
+
this._closeTimerStop();
|
|
289
|
+
if (this._isOpen && !this._isHovering) {
|
|
290
|
+
this.closeDropdown();
|
|
291
|
+
} else {
|
|
292
|
+
this._isOpenedViaClick = true;
|
|
293
|
+
this._isHovering = false;
|
|
294
|
+
this.openDropdown(true);
|
|
295
|
+
}
|
|
296
|
+
} else this.toggleOpen(false);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* used by open-on-hover option */
|
|
300
|
+
__onOpenerTouch(e) {
|
|
301
|
+
//Prevents touch from triggering mouseover/hover behavior
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
this._closeTimerStop();
|
|
304
|
+
if (this._isOpen) {
|
|
305
|
+
this.closeDropdown();
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this._isOpenedViaClick = true;
|
|
309
|
+
this.openDropdown(true);
|
|
310
|
+
}
|
|
136
311
|
}
|
|
137
312
|
|
|
313
|
+
__onTouchStart(e) {
|
|
314
|
+
if (!this.openOnHover) return;
|
|
315
|
+
if (isComposedAncestor(e.srcElement, this.getOpenerElement())) {
|
|
316
|
+
this.__onOpenerTouch(e);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/* used by open-on-hover option */
|
|
321
|
+
_closeTimerStart() {
|
|
322
|
+
if (this._isOpen) return;
|
|
323
|
+
clearTimeout(this._setTimeoutId);
|
|
324
|
+
this._isFading = true;
|
|
325
|
+
this._setTimeoutId = setTimeout(() => {
|
|
326
|
+
this.closeDropdown(false);
|
|
327
|
+
this._isFading = false;
|
|
328
|
+
// matches dropdownContentStyles CSS
|
|
329
|
+
}, 700);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* used by open-on-hover option */
|
|
333
|
+
_closeTimerStop() {
|
|
334
|
+
clearTimeout(this._setTimeoutId);
|
|
335
|
+
this._isFading = false;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/* used by open-on-hover option */
|
|
339
|
+
_onOutsideClick(e) {
|
|
340
|
+
if (!this._isOpen) return;
|
|
341
|
+
const isWithinDropdown = isComposedAncestor(this.__getContentElement(), e.composedPath()[0]);
|
|
342
|
+
const isBackdropClick = isWithinDropdown
|
|
343
|
+
&& this.__getContentElement()._useMobileStyling
|
|
344
|
+
&& e.composedPath().find(node => node.nodeName === 'D2L-BACKDROP');
|
|
345
|
+
if (!isWithinDropdown || isBackdropClick) {
|
|
346
|
+
this.closeDropdown();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
138
349
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# Filtering
|
|
2
2
|
|
|
3
|
-
**NOTE: This component is a work-in-progress and not ready for consumer use yet.**
|
|
4
|
-
|
|
5
3
|
Filter components are often used in conjuction with [tables](../../components/table) and allow users to select a subset of the presented data based on a set of parameters. Filter dimensions provide methods for entering parameters for a wide range of data types.
|
|
6
4
|
|
|
5
|
+
<!-- docs: start hidden content -->
|
|
6
|
+
Filter with multiple dimensions:
|
|
7
|
+

|
|
8
|
+
<!-- docs: end hidden content -->
|
|
9
|
+
|
|
7
10
|
<!-- docs: demo align:start autoSize:false size:large -->
|
|
8
11
|
```html
|
|
9
12
|
<script type="module">
|
|
@@ -47,10 +50,6 @@ Filter components are often used in conjuction with [tables](../../components/ta
|
|
|
47
50
|
|
|
48
51
|
The `d2l-filter` component allows a user to filter on one or more dimensions of data from a single dropdown.
|
|
49
52
|
|
|
50
|
-
<!-- docs: start hidden content -->
|
|
51
|
-
<!--  -->
|
|
52
|
-
<!-- docs: end hidden content -->
|
|
53
|
-
|
|
54
53
|
<!-- docs: demo live name:d2l-filter autoSize:false align:start size:large -->
|
|
55
54
|
```html
|
|
56
55
|
<script type="module">
|
|
@@ -96,6 +95,11 @@ The `d2l-filter` component allows a user to filter on one or more dimensions of
|
|
|
96
95
|
### Single Vs Multi Dimensional
|
|
97
96
|
A filter can be a single dimension (like picking from a list of courses) or offer multiple dimensions (filter by role, or department, or something else). Single-dimension filters can be used side-by-side to promote filters that are more commonly used, while tucking less-used filters into a multi-dimensional filter.
|
|
98
97
|
|
|
98
|
+
<!-- docs: start hidden content -->
|
|
99
|
+
Filter with a single dimension:
|
|
100
|
+

|
|
101
|
+
<!-- docs: end hidden content -->
|
|
102
|
+
|
|
99
103
|
<!-- docs: demo code autoSize:false align:start size:large -->
|
|
100
104
|
```html
|
|
101
105
|
<script type="module">
|
|
@@ -173,6 +177,11 @@ The filter will announce changes to filter selections, search results, and when
|
|
|
173
177
|
|
|
174
178
|
The `d2l-filter-dimension-set` component is the main dimension type that will work for most use cases. Used alongside the [d2l-filter-dimension-set-value](#filter-dimension%3A-set-value-%5Bd2l-filter-dimension-set-value%5D), this will give you a selectable list of filter values.
|
|
175
179
|
|
|
180
|
+
<!-- docs: start hidden content -->
|
|
181
|
+
Set dimension on mobile:
|
|
182
|
+

|
|
183
|
+
<!-- docs: end hidden content -->
|
|
184
|
+
|
|
176
185
|
<!-- docs: demo live name:d2l-filter-dimension-set align:start autoSize:false size:large -->
|
|
177
186
|
```html
|
|
178
187
|
<script type="module">
|
|
@@ -10,14 +10,17 @@ class FilterDimensionSetValue extends LitElement {
|
|
|
10
10
|
return {
|
|
11
11
|
/**
|
|
12
12
|
* REQUIRED: Unique key to represent this value in the dimension
|
|
13
|
+
* @type {string}
|
|
13
14
|
*/
|
|
14
15
|
key: { type: String },
|
|
15
16
|
/**
|
|
16
17
|
* Whether this value in the filter is selected or not
|
|
18
|
+
* @type {boolean}
|
|
17
19
|
*/
|
|
18
20
|
selected: { type: Boolean, reflect: true },
|
|
19
21
|
/**
|
|
20
22
|
* REQUIRED: The text that is displayed for the value
|
|
23
|
+
* @type {string}
|
|
21
24
|
*/
|
|
22
25
|
text: { type: String }
|
|
23
26
|
};
|
|
@@ -4,7 +4,6 @@ import { html, LitElement } from 'lit-element/lit-element.js';
|
|
|
4
4
|
* A component to represent the main filter dimension type - a set of possible values that can be selected.
|
|
5
5
|
* This component does not render anything, but instead gathers data needed for the d2l-filter.
|
|
6
6
|
* @slot - For d2l-filter-dimension-set-value components
|
|
7
|
-
* @fires d2l-filter-dimension-data-change - @ignore
|
|
8
7
|
*/
|
|
9
8
|
class FilterDimensionSet extends LitElement {
|
|
10
9
|
|
|
@@ -12,10 +11,12 @@ class FilterDimensionSet extends LitElement {
|
|
|
12
11
|
return {
|
|
13
12
|
/**
|
|
14
13
|
* REQUIRED: Unique key to represent this dimension in the filter
|
|
14
|
+
* @type {string}
|
|
15
15
|
*/
|
|
16
16
|
key: { type: String },
|
|
17
17
|
/**
|
|
18
18
|
* Whether the values for this dimension are still loading and a loading spinner should be displayed
|
|
19
|
+
* @type {boolean}
|
|
19
20
|
*/
|
|
20
21
|
loading: { type: Boolean },
|
|
21
22
|
/**
|
|
@@ -25,14 +26,17 @@ class FilterDimensionSet extends LitElement {
|
|
|
25
26
|
searchType: { type: String, attribute: 'search-type' },
|
|
26
27
|
/**
|
|
27
28
|
* Adds a select all checkbox and summary for this dimension
|
|
29
|
+
* @type {boolean}
|
|
28
30
|
*/
|
|
29
31
|
selectAll: { type: Boolean, attribute: 'select-all' },
|
|
30
32
|
/**
|
|
31
33
|
* Whether only one value can be selected at a time for this dimension
|
|
34
|
+
* @type {boolean}
|
|
32
35
|
*/
|
|
33
36
|
selectionSingle: { type: Boolean, attribute: 'selection-single' },
|
|
34
37
|
/**
|
|
35
38
|
* REQUIRED: The text that is displayed for the dimension title
|
|
39
|
+
* @type {string}
|
|
36
40
|
*/
|
|
37
41
|
text: { type: String }
|
|
38
42
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -106,6 +106,7 @@ export const FormMixin = superclass => class extends LocalizeCoreElement(supercl
|
|
|
106
106
|
|
|
107
107
|
if ((isNativeFormElement(ele) || isCustomFormElement(ele)) && e.type !== 'focusout') {
|
|
108
108
|
this._dirty = true;
|
|
109
|
+
/** Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not. */
|
|
109
110
|
this.dispatchEvent(new CustomEvent('d2l-form-dirty'));
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -8,7 +8,6 @@ import { getUniqueId } from '../../helpers/uniqueId.js';
|
|
|
8
8
|
* These interactive controls are submitted using a native HTML form submission.
|
|
9
9
|
* @slot - The native and custom form elements that participate in validation and submission
|
|
10
10
|
* @fires submit - Dispatched when the form is submitted. Cancelling this event will prevent form submission.
|
|
11
|
-
* @fires d2l-form-dirty - Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
|
|
12
11
|
*/
|
|
13
12
|
class FormNative extends FormMixin(LitElement) {
|
|
14
13
|
|
package/components/form/form.js
CHANGED
|
@@ -6,7 +6,6 @@ import { FormMixin } from './form-mixin.js';
|
|
|
6
6
|
* A component that can be used to build sections containing interactive controls that are validated and submitted as a group.
|
|
7
7
|
* Values of these interactive controls are aggregated but the user is responsible for handling submission via the @d2l-form-submit event.
|
|
8
8
|
* @slot - The native and custom form elements that participate in validation and submission
|
|
9
|
-
* @fires d2l-form-dirty - Dispatched whenever any form element fires an `input` or `change` event. Can be used to track whether the form is dirty or not.
|
|
10
9
|
*/
|
|
11
10
|
class Form extends FormMixin(LitElement) {
|
|
12
11
|
|
|
@@ -135,6 +135,14 @@ class HtmlBlock extends LitElement {
|
|
|
135
135
|
`];
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
connectedCallback() {
|
|
139
|
+
super.connectedCallback();
|
|
140
|
+
if (!this._templateObserver) return;
|
|
141
|
+
|
|
142
|
+
const template = this.querySelector('template');
|
|
143
|
+
if (template) this._templateObserver.observe(template.content, { attributes: true, childList: true, subtree: true });
|
|
144
|
+
}
|
|
145
|
+
|
|
138
146
|
disconnectedCallback() {
|
|
139
147
|
super.disconnectedCallback();
|
|
140
148
|
if (this._templateObserver) this._templateObserver.disconnect();
|
|
@@ -14,7 +14,7 @@ size:xlarge
|
|
|
14
14
|
</script>
|
|
15
15
|
<script>
|
|
16
16
|
window.addEventListener('load', function () {
|
|
17
|
-
|
|
17
|
+
var demoElem = document.querySelector('#demo-element');
|
|
18
18
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
19
19
|
|
|
20
20
|
setTimeout(function() {
|
|
@@ -63,7 +63,7 @@ size:xlarge
|
|
|
63
63
|
<!-- docs: start hidden content -->
|
|
64
64
|
<script>
|
|
65
65
|
window.addEventListener('load', function () {
|
|
66
|
-
|
|
66
|
+
var demoElem = document.querySelector('#demo-element');
|
|
67
67
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
68
68
|
|
|
69
69
|
setTimeout(function() {
|
|
@@ -131,7 +131,7 @@ size:xlarge
|
|
|
131
131
|
<!-- docs: start hidden content -->
|
|
132
132
|
<script>
|
|
133
133
|
window.addEventListener('load', function () {
|
|
134
|
-
|
|
134
|
+
var demoElem = document.querySelector('#demo-element');
|
|
135
135
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
136
136
|
|
|
137
137
|
setTimeout(function() {
|
|
@@ -205,7 +205,7 @@ size:large
|
|
|
205
205
|
<!-- docs: start hidden content -->
|
|
206
206
|
<script>
|
|
207
207
|
window.addEventListener('load', function () {
|
|
208
|
-
|
|
208
|
+
var demoElem = document.querySelector('#demo-element');
|
|
209
209
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
210
210
|
|
|
211
211
|
setTimeout(function() {
|
|
@@ -273,7 +273,7 @@ size:large
|
|
|
273
273
|
<!-- docs: start hidden content -->
|
|
274
274
|
<script>
|
|
275
275
|
window.addEventListener('load', function () {
|
|
276
|
-
|
|
276
|
+
var demoElem = document.querySelector('#demo-element');
|
|
277
277
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
278
278
|
|
|
279
279
|
setTimeout(function() {
|
|
@@ -343,7 +343,7 @@ size:xlarge
|
|
|
343
343
|
<!-- docs: start hidden content -->
|
|
344
344
|
<script>
|
|
345
345
|
window.addEventListener('load', function () {
|
|
346
|
-
|
|
346
|
+
var demoElem = document.querySelector('#demo-element');
|
|
347
347
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
348
348
|
|
|
349
349
|
setTimeout(function() {
|
|
@@ -412,7 +412,7 @@ size:xlarge
|
|
|
412
412
|
<!-- docs: start hidden content -->
|
|
413
413
|
<script>
|
|
414
414
|
window.addEventListener('load', function () {
|
|
415
|
-
|
|
415
|
+
var demoElem = document.querySelector('#demo-element');
|
|
416
416
|
if (!demoElem.hasAttribute('data-first-load')) return;
|
|
417
417
|
|
|
418
418
|
setTimeout(function() {
|