@mrfylke/contact-form 0.1.32 → 0.1.34
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 +0 -22
- package/lib/commoneEvents.d.ts +1 -1
- package/lib/commoneEvents.d.ts.map +1 -1
- package/lib/components/form/date-selector.d.ts +4 -1
- package/lib/components/form/date-selector.d.ts.map +1 -1
- package/lib/components/form/date-selector.js +2 -2
- package/lib/components/form/file-input.js +1 -1
- package/lib/components/form/form.module.css +0 -74
- package/lib/components/form/input.d.ts +2 -6
- package/lib/components/form/input.d.ts.map +1 -1
- package/lib/components/form/input.js +7 -22
- package/lib/components/form/textarea.d.ts +3 -2
- package/lib/components/form/textarea.d.ts.map +1 -1
- package/lib/components/form/textarea.js +6 -4
- package/lib/components/form/time-selector.d.ts.map +1 -1
- package/lib/components/form/time-selector.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/journey-info/journeyInfoStateMachine.d.ts +2 -2
- package/lib/layouts/contact-pages.d.ts.map +1 -1
- package/lib/layouts/contact-pages.js +7 -2
- package/lib/lines/use-lines.d.ts +1 -0
- package/lib/lines/use-lines.d.ts.map +1 -1
- package/lib/lines/use-lines.js +1 -0
- package/lib/lost-property/LostPropertyForm.d.ts +6 -0
- package/lib/lost-property/LostPropertyForm.d.ts.map +1 -1
- package/lib/lost-property/LostPropertyForm.js +54 -12
- package/lib/lost-property/LostPropertyMachine.d.ts +5 -4
- package/lib/lost-property/LostPropertyMachine.d.ts.map +1 -1
- package/lib/lost-property/LostPropertyMachine.js +5 -1
- package/lib/lost-property/index.d.ts.map +1 -1
- package/lib/lost-property/index.js +40 -3
- package/lib/means-of-transport/forms/injuryForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/injuryForm.js +1 -1
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts +2 -2
- package/lib/modules/api-browser/index.d.ts +1 -1
- package/lib/modules/api-browser/index.d.ts.map +1 -1
- package/lib/modules/api-browser/index.js +5 -1
- package/lib/modules/config/context.d.ts.map +1 -1
- package/lib/modules/config/context.js +1 -4
- package/lib/modules/config/theme-adapter.d.ts.map +1 -1
- package/lib/modules/config/theme-adapter.js +2 -0
- package/lib/modules/config/types.d.ts +53 -8
- package/lib/modules/config/types.d.ts.map +1 -1
- package/lib/modules/transport-mode/utils.d.ts +2 -2
- package/lib/modules/transport-mode/utils.d.ts.map +1 -1
- package/lib/refund/events.d.ts +3 -3
- package/lib/refund/events.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/index.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/index.js +10 -3
- package/lib/refund/forms/refund-and-travel-guarantee/pre-purchased-ticket-refund-form/index.d.ts +11 -0
- package/lib/refund/forms/refund-and-travel-guarantee/pre-purchased-ticket-refund-form/index.d.ts.map +1 -0
- package/lib/refund/forms/refund-and-travel-guarantee/pre-purchased-ticket-refund-form/index.js +159 -0
- package/lib/refund/forms/refund-and-travel-guarantee/pre-purchased-ticket-refund-form/pre-purchased-ticket-refund-form.module.css +73 -0
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.js +2 -2
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundTaxiForm.js +2 -2
- package/lib/refund/forms/refund-ticket/appTicketRefund.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/appTicketRefund.js +13 -15
- package/lib/refund/forms/refund-ticket/otherTicketRefund.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/otherTicketRefund.js +16 -13
- package/lib/refund/index.d.ts.map +1 -1
- package/lib/refund/index.js +6 -4
- package/lib/refund/refundFormMachine.d.ts +49 -13
- package/lib/refund/refundFormMachine.d.ts.map +1 -1
- package/lib/refund/refundFormMachine.js +75 -9
- package/lib/server/journey-planner/entur-client.d.ts +2 -1
- package/lib/server/journey-planner/entur-client.d.ts.map +1 -1
- package/lib/ticket-control/forms/feeComplaintForm.js +4 -10
- package/lib/ticket-control/forms/postponePayment.d.ts.map +1 -1
- package/lib/ticket-control/forms/postponePayment.js +2 -6
- package/lib/ticket-control/ticket-control-form-machine.d.ts +2 -2
- package/lib/ticketing/forms/app/appAccountForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/appAccountForm.js +1 -3
- package/lib/ticketing/forms/app/appTicketingForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/appTicketingForm.js +2 -8
- package/lib/ticketing/forms/app/appTravelSuggestionForm.d.ts.map +1 -1
- package/lib/ticketing/forms/app/appTravelSuggestionForm.js +5 -1
- package/lib/ticketing/forms/priceAndTicketTypesForm.d.ts.map +1 -1
- package/lib/ticketing/forms/priceAndTicketTypesForm.js +5 -1
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.d.ts.map +1 -1
- package/lib/ticketing/forms/travel-card/travelCardQuestionForm.js +5 -8
- package/lib/ticketing/forms/webshop/webshopAccountForm.d.ts.map +1 -1
- package/lib/ticketing/forms/webshop/webshopAccountForm.js +1 -3
- package/lib/ticketing/forms/webshop/webshopTicketingForm.d.ts.map +1 -1
- package/lib/ticketing/forms/webshop/webshopTicketingForm.js +2 -7
- package/lib/ticketing/index.d.ts.map +1 -1
- package/lib/ticketing/index.js +8 -2
- package/lib/ticketing/ticketingStateMachine.d.ts +4 -2
- package/lib/ticketing/ticketingStateMachine.d.ts.map +1 -1
- package/lib/ticketing/ticketingStateMachine.js +4 -1
- package/lib/translations/commons.d.ts +1 -1
- package/lib/translations/commons.d.ts.map +1 -1
- package/lib/translations/commons.js +3 -1
- package/lib/translations/language-context.d.ts +2 -2
- package/lib/translations/language-context.d.ts.map +1 -1
- package/lib/translations/language-context.js +1 -1
- package/lib/translations/pages/contact.d.ts +46 -18
- package/lib/translations/pages/contact.d.ts.map +1 -1
- package/lib/translations/pages/contact.js +53 -26
- package/lib/translations/translations-context.d.ts +11 -4
- package/lib/translations/translations-context.d.ts.map +1 -1
- package/lib/translations/translations-context.js +18 -11
- package/lib/translations/types.d.ts +10 -5
- package/lib/translations/types.d.ts.map +1 -1
- package/lib/types/submit-payloads.d.ts +12 -0
- package/lib/types/submit-payloads.d.ts.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/rich-text.d.ts +2 -2
- package/lib/utils/rich-text.js +8 -3
- package/lib/utils.d.ts +56 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/validation/commonInputValidator.d.ts +1 -1
- package/lib/validation/commonInputValidator.d.ts.map +1 -1
- package/lib/validation/commonInputValidator.js +3 -3
- package/lib/validation/validationRules.d.ts +2 -0
- package/lib/validation/validationRules.d.ts.map +1 -1
- package/lib/validation/validationRules.js +28 -2
- package/package.json +12 -6
- package/lib/components/form/description-modal.d.ts +0 -13
- package/lib/components/form/description-modal.d.ts.map +0 -1
- package/lib/components/form/description-modal.js +0 -44
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationRules.d.ts","sourceRoot":"","sources":["../../src/validation/validationRules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validationRules.d.ts","sourceRoot":"","sources":["../../src/validation/validationRules.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAyD7D,KAAK,cAAc,GAAG;IAEpB,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,YAAY,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAyXF,eAAO,MAAM,2CAA2C,IAAI,CAAC;AAG7D,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,EAAE,KAAG,OAMlD,CAAC;AA0BF,KAAK,kBAAkB,GAAG;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,EAAE,CAAA;CAAE,CAAC;AAEpE,eAAO,MAAM,eAAe,EAAE,kBA4C7B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validationRules = void 0;
|
|
3
|
+
exports.validationRules = exports.isWithinOneMonth = exports.PRE_PURCHASED_TICKET_MIN_DELAYED_DEPARTURES = void 0;
|
|
4
|
+
const date_1 = require("@internationalized/date");
|
|
4
5
|
const translations_1 = require("../translations");
|
|
5
6
|
const isDefined = (value) => value !== undefined;
|
|
6
7
|
const removeWhitespace = (value) => {
|
|
@@ -316,7 +317,7 @@ const rulesAPurchasePlatform = [
|
|
|
316
317
|
];
|
|
317
318
|
const rulesAttachments = [
|
|
318
319
|
{
|
|
319
|
-
validate: (
|
|
320
|
+
validate: (files) => !!files?.length,
|
|
320
321
|
errorMessage: translations_1.PageText.Contact.components.fileinput.errorMessages.empty,
|
|
321
322
|
},
|
|
322
323
|
];
|
|
@@ -360,6 +361,29 @@ const rulesIsResponseWanted = [
|
|
|
360
361
|
errorMessage: translations_1.PageText.Contact.input.wantedResponse.errorMessages.undefined,
|
|
361
362
|
},
|
|
362
363
|
];
|
|
364
|
+
exports.PRE_PURCHASED_TICKET_MIN_DELAYED_DEPARTURES = 4;
|
|
365
|
+
// Latest departure must be less than one month after the earliest.
|
|
366
|
+
const isWithinOneMonth = (dates) => {
|
|
367
|
+
if (dates.length === 0)
|
|
368
|
+
return true;
|
|
369
|
+
const sorted = [...dates].sort();
|
|
370
|
+
const earliest = (0, date_1.parseDate)(sorted[0]);
|
|
371
|
+
const latest = (0, date_1.parseDate)(sorted[sorted.length - 1]);
|
|
372
|
+
return latest.compare(earliest.add({ months: 1 })) < 0;
|
|
373
|
+
};
|
|
374
|
+
exports.isWithinOneMonth = isWithinOneMonth;
|
|
375
|
+
const rulesPrePurchasedTicketDelayedDepartures = [
|
|
376
|
+
{
|
|
377
|
+
validate: (departures) => (departures?.length ?? 0) >= exports.PRE_PURCHASED_TICKET_MIN_DELAYED_DEPARTURES,
|
|
378
|
+
errorMessage: translations_1.PageText.Contact.refund.prePurchasedTicketRefund.delayedDepartures
|
|
379
|
+
.errorMessages.tooFew,
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
validate: (departures) => (0, exports.isWithinOneMonth)((departures ?? []).map((d) => d.date)),
|
|
383
|
+
errorMessage: translations_1.PageText.Contact.refund.prePurchasedTicketRefund.delayedDepartures
|
|
384
|
+
.errorMessages.notWithinOneMonth,
|
|
385
|
+
},
|
|
386
|
+
];
|
|
363
387
|
const rulesBankCardDetails = [
|
|
364
388
|
{
|
|
365
389
|
validate: isNonEmptyString,
|
|
@@ -403,9 +427,11 @@ exports.validationRules = {
|
|
|
403
427
|
purchasePlatform: rulesAPurchasePlatform,
|
|
404
428
|
attachments: rulesAttachments,
|
|
405
429
|
receiptAttachments: rulesAttachments,
|
|
430
|
+
identificationAttachments: rulesAttachments,
|
|
406
431
|
appPhoneNumber: rulesAppPhoneNumber,
|
|
407
432
|
customerNumber: rulesCustomerNumber,
|
|
408
433
|
travelCardNumber: rulesTravelCardNumber,
|
|
409
434
|
isResponseWanted: rulesIsResponseWanted,
|
|
410
435
|
bankCardDetails: rulesBankCardDetails,
|
|
436
|
+
prePurchasedTicketDelayedDepartures: rulesPrePurchasedTicketDelayedDepartures,
|
|
411
437
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrfylke/contact-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"generate-icons-manifest": "generate-assets all atb -o ./.tmp-icon-assets/ -ts -ts-o ./src/components/icon && rm -rf ./.tmp-icon-assets",
|
|
55
|
-
"prebuild": "
|
|
55
|
+
"prebuild": "pnpm run generate-icons-manifest",
|
|
56
56
|
"build": "tsc -p tsconfig.build.json && node scripts/copy-css.cjs",
|
|
57
57
|
"clean": "rm -rf lib",
|
|
58
58
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
59
59
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
|
|
60
60
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
|
|
61
|
-
"pretest": "
|
|
61
|
+
"pretest": "pnpm run generate-icons-manifest",
|
|
62
62
|
"test": "vitest run",
|
|
63
63
|
"test:watch": "vitest"
|
|
64
64
|
},
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@testing-library/react": "^16.3.3",
|
|
75
75
|
"@testing-library/user-event": "^14.6.6",
|
|
76
76
|
"@types/jsdom": "^28.0.3",
|
|
77
|
+
"@types/node": "^26",
|
|
77
78
|
"@types/react": "19.2.18",
|
|
78
79
|
"@types/react-dom": "19.2.5",
|
|
79
80
|
"eslint": "^9",
|
|
@@ -81,7 +82,12 @@
|
|
|
81
82
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
82
83
|
"jiti": "^2",
|
|
83
84
|
"jsdom": "^28.1.0",
|
|
85
|
+
"next": "16.3.4",
|
|
84
86
|
"prettier": "^3.9.6",
|
|
87
|
+
"react": "19.2.8",
|
|
88
|
+
"react-dom": "19.2.8",
|
|
89
|
+
"swr": "^2.5.1",
|
|
90
|
+
"typescript": "^5",
|
|
85
91
|
"typescript-eslint": "^8.69.0",
|
|
86
92
|
"vitest": "^4.1.11"
|
|
87
93
|
},
|
|
@@ -93,14 +99,14 @@
|
|
|
93
99
|
"@atb-as/token": "^0.0.4",
|
|
94
100
|
"@internationalized/date": "^3.12.3",
|
|
95
101
|
"@leile/lobo-t": "^1.0.5",
|
|
96
|
-
"@react-aria/focus": "^3.22.1",
|
|
97
102
|
"@xstate/react": "^6.1.0",
|
|
98
103
|
"detect-nearest-browser-locale": "^19.0.0",
|
|
99
104
|
"detect-nearest-locale": "^1.0.1",
|
|
100
|
-
"framer-motion": "^12.43.0",
|
|
101
105
|
"graphql": "^16.14.2",
|
|
106
|
+
"graphql-tag": "^2.12.6",
|
|
102
107
|
"react-aria-components": "^1.20.0",
|
|
103
|
-
"xstate": "^5.32.6"
|
|
108
|
+
"xstate": "^5.32.6",
|
|
109
|
+
"zod": "^4.3.6"
|
|
104
110
|
},
|
|
105
111
|
"peerDependencies": {
|
|
106
112
|
"@atb-as/theme": "^15.3.0",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type DescriptionModalProps = {
|
|
2
|
-
title: string;
|
|
3
|
-
modalContent: {
|
|
4
|
-
description?: string;
|
|
5
|
-
instruction?: string;
|
|
6
|
-
bulletPoints?: string[];
|
|
7
|
-
};
|
|
8
|
-
isModalOpen: boolean;
|
|
9
|
-
closeModal: () => void;
|
|
10
|
-
};
|
|
11
|
-
declare const DescriptionModal: ({ title, modalContent, isModalOpen, closeModal, }: DescriptionModalProps) => import("react").JSX.Element | null;
|
|
12
|
-
export default DescriptionModal;
|
|
13
|
-
//# sourceMappingURL=description-modal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"description-modal.d.ts","sourceRoot":"","sources":["../../../src/components/form/description-modal.tsx"],"names":[],"mappings":"AASA,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,mDAKvB,qBAAqB,uCA2FvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const form_module_css_1 = __importDefault(require("./form.module.css"));
|
|
8
|
-
const framer_motion_1 = require("framer-motion");
|
|
9
|
-
const focus_1 = require("@react-aria/focus");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const translations_1 = require("../../translations");
|
|
12
|
-
const typography_1 = require("../typography");
|
|
13
|
-
const button_1 = require("../button");
|
|
14
|
-
const icon_1 = require("../icon");
|
|
15
|
-
const DescriptionModal = ({ title, modalContent, isModalOpen, closeModal, }) => {
|
|
16
|
-
const PageText = (0, translations_1.usePageText)();
|
|
17
|
-
const { t } = (0, translations_1.useTranslation)();
|
|
18
|
-
const modalRef = (0, react_1.useRef)(null);
|
|
19
|
-
const { description, instruction, bulletPoints } = modalContent;
|
|
20
|
-
const handleEscapeOrClickOutside = (0, react_1.useCallback)((event) => {
|
|
21
|
-
if (event instanceof KeyboardEvent && event.key === 'Escape') {
|
|
22
|
-
closeModal();
|
|
23
|
-
}
|
|
24
|
-
else if (event instanceof MouseEvent &&
|
|
25
|
-
modalRef.current &&
|
|
26
|
-
!modalRef.current.contains(event.target)) {
|
|
27
|
-
closeModal();
|
|
28
|
-
}
|
|
29
|
-
}, [closeModal]);
|
|
30
|
-
(0, react_1.useEffect)(() => {
|
|
31
|
-
document.addEventListener('keydown', handleEscapeOrClickOutside);
|
|
32
|
-
document.addEventListener('mousedown', handleEscapeOrClickOutside);
|
|
33
|
-
return () => {
|
|
34
|
-
document.removeEventListener('keydown', handleEscapeOrClickOutside);
|
|
35
|
-
document.removeEventListener('mousedown', handleEscapeOrClickOutside);
|
|
36
|
-
};
|
|
37
|
-
}, [handleEscapeOrClickOutside]);
|
|
38
|
-
if (!isModalOpen)
|
|
39
|
-
return null;
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: form_module_css_1.default.modal_wrapper, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { ease: 'easeInOut', duration: 0.15 }, children: (0, jsx_runtime_1.jsx)(focus_1.FocusScope, { contain: true, restoreFocus: true, autoFocus: true, children: (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { ref: modalRef, initial: { opacity: 0, y: -30 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: 0 }, transition: { ease: 'backOut', delay: 0.1, duration: 0.15 }, children: (0, jsx_runtime_1.jsxs)("dialog", { "aria-modal": "true", "aria-labelledby": "title", tabIndex: 0, className: form_module_css_1.default.modal_content, children: [(0, jsx_runtime_1.jsxs)("div", { className: form_module_css_1.default.modal_header, children: [(0, jsx_runtime_1.jsx)(typography_1.Typo.h2, { id: "title", textType: "body__m", autoFocus: true, children: title }), (0, jsx_runtime_1.jsx)(button_1.Button, { className: form_module_css_1.default.iconButton, onClick: closeModal, icon: { right: (0, jsx_runtime_1.jsx)(icon_1.MonoIcon, { icon: 'actions/Close' }) }, buttonProps: {
|
|
41
|
-
'aria-label': t(PageText.Contact.components.modal.close()),
|
|
42
|
-
} })] }), description && (0, jsx_runtime_1.jsx)(typography_1.Typo.p, { textType: "body__m", children: description }), bulletPoints && ((0, jsx_runtime_1.jsx)("ul", { className: form_module_css_1.default.modal__rules_list, children: bulletPoints.map((desc, index) => ((0, jsx_runtime_1.jsx)("li", { children: (0, jsx_runtime_1.jsx)(typography_1.Typo.p, { textType: "body__m", children: desc }, index) }, index))) })), instruction && ((0, jsx_runtime_1.jsx)(typography_1.Typo.p, { textType: "body__m__strong", children: instruction }))] }) }) }) }));
|
|
43
|
-
};
|
|
44
|
-
exports.default = DescriptionModal;
|