@descope-ui/common 0.0.12 → 0.0.14
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.14](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.13...@descope-ui/common-0.0.14) (2025-06-26)
|
|
6
|
+
|
|
7
|
+
## [0.0.13](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.12...@descope-ui/common-0.0.13) (2025-06-09)
|
|
8
|
+
|
|
5
9
|
## [0.0.12](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.11...@descope-ui/common-0.0.12) (2025-05-28)
|
|
6
10
|
|
|
7
11
|
## [0.0.11](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.10...@descope-ui/common-0.0.11) (2025-04-29)
|
package/package.json
CHANGED
|
@@ -12,7 +12,9 @@ export const inputEventsDispatchingMixin = (superclass) =>
|
|
|
12
12
|
#blockNativeEvents() {
|
|
13
13
|
['blur', 'focus', 'focusin', 'focusout'].forEach((event) => {
|
|
14
14
|
this.addEventListener(event, (e) => {
|
|
15
|
-
e.isTrusted && e.target === this
|
|
15
|
+
if (e.isTrusted && e.target === this) {
|
|
16
|
+
e.stopImmediatePropagation()
|
|
17
|
+
};
|
|
16
18
|
});
|
|
17
19
|
});
|
|
18
20
|
}
|
|
@@ -73,6 +73,12 @@ export const inputValidationMixin = (superclass) =>
|
|
|
73
73
|
return `Please match the requested type.`;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
getCustomErrorMessage(attr, defaultMsg) {
|
|
77
|
+
return this.hasAttribute(attr)
|
|
78
|
+
? this.getAttribute(attr) || ' '
|
|
79
|
+
: defaultMsg;
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
getErrorMessage(flags) {
|
|
77
83
|
const {
|
|
78
84
|
valueMissing,
|
|
@@ -89,31 +95,39 @@ export const inputValidationMixin = (superclass) =>
|
|
|
89
95
|
|
|
90
96
|
switch (true) {
|
|
91
97
|
case valueMissing:
|
|
92
|
-
return (
|
|
93
|
-
|
|
98
|
+
return this.getCustomErrorMessage(
|
|
99
|
+
errorAttributes.valueMissing,
|
|
100
|
+
this.defaultErrorMsgValueMissing,
|
|
94
101
|
);
|
|
95
102
|
case patternMismatch || stepMismatch || badInput:
|
|
96
|
-
return (
|
|
97
|
-
|
|
98
|
-
this.defaultErrorMsgPatternMismatch
|
|
103
|
+
return this.getCustomErrorMessage(
|
|
104
|
+
errorAttributes.patternMismatch,
|
|
105
|
+
this.defaultErrorMsgPatternMismatch,
|
|
99
106
|
);
|
|
100
107
|
case typeMismatch:
|
|
101
|
-
return (
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
this.defaultErrorMsgTypeMismatch
|
|
108
|
+
return this.getCustomErrorMessage(
|
|
109
|
+
errorAttributes.typeMismatch,
|
|
110
|
+
this.defaultErrorMsgTypeMismatch,
|
|
105
111
|
);
|
|
106
112
|
case tooShort:
|
|
107
|
-
return this.
|
|
113
|
+
return this.getCustomErrorMessage(
|
|
114
|
+
errorAttributes.tooShort,
|
|
115
|
+
this.defaultErrorMsgTooShort,
|
|
116
|
+
);
|
|
108
117
|
case tooLong:
|
|
109
|
-
return this.
|
|
118
|
+
return this.getCustomErrorMessage(
|
|
119
|
+
errorAttributes.tooLong,
|
|
120
|
+
this.defaultErrorMsgTooLong,
|
|
121
|
+
);
|
|
110
122
|
case rangeUnderflow:
|
|
111
|
-
return (
|
|
112
|
-
|
|
123
|
+
return this.getCustomErrorMessage(
|
|
124
|
+
errorAttributes.rangeUnderflow,
|
|
125
|
+
this.defaultErrorMsgRangeUnderflow,
|
|
113
126
|
);
|
|
114
127
|
case rangeOverflow:
|
|
115
|
-
return (
|
|
116
|
-
|
|
128
|
+
return this.getCustomErrorMessage(
|
|
129
|
+
errorAttributes.rangeOverflow,
|
|
130
|
+
this.defaultErrorMsgRangeOverflow,
|
|
117
131
|
);
|
|
118
132
|
case customError:
|
|
119
133
|
return this.validationMessage;
|
|
@@ -124,7 +138,11 @@ export const inputValidationMixin = (superclass) =>
|
|
|
124
138
|
|
|
125
139
|
#setValidity() {
|
|
126
140
|
const validity = this.isReadOnly ? {} : this.getValidity();
|
|
127
|
-
this.#internals.setValidity(
|
|
141
|
+
this.#internals.setValidity(
|
|
142
|
+
validity,
|
|
143
|
+
this.getErrorMessage(validity),
|
|
144
|
+
this.validationTarget,
|
|
145
|
+
);
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
get validationMessage() {
|
|
@@ -161,7 +179,11 @@ export const inputValidationMixin = (superclass) =>
|
|
|
161
179
|
|
|
162
180
|
setCustomValidity(errorMessage) {
|
|
163
181
|
if (errorMessage) {
|
|
164
|
-
this.#internals.setValidity(
|
|
182
|
+
this.#internals.setValidity(
|
|
183
|
+
{ customError: true },
|
|
184
|
+
errorMessage,
|
|
185
|
+
this.validationTarget,
|
|
186
|
+
);
|
|
165
187
|
} else {
|
|
166
188
|
this.#internals.setValidity({});
|
|
167
189
|
this.#setValidity();
|
|
@@ -169,15 +191,24 @@ export const inputValidationMixin = (superclass) =>
|
|
|
169
191
|
}
|
|
170
192
|
|
|
171
193
|
get isRequired() {
|
|
172
|
-
return
|
|
194
|
+
return (
|
|
195
|
+
this.hasAttribute('required') &&
|
|
196
|
+
this.getAttribute('required') !== 'false'
|
|
197
|
+
);
|
|
173
198
|
}
|
|
174
199
|
|
|
175
200
|
get isReadOnly() {
|
|
176
|
-
return
|
|
201
|
+
return (
|
|
202
|
+
this.hasAttribute('readonly') &&
|
|
203
|
+
this.getAttribute('readonly') !== 'false'
|
|
204
|
+
);
|
|
177
205
|
}
|
|
178
206
|
|
|
179
207
|
get isDisabled() {
|
|
180
|
-
return
|
|
208
|
+
return (
|
|
209
|
+
this.hasAttribute('disabled') &&
|
|
210
|
+
this.getAttribute('disabled') !== 'false'
|
|
211
|
+
);
|
|
181
212
|
}
|
|
182
213
|
|
|
183
214
|
get pattern() {
|
package/src/sbControls.js
CHANGED
|
@@ -303,6 +303,24 @@ export const errorMessageIconControl = {
|
|
|
303
303
|
},
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
+
export const defaultValueMissingControl = {
|
|
307
|
+
defaultErrorMessageValueMissing: {
|
|
308
|
+
name: 'Default error-message: Value missing',
|
|
309
|
+
control: {
|
|
310
|
+
type: 'boolean',
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export const toggleDefaultErrorMessagePatternMismatch = {
|
|
316
|
+
defaultErrorMessagePatternMismatch: {
|
|
317
|
+
name: 'Default error-message: Pattern mismatch',
|
|
318
|
+
control: {
|
|
319
|
+
type: 'boolean',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
|
|
306
324
|
export const errorMessageIconAttrs = `
|
|
307
325
|
st-error-message-icon="url(${errorMessageIconBase64})"
|
|
308
326
|
st-error-message-icon-size="14px"
|
package/src/sbHelpers.js
CHANGED
|
@@ -20,6 +20,34 @@ export const withForm = (story) => {
|
|
|
20
20
|
`;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
export const toggleDefaultErrorMessageValueMissingDecorator = (
|
|
24
|
+
story,
|
|
25
|
+
{ component, args },
|
|
26
|
+
) => {
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
const ele = document.querySelector(component);
|
|
29
|
+
if (!ele) return;
|
|
30
|
+
if (args.defaultErrorMessageValueMissing) {
|
|
31
|
+
ele.removeAttribute('data-errormessage-value-missing');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return story();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const toggleDefaultErrorMessagePatternMismatchDecorator = (
|
|
38
|
+
story,
|
|
39
|
+
{ component, args },
|
|
40
|
+
) => {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
const ele = document.querySelector(component);
|
|
43
|
+
if (!ele) return;
|
|
44
|
+
if (args.defaultErrorMessagePatternMismatch) {
|
|
45
|
+
ele.removeAttribute('data-errormessage-pattern-mismatch');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return story();
|
|
49
|
+
};
|
|
50
|
+
|
|
23
51
|
export const appleIcon = `
|
|
24
52
|
<svg
|
|
25
53
|
width="1.5em"
|