@commmerce/ui 1.13.0 → 1.13.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.
@@ -16,6 +16,12 @@ declare const strings: {
16
16
  badTime: string;
17
17
  /** Validation, `type="datetime-local"`: the date and time are only partly filled in. */
18
18
  badDateTime: string;
19
+ /** Validation, `type="email"`: the text isn't an email address (1.13.1). */
20
+ badEmail: string;
21
+ /** Validation, `type="url"`: the text isn't a full web address (1.13.1). */
22
+ badUrl: string;
23
+ /** Validation, `type="number"`: the text isn't a number (1.13.1). */
24
+ badNumber: string;
19
25
  };
20
26
  declare module '../localize.js' {
21
27
  interface CmStrings {
@@ -32,6 +32,12 @@ const strings = defineStrings('textField', {
32
32
  badTime: 'Enter a complete time.',
33
33
  /** Validation, `type="datetime-local"`: the date and time are only partly filled in. */
34
34
  badDateTime: 'Enter a complete date and time.',
35
+ /** Validation, `type="email"`: the text isn't an email address (1.13.1). */
36
+ badEmail: 'Enter an email address like name@example.com.',
37
+ /** Validation, `type="url"`: the text isn't a full web address (1.13.1). */
38
+ badUrl: 'Enter a web address like https://example.com.',
39
+ /** Validation, `type="number"`: the text isn't a number (1.13.1). */
40
+ badNumber: 'Enter a number.',
35
41
  });
36
42
  /**
37
43
  * Labelled single- or multi-line input. Participates in native forms.
@@ -136,8 +142,14 @@ _CmTextField_internals = new WeakMap(), _CmTextField_id = new WeakMap(), _CmText
136
142
  // A half-typed time reads as an empty value; say so instead of "fill in this field".
137
143
  else if (dated && native?.badInput)
138
144
  __classPrivateFieldGet(this, _CmTextField_internals, "f").setValidity({ badInput: true }, this.t(this.type === 'time' ? 'badTime' : 'badDateTime'), control ?? undefined);
145
+ // Text that isn't a number reads as an empty value; say so instead of "fill in this field" or accepting it (1.13.1).
146
+ else if (this.type === 'number' && native?.badInput)
147
+ __classPrivateFieldGet(this, _CmTextField_internals, "f").setValidity({ badInput: true }, this.t('badNumber'), control ?? undefined);
139
148
  else if (this.required && !this.value)
140
149
  __classPrivateFieldGet(this, _CmTextField_internals, "f").setValidity({ valueMissing: true }, this.t('required'), control ?? undefined);
150
+ // The browser's own email and web address checks (before 1.13.1 they were ignored and any text was valid).
151
+ else if (!this.multiline && native?.typeMismatch)
152
+ __classPrivateFieldGet(this, _CmTextField_internals, "f").setValidity({ typeMismatch: true }, this.t(this.type === 'url' ? 'badUrl' : 'badEmail'), control ?? undefined);
141
153
  else if (!this.multiline && native?.rangeUnderflow)
142
154
  __classPrivateFieldGet(this, _CmTextField_internals, "f").setValidity({ rangeUnderflow: true }, this.t(this.type === 'number' ? 'numberUnderflow' : 'rangeUnderflow', { min: __classPrivateFieldGet(this, _CmTextField_instances, "m", _CmTextField_show).call(this, this.min ?? '') }), control ?? undefined);
143
155
  else if (!this.multiline && native?.rangeOverflow)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commmerce/ui",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Commmerce UI web components: build apps that feel native to the Commmerce admin. Works in plain HTML, React, Vue and server-rendered pages.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -50,8 +50,8 @@
50
50
  "test": "vitest run"
51
51
  },
52
52
  "dependencies": {
53
- "@commmerce/icons": "1.13.0",
54
- "@commmerce/tokens": "1.13.0",
53
+ "@commmerce/icons": "1.13.1",
54
+ "@commmerce/tokens": "1.13.1",
55
55
  "lit": "3.2.1"
56
56
  },
57
57
  "devDependencies": {