@equinor/mad-core 0.13.0 → 0.15.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/{chunk-DJMBVNB6.js → chunk-4MZFJLIZ.js} +2 -2
  3. package/dist/{chunk-U5IJVQDO.js → chunk-5JFNRREO.js} +1 -1
  4. package/dist/chunk-5O4PAUNU.js +13 -0
  5. package/dist/{chunk-7HGZLLNX.js → chunk-6HDRI6TU.js} +1 -1
  6. package/dist/chunk-ANDIOEIN.js +353 -0
  7. package/dist/{chunk-6RPJUHBL.js → chunk-BFY7M5I2.js} +1 -1
  8. package/dist/{chunk-STKI44UB.js → chunk-COSM7WGR.js} +4 -4
  9. package/dist/{chunk-TWUGCMPQ.js → chunk-D4SVYUGC.js} +2 -2
  10. package/dist/{chunk-KEH6NBFE.js → chunk-G4GPSIHD.js} +1 -1
  11. package/dist/{chunk-HVZWOPNE.js → chunk-HPDK6AZ3.js} +4 -11
  12. package/dist/{chunk-EOM477VC.js → chunk-IPJ2CVM4.js} +1 -1
  13. package/dist/{chunk-ETY3HZNI.js → chunk-IXKJM7VZ.js} +1 -1
  14. package/dist/{chunk-WWF7QKDX.js → chunk-LEWQGDM7.js} +2 -7
  15. package/dist/{chunk-SVBUWW4H.js → chunk-N7YMTR7Q.js} +2 -2
  16. package/dist/{chunk-O2GHT2UV.js → chunk-NVAF6GOY.js} +2 -2
  17. package/dist/{chunk-CKOB6JKU.js → chunk-OAVRCDCP.js} +4 -4
  18. package/dist/{chunk-HUG4RNGS.js → chunk-PYTNVR7M.js} +3 -5
  19. package/dist/{chunk-7FO6SNUK.js → chunk-QGFTS65Y.js} +5 -10
  20. package/dist/{chunk-GEEFQMRN.js → chunk-RBFR3YMY.js} +5 -5
  21. package/dist/{chunk-PB3TI2RT.js → chunk-RPD2KUSY.js} +1 -1
  22. package/dist/{chunk-IHCNAGT7.js → chunk-SRQFW6D5.js} +1 -1
  23. package/dist/{chunk-DIITQCRW.js → chunk-TO775HMH.js} +1 -1
  24. package/dist/{chunk-6LMMRQYQ.js → chunk-UOOFD7CI.js} +2 -2
  25. package/dist/{chunk-RJDKNHBE.js → chunk-XMQYRBUW.js} +1 -1
  26. package/dist/{chunk-4JWXJOGM.js → chunk-YTQLIYLS.js} +4 -4
  27. package/dist/{chunk-GNJZV3PL.js → chunk-ZAEB6ZS3.js} +5 -9
  28. package/dist/components/EnvironmentBanner.js +2 -2
  29. package/dist/components/EnvironmentProvider.js +2 -2
  30. package/dist/components/NavigationContainer.d.ts +2 -15
  31. package/dist/components/OfflineBanner.js +2 -2
  32. package/dist/components/createCoreStackNavigator.d.ts +18 -37
  33. package/dist/components/createCoreStackNavigator.js +37 -30
  34. package/dist/components/index.js +37 -40
  35. package/dist/components/navigation/MadCoreSubHeader.js +7 -7
  36. package/dist/components/navigation/index.js +8 -8
  37. package/dist/components/navigation/navigation-creators.d.ts +6 -7
  38. package/dist/components/navigation/navigation-creators.js +8 -8
  39. package/dist/components/screens/AboutScreen.js +2 -2
  40. package/dist/components/screens/LoginScreen.d.ts +2 -2
  41. package/dist/components/screens/LoginScreen.js +4 -4
  42. package/dist/components/screens/create-incident/CreateIncidentScreen.js +51 -5
  43. package/dist/components/screens/create-incident/createIncident.js +62 -1
  44. package/dist/components/screens/language/SelectLanguageScreen.js +5 -5
  45. package/dist/components/screens/language/components/SelectLanguageCellGroup.js +2 -2
  46. package/dist/components/screens/release-notes/ReleaseNotesScreen.js +5 -8
  47. package/dist/components/screens/release-notes/WhatsNewScreen.js +6 -6
  48. package/dist/components/screens/release-notes/fetchReleaseNotes.js +1 -11
  49. package/dist/components/screens/settings/Section.js +1 -9
  50. package/dist/components/screens/settings/SettingsScreen.js +6 -6
  51. package/dist/components/screens/settings/index.js +6 -6
  52. package/dist/components/screens/settings/useSignOut.d.ts +1 -1
  53. package/dist/components/screens/settings/useSignOut.js +4 -4
  54. package/dist/components/service-message/ServiceMessageBanner.js +4 -4
  55. package/dist/components/service-message/ServiceMessageProvider.js +3 -3
  56. package/dist/components/service-message/hooks/useFetchServiceMessage.d.ts +0 -1
  57. package/dist/components/service-message/hooks/useFetchServiceMessage.js +2 -2
  58. package/dist/hooks/UseReleaseNotes.js +3 -6
  59. package/dist/hooks/index.js +1 -9
  60. package/dist/hooks/useAccountOrDemoAccount.js +1 -9
  61. package/dist/hooks/useNavigateFromLanguageSelectScreen.js +2 -2
  62. package/dist/hooks/useNavigateFromLoginScreen.js +3 -3
  63. package/dist/hooks/useNavigateFromWhatsNewScreen.js +3 -3
  64. package/dist/hooks/useScreenTitleFromDictionary.js +2 -2
  65. package/dist/index.js +55 -77
  66. package/dist/language/useDictionary.js +1 -1
  67. package/dist/store/index.js +2 -2
  68. package/dist/store/language/index.js +1 -1
  69. package/dist/store/language/language.js +1 -1
  70. package/dist/store/mad-config/hooks.d.ts +3 -3
  71. package/dist/store/mad-config/hooks.js +1 -1
  72. package/dist/store/mad-config/index.js +1 -1
  73. package/dist/store/mad-config/mad-config.js +1 -1
  74. package/dist/utils/MadCoreProviders.d.ts +1 -1
  75. package/dist/utils/MadCoreProviders.js +5 -5
  76. package/dist/utils/createEnvironmentProxy.d.ts +2 -2
  77. package/dist/utils/createEnvironmentProxy.js +1 -1
  78. package/dist/utils/createMadCoreNavigator.d.ts +6 -6
  79. package/dist/utils/createMadCoreNavigator.js +41 -22
  80. package/dist/utils/initiateAuthenticationClient.js +1 -11
  81. package/package.json +10 -11
  82. package/dist/chunk-3YVGPC4G.js +0 -41
  83. package/dist/chunk-GE4JC2VP.js +0 -98
  84. package/dist/chunk-JYWP44JR.js +0 -0
  85. package/dist/chunk-NJ5W3O5I.js +0 -30
  86. package/dist/chunk-WDZF2C5R.js +0 -20
  87. package/dist/chunk-ZIV7DVBA.js +0 -158
