bhl-forms 0.1.6 → 0.1.7

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.
@@ -198,7 +198,6 @@ const hiddenInputsLegal = [
198
198
  ...hiddenInputsBase
199
199
  ];
200
200
 
201
-
202
201
  const legalRedirectMapDefaults = {
203
202
  "properties.Type_Of_Legal_Problem": {
204
203
  'Adoption': JAUrl('565949'),
@@ -0,0 +1,315 @@
1
+ function merge() {
2
+ return Object.assign({}, ...arguments)
3
+ }
4
+
5
+ function JAUrl(pageId) {
6
+ return 'https://justanswer.9pctbx.net/c/2880795/' + pageId + '/9320?sharedid=${properties.vid}&subid1=${properties.Domain_Abbrev}'
7
+ }
8
+
9
+ const DEFAULT_COMMENTS_PLACEHOLDER_DYNAMIC = '$getKey($meta, "commentsPlaceholders." + $get(Type_Of_Legal_Problem).value, $meta.defaultCommentsPlaceholder)';
10
+ const DEFAULT_COMMENTS_LABEL = 'Please briefly describe your legal issue in a few words:';
11
+
12
+ const formPropDefaults = {
13
+ type: 'form',
14
+ id: 'form',
15
+ config: { validationVisibility: 'submit' },
16
+ onSubmit: '$submit($submitUrl, $prepData, $handleRedirect, "text/plain; charset=UTF-8")',
17
+ plugins: '$plugins',
18
+ actions: false,
19
+ anchorElement: 'form-anchor',
20
+ prepop: {
21
+ fromURL: true
22
+ },
23
+ errorCodes: {
24
+ 403: { message: "An Error Occurred", abort: false },
25
+ 409: { abort: false },
26
+ 429: "An Error Occurred",
27
+ 504: { message: "An Error Occurred", abort: false },
28
+ },
29
+ formClass: '!t-max-w-[40rem]'
30
+ };
31
+
32
+ function formProps(updates) {
33
+ return merge(
34
+ formPropDefaults,
35
+ updates
36
+ )
37
+ }
38
+
39
+ const formAnchorDefaults = {
40
+ $el: 'div',
41
+ children: [
42
+ {
43
+ $el: 'div',
44
+ attrs: {
45
+ id: 'form-anchor',
46
+ class: 't-absolute',
47
+ style: { top: '-30px', left: 0 }
48
+ }
49
+ }
50
+ ],
51
+ attrs: {
52
+ class: 't-relative'
53
+ }
54
+ };
55
+
56
+ function formAnchor(updates) {
57
+ return merge(
58
+ formAnchorDefaults,
59
+ updates
60
+ )
61
+ }
62
+
63
+ const headlineDefaults = {
64
+ $el: 'h1',
65
+ attrs: {
66
+ class: 't-flex t-justify-center t-text-center !t-text-[2rem] t-font-semibold t-pt-5 t-px-7 md:t-px-3'
67
+ }
68
+ };
69
+
70
+ function headline(updates) {
71
+ return merge(
72
+ headlineDefaults,
73
+ updates
74
+ )
75
+ }
76
+
77
+ const subHeadlineDefaults = {
78
+ $el: 'h3',
79
+ attrs: {
80
+ class: 't-flex t-justify-center t-text-center !t-text-[1.2rem] t-font-medium t-text-blue-500 t-px-10'
81
+ }
82
+ };
83
+
84
+ function subHeadline(updates) {
85
+ return merge(
86
+ subHeadlineDefaults,
87
+ updates
88
+ )
89
+ }
90
+
91
+ const hiddenInputsBase = [
92
+ {
93
+ $formkit: 'hidden',
94
+ name: "gclid",
95
+ value: null
96
+ },
97
+ {
98
+ $formkit: 'hidden',
99
+ name: "campaignid",
100
+ value: null
101
+ },
102
+ {
103
+ $formkit: 'hidden',
104
+ name: "s",
105
+ value: null
106
+ }
107
+ ];
108
+
109
+ const hiddenInputsAppraisals = [
110
+ {
111
+ $formkit: 'hidden',
112
+ name: "vertical",
113
+ value: "Appraisals"
114
+ },
115
+ ...hiddenInputsBase
116
+ ];
117
+
118
+ const textArea = (updates) => {
119
+ return merge({
120
+ $formkit: 'textarea',
121
+ rows: 5,
122
+ maxlength: 500,
123
+ validation: 'required',
124
+ validationMessages: {
125
+ required: 'Field is required'
126
+ },
127
+ innerClass: 't-max-w-xl',
128
+ labelClass: 'required'
129
+ }, updates)
130
+ };
131
+
132
+ const comments$1 = (updates) => textArea(
133
+ merge({
134
+ label: 'Please briefly describe your situation in a few words:',
135
+ name: 'Comments',
136
+ placeholder: 'For Example: "I would like help with child support payments" or "I need help with visitation rights"'
137
+ }, updates)
138
+ );
139
+
140
+ const NEXT_ON_ENTER = '$onEnter($setNextStep($fireStepEvent($get(form)), $preStepFunc($get(form))))';
141
+
142
+ const isInput = (n) => { return (n.type !== 'group' && n.type !== 'section' && n.type !== 'form' && n.$formkit !== 'hidden' && !n.children) };
143
+
144
+ const findLastInput = (n) => {
145
+ if (isInput(n)) {
146
+ return n
147
+ }
148
+ for (var i = n.children.length - 1; i >= 0; i--) {
149
+ if (typeof n.children === 'string') {
150
+ continue
151
+ }
152
+ const child = n.children[i];
153
+ if (isInput(child)) {
154
+ return child
155
+ }
156
+ const res = findLastInput(child);
157
+ if (res) {
158
+ return res
159
+ }
160
+ }
161
+ return null
162
+ };
163
+
164
+ const stepDefaults = (step) => ({
165
+ $el: 'section',
166
+ if: '$stepIsEnabled("' + step + '")',
167
+ attrs: {
168
+ style: {
169
+ if: '$activeStep !== "' + step + '"',
170
+ then: 'display: none;'
171
+ }
172
+ }
173
+ });
174
+
175
+ function step(name, inputs, nextOnEnter = true) {
176
+ if (typeof nextOnEnter === 'undefined') {
177
+ nextOnEnter = true;
178
+ }
179
+ if (inputs && inputs.length && nextOnEnter) {
180
+ const lastInput = findLastInput(inputs[inputs.length - 1]);
181
+ lastInput.onKeypress = NEXT_ON_ENTER;
182
+ }
183
+
184
+ return merge(
185
+ stepDefaults(name),
186
+ {
187
+ children: [
188
+ {
189
+ $formkit: 'group',
190
+ id: name,
191
+ name: name,
192
+ children: inputs
193
+ }
194
+ ]
195
+ }
196
+ )
197
+ }
198
+
199
+ function comments(updates = {}) {
200
+ return step(
201
+ 'comments',
202
+ [
203
+ comments$1({
204
+ label: updates.label || DEFAULT_COMMENTS_LABEL,
205
+ placeholder: updates.placeholder || DEFAULT_COMMENTS_PLACEHOLDER_DYNAMIC
206
+ })
207
+ ],
208
+ updates.nextOnEnter
209
+ )
210
+ }
211
+
212
+ const formNavigationOnlySubmit = () => ({
213
+ $el: 'div',
214
+ attrs: {
215
+ class: 'step-nav'
216
+ },
217
+ children: [
218
+ {
219
+ $formkit: 'button',
220
+ name: 'hidden_button',
221
+ children: 'Hidden',
222
+ style: {
223
+ if: '$activeStep === $firstStep()',
224
+ then: 'visibility: hidden;'
225
+ }
226
+ },
227
+ {
228
+ $formkit: 'submit',
229
+ name: 'submit_button',
230
+ // TODO ability to customize this
231
+ label: 'Chat Now'
232
+ }
233
+ ]
234
+ });
235
+
236
+ const formDetails = () => ({
237
+ $el: 'pre',
238
+ if: '$urlParam("fdbg", "") == 1',
239
+ children: [
240
+ {
241
+ $el: 'pre',
242
+ children: '$stringify( $get(form).value )',
243
+ attrs: {
244
+ class: 't-text-xs',
245
+ style: 'overflow: scroll'
246
+ }
247
+ },
248
+ {
249
+ $el: 'pre',
250
+ children: ['activeStep: ', '$activeStep'],
251
+ attrs: {
252
+ class: 't-text-xs',
253
+ style: 'overflow: scroll'
254
+ }
255
+ },
256
+ {
257
+ $el: 'pre',
258
+ children: ['stepHistory: ', '$stepHistory'],
259
+ attrs: {
260
+ class: 't-text-xs',
261
+ style: 'overflow: scroll'
262
+ }
263
+ },
264
+ {
265
+ $el: 'pre',
266
+ children: ['stepQueue: ', '$stepQueue'],
267
+ attrs: {
268
+ class: 't-text-xs',
269
+ style: 'overflow: scroll'
270
+ }
271
+ }
272
+ ]
273
+ });
274
+
275
+ const schema = [
276
+ formAnchor(),
277
+ {
278
+ $cmp: 'FormKit',
279
+ props: formProps({
280
+ formId: 'appraisals',
281
+ redirectMap: {
282
+ '*': JAUrl('845633')
283
+ },
284
+ formClass: '!t-max-w-[36rem]'
285
+ }),
286
+ children: [
287
+ headline({
288
+ children: '$urlParam("hl", "Start Here for An Appraisal")',
289
+ if: '$activeStep === $firstStep()'
290
+ }),
291
+ subHeadline({
292
+ children: '$urlParam("shl", "Get a Valuation Within Minutes!")',
293
+ if: '$activeStep === $firstStep()'
294
+ }),
295
+ ...hiddenInputsAppraisals,
296
+ {
297
+ $el: 'div',
298
+ attrs: {
299
+ class: 'form-body'
300
+ },
301
+ children: [
302
+ comments({
303
+ label: 'Please describe your item in a few words:',
304
+ placeholder: 'Example: "I have a vintage painting, old coins, and a fine china set I would like appraised"',
305
+ nextOnEnter: false
306
+ }),
307
+ formNavigationOnlySubmit(),
308
+ formDetails()
309
+ ]
310
+ }
311
+ ]
312
+ }
313
+ ];
314
+
315
+ export { schema as default };
@@ -0,0 +1 @@
1
+ var appraisals=function(){"use strict";function e(){return Object.assign({},...arguments)}const t={type:"form",id:"form",config:{validationVisibility:"submit"},onSubmit:'$submit($submitUrl, $prepData, $handleRedirect, "text/plain; charset=UTF-8")',plugins:"$plugins",actions:!1,anchorElement:"form-anchor",prepop:{fromURL:!0},errorCodes:{403:{message:"An Error Occurred",abort:!1},409:{abort:!1},429:"An Error Occurred",504:{message:"An Error Occurred",abort:!1}},formClass:"!t-max-w-[40rem]"};const r={$el:"h1",attrs:{class:"t-flex t-justify-center t-text-center !t-text-[2rem] t-font-semibold t-pt-5 t-px-7 md:t-px-3"}};const i={$el:"h3",attrs:{class:"t-flex t-justify-center t-text-center !t-text-[1.2rem] t-font-medium t-text-blue-500 t-px-10"}};const l=[{$formkit:"hidden",name:"vertical",value:"Appraisals"},{$formkit:"hidden",name:"gclid",value:null},{$formkit:"hidden",name:"campaignid",value:null},{$formkit:"hidden",name:"s",value:null}],n=t=>(t=>e({$formkit:"textarea",rows:5,maxlength:500,validation:"required",validationMessages:{required:"Field is required"},innerClass:"t-max-w-xl",labelClass:"required"},t))(e({label:"Please briefly describe your situation in a few words:",name:"Comments",placeholder:'For Example: "I would like help with child support payments" or "I need help with visitation rights"'},t)),s=e=>"group"!==e.type&&"section"!==e.type&&"form"!==e.type&&"hidden"!==e.$formkit&&!e.children,a=e=>{if(s(e))return e;for(var t=e.children.length-1;t>=0;t--){if("string"==typeof e.children)continue;const r=e.children[t];if(s(r))return r;const i=a(r);if(i)return i}return null};const o=[e({$el:"div",children:[{$el:"div",attrs:{id:"form-anchor",class:"t-absolute",style:{top:"-30px",left:0}}}],attrs:{class:"t-relative"}},d),{$cmp:"FormKit",props:function(r){return e(t,r)}({formId:"appraisals",redirectMap:{"*":(c="845633","https://justanswer.9pctbx.net/c/2880795/"+c+"/9320?sharedid=${properties.vid}&subid1=${properties.Domain_Abbrev}")},formClass:"!t-max-w-[36rem]"}),children:[function(t){return e(r,t)}({children:'$urlParam("hl", "Start Here for An Appraisal")',if:"$activeStep === $firstStep()"}),function(t){return e(i,t)}({children:'$urlParam("shl", "Get a Valuation Within Minutes!")',if:"$activeStep === $firstStep()"}),...l,{$el:"div",attrs:{class:"form-body"},children:[function(t={}){return function(t,r,i=!0){void 0===i&&(i=!0),r&&r.length&&i&&(a(r[r.length-1]).onKeypress="$onEnter($setNextStep($fireStepEvent($get(form)), $preStepFunc($get(form))))");return e((e=>({$el:"section",if:'$stepIsEnabled("'+e+'")',attrs:{style:{if:'$activeStep !== "'+e+'"',then:"display: none;"}}}))(t),{children:[{$formkit:"group",id:t,name:t,children:r}]})}("comments",[n({label:t.label||"Please briefly describe your legal issue in a few words:",placeholder:t.placeholder||'$getKey($meta, "commentsPlaceholders." + $get(Type_Of_Legal_Problem).value, $meta.defaultCommentsPlaceholder)'})],t.nextOnEnter)}({label:"Please describe your item in a few words:",placeholder:'Example: "I have a vintage painting, old coins, and a fine china set I would like appraised"',nextOnEnter:!1}),{$el:"div",attrs:{class:"step-nav"},children:[{$formkit:"button",name:"hidden_button",children:"Hidden",style:{if:"$activeStep === $firstStep()",then:"visibility: hidden;"}},{$formkit:"submit",name:"submit_button",label:"Chat Now"}]},{$el:"pre",if:'$urlParam("fdbg", "") == 1',children:[{$el:"pre",children:"$stringify( $get(form).value )",attrs:{class:"t-text-xs",style:"overflow: scroll"}},{$el:"pre",children:["activeStep: ","$activeStep"],attrs:{class:"t-text-xs",style:"overflow: scroll"}},{$el:"pre",children:["stepHistory: ","$stepHistory"],attrs:{class:"t-text-xs",style:"overflow: scroll"}},{$el:"pre",children:["stepQueue: ","$stepQueue"],attrs:{class:"t-text-xs",style:"overflow: scroll"}}]}]}]}];var c,d;return o}();
@@ -0,0 +1 @@
1
+ [{"$el":"div","children":[{"$el":"div","attrs":{"id":"form-anchor","class":"t-absolute","style":{"top":"-30px","left":0}}}],"attrs":{"class":"t-relative"}},{"$cmp":"FormKit","props":{"type":"form","id":"form","config":{"validationVisibility":"submit"},"onSubmit":"$submit($submitUrl, $prepData, $handleRedirect, \"text/plain; charset=UTF-8\")","plugins":"$plugins","actions":false,"anchorElement":"form-anchor","prepop":{"fromURL":true},"errorCodes":{"403":{"message":"An Error Occurred","abort":false},"409":{"abort":false},"429":"An Error Occurred","504":{"message":"An Error Occurred","abort":false}},"formClass":"!t-max-w-[36rem]","formId":"appraisals","redirectMap":{"*":"https://justanswer.9pctbx.net/c/2880795/845633/9320?sharedid=${properties.vid}&subid1=${properties.Domain_Abbrev}"}},"children":[{"$el":"h1","attrs":{"class":"t-flex t-justify-center t-text-center !t-text-[2rem] t-font-semibold t-pt-5 t-px-7 md:t-px-3"},"children":"$urlParam(\"hl\", \"Start Here for An Appraisal\")","if":"$activeStep === $firstStep()"},{"$el":"h3","attrs":{"class":"t-flex t-justify-center t-text-center !t-text-[1.2rem] t-font-medium t-text-blue-500 t-px-10"},"children":"$urlParam(\"shl\", \"Get a Valuation Within Minutes!\")","if":"$activeStep === $firstStep()"},{"$formkit":"hidden","name":"vertical","value":"Appraisals"},{"$formkit":"hidden","name":"gclid","value":null},{"$formkit":"hidden","name":"campaignid","value":null},{"$formkit":"hidden","name":"s","value":null},{"$el":"div","attrs":{"class":"form-body"},"children":[{"$el":"section","if":"$stepIsEnabled(\"comments\")","attrs":{"style":{"if":"$activeStep !== \"comments\"","then":"display: none;"}},"children":[{"$formkit":"group","id":"comments","name":"comments","children":[{"$formkit":"textarea","rows":5,"maxlength":500,"validation":"required","validationMessages":{"required":"Field is required"},"innerClass":"t-max-w-xl","labelClass":"required","label":"Please describe your item in a few words:","name":"Comments","placeholder":"Example: \"I have a vintage painting, old coins, and a fine china set I would like appraised\""}]}]},{"$el":"div","attrs":{"class":"step-nav"},"children":[{"$formkit":"button","name":"hidden_button","children":"Hidden","style":{"if":"$activeStep === $firstStep()","then":"visibility: hidden;"}},{"$formkit":"submit","name":"submit_button","label":"Chat Now"}]},{"$el":"pre","if":"$urlParam(\"fdbg\", \"\") == 1","children":[{"$el":"pre","children":"$stringify( $get(form).value )","attrs":{"class":"t-text-xs","style":"overflow: scroll"}},{"$el":"pre","children":["activeStep: ","$activeStep"],"attrs":{"class":"t-text-xs","style":"overflow: scroll"}},{"$el":"pre","children":["stepHistory: ","$stepHistory"],"attrs":{"class":"t-text-xs","style":"overflow: scroll"}},{"$el":"pre","children":["stepQueue: ","$stepQueue"],"attrs":{"class":"t-text-xs","style":"overflow: scroll"}}]}]}]}]
@@ -191,7 +191,6 @@ const hiddenInputsLegal = [
191
191
  ...hiddenInputsBase
192
192
  ];
193
193
 
194
-
195
194
  const legalRedirectMapDefaults = {
196
195
  "properties.Type_Of_Legal_Problem": {
197
196
  'Adoption': JAUrl('565949'),
@@ -198,7 +198,6 @@ const hiddenInputsLegal = [
198
198
  ...hiddenInputsBase
199
199
  ];
200
200
 
201
-
202
201
  const legalRedirectMapDefaults = {
203
202
  "properties.Type_Of_Legal_Problem": {
204
203
  'Adoption': JAUrl('565949'),
@@ -205,7 +205,6 @@ const hiddenInputsLegal = [
205
205
  ...hiddenInputsBase
206
206
  ];
207
207
 
208
-
209
208
  const legalRedirectMapDefaults = {
210
209
  "properties.Type_Of_Legal_Problem": {
211
210
  'Adoption': JAUrl('565949'),
@@ -205,7 +205,6 @@ const hiddenInputsLegal = [
205
205
  ...hiddenInputsBase
206
206
  ];
207
207
 
208
-
209
208
  const legalRedirectMapDefaults = {
210
209
  "properties.Type_Of_Legal_Problem": {
211
210
  'Adoption': JAUrl('565949'),
@@ -198,7 +198,6 @@ const hiddenInputsLegal = [
198
198
  ...hiddenInputsBase
199
199
  ];
200
200
 
201
-
202
201
  const legalRedirectMapDefaults = {
203
202
  "properties.Type_Of_Legal_Problem": {
204
203
  'Adoption': JAUrl('565949'),
@@ -198,7 +198,6 @@ const hiddenInputsLegal = [
198
198
  ...hiddenInputsBase
199
199
  ];
200
200
 
201
-
202
201
  const legalRedirectMapDefaults = {
203
202
  "properties.Type_Of_Legal_Problem": {
204
203
  'Adoption': JAUrl('565949'),
@@ -198,7 +198,6 @@ const hiddenInputsLegal = [
198
198
  ...hiddenInputsBase
199
199
  ];
200
200
 
201
-
202
201
  const legalRedirectMapDefaults = {
203
202
  "properties.Type_Of_Legal_Problem": {
204
203
  'Adoption': JAUrl('565949'),
@@ -205,7 +205,6 @@ const hiddenInputsLegal = [
205
205
  ...hiddenInputsBase
206
206
  ];
207
207
 
208
-
209
208
  const legalRedirectMapDefaults = {
210
209
  "properties.Type_Of_Legal_Problem": {
211
210
  'Adoption': JAUrl('565949'),
@@ -205,7 +205,6 @@ const hiddenInputsLegal = [
205
205
  ...hiddenInputsBase
206
206
  ];
207
207
 
208
-
209
208
  const legalRedirectMapDefaults = {
210
209
  "properties.Type_Of_Legal_Problem": {
211
210
  'Adoption': JAUrl('565949'),
@@ -205,7 +205,6 @@ const hiddenInputsLegal = [
205
205
  ...hiddenInputsBase
206
206
  ];
207
207
 
208
-
209
208
  const legalRedirectMapDefaults = {
210
209
  "properties.Type_Of_Legal_Problem": {
211
210
  'Adoption': JAUrl('565949'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhl-forms",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },