@lysaab/lysa-pep 1.0.4-0 → 1.0.5-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 (89) hide show
  1. package/{lib/Exports.d.ts → Exports.d.ts} +7 -7
  2. package/{lib/Exports.js → Exports.js} +7 -7
  3. package/{lib/components → components}/CountrySelect.d.ts +15 -15
  4. package/{lib/components → components}/CountrySelect.js +30 -30
  5. package/{lib/components → components}/PepAnswers.d.ts +8 -8
  6. package/{lib/components → components}/PepAnswers.js +131 -131
  7. package/{lib/components → components}/PepAnswers.scss +7 -7
  8. package/messages/src/components/CountrySelect.json +1 -0
  9. package/messages/src/components/PepAnswers.json +1 -0
  10. package/messages/src/pages/IsPep/IsPepMessages.json +1 -0
  11. package/messages/src/pages/IsPep/IsPepPage.json +1 -0
  12. package/messages/src/pages/RelationPage/RelationMessages.json +1 -0
  13. package/messages/src/pages/RelationPage/RelationPage.json +1 -0
  14. package/messages/src/pages/RolePage/RoleMessages.json +1 -0
  15. package/messages/src/pages/RolePage/RolePage.json +1 -0
  16. package/messages/src/pages/StatusPage/StatusMessages.json +1 -0
  17. package/messages/src/pages/StatusPage/StatusPage.json +1 -0
  18. package/{lib/model → model}/Countries.d.ts +4 -4
  19. package/{lib/model → model}/Countries.js +1002 -1002
  20. package/{lib/model → model}/PepModel.d.ts +7 -7
  21. package/{lib/model → model}/PepModel.js +40 -40
  22. package/{lib/model → model}/PepTexts.d.ts +380 -322
  23. package/{lib/model → model}/PepTexts.js +552 -467
  24. package/package.json +69 -57
  25. package/{lib/pages → pages}/IsPep/IsPepMessages.d.ts +32 -32
  26. package/{lib/pages → pages}/IsPep/IsPepMessages.js +66 -66
  27. package/{lib/pages → pages}/IsPep/IsPepPage.d.ts +14 -14
  28. package/{lib/pages → pages}/IsPep/IsPepPage.js +60 -60
  29. package/{lib/pages → pages}/PepContext.d.ts +80 -80
  30. package/{lib/pages → pages}/PepContext.js +88 -88
  31. package/pages/PepIsPepPage.d.ts +15 -0
  32. package/{lib/pages → pages}/PepIsPepPage.js +59 -57
  33. package/{lib/pages → pages}/PepRelationPage.d.ts +6 -6
  34. package/{lib/pages → pages}/PepRelationPage.js +79 -83
  35. package/{lib/pages → pages}/PepRolePage.d.ts +10 -9
  36. package/{lib/pages → pages}/PepRolePage.js +127 -127
  37. package/{lib/pages → pages}/PepStatusPage.d.ts +6 -6
  38. package/pages/PepStatusPage.js +58 -0
  39. package/{lib/pages → pages}/RelationPage/RelationMessages.d.ts +105 -105
  40. package/{lib/pages → pages}/RelationPage/RelationMessages.js +283 -283
  41. package/{lib/pages → pages}/RelationPage/RelationPage.d.ts +6 -6
  42. package/{lib/pages → pages}/RelationPage/RelationPage.js +154 -154
  43. package/{lib/pages → pages}/RolePage/RoleMessages.d.ts +185 -185
  44. package/{lib/pages → pages}/RolePage/RoleMessages.js +385 -385
  45. package/{lib/pages → pages}/RolePage/RolePage.d.ts +11 -11
  46. package/{lib/pages → pages}/RolePage/RolePage.js +223 -223
  47. package/{lib/pages → pages}/StatusPage/StatusMessages.d.ts +72 -72
  48. package/{lib/pages → pages}/StatusPage/StatusMessages.js +266 -266
  49. package/{lib/pages → pages}/StatusPage/StatusPage.d.ts +6 -6
  50. package/{lib/pages → pages}/StatusPage/StatusPage.js +98 -98
  51. package/{lib/utils → utils}/Possession.d.ts +1 -1
  52. package/{lib/utils → utils}/Possession.js +18 -18
  53. package/.vscode/settings.json +0 -4
  54. package/lib/pages/PepIsPepPage.d.ts +0 -6
  55. package/lib/pages/PepStatusPage.js +0 -57
  56. package/public/favicon.ico +0 -0
  57. package/public/index.html +0 -43
  58. package/public/logo192.png +0 -0
  59. package/public/logo512.png +0 -0
  60. package/public/manifest.json +0 -25
  61. package/public/robots.txt +0 -2
  62. package/src/App.css +0 -3
  63. package/src/App.test.tsx +0 -9
  64. package/src/App.tsx +0 -25
  65. package/src/Exports.ts +0 -12
  66. package/src/components/CountrySelect.tsx +0 -47
  67. package/src/components/PepAnswers.scss +0 -7
  68. package/src/components/PepAnswers.tsx +0 -252
  69. package/src/demo/Done.tsx +0 -16
  70. package/src/demo/Pep.tsx +0 -112
  71. package/src/index.css +0 -13
  72. package/src/index.tsx +0 -12
  73. package/src/logo.svg +0 -1
  74. package/src/model/Countries.ts +0 -1002
  75. package/src/model/PepModel.ts +0 -52
  76. package/src/pages/IsPep/IsPepMessages.ts +0 -67
  77. package/src/pages/IsPep/IsPepPage.tsx +0 -118
  78. package/src/pages/PepContext.tsx +0 -144
  79. package/src/pages/RelationPage/RelationMessages.ts +0 -288
  80. package/src/pages/RelationPage/RelationPage.tsx +0 -304
  81. package/src/pages/RolePage/RoleMessages.ts +0 -393
  82. package/src/pages/RolePage/RolePage.tsx +0 -361
  83. package/src/pages/StatusPage/StatusMessages.ts +0 -272
  84. package/src/pages/StatusPage/StatusPage.tsx +0 -213
  85. package/src/react-app-env.d.ts +0 -1
  86. package/src/serviceWorker.ts +0 -143
  87. package/src/utils/Possession.ts +0 -21
  88. package/tsconfig.json +0 -25
  89. package/tsconfig_build.json +0 -19
