@gravitywiz/types 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  Herein find TypeScript definitions for Gravity Forms, Perks crafted by Gravity Wiz and other Gravity Forms plugins.
4
4
 
5
- # 🚀 Usage
6
-
7
- ### Install
5
+ ## 💾 Installation
8
6
 
9
7
  ```sh
10
8
  yarn add -D types-gravity-wiz
@@ -15,18 +13,32 @@ or...
15
13
  npm install --save-dev types-gravity-wiz
16
14
  ```
17
15
 
18
- ### Extending `window`
16
+ ## 🚀 Usage
19
17
 
20
- To use the ambient module definitions to make types available on the `window` object, reference the respective types files you need like this. (Make sure to the path is correct for your setup.)
18
+ ### `tsconfig.json`
21
19
 
22
- ```ts
23
- /// <reference path="../../../node_modules/types-gravity-wiz/gravityforms.d.ts" />
20
+ To make ambient types automatically available, you can add `@gravitywiz` to the TypeScript `typeRoots` like so:
21
+
22
+ (By default, `node_modules/@types` is included in `typeRoots` and it's recommended to keep it.)
23
+
24
+ ```json
25
+ {
26
+ "compilerOptions": {
27
+ "typeRoots": [
28
+ "node_modules/@types",
29
+ "node_modules/@gravitywiz"
30
+ ]
31
+ }
32
+ }
24
33
  ```
25
34
 
26
- ### Importing types individually
35
+ ### `/// <reference path="..." />`
36
+
37
+ To use the ambient module definitions without modifying `tsconfig.json`, you can load in the types using
38
+ [`/// <reference path="..." />`](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-path-).
27
39
 
28
- This also supports importing individual types like so:
40
+ (Make sure to the path is correct for your setup.)
29
41
 
30
42
  ```ts
31
- import type { GFField } from 'types-gravity-wiz/gravityforms';
43
+ /// <reference path="../../../node_modules/@gravitywiz/types/index.d.ts" />
32
44
  ```
package/index.d.ts CHANGED
@@ -1,6 +1,165 @@
1
- export {};
1
+ import * as Plupload from "plupload";
2
2
 
