@payloadcms/plugin-form-builder 1.0.13 → 1.0.14

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 (47) hide show
  1. package/README.md +40 -14
  2. package/package.json +23 -3
  3. package/dist/collections/FormSubmissions/hooks/createCharge.d.ts +0 -3
  4. package/dist/collections/FormSubmissions/hooks/createCharge.js +0 -58
  5. package/dist/collections/FormSubmissions/hooks/createCharge.js.map +0 -1
  6. package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +0 -3
  7. package/dist/collections/FormSubmissions/hooks/sendEmail.js +0 -153
  8. package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +0 -1
  9. package/dist/collections/FormSubmissions/index.d.ts +0 -3
  10. package/dist/collections/FormSubmissions/index.js +0 -139
  11. package/dist/collections/FormSubmissions/index.js.map +0 -1
  12. package/dist/collections/Forms/DynamicFieldSelector.d.ts +0 -3
  13. package/dist/collections/Forms/DynamicFieldSelector.js +0 -66
  14. package/dist/collections/Forms/DynamicFieldSelector.js.map +0 -1
  15. package/dist/collections/Forms/DynamicPriceSelector.d.ts +0 -3
  16. package/dist/collections/Forms/DynamicPriceSelector.js +0 -86
  17. package/dist/collections/Forms/DynamicPriceSelector.js.map +0 -1
  18. package/dist/collections/Forms/fields.d.ts +0 -6
  19. package/dist/collections/Forms/fields.js +0 -500
  20. package/dist/collections/Forms/fields.js.map +0 -1
  21. package/dist/collections/Forms/index.d.ts +0 -3
  22. package/dist/collections/Forms/index.js +0 -231
  23. package/dist/collections/Forms/index.js.map +0 -1
  24. package/dist/index.d.ts +0 -5
  25. package/dist/index.js +0 -52
  26. package/dist/index.js.map +0 -1
  27. package/dist/mocks/serverModule.d.ts +0 -2
  28. package/dist/mocks/serverModule.js +0 -4
  29. package/dist/mocks/serverModule.js.map +0 -1
  30. package/dist/types.d.ts +0 -174
  31. package/dist/types.js +0 -11
  32. package/dist/types.js.map +0 -1
  33. package/dist/utilities/calculatePaymentTotal.d.ts +0 -4
  34. package/dist/utilities/calculatePaymentTotal.js +0 -47
  35. package/dist/utilities/calculatePaymentTotal.js.map +0 -1
  36. package/dist/utilities/deepMerge.d.ts +0 -2
  37. package/dist/utilities/deepMerge.js +0 -44
  38. package/dist/utilities/deepMerge.js.map +0 -1
  39. package/dist/utilities/getPaymentTotal.d.ts +0 -4
  40. package/dist/utilities/getPaymentTotal.js +0 -44
  41. package/dist/utilities/getPaymentTotal.js.map +0 -1
  42. package/dist/utilities/replaceDoubleCurlys.d.ts +0 -7
  43. package/dist/utilities/replaceDoubleCurlys.js +0 -20
  44. package/dist/utilities/replaceDoubleCurlys.js.map +0 -1
  45. package/dist/utilities/serializeRichText.d.ts +0 -10
  46. package/dist/utilities/serializeRichText.js +0 -49
  47. package/dist/utilities/serializeRichText.js.map +0 -1
