@player-ui/common-types-plugin 0.3.1-next.1 → 0.3.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.
@@ -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.3.1-next.1",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/player": "0.3.1-next.1"
9
+ "@player-ui/player": "0.3.1"
10
10
  },
11
11
  "dependencies": {
12
- "@player-ui/types-provider-plugin": "0.3.1-next.1",
12
+ "@player-ui/types-provider-plugin": "0.3.1",
13
13
  "@babel/runtime": "7.15.4"
14
14
  },
15
15
  "main": "dist/index.cjs.js",
@@ -53,6 +53,15 @@
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
+ ],
66
+ "bundle": "./dist/common-types-plugin.prod.js"
58
67
  }
@@ -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 removeFormatCharactersFromMaskedString(value, mask);
213
+ return formatAsMasked(value, /\d/g, mask.replace(/[^#]/g, ''));
190
214
  },
191
215
  };
192
216
  };
package/src/index.ts CHANGED
@@ -1,10 +1,20 @@
1
- import type { Player, PlayerPlugin } from '@player-ui/player';
1
+ import type { Player, ExtendedPlayerPlugin } from '@player-ui/player';
2
2
  import { TypesProviderPlugin } from '@player-ui/types-provider-plugin';
3
3
 
4
4
  import * as validators from './validators';
5
5
  import * as dataTypes from './data-types/types';
6
6
  import * as dataRefs from './data-types/refs';
7
7
  import * as formats from './formats';
8
+ import type {
9
+ BooleanType,
10
+ IntegerType,
11
+ IntegerPosType,
12
+ IntegerNNType,
13
+ StringType,
14
+ CollectionType,
15
+ DateType,
16
+ PhoneType,
17
+ } from './data-types/types';
8
18
 
9
19
  export { validators, dataTypes, dataRefs, formats };
10
20
  export * from './formats/utils';
@@ -12,7 +22,24 @@ export * from './formats/utils';
12
22
  /**
13
23
  * Exposes a lot of common DataTypes, validations, and formats to Player instance.
14
24
  */
15
- export class CommonTypesPlugin implements PlayerPlugin {
25
+ export class CommonTypesPlugin
26
+ implements
27
+ ExtendedPlayerPlugin<
28
+ [],
29
+ [],
30
+ [],
31
+ [
32
+ typeof BooleanType,
33
+ typeof IntegerType,
34
+ typeof IntegerPosType,
35
+ typeof IntegerNNType,
36
+ typeof StringType,
37
+ typeof CollectionType,
38
+ typeof DateType,
39
+ typeof PhoneType
40
+ ]
41
+ >
42
+ {
16
43
  name = 'CommonTypes';
17
44
 
18
45
  apply(player: Player) {