@crystaldesign/widget-contact-form 25.2.0-rc.4 → 25.2.0-rc.5
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/build/esm/index.js
CHANGED
|
@@ -48,9 +48,13 @@ function styleInject(css, ref) {
|
|
|
48
48
|
var form = "form-B77D-";
|
|
49
49
|
var input = "input-oPXuT";
|
|
50
50
|
var textarea = "textarea-cMW-q";
|
|
51
|
+
var inputGroup = "inputGroup-gO790";
|
|
51
52
|
var button = "button-fOW5S";
|
|
52
53
|
var agbContainer = "agbContainer--O-xN";
|
|
53
|
-
var
|
|
54
|
+
var checkAgbText = "checkAgbText-Jl3wz";
|
|
55
|
+
var errorBox = "errorBox-hMx0W";
|
|
56
|
+
var errorMailValidation = "errorMailValidation-HNoLo";
|
|
57
|
+
var css_248z = ".form-B77D- {\n display: flex;\n flex-direction: column;\n padding: 10px;\n gap: 1.3rem;\n font-family: 'Roboto';\n}\n\n.input-oPXuT,\n.textarea-cMW-q {\n padding: 0.5rem;\n border: 1px solid #ccc;\n}\n\n.inputGroup-gO790 {\n display: flex;\n flex-direction: column;\n}\n.textarea-cMW-q {\n min-height: 150px;\n font-family: 'Roboto';\n resize: none;\n}\n\n.button-fOW5S {\n padding: 0.75rem;\n background-color: #6c757d;\n background-color: var(--primaryColor, #6c757d);\n color: white;\n border: none;\n cursor: pointer;\n}\n\n.button-fOW5S:disabled {\n background-color: #ccc;\n cursor: not-allowed;\n color: #666;\n}\n\n.button-fOW5S:enabled:hover {\n background-color: #5a6268;\n background-color: var(--primaryColor, #5a6268);\n}\n\n.agbContainer--O-xN {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n gap: 10px;\n}\n.agbContainer--O-xN input {\n transform: scale(1.5);\n}\n\n.checkAgbText-Jl3wz {\n display: flex;\n flex-direction: column;\n font-size: 12px;\n}\n\n.errorBox-hMx0W {\n background-color: #fdecea; /* Helles Rot */\n border-left: 4px solid #e53e3e; /* Dunkelrote linke Linie */\n color: #b71c1c; /* Kräftiges Rot für den Text */\n padding: 10px;\n border-radius: 6px;\n font-weight: bold;\n}\n.errorMailValidation-HNoLo {\n color: #d9534f; /* Dezentes Rot */\n font-size: 13px; /* Kleine Schrift */\n margin-top: 4px;\n font-weight: 500; /* Etwas kräftiger für bessere Lesbarkeit */\n}\n";
|
|
54
58
|
styleInject(css_248z);
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -195,29 +199,27 @@ function useContactForm(settings) {
|
|
|
195
199
|
_context.next = 7;
|
|
196
200
|
return sendMail(apiConfig.messageService, jwt, organization._id, variant === 'CLIENT' ? email : contactFormSettings.mailTo, variant, data, attachments, (_ref = i18n.language.toUpperCase()) !== null && _ref !== void 0 ? _ref : 'DE');
|
|
197
201
|
case 7:
|
|
202
|
+
toggleLoading('sendMail');
|
|
198
203
|
openModal({
|
|
199
204
|
content: t('modal.success.sendingcontactform'),
|
|
200
205
|
accept: true
|
|
201
206
|
});
|
|
202
|
-
_context.next =
|
|
207
|
+
_context.next = 15;
|
|
203
208
|
break;
|
|
204
|
-
case
|
|
205
|
-
_context.prev =
|
|
209
|
+
case 11:
|
|
210
|
+
_context.prev = 11;
|
|
206
211
|
_context.t0 = _context["catch"](0);
|
|
212
|
+
toggleLoading('sendMail');
|
|
207
213
|
openModal({
|
|
208
214
|
title: t('Error'),
|
|
209
215
|
content: t('modal.error.sendingcontactform') + _context.t0,
|
|
210
216
|
accept: true
|
|
211
217
|
});
|
|
212
|
-
case
|
|
213
|
-
_context.prev = 13;
|
|
214
|
-
toggleLoading('sendMail');
|
|
215
|
-
return _context.finish(13);
|
|
216
|
-
case 16:
|
|
218
|
+
case 15:
|
|
217
219
|
case "end":
|
|
218
220
|
return _context.stop();
|
|
219
221
|
}
|
|
220
|
-
}, _callee, null, [[0,
|
|
222
|
+
}, _callee, null, [[0, 11]]);
|
|
221
223
|
}));
|
|
222
224
|
return _sendEMail.apply(this, arguments);
|
|
223
225
|
}
|
|
@@ -243,9 +245,14 @@ function useContactForm(settings) {
|
|
|
243
245
|
}
|
|
244
246
|
return undefined;
|
|
245
247
|
}
|
|
248
|
+
var validateEmail = function validateEmail(email) {
|
|
249
|
+
var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
250
|
+
return regex.test(email);
|
|
251
|
+
};
|
|
246
252
|
return {
|
|
247
253
|
sendEMail: sendEMail,
|
|
248
|
-
navigationConfiguration: navigationConfiguration
|
|
254
|
+
navigationConfiguration: navigationConfiguration,
|
|
255
|
+
validateEmail: validateEmail
|
|
249
256
|
};
|
|
250
257
|
}
|
|
251
258
|
|
|
@@ -261,31 +268,50 @@ var MainComponent = function MainComponent(_ref) {
|
|
|
261
268
|
t = _useTranslation.t;
|
|
262
269
|
var _useContactForm = useContactForm(settings),
|
|
263
270
|
sendEMail = _useContactForm.sendEMail,
|
|
264
|
-
navigationConfiguration = _useContactForm.navigationConfiguration
|
|
271
|
+
navigationConfiguration = _useContactForm.navigationConfiguration,
|
|
272
|
+
validateEmail = _useContactForm.validateEmail;
|
|
265
273
|
var _useState = useState(''),
|
|
266
274
|
_useState2 = _slicedToArray(_useState, 2),
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
error = _useState2[0],
|
|
276
|
+
setError = _useState2[1];
|
|
269
277
|
var _useState3 = useState(''),
|
|
270
278
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
271
|
-
|
|
272
|
-
|
|
279
|
+
name = _useState4[0],
|
|
280
|
+
setName = _useState4[1];
|
|
273
281
|
var _useState5 = useState(''),
|
|
274
282
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var _useState7 = useState(
|
|
283
|
+
email = _useState6[0],
|
|
284
|
+
setEmail = _useState6[1];
|
|
285
|
+
var _useState7 = useState(''),
|
|
278
286
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
279
|
-
|
|
280
|
-
|
|
287
|
+
message = _useState8[0],
|
|
288
|
+
setMessage = _useState8[1];
|
|
289
|
+
var _useState9 = useState(false),
|
|
290
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
291
|
+
acceptAgbs = _useState10[0],
|
|
292
|
+
setAcceptAgbs = _useState10[1];
|
|
293
|
+
var _useState11 = useState(''),
|
|
294
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
295
|
+
emailError = _useState12[0],
|
|
296
|
+
setEmailError = _useState12[1];
|
|
297
|
+
var inputOk = name && validateEmail(email) && message && acceptAgbs;
|
|
298
|
+
var handleEmailChange = function handleEmailChange(e) {
|
|
299
|
+
var value = e.target.value;
|
|
300
|
+
setEmail(value);
|
|
301
|
+
if (!validateEmail(value)) {
|
|
302
|
+
setEmailError(t('input.mail.validation.error'));
|
|
303
|
+
} else {
|
|
304
|
+
setEmailError('');
|
|
305
|
+
}
|
|
306
|
+
};
|
|
281
307
|
var handleSubmit = function handleSubmit() {
|
|
282
308
|
if (action === 'SEND_MAIL') {
|
|
283
|
-
if (
|
|
309
|
+
if (inputOk) {
|
|
284
310
|
var attachments = basket !== null && basket !== void 0 && basket.PDFDocumentURL ? [basket === null || basket === void 0 ? void 0 : basket.PDFDocumentURL] : undefined;
|
|
285
311
|
sendEMail(name, email, message, 'DEFAULT', attachments, basket === null || basket === void 0 ? void 0 : basket.DivaNr);
|
|
286
312
|
sendEMail(name, email, message, 'CLIENT', attachments, undefined);
|
|
287
313
|
} else {
|
|
288
|
-
|
|
314
|
+
setError(t('contactform.error.fields'));
|
|
289
315
|
}
|
|
290
316
|
} else if (onSubmit) {
|
|
291
317
|
onSubmit({
|
|
@@ -299,7 +325,6 @@ var MainComponent = function MainComponent(_ref) {
|
|
|
299
325
|
children: [title && /*#__PURE__*/jsx("h2", {
|
|
300
326
|
children: t(title, title)
|
|
301
327
|
}), /*#__PURE__*/jsxs("div", {
|
|
302
|
-
id: "contactForm",
|
|
303
328
|
className: form,
|
|
304
329
|
children: [/*#__PURE__*/jsx("input", {
|
|
305
330
|
type: "text",
|
|
@@ -311,16 +336,20 @@ var MainComponent = function MainComponent(_ref) {
|
|
|
311
336
|
required: true,
|
|
312
337
|
className: input,
|
|
313
338
|
placeholder: t('contactform.placeholder.name')
|
|
314
|
-
}), /*#__PURE__*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
339
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
340
|
+
className: inputGroup,
|
|
341
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
342
|
+
type: "email",
|
|
343
|
+
id: "email",
|
|
344
|
+
value: email,
|
|
345
|
+
onChange: handleEmailChange,
|
|
346
|
+
required: true,
|
|
347
|
+
className: input,
|
|
348
|
+
placeholder: t('contactform.placeholder.email')
|
|
349
|
+
}), emailError && /*#__PURE__*/jsx("div", {
|
|
350
|
+
className: errorMailValidation,
|
|
351
|
+
children: emailError
|
|
352
|
+
})]
|
|
324
353
|
}), /*#__PURE__*/jsx("textarea", {
|
|
325
354
|
id: "message",
|
|
326
355
|
value: message,
|
|
@@ -339,18 +368,11 @@ var MainComponent = function MainComponent(_ref) {
|
|
|
339
368
|
onChange: function onChange(e) {
|
|
340
369
|
return setAcceptAgbs(e.target.checked);
|
|
341
370
|
},
|
|
342
|
-
required: true
|
|
343
|
-
style: {
|
|
344
|
-
transform: 'scale(1.5)'
|
|
345
|
-
}
|
|
371
|
+
required: true
|
|
346
372
|
}), /*#__PURE__*/jsx("label", {
|
|
347
373
|
htmlFor: "acceptAgbs",
|
|
348
374
|
children: /*#__PURE__*/jsxs("div", {
|
|
349
|
-
|
|
350
|
-
display: 'flex',
|
|
351
|
-
flexDirection: 'column',
|
|
352
|
-
fontSize: 12
|
|
353
|
-
},
|
|
375
|
+
className: checkAgbText,
|
|
354
376
|
children: [/*#__PURE__*/jsx("span", {
|
|
355
377
|
children: t('auth.acceptprivacyandagb')
|
|
356
378
|
}), /*#__PURE__*/jsxs("span", {
|
|
@@ -366,12 +388,15 @@ var MainComponent = function MainComponent(_ref) {
|
|
|
366
388
|
})]
|
|
367
389
|
})
|
|
368
390
|
})]
|
|
391
|
+
}), error && /*#__PURE__*/jsx("div", {
|
|
392
|
+
className: errorBox,
|
|
393
|
+
children: error
|
|
369
394
|
}), /*#__PURE__*/jsx("button", {
|
|
370
395
|
type: "submit",
|
|
371
396
|
id: "submitButton",
|
|
372
397
|
className: button,
|
|
373
398
|
onClick: handleSubmit,
|
|
374
|
-
disabled: !
|
|
399
|
+
disabled: !inputOk,
|
|
375
400
|
children: submitButtonText ? t(submitButtonText, submitButtonText) : t('contactform.submitbuttontext')
|
|
376
401
|
})]
|
|
377
402
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAI5C,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAiGpD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default function useContactForm(settings?: any): {
|
|
2
2
|
sendEMail: (name: string, email: string, message: string, variant: string, attachments?: string[], divaNr?: string) => Promise<void>;
|
|
3
3
|
navigationConfiguration: import("packages/core/src/types").NavigationConfiguration;
|
|
4
|
+
validateEmail: (email: string) => boolean;
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=useContactForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContactForm.d.ts","sourceRoot":"","sources":["../../../../src/useContactForm.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,CAAC,EAAE,GAAG;sBA0BpB,MAAM,SAAS,MAAM,WAAW,MAAM,WAAW,MAAM,gBAAgB,MAAM,EAAE,WAAW,MAAM;;
|
|
1
|
+
{"version":3,"file":"useContactForm.d.ts","sourceRoot":"","sources":["../../../../src/useContactForm.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,QAAQ,CAAC,EAAE,GAAG;sBA0BpB,MAAM,SAAS,MAAM,WAAW,MAAM,WAAW,MAAM,gBAAgB,MAAM,EAAE,WAAW,MAAM;;2BA2CjG,MAAM;EAMrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/widget-contact-form",
|
|
3
|
-
"version": "25.2.0-rc.
|
|
3
|
+
"version": "25.2.0-rc.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"storybook": "storybook dev -p 6006",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
},
|
|
28
28
|
"module": "build/esm/index.js",
|
|
29
29
|
"types": "./build/types/widget-contact-form/src/index.d.ts",
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "527d19211a04e6f8748b2a8c33cf73084d549fc5"
|
|
31
31
|
}
|