@fkui/logic 6.20.0 → 6.22.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.
- package/lib/cjs/index.js +89 -89
- package/lib/esm/index.js +89 -89
- package/lib/types/index.d.ts +9 -9
- package/lib/types/tsdoc-metadata.json +1 -1
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -199,7 +199,7 @@ class DecoratedError extends Error {
|
|
|
199
199
|
super(message);
|
|
200
200
|
Object.setPrototypeOf(this, DecoratedError.prototype);
|
|
201
201
|
/* eslint-disable-next-line @typescript-eslint/restrict-plus-operands -- technical debt */
|
|
202
|
-
this.stack += `\nCaused by: ${cause.stack}`;
|
|
202
|
+
this.stack += `\nCaused by: ${String(cause.stack)}`;
|
|
203
203
|
this.cause = cause;
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
@@ -2198,7 +2198,7 @@ function setCookie(options) {
|
|
|
2198
2198
|
return;
|
|
2199
2199
|
}
|
|
2200
2200
|
const timeout = timeLimitSeconds ?? TWELVE_HOURS;
|
|
2201
|
-
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${timeout};`;
|
|
2201
|
+
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${String(timeout)};`;
|
|
2202
2202
|
document.cookie = cookieString;
|
|
2203
2203
|
}
|
|
2204
2204
|
/**
|
|
@@ -2593,7 +2593,7 @@ class FDate {
|
|
|
2593
2593
|
static fromYearMonthDay(year, month, day) {
|
|
2594
2594
|
const paddedMonth = month.toString().padStart(2, "0");
|
|
2595
2595
|
const paddedDay = day.toString().padStart(2, "0");
|
|
2596
|
-
const iso = `${year}-${paddedMonth}-${paddedDay}`;
|
|
2596
|
+
const iso = `${String(year)}-${paddedMonth}-${paddedDay}`;
|
|
2597
2597
|
return FDate.fromIso(iso);
|
|
2598
2598
|
}
|
|
2599
2599
|
/**
|
|
@@ -3529,7 +3529,7 @@ function popFocus(handle) {
|
|
|
3529
3529
|
}
|
|
3530
3530
|
const top = _focusElementStack.pop();
|
|
3531
3531
|
if (top?.id !== handle[sym]) {
|
|
3532
|
-
const outOfOrderErrorMsg = `push/pop called out-of-order. Expected stack handle id: ${top?.id} but got ${handle[sym]}`;
|
|
3532
|
+
const outOfOrderErrorMsg = `push/pop called out-of-order. Expected stack handle id: ${String(top?.id)} but got ${String(handle[sym])}`;
|
|
3533
3533
|
if (configLogic.production) {
|
|
3534
3534
|
// eslint-disable-next-line no-console -- expected to log
|
|
3535
3535
|
console.error(outOfOrderErrorMsg);
|
|
@@ -3842,6 +3842,82 @@ const TranslationService =
|
|
|
3842
3842
|
/* @__PURE__ */
|
|
3843
3843
|
new TranslationServiceImpl();
|
|
3844
3844
|
|
|
3845
|
+
/**
|
|
3846
|
+
* @internal
|
|
3847
|
+
*/
|
|
3848
|
+
function createFieldsetValidator(element, validationService) {
|
|
3849
|
+
/* eslint-disable-next-line no-new, sonarjs/constructor-for-side-effects --
|
|
3850
|
+
* technical debt, this should be refactored as to not rely of side-effects
|
|
3851
|
+
* of the constructor */
|
|
3852
|
+
new FieldsetValidationHandler(element, validationService);
|
|
3853
|
+
}
|
|
3854
|
+
class FieldsetValidationHandler {
|
|
3855
|
+
hasDocumentListener = false;
|
|
3856
|
+
documentFocusInRef = undefined;
|
|
3857
|
+
element;
|
|
3858
|
+
validationService;
|
|
3859
|
+
constructor(element, validationService) {
|
|
3860
|
+
Object.assign(this);
|
|
3861
|
+
this.element = element;
|
|
3862
|
+
this.validationService = validationService;
|
|
3863
|
+
element.addEventListener("focusin", (event) => {
|
|
3864
|
+
this.onFocusIn(event);
|
|
3865
|
+
});
|
|
3866
|
+
// Handle checking of input by using keyboard (space)
|
|
3867
|
+
element.addEventListener("change", this.documentFocusIn.bind(this));
|
|
3868
|
+
Array.from(this.element.querySelectorAll("input[type='checkbox'], input[type='radio']"))
|
|
3869
|
+
.filter((childElement) => childElement.closest("fieldset") === element)
|
|
3870
|
+
.forEach((childElement) => {
|
|
3871
|
+
childElement.setAttribute("required", "");
|
|
3872
|
+
});
|
|
3873
|
+
}
|
|
3874
|
+
hasFocusableTarget(target) {
|
|
3875
|
+
return target
|
|
3876
|
+
? Array.from(this.element.querySelectorAll("input, label")).some((element) => element === target)
|
|
3877
|
+
: false;
|
|
3878
|
+
}
|
|
3879
|
+
onFocusIn(event) {
|
|
3880
|
+
// IE11 (not Chrome / FF) trigger focusin-event on legends and other elements inside the fieldset
|
|
3881
|
+
// So we need to check the event target, if it's focusable.
|
|
3882
|
+
if (this.hasFocusableTarget(event.target) &&
|
|
3883
|
+
!this.hasDocumentListener) {
|
|
3884
|
+
this.documentFocusInRef = this.documentFocusIn.bind(this);
|
|
3885
|
+
document.addEventListener("focusin", this.documentFocusInRef);
|
|
3886
|
+
document.addEventListener("click", this.documentFocusInRef);
|
|
3887
|
+
this.hasDocumentListener = true;
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
documentFocusIn(event) {
|
|
3891
|
+
this.validationService.setTouched(this.element);
|
|
3892
|
+
const children = Array.from(this.element.querySelectorAll("input"));
|
|
3893
|
+
for (const childElement of children) {
|
|
3894
|
+
this.validationService.setTouched(childElement);
|
|
3895
|
+
}
|
|
3896
|
+
if (!this.hasFocusableTarget(event.target)) {
|
|
3897
|
+
this.removeEventListeners();
|
|
3898
|
+
}
|
|
3899
|
+
else if (event.target.checked) {
|
|
3900
|
+
this.validateFieldsetAndChildren();
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
removeEventListeners() {
|
|
3904
|
+
if (this.hasDocumentListener && this.documentFocusInRef) {
|
|
3905
|
+
document.removeEventListener("focusin", this.documentFocusInRef);
|
|
3906
|
+
document.removeEventListener("click", this.documentFocusInRef);
|
|
3907
|
+
this.hasDocumentListener = false;
|
|
3908
|
+
this.validateFieldsetAndChildren();
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
validateFieldsetAndChildren() {
|
|
3912
|
+
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
3913
|
+
validatableElements.forEach((element) => {
|
|
3914
|
+
if (element.id) {
|
|
3915
|
+
this.validationService.validateElement(element.id);
|
|
3916
|
+
}
|
|
3917
|
+
});
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3845
3921
|
/**
|
|
3846
3922
|
* Builder to create validation error message map.
|
|
3847
3923
|
*
|
|
@@ -3965,89 +4041,6 @@ function getErrorMessages() {
|
|
|
3965
4041
|
.build();
|
|
3966
4042
|
}
|
|
3967
4043
|
|
|
3968
|
-
/**
|
|
3969
|
-
* @internal
|
|
3970
|
-
*/
|
|
3971
|
-
function createFieldsetValidator(element, validationService) {
|
|
3972
|
-
/* eslint-disable-next-line no-new, sonarjs/constructor-for-side-effects --
|
|
3973
|
-
* technical debt, this should be refactored as to not rely of side-effects
|
|
3974
|
-
* of the constructor */
|
|
3975
|
-
new FieldsetValidationHandler(element, validationService);
|
|
3976
|
-
}
|
|
3977
|
-
class FieldsetValidationHandler {
|
|
3978
|
-
hasDocumentListener = false;
|
|
3979
|
-
documentFocusInRef = undefined;
|
|
3980
|
-
element;
|
|
3981
|
-
validationService;
|
|
3982
|
-
constructor(element, validationService) {
|
|
3983
|
-
Object.assign(this);
|
|
3984
|
-
this.element = element;
|
|
3985
|
-
this.validationService = validationService;
|
|
3986
|
-
element.addEventListener("focusin", (event) => {
|
|
3987
|
-
this.onFocusIn(event);
|
|
3988
|
-
});
|
|
3989
|
-
// Handle checking of input by using keyboard (space)
|
|
3990
|
-
element.addEventListener("change", this.documentFocusIn.bind(this));
|
|
3991
|
-
Array.from(this.element.querySelectorAll("input[type='checkbox'], input[type='radio']"))
|
|
3992
|
-
.filter((childElement) => childElement.closest("fieldset") === element)
|
|
3993
|
-
.forEach((childElement) => {
|
|
3994
|
-
childElement.setAttribute("required", "");
|
|
3995
|
-
});
|
|
3996
|
-
}
|
|
3997
|
-
hasFocusableTarget(target) {
|
|
3998
|
-
return target
|
|
3999
|
-
? Array.from(this.element.querySelectorAll("input, label")).some((element) => element === target)
|
|
4000
|
-
: false;
|
|
4001
|
-
}
|
|
4002
|
-
onFocusIn(event) {
|
|
4003
|
-
// IE11 (not Chrome / FF) trigger focusin-event on legends and other elements inside the fieldset
|
|
4004
|
-
// So we need to check the event target, if it's focusable.
|
|
4005
|
-
if (this.hasFocusableTarget(event.target) &&
|
|
4006
|
-
!this.hasDocumentListener) {
|
|
4007
|
-
this.documentFocusInRef = this.documentFocusIn.bind(this);
|
|
4008
|
-
document.addEventListener("focusin", this.documentFocusInRef);
|
|
4009
|
-
document.addEventListener("click", this.documentFocusInRef);
|
|
4010
|
-
this.hasDocumentListener = true;
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4013
|
-
documentFocusIn(event) {
|
|
4014
|
-
this.validationService.setTouched(this.element);
|
|
4015
|
-
const children = Array.from(this.element.querySelectorAll("input"));
|
|
4016
|
-
for (const childElement of children) {
|
|
4017
|
-
this.validationService.setTouched(childElement);
|
|
4018
|
-
}
|
|
4019
|
-
if (!this.hasFocusableTarget(event.target)) {
|
|
4020
|
-
this.removeEventListeners();
|
|
4021
|
-
}
|
|
4022
|
-
else if (event.target.checked) {
|
|
4023
|
-
this.validateFieldsetAndChildren();
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
removeEventListeners() {
|
|
4027
|
-
if (this.hasDocumentListener && this.documentFocusInRef) {
|
|
4028
|
-
document.removeEventListener("focusin", this.documentFocusInRef);
|
|
4029
|
-
document.removeEventListener("click", this.documentFocusInRef);
|
|
4030
|
-
this.hasDocumentListener = false;
|
|
4031
|
-
this.validateFieldsetAndChildren();
|
|
4032
|
-
}
|
|
4033
|
-
}
|
|
4034
|
-
validateFieldsetAndChildren() {
|
|
4035
|
-
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
4036
|
-
validatableElements.forEach((element) => {
|
|
4037
|
-
if (element.id) {
|
|
4038
|
-
this.validationService.validateElement(element.id);
|
|
4039
|
-
}
|
|
4040
|
-
});
|
|
4041
|
-
}
|
|
4042
|
-
}
|
|
4043
|
-
|
|
4044
|
-
/**
|
|
4045
|
-
* Registered validators.
|
|
4046
|
-
*
|
|
4047
|
-
* @internal
|
|
4048
|
-
*/
|
|
4049
|
-
const registry = {};
|
|
4050
|
-
|
|
4051
4044
|
/**
|
|
4052
4045
|
* Returns validation error message candidates in prioritized order.
|
|
4053
4046
|
*
|
|
@@ -4096,6 +4089,13 @@ function getElementType(element) {
|
|
|
4096
4089
|
}
|
|
4097
4090
|
}
|
|
4098
4091
|
|
|
4092
|
+
/**
|
|
4093
|
+
* Registered validators.
|
|
4094
|
+
*
|
|
4095
|
+
* @internal
|
|
4096
|
+
*/
|
|
4097
|
+
const registry = {};
|
|
4098
|
+
|
|
4099
4099
|
/**
|
|
4100
4100
|
* Returns true if given element is a validatable element.
|
|
4101
4101
|
*
|
|
@@ -4722,7 +4722,7 @@ const dateFormatValidator = {
|
|
|
4722
4722
|
};
|
|
4723
4723
|
|
|
4724
4724
|
function createNumberRegexp(minDecimals = 0, maxDecimals = 2) {
|
|
4725
|
-
return new RegExp(`^([-\u2212]?[0-9]+)([,.][0-9]{${minDecimals},${maxDecimals}})(?<![,.])$`);
|
|
4725
|
+
return new RegExp(`^([-\u2212]?[0-9]+)([,.][0-9]{${String(minDecimals)},${String(maxDecimals)}})(?<![,.])$`);
|
|
4726
4726
|
}
|
|
4727
4727
|
const decimalValidator = {
|
|
4728
4728
|
name: "decimal",
|
|
@@ -4756,7 +4756,7 @@ const emailValidator = {
|
|
|
4756
4756
|
name: "email",
|
|
4757
4757
|
validation(value, _element, config) {
|
|
4758
4758
|
const maxLength = config.maxLength ?? 254;
|
|
4759
|
-
const EMAIL_REGEXP = new RegExp(`^(?=.{1,${maxLength}}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+(\\.[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$`);
|
|
4759
|
+
const EMAIL_REGEXP = new RegExp(`^(?=.{1,${String(maxLength)}}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+(\\.[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$`);
|
|
4760
4760
|
return isEmpty(value) || EMAIL_REGEXP.test(value);
|
|
4761
4761
|
},
|
|
4762
4762
|
};
|
package/lib/esm/index.js
CHANGED
|
@@ -197,7 +197,7 @@ class DecoratedError extends Error {
|
|
|
197
197
|
super(message);
|
|
198
198
|
Object.setPrototypeOf(this, DecoratedError.prototype);
|
|
199
199
|
/* eslint-disable-next-line @typescript-eslint/restrict-plus-operands -- technical debt */
|
|
200
|
-
this.stack += `\nCaused by: ${cause.stack}`;
|
|
200
|
+
this.stack += `\nCaused by: ${String(cause.stack)}`;
|
|
201
201
|
this.cause = cause;
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
@@ -2196,7 +2196,7 @@ function setCookie(options) {
|
|
|
2196
2196
|
return;
|
|
2197
2197
|
}
|
|
2198
2198
|
const timeout = timeLimitSeconds ?? TWELVE_HOURS;
|
|
2199
|
-
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${timeout};`;
|
|
2199
|
+
const cookieString = `${name}=${encodeURIComponent(value)}; path=/; max-age=${String(timeout)};`;
|
|
2200
2200
|
document.cookie = cookieString;
|
|
2201
2201
|
}
|
|
2202
2202
|
/**
|
|
@@ -2591,7 +2591,7 @@ class FDate {
|
|
|
2591
2591
|
static fromYearMonthDay(year, month, day) {
|
|
2592
2592
|
const paddedMonth = month.toString().padStart(2, "0");
|
|
2593
2593
|
const paddedDay = day.toString().padStart(2, "0");
|
|
2594
|
-
const iso = `${year}-${paddedMonth}-${paddedDay}`;
|
|
2594
|
+
const iso = `${String(year)}-${paddedMonth}-${paddedDay}`;
|
|
2595
2595
|
return FDate.fromIso(iso);
|
|
2596
2596
|
}
|
|
2597
2597
|
/**
|
|
@@ -3527,7 +3527,7 @@ function popFocus(handle) {
|
|
|
3527
3527
|
}
|
|
3528
3528
|
const top = _focusElementStack.pop();
|
|
3529
3529
|
if (top?.id !== handle[sym]) {
|
|
3530
|
-
const outOfOrderErrorMsg = `push/pop called out-of-order. Expected stack handle id: ${top?.id} but got ${handle[sym]}`;
|
|
3530
|
+
const outOfOrderErrorMsg = `push/pop called out-of-order. Expected stack handle id: ${String(top?.id)} but got ${String(handle[sym])}`;
|
|
3531
3531
|
if (configLogic.production) {
|
|
3532
3532
|
// eslint-disable-next-line no-console -- expected to log
|
|
3533
3533
|
console.error(outOfOrderErrorMsg);
|
|
@@ -3840,6 +3840,82 @@ const TranslationService =
|
|
|
3840
3840
|
/* @__PURE__ */
|
|
3841
3841
|
new TranslationServiceImpl();
|
|
3842
3842
|
|
|
3843
|
+
/**
|
|
3844
|
+
* @internal
|
|
3845
|
+
*/
|
|
3846
|
+
function createFieldsetValidator(element, validationService) {
|
|
3847
|
+
/* eslint-disable-next-line no-new, sonarjs/constructor-for-side-effects --
|
|
3848
|
+
* technical debt, this should be refactored as to not rely of side-effects
|
|
3849
|
+
* of the constructor */
|
|
3850
|
+
new FieldsetValidationHandler(element, validationService);
|
|
3851
|
+
}
|
|
3852
|
+
class FieldsetValidationHandler {
|
|
3853
|
+
hasDocumentListener = false;
|
|
3854
|
+
documentFocusInRef = undefined;
|
|
3855
|
+
element;
|
|
3856
|
+
validationService;
|
|
3857
|
+
constructor(element, validationService) {
|
|
3858
|
+
Object.assign(this);
|
|
3859
|
+
this.element = element;
|
|
3860
|
+
this.validationService = validationService;
|
|
3861
|
+
element.addEventListener("focusin", (event) => {
|
|
3862
|
+
this.onFocusIn(event);
|
|
3863
|
+
});
|
|
3864
|
+
// Handle checking of input by using keyboard (space)
|
|
3865
|
+
element.addEventListener("change", this.documentFocusIn.bind(this));
|
|
3866
|
+
Array.from(this.element.querySelectorAll("input[type='checkbox'], input[type='radio']"))
|
|
3867
|
+
.filter((childElement) => childElement.closest("fieldset") === element)
|
|
3868
|
+
.forEach((childElement) => {
|
|
3869
|
+
childElement.setAttribute("required", "");
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
hasFocusableTarget(target) {
|
|
3873
|
+
return target
|
|
3874
|
+
? Array.from(this.element.querySelectorAll("input, label")).some((element) => element === target)
|
|
3875
|
+
: false;
|
|
3876
|
+
}
|
|
3877
|
+
onFocusIn(event) {
|
|
3878
|
+
// IE11 (not Chrome / FF) trigger focusin-event on legends and other elements inside the fieldset
|
|
3879
|
+
// So we need to check the event target, if it's focusable.
|
|
3880
|
+
if (this.hasFocusableTarget(event.target) &&
|
|
3881
|
+
!this.hasDocumentListener) {
|
|
3882
|
+
this.documentFocusInRef = this.documentFocusIn.bind(this);
|
|
3883
|
+
document.addEventListener("focusin", this.documentFocusInRef);
|
|
3884
|
+
document.addEventListener("click", this.documentFocusInRef);
|
|
3885
|
+
this.hasDocumentListener = true;
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
documentFocusIn(event) {
|
|
3889
|
+
this.validationService.setTouched(this.element);
|
|
3890
|
+
const children = Array.from(this.element.querySelectorAll("input"));
|
|
3891
|
+
for (const childElement of children) {
|
|
3892
|
+
this.validationService.setTouched(childElement);
|
|
3893
|
+
}
|
|
3894
|
+
if (!this.hasFocusableTarget(event.target)) {
|
|
3895
|
+
this.removeEventListeners();
|
|
3896
|
+
}
|
|
3897
|
+
else if (event.target.checked) {
|
|
3898
|
+
this.validateFieldsetAndChildren();
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
removeEventListeners() {
|
|
3902
|
+
if (this.hasDocumentListener && this.documentFocusInRef) {
|
|
3903
|
+
document.removeEventListener("focusin", this.documentFocusInRef);
|
|
3904
|
+
document.removeEventListener("click", this.documentFocusInRef);
|
|
3905
|
+
this.hasDocumentListener = false;
|
|
3906
|
+
this.validateFieldsetAndChildren();
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
validateFieldsetAndChildren() {
|
|
3910
|
+
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
3911
|
+
validatableElements.forEach((element) => {
|
|
3912
|
+
if (element.id) {
|
|
3913
|
+
this.validationService.validateElement(element.id);
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3843
3919
|
/**
|
|
3844
3920
|
* Builder to create validation error message map.
|
|
3845
3921
|
*
|
|
@@ -3963,89 +4039,6 @@ function getErrorMessages() {
|
|
|
3963
4039
|
.build();
|
|
3964
4040
|
}
|
|
3965
4041
|
|
|
3966
|
-
/**
|
|
3967
|
-
* @internal
|
|
3968
|
-
*/
|
|
3969
|
-
function createFieldsetValidator(element, validationService) {
|
|
3970
|
-
/* eslint-disable-next-line no-new, sonarjs/constructor-for-side-effects --
|
|
3971
|
-
* technical debt, this should be refactored as to not rely of side-effects
|
|
3972
|
-
* of the constructor */
|
|
3973
|
-
new FieldsetValidationHandler(element, validationService);
|
|
3974
|
-
}
|
|
3975
|
-
class FieldsetValidationHandler {
|
|
3976
|
-
hasDocumentListener = false;
|
|
3977
|
-
documentFocusInRef = undefined;
|
|
3978
|
-
element;
|
|
3979
|
-
validationService;
|
|
3980
|
-
constructor(element, validationService) {
|
|
3981
|
-
Object.assign(this);
|
|
3982
|
-
this.element = element;
|
|
3983
|
-
this.validationService = validationService;
|
|
3984
|
-
element.addEventListener("focusin", (event) => {
|
|
3985
|
-
this.onFocusIn(event);
|
|
3986
|
-
});
|
|
3987
|
-
// Handle checking of input by using keyboard (space)
|
|
3988
|
-
element.addEventListener("change", this.documentFocusIn.bind(this));
|
|
3989
|
-
Array.from(this.element.querySelectorAll("input[type='checkbox'], input[type='radio']"))
|
|
3990
|
-
.filter((childElement) => childElement.closest("fieldset") === element)
|
|
3991
|
-
.forEach((childElement) => {
|
|
3992
|
-
childElement.setAttribute("required", "");
|
|
3993
|
-
});
|
|
3994
|
-
}
|
|
3995
|
-
hasFocusableTarget(target) {
|
|
3996
|
-
return target
|
|
3997
|
-
? Array.from(this.element.querySelectorAll("input, label")).some((element) => element === target)
|
|
3998
|
-
: false;
|
|
3999
|
-
}
|
|
4000
|
-
onFocusIn(event) {
|
|
4001
|
-
// IE11 (not Chrome / FF) trigger focusin-event on legends and other elements inside the fieldset
|
|
4002
|
-
// So we need to check the event target, if it's focusable.
|
|
4003
|
-
if (this.hasFocusableTarget(event.target) &&
|
|
4004
|
-
!this.hasDocumentListener) {
|
|
4005
|
-
this.documentFocusInRef = this.documentFocusIn.bind(this);
|
|
4006
|
-
document.addEventListener("focusin", this.documentFocusInRef);
|
|
4007
|
-
document.addEventListener("click", this.documentFocusInRef);
|
|
4008
|
-
this.hasDocumentListener = true;
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
documentFocusIn(event) {
|
|
4012
|
-
this.validationService.setTouched(this.element);
|
|
4013
|
-
const children = Array.from(this.element.querySelectorAll("input"));
|
|
4014
|
-
for (const childElement of children) {
|
|
4015
|
-
this.validationService.setTouched(childElement);
|
|
4016
|
-
}
|
|
4017
|
-
if (!this.hasFocusableTarget(event.target)) {
|
|
4018
|
-
this.removeEventListeners();
|
|
4019
|
-
}
|
|
4020
|
-
else if (event.target.checked) {
|
|
4021
|
-
this.validateFieldsetAndChildren();
|
|
4022
|
-
}
|
|
4023
|
-
}
|
|
4024
|
-
removeEventListeners() {
|
|
4025
|
-
if (this.hasDocumentListener && this.documentFocusInRef) {
|
|
4026
|
-
document.removeEventListener("focusin", this.documentFocusInRef);
|
|
4027
|
-
document.removeEventListener("click", this.documentFocusInRef);
|
|
4028
|
-
this.hasDocumentListener = false;
|
|
4029
|
-
this.validateFieldsetAndChildren();
|
|
4030
|
-
}
|
|
4031
|
-
}
|
|
4032
|
-
validateFieldsetAndChildren() {
|
|
4033
|
-
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
4034
|
-
validatableElements.forEach((element) => {
|
|
4035
|
-
if (element.id) {
|
|
4036
|
-
this.validationService.validateElement(element.id);
|
|
4037
|
-
}
|
|
4038
|
-
});
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
/**
|
|
4043
|
-
* Registered validators.
|
|
4044
|
-
*
|
|
4045
|
-
* @internal
|
|
4046
|
-
*/
|
|
4047
|
-
const registry = {};
|
|
4048
|
-
|
|
4049
4042
|
/**
|
|
4050
4043
|
* Returns validation error message candidates in prioritized order.
|
|
4051
4044
|
*
|
|
@@ -4094,6 +4087,13 @@ function getElementType(element) {
|
|
|
4094
4087
|
}
|
|
4095
4088
|
}
|
|
4096
4089
|
|
|
4090
|
+
/**
|
|
4091
|
+
* Registered validators.
|
|
4092
|
+
*
|
|
4093
|
+
* @internal
|
|
4094
|
+
*/
|
|
4095
|
+
const registry = {};
|
|
4096
|
+
|
|
4097
4097
|
/**
|
|
4098
4098
|
* Returns true if given element is a validatable element.
|
|
4099
4099
|
*
|
|
@@ -4720,7 +4720,7 @@ const dateFormatValidator = {
|
|
|
4720
4720
|
};
|
|
4721
4721
|
|
|
4722
4722
|
function createNumberRegexp(minDecimals = 0, maxDecimals = 2) {
|
|
4723
|
-
return new RegExp(`^([-\u2212]?[0-9]+)([,.][0-9]{${minDecimals},${maxDecimals}})(?<![,.])$`);
|
|
4723
|
+
return new RegExp(`^([-\u2212]?[0-9]+)([,.][0-9]{${String(minDecimals)},${String(maxDecimals)}})(?<![,.])$`);
|
|
4724
4724
|
}
|
|
4725
4725
|
const decimalValidator = {
|
|
4726
4726
|
name: "decimal",
|
|
@@ -4754,7 +4754,7 @@ const emailValidator = {
|
|
|
4754
4754
|
name: "email",
|
|
4755
4755
|
validation(value, _element, config) {
|
|
4756
4756
|
const maxLength = config.maxLength ?? 254;
|
|
4757
|
-
const EMAIL_REGEXP = new RegExp(`^(?=.{1,${maxLength}}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+(\\.[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$`);
|
|
4757
|
+
const EMAIL_REGEXP = new RegExp(`^(?=.{1,${String(maxLength)}}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+(\\.[-!#$%&'*+/0-9=?A-Z^_\`a-z{|}~åäöÅÄÖ]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$`);
|
|
4758
4758
|
return isEmpty(value) || EMAIL_REGEXP.test(value);
|
|
4759
4759
|
},
|
|
4760
4760
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -268,25 +268,25 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
268
268
|
export {
|
|
269
269
|
addFocusListener,
|
|
270
270
|
documentOrderComparator,
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
isTabbable,
|
|
271
|
+
FocusOptions_2 as FocusOptions,
|
|
272
|
+
StackHandle,
|
|
274
273
|
findTabbableElements,
|
|
274
|
+
focus_2 as focus,
|
|
275
275
|
focusFirst,
|
|
276
276
|
focusLast,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
FocusOptions_2 as FocusOptions,
|
|
277
|
+
isFocusable,
|
|
278
|
+
isTabbable,
|
|
280
279
|
popFocus,
|
|
281
280
|
pushFocus,
|
|
282
|
-
|
|
281
|
+
restoreFocus,
|
|
282
|
+
saveFocus,
|
|
283
283
|
handleTab,
|
|
284
284
|
isValidatableFormElement,
|
|
285
285
|
isVisible,
|
|
286
286
|
isVisibleInViewport,
|
|
287
287
|
removeFocusListener,
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
ScrollToOptions_2 as ScrollToOptions,
|
|
289
|
+
scrollTo_2 as scrollTo
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
export { DomUtils }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkui/logic",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.22.0",
|
|
4
4
|
"description": "Logic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fkui",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"watch": "rollup --config --watch"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@fkui/date": "^6.
|
|
64
|
+
"@fkui/date": "^6.22.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">= 20",
|
|
68
68
|
"npm": ">= 7"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "ebc31640a950acc4a20ac6b07509aa12f78ee781"
|
|
71
71
|
}
|