@brightspace-ui/core 1.213.2 → 1.215.2

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.
@@ -80,6 +80,37 @@
80
80
  </template>
81
81
  </d2l-demo-snippet>
82
82
 
83
+ <h2>HTML Block (compact)</h2>
84
+
85
+ <d2l-demo-snippet>
86
+ <template>
87
+ <d2l-html-block compact>
88
+ <template>
89
+ <h1>heading 1</h1>
90
+ <h2>heading 2</h2>
91
+ <h3>heading 3</h3>
92
+ <h4>heading 4</h4>
93
+ <h5>heading 5</h5>
94
+ <h6>heading 6</h6>
95
+ <div><strong>strong</strong></div>
96
+ <div><b>bold</b></div>
97
+ <div>text</div>
98
+ <pre>preformatted</pre>
99
+ <p>paragraph</p>
100
+ <ul>
101
+ <li>unordered item 1</li>
102
+ <li>unordered item 2</li>
103
+ </ul>
104
+ <ol>
105
+ <li>ordered item 1</li>
106
+ <li>ordered item 2</li>
107
+ </ol>
108
+ <div><a href="https://d2l.com">anchor</a></div>
109
+ </template>
110
+ </d2l-html-block>
111
+ </template>
112
+ </d2l-demo-snippet>
113
+
83
114
  <h2>HTML Block (math)</h2>
84
115
 
85
116
  <d2l-demo-snippet>
@@ -5,6 +5,11 @@ import { HtmlBlockMathRenderer } from '../../helpers/mathjax.js';
5
5
  import { requestInstance } from '../../mixins/provider-mixin.js';
6
6
 
7
7
  export const htmlBlockContentStyles = css`
8
+ .d2l-html-block-compact {
9
+ font-size: 0.8rem;
10
+ font-weight: 400;
11
+ line-height: 1.2rem;
12
+ }
8
13
  h1, h2, h3, h4, h5, h6, b, strong, b *, strong * {
9
14
  font-weight: bold;
10
15
  }
@@ -49,7 +54,11 @@ export const htmlBlockContentStyles = css`
49
54
  ul, ol {
50
55
  list-style-position: outside;
51
56
  margin: 1em 0;
52
- padding-left: 3em;
57
+ padding-inline-start: 3em;
58
+ }
59
+ .d2l-html-block-compact ul,
60
+ .d2l-html-block-compact ol {
61
+ padding-inline-start: 1.5em;
53
62
  }
