@brightspace-ui/core 2.76.3 → 2.77.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.
@@ -5,7 +5,6 @@ import { classMap } from 'lit/directives/class-map.js';
5
5
  import { createHtmlBlockRenderer as createMathRenderer } from '../../helpers/mathjax.js';
6
6
  import { HtmlAttributeObserverController } from '../../controllers/attributeObserver/htmlAttributeObserverController.js';
7
7
  import { requestInstance } from '../../mixins/provider-mixin.js';
8
- import { RtlMixin } from '../../mixins/rtl-mixin.js';
9
8
 
10
9
  export const htmlBlockContentStyles = css`
11
10
  .d2l-html-block-rendered {
@@ -131,7 +130,7 @@ const getRenderers = async() => {
131
130
  * A component for displaying user-authored HTML.
132
131
  * @slot - Provide your user-authored HTML
133
132
  */
134
- class HtmlBlock extends RtlMixin(LitElement) {
133
+ class HtmlBlock extends LitElement {
135
134
 
136
135
  static get properties() {
137
136
  return {
@@ -164,7 +163,7 @@ class HtmlBlock extends RtlMixin(LitElement) {
164
163
  :host {
165
164
  display: block;
166
165
  overflow-wrap: break-word;
167
- text-align: left;
166
+ text-align: start;
168
167
  }
169
168
  :host([inline]),
170
169
  :host([inline]) .d2l-html-block-rendered {
@@ -178,9 +177,6 @@ class HtmlBlock extends RtlMixin(LitElement) {
178
177
  :host([no-deferred-rendering]) slot {
179
178
  display: contents;
180
179
  }
181
- :host([dir="rtl"]) {
182
- text-align: right;
183
- }
184
180
  `];
185
181
  }
186
182
 
@@ -28,6 +28,14 @@
28
28
  </template>
29
29
  </d2l-demo-snippet>
30
30
 
31
+ <h2>Search Input (Search on Input)</h2>
32
+ <d2l-demo-snippet>
33
+ <template>
34
+ <d2l-input-search label="Search" value="Will dispatch search after every input" placeholder="Search for some stuff" search-on-input>
35
+ </d2l-input-search>
36
+ </template>
37
+ </d2l-demo-snippet>
38
+
31
39
  <script>
32
40
  document.body.addEventListener('d2l-input-search-searched', (e) => {
33
41
  // eslint-disable-next-line no-console
@@ -60,6 +60,7 @@ For text searches use `<d2l-input-search>`, which wraps the native `<input type=
60
60
  | `disabled` | Boolean | Disables the input |
61
61
  | `maxlength` | Number | Imposes an upper character limit |
62
62
  | `no-clear` | Boolean | Prevents the "clear" button from appearing |
63
+ | `search-on-input` | Boolean | Dispatch search events after each input event |
63
64
  | `placeholder` | String, default:`'Search...'` | Placeholder text |
64
65
  | `value` | String, default: `''` | Value of the input |
65
66
 
@@ -8,6 +8,8 @@ import { inputStyles } from './input-styles.js';
8
8
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
9
9
  import { RtlMixin } from '../../mixins/rtl-mixin.js';
10
10
 
11
+ const INPUT_TIMEOUT_MS = 400;
12
+
11
13
  /**
12
14
  * This component wraps the native "<input type="search">"" element and is for text searching.
13
15
  * @fires d2l-input-search-searched - Dispatched when a search is performed. When the input is cleared, this will be fired with an empty value.
@@ -50,6 +52,11 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
50
52
  * @type {string}
51
53
  */
52
54
  placeholder: { type: String },
55
+ /**
56
+ * Dispatch search events after each input event
57
+ * @type {boolean}
58
+ */
59
+ searchOnInput: { type: Boolean, attribute: 'search-on-input' },
53
60
  /**
54
61
  * Value of the input
55
62
  * @type {string}
@@ -81,9 +88,11 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
81
88
 
82
89
  constructor() {
83
90
  super();
91
+ this._inputTimeout = undefined;
84
92
  this._lastSearchValue = '';
85
93
  this.disabled = false;
86
94
  this.noClear = false;
95
+ this.searchOnInput = false;
87
96
  this.value = '';
88
97
  }
89
98
 
@@ -151,6 +160,12 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
151
160
  return showSearch;
152
161
  }
153
162
 
163
+ _debounceInput() {
164
+ clearTimeout(this._inputTimeout);
165
+ this._setLastSearchValue(this.value);
166
+ this._inputTimeout = setTimeout(() => this._dispatchEvent(), INPUT_TIMEOUT_MS);
167
+ }
168
+
154
169
  _dispatchEvent() {
155
170
  this.dispatchEvent(new CustomEvent(
156
171
  'd2l-input-search-searched',
@@ -169,6 +184,9 @@ class InputSearch extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement)))
169
184
 
170
185
  _handleInput(e) {
171
186
  this.value = e.target.value;
187
+ if (this.searchOnInput) {
188
+ this._debounceInput();
189
+ }
172
190
  }
173
191
 
174
192
  _handleInputKeyPress(e) {
@@ -5999,6 +5999,12 @@
5999
5999
  "type": "boolean",
6000
6000
  "default": "false"
6001
6001
  },
6002
+ {
6003
+ "name": "search-on-input",
6004
+ "description": "Dispatch search events after each input event",
6005
+ "type": "boolean",
6006
+ "default": "false"
6007
+ },
6002
6008
  {
6003
6009
  "name": "value",
6004
6010
  "description": "Value of the input",
@@ -6049,6 +6055,13 @@
6049
6055
  "type": "boolean",
6050
6056
  "default": "false"
6051
6057
  },
6058
+ {
6059
+ "name": "searchOnInput",
6060
+ "attribute": "search-on-input",
6061
+ "description": "Dispatch search events after each input event",
6062
+ "type": "boolean",
6063
+ "default": "false"
6064
+ },
6052
6065
  {
6053
6066
  "name": "value",
6054
6067
  "attribute": "value",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.76.3",
3
+ "version": "2.77.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",