@fkui/logic 6.31.0 → 6.32.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.
- package/lib/cjs/index.js +29 -3
- package/lib/esm/index.js +29 -3
- package/lib/types/index.d.ts +6 -1
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -2213,6 +2213,7 @@ function deleteCookie(name) {
|
|
|
2213
2213
|
function findCookie(name) {
|
|
2214
2214
|
/* handle when document or cookie does not exist, e.g. when DOM isn't
|
|
2215
2215
|
* present */
|
|
2216
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
2216
2217
|
if (!document?.cookie) {
|
|
2217
2218
|
return undefined;
|
|
2218
2219
|
}
|
|
@@ -3398,6 +3399,7 @@ function focus(element, options = {}) {
|
|
|
3398
3399
|
element.focus(params);
|
|
3399
3400
|
if (scrollToTop) {
|
|
3400
3401
|
element.focus({ ...params, preventScroll: true });
|
|
3402
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
3401
3403
|
scrollTo(element);
|
|
3402
3404
|
}
|
|
3403
3405
|
else {
|
|
@@ -3524,10 +3526,13 @@ function pushFocus(element) {
|
|
|
3524
3526
|
* Restore the focus on the last element from the stack
|
|
3525
3527
|
*
|
|
3526
3528
|
* @public
|
|
3529
|
+
* @param handle - The stack handle returned from the corresponding `pushFocus` call.
|
|
3530
|
+
* @param options - Options for `popFocus`.
|
|
3527
3531
|
* @throws Error when pop is called on an empty focus stack
|
|
3528
3532
|
* @throws Error when pop is called without a valid StackHandle
|
|
3529
3533
|
*/
|
|
3530
|
-
function popFocus(handle) {
|
|
3534
|
+
function popFocus(handle, options = {}) {
|
|
3535
|
+
const { restoreFocus = true } = options;
|
|
3531
3536
|
if (_focusElementStack.length === 0) {
|
|
3532
3537
|
const emptyStackErrorMsg = "Can not call pop on an empty focus stack";
|
|
3533
3538
|
if (configLogic.production) {
|
|
@@ -3551,7 +3556,10 @@ function popFocus(handle) {
|
|
|
3551
3556
|
throw new Error(outOfOrderErrorMsg);
|
|
3552
3557
|
}
|
|
3553
3558
|
}
|
|
3554
|
-
|
|
3559
|
+
if (restoreFocus) {
|
|
3560
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
3561
|
+
focus(top?.element);
|
|
3562
|
+
}
|
|
3555
3563
|
}
|
|
3556
3564
|
/**
|
|
3557
3565
|
* Restore the focus on the last element from the stack
|
|
@@ -3708,6 +3716,7 @@ new ElementIdServiceImpl();
|
|
|
3708
3716
|
const haveSessionStorage = /* @__PURE__ */ (() => {
|
|
3709
3717
|
const test = "fkui.sessionstorage.test";
|
|
3710
3718
|
try {
|
|
3719
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
3711
3720
|
if (window.sessionStorage) {
|
|
3712
3721
|
window.sessionStorage.setItem(test, "test");
|
|
3713
3722
|
window.sessionStorage.removeItem(test);
|
|
@@ -3760,7 +3769,9 @@ class PersistenceService {
|
|
|
3760
3769
|
? window.sessionStorage.getItem(key)
|
|
3761
3770
|
: null;
|
|
3762
3771
|
if (persisted) {
|
|
3772
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- technical debt */
|
|
3763
3773
|
const value = JSON.parse(persisted);
|
|
3774
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- technical debt */
|
|
3764
3775
|
this.cache.set(key, value);
|
|
3765
3776
|
}
|
|
3766
3777
|
return this.cache.get(key);
|
|
@@ -3835,7 +3846,9 @@ class DefaultTranslationProvider {
|
|
|
3835
3846
|
: defaultValueOrArgs;
|
|
3836
3847
|
}
|
|
3837
3848
|
interpolate(defaultValue, args) {
|
|
3838
|
-
return defaultValue.replace(
|
|
3849
|
+
return defaultValue.replace(
|
|
3850
|
+
/* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
|
|
3851
|
+
/{{\s*([^\s]+)\s*}}/g, (match, key) => {
|
|
3839
3852
|
return String(args[key]) || match;
|
|
3840
3853
|
});
|
|
3841
3854
|
}
|
|
@@ -3924,6 +3937,7 @@ class FieldsetValidationHandler {
|
|
|
3924
3937
|
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
3925
3938
|
validatableElements.forEach((element) => {
|
|
3926
3939
|
if (element.id) {
|
|
3940
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
3927
3941
|
this.validationService.validateElement(element.id);
|
|
3928
3942
|
}
|
|
3929
3943
|
});
|
|
@@ -4401,16 +4415,19 @@ class ValidationServiceImpl {
|
|
|
4401
4415
|
}
|
|
4402
4416
|
else if (typeof element === "string") {
|
|
4403
4417
|
const found = document.getElementById(element);
|
|
4418
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4404
4419
|
this.setState(found, validationState);
|
|
4405
4420
|
}
|
|
4406
4421
|
else if (!isValidatableHTMLElement(element)) {
|
|
4407
4422
|
const childElements = this.getValidatableElements(element);
|
|
4408
4423
|
for (const childElement of childElements) {
|
|
4424
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4409
4425
|
this.setState(childElement, validationState);
|
|
4410
4426
|
}
|
|
4411
4427
|
}
|
|
4412
4428
|
else {
|
|
4413
4429
|
const existingState = this.validationStates[element.id];
|
|
4430
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4414
4431
|
if (existingState) {
|
|
4415
4432
|
this.validationStates[element.id] = {
|
|
4416
4433
|
...existingState,
|
|
@@ -4423,21 +4440,25 @@ class ValidationServiceImpl {
|
|
|
4423
4440
|
}
|
|
4424
4441
|
}
|
|
4425
4442
|
setSubmitted(element) {
|
|
4443
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4426
4444
|
this.setState(element, {
|
|
4427
4445
|
submitted: true,
|
|
4428
4446
|
});
|
|
4429
4447
|
}
|
|
4430
4448
|
setTouched(element) {
|
|
4449
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4431
4450
|
this.setState(element, {
|
|
4432
4451
|
touched: true,
|
|
4433
4452
|
});
|
|
4434
4453
|
}
|
|
4435
4454
|
setError(element, message) {
|
|
4455
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4436
4456
|
this.setState(element, {
|
|
4437
4457
|
serverError: message,
|
|
4438
4458
|
});
|
|
4439
4459
|
}
|
|
4440
4460
|
resetState(element) {
|
|
4461
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4441
4462
|
this.setState(element, {
|
|
4442
4463
|
touched: false,
|
|
4443
4464
|
submitted: false,
|
|
@@ -4489,8 +4510,10 @@ class ValidationServiceImpl {
|
|
|
4489
4510
|
}
|
|
4490
4511
|
getExistingStateOrSetDefault(element) {
|
|
4491
4512
|
let validationState = this.getState(element.id);
|
|
4513
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4492
4514
|
if (!validationState) {
|
|
4493
4515
|
validationState = { touched: false, submitted: false };
|
|
4516
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4494
4517
|
this.setState(element, validationState);
|
|
4495
4518
|
}
|
|
4496
4519
|
return validationState;
|
|
@@ -4499,6 +4522,7 @@ class ValidationServiceImpl {
|
|
|
4499
4522
|
const validatorNames = Object.keys(validatorConfigs);
|
|
4500
4523
|
return validatorNames.map((validatorName) => {
|
|
4501
4524
|
const validator = registry[validatorName];
|
|
4525
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4502
4526
|
if (validator) {
|
|
4503
4527
|
return validator;
|
|
4504
4528
|
}
|
|
@@ -5189,6 +5213,7 @@ function alertScreenReader(text, options) {
|
|
|
5189
5213
|
updateProperties(mergedOptions);
|
|
5190
5214
|
const msg = document.createElement("p");
|
|
5191
5215
|
msg.textContent = text;
|
|
5216
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
5192
5217
|
waitForScreenReader(() => {
|
|
5193
5218
|
while (wrapper.firstChild) {
|
|
5194
5219
|
wrapper.removeChild(wrapper.firstChild);
|
|
@@ -5209,6 +5234,7 @@ function alertScreenReader(text, options) {
|
|
|
5209
5234
|
* @param options - options for wrapper element attributes.
|
|
5210
5235
|
*/
|
|
5211
5236
|
function createScreenReaderWrapper(options) {
|
|
5237
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
5212
5238
|
if (!getWrapper()) {
|
|
5213
5239
|
wrapper = document.createElement("div");
|
|
5214
5240
|
wrapper.id = "fkui-alert-screen-reader";
|
package/lib/esm/index.js
CHANGED
|
@@ -2211,6 +2211,7 @@ function deleteCookie(name) {
|
|
|
2211
2211
|
function findCookie(name) {
|
|
2212
2212
|
/* handle when document or cookie does not exist, e.g. when DOM isn't
|
|
2213
2213
|
* present */
|
|
2214
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
2214
2215
|
if (!document?.cookie) {
|
|
2215
2216
|
return undefined;
|
|
2216
2217
|
}
|
|
@@ -3396,6 +3397,7 @@ function focus(element, options = {}) {
|
|
|
3396
3397
|
element.focus(params);
|
|
3397
3398
|
if (scrollToTop) {
|
|
3398
3399
|
element.focus({ ...params, preventScroll: true });
|
|
3400
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
3399
3401
|
scrollTo(element);
|
|
3400
3402
|
}
|
|
3401
3403
|
else {
|
|
@@ -3522,10 +3524,13 @@ function pushFocus(element) {
|
|
|
3522
3524
|
* Restore the focus on the last element from the stack
|
|
3523
3525
|
*
|
|
3524
3526
|
* @public
|
|
3527
|
+
* @param handle - The stack handle returned from the corresponding `pushFocus` call.
|
|
3528
|
+
* @param options - Options for `popFocus`.
|
|
3525
3529
|
* @throws Error when pop is called on an empty focus stack
|
|
3526
3530
|
* @throws Error when pop is called without a valid StackHandle
|
|
3527
3531
|
*/
|
|
3528
|
-
function popFocus(handle) {
|
|
3532
|
+
function popFocus(handle, options = {}) {
|
|
3533
|
+
const { restoreFocus = true } = options;
|
|
3529
3534
|
if (_focusElementStack.length === 0) {
|
|
3530
3535
|
const emptyStackErrorMsg = "Can not call pop on an empty focus stack";
|
|
3531
3536
|
if (configLogic.production) {
|
|
@@ -3549,7 +3554,10 @@ function popFocus(handle) {
|
|
|
3549
3554
|
throw new Error(outOfOrderErrorMsg);
|
|
3550
3555
|
}
|
|
3551
3556
|
}
|
|
3552
|
-
|
|
3557
|
+
if (restoreFocus) {
|
|
3558
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
3559
|
+
focus(top?.element);
|
|
3560
|
+
}
|
|
3553
3561
|
}
|
|
3554
3562
|
/**
|
|
3555
3563
|
* Restore the focus on the last element from the stack
|
|
@@ -3706,6 +3714,7 @@ new ElementIdServiceImpl();
|
|
|
3706
3714
|
const haveSessionStorage = /* @__PURE__ */ (() => {
|
|
3707
3715
|
const test = "fkui.sessionstorage.test";
|
|
3708
3716
|
try {
|
|
3717
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
3709
3718
|
if (window.sessionStorage) {
|
|
3710
3719
|
window.sessionStorage.setItem(test, "test");
|
|
3711
3720
|
window.sessionStorage.removeItem(test);
|
|
@@ -3758,7 +3767,9 @@ class PersistenceService {
|
|
|
3758
3767
|
? window.sessionStorage.getItem(key)
|
|
3759
3768
|
: null;
|
|
3760
3769
|
if (persisted) {
|
|
3770
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- technical debt */
|
|
3761
3771
|
const value = JSON.parse(persisted);
|
|
3772
|
+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- technical debt */
|
|
3762
3773
|
this.cache.set(key, value);
|
|
3763
3774
|
}
|
|
3764
3775
|
return this.cache.get(key);
|
|
@@ -3833,7 +3844,9 @@ class DefaultTranslationProvider {
|
|
|
3833
3844
|
: defaultValueOrArgs;
|
|
3834
3845
|
}
|
|
3835
3846
|
interpolate(defaultValue, args) {
|
|
3836
|
-
return defaultValue.replace(
|
|
3847
|
+
return defaultValue.replace(
|
|
3848
|
+
/* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
|
|
3849
|
+
/{{\s*([^\s]+)\s*}}/g, (match, key) => {
|
|
3837
3850
|
return String(args[key]) || match;
|
|
3838
3851
|
});
|
|
3839
3852
|
}
|
|
@@ -3922,6 +3935,7 @@ class FieldsetValidationHandler {
|
|
|
3922
3935
|
const validatableElements = document.querySelectorAll(`fieldset#${this.element.id}, #${this.element.id} input[type='checkbox'], #${this.element.id} input[type='radio']`);
|
|
3923
3936
|
validatableElements.forEach((element) => {
|
|
3924
3937
|
if (element.id) {
|
|
3938
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
3925
3939
|
this.validationService.validateElement(element.id);
|
|
3926
3940
|
}
|
|
3927
3941
|
});
|
|
@@ -4399,16 +4413,19 @@ class ValidationServiceImpl {
|
|
|
4399
4413
|
}
|
|
4400
4414
|
else if (typeof element === "string") {
|
|
4401
4415
|
const found = document.getElementById(element);
|
|
4416
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4402
4417
|
this.setState(found, validationState);
|
|
4403
4418
|
}
|
|
4404
4419
|
else if (!isValidatableHTMLElement(element)) {
|
|
4405
4420
|
const childElements = this.getValidatableElements(element);
|
|
4406
4421
|
for (const childElement of childElements) {
|
|
4422
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4407
4423
|
this.setState(childElement, validationState);
|
|
4408
4424
|
}
|
|
4409
4425
|
}
|
|
4410
4426
|
else {
|
|
4411
4427
|
const existingState = this.validationStates[element.id];
|
|
4428
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4412
4429
|
if (existingState) {
|
|
4413
4430
|
this.validationStates[element.id] = {
|
|
4414
4431
|
...existingState,
|
|
@@ -4421,21 +4438,25 @@ class ValidationServiceImpl {
|
|
|
4421
4438
|
}
|
|
4422
4439
|
}
|
|
4423
4440
|
setSubmitted(element) {
|
|
4441
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4424
4442
|
this.setState(element, {
|
|
4425
4443
|
submitted: true,
|
|
4426
4444
|
});
|
|
4427
4445
|
}
|
|
4428
4446
|
setTouched(element) {
|
|
4447
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4429
4448
|
this.setState(element, {
|
|
4430
4449
|
touched: true,
|
|
4431
4450
|
});
|
|
4432
4451
|
}
|
|
4433
4452
|
setError(element, message) {
|
|
4453
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4434
4454
|
this.setState(element, {
|
|
4435
4455
|
serverError: message,
|
|
4436
4456
|
});
|
|
4437
4457
|
}
|
|
4438
4458
|
resetState(element) {
|
|
4459
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4439
4460
|
this.setState(element, {
|
|
4440
4461
|
touched: false,
|
|
4441
4462
|
submitted: false,
|
|
@@ -4487,8 +4508,10 @@ class ValidationServiceImpl {
|
|
|
4487
4508
|
}
|
|
4488
4509
|
getExistingStateOrSetDefault(element) {
|
|
4489
4510
|
let validationState = this.getState(element.id);
|
|
4511
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4490
4512
|
if (!validationState) {
|
|
4491
4513
|
validationState = { touched: false, submitted: false };
|
|
4514
|
+
/* eslint-disable-next-line @typescript-eslint/no-deprecated -- internal usage */
|
|
4492
4515
|
this.setState(element, validationState);
|
|
4493
4516
|
}
|
|
4494
4517
|
return validationState;
|
|
@@ -4497,6 +4520,7 @@ class ValidationServiceImpl {
|
|
|
4497
4520
|
const validatorNames = Object.keys(validatorConfigs);
|
|
4498
4521
|
return validatorNames.map((validatorName) => {
|
|
4499
4522
|
const validator = registry[validatorName];
|
|
4523
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
4500
4524
|
if (validator) {
|
|
4501
4525
|
return validator;
|
|
4502
4526
|
}
|
|
@@ -5187,6 +5211,7 @@ function alertScreenReader(text, options) {
|
|
|
5187
5211
|
updateProperties(mergedOptions);
|
|
5188
5212
|
const msg = document.createElement("p");
|
|
5189
5213
|
msg.textContent = text;
|
|
5214
|
+
/* eslint-disable-next-line @typescript-eslint/no-floating-promises -- technical debt */
|
|
5190
5215
|
waitForScreenReader(() => {
|
|
5191
5216
|
while (wrapper.firstChild) {
|
|
5192
5217
|
wrapper.removeChild(wrapper.firstChild);
|
|
@@ -5207,6 +5232,7 @@ function alertScreenReader(text, options) {
|
|
|
5207
5232
|
* @param options - options for wrapper element attributes.
|
|
5208
5233
|
*/
|
|
5209
5234
|
function createScreenReaderWrapper(options) {
|
|
5235
|
+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- technical debt */
|
|
5210
5236
|
if (!getWrapper()) {
|
|
5211
5237
|
wrapper = document.createElement("div");
|
|
5212
5238
|
wrapper.id = "fkui-alert-screen-reader";
|
package/lib/types/index.d.ts
CHANGED
|
@@ -792,10 +792,15 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
792
792
|
* Restore the focus on the last element from the stack
|
|
793
793
|
*
|
|
794
794
|
* @public
|
|
795
|
+
* @param handle - The stack handle returned from the corresponding `pushFocus` call.
|
|
796
|
+
* @param options - Options for `popFocus`.
|
|
795
797
|
* @throws Error when pop is called on an empty focus stack
|
|
796
798
|
* @throws Error when pop is called without a valid StackHandle
|
|
797
799
|
*/
|
|
798
|
-
export declare function popFocus(handle: StackHandle
|
|
800
|
+
export declare function popFocus(handle: StackHandle, options?: {
|
|
801
|
+
/** Whether to restore focus after popping it from the stack. Defaults to true. */
|
|
802
|
+
restoreFocus?: boolean;
|
|
803
|
+
}): void;
|
|
799
804
|
|
|
800
805
|
/**
|
|
801
806
|
* A 5-digit string with space separator, for example "932 22"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkui/logic",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.32.1",
|
|
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.32.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">= 20",
|
|
68
68
|
"npm": ">= 7"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "1618fc839a8da920fbbaa15bfe75c2cccd09caba"
|
|
71
71
|
}
|