@gravitywiz/types 0.0.12 → 0.0.13

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 (2) hide show
  1. package/index.d.ts +69 -10
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -7,27 +7,68 @@ declare global {
7
7
  // TODO type ...any better (e.g. provide a way to for the caller to declare what these arguments should be).
8
8
  type GFHookCallback = (...args: any[]) => void;
9
9
 
10
- type GFFieldType = 'text' | 'date' | 'website' | 'email' | 'phone' | 'survey';
11
-
12
- type GFInputType = 'text' | 'email' | 'fileupload' | 'date' | 'website' | 'total' | 'rating';
10
+ type GFFieldType =
11
+ | 'text'
12
+ | 'date'
13
+ | 'website'
14
+ | 'email'
15
+ | 'phone'
16
+ | 'survey';
17
+
18
+ type GFInputType =
19
+ | 'text'
20
+ | 'number'
21
+ | 'email'
22
+ | 'fileupload'
23
+ | 'date'
24
+ | 'website'
25
+ | 'total'
26
+ | 'rating'
27
+ | 'radio'
28
+ | 'select'
29
+ | 'singleproduct'
30
+ | 'hiddenproduct'
31
+ | 'calculation'
32
+ | 'singleshipping'
33
+ | 'donation'
34
+ | 'price'
35
+ | 'consent'
13
36
 
14
37
  interface GFFieldInput {
15
- id: string;
38
+ id: string | number;
39
+ label: string;
40
+ name: string;
41
+ isHidden?: boolean;
42
+ key?: string;
43
+ autoComplete?: string;
44
+ }
45
+
46
+ class Input implements GFFieldInput {
47
+ constructor(
48
+ id: string | number,
49
+ label?: string,
50
+ autocompleteAttribute?: string,
51
+ );
52
+ id: string | number;
16
53
  label: string;
17
54
  name: string;
18
55
  isHidden?: boolean;
56
+ key?: string;
57
+ autoComplete?: string;
19
58
  }
59
+
20
60
  interface GFBaseField {
61
+ id: number;
62
+ formId: number;
63
+ type: GFFieldType;
21
64
  inputs?: GFFieldInput[] | null;
22
65
  choices?: GFChoice[];
23
66
  label: string;
24
67
  adminLabel?: string;
25
- id: number;
26
- formId: number;
27
- type: GFFieldType;
28
68
  enableEnhancedUI?: boolean;
29
69
  inputType: GFInputType;
30
70
  productId: string;
71
+ validateState?: boolean;
31
72
  }
32
73
 
33
74
  type GFSurveyField = GFBaseField & {
@@ -36,15 +77,30 @@ declare global {
36
77
  gsurveyLikertRows?: { text: string; value: string }[];
37
78
  }
38
79
 
39
- type GFField = GFBaseField | GFSurveyField;
80
+ type GFField<Extra = {}> = (GFBaseField | GFSurveyField) & Extra;
40
81
 
41
82
  interface GFChoice {
83
+ text: string;
84
+ value: string | number;
42
85
  isSelected?: boolean;
43
- price?: string;
86
+ price?: string | number;
87
+ key?: string;
88
+ }
89
+
90
+ class Choice implements GFChoice {
91
+ constructor(
92
+ text: string,
93
+ value?: string | number,
94
+ price?: string | number
95
+ );
44
96
  text: string;
45
- value: string;
97
+ value: string | number;
98
+ isSelected?: boolean;
99
+ price?: string | number;
100
+ key?: string;
46
101
  }
47
102
 
103
+
48
104
  interface GFForm {
49
105
  button: {
50
106
  type: string;
@@ -246,6 +302,8 @@ declare global {
246
302
  [key: string]: any
247
303
  };
248
304
 
305
+ GenerateUniqueFieldKey: () => string;
306
+
249
307
  // Placeholders
250
308
  mOxie: any;
251
309
  gf_raw_input_change: any;
@@ -279,6 +337,7 @@ declare global {
279
337
 
280
338
  gformFormat: (...format: any[]) => string;
281
339
  }
340
+
282
341
  }
283
342
 
284
343
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitywiz/types",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "TypesScript type definitions for Gravity Forms and Gravity Wiz.",
5
5
  "author": "Gravity Wiz",
6
6
  "license": "GPL-2.0-or-later",