@@ -1,213 +0,0 @@
1
- import React, {
2
- FunctionComponent,
3
- useRef,
4
- useCallback,
5
- useContext,
6
- } from "react";
7
- import {
8
- Form,
9
- RadioGroup,
10
- RequiredValidator,
11
- PrimaryButton,
12
- LysaFormRef,
13
- Datepicker,
14
- Card,
15
- } from "@lysaab/ui-2";
16
- import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
17
- import { PepContext, PepStatus, EntityType, PepType } from "../PepContext";
18
- import { CountrySelect } from "../../components/CountrySelect";
19
- import { useIntl, FormattedMessage, IntlShape } from "react-intl";
20
- import {
21
- isOngoingMessages,
22
- endedMessages,
23
- isLocalCountryMessages,
24
- countrySelectionMessages,
25
- localCountryAltMessages,
26
- stateAltMessages,
27
- } from "./StatusMessages";
28
- import { formatPossessive } from "../../utils/Possession";
29
-
30
- interface Props {
31
- next: () => void;
32
- }
33
-
34
- export const StatusPage: FunctionComponent<Props> = ({ next }) => {
35
- const pepContext = useContext(PepContext);
36
- const formRef = useRef<LysaFormRef>();
37
- const intl = useIntl();
38
- const stateAlternatives = getStateAlternatives(intl);
39
- const isSwedenAlternatives = getIsLocalCountryAlternatives(intl);
40
- const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
41
-
42
- const nextPage = useCallback(() => {
43
- if (formRef.current && formRef.current.isValid) {
44
- next();
45
- }
46
- }, [formRef, next]);
47
-
48
- const updateIsSweden = useCallback(
49
- (alternative: Alternative<string>) => {
50
- pepContext.setState({ isSweden: alternative.value });
51
-
52
- if (alternative.value === "other") {
53
- pepContext.setState({ country: undefined });
54
- }
55
- },
56
- [pepContext]
57
- );
58
-
59
- const updateIsOngoing = useCallback(
60
- (alternative: Alternative<PepStatus>) => {
61
- pepContext.setState({ isOngoing: alternative.value });
62
-
63
- if (alternative.value === PepStatus.ONGOING) {
64
- pepContext.setState({ ended: undefined });
65
- }
66
- },
67
- [pepContext]
68
- );
69
-
70
- return (
71
- <div>
72
- <Form
73
- lysaFormRef={formRef}
74
- onSubmit={() => {
75
- nextPage();
76
- }}
77
- >
78
- <Card>
79
- <RadioGroup
80
- alternatives={stateAlternatives}
81
- header={intl.formatMessage(isOngoingMessages.header, {
82
- entityType,
83
- name: pepContext.state.ownerName,
84
- possessiveName: formatPossessive(
85
- pepContext.state.ownerName,
86
- intl.locale
87
- ),
88
- relation:
89
- pepContext.state.type === PepType.COLLEAGUE
90
- ? pepContext.state.businessRelation
91
- : pepContext.state.relationToPEP,
92
- pepType: pepContext.state.type,
93
- })}
94
- onChange={updateIsOngoing}
95
- value={stateAlternatives.find(
96
- (alt) => alt.value === pepContext.state.isOngoing
97
- )}
98
- validators={[
99
- new RequiredValidator(
100
- intl.formatMessage(isOngoingMessages.required)
101
- ),
102
- ]}
103
- />
104
-
105
- {pepContext.state.isOngoing &&
106
- pepContext.state.isOngoing === PepStatus.ENDED ? (
107
- <Datepicker
108
- label={intl.formatMessage(endedMessages.header)}
109
- selected={pepContext.state.ended}
110
- onChange={(event) =>
111
- pepContext.setState({ ended: event || undefined })
112
- }
113
- validators={[
114
- new RequiredValidator(
115
- intl.formatMessage(isOngoingMessages.required)
116
- ),
117
- ]}
118
- showMonthYearPicker
119
- dateFormat="yyyy-MM"
120
- maxDate={new Date()}
121
- />
122
- ) : null}
123
- </Card>
124
-
125
- <Card>
126
- <RadioGroup
127
- alternatives={isSwedenAlternatives}
128
- header={intl.formatMessage(isLocalCountryMessages.header, {
129
- possessiveName: formatPossessive(
130
- pepContext.state.ownerName,
131
- intl.locale
132
- ),
133
- })}
134
- onChange={updateIsSweden}
135
- value={isSwedenAlternatives.find(
136
- (alt) => alt.value === pepContext.state.isSweden
137
- )}
138
- validators={[
139
- new RequiredValidator(
140
- intl.formatMessage(isLocalCountryMessages.required)
141
- ),
142
- ]}
143
- />
144
-
145
- {pepContext.state.isSweden &&
146
- pepContext.state.isSweden === "other" ? (
147
- <CountrySelect
148
- label={intl.formatMessage(countrySelectionMessages.header, {
149
- entityType,
150
- name: pepContext.state.ownerName,
151
- possessiveName: formatPossessive(
152
- pepContext.state.ownerName,
153
- intl.locale
154
- ),
155
- relation:
156
- pepContext.state.type === PepType.COLLEAGUE
157
- ? pepContext.state.businessRelation
158
- : pepContext.state.relationToPEP,
159
- pepType: pepContext.state.type,
160
- })}
161
- onChange={(event) =>
162
- pepContext.setState({
163
- country: event.value ? event.value.toString() : undefined,
164
- })
165
- }
166
- validators={[
167
- new RequiredValidator(
168
- intl.formatMessage(countrySelectionMessages.required)
169
- ),
170
- ]}
171
- value={pepContext.state.country}
172
- omitCountries={["SE"]}
173
- />
174
- ) : null}
175
- </Card>
176
-
177
- <PrimaryButton block type="submit">
178
- <FormattedMessage
179
- id="pep.status.next"
180
- description="Next button"
181
- defaultMessage="Gå vidare"
182
- />
183
- </PrimaryButton>
184
- </Form>
185
- </div>
186
- );
187
- };
188
-
189
- function getIsLocalCountryAlternatives(intl: IntlShape): Alternative<string>[] {
190
- return [
191
- {
192
- text: intl.formatMessage(localCountryAltMessages.localCountry),
193
- value: "sweden",
194
- },
195
- {
196
- text: intl.formatMessage(localCountryAltMessages.otherCountry),
197
- value: "other",
198
- },
199
- ];
200
- }
201
-
202
- function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
203
- return [
204
- {
205
- text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
206
- value: PepStatus.ONGOING,
207
- },
208
- {
209
- text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
210
- value: PepStatus.ENDED,
211
- },
212
- ];
213
- }
@@ -1 +0,0 @@
1
- /// <reference types="react-scripts" />
@@ -1,143 +0,0 @@
1
- // This optional code is used to register a service worker.
2
- // register() is not called by default.
3
-
4
- // This lets the app load faster on subsequent visits in production, and gives
5
- // it offline capabilities. However, it also means that developers (and users)
6
- // will only see deployed updates on subsequent visits to a page, after all the
7
- // existing tabs open on the page have been closed, since previously cached
8
- // resources are updated in the background.
9
-
10
- // To learn more about the benefits of this model and instructions on how to
11
- // opt-in, read https://bit.ly/CRA-PWA
12
-
13
- const isLocalhost = Boolean(
14
- window.location.hostname === 'localhost' ||
15
- // [::1] is the IPv6 localhost address.
16
- window.location.hostname === '[::1]' ||
17
- // 127.0.0.1/8 is considered localhost for IPv4.
18
- window.location.hostname.match(
19
- /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20
- )
21
- );
22
-
23
- type Config = {
24
- onSuccess?: (registration: ServiceWorkerRegistration) => void;
25
- onUpdate?: (registration: ServiceWorkerRegistration) => void;
26
- };
27
-
28
- export function register(config?: Config) {
29
- if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
30
- // The URL constructor is available in all browsers that support SW.
31
- const publicUrl = new URL(
32
- (process as { env: { [key: string]: string } }).env.PUBLIC_URL,
33
- window.location.href
34
- );
35
- if (publicUrl.origin !== window.location.origin) {
36
- // Our service worker won't work if PUBLIC_URL is on a different origin
37
- // from what our page is served on. This might happen if a CDN is used to
38
- // serve assets; see https://github.com/facebook/create-react-app/issues/2374
39
- return;
40
- }
41
-
42
- window.addEventListener('load', () => {
43
- const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
44
-
45
- if (isLocalhost) {
46
- // This is running on localhost. Let's check if a service worker still exists or not.
47
- checkValidServiceWorker(swUrl, config);
48
-
49
- // Add some additional logging to localhost, pointing developers to the
50
- // service worker/PWA documentation.
51
- navigator.serviceWorker.ready.then(() => {
52
- console.log(
53
- 'This web app is being served cache-first by a service ' +
54
- 'worker. To learn more, visit https://bit.ly/CRA-PWA'
55
- );
56
- });
57
- } else {
58
- // Is not localhost. Just register service worker
59
- registerValidSW(swUrl, config);
60
- }
61
- });
62
- }
63
- }
64
-
65
- function registerValidSW(swUrl: string, config?: Config) {
66
- navigator.serviceWorker
67
- .register(swUrl)
68
- .then(registration => {
69
- registration.onupdatefound = () => {
70
- const installingWorker = registration.installing;
71
- if (installingWorker == null) {
72
- return;
73
- }
74
- installingWorker.onstatechange = () => {
75
- if (installingWorker.state === 'installed') {
76
- if (navigator.serviceWorker.controller) {
77
- // At this point, the updated precached content has been fetched,
78
- // but the previous service worker will still serve the older
79
- // content until all client tabs are closed.
80
- console.log(
81
- 'New content is available and will be used when all ' +
82
- 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
83
- );
84
-
85
- // Execute callback
86
- if (config && config.onUpdate) {
87
- config.onUpdate(registration);
88
- }
89
- } else {
90
- // At this point, everything has been precached.
91
- // It's the perfect time to display a
92
- // "Content is cached for offline use." message.
93
- console.log('Content is cached for offline use.');
94
-
95
- // Execute callback
96
- if (config && config.onSuccess) {
97
- config.onSuccess(registration);
98
- }
99
- }
100
- }
101
- };
102
- };
103
- })
104
- .catch(error => {
105
- console.error('Error during service worker registration:', error);
106
- });
107
- }
108
-
109
- function checkValidServiceWorker(swUrl: string, config?: Config) {
110
- // Check if the service worker can be found. If it can't reload the page.
111
- fetch(swUrl)
112
- .then(response => {
113
- // Ensure service worker exists, and that we really are getting a JS file.
114
- const contentType = response.headers.get('content-type');
115
- if (
116
- response.status === 404 ||
117
- (contentType != null && contentType.indexOf('javascript') === -1)
118
- ) {
119
- // No service worker found. Probably a different app. Reload the page.
120
- navigator.serviceWorker.ready.then(registration => {
121
- registration.unregister().then(() => {
122
- window.location.reload();
123
- });
124
- });
125
- } else {
126
- // Service worker found. Proceed as normal.
127
- registerValidSW(swUrl, config);
128
- }
129
- })
130
- .catch(() => {
131
- console.log(
132
- 'No internet connection found. App is running in offline mode.'
133
- );
134
- });
135
- }
136
-
137
- export function unregister() {
138
- if ('serviceWorker' in navigator) {
139
- navigator.serviceWorker.ready.then(registration => {
140
- registration.unregister();
141
- });
142
- }
143
- }
@@ -1,21 +0,0 @@
1
- export function formatPossessive(text: string | undefined, locale: string) {
2
- if (!text) {
3
- return;
4
- }
5
- const language = locale.substr(0, 2);
6
- if (language === "sv") {
7
- return formatSwedish(text);
8
- }
9
- return text;
10
- }
11
-
12
- function formatSwedish(text: string) {
13
- if (
14
- text[text.length - 1] !== "s" &&
15
- text[text.length - 1] !== "z" &&
16
- text[text.length - 1] !== "x"
17
- ) {
18
- text += "s";
19
- }
20
- return text;
21
- }
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
12
- "allowSyntheticDefaultImports": true,
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "module": "esnext",
16
- "moduleResolution": "node",
17
- "resolveJsonModule": true,
18
- "isolatedModules": true,
19
- "noEmit": true,
20
- "jsx": "react"
21
- },
22
- "include": [
23
- "src"
24
- ]
25
- }
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["dom", "dom.iterable", "esnext"],
4
- "skipLibCheck": true,
5
- "esModuleInterop": true,
6
- "target": "ES2015",
7
- "module": "esnext",
8
- "declaration": true,
9
- "outDir": "lib",
10
- "strict": true,
11
- "removeComments": true,
12
- "jsx": "react",
13
- "allowSyntheticDefaultImports": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "moduleResolution": "node",
16
- "resolveJsonModule": true
17
- },
18
- "include": ["src/Exports.ts"]
19
- }