@fkui/logic 6.3.0 → 6.4.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 +192 -178
- package/lib/esm/index.js +192 -179
- package/lib/types/index.d.ts +7 -0
- package/lib/types/polyfills.d.ts +1 -1
- package/lib/types/tsdoc-metadata.json +1 -1
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -2325,7 +2325,7 @@ var Locale;
|
|
|
2325
2325
|
function getDefaultLocale() {
|
|
2326
2326
|
return Locale.SWEDISH;
|
|
2327
2327
|
}
|
|
2328
|
-
let _locale = getDefaultLocale();
|
|
2328
|
+
let _locale = /* @__PURE__ */ getDefaultLocale();
|
|
2329
2329
|
/**
|
|
2330
2330
|
* Get current locale.
|
|
2331
2331
|
*
|
|
@@ -3263,10 +3263,10 @@ function scrollToSlow(element, duration, offset = 0) {
|
|
|
3263
3263
|
});
|
|
3264
3264
|
}
|
|
3265
3265
|
|
|
3266
|
-
const sym = Symbol("focus-stack");
|
|
3266
|
+
const sym = /* @__PURE__ */ Symbol("focus-stack");
|
|
3267
3267
|
let _stackHandleCounter = 0;
|
|
3268
3268
|
const _focusElementStack = [];
|
|
3269
|
-
const TABBABLE_ELEMENT_SELECTOR = [
|
|
3269
|
+
const TABBABLE_ELEMENT_SELECTOR = /* @__PURE__ */ [
|
|
3270
3270
|
"a[href]",
|
|
3271
3271
|
"area[href]",
|
|
3272
3272
|
"input",
|
|
@@ -3574,6 +3574,150 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3574
3574
|
scrollTo: scrollTo
|
|
3575
3575
|
});
|
|
3576
3576
|
|
|
3577
|
+
class ElementIdServiceImpl {
|
|
3578
|
+
elementIdMap = new Map();
|
|
3579
|
+
generateElementId(prefix = "fkui") {
|
|
3580
|
+
const id = this.nextId(prefix);
|
|
3581
|
+
if (document.getElementById(id) === null) {
|
|
3582
|
+
return id;
|
|
3583
|
+
}
|
|
3584
|
+
return this.generateElementId(prefix);
|
|
3585
|
+
}
|
|
3586
|
+
nextId(prefix) {
|
|
3587
|
+
let elementIdWithPadding = String(this.getIdFromMap(prefix));
|
|
3588
|
+
while (elementIdWithPadding.length < 4) {
|
|
3589
|
+
elementIdWithPadding = `0${elementIdWithPadding}`;
|
|
3590
|
+
}
|
|
3591
|
+
return `${prefix}-vue-element-${elementIdWithPadding}`;
|
|
3592
|
+
}
|
|
3593
|
+
getIdFromMap(prefix) {
|
|
3594
|
+
const elementId = this.elementIdMap.get(prefix);
|
|
3595
|
+
if (!elementId) {
|
|
3596
|
+
this.elementIdMap.set(prefix, { count: 1 });
|
|
3597
|
+
return 1;
|
|
3598
|
+
}
|
|
3599
|
+
elementId.count++;
|
|
3600
|
+
return elementId.count;
|
|
3601
|
+
}
|
|
3602
|
+
reset() {
|
|
3603
|
+
this.elementIdMap = new Map();
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
/**
|
|
3607
|
+
* @public
|
|
3608
|
+
*/
|
|
3609
|
+
const ElementIdService =
|
|
3610
|
+
/* @__PURE__ */
|
|
3611
|
+
new ElementIdServiceImpl();
|
|
3612
|
+
|
|
3613
|
+
/* istanbul ignore next: manually tested */
|
|
3614
|
+
const haveSessionStorage = /* @__PURE__ */ (() => {
|
|
3615
|
+
const test = "fkui.sessionstorage.test";
|
|
3616
|
+
try {
|
|
3617
|
+
if (window.sessionStorage) {
|
|
3618
|
+
window.sessionStorage.setItem(test, "test");
|
|
3619
|
+
window.sessionStorage.removeItem(test);
|
|
3620
|
+
return true;
|
|
3621
|
+
}
|
|
3622
|
+
else {
|
|
3623
|
+
return false;
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
catch {
|
|
3627
|
+
/* Safari on iOS throws security exceptions when accessing
|
|
3628
|
+
* sessionstorage in private browsing. */
|
|
3629
|
+
return false;
|
|
3630
|
+
}
|
|
3631
|
+
})();
|
|
3632
|
+
/**
|
|
3633
|
+
* This feature can be used by creating a new file with something like:
|
|
3634
|
+
*
|
|
3635
|
+
* ```
|
|
3636
|
+
* export const MyCustomPersistenceService = new PersistenceService<MyCustomApplicationModel>();
|
|
3637
|
+
* ```
|
|
3638
|
+
*
|
|
3639
|
+
* There is also a simplified version in {@link SimplePersistenceService}.
|
|
3640
|
+
*
|
|
3641
|
+
* @public
|
|
3642
|
+
*/
|
|
3643
|
+
class PersistenceService {
|
|
3644
|
+
cache;
|
|
3645
|
+
constructor() {
|
|
3646
|
+
this.cache = new Map();
|
|
3647
|
+
}
|
|
3648
|
+
set(key, value) {
|
|
3649
|
+
if (this.isSessionPresent) {
|
|
3650
|
+
window.sessionStorage.setItem(key, JSON.stringify(value));
|
|
3651
|
+
}
|
|
3652
|
+
this.cache.set(key, value);
|
|
3653
|
+
}
|
|
3654
|
+
get(key) {
|
|
3655
|
+
const found = this.find(key);
|
|
3656
|
+
if (typeof found !== "undefined") {
|
|
3657
|
+
return found;
|
|
3658
|
+
}
|
|
3659
|
+
throw Error(`PersistenceService cannot find entry with key "${key}"`);
|
|
3660
|
+
}
|
|
3661
|
+
find(key) {
|
|
3662
|
+
if (this.cache.has(key)) {
|
|
3663
|
+
return this.cache.get(key);
|
|
3664
|
+
}
|
|
3665
|
+
const persisted = this.isSessionPresent
|
|
3666
|
+
? window.sessionStorage.getItem(key)
|
|
3667
|
+
: null;
|
|
3668
|
+
if (persisted) {
|
|
3669
|
+
const value = JSON.parse(persisted);
|
|
3670
|
+
this.cache.set(key, value);
|
|
3671
|
+
}
|
|
3672
|
+
return this.cache.get(key);
|
|
3673
|
+
}
|
|
3674
|
+
remove(key) {
|
|
3675
|
+
if (this.isSessionPresent) {
|
|
3676
|
+
window.sessionStorage.removeItem(key);
|
|
3677
|
+
}
|
|
3678
|
+
this.cache.delete(key);
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* @internal
|
|
3682
|
+
*/
|
|
3683
|
+
/* istanbul ignore next: for mocking in unittests */
|
|
3684
|
+
get isSessionPresent() {
|
|
3685
|
+
return haveSessionStorage;
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
|
|
3689
|
+
/**
|
|
3690
|
+
* This feature can be used by creating a new file with something like:
|
|
3691
|
+
*
|
|
3692
|
+
* ```ts
|
|
3693
|
+
* export const MyAwesomePersistenceService = new SimplePersistenceService<MyAwesomeModel>("my-awesome-key");
|
|
3694
|
+
* ```
|
|
3695
|
+
*
|
|
3696
|
+
* There is also a more advanced version in {@link PersistenceService}.
|
|
3697
|
+
*
|
|
3698
|
+
* @public
|
|
3699
|
+
*/
|
|
3700
|
+
class SimplePersistenceService {
|
|
3701
|
+
persistenceService;
|
|
3702
|
+
key;
|
|
3703
|
+
constructor(key) {
|
|
3704
|
+
this.key = key;
|
|
3705
|
+
this.persistenceService = new PersistenceService();
|
|
3706
|
+
}
|
|
3707
|
+
set(value) {
|
|
3708
|
+
this.persistenceService.set(this.key, value);
|
|
3709
|
+
}
|
|
3710
|
+
get() {
|
|
3711
|
+
return this.persistenceService.get(this.key);
|
|
3712
|
+
}
|
|
3713
|
+
find() {
|
|
3714
|
+
return this.persistenceService.find(this.key);
|
|
3715
|
+
}
|
|
3716
|
+
remove() {
|
|
3717
|
+
this.persistenceService.remove(this.key);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3577
3721
|
class DefaultTranslationProvider {
|
|
3578
3722
|
language = "sv";
|
|
3579
3723
|
get currentLanguage() {
|
|
@@ -3610,7 +3754,9 @@ class TranslationServiceImpl {
|
|
|
3610
3754
|
/**
|
|
3611
3755
|
* @public
|
|
3612
3756
|
*/
|
|
3613
|
-
const TranslationService =
|
|
3757
|
+
const TranslationService =
|
|
3758
|
+
/* @__PURE__ */
|
|
3759
|
+
new TranslationServiceImpl();
|
|
3614
3760
|
|
|
3615
3761
|
/**
|
|
3616
3762
|
* Builder to create validation error message map.
|
|
@@ -4385,7 +4531,9 @@ class ValidationServiceImpl {
|
|
|
4385
4531
|
/**
|
|
4386
4532
|
* @public
|
|
4387
4533
|
*/
|
|
4388
|
-
const ValidationService =
|
|
4534
|
+
const ValidationService =
|
|
4535
|
+
/* @__PURE__ */
|
|
4536
|
+
new ValidationServiceImpl();
|
|
4389
4537
|
|
|
4390
4538
|
/**
|
|
4391
4539
|
* @public
|
|
@@ -4826,183 +4974,48 @@ const whitelistValidator = {
|
|
|
4826
4974
|
},
|
|
4827
4975
|
};
|
|
4828
4976
|
|
|
4829
|
-
ValidationService.registerValidator(allowListValidator);
|
|
4830
|
-
ValidationService.registerValidator(bankAccountNumberValidator);
|
|
4831
|
-
ValidationService.registerValidator(bankgiroValidator);
|
|
4832
|
-
ValidationService.registerValidator(blacklistValidator);
|
|
4833
|
-
ValidationService.registerValidator(clearingNumberValidator);
|
|
4834
|
-
ValidationService.registerValidator(currencyValidator);
|
|
4835
|
-
ValidationService.registerValidator(dateFormatValidator);
|
|
4836
|
-
ValidationService.registerValidator(dateValidator);
|
|
4837
|
-
ValidationService.registerValidator(decimalValidator);
|
|
4838
|
-
ValidationService.registerValidator(emailValidator);
|
|
4839
|
-
ValidationService.registerValidator(greaterThanValidator);
|
|
4840
|
-
ValidationService.registerValidator(integerValidator);
|
|
4841
|
-
ValidationService.registerValidator(invalidDatesValidator);
|
|
4842
|
-
ValidationService.registerValidator(invalidWeekdaysValidator);
|
|
4843
|
-
ValidationService.registerValidator(lessThanValidator);
|
|
4844
|
-
ValidationService.registerValidator(matchesValidator);
|
|
4845
|
-
ValidationService.registerValidator(maxDateValidator);
|
|
4846
|
-
ValidationService.registerValidator(maxLengthValidator);
|
|
4847
|
-
ValidationService.registerValidator(maxValueValidator);
|
|
4848
|
-
ValidationService.registerValidator(minDateValidator);
|
|
4849
|
-
ValidationService.registerValidator(minLengthValidator);
|
|
4850
|
-
ValidationService.registerValidator(minValueValidator);
|
|
4851
|
-
ValidationService.registerValidator(numberValidator);
|
|
4852
|
-
ValidationService.registerValidator(organisationsnummerValidator);
|
|
4853
|
-
ValidationService.registerValidator(percentValidator);
|
|
4854
|
-
ValidationService.registerValidator(personnummerFormatValidator);
|
|
4855
|
-
ValidationService.registerValidator(personnummerLuhnValidator);
|
|
4856
|
-
ValidationService.registerValidator(personnummerNotSame);
|
|
4857
|
-
ValidationService.registerValidator(personnummerOlder);
|
|
4858
|
-
ValidationService.registerValidator(personnummerYounger);
|
|
4859
|
-
ValidationService.registerValidator(phoneNumberValidator);
|
|
4860
|
-
ValidationService.registerValidator(plusgiroValidator);
|
|
4861
|
-
ValidationService.registerValidator(postalCodeValidator);
|
|
4862
|
-
ValidationService.registerValidator(requiredValidator);
|
|
4863
|
-
ValidationService.registerValidator(whitelistValidator);
|
|
4864
|
-
|
|
4865
|
-
class ElementIdServiceImpl {
|
|
4866
|
-
elementIdMap = new Map();
|
|
4867
|
-
generateElementId(prefix = "fkui") {
|
|
4868
|
-
const id = this.nextId(prefix);
|
|
4869
|
-
if (document.getElementById(id) === null) {
|
|
4870
|
-
return id;
|
|
4871
|
-
}
|
|
4872
|
-
return this.generateElementId(prefix);
|
|
4873
|
-
}
|
|
4874
|
-
nextId(prefix) {
|
|
4875
|
-
let elementIdWithPadding = String(this.getIdFromMap(prefix));
|
|
4876
|
-
while (elementIdWithPadding.length < 4) {
|
|
4877
|
-
elementIdWithPadding = `0${elementIdWithPadding}`;
|
|
4878
|
-
}
|
|
4879
|
-
return `${prefix}-vue-element-${elementIdWithPadding}`;
|
|
4880
|
-
}
|
|
4881
|
-
getIdFromMap(prefix) {
|
|
4882
|
-
const elementId = this.elementIdMap.get(prefix);
|
|
4883
|
-
if (!elementId) {
|
|
4884
|
-
this.elementIdMap.set(prefix, { count: 1 });
|
|
4885
|
-
return 1;
|
|
4886
|
-
}
|
|
4887
|
-
elementId.count++;
|
|
4888
|
-
return elementId.count;
|
|
4889
|
-
}
|
|
4890
|
-
reset() {
|
|
4891
|
-
this.elementIdMap = new Map();
|
|
4892
|
-
}
|
|
4893
|
-
}
|
|
4894
|
-
/**
|
|
4895
|
-
* @public
|
|
4896
|
-
*/
|
|
4897
|
-
const ElementIdService = new ElementIdServiceImpl();
|
|
4898
|
-
|
|
4899
|
-
/* istanbul ignore next: manually tested */
|
|
4900
|
-
const haveSessionStorage = (() => {
|
|
4901
|
-
const test = "fkui.sessionstorage.test";
|
|
4902
|
-
try {
|
|
4903
|
-
if (window.sessionStorage) {
|
|
4904
|
-
window.sessionStorage.setItem(test, "test");
|
|
4905
|
-
window.sessionStorage.removeItem(test);
|
|
4906
|
-
return true;
|
|
4907
|
-
}
|
|
4908
|
-
else {
|
|
4909
|
-
return false;
|
|
4910
|
-
}
|
|
4911
|
-
}
|
|
4912
|
-
catch {
|
|
4913
|
-
/* Safari on iOS throws security exceptions when accessing
|
|
4914
|
-
* sessionstorage in private browsing. */
|
|
4915
|
-
return false;
|
|
4916
|
-
}
|
|
4917
|
-
})();
|
|
4918
|
-
/**
|
|
4919
|
-
* This feature can be used by creating a new file with something like:
|
|
4920
|
-
*
|
|
4921
|
-
* ```
|
|
4922
|
-
* export const MyCustomPersistenceService = new PersistenceService<MyCustomApplicationModel>();
|
|
4923
|
-
* ```
|
|
4924
|
-
*
|
|
4925
|
-
* There is also a simplified version in {@link SimplePersistenceService}.
|
|
4926
|
-
*
|
|
4927
|
-
* @public
|
|
4928
|
-
*/
|
|
4929
|
-
class PersistenceService {
|
|
4930
|
-
cache;
|
|
4931
|
-
constructor() {
|
|
4932
|
-
this.cache = new Map();
|
|
4933
|
-
}
|
|
4934
|
-
set(key, value) {
|
|
4935
|
-
if (this.isSessionPresent) {
|
|
4936
|
-
window.sessionStorage.setItem(key, JSON.stringify(value));
|
|
4937
|
-
}
|
|
4938
|
-
this.cache.set(key, value);
|
|
4939
|
-
}
|
|
4940
|
-
get(key) {
|
|
4941
|
-
const found = this.find(key);
|
|
4942
|
-
if (typeof found !== "undefined") {
|
|
4943
|
-
return found;
|
|
4944
|
-
}
|
|
4945
|
-
throw Error(`PersistenceService cannot find entry with key "${key}"`);
|
|
4946
|
-
}
|
|
4947
|
-
find(key) {
|
|
4948
|
-
if (this.cache.has(key)) {
|
|
4949
|
-
return this.cache.get(key);
|
|
4950
|
-
}
|
|
4951
|
-
const persisted = this.isSessionPresent
|
|
4952
|
-
? window.sessionStorage.getItem(key)
|
|
4953
|
-
: null;
|
|
4954
|
-
if (persisted) {
|
|
4955
|
-
const value = JSON.parse(persisted);
|
|
4956
|
-
this.cache.set(key, value);
|
|
4957
|
-
}
|
|
4958
|
-
return this.cache.get(key);
|
|
4959
|
-
}
|
|
4960
|
-
remove(key) {
|
|
4961
|
-
if (this.isSessionPresent) {
|
|
4962
|
-
window.sessionStorage.removeItem(key);
|
|
4963
|
-
}
|
|
4964
|
-
this.cache.delete(key);
|
|
4965
|
-
}
|
|
4966
|
-
/**
|
|
4967
|
-
* @internal
|
|
4968
|
-
*/
|
|
4969
|
-
/* istanbul ignore next: for mocking in unittests */
|
|
4970
|
-
get isSessionPresent() {
|
|
4971
|
-
return haveSessionStorage;
|
|
4972
|
-
}
|
|
4973
|
-
}
|
|
4974
|
-
|
|
4975
4977
|
/**
|
|
4976
|
-
*
|
|
4977
|
-
*
|
|
4978
|
-
* ```ts
|
|
4979
|
-
* export const MyAwesomePersistenceService = new SimplePersistenceService<MyAwesomeModel>("my-awesome-key");
|
|
4980
|
-
* ```
|
|
4981
|
-
*
|
|
4982
|
-
* There is also a more advanced version in {@link PersistenceService}.
|
|
4978
|
+
* List of all available builtin validators.
|
|
4983
4979
|
*
|
|
4984
4980
|
* @public
|
|
4985
4981
|
*/
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
4982
|
+
const availableValidators = [
|
|
4983
|
+
allowListValidator,
|
|
4984
|
+
bankAccountNumberValidator,
|
|
4985
|
+
bankgiroValidator,
|
|
4986
|
+
blacklistValidator,
|
|
4987
|
+
clearingNumberValidator,
|
|
4988
|
+
currencyValidator,
|
|
4989
|
+
dateFormatValidator,
|
|
4990
|
+
dateValidator,
|
|
4991
|
+
decimalValidator,
|
|
4992
|
+
emailValidator,
|
|
4993
|
+
greaterThanValidator,
|
|
4994
|
+
integerValidator,
|
|
4995
|
+
invalidDatesValidator,
|
|
4996
|
+
invalidWeekdaysValidator,
|
|
4997
|
+
lessThanValidator,
|
|
4998
|
+
matchesValidator,
|
|
4999
|
+
maxDateValidator,
|
|
5000
|
+
maxLengthValidator,
|
|
5001
|
+
maxValueValidator,
|
|
5002
|
+
minDateValidator,
|
|
5003
|
+
minLengthValidator,
|
|
5004
|
+
minValueValidator,
|
|
5005
|
+
numberValidator,
|
|
5006
|
+
organisationsnummerValidator,
|
|
5007
|
+
percentValidator,
|
|
5008
|
+
personnummerFormatValidator,
|
|
5009
|
+
personnummerLuhnValidator,
|
|
5010
|
+
personnummerNotSame,
|
|
5011
|
+
personnummerOlder,
|
|
5012
|
+
personnummerYounger,
|
|
5013
|
+
phoneNumberValidator,
|
|
5014
|
+
plusgiroValidator,
|
|
5015
|
+
postalCodeValidator,
|
|
5016
|
+
requiredValidator,
|
|
5017
|
+
whitelistValidator,
|
|
5018
|
+
];
|
|
5006
5019
|
|
|
5007
5020
|
/**
|
|
5008
5021
|
* Default delay in milliseconds for {@link waitForScreenReader}
|
|
@@ -5121,6 +5134,7 @@ exports.ValidationErrorMessageBuilder = ValidationErrorMessageBuilder;
|
|
|
5121
5134
|
exports.ValidationService = ValidationService;
|
|
5122
5135
|
exports.addFocusListener = addFocusListener;
|
|
5123
5136
|
exports.alertScreenReader = alertScreenReader;
|
|
5137
|
+
exports.availableValidators = availableValidators;
|
|
5124
5138
|
exports.configLogic = configLogic;
|
|
5125
5139
|
exports.debounce = debounce;
|
|
5126
5140
|
exports.deepClone = deepClone;
|
package/lib/esm/index.js
CHANGED
|
@@ -2323,7 +2323,7 @@ var Locale;
|
|
|
2323
2323
|
function getDefaultLocale() {
|
|
2324
2324
|
return Locale.SWEDISH;
|
|
2325
2325
|
}
|
|
2326
|
-
let _locale = getDefaultLocale();
|
|
2326
|
+
let _locale = /* @__PURE__ */ getDefaultLocale();
|
|
2327
2327
|
/**
|
|
2328
2328
|
* Get current locale.
|
|
2329
2329
|
*
|
|
@@ -3261,10 +3261,10 @@ function scrollToSlow(element, duration, offset = 0) {
|
|
|
3261
3261
|
});
|
|
3262
3262
|
}
|
|
3263
3263
|
|
|
3264
|
-
const sym = Symbol("focus-stack");
|
|
3264
|
+
const sym = /* @__PURE__ */ Symbol("focus-stack");
|
|
3265
3265
|
let _stackHandleCounter = 0;
|
|
3266
3266
|
const _focusElementStack = [];
|
|
3267
|
-
const TABBABLE_ELEMENT_SELECTOR = [
|
|
3267
|
+
const TABBABLE_ELEMENT_SELECTOR = /* @__PURE__ */ [
|
|
3268
3268
|
"a[href]",
|
|
3269
3269
|
"area[href]",
|
|
3270
3270
|
"input",
|
|
@@ -3572,6 +3572,150 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3572
3572
|
scrollTo: scrollTo
|
|
3573
3573
|
});
|
|
3574
3574
|
|
|
3575
|
+
class ElementIdServiceImpl {
|
|
3576
|
+
elementIdMap = new Map();
|
|
3577
|
+
generateElementId(prefix = "fkui") {
|
|
3578
|
+
const id = this.nextId(prefix);
|
|
3579
|
+
if (document.getElementById(id) === null) {
|
|
3580
|
+
return id;
|
|
3581
|
+
}
|
|
3582
|
+
return this.generateElementId(prefix);
|
|
3583
|
+
}
|
|
3584
|
+
nextId(prefix) {
|
|
3585
|
+
let elementIdWithPadding = String(this.getIdFromMap(prefix));
|
|
3586
|
+
while (elementIdWithPadding.length < 4) {
|
|
3587
|
+
elementIdWithPadding = `0${elementIdWithPadding}`;
|
|
3588
|
+
}
|
|
3589
|
+
return `${prefix}-vue-element-${elementIdWithPadding}`;
|
|
3590
|
+
}
|
|
3591
|
+
getIdFromMap(prefix) {
|
|
3592
|
+
const elementId = this.elementIdMap.get(prefix);
|
|
3593
|
+
if (!elementId) {
|
|
3594
|
+
this.elementIdMap.set(prefix, { count: 1 });
|
|
3595
|
+
return 1;
|
|
3596
|
+
}
|
|
3597
|
+
elementId.count++;
|
|
3598
|
+
return elementId.count;
|
|
3599
|
+
}
|
|
3600
|
+
reset() {
|
|
3601
|
+
this.elementIdMap = new Map();
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
/**
|
|
3605
|
+
* @public
|
|
3606
|
+
*/
|
|
3607
|
+
const ElementIdService =
|
|
3608
|
+
/* @__PURE__ */
|
|
3609
|
+
new ElementIdServiceImpl();
|
|
3610
|
+
|
|
3611
|
+
/* istanbul ignore next: manually tested */
|
|
3612
|
+
const haveSessionStorage = /* @__PURE__ */ (() => {
|
|
3613
|
+
const test = "fkui.sessionstorage.test";
|
|
3614
|
+
try {
|
|
3615
|
+
if (window.sessionStorage) {
|
|
3616
|
+
window.sessionStorage.setItem(test, "test");
|
|
3617
|
+
window.sessionStorage.removeItem(test);
|
|
3618
|
+
return true;
|
|
3619
|
+
}
|
|
3620
|
+
else {
|
|
3621
|
+
return false;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
catch {
|
|
3625
|
+
/* Safari on iOS throws security exceptions when accessing
|
|
3626
|
+
* sessionstorage in private browsing. */
|
|
3627
|
+
return false;
|
|
3628
|
+
}
|
|
3629
|
+
})();
|
|
3630
|
+
/**
|
|
3631
|
+
* This feature can be used by creating a new file with something like:
|
|
3632
|
+
*
|
|
3633
|
+
* ```
|
|
3634
|
+
* export const MyCustomPersistenceService = new PersistenceService<MyCustomApplicationModel>();
|
|
3635
|
+
* ```
|
|
3636
|
+
*
|
|
3637
|
+
* There is also a simplified version in {@link SimplePersistenceService}.
|
|
3638
|
+
*
|
|
3639
|
+
* @public
|
|
3640
|
+
*/
|
|
3641
|
+
class PersistenceService {
|
|
3642
|
+
cache;
|
|
3643
|
+
constructor() {
|
|
3644
|
+
this.cache = new Map();
|
|
3645
|
+
}
|
|
3646
|
+
set(key, value) {
|
|
3647
|
+
if (this.isSessionPresent) {
|
|
3648
|
+
window.sessionStorage.setItem(key, JSON.stringify(value));
|
|
3649
|
+
}
|
|
3650
|
+
this.cache.set(key, value);
|
|
3651
|
+
}
|
|
3652
|
+
get(key) {
|
|
3653
|
+
const found = this.find(key);
|
|
3654
|
+
if (typeof found !== "undefined") {
|
|
3655
|
+
return found;
|
|
3656
|
+
}
|
|
3657
|
+
throw Error(`PersistenceService cannot find entry with key "${key}"`);
|
|
3658
|
+
}
|
|
3659
|
+
find(key) {
|
|
3660
|
+
if (this.cache.has(key)) {
|
|
3661
|
+
return this.cache.get(key);
|
|
3662
|
+
}
|
|
3663
|
+
const persisted = this.isSessionPresent
|
|
3664
|
+
? window.sessionStorage.getItem(key)
|
|
3665
|
+
: null;
|
|
3666
|
+
if (persisted) {
|
|
3667
|
+
const value = JSON.parse(persisted);
|
|
3668
|
+
this.cache.set(key, value);
|
|
3669
|
+
}
|
|
3670
|
+
return this.cache.get(key);
|
|
3671
|
+
}
|
|
3672
|
+
remove(key) {
|
|
3673
|
+
if (this.isSessionPresent) {
|
|
3674
|
+
window.sessionStorage.removeItem(key);
|
|
3675
|
+
}
|
|
3676
|
+
this.cache.delete(key);
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* @internal
|
|
3680
|
+
*/
|
|
3681
|
+
/* istanbul ignore next: for mocking in unittests */
|
|
3682
|
+
get isSessionPresent() {
|
|
3683
|
+
return haveSessionStorage;
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
/**
|
|
3688
|
+
* This feature can be used by creating a new file with something like:
|
|
3689
|
+
*
|
|
3690
|
+
* ```ts
|
|
3691
|
+
* export const MyAwesomePersistenceService = new SimplePersistenceService<MyAwesomeModel>("my-awesome-key");
|
|
3692
|
+
* ```
|
|
3693
|
+
*
|
|
3694
|
+
* There is also a more advanced version in {@link PersistenceService}.
|
|
3695
|
+
*
|
|
3696
|
+
* @public
|
|
3697
|
+
*/
|
|
3698
|
+
class SimplePersistenceService {
|
|
3699
|
+
persistenceService;
|
|
3700
|
+
key;
|
|
3701
|
+
constructor(key) {
|
|
3702
|
+
this.key = key;
|
|
3703
|
+
this.persistenceService = new PersistenceService();
|
|
3704
|
+
}
|
|
3705
|
+
set(value) {
|
|
3706
|
+
this.persistenceService.set(this.key, value);
|
|
3707
|
+
}
|
|
3708
|
+
get() {
|
|
3709
|
+
return this.persistenceService.get(this.key);
|
|
3710
|
+
}
|
|
3711
|
+
find() {
|
|
3712
|
+
return this.persistenceService.find(this.key);
|
|
3713
|
+
}
|
|
3714
|
+
remove() {
|
|
3715
|
+
this.persistenceService.remove(this.key);
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3575
3719
|
class DefaultTranslationProvider {
|
|
3576
3720
|
language = "sv";
|
|
3577
3721
|
get currentLanguage() {
|
|
@@ -3608,7 +3752,9 @@ class TranslationServiceImpl {
|
|
|
3608
3752
|
/**
|
|
3609
3753
|
* @public
|
|
3610
3754
|
*/
|
|
3611
|
-
const TranslationService =
|
|
3755
|
+
const TranslationService =
|
|
3756
|
+
/* @__PURE__ */
|
|
3757
|
+
new TranslationServiceImpl();
|
|
3612
3758
|
|
|
3613
3759
|
/**
|
|
3614
3760
|
* Builder to create validation error message map.
|
|
@@ -4383,7 +4529,9 @@ class ValidationServiceImpl {
|
|
|
4383
4529
|
/**
|
|
4384
4530
|
* @public
|
|
4385
4531
|
*/
|
|
4386
|
-
const ValidationService =
|
|
4532
|
+
const ValidationService =
|
|
4533
|
+
/* @__PURE__ */
|
|
4534
|
+
new ValidationServiceImpl();
|
|
4387
4535
|
|
|
4388
4536
|
/**
|
|
4389
4537
|
* @public
|
|
@@ -4824,183 +4972,48 @@ const whitelistValidator = {
|
|
|
4824
4972
|
},
|
|
4825
4973
|
};
|
|
4826
4974
|
|
|
4827
|
-
ValidationService.registerValidator(allowListValidator);
|
|
4828
|
-
ValidationService.registerValidator(bankAccountNumberValidator);
|
|
4829
|
-
ValidationService.registerValidator(bankgiroValidator);
|
|
4830
|
-
ValidationService.registerValidator(blacklistValidator);
|
|
4831
|
-
ValidationService.registerValidator(clearingNumberValidator);
|
|
4832
|
-
ValidationService.registerValidator(currencyValidator);
|
|
4833
|
-
ValidationService.registerValidator(dateFormatValidator);
|
|
4834
|
-
ValidationService.registerValidator(dateValidator);
|
|
4835
|
-
ValidationService.registerValidator(decimalValidator);
|
|
4836
|
-
ValidationService.registerValidator(emailValidator);
|
|
4837
|
-
ValidationService.registerValidator(greaterThanValidator);
|
|
4838
|
-
ValidationService.registerValidator(integerValidator);
|
|
4839
|
-
ValidationService.registerValidator(invalidDatesValidator);
|
|
4840
|
-
ValidationService.registerValidator(invalidWeekdaysValidator);
|
|
4841
|
-
ValidationService.registerValidator(lessThanValidator);
|
|
4842
|
-
ValidationService.registerValidator(matchesValidator);
|
|
4843
|
-
ValidationService.registerValidator(maxDateValidator);
|
|
4844
|
-
ValidationService.registerValidator(maxLengthValidator);
|
|
4845
|
-
ValidationService.registerValidator(maxValueValidator);
|
|
4846
|
-
ValidationService.registerValidator(minDateValidator);
|
|
4847
|
-
ValidationService.registerValidator(minLengthValidator);
|
|
4848
|
-
ValidationService.registerValidator(minValueValidator);
|
|
4849
|
-
ValidationService.registerValidator(numberValidator);
|
|
4850
|
-
ValidationService.registerValidator(organisationsnummerValidator);
|
|
4851
|
-
ValidationService.registerValidator(percentValidator);
|
|
4852
|
-
ValidationService.registerValidator(personnummerFormatValidator);
|
|
4853
|
-
ValidationService.registerValidator(personnummerLuhnValidator);
|
|
4854
|
-
ValidationService.registerValidator(personnummerNotSame);
|
|
4855
|
-
ValidationService.registerValidator(personnummerOlder);
|
|
4856
|
-
ValidationService.registerValidator(personnummerYounger);
|
|
4857
|
-
ValidationService.registerValidator(phoneNumberValidator);
|
|
4858
|
-
ValidationService.registerValidator(plusgiroValidator);
|
|
4859
|
-
ValidationService.registerValidator(postalCodeValidator);
|
|
4860
|
-
ValidationService.registerValidator(requiredValidator);
|
|
4861
|
-
ValidationService.registerValidator(whitelistValidator);
|
|
4862
|
-
|
|
4863
|
-
class ElementIdServiceImpl {
|
|
4864
|
-
elementIdMap = new Map();
|
|
4865
|
-
generateElementId(prefix = "fkui") {
|
|
4866
|
-
const id = this.nextId(prefix);
|
|
4867
|
-
if (document.getElementById(id) === null) {
|
|
4868
|
-
return id;
|
|
4869
|
-
}
|
|
4870
|
-
return this.generateElementId(prefix);
|
|
4871
|
-
}
|
|
4872
|
-
nextId(prefix) {
|
|
4873
|
-
let elementIdWithPadding = String(this.getIdFromMap(prefix));
|
|
4874
|
-
while (elementIdWithPadding.length < 4) {
|
|
4875
|
-
elementIdWithPadding = `0${elementIdWithPadding}`;
|
|
4876
|
-
}
|
|
4877
|
-
return `${prefix}-vue-element-${elementIdWithPadding}`;
|
|
4878
|
-
}
|
|
4879
|
-
getIdFromMap(prefix) {
|
|
4880
|
-
const elementId = this.elementIdMap.get(prefix);
|
|
4881
|
-
if (!elementId) {
|
|
4882
|
-
this.elementIdMap.set(prefix, { count: 1 });
|
|
4883
|
-
return 1;
|
|
4884
|
-
}
|
|
4885
|
-
elementId.count++;
|
|
4886
|
-
return elementId.count;
|
|
4887
|
-
}
|
|
4888
|
-
reset() {
|
|
4889
|
-
this.elementIdMap = new Map();
|
|
4890
|
-
}
|
|
4891
|
-
}
|
|
4892
|
-
/**
|
|
4893
|
-
* @public
|
|
4894
|
-
*/
|
|
4895
|
-
const ElementIdService = new ElementIdServiceImpl();
|
|
4896
|
-
|
|
4897
|
-
/* istanbul ignore next: manually tested */
|
|
4898
|
-
const haveSessionStorage = (() => {
|
|
4899
|
-
const test = "fkui.sessionstorage.test";
|
|
4900
|
-
try {
|
|
4901
|
-
if (window.sessionStorage) {
|
|
4902
|
-
window.sessionStorage.setItem(test, "test");
|
|
4903
|
-
window.sessionStorage.removeItem(test);
|
|
4904
|
-
return true;
|
|
4905
|
-
}
|
|
4906
|
-
else {
|
|
4907
|
-
return false;
|
|
4908
|
-
}
|
|
4909
|
-
}
|
|
4910
|
-
catch {
|
|
4911
|
-
/* Safari on iOS throws security exceptions when accessing
|
|
4912
|
-
* sessionstorage in private browsing. */
|
|
4913
|
-
return false;
|
|
4914
|
-
}
|
|
4915
|
-
})();
|
|
4916
|
-
/**
|
|
4917
|
-
* This feature can be used by creating a new file with something like:
|
|
4918
|
-
*
|
|
4919
|
-
* ```
|
|
4920
|
-
* export const MyCustomPersistenceService = new PersistenceService<MyCustomApplicationModel>();
|
|
4921
|
-
* ```
|
|
4922
|
-
*
|
|
4923
|
-
* There is also a simplified version in {@link SimplePersistenceService}.
|
|
4924
|
-
*
|
|
4925
|
-
* @public
|
|
4926
|
-
*/
|
|
4927
|
-
class PersistenceService {
|
|
4928
|
-
cache;
|
|
4929
|
-
constructor() {
|
|
4930
|
-
this.cache = new Map();
|
|
4931
|
-
}
|
|
4932
|
-
set(key, value) {
|
|
4933
|
-
if (this.isSessionPresent) {
|
|
4934
|
-
window.sessionStorage.setItem(key, JSON.stringify(value));
|
|
4935
|
-
}
|
|
4936
|
-
this.cache.set(key, value);
|
|
4937
|
-
}
|
|
4938
|
-
get(key) {
|
|
4939
|
-
const found = this.find(key);
|
|
4940
|
-
if (typeof found !== "undefined") {
|
|
4941
|
-
return found;
|
|
4942
|
-
}
|
|
4943
|
-
throw Error(`PersistenceService cannot find entry with key "${key}"`);
|
|
4944
|
-
}
|
|
4945
|
-
find(key) {
|
|
4946
|
-
if (this.cache.has(key)) {
|
|
4947
|
-
return this.cache.get(key);
|
|
4948
|
-
}
|
|
4949
|
-
const persisted = this.isSessionPresent
|
|
4950
|
-
? window.sessionStorage.getItem(key)
|
|
4951
|
-
: null;
|
|
4952
|
-
if (persisted) {
|
|
4953
|
-
const value = JSON.parse(persisted);
|
|
4954
|
-
this.cache.set(key, value);
|
|
4955
|
-
}
|
|
4956
|
-
return this.cache.get(key);
|
|
4957
|
-
}
|
|
4958
|
-
remove(key) {
|
|
4959
|
-
if (this.isSessionPresent) {
|
|
4960
|
-
window.sessionStorage.removeItem(key);
|
|
4961
|
-
}
|
|
4962
|
-
this.cache.delete(key);
|
|
4963
|
-
}
|
|
4964
|
-
/**
|
|
4965
|
-
* @internal
|
|
4966
|
-
*/
|
|
4967
|
-
/* istanbul ignore next: for mocking in unittests */
|
|
4968
|
-
get isSessionPresent() {
|
|
4969
|
-
return haveSessionStorage;
|
|
4970
|
-
}
|
|
4971
|
-
}
|
|
4972
|
-
|
|
4973
4975
|
/**
|
|
4974
|
-
*
|
|
4975
|
-
*
|
|
4976
|
-
* ```ts
|
|
4977
|
-
* export const MyAwesomePersistenceService = new SimplePersistenceService<MyAwesomeModel>("my-awesome-key");
|
|
4978
|
-
* ```
|
|
4979
|
-
*
|
|
4980
|
-
* There is also a more advanced version in {@link PersistenceService}.
|
|
4976
|
+
* List of all available builtin validators.
|
|
4981
4977
|
*
|
|
4982
4978
|
* @public
|
|
4983
4979
|
*/
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
4980
|
+
const availableValidators = [
|
|
4981
|
+
allowListValidator,
|
|
4982
|
+
bankAccountNumberValidator,
|
|
4983
|
+
bankgiroValidator,
|
|
4984
|
+
blacklistValidator,
|
|
4985
|
+
clearingNumberValidator,
|
|
4986
|
+
currencyValidator,
|
|
4987
|
+
dateFormatValidator,
|
|
4988
|
+
dateValidator,
|
|
4989
|
+
decimalValidator,
|
|
4990
|
+
emailValidator,
|
|
4991
|
+
greaterThanValidator,
|
|
4992
|
+
integerValidator,
|
|
4993
|
+
invalidDatesValidator,
|
|
4994
|
+
invalidWeekdaysValidator,
|
|
4995
|
+
lessThanValidator,
|
|
4996
|
+
matchesValidator,
|
|
4997
|
+
maxDateValidator,
|
|
4998
|
+
maxLengthValidator,
|
|
4999
|
+
maxValueValidator,
|
|
5000
|
+
minDateValidator,
|
|
5001
|
+
minLengthValidator,
|
|
5002
|
+
minValueValidator,
|
|
5003
|
+
numberValidator,
|
|
5004
|
+
organisationsnummerValidator,
|
|
5005
|
+
percentValidator,
|
|
5006
|
+
personnummerFormatValidator,
|
|
5007
|
+
personnummerLuhnValidator,
|
|
5008
|
+
personnummerNotSame,
|
|
5009
|
+
personnummerOlder,
|
|
5010
|
+
personnummerYounger,
|
|
5011
|
+
phoneNumberValidator,
|
|
5012
|
+
plusgiroValidator,
|
|
5013
|
+
postalCodeValidator,
|
|
5014
|
+
requiredValidator,
|
|
5015
|
+
whitelistValidator,
|
|
5016
|
+
];
|
|
5004
5017
|
|
|
5005
5018
|
/**
|
|
5006
5019
|
* Default delay in milliseconds for {@link waitForScreenReader}
|
|
@@ -5107,5 +5120,5 @@ if (typeof document !== "undefined") {
|
|
|
5107
5120
|
createScreenReaderWrapper({ assertive: false });
|
|
5108
5121
|
}
|
|
5109
5122
|
|
|
5110
|
-
export { DecoratedError, index as DomUtils, ElementIdService, MissingValueError, PersistenceService, SCREEN_READER_DELAY, SimplePersistenceService, TranslationService, ValidationErrorMessageBuilder, ValidationService, addFocusListener, alertScreenReader, configLogic, debounce, deepClone, deleteCookie, documentOrderComparator, ensureSet, findCookie, findTabbableElements, flatten, focus, focusFirst, focusLast, formatClearingNumberForBackend, formatNumber, formatPercent, formatPersonnummer, formatPersonnummerToDate, formatPostalCode, getErrorMessages, handleTab, isEmpty, isFocusable, isInvalidDatesConfig, isInvalidWeekdaysConfig, isRadiobuttonOrCheckbox, isSet, isString, isTabbable, isValidatableFormElement, isValidatableHTMLElement, isVisible, isVisibleInViewport, normalizeDateFormat, parseBankAccountNumber, parseBankgiro, parseClearingNumber, parseDate, parseNumber, parseOrganisationsnummer, parsePercent, parsePersonnummer, parsePersonnummerLuhn, parsePlusgiro, parsePostalCode, popFocus, pushFocus, removeFocusListener, restoreFocus, saveFocus, scrollTo, setCookie, stripNull, stripWhitespace, testLuhnChecksum, validChecksum, validLimit, waitForScreenReader };
|
|
5123
|
+
export { DecoratedError, index as DomUtils, ElementIdService, MissingValueError, PersistenceService, SCREEN_READER_DELAY, SimplePersistenceService, TranslationService, ValidationErrorMessageBuilder, ValidationService, addFocusListener, alertScreenReader, availableValidators, configLogic, debounce, deepClone, deleteCookie, documentOrderComparator, ensureSet, findCookie, findTabbableElements, flatten, focus, focusFirst, focusLast, formatClearingNumberForBackend, formatNumber, formatPercent, formatPersonnummer, formatPersonnummerToDate, formatPostalCode, getErrorMessages, handleTab, isEmpty, isFocusable, isInvalidDatesConfig, isInvalidWeekdaysConfig, isRadiobuttonOrCheckbox, isSet, isString, isTabbable, isValidatableFormElement, isValidatableHTMLElement, isVisible, isVisibleInViewport, normalizeDateFormat, parseBankAccountNumber, parseBankgiro, parseClearingNumber, parseDate, parseNumber, parseOrganisationsnummer, parsePercent, parsePersonnummer, parsePersonnummerLuhn, parsePlusgiro, parsePostalCode, popFocus, pushFocus, removeFocusListener, restoreFocus, saveFocus, scrollTo, setCookie, stripNull, stripWhitespace, testLuhnChecksum, validChecksum, validLimit, waitForScreenReader };
|
|
5111
5124
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -35,6 +35,13 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
35
35
|
list: string[];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* List of all available builtin validators.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare const availableValidators: Validator[];
|
|
44
|
+
|
|
38
45
|
/**
|
|
39
46
|
* A string with 3-16 digits, for example "0123456789"
|
|
40
47
|
*
|
package/lib/types/polyfills.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkui/logic",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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.4.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">= 20",
|
|
68
68
|
"npm": ">= 7"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "a5c516be9b76d94394962a524abaf3e6efe0a7be"
|
|
71
71
|
}
|