@@ -1,231 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateFormCollection = void 0;
27
- var deepmerge_1 = __importDefault(require("deepmerge"));
28
- var fields_1 = __importDefault(require("./fields"));
29
- // all settings can be overridden by the config
30
- var generateFormCollection = function (formConfig) {
31
- var _a, _b, _c, _d;
32
- var redirect = {
33
- name: 'redirect',
34
- type: 'group',
35
- admin: {
36
- hideGutter: true,
37
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.confirmationType) === 'redirect'; },
38
- },
39
- fields: [
40
- {
41
- name: 'url',
42
- label: 'URL to redirect to',
43
- type: 'text',
44
- required: true,
45
- },
46
- ],
47
- };
48
- if (formConfig.redirectRelationships) {
49
- redirect.fields.unshift({
50
- name: 'reference',
51
- label: 'Document to link to',
52
- type: 'relationship',
53
- relationTo: formConfig.redirectRelationships,
54
- required: true,
55
- maxDepth: 2,
56
- admin: {
57
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'reference'; },
58
- },
59
- });
60
- redirect.fields.unshift({
61
- name: 'type',
62
- type: 'radio',
63
- options: [
64
- {
65
- label: 'Internal link',
66
- value: 'reference',
67
- },
68
- {
69
- label: 'Custom URL',
70
- value: 'custom',
71
- },
72
- ],
73
- defaultValue: 'reference',
74
- admin: {
75
- layout: 'horizontal',
76
- },
77
- });
78
- if (redirect.fields[2].type !== 'row')
79
- redirect.fields[2].label = 'Custom URL';
80
- redirect.fields[2].admin = {
81
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'custom'; },
82
- };
83
- }
84
- var config = __assign(__assign({}, (formConfig === null || formConfig === void 0 ? void 0 : formConfig.formOverrides) || {}), { slug: ((_a = formConfig === null || formConfig === void 0 ? void 0 : formConfig.formOverrides) === null || _a === void 0 ? void 0 : _a.slug) || 'forms', admin: __assign({ useAsTitle: 'title', enableRichTextRelationship: false }, ((_b = formConfig === null || formConfig === void 0 ? void 0 : formConfig.formOverrides) === null || _b === void 0 ? void 0 : _b.admin) || {}), access: __assign({ read: function () { return true; } }, ((_c = formConfig === null || formConfig === void 0 ? void 0 : formConfig.formOverrides) === null || _c === void 0 ? void 0 : _c.access) || {}), fields: __spreadArray([
85
- {
86
- name: 'title',
87
- type: 'text',
88
- required: true,
89
- },
90
- {
91
- name: 'fields',
92
- type: 'blocks',
93
- blocks: Object.entries((formConfig === null || formConfig === void 0 ? void 0 : formConfig.fields) || {}).map(function (_a) {
94
- var fieldKey = _a[0], fieldConfig = _a[1];
95
- // let the config enable/disable fields with either boolean values or objects
96
- if (fieldConfig !== false) {
97
- var block = fields_1.default[fieldKey];
98
- if (block === undefined && typeof fieldConfig === 'object') {
99
- return fieldConfig;
100
- }
101
- if (typeof block === 'object' && typeof fieldConfig === 'object') {
102
- return (0, deepmerge_1.default)(block, fieldConfig, {
103
- arrayMerge: function (_, sourceArray) { return sourceArray; }
104
- });
105
- }
106
- if (typeof block === 'function') {
107
- return block(fieldConfig);
108
- }
109
- return block;
110
- }
111
- return null;
112
- }).filter(Boolean),
113
- },
114
- {
115
- name: 'submitButtonLabel',
116
- type: 'text',
117
- localized: true,
118
- },
119
- {
120
- name: 'confirmationType',
121
- type: 'radio',
122
- admin: {
123
- description: 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',
124
- layout: 'horizontal',
125
- },
126
- options: [
127
- {
128
- label: 'Message',
129
- value: 'message',
130
- },
131
- {
132
- label: 'Redirect',
133
- value: 'redirect',
134
- },
135
- ],
136
- defaultValue: 'message',
137
- },
138
- {
139
- name: 'confirmationMessage',
140
- type: 'richText',
141
- localized: true,
142
- required: true,
143
- admin: {
144
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.confirmationType) === 'message'; },
145
- },
146
- },
147
- redirect,
148
- {
149
- name: 'emails',
150
- type: 'array',
151
- admin: {
152
- description: 'Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field\'s name with double curly brackets, i.e. {{firstName}}.',
153
- },
154
- fields: [
155
- {
156
- type: 'row',
157
- fields: [
158
- {
159
- type: 'text',
160
- name: 'emailTo',
161
- label: 'Email To',
162
- admin: {
163
- width: '100%',
164
- placeholder: '"Email Sender" <sender@email.com>'
165
- },
166
- },
167
- {
168
- type: 'text',
169
- name: 'cc',
170
- label: 'CC',
171
- admin: {
172
- width: '50%',
173
- },
174
- },
175
- {
176
- type: 'text',
177
- name: 'bcc',
178
- label: 'BCC',
179
- admin: {
180
- width: '50%',
181
- },
182
- },
183
- ],
184
- },
185
- {
186
- type: 'row',
187
- fields: [
188
- {
189
- type: 'text',
190
- name: 'replyTo',
191
- label: 'Reply To',
192
- admin: {
193
- width: '50%',
194
- placeholder: '"Reply To" <reply-to@email.com>',
195
- },
196
- },
197
- {
198
- type: 'text',
199
- name: 'emailFrom',
200
- label: 'Email From',
201
- admin: {
202
- width: '50%',
203
- placeholder: '"Email From" <email-from@email.com>',
204
- },
205
- },
206
- ],
207
- },
208
- {
209
- type: 'text',
210
- name: 'subject',
211
- label: 'Subject',
212
- defaultValue: 'You\'ve received a new message.',
213
- required: true,
214
- localized: true,
215
- },
216
- {
217
- type: 'richText',
218
- name: 'message',
219
- label: 'Message',
220
- localized: true,
221
- admin: {
222
- description: 'Enter the message that should be sent in this email.',
223
- },
224
- },
225
- ],
226
- }
227
- ], ((_d = formConfig === null || formConfig === void 0 ? void 0 : formConfig.formOverrides) === null || _d === void 0 ? void 0 : _d.fields) || [], true) });
228
- return config;
229
- };
230
- exports.generateFormCollection = generateFormCollection;
231
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAA8B;AAE9B,oDAA8B;AAE9B,+CAA+C;AACxC,IAAM,sBAAsB,GAAG,UAAC,UAAwB;;IAE7D,IAAM,QAAQ,GAAU;QACtB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE;YACL,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,UAAC,CAAC,EAAE,WAAW,IAAK,OAAA,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,MAAK,U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AAsB,0BA8NjC"}
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Config } from 'payload/config';
2
- import { PluginConfig } from './types';
3
- export { getPaymentTotal } from './utilities/getPaymentTotal';
4
- declare const FormBuilder: (incomingFormConfig: PluginConfig) => (config: Config) => Config;
5
- export default FormBuilder;
package/dist/index.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.getPaymentTotal = void 0;
24
- var Forms_1 = require("./collections/Forms");
25
- var FormSubmissions_1 = require("./collections/FormSubmissions");
26
- // import path from 'path';
27
- var getPaymentTotal_1 = require("./utilities/getPaymentTotal");
28
- Object.defineProperty(exports, "getPaymentTotal", { enumerable: true, get: function () { return getPaymentTotal_1.getPaymentTotal; } });
29
- var FormBuilder = function (incomingFormConfig) { return function (config) {
30
- var formConfig = __assign(__assign({}, incomingFormConfig), { fields: __assign({ text: true, textarea: true, select: true, email: true, state: true, country: true, number: true, checkbox: true, message: true, payment: false }, incomingFormConfig.fields) });
31
- return __assign(__assign({}, config), {
32
- // admin: {
33
- // ...config.admin,
34
- // webpack: (webpackConfig) => ({
35
- // ...webpackConfig,
36
- // resolve: {
37
- // ...webpackConfig.resolve,
38
- // alias: {
39
- // ...webpackConfig.resolve.alias,
40
- // [path.resolve(__dirname, 'collections/FormSubmissions/hooks/sendEmail.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
41
- // [path.resolve(__dirname, 'collections/FormSubmissions/hooks/createCharge.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
42
- // },
43
- // },
44
- // })
45
- // },
46
- collections: __spreadArray(__spreadArray([], (config === null || config === void 0 ? void 0 : config.collections) || [], true), [
47
- (0, Forms_1.generateFormCollection)(formConfig),
48
- (0, FormSubmissions_1.generateSubmissionCollection)(formConfig),
49
- ], false) });
50
- }; };
51
- exports.default = FormBuilder;
52
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA6D;AAC7D,iEAA6E;AAE7E,2BAA2B;AAE3B,+DAA6D;AAApD,kHAAA,eAAe,OAAA;AAExB,IAAM,WAAW,GAAG,UAAC,kBAAgC,IAAK,OAAA,UAAC,MAAc;IACvE,IAAM,UAAU,yBACX,kBAAkB,KACrB,MAAM,aACJ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,IAAI,EACd,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,EACX,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,IAAI,EACb,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,IAAI,EACd,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,KAAK,IACX,kBAAkB,CAAC,MAAM,IAE/B,CAAC;IAEF,6BACK,MAAM;QACT,WAAW;QACX,qBAAqB;QACrB,mCAAmC;QACnC,wBAAwB;QACxB,iBAAiB;QACjB,kCAAkC;QAClC,iBAAiB;QACjB,0CAA0C;QAC1C,yIAAyI;QACzI,4IAA4I;QAC5I,WAAW;QACX,SAAS;QACT,OAAO;QACP,KAAK;QACL,WAAW,kCACN,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,EAAE;YAC5B,IAAA,8BAAsB,EAAC,UAAU,CAAC;YAClC,IAAA,8CAA4B,EAAC,UAAU,CAAC;qBAE1C;AACJ,CAAC,EAxCyD,CAwCzD,CAAC;AAEF,kBAAe,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const _default: {};
2
- export default _default;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {};
4
- //# sourceMappingURL=serverModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverModule.js","sourceRoot":"","sources":["../../src/mocks/serverModule.js"],"names":[],"mappings":";;AAAA,kBAAe,EAAE,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,174 +0,0 @@
1
- import { Block, CollectionConfig, Field } from 'payload/types';
2
- export type BlockConfig = {
3
- block: Block;
4
- validate?: (value: unknown) => boolean | string;
5
- };
6
- export declare function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig;
7
- export type FieldValues = {
8
- [key: string]: string | number | boolean | null | undefined;
9
- };
10
- export type PaymentFieldConfig = Partial<Field> & {
11
- paymentProcessor: Partial<SelectField>;
12
- };
13
- export type FieldConfig = Partial<Field> | PaymentFieldConfig;
14
- export type FieldsConfig = {
15
- select?: boolean | FieldConfig;
16
- text?: boolean | FieldConfig;
17
- textarea?: boolean | FieldConfig;
18
- email?: boolean | FieldConfig;
19
- state?: boolean | FieldConfig;
20
- country?: boolean | FieldConfig;
21
- checkbox?: boolean | FieldConfig;
22
- number?: boolean | FieldConfig;
23
- message?: boolean | FieldConfig;
24
- payment?: boolean | FieldConfig;
25
- [key: string]: boolean | FieldConfig | undefined;
26
- };
27
- export type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>;
28
- export type HandlePayment = (data: any) => void;
29
- export type PluginConfig = {
30
- fields?: FieldsConfig;
31
- formSubmissionOverrides?: Partial<CollectionConfig>;
32
- formOverrides?: Partial<CollectionConfig>;
33
- beforeEmail?: BeforeEmail;
34
- handlePayment?: HandlePayment;
35
- redirectRelationships?: string[];
36
- };
37
- export type TextField = {
38
- blockType: 'text';
39
- blockName?: string;
40
- width?: string;
41
- name: string;
42
- label?: string;
43
- defaultValue?: string;
44
- required?: boolean;
45
- };
46
- export type TextAreaField = {
47
- blockType: 'textarea';
48
- blockName?: string;
49
- width?: string;
50
- name: string;
51
- label?: string;
52
- defaultValue?: string;
53
- required?: boolean;
54
- };
55
- export type SelectFieldOption = {
56
- label: string;
57
- value: string;
58
- };
59
- export type SelectField = {
60
- blockType: 'select';
61
- blockName?: string;
62
- width?: string;
63
- name: string;
64
- label?: string;
65
- defaultValue?: string;
66
- required?: boolean;
67
- options: SelectFieldOption[];
68
- };
69
- export type PriceCondition = {
70
- fieldToUse: string;
71
- condition: 'equals' | 'notEquals' | 'hasValue';
72
- valueForCondition: string;
73
- operator: 'add' | 'subtract' | 'multiply' | 'divide';
74
- valueType: 'static' | 'valueOfField';
75
- valueForOperator: string | number;
76
- };
77
- export type PaymentField = {
78
- blockType: 'payment';
79
- blockName?: string;
80
- width?: string;
81
- name: string;
82
- label?: string;
83
- defaultValue?: string;
84
- required?: boolean;
85
- paymentProcessor: string;
86
- basePrice: number;
87
- priceConditions: PriceCondition[];
88
- };
89
- export type EmailField = {
90
- blockType: 'email';
91
- blockName?: string;
92
- width?: string;
93
- name: string;
94
- label?: string;
95
- defaultValue?: string;
96
- required?: boolean;
97
- };
98
- export type StateField = {
99
- blockType: 'state';
100
- blockName?: string;
101
- width?: string;
102
- name: string;
103
- label?: string;
104
- defaultValue?: string;
105
- required?: boolean;
106
- };
107
- export type CountryField = {
108
- blockType: 'country';
109
- blockName?: string;
110
- width?: string;
111
- name: string;
112
- label?: string;
113
- defaultValue?: string;
114
- required?: boolean;
115
- };
116
- export type CheckboxField = {
117
- blockType: 'checkbox';
118
- blockName?: string;
119
- width?: string;
120
- name: string;
121
- label?: string;
122
- defaultValue?: boolean;
123
- required?: boolean;
124
- };
125
- export type MessageField = {
126
- blockType: 'message';
127
- blockName?: string;
128
- message: unknown;
129
- };
130
- export type FormFieldBlock = TextField | TextAreaField | SelectField | EmailField | StateField | CountryField | CheckboxField | MessageField | PaymentField;
131
- export type Email = {
132
- emailTo: string;
133
- emailFrom: string;
134
- cc?: string;
135
- bcc?: string;
136
- replyTo?: string;
137
- subject: string;
138
- message?: any;
139
- };
140
- export type FormattedEmail = {
141
- to: string;
142
- cc?: string;
143
- bcc?: string;
144
- from: string;
145
- subject: string;
146
- html: string;
147
- replyTo: string;
148
- };
149
- export type Redirect = {
150
- type: 'reference' | 'custom';
151
- reference?: {
152
- relationTo: string;
153
- value: string | unknown;
154
- };
155
- url: string;
156
- };
157
- export type Form = {
158
- id: string;
159
- title: string;
160
- fields: FormFieldBlock[];
161
- submitButtonLabel?: string;
162
- confirmationType: 'message' | 'redirect';
163
- confirmationMessage?: any;
164
- redirect?: Redirect;
165
- emails: Email[];
166
- };
167
- export type SubmissionValue = {
168
- field: string;
169
- value: unknown;
170
- };
171
- export type FormSubmission = {
172
- form: string | Form;
173
- submissionData: SubmissionValue[];
174
- };
package/dist/types.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidBlockConfig = void 0;
4
- function isValidBlockConfig(blockConfig) {
5
- var _a, _b;
6
- return typeof blockConfig !== 'string'
7
- && typeof ((_a = blockConfig === null || blockConfig === void 0 ? void 0 : blockConfig.block) === null || _a === void 0 ? void 0 : _a.slug) === 'string'
8
- && Array.isArray((_b = blockConfig === null || blockConfig === void 0 ? void 0 : blockConfig.block) === null || _b === void 0 ? void 0 : _b.fields);
9
- }
10
- exports.isValidBlockConfig = isValidBlockConfig;
11
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAOA,SAAgB,kBAAkB,CAAC,WAAiC;;IAClE,OAAO,OAAO,WAAW,KAAK,QAAQ;WACjC,OAAO,CAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,0CAAE,IAAI,CAAA,KAAK,QAAQ;WAC5C,KAAK,CAAC,OAAO,CAAC,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,0CAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAJD,gDAIC"}
@@ -1,4 +0,0 @@
1
- import { FieldValues, PaymentField } from "../types";
2
- export declare const calculatePaymentTotal: (args: Partial<PaymentField> & {
3
- fieldValues: FieldValues;
4
- }) => number | undefined;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculatePaymentTotal = void 0;
4
- var calculatePaymentTotal = function (args) {
5
- var _a = args.basePrice, basePrice = _a === void 0 ? 0 : _a, priceConditions = args.priceConditions, fieldValues = args.fieldValues;
6
- var total = basePrice;
7
- if (Array.isArray(priceConditions) && priceConditions.length > 0) {
8
- priceConditions.forEach(function (priceCondition) {
9
- var condition = priceCondition.condition, valueForCondition = priceCondition.valueForCondition, fieldToUse = priceCondition.fieldToUse, operator = priceCondition.operator, valueType = priceCondition.valueType, valueForOperator = priceCondition.valueForOperator;
10
- var valueOfField = fieldValues === null || fieldValues === void 0 ? void 0 : fieldValues[fieldToUse];
11
- console.log(priceCondition);
12
- if (valueOfField) {
13
- if (condition === 'hasValue'
14
- || condition === 'equals' && valueOfField === valueForCondition
15
- || condition === 'notEquals' && valueOfField !== valueForCondition) {
16
- var valueToUse = Number(valueType === 'valueOfField' ? valueOfField : valueForOperator);
17
- console.log('valueToUse', valueToUse);
18
- switch (operator) {
19
- case 'add': {
20
- total += valueToUse;
21
- break;
22
- }
23
- case 'subtract': {
24
- total -= valueToUse;
25
- break;
26
- }
27
- case 'multiply': {
28
- total *= valueToUse;
29
- break;
30
- }
31
- case 'divide': {
32
- total /= valueToUse;
33
- break;
34
- }
35
- default: {
36
- break;
37
- }
38
- }
39
- }
40
- }
41
- });
42
- }
43
- console.log(args, total);
44
- return total;
45
- };
46
- exports.calculatePaymentTotal = calculatePaymentTotal;
47
- //# sourceMappingURL=calculatePaymentTotal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculatePaymentTotal.js","sourceRoot":"","sources":["../../src/utilities/calculatePaymentTotal.ts"],"names":[],"mappings":";;;AAEO,IAAM,qBAAqB,GAAG,UAAC,IAErC;IAEG,IAAA,KAGE,IAAI,UAHO,EAAb,SAAS,mBAAG,CAAC,KAAA,EACb,eAAe,GAEb,IAAI,gBAFS,EACf,WAAW,GACT,IAAI,YADK,CACJ;IAET,IAAI,KAAK,GAAG,SAAS,CAAC;IAEtB,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;QAChE,eAAe,CAAC,OAAO,CAAC,UAAC,cAA8B;YAEnD,IAAA,SAAS,GAMP,cAAc,UANP,EACT,iBAAiB,GAKf,cAAc,kBALC,EACjB,UAAU,GAIR,cAAc,WAJN,EACV,QAAQ,GAGN,cAAc,SAHR,EACR,SAAS,GAEP,cAAc,UAFP,EACT,gBAAgB,GACd,cAAc,iBADA,CACC;YAEnB,IAAM,YAAY,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,UAAU,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;YAE3B,IAAI,YAAY,EAAE;gBAChB,IACE,SAAS,KAAK,UAAU;uBACrB,SAAS,KAAK,QAAQ,IAAI,YAAY,KAAK,iBAAiB;uBAC5D,SAAS,KAAK,WAAW,IAAI,YAAY,KAAK,iBAAiB,EAClE;oBACA,IAAM,UAAU,GAAG,MAAM,CAAC,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;oBAC1F,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;oBACrC,QAAQ,QAAQ,EAAE;wBAChB,KAAK,KAAK,CAAC,CAAC;4BACV,KAAK,IAAI,UAAU,CAAC;4BACpB,MAAM;yBACP;wBACD,KAAK,UAAU,CAAC,CAAC;4BACf,KAAK,IAAI,UAAU,CAAC;4BACpB,MAAM;yBACP;wBACD,KAAK,UAAU,CAAC,CAAC;4BACf,KAAK,IAAI,UAAU,CAAC;4BACpB,MAAM;yBACP;wBACD,KAAK,QAAQ,CAAC,CAAC;4BACb,KAAK,IAAI,UAAU,CAAC;4BACpB,MAAM;yBACP;wBACD,OAAO,CAAC,CAAC;4BACP,MAAM;yBACP;qBACF;iBACF;aACF;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAExB,OAAO,KAAK,CAAC;AACf,CAAC,CAAA;AA9DY,QAAA,qBAAqB,yBA8DjC"}
@@ -1,2 +0,0 @@
1
- export declare function isObject(item: unknown): boolean;
2
- export default function deepMerge<T, R>(target: T, source: R): T;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.isObject = void 0;
15
- function isObject(item) {
16
- return Boolean(item && typeof item === 'object' && !Array.isArray(item));
17
- }
18
- exports.isObject = isObject;
19
- function deepMerge(target, source) {
20
- var output = __assign({}, target);
21
- if (isObject(target) && isObject(source)) {
22
- Object.keys(source).forEach(function (key) {
23
- var _a, _b;
24
- // @ts-ignore
25
- if (isObject(source[key])) {
26
- if (!(key in target)) {
27
- // @ts-ignore
28
- Object.assign(output, (_a = {}, _a[key] = source[key], _a));
29
- }
30
- else {
31
- // @ts-ignore
32
- output[key] = deepMerge(target[key], source[key]);
33
- }
34
- }
35
- else {
36
- // @ts-ignore
37
- Object.assign(output, (_b = {}, _b[key] = source[key], _b));
38
- }
39
- });
40
- }
41
- return output;
42
- }
43
- exports.default = deepMerge;
44
- //# sourceMappingURL=deepMerge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../../src/utilities/deepMerge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAFD,4BAEC;AAED,SAAwB,SAAS,CAAO,MAAS,EAAE,MAAS;IAC1D,IAAM,MAAM,gBAAQ,MAAM,CAAE,CAAC;IAC7B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;;YAC9B,aAAa;YACb,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;oBACpB,aAAa;oBACb,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;iBAC/C;qBAAM;oBACL,aAAa;oBACb,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;iBACnD;aACF;iBAAM;gBACL,aAAa;gBACb,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAC;aAC/C;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,4BAqBC"}
@@ -1,4 +0,0 @@
1
- import { FieldValues, PaymentField } from "../types";
2
- export declare const getPaymentTotal: (args: Partial<PaymentField> & {
3
- fieldValues: FieldValues;
4
- }) => number;