@mrfylke/contact-form 0.1.25 → 0.1.27
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 +41 -13
- package/lib/ContactFormRoot.d.ts.map +1 -1
- package/lib/ContactFormRoot.js +4 -3
- package/lib/components/icon/generated-icons.d.ts +26 -26
- package/lib/components/icon/generated-icons.js +108 -108
- package/lib/contact.module.css +0 -9
- package/lib/group-travel/index.d.ts.map +1 -1
- package/lib/group-travel/index.js +1 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/journey-info/index.d.ts.map +1 -1
- package/lib/journey-info/index.js +10 -8
- package/lib/journey-info/journeyInfoStateMachine.d.ts +2 -2
- package/lib/journey-info/journeyInfoStateMachine.d.ts.map +1 -1
- package/lib/journey-info/journeyInfoStateMachine.js +1 -1
- package/lib/layouts/contact-pages.js +1 -1
- package/lib/lost-property/LostPropertyMachine.d.ts +2 -2
- package/lib/lost-property/LostPropertyMachine.d.ts.map +1 -1
- package/lib/lost-property/LostPropertyMachine.js +1 -1
- package/lib/lost-property-external/index.d.ts.map +1 -1
- package/lib/lost-property-external/index.js +1 -2
- package/lib/means-of-transport/forms/serviceOfferingForm.d.ts.map +1 -1
- package/lib/means-of-transport/forms/serviceOfferingForm.js +3 -1
- package/lib/means-of-transport/index.d.ts.map +1 -1
- package/lib/means-of-transport/index.js +8 -2
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts +4 -2
- package/lib/means-of-transport/means-of-transport-form-machine.d.ts.map +1 -1
- package/lib/means-of-transport/means-of-transport-form-machine.js +9 -3
- package/lib/modules/config/context.d.ts +8 -1
- package/lib/modules/config/context.d.ts.map +1 -1
- package/lib/modules/config/context.js +7 -1
- package/lib/modules/config/default-submit.d.ts +3 -0
- package/lib/modules/config/default-submit.d.ts.map +1 -0
- package/lib/modules/config/default-submit.js +13 -0
- package/lib/modules/config/index.d.ts +1 -0
- package/lib/modules/config/index.d.ts.map +1 -1
- package/lib/modules/config/index.js +1 -0
- package/lib/modules/config/types.d.ts +52 -25
- package/lib/modules/config/types.d.ts.map +1 -1
- package/lib/modules/org-data/index.d.ts +1 -2
- package/lib/modules/org-data/index.d.ts.map +1 -1
- package/lib/modules/org-data/index.js +1 -2
- package/lib/refund/forms/refund-and-travel-guarantee/index.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/index.js +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.d.ts.map +1 -1
- package/lib/refund/forms/refund-and-travel-guarantee/refundCarForm.js +1 -1
- package/lib/refund/forms/refund-ticket/appTicketRefund.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/appTicketRefund.js +18 -2
- package/lib/refund/forms/refund-ticket/index.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/index.js +1 -1
- package/lib/refund/forms/refund-ticket/otherTicketRefund.d.ts.map +1 -1
- package/lib/refund/forms/refund-ticket/otherTicketRefund.js +19 -3
- package/lib/refund/forms/residualValueOnTravelCard/index.d.ts.map +1 -1
- package/lib/refund/forms/residualValueOnTravelCard/index.js +1 -2
- package/lib/refund/index.d.ts.map +1 -1
- package/lib/refund/index.js +9 -0
- package/lib/refund/refundFormMachine.d.ts +11 -2
- package/lib/refund/refundFormMachine.d.ts.map +1 -1
- package/lib/refund/refundFormMachine.js +24 -2
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.d.ts.map +1 -1
- package/lib/server/index.js +3 -1
- package/lib/server/submit-route-handler.d.ts +20 -0
- package/lib/server/submit-route-handler.d.ts.map +1 -0
- package/lib/server/submit-route-handler.js +62 -0
- package/lib/ticket-control/forms/feeComplaintForm.d.ts.map +1 -1
- package/lib/ticket-control/forms/feeComplaintForm.js +2 -2
- package/lib/ticket-control/forms/postponePayment.d.ts.map +1 -1
- package/lib/ticket-control/forms/postponePayment.js +2 -2
- package/lib/ticket-control/index.d.ts.map +1 -1
- package/lib/ticket-control/index.js +2 -0
- package/lib/ticket-control/ticket-control-form-machine.d.ts +5 -2
- package/lib/ticket-control/ticket-control-form-machine.d.ts.map +1 -1
- package/lib/ticket-control/ticket-control-form-machine.js +14 -4
- package/lib/ticketing/forms/travel-card/orderTravelCard.d.ts.map +1 -1
- package/lib/ticketing/forms/travel-card/orderTravelCard.js +1 -1
- package/lib/ticketing/ticketingStateMachine.d.ts +2 -2
- package/lib/ticketing/ticketingStateMachine.d.ts.map +1 -1
- package/lib/translations/commons.d.ts +1 -0
- package/lib/translations/commons.d.ts.map +1 -1
- package/lib/translations/commons.js +4 -4
- package/lib/translations/index.d.ts +2 -6
- package/lib/translations/index.d.ts.map +1 -1
- package/lib/translations/index.js +1 -9
- package/lib/translations/language-context.d.ts +0 -8
- package/lib/translations/language-context.d.ts.map +1 -1
- package/lib/translations/language-context.js +1 -31
- package/lib/translations/merge-overrides.d.ts +1 -7
- package/lib/translations/merge-overrides.d.ts.map +1 -1
- package/lib/translations/merge-overrides.js +1 -13
- package/lib/translations/pages/contact.d.ts +9 -4
- package/lib/translations/pages/contact.d.ts.map +1 -1
- package/lib/translations/pages/contact.js +10 -5
- package/lib/translations/server/endpoints.d.ts +0 -62
- package/lib/translations/server/endpoints.d.ts.map +1 -1
- package/lib/translations/server/endpoints.js +0 -62
- package/lib/translations/types.d.ts +0 -6
- package/lib/translations/types.d.ts.map +1 -1
- package/lib/types/submit-payloads.d.ts +2 -0
- package/lib/types/submit-payloads.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/translations/common/index.d.ts +0 -3
- package/lib/translations/common/index.d.ts.map +0 -1
- package/lib/translations/common/index.js +0 -7
- package/lib/translations/common/layout.d.ts +0 -8
- package/lib/translations/common/layout.d.ts.map +0 -1
- package/lib/translations/common/layout.js +0 -11
- package/lib/translations/common/titles.d.ts +0 -4
- package/lib/translations/common/titles.d.ts.map +0 -1
- package/lib/translations/common/titles.js +0 -7
- package/lib/translations/json-to-override.d.ts +0 -19
- package/lib/translations/json-to-override.d.ts.map +0 -1
- package/lib/translations/json-to-override.js +0 -65
- package/lib/translations/load-org-translations.d.ts +0 -19
- package/lib/translations/load-org-translations.d.ts.map +0 -1
- package/lib/translations/load-org-translations.js +0 -23
package/README.md
CHANGED
|
@@ -64,37 +64,65 @@ export default function ContactPage() {
|
|
|
64
64
|
|
|
65
65
|
## API configuration
|
|
66
66
|
|
|
67
|
-
The package is decoupled from your backend.
|
|
67
|
+
The package is decoupled from your backend. By default, it POSTs to
|
|
68
|
+
`endpoints.submit` (`/api/contact/submit`) with `{ ...state, $slug: slug }`
|
|
69
|
+
in the body — no `onSubmit` needed:
|
|
68
70
|
|
|
69
71
|
```ts
|
|
70
|
-
|
|
72
|
+
api: {
|
|
73
|
+
endpoints: {
|
|
74
|
+
submit: '/api/contact/submit', // Optional, this is the default
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Pair that with `createSubmitRouteHandler` for the route itself — it reads
|
|
80
|
+
`$slug` from the body and forwards the rest to your connector at that path:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// app/api/contact/submit/route.ts
|
|
84
|
+
import { createSubmitRouteHandler } from '@mrfylke/contact-form/server';
|
|
85
|
+
|
|
86
|
+
export const POST = createSubmitRouteHandler({
|
|
87
|
+
request: (path, init) => fetch(`${process.env.CONNECTOR_URL}${path}`, init),
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Overriding the submit callback
|
|
92
|
+
|
|
93
|
+
For full control over routing, provide your own `onSubmit` callback instead —
|
|
94
|
+
it receives the form slug and form state:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import type { FormSlug } from '@mrfylke/contact-form';
|
|
71
98
|
|
|
72
99
|
const onSubmit = async (
|
|
73
|
-
|
|
100
|
+
slug: FormSlug,
|
|
74
101
|
state: Record<string, unknown>,
|
|
75
102
|
): Promise<Response> => {
|
|
76
103
|
return fetch('/api/contact/submit', {
|
|
77
104
|
method: 'POST',
|
|
78
105
|
headers: { 'Content-Type': 'application/json' },
|
|
79
|
-
body: JSON.stringify({ ...state, formType:
|
|
106
|
+
body: JSON.stringify({ ...state, formType: slug }),
|
|
80
107
|
});
|
|
81
108
|
};
|
|
82
109
|
```
|
|
83
110
|
|
|
84
|
-
|
|
111
|
+
See `FormSlug` for the full set of possible values.
|
|
85
112
|
|
|
86
113
|
### Routing submissions to different endpoints
|
|
87
114
|
|
|
88
115
|
```ts
|
|
89
|
-
const onSubmit = async (
|
|
90
|
-
const endpointMap: Record<
|
|
91
|
-
|
|
92
|
-
refund:
|
|
93
|
-
|
|
94
|
-
ticketing:
|
|
95
|
-
|
|
116
|
+
const onSubmit = async (slug: FormSlug, state) => {
|
|
117
|
+
const endpointMap: Record<FormSlug, string> = {
|
|
118
|
+
'ticket-control': '/api/contact/ticket-control',
|
|
119
|
+
refund: '/api/contact/refund',
|
|
120
|
+
'means-of-transport': '/api/contact/means-of-transport',
|
|
121
|
+
ticketing: '/api/contact/ticketing',
|
|
122
|
+
'journey-info': '/api/contact/journey-info',
|
|
123
|
+
'lost-property': '/api/contact/lost-property',
|
|
96
124
|
};
|
|
97
|
-
return fetch(endpointMap[
|
|
125
|
+
return fetch(endpointMap[slug], {
|
|
98
126
|
method: 'POST',
|
|
99
127
|
headers: { 'Content-Type': 'application/json' },
|
|
100
128
|
body: JSON.stringify(state),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactFormRoot.d.ts","sourceRoot":"","sources":["../src/ContactFormRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,KAAK,+BAA+B,EACpC,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAQxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,mEAAmE;IACnE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,+BAA+B,CAAC;IACvD,sDAAsD;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,QAAQ,GACT,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ContactFormRoot.d.ts","sourceRoot":"","sources":["../src/ContactFormRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,KAAK,+BAA+B,EACpC,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAQxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,mEAAmE;IACnE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,+BAA+B,CAAC;IACvD,sDAAsD;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,QAAQ,GACT,EAAE,oBAAoB,qBAsBtB"}
|
package/lib/ContactFormRoot.js
CHANGED
|
@@ -16,10 +16,11 @@ function ThemeSync({ children }) {
|
|
|
16
16
|
* consumers can pass their routes/layout as children.
|
|
17
17
|
*/
|
|
18
18
|
function ContactFormRoot({ config, language, theme, translationsOverride, children, }) {
|
|
19
|
-
// Merge config translations (
|
|
19
|
+
// Merge config translations (optional) with optional root-level override (override takes precedence)
|
|
20
|
+
const configTranslations = config.translations ?? {};
|
|
20
21
|
const mergedTranslations = translationsOverride
|
|
21
|
-
? deepMerge(
|
|
22
|
-
:
|
|
22
|
+
? deepMerge(configTranslations, translationsOverride)
|
|
23
|
+
: configTranslations;
|
|
23
24
|
const mergedConfig = (0, config_1.mergeConfigThemeOverrides)(config);
|
|
24
25
|
return ((0, jsx_runtime_1.jsx)(config_1.ContactFormConfigContext.Provider, { value: mergedConfig, children: (0, jsx_runtime_1.jsx)(theme_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(ThemeSync, { children: (0, jsx_runtime_1.jsx)(translations_1.AppLanguageProvider, { overrides: mergedTranslations, language: language, children: children }) }) }) }));
|
|
25
26
|
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
export declare const icons: {
|
|
2
2
|
mono: {
|
|
3
|
-
"bonus/Star": {
|
|
4
|
-
relative: string;
|
|
5
|
-
absolute: string;
|
|
6
|
-
assetType: string;
|
|
7
|
-
id: string;
|
|
8
|
-
};
|
|
9
|
-
"bonus/StarFill": {
|
|
10
|
-
relative: string;
|
|
11
|
-
absolute: string;
|
|
12
|
-
assetType: string;
|
|
13
|
-
id: string;
|
|
14
|
-
};
|
|
15
3
|
"actions/Add": {
|
|
16
4
|
relative: string;
|
|
17
5
|
absolute: string;
|
|
@@ -168,6 +156,18 @@ export declare const icons: {
|
|
|
168
156
|
assetType: string;
|
|
169
157
|
id: string;
|
|
170
158
|
};
|
|
159
|
+
"bonus/Star": {
|
|
160
|
+
relative: string;
|
|
161
|
+
absolute: string;
|
|
162
|
+
assetType: string;
|
|
163
|
+
id: string;
|
|
164
|
+
};
|
|
165
|
+
"bonus/StarFill": {
|
|
166
|
+
relative: string;
|
|
167
|
+
absolute: string;
|
|
168
|
+
assetType: string;
|
|
169
|
+
id: string;
|
|
170
|
+
};
|
|
171
171
|
"devices/Laptop": {
|
|
172
172
|
relative: string;
|
|
173
173
|
absolute: string;
|
|
@@ -1140,19 +1140,19 @@ export declare const icons: {
|
|
|
1140
1140
|
assetType: string;
|
|
1141
1141
|
id: string;
|
|
1142
1142
|
};
|
|
1143
|
-
"
|
|
1143
|
+
"logo/logo": {
|
|
1144
1144
|
relative: string;
|
|
1145
1145
|
absolute: string;
|
|
1146
1146
|
assetType: string;
|
|
1147
1147
|
id: string;
|
|
1148
1148
|
};
|
|
1149
|
-
"ticketing/
|
|
1149
|
+
"ticketing/Travelcard": {
|
|
1150
1150
|
relative: string;
|
|
1151
1151
|
absolute: string;
|
|
1152
1152
|
assetType: string;
|
|
1153
1153
|
id: string;
|
|
1154
1154
|
};
|
|
1155
|
-
"
|
|
1155
|
+
"ticketing/TravelcardOutlined": {
|
|
1156
1156
|
relative: string;
|
|
1157
1157
|
absolute: string;
|
|
1158
1158
|
assetType: string;
|
|
@@ -1618,7 +1618,7 @@ export declare const icons: {
|
|
|
1618
1618
|
darkable: boolean;
|
|
1619
1619
|
id: string;
|
|
1620
1620
|
};
|
|
1621
|
-
"
|
|
1621
|
+
"map/Map": {
|
|
1622
1622
|
relative: string;
|
|
1623
1623
|
absolute: string;
|
|
1624
1624
|
assetType: string;
|
|
@@ -1626,7 +1626,7 @@ export declare const icons: {
|
|
|
1626
1626
|
darkable: boolean;
|
|
1627
1627
|
id: string;
|
|
1628
1628
|
};
|
|
1629
|
-
"
|
|
1629
|
+
"map/MapPin": {
|
|
1630
1630
|
relative: string;
|
|
1631
1631
|
absolute: string;
|
|
1632
1632
|
assetType: string;
|
|
@@ -1634,7 +1634,7 @@ export declare const icons: {
|
|
|
1634
1634
|
darkable: boolean;
|
|
1635
1635
|
id: string;
|
|
1636
1636
|
};
|
|
1637
|
-
"
|
|
1637
|
+
"map/Pin": {
|
|
1638
1638
|
relative: string;
|
|
1639
1639
|
absolute: string;
|
|
1640
1640
|
assetType: string;
|
|
@@ -1642,7 +1642,7 @@ export declare const icons: {
|
|
|
1642
1642
|
darkable: boolean;
|
|
1643
1643
|
id: string;
|
|
1644
1644
|
};
|
|
1645
|
-
"
|
|
1645
|
+
"map/PinInvalid": {
|
|
1646
1646
|
relative: string;
|
|
1647
1647
|
absolute: string;
|
|
1648
1648
|
assetType: string;
|
|
@@ -1650,7 +1650,7 @@ export declare const icons: {
|
|
|
1650
1650
|
darkable: boolean;
|
|
1651
1651
|
id: string;
|
|
1652
1652
|
};
|
|
1653
|
-
"map/
|
|
1653
|
+
"map/PinValid": {
|
|
1654
1654
|
relative: string;
|
|
1655
1655
|
absolute: string;
|
|
1656
1656
|
assetType: string;
|
|
@@ -1658,7 +1658,7 @@ export declare const icons: {
|
|
|
1658
1658
|
darkable: boolean;
|
|
1659
1659
|
id: string;
|
|
1660
1660
|
};
|
|
1661
|
-
"
|
|
1661
|
+
"input/CheckboxChecked": {
|
|
1662
1662
|
relative: string;
|
|
1663
1663
|
absolute: string;
|
|
1664
1664
|
assetType: string;
|
|
@@ -1666,7 +1666,7 @@ export declare const icons: {
|
|
|
1666
1666
|
darkable: boolean;
|
|
1667
1667
|
id: string;
|
|
1668
1668
|
};
|
|
1669
|
-
"
|
|
1669
|
+
"input/CheckboxUnchecked": {
|
|
1670
1670
|
relative: string;
|
|
1671
1671
|
absolute: string;
|
|
1672
1672
|
assetType: string;
|
|
@@ -1674,7 +1674,7 @@ export declare const icons: {
|
|
|
1674
1674
|
darkable: boolean;
|
|
1675
1675
|
id: string;
|
|
1676
1676
|
};
|
|
1677
|
-
"
|
|
1677
|
+
"input/RadiobuttonChecked": {
|
|
1678
1678
|
relative: string;
|
|
1679
1679
|
absolute: string;
|
|
1680
1680
|
assetType: string;
|
|
@@ -1682,7 +1682,7 @@ export declare const icons: {
|
|
|
1682
1682
|
darkable: boolean;
|
|
1683
1683
|
id: string;
|
|
1684
1684
|
};
|
|
1685
|
-
"
|
|
1685
|
+
"input/RadiobuttonUnchecked": {
|
|
1686
1686
|
relative: string;
|
|
1687
1687
|
absolute: string;
|
|
1688
1688
|
assetType: string;
|
|
@@ -1916,7 +1916,7 @@ export declare const icons: {
|
|
|
1916
1916
|
darkable: boolean;
|
|
1917
1917
|
id: string;
|
|
1918
1918
|
};
|
|
1919
|
-
"token/
|
|
1919
|
+
"token/travelcard/Travelcard": {
|
|
1920
1920
|
relative: string;
|
|
1921
1921
|
absolute: string;
|
|
1922
1922
|
assetType: string;
|
|
@@ -1924,7 +1924,7 @@ export declare const icons: {
|
|
|
1924
1924
|
darkable: boolean;
|
|
1925
1925
|
id: string;
|
|
1926
1926
|
};
|
|
1927
|
-
"token/
|
|
1927
|
+
"token/mobile/Phone": {
|
|
1928
1928
|
relative: string;
|
|
1929
1929
|
absolute: string;
|
|
1930
1930
|
assetType: string;
|