minsky-webform-formkit 1.0.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.
- package/.pnp.cjs +11555 -0
- package/.pnp.loader.mjs +2126 -0
- package/LICENSE +21 -0
- package/README.md +324 -0
- package/dist/index.css +1 -0
- package/dist/index.js +1 -0
- package/package.json +55 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/FormKitPhoneEnhanced.js +100 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/FormKitPhoneEnhanced.vue +30 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/countryCodes.js +1214 -0
- package/src/components/FormKit/FormKitRecaptcha/FormKitRecaptcha.vue +46 -0
- package/src/components/Icon.vue +38 -0
- package/src/components/InfoTooltip.vue +16 -0
- package/src/components/MinksyWebformFormKit/MinskyWebformFormKit.vue +357 -0
- package/src/components/MinksyWebformFormKit/_MinskyWebformFormKit.js +282 -0
- package/src/composables/useExample.js +0 -0
- package/src/formkit.config.js +72 -0
- package/src/index.mjs +20 -0
- package/src/plugins/customLabelPlugin.js +42 -0
- package/src/plugins/htmlHelpPlugin.js +23 -0
- package/src/rules/iban.js +9 -0
- package/src/rules/insz.js +21 -0
- package/src/rules/phone.js +29 -0
- package/src/rules/time.js +79 -0
- package/src/rules/vat.js +42 -0
- package/src/styles/_functions.scss +96 -0
- package/src/styles/_mixins.scss +29 -0
- package/src/styles/_variables.scss +7 -0
- package/src/styles/main.scss +11 -0
- package/src/styles/webform-formkit-multistep.scss +98 -0
- package/src/styles/webform-formkit.scss +215 -0
- package/src/styles/webform.scss +400 -0
- package/src/utils/functions.js +78 -0
- package/src/utils/lodash.js +208 -0
- package/src/utils/messages.js +37 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
.bef-exposed-form,
|
|
2
|
+
.webform-formkit,
|
|
3
|
+
.webform {
|
|
4
|
+
/* ========================================================================= */
|
|
5
|
+
/* customize form here */
|
|
6
|
+
/* ========================================================================= */
|
|
7
|
+
--f-color: #000;
|
|
8
|
+
--f-markup-color: #000;
|
|
9
|
+
--f-input-text-color: #000;
|
|
10
|
+
--f-input-border-color: #000;
|
|
11
|
+
--f-input-border-width: 1px;
|
|
12
|
+
--f-input-border-radius: 0;
|
|
13
|
+
--f-input-padding: 0.4em 0.6em;
|
|
14
|
+
--f-input-outline: #808080 solid;
|
|
15
|
+
--f-input-background-color: transparent;
|
|
16
|
+
--f-input-font-family: inherit;
|
|
17
|
+
--f-input-font-size: 1.6rem;
|
|
18
|
+
--f-input-placeholder-color: #808080;
|
|
19
|
+
--f-input-placeholder-font-style: inherit;
|
|
20
|
+
--f-input-height: 2.3em;
|
|
21
|
+
--f-label-margin-bottom: 0.2em;
|
|
22
|
+
|
|
23
|
+
// description
|
|
24
|
+
--f-description-color: #000;
|
|
25
|
+
|
|
26
|
+
// submit btn
|
|
27
|
+
--f-submit-btn-background-color: #000;
|
|
28
|
+
--f-submit-btn-text-color: #fff;
|
|
29
|
+
--f-submit-btn-border-color: #000;
|
|
30
|
+
--f-submit-btn-border-width: 1px;
|
|
31
|
+
--f-submit-btn-border-radius: 0;
|
|
32
|
+
--f-submit-btn-font-family: inherit;
|
|
33
|
+
--f-submit-btn-min-width: 13.4rem; // must be defined for mobile devices
|
|
34
|
+
--f-submit-btn-min-height: 4.8rem; // must be defined for mobile devices
|
|
35
|
+
--f-submit-btn-hover-text-color: #000;
|
|
36
|
+
--f-submit-btn-hover-background-color: #fff;
|
|
37
|
+
--f-submit-btn-hover-border-color: #000;
|
|
38
|
+
--f-submit-btn-disabled-background-color: #e5e5e5;
|
|
39
|
+
|
|
40
|
+
// radio-buttons & check-boxes
|
|
41
|
+
--f-radio-check-border-color: #000;
|
|
42
|
+
--f-radio-check-background-color: #fff;
|
|
43
|
+
--f-radio-check-background-color-active: #e5e5e5;
|
|
44
|
+
--f-radio-check-decorater-height: 1.6rem;
|
|
45
|
+
|
|
46
|
+
// help element
|
|
47
|
+
--f-help-background-color: #000;
|
|
48
|
+
--f-help-color: #fff;
|
|
49
|
+
--f-help-border-color: #000;
|
|
50
|
+
|
|
51
|
+
// other
|
|
52
|
+
--f-form-gap: 1.5em;
|
|
53
|
+
--f-error-color: red;
|
|
54
|
+
--f-success-color: green;
|
|
55
|
+
|
|
56
|
+
// webform-fornkit props
|
|
57
|
+
--f-loader-color: #000;
|
|
58
|
+
|
|
59
|
+
// multistep
|
|
60
|
+
--f-multistep-background-color-tab: #e5e5e5;
|
|
61
|
+
--f-multistep-color-tab: #000;
|
|
62
|
+
--f-multistep-background-color-tab-active: #000;
|
|
63
|
+
--f-multistep-color-tab-active: #fff;
|
|
64
|
+
|
|
65
|
+
/* ========================================================================= */
|
|
66
|
+
/* styles */
|
|
67
|
+
/* ========================================================================= */
|
|
68
|
+
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
* {
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
form {
|
|
75
|
+
color: var(--f-color);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.form-item-markup,
|
|
79
|
+
.formkit-markup {
|
|
80
|
+
color: var(--f-markup-color);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// hide number input arrows
|
|
84
|
+
/* Chrome, Safari, Edge, Opera */
|
|
85
|
+
input::-webkit-outer-spin-button,
|
|
86
|
+
input::-webkit-inner-spin-button {
|
|
87
|
+
-webkit-appearance: none;
|
|
88
|
+
margin: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Firefox */
|
|
92
|
+
input[type='number'] {
|
|
93
|
+
-moz-appearance: textfield;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.formkit-outer,
|
|
97
|
+
.form-item {
|
|
98
|
+
select,
|
|
99
|
+
textarea,
|
|
100
|
+
input[elementtype='date'],
|
|
101
|
+
input[type='time'],
|
|
102
|
+
input[type='mask'],
|
|
103
|
+
input[type='date'],
|
|
104
|
+
input[type='number'],
|
|
105
|
+
input[type='text'],
|
|
106
|
+
input[type='email'],
|
|
107
|
+
input[type='tel'],
|
|
108
|
+
input[type='url'] {
|
|
109
|
+
background-color: var(--f-input-background-color);
|
|
110
|
+
border-color: var(--f-input-border-color);
|
|
111
|
+
border-width: var(--f-input-border-width);
|
|
112
|
+
color: var(--f-input-text-color);
|
|
113
|
+
font-family: var(--f-input-font-family);
|
|
114
|
+
font-size: var(--f-input-font-size);
|
|
115
|
+
padding: var(--f-input-padding);
|
|
116
|
+
border-radius: var(--f-input-border-radius);
|
|
117
|
+
appearance: none;
|
|
118
|
+
width: 100%;
|
|
119
|
+
box-shadow: none;
|
|
120
|
+
border-style: solid;
|
|
121
|
+
|
|
122
|
+
&::placeholder {
|
|
123
|
+
color: var(--f-input-placeholder-color);
|
|
124
|
+
font-style: var(--f-input-placeholder-font-style);
|
|
125
|
+
transition: opacity 0.25s ease;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:focus {
|
|
129
|
+
outline: var(--f-input-outline);
|
|
130
|
+
&::placeholder {
|
|
131
|
+
opacity: 0.5;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&.form-item--error {
|
|
136
|
+
select,
|
|
137
|
+
textarea,
|
|
138
|
+
input {
|
|
139
|
+
border-color: var(--f-error-color);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
select,
|
|
145
|
+
input[type='time'],
|
|
146
|
+
input[type='date'],
|
|
147
|
+
input[type='number'],
|
|
148
|
+
input[type='text'],
|
|
149
|
+
input[type='email'],
|
|
150
|
+
input[type='url'],
|
|
151
|
+
input[type='mask'],
|
|
152
|
+
input[type='tel'] {
|
|
153
|
+
height: var(--f-input-height);
|
|
154
|
+
line-height: 1.1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
input[type='time'],
|
|
158
|
+
input[type='date'] {
|
|
159
|
+
display: block;
|
|
160
|
+
min-width: 15rem;
|
|
161
|
+
line-height: 1.5em;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
input[type='date'] {
|
|
165
|
+
text-align: left;
|
|
166
|
+
display: flex;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
input::-webkit-date-and-time-value {
|
|
170
|
+
text-align: left;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.formkit-label,
|
|
174
|
+
> label {
|
|
175
|
+
margin-bottom: var(--f-label-margin-bottom);
|
|
176
|
+
padding-right: 0.6em;
|
|
177
|
+
display: inline-block;
|
|
178
|
+
|
|
179
|
+
.info-tooltip {
|
|
180
|
+
display: inline-block;
|
|
181
|
+
margin-left: 0.25em;
|
|
182
|
+
position: relative;
|
|
183
|
+
top: 0.3rem;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
select {
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
padding-right: 3rem;
|
|
190
|
+
min-width: 12rem;
|
|
191
|
+
background-image: svg('f-chevron-down');
|
|
192
|
+
background-repeat: no-repeat;
|
|
193
|
+
background-position: calc(100% - 1rem) center;
|
|
194
|
+
background-size: 0.7em;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
textarea {
|
|
198
|
+
display: flex;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.formkit-outer,
|
|
203
|
+
.formkit-actions,
|
|
204
|
+
.form-actions {
|
|
205
|
+
button[type='submit'],
|
|
206
|
+
input[type='submit'] {
|
|
207
|
+
background-color: var(--f-submit-btn-background-color);
|
|
208
|
+
color: var(--f-submit-btn-text-color);
|
|
209
|
+
border-width: var(--f-submit-btn-border-width);
|
|
210
|
+
border-color: var(--f-submit-btn-border-color);
|
|
211
|
+
font-family: var(--f-submit-btn-font-family);
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
appearance: none;
|
|
214
|
+
min-width: var(--f-submit-btn-min-width);
|
|
215
|
+
min-height: var(--f-submit-btn-min-height);
|
|
216
|
+
width: auto;
|
|
217
|
+
outline: none;
|
|
218
|
+
border-radius: var(--f-submit-btn-border-radius);
|
|
219
|
+
box-shadow: none;
|
|
220
|
+
|
|
221
|
+
&:focus,
|
|
222
|
+
&:active,
|
|
223
|
+
&:hover {
|
|
224
|
+
color: var(--f-submit-btn-hover-text-color);
|
|
225
|
+
background-color: var(--f-submit-btn-hover-background-color);
|
|
226
|
+
border-color: var(--f-submit-btn-hover-border-color);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&:disabled {
|
|
230
|
+
pointer-events: none;
|
|
231
|
+
opacity: 0.5;
|
|
232
|
+
background-color: var(--f-submit-btn-disabled-background-color);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.checkboxes--wrapper {
|
|
238
|
+
.form-item--checkbox {
|
|
239
|
+
margin-bottom: var(--f-radio-check-padding-bottom);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.webform-element-help {
|
|
244
|
+
background-color: var(--f-help-background-color);
|
|
245
|
+
border-color: var(--f-help-border-color);
|
|
246
|
+
color: var(--f-help-color);
|
|
247
|
+
font-weight: 400;
|
|
248
|
+
line-height: 1.2rem;
|
|
249
|
+
font-size: 1rem;
|
|
250
|
+
width: 1.5rem;
|
|
251
|
+
height: 1.5rem;
|
|
252
|
+
position: relative;
|
|
253
|
+
top: -2px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.form-text,
|
|
257
|
+
.form-textarea {
|
|
258
|
+
width: 100%;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.form-textarea {
|
|
262
|
+
resize: none;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.form-number::-webkit-inner-spin-button {
|
|
266
|
+
appearance: none;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.formkit-help,
|
|
270
|
+
.webform-element-description {
|
|
271
|
+
margin-top: 0.5em;
|
|
272
|
+
font-style: italic;
|
|
273
|
+
font-size: 1.4rem;
|
|
274
|
+
color: var(--f-description-color);
|
|
275
|
+
|
|
276
|
+
* {
|
|
277
|
+
font-size: 1.4rem;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.form-required {
|
|
282
|
+
&:after {
|
|
283
|
+
content: '*';
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.fieldset-legend {
|
|
288
|
+
font-weight: 700;
|
|
289
|
+
margin-bottom: 1em;
|
|
290
|
+
display: block;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.formkit-form,
|
|
294
|
+
fieldset {
|
|
295
|
+
display: grid;
|
|
296
|
+
gap: var(--f-form-gap);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
fieldset {
|
|
300
|
+
padding: 1.5rem;
|
|
301
|
+
border-color: var(--f-input-border-color);
|
|
302
|
+
border-width: var(--f-input-border-width);
|
|
303
|
+
border-radius: var(--f-input-border-radius);
|
|
304
|
+
|
|
305
|
+
legend {
|
|
306
|
+
font-size: 1em;
|
|
307
|
+
font-family: var(--f-input-font-family);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.form-item,
|
|
312
|
+
.radios--wrapper,
|
|
313
|
+
.checkboxes--wrapper,
|
|
314
|
+
.form-item--webform-time,
|
|
315
|
+
.form-item--webform-markup,
|
|
316
|
+
.form-item--checkbox,
|
|
317
|
+
.form-item--date,
|
|
318
|
+
.form-item--number,
|
|
319
|
+
.form-item--select,
|
|
320
|
+
.form-item--email,
|
|
321
|
+
.form-item--tel,
|
|
322
|
+
.form-item--textarea,
|
|
323
|
+
.form-item--textfield {
|
|
324
|
+
margin-top: var(--f-form-gap);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.form-item--datetime {
|
|
328
|
+
.form-item--date {
|
|
329
|
+
margin-right: 1rem;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.fieldgroup {
|
|
334
|
+
margin: 0 !important;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.form-actions,
|
|
338
|
+
.webform-actions {
|
|
339
|
+
margin-top: 2rem;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.formkit-messages {
|
|
343
|
+
margin-bottom: 0;
|
|
344
|
+
padding: 0;
|
|
345
|
+
margin: 0;
|
|
346
|
+
font-size: 1.4rem;
|
|
347
|
+
list-style-type: none;
|
|
348
|
+
color: var(--f-error-color);
|
|
349
|
+
margin-top: 0.5rem;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// flexbox paddings en margins
|
|
353
|
+
.webform-flexbox {
|
|
354
|
+
width: 100%;
|
|
355
|
+
@media (--bp-min-medium) {
|
|
356
|
+
margin: 0 -0.5em;
|
|
357
|
+
width: auto;
|
|
358
|
+
}
|
|
359
|
+
.webform-flexbox {
|
|
360
|
+
margin: 0;
|
|
361
|
+
padding-bottom: 0;
|
|
362
|
+
}
|
|
363
|
+
.webform-flex {
|
|
364
|
+
margin: 0;
|
|
365
|
+
.fieldgroup {
|
|
366
|
+
padding-bottom: 0;
|
|
367
|
+
}
|
|
368
|
+
.fieldset-wrapper {
|
|
369
|
+
margin: 0 -0.5em;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
hr {
|
|
375
|
+
width: 100%;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.form-item--error-message {
|
|
379
|
+
margin-top: 0.3em;
|
|
380
|
+
color: var(--f-error-color);
|
|
381
|
+
font-size: 1.2rem;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.captcha {
|
|
385
|
+
padding: 0;
|
|
386
|
+
margin: 0;
|
|
387
|
+
border: 0;
|
|
388
|
+
margin-bottom: var(--f-form-gap);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.captcha__title {
|
|
392
|
+
display: none;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.captcha__description {
|
|
396
|
+
font-size: 1.2rem;
|
|
397
|
+
max-width: 40rem;
|
|
398
|
+
margin-top: 0.5rem;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export function flattenObject(obj) {
|
|
2
|
+
const flattened = {};
|
|
3
|
+
|
|
4
|
+
function flatten(obj, parentKey = '') {
|
|
5
|
+
for (const key in obj) {
|
|
6
|
+
if (Array.isArray(obj[key])) {
|
|
7
|
+
flattened[key] = obj[key];
|
|
8
|
+
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
9
|
+
flatten(obj[key], `${parentKey + key}.`);
|
|
10
|
+
} else {
|
|
11
|
+
flattened[key] = obj[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
flatten(obj);
|
|
17
|
+
return flattened;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function hasValue(val) {
|
|
21
|
+
let hasValue = false;
|
|
22
|
+
if (val || val === 0) {
|
|
23
|
+
hasValue = true;
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(val)) {
|
|
26
|
+
hasValue = true;
|
|
27
|
+
}
|
|
28
|
+
return hasValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function cleanClass(name) {
|
|
32
|
+
return name.toLowerCase().replace(/\s/g, '-').replace('_', '-');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// setUserData(data) {
|
|
36
|
+
// // get current userData and merge with new form data
|
|
37
|
+
// const userData = JSON.parse(window.localStorage.getItem('userData')) || {};
|
|
38
|
+
// data = _merge(userData, data);
|
|
39
|
+
|
|
40
|
+
// // do not save hidden fields and other fields in localStorage
|
|
41
|
+
// delete data.petitions;
|
|
42
|
+
// delete data.free_text_value_1;
|
|
43
|
+
// delete data.free_text_value_2;
|
|
44
|
+
// delete data.free_text_value_3;
|
|
45
|
+
// delete data.free_text_value_4;
|
|
46
|
+
// delete data.free_text_value_5;
|
|
47
|
+
// delete data.yes_no_value_1;
|
|
48
|
+
// delete data.yes_no_value_2;
|
|
49
|
+
// delete data.yes_no_value_3;
|
|
50
|
+
// delete data.yes_no_value_4;
|
|
51
|
+
// delete data.yes_no_value_5;
|
|
52
|
+
// delete data.int_value_1;
|
|
53
|
+
// delete data.int_value_2;
|
|
54
|
+
// delete data.int_value_3;
|
|
55
|
+
// delete data.int_value_4;
|
|
56
|
+
// delete data.int_value_5;
|
|
57
|
+
// delete data.privacy_verklaring;
|
|
58
|
+
// delete data.more_information;
|
|
59
|
+
// delete data.organisation_number;
|
|
60
|
+
// delete data.rijkregisternummer;
|
|
61
|
+
|
|
62
|
+
// // delete certain field types
|
|
63
|
+
// this.schema[0].children.forEach(item => {
|
|
64
|
+
// if (item.$formkit === 'multi-step') {
|
|
65
|
+
// // loop through children from multisteps
|
|
66
|
+
// item.children.forEach(step => {
|
|
67
|
+
// step.children.forEach(stepItem => {
|
|
68
|
+
// deletePropFromSubmittedData(data, stepItem);
|
|
69
|
+
// });
|
|
70
|
+
// });
|
|
71
|
+
// } else {
|
|
72
|
+
// // loop trouph form elements outside multistep
|
|
73
|
+
// deletePropFromSubmittedData(data, item);
|
|
74
|
+
// }
|
|
75
|
+
// });
|
|
76
|
+
|
|
77
|
+
// window.localStorage.setItem('userData', JSON.stringify(data));
|
|
78
|
+
// }
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deeply merges source objects into the target object.
|
|
3
|
+
*
|
|
4
|
+
* Behavior:
|
|
5
|
+
* - plain objects are merged recursively
|
|
6
|
+
* - arrays are concatenated
|
|
7
|
+
* - primitive values are overwritten by the latest source
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} target - object to merge into
|
|
10
|
+
* @param {...Object} sources - source objects
|
|
11
|
+
* @returns {Object} merged target object
|
|
12
|
+
*/
|
|
13
|
+
export function _merge(target, ...sources) {
|
|
14
|
+
if (!isObject(target) && !Array.isArray(target)) {
|
|
15
|
+
target = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const source of sources) {
|
|
19
|
+
if (!isObject(source) && !Array.isArray(source)) continue;
|
|
20
|
+
|
|
21
|
+
for (const key of Object.keys(source)) {
|
|
22
|
+
const srcValue = source[key];
|
|
23
|
+
const tgtValue = target[key];
|
|
24
|
+
|
|
25
|
+
// merge arrays by concatenation
|
|
26
|
+
if (Array.isArray(srcValue)) {
|
|
27
|
+
if (Array.isArray(tgtValue)) {
|
|
28
|
+
target[key] = [...tgtValue, ...srcValue];
|
|
29
|
+
} else {
|
|
30
|
+
target[key] = [...srcValue];
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// merge plain objects recursively
|
|
36
|
+
if (isObject(srcValue)) {
|
|
37
|
+
if (!isObject(tgtValue)) {
|
|
38
|
+
target[key] = {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
target[key] = _merge(target[key], srcValue);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// overwrite primitives
|
|
46
|
+
target[key] = srcValue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return target;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Removes all elements from an array that match any value in the given values array.
|
|
55
|
+
* Modifies the original array in place.
|
|
56
|
+
*
|
|
57
|
+
* @param {Array} array - the array to modify
|
|
58
|
+
* @param {Array} values - values to remove from the array
|
|
59
|
+
* @returns {Array} - the modified array
|
|
60
|
+
*/
|
|
61
|
+
export function _pullAll(array, values) {
|
|
62
|
+
if (!Array.isArray(array) || !Array.isArray(values)) {
|
|
63
|
+
return array;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let index = 0;
|
|
67
|
+
|
|
68
|
+
while (index < array.length) {
|
|
69
|
+
if (values.includes(array[index])) {
|
|
70
|
+
array.splice(index, 1);
|
|
71
|
+
} else {
|
|
72
|
+
index++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return array;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Creates a shallow clone of a value.
|
|
81
|
+
* - Primitives and functions are returned as-is.
|
|
82
|
+
* - Arrays are shallow-copied.
|
|
83
|
+
* - Plain objects are shallow-copied.
|
|
84
|
+
*
|
|
85
|
+
* @param {*} value - value to clone
|
|
86
|
+
* @returns {*} - cloned value
|
|
87
|
+
*/
|
|
88
|
+
export function _clone(value) {
|
|
89
|
+
// Primitives and functions are returned directly
|
|
90
|
+
if (value === null || typeof value !== 'object') {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Array clone
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
return value.slice();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Object clone (shallow)
|
|
100
|
+
const result = {};
|
|
101
|
+
|
|
102
|
+
Object.keys(value).forEach(key => {
|
|
103
|
+
result[key] = value[key];
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Converts a string to kebab-case.
|
|
111
|
+
* - Replaces non-alphanumeric characters with spaces.
|
|
112
|
+
* - Inserts spaces between lowercase-uppercase transitions.
|
|
113
|
+
* - Converts to lowercase and joins with hyphens.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} str - input string
|
|
116
|
+
* @returns {string} - kebab-case string
|
|
117
|
+
*/
|
|
118
|
+
export function _kebabCase(str) {
|
|
119
|
+
if (typeof str !== 'string') return '';
|
|
120
|
+
|
|
121
|
+
return str
|
|
122
|
+
// Replace separators and transitions between lowercase-uppercase
|
|
123
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
124
|
+
// Replace non-alphanumeric characters with space
|
|
125
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
126
|
+
// Trim spaces
|
|
127
|
+
.trim()
|
|
128
|
+
// Split into words
|
|
129
|
+
.split(/\s+/)
|
|
130
|
+
// Convert to lowercase
|
|
131
|
+
.map(word => word.toLowerCase())
|
|
132
|
+
// Join with hyphen
|
|
133
|
+
.join('-');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns an array of an object's own enumerable property names.
|
|
138
|
+
* Safe for null/undefined objects.
|
|
139
|
+
*
|
|
140
|
+
* @param {Object} obj - object to get keys from
|
|
141
|
+
* @returns {string[]} - array of keys
|
|
142
|
+
*/
|
|
143
|
+
export const _keys = obj => obj == null ? [] : Object.keys(Object(obj));
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Returns a new object containing only the specified keys from the source object.
|
|
147
|
+
* Accepts a single key or an array of keys.
|
|
148
|
+
* Safe for null/undefined objects.
|
|
149
|
+
*
|
|
150
|
+
* @param {Object} obj - source object
|
|
151
|
+
* @param {string[] | string} keys - key(s) to pick
|
|
152
|
+
* @returns {Object} - object with selected keys
|
|
153
|
+
*/
|
|
154
|
+
export function _pick(obj, keys) {
|
|
155
|
+
if (obj == null) return {};
|
|
156
|
+
if (!Array.isArray(keys)) keys = [keys];
|
|
157
|
+
|
|
158
|
+
const result = {};
|
|
159
|
+
for (const key of keys) {
|
|
160
|
+
if (key in obj) {
|
|
161
|
+
result[key] = obj[key];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Recursively assigns default values from source objects to the target object.
|
|
169
|
+
* - Only sets a key if the target's value is undefined.
|
|
170
|
+
* - Merges nested objects recursively.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} target - target object
|
|
173
|
+
* @param {...Object} sources - source objects
|
|
174
|
+
* @returns {Object} - target object with defaults applied
|
|
175
|
+
*/
|
|
176
|
+
export function _defaultsDeep(target, ...sources) {
|
|
177
|
+
if (target == null) target = {};
|
|
178
|
+
|
|
179
|
+
for (const source of sources) {
|
|
180
|
+
if (source == null) continue;
|
|
181
|
+
|
|
182
|
+
for (const key of Object.keys(source)) {
|
|
183
|
+
const srcVal = source[key];
|
|
184
|
+
const tgtVal = target[key];
|
|
185
|
+
|
|
186
|
+
if (tgtVal === undefined) {
|
|
187
|
+
// copy value if undefined
|
|
188
|
+
target[key] = srcVal;
|
|
189
|
+
} else if (isObject(tgtVal) && isObject(srcVal)) {
|
|
190
|
+
// recurse into nested objects
|
|
191
|
+
_defaultsDeep(tgtVal, srcVal);
|
|
192
|
+
}
|
|
193
|
+
// otherwise, keep existing target value
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return target;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Helper to check if a value is a plain object (non-null, non-array).
|
|
202
|
+
*
|
|
203
|
+
* @param {*} val - value to check
|
|
204
|
+
* @returns {boolean} - true if plain object
|
|
205
|
+
*/
|
|
206
|
+
function isObject(val) {
|
|
207
|
+
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
208
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
global: {
|
|
3
|
+
editor: {
|
|
4
|
+
error: 'Check that the form has been completed correctly. Ensure that no unnecessary conditional fields have been filled in.'
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
nl: {
|
|
8
|
+
messages: {
|
|
9
|
+
missing: 'Dit formulier ontbreekt. Controleer of het ID dat u gebruikt correct is.',
|
|
10
|
+
error: 'Er is iets misgegaan bij het laden van het formulier.'
|
|
11
|
+
},
|
|
12
|
+
success: {
|
|
13
|
+
title: 'Bedankt!',
|
|
14
|
+
message: 'We hebben je gegevens goed ontvangen.',
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
en: {
|
|
18
|
+
messages: {
|
|
19
|
+
missing: 'This form is missing. Please check that the ID you are using is correct.',
|
|
20
|
+
error: 'Something went wrong while loading the form.'
|
|
21
|
+
},
|
|
22
|
+
success: {
|
|
23
|
+
title: 'Thank you!',
|
|
24
|
+
message: 'We have successfully received your information.',
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
fr: {
|
|
28
|
+
messages: {
|
|
29
|
+
missing: "Ce formulaire est manquant. Vérifiez que l'ID que vous utilisez est correct.",
|
|
30
|
+
error: "Une erreur est survenue lors du chargement du formulaire."
|
|
31
|
+
},
|
|
32
|
+
success: {
|
|
33
|
+
title: "Merci !",
|
|
34
|
+
message: "Nous avons bien reçu vos informations.",
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}
|