3
3
  declare global {
4
- interface Window {
5
- }
4
+ type GFFieldID = number | string;
5
+ type GFFormID = number | string;
6
+
7
+ // TODO type ...any better (e.g. provide a way to for the caller to declare what these arguments should be).
8
+ type GFHookCallback = (...args: any[]) => void;
9
+
10
+ interface GFField {
11
+ inputs: any;
12
+ choices: GFChoice[];
13
+ label: string;
14
+ adminLabel?: string;
15
+ id: number;
16
+ formId: number;
17
+ type: string;
18
+ enableEnhancedUI?: boolean;
19
+ inputType: string;
20
+ }
21
+
22
+ interface GFChoice {
23
+ isSelected?: boolean;
24
+ price?: string;
25
+ text: string;
26
+ value: string;
27
+ }
28
+
29
+ interface GFForm {
30
+ button: {
31
+ type: string;
32
+ text: string;
33
+ imageUrl: string;
34
+ };
35
+ confirmations: any;
36
+ description: string;
37
+ descriptionPlacement: string;
38
+ fields: GFField[];
39
+ firstPageCssClass: string;
40
+ id: number;
41
+ labelPlacement: string;
42
+ lastPageButton: string;
43
+ markupVersion: number;
44
+ nextFieldId: number;
45
+ notifications: any;
46
+ pagination: any;
47
+ postContentTemplate: string;
48
+ postContentTemplateEnabled: boolean;
49
+ postTitleTemplate: string;
50
+ postTitleTemplateEnabled: boolean;
51
+ title: string;
52
+ useCurrentUserAsAuthor: boolean;
53
+ version: string;
54
+ [key: string]: any;
55
+ }
56
+
57
+ interface GFConditionalLogicRuleField {
58
+ label: string;
59
+ value: string | number;
60
+ }
61
+
62
+ interface GFConditionalLogicRule {
63
+ fieldId: string;
64
+ operator: string;
65
+ value: number | string;
66
+ }
67
+
68
+ interface Window {
69
+ jQuery: JQueryStatic;
70
+
71
+ // Form Editor
72
+ field: GFField;
73
+ fieldSettings: { [fieldType: string]: string };
74
+ form: GFForm;
75
+ UpdateFieldChoices: (fieldType: string) => void;
76
+ SetFieldProperty: (setting: string, value: any) => void;
77
+ SetFieldEnhancedUI: (enabled: boolean) => void;
78
+ GetSelectedField: () => GFField;
79
+ GetFieldById: (fieldId: GFFieldID) => GFField;
80
+ GetLabel: (
81
+ field: GFField,
82
+ inputId?: number,
83
+ inputOnly?: boolean
84
+ ) => string;
85
+ has_entry: (fieldId: GFFieldID) => boolean;
86
+ IsPricingField: (fieldType: string) => boolean;
87
+ IsProductField: (fieldType: string) => boolean;
88
+ HasPageField: () => boolean;
89
+ HasPostField: () => boolean;
90
+ ToggleMultiFile: (isInit: boolean) => void;
91
+ GetInputType: (field: GFField) => string;
92
+ SetFieldPhoneFormat: (format: string) => void;
93
+
94
+ // Frontend
95
+ gform: {
96
+ addAction: (
97
+ actionName: string,
98
+ cb: GFHookCallback,
99
+ priority?: number,
100
+ tag?: string
101
+ ) => void;
102
+ removeAction: (actionName: string, tag?: string) => void;
103
+ addFilter: (
104
+ filterName: string,
105
+ cb: GFHookCallback,
106
+ priority?: number,
107
+ tag?: string
108
+ ) => void;
109
+ removeFilter: (
110
+ filterName: string,
111
+ priority?: number,
112
+ tag?: string
113
+ ) => void;
114
+ doAction: (actionName: string, ...args: any[]) => void;
115
+ applyFilters: <S>(
116
+ filterName: string,
117
+ subject: S,
118
+ ...args: any[]
119
+ ) => S;
120
+ };
121
+
122
+ gformCalculateTotalPrice: (formId: string | number) => void;
123
+
124
+ gfMultiFileUploader: {
125
+ uploaders: { [name: string]: Plupload.Uploader };
126
+ setup: Function;
127
+ toggleDisabled: Function;
128
+ };
129
+
130
+ gformDeleteUploadedFile: (
131
+ formId: string,
132
+ fieldId: string,
133
+ deleteButton: HTMLElement
134
+ ) => void;
135
+
136
+ mOxie: any;
137
+
138
+ // Placeholders
139
+ gfMergeTagsObj: any;
140
+ gf_raw_input_change: any;
141
+ gf_check_field_rule: any;
142
+ gf_global: any;
143
+ gf_vars: any;
144
+ gformInitChosenFields: any;
145
+ ToggleCalculationOptions: any;
146
+ gformInitDatepicker: any;
147
+ GFCalc: any;
148
+ GFMergeTag: any;
149
+ gfAjaxSpinner: any;
150
+ gformIsHidden: any;
151
+ gf_form_conditional_logic: any;
152
+ Currency: any;
153
+ gf_matches_operation: any;
154
+ gf_apply_rules: any;
155
+ }
156
+
157
+ interface String {
158
+ // Deprecated, being removed in GF 2.8.
159
+ format: (...format: any[]) => string;
160
+
161
+ gformFormat: (...format: any[]) => string;
162
+ }
6
163
  }
164
+
165
+ export {};
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
- "name": "@gravitywiz/types",
3
- "version": "0.0.2",
4
- "description": "TypesScript type definitions for Gravity Forms and Gravity Wiz.",
5
- "main": "index.d.ts",
6
- "type": "module",
7
- "author": "Gravity Wiz",
8
- "license": "MIT",
9
- "private": false,
10
- "devDependencies": {
11
- "@types/jquery": "^3.5.16",
12
- "@types/plupload": "^2.0.10"
13
- }
2
+ "name": "@gravitywiz/types",
3
+ "version": "0.0.3",
4
+ "description": "TypesScript type definitions for Gravity Forms and Gravity Wiz.",
5
+ "author": "Gravity Wiz",
6
+ "license": "MIT",
7
+ "main": "",
8
+ "types": "index.d.ts",
9
+ "private": false,
10
+ "devDependencies": {
11
+ "@types/jquery": "^3.5.16",
12
+ "@types/plupload": "^2.0.10"
13
+ }
14
14
  }
