@player-ui/common-types-plugin 0.4.0 → 0.4.1-next.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/dist/common-types-plugin.dev.js +11097 -660
- package/dist/common-types-plugin.prod.js +2 -1
- package/dist/index.cjs.js +18 -3
- package/dist/index.d.ts +14 -2
- package/dist/index.esm.js +18 -3
- package/dist/xlr/BooleanType.json +72 -0
- package/dist/xlr/CollectionType.json +39 -0
- package/dist/xlr/DateType.json +55 -0
- package/dist/xlr/IntegerNNType.json +75 -0
- package/dist/xlr/IntegerPosType.json +75 -0
- package/dist/xlr/IntegerType.json +55 -0
- package/dist/xlr/PhoneType.json +55 -0
- package/dist/xlr/StringType.json +62 -0
- package/dist/xlr/manifest.js +21 -0
- package/dist/xlr/manifest.json +26 -0
- package/package.json +11 -3
- package/src/formats/utils.ts +25 -1
- package/src/index.ts +29 -2
- package/src/validators/index.ts +4 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TypesProviderPlugin } from '@player-ui/types-provider-plugin';
|
|
2
|
+
import { resolveDataRefs } from '@player-ui/player';
|
|
2
3
|
|
|
3
4
|
const EMAIL_REGEX = /^((([a-z]|\d|[!#$%&'*+\-/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#$%&'*+-/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
|
4
5
|
const PHONE_REGEX = /^\+?[1]?[- ]?\(?\d{3}[)\- ]?\s?\d{3}[ -]?\d{4}$/;
|
|
@@ -76,8 +77,9 @@ const regex = skipNullish((context, value, options) => {
|
|
|
76
77
|
if (value === void 0 || value === null || value === "" || typeof (options == null ? void 0 : options.regex) !== "string") {
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
|
-
const
|
|
80
|
-
const
|
|
80
|
+
const resolvedRegex = resolveDataRefs(options.regex, context);
|
|
81
|
+
const patternMatch = resolvedRegex.match(/^\/(.*)\/(\w)*$/);
|
|
82
|
+
const regexp = patternMatch ? new RegExp(patternMatch[1], patternMatch[2]) : new RegExp(resolvedRegex);
|
|
81
83
|
if (!regexp.test(value)) {
|
|
82
84
|
const message = context.constants.getConstants("validation.regex", "constants", "Invalid entry");
|
|
83
85
|
return { message };
|
|
@@ -338,9 +340,22 @@ var dataTypes = /*#__PURE__*/Object.freeze({
|
|
|
338
340
|
|
|
339
341
|
const PLACEHOLDER = "#";
|
|
340
342
|
const removeFormatCharactersFromMaskedString = (value, mask, reserved = [PLACEHOLDER]) => {
|
|
343
|
+
const reservedMatchesLength = mask.split("").filter((val) => reserved.includes(val)).length;
|
|
344
|
+
let replacements = 0;
|
|
341
345
|
return value.split("").reduce((newString, nextChar, nextIndex) => {
|
|
342
346
|
const maskedVal = mask[nextIndex];
|
|
347
|
+
if (maskedVal === void 0) {
|
|
348
|
+
return newString;
|
|
349
|
+
}
|
|
350
|
+
if (reservedMatchesLength === replacements) {
|
|
351
|
+
return newString;
|
|
352
|
+
}
|
|
343
353
|
if (reserved.includes(maskedVal)) {
|
|
354
|
+
replacements++;
|
|
355
|
+
return newString + nextChar;
|
|
356
|
+
}
|
|
357
|
+
if (maskedVal !== nextChar) {
|
|
358
|
+
replacements++;
|
|
344
359
|
return newString + nextChar;
|
|
345
360
|
}
|
|
346
361
|
return newString;
|
|
@@ -419,7 +434,7 @@ const createMaskedNumericFormatter = (name, mask) => {
|
|
|
419
434
|
return usingExceptions;
|
|
420
435
|
}
|
|
421
436
|
}
|
|
422
|
-
return
|
|
437
|
+
return formatAsMasked(value, /\d/g, mask.replace(/[^#]/g, ""));
|
|
423
438
|
}
|
|
424
439
|
};
|
|
425
440
|
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "BooleanType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "BooleanType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"default": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"const": false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"validation": {
|
|
21
|
+
"required": true,
|
|
22
|
+
"node": {
|
|
23
|
+
"type": "array",
|
|
24
|
+
"elementType": {
|
|
25
|
+
"type": "any"
|
|
26
|
+
},
|
|
27
|
+
"const": [
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"type": {
|
|
32
|
+
"required": true,
|
|
33
|
+
"node": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"const": "oneOf"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"message": {
|
|
39
|
+
"required": true,
|
|
40
|
+
"node": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"const": "Value must be true or false"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"options": {
|
|
46
|
+
"required": true,
|
|
47
|
+
"node": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"elementType": {
|
|
50
|
+
"type": "any"
|
|
51
|
+
},
|
|
52
|
+
"const": [
|
|
53
|
+
{
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"const": true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"const": false
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"additionalProperties": false
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"additionalProperties": false
|
|
72
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "CollectionType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "CollectionType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "collection"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"additionalProperties": false
|
|
39
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "DateType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "DateType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "string"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"format": {
|
|
38
|
+
"required": true,
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"type": {
|
|
43
|
+
"required": true,
|
|
44
|
+
"node": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"const": "date"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"additionalProperties": false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "IntegerNNType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "IntegerNNType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "integer"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"type": {
|
|
38
|
+
"required": true,
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"const": "min"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"value": {
|
|
45
|
+
"required": true,
|
|
46
|
+
"node": {
|
|
47
|
+
"type": "number",
|
|
48
|
+
"const": 0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"format": {
|
|
58
|
+
"required": true,
|
|
59
|
+
"node": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"type": {
|
|
63
|
+
"required": true,
|
|
64
|
+
"node": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"const": "integer"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"additionalProperties": false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"additionalProperties": false
|
|
75
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "IntegerPosType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "IntegerPosType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "integer"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"type": {
|
|
38
|
+
"required": true,
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"const": "min"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"value": {
|
|
45
|
+
"required": true,
|
|
46
|
+
"node": {
|
|
47
|
+
"type": "number",
|
|
48
|
+
"const": 1
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"additionalProperties": false
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"format": {
|
|
58
|
+
"required": true,
|
|
59
|
+
"node": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"type": {
|
|
63
|
+
"required": true,
|
|
64
|
+
"node": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"const": "integer"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"additionalProperties": false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"additionalProperties": false
|
|
75
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "IntegerType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "IntegerType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "integer"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"format": {
|
|
38
|
+
"required": true,
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"type": {
|
|
43
|
+
"required": true,
|
|
44
|
+
"node": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"const": "integer"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"additionalProperties": false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "PhoneType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "PhoneType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"validation": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"elementType": {
|
|
18
|
+
"type": "any"
|
|
19
|
+
},
|
|
20
|
+
"const": [
|
|
21
|
+
{
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"type": {
|
|
25
|
+
"required": true,
|
|
26
|
+
"node": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"const": "phone"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"format": {
|
|
38
|
+
"required": true,
|
|
39
|
+
"node": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"type": {
|
|
43
|
+
"required": true,
|
|
44
|
+
"node": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"const": "phone"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"additionalProperties": false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "/home/circleci/.cache/bazel/_bazel_circleci/e8362d362e14c7d23506d1dfa3aea8b8/sandbox/processwrapper-sandbox/2669/execroot/player/plugins/common-types/core/src/data-types/types.ts",
|
|
3
|
+
"name": "StringType",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"type": {
|
|
7
|
+
"required": true,
|
|
8
|
+
"node": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"const": "StringType"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"default": {
|
|
14
|
+
"required": true,
|
|
15
|
+
"node": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"const": ""
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"validation": {
|
|
21
|
+
"required": true,
|
|
22
|
+
"node": {
|
|
23
|
+
"type": "array",
|
|
24
|
+
"elementType": {
|
|
25
|
+
"type": "any"
|
|
26
|
+
},
|
|
27
|
+
"const": [
|
|
28
|
+
{
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"type": {
|
|
32
|
+
"required": true,
|
|
33
|
+
"node": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"const": "string"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"additionalProperties": false
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"format": {
|
|
45
|
+
"required": true,
|
|
46
|
+
"node": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"type": {
|
|
50
|
+
"required": true,
|
|
51
|
+
"node": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"const": "string"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"additionalProperties": false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"additionalProperties": false
|
|
62
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const BooleanType = require('./BooleanType.json')
|
|
2
|
+
const IntegerType = require('./IntegerType.json')
|
|
3
|
+
const IntegerPosType = require('./IntegerPosType.json')
|
|
4
|
+
const IntegerNNType = require('./IntegerNNType.json')
|
|
5
|
+
const StringType = require('./StringType.json')
|
|
6
|
+
const CollectionType = require('./CollectionType.json')
|
|
7
|
+
const DateType = require('./DateType.json')
|
|
8
|
+
const PhoneType = require('./PhoneType.json')
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
"pluginName": "CommonTypes",
|
|
12
|
+
"capabilities": {
|
|
13
|
+
"Assets":[],
|
|
14
|
+
"Views":[],
|
|
15
|
+
"Expressions":[],
|
|
16
|
+
"DataTypes":[BooleanType,IntegerType,IntegerPosType,IntegerNNType,StringType,CollectionType,DateType,PhoneType],
|
|
17
|
+
},
|
|
18
|
+
"customPrimitives": [
|
|
19
|
+
'Expression','Asset','Binding','AssetWrapper','Schema.DataType','ExpressionHandler'
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginName": "CommonTypes",
|
|
3
|
+
"capabilities": {
|
|
4
|
+
"Assets": [],
|
|
5
|
+
"Views": [],
|
|
6
|
+
"Expressions": [],
|
|
7
|
+
"DataTypes": [
|
|
8
|
+
"BooleanType",
|
|
9
|
+
"IntegerType",
|
|
10
|
+
"IntegerPosType",
|
|
11
|
+
"IntegerNNType",
|
|
12
|
+
"StringType",
|
|
13
|
+
"CollectionType",
|
|
14
|
+
"DateType",
|
|
15
|
+
"PhoneType"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"customPrimitives": [
|
|
19
|
+
"Expression",
|
|
20
|
+
"Asset",
|
|
21
|
+
"Binding",
|
|
22
|
+
"AssetWrapper",
|
|
23
|
+
"Schema.DataType",
|
|
24
|
+
"ExpressionHandler"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-ui/common-types-plugin",
|
|
3
|
-
"version": "0.4.0",
|
|
3
|
+
"version": "0.4.1-next.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@player-ui/player": "0.4.0"
|
|
9
|
+
"@player-ui/player": "0.4.1-next.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-ui/types-provider-plugin": "0.4.0",
|
|
12
|
+
"@player-ui/types-provider-plugin": "0.4.1-next.0",
|
|
13
13
|
"@babel/runtime": "7.15.4"
|
|
14
14
|
},
|
|
15
15
|
"main": "dist/index.cjs.js",
|
|
@@ -53,6 +53,14 @@
|
|
|
53
53
|
{
|
|
54
54
|
"name": "Kelly Harrop",
|
|
55
55
|
"url": "https://github.com/kharrop"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "Alejandro Fimbres",
|
|
59
|
+
"url": "https://github.com/lexfm"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "Rafael Campos",
|
|
63
|
+
"url": "https://github.com/rafbcampos"
|
|
56
64
|
}
|
|
57
65
|
],
|
|
58
66
|
"bundle": "./dist/common-types-plugin.prod.js"
|
package/src/formats/utils.ts
CHANGED
|
@@ -17,10 +17,34 @@ export const removeFormatCharactersFromMaskedString = (
|
|
|
17
17
|
mask: string,
|
|
18
18
|
reserved: string[] = [PLACEHOLDER]
|
|
19
19
|
): string => {
|
|
20
|
+
const reservedMatchesLength = mask
|
|
21
|
+
.split('')
|
|
22
|
+
.filter((val) => reserved.includes(val)).length;
|
|
23
|
+
let replacements = 0;
|
|
24
|
+
|
|
20
25
|
return value.split('').reduce((newString, nextChar, nextIndex) => {
|
|
21
26
|
const maskedVal = mask[nextIndex];
|
|
22
27
|
|
|
28
|
+
if (maskedVal === undefined) {
|
|
29
|
+
return newString;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (reservedMatchesLength === replacements) {
|
|
33
|
+
return newString;
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
if (reserved.includes(maskedVal)) {
|
|
37
|
+
replacements++;
|
|
38
|
+
return newString + nextChar;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Characters will match when the incoming value is formatted, but in cases
|
|
43
|
+
* where it's being pulled from the model and deformatted again, ensure we
|
|
44
|
+
* don't skip over characters.
|
|
45
|
+
*/
|
|
46
|
+
if (maskedVal !== nextChar) {
|
|
47
|
+
replacements++;
|
|
24
48
|
return newString + nextChar;
|
|
25
49
|
}
|
|
26
50
|
|
|
@@ -186,7 +210,7 @@ export const createMaskedNumericFormatter = (
|
|
|
186
210
|
}
|
|
187
211
|
}
|
|
188
212
|
|
|
189
|
-
return
|
|
213
|
+
return formatAsMasked(value, /\d/g, mask.replace(/[^#]/g, ''));
|
|
190
214
|
},
|
|
191
215
|
};
|
|
192
216
|
};
|