@@ -1,98 +0,0 @@
1
- import {
2
- WhatsNewScreen
3
- } from "./chunk-CKOB6JKU.js";
4
- import {
5
- CreateIncidentScreen
6
- } from "./chunk-ZIV7DVBA.js";
7
- import {
8
- SelectLanguageScreen
9
- } from "./chunk-STKI44UB.js";
10
- import {
11
- ReleaseNotesScreen
12
- } from "./chunk-TWUGCMPQ.js";
13
- import {
14
- AboutScreen
15
- } from "./chunk-HUG4RNGS.js";
16
- import {
17
- LoginScreen
18
- } from "./chunk-GNJZV3PL.js";
19
- import {
20
- MadCoreProviders
21
- } from "./chunk-6LMMRQYQ.js";
22
- import {
23
- getDefaultScreenOptionsForLoginScreen
24
- } from "./chunk-RGJ4RWVB.js";
25
- import {
26
- useMadConfig
27
- } from "./chunk-GEEFQMRN.js";
28
- import {
29
- CoreRoutes
30
- } from "./chunk-UKAZW3CQ.js";
31
- import {
32
- __spreadProps,
33
- __spreadValues
34
- } from "./chunk-CWMXXUWU.js";
35
-
36
- // src/utils/createMadCoreNavigator.tsx
37
- import React from "react";
38
- var createMadCoreNativeStackNavigator = (Stack) => {
39
- function MadCoreNavigator(props) {
40
- const config = useMadConfig();
41
- if (!config) return null;
42
- return /* @__PURE__ */ React.createElement(MadCoreProviders, { config, type: "native-stack" }, /* @__PURE__ */ React.createElement(Stack.Navigator, __spreadProps(__spreadValues({}, props), { initialRouteName: CoreRoutes.LOGIN }), config.login.addScreenManually !== true && /* @__PURE__ */ React.createElement(
43
- Stack.Screen,
44
- {
45
- name: CoreRoutes.LOGIN,
46
- component: LoginScreen,
47
- options: getDefaultScreenOptionsForLoginScreen()
48
- }
49
- ), /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.RELEASE_NOTES, component: ReleaseNotesScreen }), /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.WHATS_NEW, component: WhatsNewScreen }), config.about && /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.ABOUT, component: AboutScreen }), config.serviceNow && /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.FEEDBACK, component: CreateIncidentScreen }), config.language.supportedLanguages.length > 1 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
50
- Stack.Screen,
51
- {
52
- name: CoreRoutes.SELECT_LANGUAGE,
53
- component: SelectLanguageScreen
54
- }
55
- ), /* @__PURE__ */ React.createElement(
56
- Stack.Screen,
57
- {
58
- name: CoreRoutes.SELECT_LANGUAGE_ONBOARDING,
59
- component: SelectLanguageScreen,
60
- options: { headerBackVisible: false }
61
- }
62
- )), props.children));
63
- }
64
- return MadCoreNavigator;
65
- };
66
- var createMadCoreStackNavigator = (Stack) => {
67
- function MadCoreNavigator(props) {
68
- const config = useMadConfig();
69
- if (!config) return null;
70
- return /* @__PURE__ */ React.createElement(MadCoreProviders, { config, type: "stack" }, /* @__PURE__ */ React.createElement(Stack.Navigator, __spreadProps(__spreadValues({}, props), { initialRouteName: CoreRoutes.LOGIN }), config.login.addScreenManually !== true && /* @__PURE__ */ React.createElement(
71
- Stack.Screen,
72
- {
73
- name: CoreRoutes.LOGIN,
74
- component: LoginScreen,
75
- options: getDefaultScreenOptionsForLoginScreen()
76
- }
77
- ), /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.RELEASE_NOTES, component: ReleaseNotesScreen }), /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.WHATS_NEW, component: WhatsNewScreen }), config.about && /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.ABOUT, component: AboutScreen }), config.serviceNow && /* @__PURE__ */ React.createElement(Stack.Screen, { name: CoreRoutes.FEEDBACK, component: CreateIncidentScreen }), config.language.supportedLanguages.length > 1 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
78
- Stack.Screen,
79
- {
80
- name: CoreRoutes.SELECT_LANGUAGE,
81
- component: SelectLanguageScreen
82
- }
83
- ), /* @__PURE__ */ React.createElement(
84
- Stack.Screen,
85
- {
86
- name: CoreRoutes.SELECT_LANGUAGE_ONBOARDING,
87
- component: SelectLanguageScreen,
88
- options: { headerLeft: () => null }
89
- }
90
- )), props.children));
91
- }
92
- return MadCoreNavigator;
93
- };
94
-
95
- export {
96
- createMadCoreNativeStackNavigator,
97
- createMadCoreStackNavigator
98
- };
File without changes
@@ -1,30 +0,0 @@
1
- import {
2
- getMadCommonBaseUrl,
3
- getMadCommonScopes
4
- } from "./chunk-ZB37EIZB.js";
5
- import {
6
- __async
7
- } from "./chunk-CWMXXUWU.js";
8
-
9
- // src/components/screens/create-incident/createIncident.ts
10
- import { authenticateSilently } from "@equinor/mad-auth";
11
- var createIncident = (data, env, serviceNow) => __async(void 0, null, function* () {
12
- const baseUrl = getMadCommonBaseUrl(env);
13
- const scopes = getMadCommonScopes(env);
14
- const authenticationResponse = yield authenticateSilently(scopes);
15
- if (!authenticationResponse) throw new Error("Unable to authenticate silently");
16
- const fetchResponse = yield fetch(`${baseUrl}/ServiceNow/apps/${serviceNow}/incidents`, {
17
- method: "POST",
18
- body: JSON.stringify(data),
19
- headers: new Headers({
20
- Accept: "application/json",
21
- "Content-Type": "application/json",
22
- Authorization: `Bearer ${authenticationResponse.accessToken}`
23
- })
24
- });
25
- return yield fetchResponse.json().then((result) => JSON.parse(result));
26
- });
27
-
28
- export {
29
- createIncident
30
- };
@@ -1,20 +0,0 @@
1
- import {
2
- getConfig
3
- } from "./chunk-GEEFQMRN.js";
4
- import {
5
- getRedirectUriFromAuthConfig
6
- } from "./chunk-MODG2KVN.js";
7
-
8
- // src/utils/initiateAuthenticationClient.ts
9
- import { initiateAuthenticationClient as madAuthInitiateAuthenticationClient } from "@equinor/mad-auth";
10
- var initiateAuthenticationClient = () => {
11
- const {
12
- authentication: { clientId, redirectUri: redirectUriIos, redirectUriWeb }
13
- } = getConfig();
14
- const redirectUri = getRedirectUriFromAuthConfig(redirectUriIos, redirectUriWeb);
15
- void madAuthInitiateAuthenticationClient({ clientId, redirectUri });
16
- };
17
-
18
- export {
19
- initiateAuthenticationClient
20
- };
@@ -1,158 +0,0 @@
1
- import {
2
- UserInfo
3
- } from "./chunk-3WUJAVUO.js";
4
- import {
5
- createIncident
6
- } from "./chunk-NJ5W3O5I.js";
7
- import {
8
- useAccountOrDemoAccount
9
- } from "./chunk-WWF7QKDX.js";
10
- import {
11
- useEnvironment,
12
- useServiceNow
13
- } from "./chunk-GEEFQMRN.js";
14
-
15
- // src/components/screens/create-incident/CreateIncidentScreen.tsx
16
- import {
17
- Button,
18
- Cell,
19
- EDSStyleSheet,
20
- Spacer,
21
- TextField,
22
- Typography,
23
- useStyles
24
- } from "@equinor/mad-components";
25
- import * as Device from "expo-device";
26
- import * as Localization from "expo-localization";
27
- import React, { useState } from "react";
28
- import { KeyboardAvoidingView, LayoutAnimation, Platform, ScrollView, View } from "react-native";
29
- var CreateIncidentScreen = () => {
30
- var _a, _b, _c, _d;
31
- const [error, setError] = useState(null);
32
- const [ticketNumber, setTicketNumber] = useState(void 0);
33
- const [ticketTitle, setTicketTitle] = useState(void 0);
34
- const [ticketDescription, setTicketDescription] = useState(void 0);
35
- const [isSending, setIsSending] = useState(false);
36
- const account = useAccountOrDemoAccount();
37
- const serviceNowConfigurationItem = useServiceNow();
38
- const environment = useEnvironment();
39
- const styles = useStyles(createIncidentStyles);
40
- const timeZone = (_b = (_a = Localization.getCalendars()[0]) == null ? void 0 : _a.timeZone) != null ? _b : "Unknown TimeZone";
41
- const locale = (_d = (_c = Localization.getLocales()[0]) == null ? void 0 : _c.languageTag) != null ? _d : "Unknown Locale";
42
- const onSubmit = () => {
43
- setIsSending(true);
44
- const data = {
45
- callerEmail: account == null ? void 0 : account.username,
46
- title: ticketTitle,
47
- description: createDescription()
48
- };
49
- createIncident(data, environment, serviceNowConfigurationItem).then((response) => {
50
- LayoutAnimation.configureNext({
51
- duration: 500,
52
- update: {
53
- type: LayoutAnimation.Types.easeInEaseOut
54
- },
55
- create: {
56
- type: LayoutAnimation.Types.easeInEaseOut,
57
- property: LayoutAnimation.Properties.opacity
58
- }
59
- });
60
- if (response.result.details.number) {
61
- setTicketNumber(response.result.details.number);
62
- } else {
63
- setError(response);
64
- }
65
- setTicketDescription(void 0);
66
- setTicketTitle(void 0);
67
- setIsSending(false);
68
- }).catch(setError).finally(() => setIsSending(false));
69
- };
70
- const createDescription = () => {
71
- let description = "";
72
- description += `User: ${account == null ? void 0 : account.username}
73
- `;
74
- description += `Device Brand: ${Device.brand}
75
- `;
76
- description += `Device: ${Device.deviceName}
77
- `;
78
- description += `Operating System: ${Device.osVersion}
79
- `;
80
- description += `Time Zone: ${timeZone}
81
- `;
82
- description += `Locale: ${locale}
83
- `;
84
- return `${description}
85
- ${ticketDescription}`;
86
- };
87
- return /* @__PURE__ */ React.createElement(
88
- KeyboardAvoidingView,
89
- {
90
- behavior: "padding",
91
- keyboardVerticalOffset: 115,
92
- style: styles.container
93
- },
94
- /* @__PURE__ */ React.createElement(ScrollView, { contentInsetAdjustmentBehavior: "automatic" }, /* @__PURE__ */ React.createElement(Spacer, null), /* @__PURE__ */ React.createElement(Cell, null, /* @__PURE__ */ React.createElement(View, { style: styles.topTextContainer }, /* @__PURE__ */ React.createElement(Typography, { variant: "h1" }, "Create ticket in ServiceNow"), /* @__PURE__ */ React.createElement(Typography, { group: "paragraph", variant: "body_short" }, "We collect information about your device as part of our feedback process. By submitting, you agree to share the following information:")), /* @__PURE__ */ React.createElement(UserInfo, { infoType: "User", infoValue: account == null ? void 0 : account.username }), Platform.OS !== "web" && /* @__PURE__ */ React.createElement(UserInfo, { infoType: "Device Brand", infoValue: Device.brand }), Platform.OS !== "web" && /* @__PURE__ */ React.createElement(UserInfo, { infoType: "Device", infoValue: Device.deviceName }), /* @__PURE__ */ React.createElement(UserInfo, { infoType: "Operating System", infoValue: Device.osVersion }), /* @__PURE__ */ React.createElement(UserInfo, { infoType: "Time Zone", infoValue: timeZone }), /* @__PURE__ */ React.createElement(UserInfo, { infoType: "Locale", infoValue: locale }), ticketNumber && /* @__PURE__ */ React.createElement(View, { style: [styles.popupBox, styles.popupSuccess] }, /* @__PURE__ */ React.createElement(Typography, null, "Ticket number: "), /* @__PURE__ */ React.createElement(Typography, { selectable: true }, ticketNumber)), error && /* @__PURE__ */ React.createElement(View, { style: [styles.popupBox, styles.popupDanger] }, /* @__PURE__ */ React.createElement(Typography, null, "An error occurred creating your ticket:"), /* @__PURE__ */ React.createElement(Typography, { selectable: true }, error instanceof Error ? error.message : "")), /* @__PURE__ */ React.createElement(View, { style: styles.titleField }, /* @__PURE__ */ React.createElement(
95
- TextField,
96
- {
97
- onChange: setTicketTitle,
98
- value: ticketTitle,
99
- placeholder: "Write a title for the Service Now ticket",
100
- readOnly: isSending
101
- }
102
- )), /* @__PURE__ */ React.createElement(View, { style: styles.titleField }, /* @__PURE__ */ React.createElement(
103
- TextField,
104
- {
105
- multiline: true,
106
- onChange: setTicketDescription,
107
- placeholder: "Write a complete description of your issue. You do not need to provide information about your device.",
108
- value: ticketDescription,
109
- readOnly: isSending
110
- }
111
- )), /* @__PURE__ */ React.createElement(View, { style: styles.buttonContainer }, /* @__PURE__ */ React.createElement(
112
- Button,
113
- {
114
- disabled: !ticketTitle || !ticketDescription || isSending,
115
- onPress: onSubmit,
116
- style: { width: 81 },
117
- title: "Send"
118
- }
119
- ))))
120
- );
121
- };
122
- var createIncidentStyles = EDSStyleSheet.create((theme) => ({
123
- container: {
124
- flex: 1
125
- },
126
- topTextContainer: {
127
- paddingBottom: theme.geometry.dimension.cell.minHeight
128
- },
129
- titleField: {
130
- marginVertical: theme.spacing.textField.paddingVertical * 3
131
- },
132
- multiTextField: {
133
- height: theme.geometry.dimension.dialog.minHeight
134
- },
135
- buttonContainer: {
136
- flexDirection: "row",
137
- justifyContent: "flex-end"
138
- },
139
- popupBox: {
140
- padding: 24,
141
- marginTop: 16,
142
- borderWidth: 2,
143
- borderRadius: 4,
144
- flexDirection: "row",
145
- gap: 8,
146
- flexWrap: "wrap"
147
- },
148
- popupDanger: {
149
- borderColor: theme.colors.feedback.danger
150
- },
151
- popupSuccess: {
152
- borderColor: theme.colors.feedback.success
153
- }
154
- }));
155
-
156
- export {
157
- CreateIncidentScreen
158
- };