54
63
  ul, ul[type="disc"] {
55
64
  list-style-type: disc;
@@ -95,11 +104,6 @@ export const htmlBlockContentStyles = css`
95
104
  :host([dir="rtl"]) {
96
105
  text-align: right;
97
106
  }
98
- :host([dir="rtl"]) ul,
99
- :host([dir="rtl"]) ol {
100
- padding-left: 0;
101
- padding-right: 3em;
102
- }
103
107
  `;
104
108
 
105
109
  let renderers;
@@ -120,6 +124,11 @@ class HtmlBlock extends LitElement {
120
124
 
121
125
  static get properties() {
122
126
  return {
127
+ /**
128
+ * Whether compact styles should be applied
129
+ * @type {Boolean}
130
+ */
131
+ compact: { type: Boolean },
123
132
  /**
124
133
  * Whether to disable deferred rendering of the user-authored HTML. Do *not* set this
125
134
  * unless your HTML relies on script executions that may break upon stamping.
@@ -153,6 +162,7 @@ class HtmlBlock extends LitElement {
153
162
 
154
163
  constructor() {
155
164
  super();
165
+ this.compact = false;
156
166
  this.noDeferredRendering = false;
157
167
 
158
168
  const rendererContextAttributes = getRenderers().reduce((attrs, currentRenderer) => {
@@ -185,7 +195,7 @@ class HtmlBlock extends LitElement {
185
195
 
186
196
  if (this._renderContainer) return;
187
197
 
188
- this.shadowRoot.innerHTML += '<div class="d2l-html-block-rendered"></div><slot></slot>';
198
+ this.shadowRoot.innerHTML += `<div class="d2l-html-block-rendered${this.compact ? ' d2l-html-block-compact' : ''}"></div><slot></slot>`;
189
199
 
190
200
  this.shadowRoot.querySelector('slot').addEventListener('slotchange', async e => await this._render(e.target));
191
201
  this._renderContainer = this.shadowRoot.querySelector('.d2l-html-block-rendered');
@@ -264,14 +264,13 @@ class InputNumber extends LabelledMixin(SkeletonMixin(FormElementMixin(LocalizeC
264
264
  countDecimalDigits(this._valueTrailingZeroes, false),
265
265
  this.maxFractionDigits
266
266
  );
267
- let valueTrailingZeroes = this.value.toString();
268
- const decimalDiff = (numDecimals - countDecimalDigits(valueTrailingZeroes, false));
269
- if (decimalDiff > 0) {
270
- if (decimalDiff === numDecimals) {
271
- valueTrailingZeroes += '.';
267
+ const valueTrailingZeroes = new Intl.NumberFormat(
268
+ 'en-US',
269
+ {
270
+ minimumFractionDigits: numDecimals,
271
+ useGrouping: false
272
272
  }
273
- valueTrailingZeroes = valueTrailingZeroes.padEnd(valueTrailingZeroes.length + decimalDiff, '0');
274
- }
273
+ ).format(this.value);
275
274
  return valueTrailingZeroes;
276
275
  }
277
276
  set valueTrailingZeroes(val) {
@@ -1,6 +1,4 @@
1
-
2
- import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
3
- export const MenuItemMixin = superclass => class extends FocusVisiblePolyfillMixin(superclass) {
1
+ export const MenuItemMixin = superclass => class extends superclass {
4
2
 
5
3
  static get properties() {
6
4
  return {
@@ -17,8 +17,8 @@ export const menuItemStyles = css`
17
17
  }
18
18
 
19
19
  :host(:hover),
20
- :host(.focus-visible),
21
- :host(.focus-visible[first]),
20
+ :host(:focus-visible),
21
+ :host(:focus-visible[first]),
22
22
  :host([first]:hover) {
23
23
  background-color: var(--d2l-menu-background-color-hover);
24
24
  border-bottom: 1px solid var(--d2l-menu-border-color-hover);
@@ -27,7 +27,7 @@ export const menuItemStyles = css`
27
27
  z-index: 2;
28
28
  }
29
29
 
30
- :host([disabled]), :host([disabled]:hover), :host([disabled].focus-visible) {
30
+ :host([disabled]), :host([disabled]:hover), :host([disabled]:focus-visible) {
31
31
  cursor: default;
32
32
  opacity: 0.75;
33
33
  }
@@ -40,7 +40,7 @@ export const menuItemStyles = css`
40
40
  border-top-color: transparent;
41
41
  }
42
42
 
43
- :host([last].focus-visible),
43
+ :host([last]:focus-visible),
44
44
  :host([last]:hover) {
45
45
  border-bottom-color: var(--d2l-menu-border-color-hover);
46
46
  }
@@ -2,7 +2,6 @@ import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import './menu-item-return.js';
4
4
  import { css, html, LitElement } from 'lit-element/lit-element.js';
5
- import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
6
5
  import { HierarchicalViewMixin } from '../hierarchical-view/hierarchical-view-mixin.js';
7
6
  import { ThemeMixin } from '../../mixins/theme-mixin.js';
8
7
 
@@ -21,7 +20,7 @@ const keyCodes = {
21
20
  * @slot - Menu items
22
21
  * @fires d2l-menu-resize - Dispatched when size of menu changes (e.g., when nested menu of a different size is opened)
23
22
  */
24
- class Menu extends ThemeMixin(HierarchicalViewMixin(FocusVisiblePolyfillMixin(LitElement))) {
23
+ class Menu extends ThemeMixin(HierarchicalViewMixin(LitElement)) {
25
24
 
26
25
  static get properties() {
27
26
  return {
@@ -3378,6 +3378,12 @@
3378
3378
  "path": "./components/html-block/html-block.js",
3379
3379
  "description": "A component for displaying user-authored HTML.",
3380
3380
  "attributes": [
3381
+ {
3382
+ "name": "compact",
3383
+ "description": "Whether compact styles should be applied",
3384
+ "type": "Boolean",
3385
+ "default": "false"
3386
+ },
3381
3387
  {
3382
3388
  "name": "no-deferred-rendering",
3383
3389
  "description": "Whether to disable deferred rendering of the user-authored HTML. Do *not* set this\nunless your HTML relies on script executions that may break upon stamping.",
@@ -3386,6 +3392,13 @@
3386
3392
  }
3387
3393
  ],
3388
3394
  "properties": [
3395
+ {
3396
+ "name": "compact",
3397
+ "attribute": "compact",
3398
+ "description": "Whether compact styles should be applied",
3399
+ "type": "Boolean",
3400
+ "default": "false"
3401
+ },
3389
3402
  {
3390
3403
  "name": "noDeferredRendering",
3391
3404
  "attribute": "no-deferred-rendering",
@@ -1,6 +1,8 @@
1
- import { directive, PropertyPart } from 'lit-html';
1
+ import { directive, PartType } from 'lit-html/directive.js';
2
2
  import { getComposedActiveElement, getNextFocusable } from '../../helpers/focus.js';
3
+ import { AsyncDirective } from 'lit-html/async-directive.js';
3
4
  import { isComposedAncestor } from '../../helpers/dom.js';
5
+ import { noChange } from 'lit-html';
4
6
 
5
7
  const stateMap = new WeakMap();
6
8
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -10,15 +12,13 @@ const moveYValue = 20;
10
12
 
11
13
  class AnimationState {
12
14
 
13
- constructor(propertyPart) {
14
-
15
- if (!(propertyPart instanceof PropertyPart) || propertyPart.committer.name !== 'animate') {
16
- throw new Error('animation directives must be used with "animate" property');
15
+ constructor(partInfo) {
16
+ if (!(partInfo.type === PartType.PROPERTY) || partInfo.name !== 'animate') {
17
+ throw new Error('animate directives must be used with "animate" property');
17
18
  }
18
-
19
19
  this.id = 0;
20
20
  this.clone = null;
21
- this.elem = propertyPart.committer.element;
21
+ this.elem = partInfo.element;
22
22
  this.state = 'unknown';
23
23
  this.styleAttr = null;
24
24
  this.styleAttrUse = false;
@@ -289,20 +289,37 @@ class AnimationState {
289
289
 
290
290
  }
291
291
 
292
- async function helper(part, action, opts) {
293
- let state = stateMap.get(part);
294
- if (state === undefined) {
295
- state = new AnimationState(part);
296
- stateMap.set(part, state);
292
+ class Hide extends AsyncDirective {
293
+ render() {
294
+ return noChange;
297
295
  }
298
- opts = opts || {};
299
- if (action === 'show') {
300
- state.show(opts);
301
- } else if (action === 'hide') {
296
+ update(part, [opts]) {
297
+ opts = opts || {};
298
+ let state = stateMap.get(part.element);
299
+ if (state === undefined) {
300
+ state = new AnimationState(part);
301
+ stateMap.set(part.element, state);
302
+ }
302
303
  state.hide(opts);
304
+ return this.render();
303
305
  }
304
306
  }
305
307
 
306
- export const hide = directive((opts) => async(part) => helper(part, 'hide', opts));
308
+ class Show extends AsyncDirective {
309
+ render() {
310
+ return noChange;
311
+ }
312
+ update(part, [opts]) {
313
+ opts = opts || {};
314
+ let state = stateMap.get(part.element);
315
+ if (state === undefined) {
316
+ state = new AnimationState(part);
317
+ stateMap.set(part.element, state);
318
+ }
319
+ state.show(opts);
320
+ return this.render();
321
+ }
322
+ }
307
323
 
308
- export const show = directive((opts) => async(part) => helper(part, 'show', opts));
324
+ export const hide = directive(Hide);
325
+ export const show = directive(Show);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.213.2",
3
+ "version": "1.215.2",
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",