@brightspace-ui/core 3.70.0 → 3.71.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.
@@ -132,9 +132,9 @@
132
132
  <h2>Inline Help</h2>
133
133
  <d2l-demo-snippet>
134
134
  <template>
135
- <d2l-input-text label="Name">
135
+ <d2l-input-text label="Alphabet" pattern="[a-z]*" pattern-failure-text="Must be a lowercase letter from a to z">
136
136
  <div slot="inline-help">
137
- Help text <b>right here</b>!
137
+ Enter only lowercase letters from the alphabet.
138
138
  </div>
139
139
  </d2l-input-text>
140
140
  </template>
@@ -81,6 +81,7 @@ The `<d2l-input-text>` element is a simple wrapper around the native `<input typ
81
81
  | `name` | String | Name of the input |
82
82
  | `novalidate` | Boolean | Disables the built-in validation |
83
83
  | `pattern` | String | Regular expression pattern to validate the value |
84
+ | `pattern-failure-text` | String | Text to display when input fails validation against the pattern. If a list of characters is included in the message, use `LocalizeMixin`'s `localizeCharacter`. |
84
85
  | `prevent-submit` | Boolean | Prevents pressing ENTER from submitting forms |
85
86
  | `readonly` | Boolean | Makes the input read-only |
86
87
  | `required` | Boolean | Indicates that a value is required |
@@ -102,12 +102,12 @@ class InputText extends InputInlineHelpMixin(PropertyRequiredMixin(FocusMixin(La
102
102
  */
103
103
  minlength: { type: Number },
104
104
  /**
105
- * Regular expression pattern to validate the value
105
+ * ADVANCED: Regular expression pattern to validate the value
106
106
  * @type {string}
107
107
  */
108
108
  pattern: { type: String },
109
109
  /**
110
- * Text to display when input fails validation against the pattern
110
+ * ADVANCED: Text to display when input fails validation against the pattern. If a list of characters is included in the message, use `LocalizeMixin`'s `localizeCharacter`.
111
111
  */
112
112
  patternFailureText: { type: String, attribute: 'pattern-failure-text' },
113
113
  /**
@@ -332,6 +332,8 @@ class InputText extends InputInlineHelpMixin(PropertyRequiredMixin(FocusMixin(La
332
332
  } else if (this.type === 'url') {
333
333
  return this.localize('components.form-element.input.url.typeMismatch');
334
334
  }
335
+ } else if (this.validity.patternMismatch && (typeof this.patternFailureText === 'string')) {
336
+ return this.patternFailureText;
335
337
  }
336
338
  return super.validationMessage;
337
339
  }
@@ -6847,12 +6847,12 @@
6847
6847
  },
6848
6848
  {
6849
6849
  "name": "pattern",
6850
- "description": "Regular expression pattern to validate the value",
6850
+ "description": "ADVANCED: Regular expression pattern to validate the value",
6851
6851
  "type": "string"
6852
6852
  },
6853
6853
  {
6854
6854
  "name": "pattern-failure-text",
6855
- "description": "Text to display when input fails validation against the pattern",
6855
+ "description": "ADVANCED: Text to display when input fails validation against the pattern. If a list of characters is included in the message, use `LocalizeMixin`'s `localizeCharacter`.",
6856
6856
  "type": "string"
6857
6857
  },
6858
6858
  {
@@ -7013,13 +7013,13 @@
7013
7013
  {
7014
7014
  "name": "pattern",
7015
7015
  "attribute": "pattern",
7016
- "description": "Regular expression pattern to validate the value",
7016
+ "description": "ADVANCED: Regular expression pattern to validate the value",
7017
7017
  "type": "string"
7018
7018
  },
7019
7019
  {
7020
7020
  "name": "patternFailureText",
7021
7021
  "attribute": "pattern-failure-text",
7022
- "description": "Text to display when input fails validation against the pattern",
7022
+ "description": "ADVANCED: Text to display when input fails validation against the pattern. If a list of characters is included in the message, use `LocalizeMixin`'s `localizeCharacter`.",
7023
7023
  "type": "string"
7024
7024
  },
7025
7025
  {
@@ -152,6 +152,39 @@ this.localizeHTML('octopus', {
152
152
  });
153
153
  ```
154
154
 
155
+ ### Common Resources
156
+
157
+ Some localization resources are common and shared across D2L applications. To use these resources, set the `loadCommon` option:
158
+
159
+ ```javascript
160
+ static get localizeConfig() {
161
+ return {
162
+ loadCommon: true
163
+ };
164
+ }
165
+ ```
166
+
167
+ #### localizeCharacter
168
+
169
+ The localized value of the following characters can be accessed using `localizeCharacter(char)`:
170
+ * `'` (apostrophe)
171
+ * `&` (ampersand)
172
+ * `*` (asterisk)
173
+ * `\` (backslash)
174
+ * `:` (colon)
175
+ * `,` (comma)
176
+ * `>` (greater-than sign)
177
+ * `<` (less-than sign)
178
+ * `#` (number sign)
179
+ * `%` (percent sign)
180
+ * `|` (pipe)
181
+ * `?` (question mark)
182
+ * `"` (quotation mark)
183
+
184
+ ```javascript
185
+ this.localizeCharacter('&'); // -> 'ampersand' in en-US
186
+ ```
187
+
155
188
  ## Off-Stack Language Overrides
156
189
 
157
190
  To enable OSLO, map the project's localization resources to a language collection in Brightspace by defining `osloCollection` in `localizeConfig`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.70.0",
3
+ "version": "3.71.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",