@player-ui/common-types-plugin 0.15.1 → 0.15.2-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.
Files changed (38) hide show
  1. package/dist/CommonTypesPlugin.native.js +2 -2
  2. package/dist/CommonTypesPlugin.native.js.map +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.legacy-esm.js +0 -785
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/xlr/DataTypes.BooleanType.json +72 -0
  7. package/dist/xlr/DataTypes.CollectionType.json +39 -0
  8. package/dist/xlr/DataTypes.DateType.json +55 -0
  9. package/dist/xlr/DataTypes.IntegerNNType.json +75 -0
  10. package/dist/xlr/DataTypes.IntegerPosType.json +75 -0
  11. package/dist/xlr/DataTypes.IntegerType.json +55 -0
  12. package/dist/xlr/DataTypes.PhoneType.json +55 -0
  13. package/dist/xlr/DataTypes.StringType.json +62 -0
  14. package/dist/xlr/Formatters.commaNumber.json +28 -0
  15. package/dist/xlr/Formatters.currency.json +44 -0
  16. package/dist/xlr/Formatters.date.json +28 -0
  17. package/dist/xlr/Formatters.integer.json +14 -0
  18. package/dist/xlr/Formatters.phone.json +11 -0
  19. package/dist/xlr/Validators.collection.json +6 -0
  20. package/dist/xlr/Validators.email.json +6 -0
  21. package/dist/xlr/Validators.expression.json +23 -0
  22. package/dist/xlr/Validators.integer.json +6 -0
  23. package/dist/xlr/Validators.length.json +49 -0
  24. package/dist/xlr/Validators.max.json +22 -0
  25. package/dist/xlr/Validators.min.json +22 -0
  26. package/dist/xlr/Validators.oneOf.json +25 -0
  27. package/dist/xlr/Validators.phone.json +6 -0
  28. package/dist/xlr/Validators.readonly.json +6 -0
  29. package/dist/xlr/Validators.regex.json +22 -0
  30. package/dist/xlr/Validators.required.json +32 -0
  31. package/dist/xlr/Validators.string.json +6 -0
  32. package/dist/xlr/Validators.zip.json +6 -0
  33. package/dist/xlr/manifest.js +42 -0
  34. package/dist/xlr/manifest.json +51 -0
  35. package/package.json +6 -4
  36. package/src/index.ts +44 -2
  37. package/src/validators/index.ts +3 -3
  38. package/types/index.d.ts +24 -1
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ import { TypesProviderPlugin } from "@player-ui/types-provider-plugin";
4
4
  import * as validators from "./validators";
5
5
  import * as dataTypes from "./data-types/types";
6
6
  import * as formats from "./formats";
7
- import type {
7
+ import {
8
8
  BooleanType,
9
9
  IntegerType,
10
10
  IntegerPosType,
@@ -15,6 +15,25 @@ import type {
15
15
  PhoneType,
16
16
  } from "./data-types/types";
17
17
 
18
+ import { commaNumber, currency, date, integer, phone } from "./formats/index";
19
+
20
+ import {
21
+ collection,
22
+ email,
23
+ expression,
24
+ integer as vinteger,
25
+ length,
26
+ max,
27
+ min,
28
+ oneOf,
29
+ phone as vphone,
30
+ readonly,
31
+ regex,
32
+ required,
33
+ string,
34
+ zip,
35
+ } from "./validators/index";
36
+
18
37
  export { validators, dataTypes, formats };
19
38
 
20
39
  export * from "./formats/utils";
@@ -37,12 +56,35 @@ export class CommonTypesPlugin
37
56
  typeof CollectionType,
38
57
  typeof DateType,
39
58
  typeof PhoneType,
59
+ ],
60
+ [
61
+ typeof commaNumber,
62
+ typeof currency,
63
+ typeof date,
64
+ typeof integer,
65
+ typeof phone,
66
+ ],
67
+ [
68
+ typeof collection,
69
+ typeof email,
70
+ typeof expression,
71
+ typeof vinteger,
72
+ typeof length,
73
+ typeof max,
74
+ typeof min,
75
+ typeof oneOf,
76
+ typeof vphone,
77
+ typeof readonly,
78
+ typeof regex,
79
+ typeof required,
80
+ typeof string,
81
+ typeof zip,
40
82
  ]
41
83
  >
42
84
  {
43
85
  name = "CommonTypes";
44
86
 
45
- apply(player: Player) {
87
+ apply(player: Player): void {
46
88
  player.registerPlugin(
47
89
  new TypesProviderPlugin({
48
90
  types: Object.values(dataTypes),
@@ -347,21 +347,21 @@ const stringRegexValidator = (
347
347
  };
348
348
 
349
349
  /** Checks that the given value represents an email */
350
- export const email = stringRegexValidator(
350
+ export const email: ValidatorFunction = stringRegexValidator(
351
351
  EMAIL_REGEX,
352
352
  "validation.email",
353
353
  "Improper email format",
354
354
  );
355
355
 
356
356
  /** Checks that the given value represents a phone number */
357
- export const phone = stringRegexValidator(
357
+ export const phone: ValidatorFunction = stringRegexValidator(
358
358
  PHONE_REGEX,
359
359
  "validation.phone",
360
360
  "Invalid phone number",
361
361
  );
362
362
 
363
363
  /** Checks that the given value represents a phone number */
364
- export const zip = stringRegexValidator(
364
+ export const zip: ValidatorFunction = stringRegexValidator(
365
365
  ZIP_REGEX,
366
366
  "validation.regex",
367
367
  "Invalid zip code",
package/types/index.d.ts CHANGED
@@ -2,7 +2,9 @@ import type { Player, ExtendedPlayerPlugin } from "@player-ui/player";
2
2
  import * as validators from "./validators";
3
3
  import * as dataTypes from "./data-types/types";
4
4
  import * as formats from "./formats";
5
- import type { BooleanType, IntegerType, IntegerPosType, IntegerNNType, StringType, CollectionType, DateType, PhoneType } from "./data-types/types";
5
+ import { BooleanType, IntegerType, IntegerPosType, IntegerNNType, StringType, CollectionType, DateType, PhoneType } from "./data-types/types";
6
+ import { commaNumber, currency, date, integer, phone } from "./formats/index";
7
+ import { collection, email, expression, integer as vinteger, length, max, min, oneOf, phone as vphone, readonly, regex, required, string, zip } from "./validators/index";
6
8
  export { validators, dataTypes, formats };
7
9
  export * from "./formats/utils";
8
10
  /**
@@ -20,6 +22,27 @@ export declare class CommonTypesPlugin implements ExtendedPlayerPlugin<[
20
22
  typeof CollectionType,
21
23
  typeof DateType,
22
24
  typeof PhoneType
25
+ ], [
26
+ typeof commaNumber,
27
+ typeof currency,
28
+ typeof date,
29
+ typeof integer,
30
+ typeof phone
31
+ ], [
32
+ typeof collection,
33
+ typeof email,
34
+ typeof expression,
35
+ typeof vinteger,
36
+ typeof length,
37
+ typeof max,
38
+ typeof min,
39
+ typeof oneOf,
40
+ typeof vphone,
41
+ typeof readonly,
42
+ typeof regex,
43
+ typeof required,
44
+ typeof string,
45
+ typeof zip
23
46
  ]> {
24
47
  name: string;
25
48
  apply(player: Player): void;