package/gravityforms.d.ts DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * Type definitions for Gravity Forms.
3
- */
4
- declare global {
5
- type GFFieldID = number | string;
6
- type GFFormID = number | string;
7
-
8
- interface GFField {
9
- inputs: any;
10
- choices: GFChoice[];
11
- label: string;
12
- adminLabel?: string;
13
- id: number;
14
- formId: number;
15
- type: string;
16
- enableEnhancedUI?: boolean;
17
- inputType: string;
18
- }
19
-
20
- interface GFChoice {
21
- isSelected?: boolean;
22
- price?: string;
23
- text: string;
24
- value: string;
25
- }
26
-
27
- interface GFForm {
28
- button: {
29
- type: string;
30
- text: string;
31
- imageUrl: string;
32
- };
33
- confirmations: any;
34
- description: string;
35
- descriptionPlacement: string;
36
- fields: GFField[];
37
- firstPageCssClass: string;
38
- id: number;
39
- labelPlacement: string;
40
- lastPageButton: string;
41
- markupVersion: number;
42
- nextFieldId: number;
43
- notifications: any;
44
- pagination: any;
45
- postContentTemplate: string;
46
- postContentTemplateEnabled: boolean;
47
- postTitleTemplate: string;
48
- postTitleTemplateEnabled: boolean;
49
- title: string;
50
- useCurrentUserAsAuthor: boolean;
51
- version: string;
52
- [key: string]: any;
53
- }
54
-
55
- interface GFConditionalLogicRuleField {
56
- label: string;
57
- value: string | number;
58
- }
59
-
60
- interface GFConditionalLogicRule {
61
- fieldId: string;
62
- operator: string;
63
- value: number | string;
64
- }
65
- }
66
-
67
- export {};
package/window.d.ts DELETED
@@ -1,104 +0,0 @@
1
- import * as Plupload from "plupload";
2
-
3
- // TODO type ...any better (e.g. provide a way to for the caller to declare what these arguments should be).
4
- export type HookCallback = (...args: any[]) => void;
5
-
6
- declare global {
7
- interface Window {
8
- jQuery: JQueryStatic;
9
-
10
- // Form Editor
11
- field: GFField;
12
- fieldSettings: { [fieldType: string]: string };
13
- form: GFForm;
14
- UpdateFieldChoices: (fieldType: string) => void;
15
- SetFieldProperty: (setting: string, value: any) => void;
16
- SetFieldEnhancedUI: (enabled: boolean) => void;
17
- GetSelectedField: () => GFField;
18
- GetFieldById: (fieldId: GFFieldID) => GFField;
19
- GetLabel: (
20
- field: GFField,
21
- inputId?: number,
22
- inputOnly?: boolean
23
- ) => string;
24
- has_entry: (fieldId: GFFieldID) => boolean;
25
- IsPricingField: (fieldType: string) => boolean;
26
- IsProductField: (fieldType: string) => boolean;
27
- HasPageField: () => boolean;
28
- HasPostField: () => boolean;
29
- ToggleMultiFile: (isInit: boolean) => void;
30
- GetInputType: (field: GFField) => string;
31
- SetFieldPhoneFormat: (format: string) => void;
32
-
33
- // Frontend
34
- gform: {
35
- addAction: (
36
- actionName: string,
37
- cb: HookCallback,
38
- priority?: number,
39
- tag?: string
40
- ) => void;
41
- removeAction: (actionName: string, tag?: string) => void;
42
- addFilter: (
43
- filterName: string,
44
- cb: HookCallback,
45
- priority?: number,
46
- tag?: string
47
- ) => void;
48
- removeFilter: (
49
- filterName: string,
50
- priority?: number,
51
- tag?: string
52
- ) => void;
53
- doAction: (actionName: string, ...args: any[]) => void;
54
- applyFilters: <S>(
55
- filterName: string,
56
- subject: S,
57
- ...args: any[]
58
- ) => S;
59
- };
60
-
61
- gformCalculateTotalPrice: (formId: string | number) => void;
62
-
63
- gfMultiFileUploader: {
64
- uploaders: { [name: string]: Plupload.Uploader };
65
- setup: Function;
66
- toggleDisabled: Function;
67
- };
68
-
69
- gformDeleteUploadedFile: (
70
- formId: string,
71
- fieldId: string,
72
- deleteButton: HTMLElement
73
- ) => void;
74
-
75
- mOxie: any;
76
-
77
- // Placeholders
78
- gfMergeTagsObj: any;
79
- gf_raw_input_change: any;
80
- gf_check_field_rule: any;
81
- gf_global: any;
82
- gf_vars: any;
83
- gformInitChosenFields: any;
84
- ToggleCalculationOptions: any;
85
- gformInitDatepicker: any;
86
- GFCalc: any;
87
- GFMergeTag: any;
88
- gfAjaxSpinner: any;
89
- gformIsHidden: any;
90
- gf_form_conditional_logic: any;
91
- Currency: any;
92
- gf_matches_operation: any;
93
- gf_apply_rules: any;
94
- }
95
-
96
- interface String {
97
- // Deprecated, being removed in GF 2.8.
98
- format: (...format: any[]) => string;
99
-
100
- gformFormat: (...format: any[]) => string;
101
- }
102
- }
103
-
104
- export {};