@lysaab/lysa-pep 7.0.0 → 7.1.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 (85) hide show
  1. package/{src/Exports.ts → Exports.d.ts} +2 -7
  2. package/{lib/Exports.js → Exports.js} +2 -2
  3. package/{lib/components → components}/PepAnswers.d.ts +6 -0
  4. package/components/PepAnswers.js +182 -0
  5. package/package.json +8 -8
  6. package/{lib/pages → pages}/IsPep/IsPepPage.d.ts +2 -0
  7. package/{lib/pages → pages}/IsPep/IsPepPage.js +7 -4
  8. package/lib/Exports.d.ts +0 -7
  9. package/lib/README.md +0 -51
  10. package/lib/components/PepAnswers.js +0 -101
  11. package/lib/package.json +0 -73
  12. package/public/favicon.ico +0 -0
  13. package/public/index.html +0 -43
  14. package/public/logo192.png +0 -0
  15. package/public/logo512.png +0 -0
  16. package/public/manifest.json +0 -25
  17. package/public/robots.txt +0 -2
  18. package/src/App.scss +0 -5
  19. package/src/App.test.tsx +0 -9
  20. package/src/App.tsx +0 -17
  21. package/src/components/PepAnswers.scss +0 -7
  22. package/src/components/PepAnswers.tsx +0 -218
  23. package/src/demo/Done.tsx +0 -21
  24. package/src/demo/Localization.tsx +0 -66
  25. package/src/demo/LocalizationContext.tsx +0 -61
  26. package/src/demo/Pep.tsx +0 -172
  27. package/src/index.css +0 -13
  28. package/src/index.tsx +0 -13
  29. package/src/locales/da.json +0 -98
  30. package/src/locales/de.json +0 -98
  31. package/src/locales/defaultMessages.json +0 -335
  32. package/src/locales/en.json +0 -98
  33. package/src/locales/fi.json +0 -98
  34. package/src/locales/sv.json +0 -98
  35. package/src/locales/whitelist_da.json +0 -2
  36. package/src/locales/whitelist_en.json +0 -2
  37. package/src/locales/whitelist_fi.json +0 -2
  38. package/src/locales/whitelist_sv.json +0 -2
  39. package/src/logo.svg +0 -1
  40. package/src/model/PepModel.ts +0 -54
  41. package/src/pages/IsPep/IsPepMessages.ts +0 -11
  42. package/src/pages/IsPep/IsPepPage.tsx +0 -119
  43. package/src/pages/PepContext.tsx +0 -150
  44. package/src/pages/RelationPage/RelationMessages.ts +0 -74
  45. package/src/pages/RelationPage/RelationPage.tsx +0 -306
  46. package/src/pages/RolePage/RoleMessages.ts +0 -128
  47. package/src/pages/RolePage/RolePage.tsx +0 -359
  48. package/src/pages/StatusPage/StatusMessages.ts +0 -59
  49. package/src/pages/StatusPage/StatusPage.tsx +0 -237
  50. package/src/react-app-env.d.ts +0 -1
  51. package/src/serviceWorker.ts +0 -143
  52. package/src/utils/Possession.ts +0 -41
  53. package/translationRunner.js +0 -7
  54. package/tsconfig.json +0 -26
  55. package/tsconfig_build.json +0 -19
  56. /package/{lib/components → components}/PepAnswers.scss +0 -0
  57. /package/{lib/messages → messages}/src/components/PepAnswers.json +0 -0
  58. /package/{lib/messages → messages}/src/pages/IsPep/IsPepMessages.json +0 -0
  59. /package/{lib/messages → messages}/src/pages/IsPep/IsPepPage.json +0 -0
  60. /package/{lib/messages → messages}/src/pages/RelationPage/RelationMessages.json +0 -0
  61. /package/{lib/messages → messages}/src/pages/RelationPage/RelationPage.json +0 -0
  62. /package/{lib/messages → messages}/src/pages/RolePage/RoleMessages.json +0 -0
  63. /package/{lib/messages → messages}/src/pages/RolePage/RolePage.json +0 -0
  64. /package/{lib/messages → messages}/src/pages/StatusPage/StatusMessages.json +0 -0
  65. /package/{lib/messages → messages}/src/pages/StatusPage/StatusPage.json +0 -0
  66. /package/{lib/model → model}/PepModel.d.ts +0 -0
  67. /package/{lib/model → model}/PepModel.js +0 -0
  68. /package/{lib/pages → pages}/IsPep/IsPepMessages.d.ts +0 -0
  69. /package/{lib/pages → pages}/IsPep/IsPepMessages.js +0 -0
  70. /package/{lib/pages → pages}/PepContext.d.ts +0 -0
  71. /package/{lib/pages → pages}/PepContext.js +0 -0
  72. /package/{lib/pages → pages}/RelationPage/RelationMessages.d.ts +0 -0
  73. /package/{lib/pages → pages}/RelationPage/RelationMessages.js +0 -0
  74. /package/{lib/pages → pages}/RelationPage/RelationPage.d.ts +0 -0
  75. /package/{lib/pages → pages}/RelationPage/RelationPage.js +0 -0
  76. /package/{lib/pages → pages}/RolePage/RoleMessages.d.ts +0 -0
  77. /package/{lib/pages → pages}/RolePage/RoleMessages.js +0 -0
  78. /package/{lib/pages → pages}/RolePage/RolePage.d.ts +0 -0
  79. /package/{lib/pages → pages}/RolePage/RolePage.js +0 -0
  80. /package/{lib/pages → pages}/StatusPage/StatusMessages.d.ts +0 -0
  81. /package/{lib/pages → pages}/StatusPage/StatusMessages.js +0 -0
  82. /package/{lib/pages → pages}/StatusPage/StatusPage.d.ts +0 -0
  83. /package/{lib/pages → pages}/StatusPage/StatusPage.js +0 -0
  84. /package/{lib/utils → utils}/Possession.d.ts +0 -0
  85. /package/{lib/utils → utils}/Possession.js +0 -0
@@ -1,237 +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
- LysaFormRef,
12
- Datepicker,
13
- Card,
14
- CountrySelect,
15
- Language,
16
- WorldCountry,
17
- Button,
18
- } from "@lysaab/ui-2";
19
- import { Alternative } from "@lysaab/ui-2/components/input/InputAPI";
20
- import { PepContext, PepStatus, EntityType, PepType } from "../PepContext";
21
- import { useIntl, FormattedMessage, IntlShape } from "react-intl";
22
- import {
23
- isOngoingMessages,
24
- endedMessages,
25
- isLocalCountryMessages,
26
- countrySelectionMessages,
27
- localCountryAltMessages,
28
- stateAltMessages,
29
- } from "./StatusMessages";
30
- import { formatPossessive } from "../../utils/Possession";
31
-
32
- interface Props {
33
- countryName: string;
34
- countryCode: WorldCountry;
35
- language: Language;
36
- next: () => void;
37
- }
38
-
39
- export const StatusPage: FunctionComponent<Props> = ({
40
- countryName,
41
- countryCode,
42
- language,
43
- next,
44
- }) => {
45
- const pepContext = useContext(PepContext);
46
- const formRef = useRef<LysaFormRef>();
47
- const intl = useIntl();
48
- const stateAlternatives = getStateAlternatives(intl);
49
- const isLocalCountryAlternatives = getIsLocalCountryAlternatives(
50
- intl,
51
- countryName
52
- );
53
- const entityType = pepContext.state.legalEntityType || EntityType.PERSON;
54
-
55
- const nextPage = useCallback(() => {
56
- if (formRef.current && formRef.current.isValid) {
57
- next();
58
- }
59
- }, [formRef, next]);
60
-
61
- const updateIsLocalCountry = useCallback(
62
- (alternative: Alternative<string>) => {
63
- pepContext.setState({ isLocalCountry: alternative.value });
64
-
65
- if (alternative.value === "other") {
66
- pepContext.setState({ country: undefined });
67
- } else {
68
- pepContext.setState({ country: countryCode });
69
- }
70
- },
71
- [pepContext, countryCode]
72
- );
73
-
74
- const updateIsOngoing = useCallback(
75
- (alternative: Alternative<PepStatus>) => {
76
- pepContext.setState({ isOngoing: alternative.value });
77
-
78
- if (alternative.value === PepStatus.ONGOING) {
79
- pepContext.setState({ ended: undefined });
80
- }
81
- },
82
- [pepContext]
83
- );
84
-
85
- return (
86
- <div>
87
- <Form
88
- lysaFormRef={formRef}
89
- onSubmit={() => {
90
- nextPage();
91
- }}
92
- >
93
- <Card>
94
- <RadioGroup
95
- alternatives={stateAlternatives}
96
- header={intl.formatMessage(isOngoingMessages.header, {
97
- entityType,
98
- name: pepContext.state.ownerName,
99
- possessiveName: formatPossessive(
100
- pepContext.state.ownerName,
101
- intl.locale
102
- ),
103
- relation:
104
- pepContext.state.type === PepType.COLLEAGUE
105
- ? pepContext.state.businessRelation
106
- : pepContext.state.relationToPEP,
107
- pepType: pepContext.state.type,
108
- })}
109
- onChange={updateIsOngoing}
110
- value={stateAlternatives.find(
111
- (alt) => alt.value === pepContext.state.isOngoing
112
- )}
113
- validators={[
114
- new RequiredValidator(
115
- intl.formatMessage(isOngoingMessages.required)
116
- ),
117
- ]}
118
- />
119
-
120
- {pepContext.state.isOngoing &&
121
- pepContext.state.isOngoing === PepStatus.ENDED ? (
122
- <Datepicker
123
- label={intl.formatMessage(endedMessages.header)}
124
- selected={pepContext.state.ended}
125
- onChange={(event) => {
126
- // event has a type that says it can be [startDate, endDate]
127
- // but we know that will never be the case here
128
- pepContext.setState({ ended: (event as Date) || undefined });
129
- }}
130
- validators={[
131
- new RequiredValidator(
132
- intl.formatMessage(endedMessages.required)
133
- ),
134
- ]}
135
- showMonthYearPicker
136
- dateFormat="yyyy-MM"
137
- maxDate={new Date()}
138
- />
139
- ) : null}
140
- </Card>
141
-
142
- <Card>
143
- <RadioGroup
144
- alternatives={isLocalCountryAlternatives}
145
- header={intl.formatMessage(isLocalCountryMessages.header, {
146
- possessiveName: formatPossessive(
147
- pepContext.state.ownerName,
148
- intl.locale
149
- ),
150
- })}
151
- onChange={updateIsLocalCountry}
152
- value={isLocalCountryAlternatives.find(
153
- (alt) => alt.value === pepContext.state.isLocalCountry
154
- )}
155
- validators={[
156
- new RequiredValidator(
157
- intl.formatMessage(isLocalCountryMessages.required)
158
- ),
159
- ]}
160
- />
161
-
162
- {pepContext.state.isLocalCountry &&
163
- pepContext.state.isLocalCountry === "other" ? (
164
- <CountrySelect
165
- label={intl.formatMessage(countrySelectionMessages.header, {
166
- entityType,
167
- name: pepContext.state.ownerName,
168
- possessiveName: formatPossessive(
169
- pepContext.state.ownerName,
170
- intl.locale
171
- ),
172
- relation:
173
- pepContext.state.type === PepType.COLLEAGUE
174
- ? pepContext.state.businessRelation
175
- : pepContext.state.relationToPEP,
176
- pepType: pepContext.state.type,
177
- })}
178
- onChange={(event) =>
179
- pepContext.setState({
180
- country: event.value ? event.value : undefined,
181
- })
182
- }
183
- validators={[
184
- new RequiredValidator(
185
- intl.formatMessage(countrySelectionMessages.required)
186
- ),
187
- ]}
188
- value={pepContext.state.country}
189
- omitList={[countryCode]}
190
- language={language}
191
- placeholder={intl.formatMessage(
192
- countrySelectionMessages.placeholder
193
- )}
194
- />
195
- ) : null}
196
- </Card>
197
-
198
- <Button
199
- label={<FormattedMessage id="pep.status.next" />}
200
- block
201
- type="submit"
202
- />
203
- </Form>
204
- </div>
205
- );
206
- };
207
-
208
- function getIsLocalCountryAlternatives(
209
- intl: IntlShape,
210
- countryName: string
211
- ): Alternative<string>[] {
212
- return [
213
- {
214
- text: intl.formatMessage(localCountryAltMessages.localCountry, {
215
- countryName,
216
- }),
217
- value: "local",
218
- },
219
- {
220
- text: intl.formatMessage(localCountryAltMessages.otherCountry),
221
- value: "other",
222
- },
223
- ];
224
- }
225
-
226
- function getStateAlternatives(intl: IntlShape): Alternative<PepStatus>[] {
227
- return [
228
- {
229
- text: intl.formatMessage(stateAltMessages[PepStatus.ONGOING]),
230
- value: PepStatus.ONGOING,
231
- },
232
- {
233
- text: intl.formatMessage(stateAltMessages[PepStatus.ENDED]),
234
- value: PepStatus.ENDED,
235
- },
236
- ];
237
- }
@@ -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,41 +0,0 @@
1
- export function formatPossessive(text: string | undefined, locale: string) {
2
- if (!text) {
3
- return;
4
- }
5
-
6
- const language = locale.substr(0, 2);
7
-
8
- if (language === "sv") {
9
- return formatSwedish(text);
10
- } else if (language === "en") {
11
- return formatEnglish(text);
12
- }
13
-
14
- return text;
15
- }
16
-
17
- function formatSwedish(text: string) {
18
- if (
19
- text[text.length - 1] !== "s" &&
20
- text[text.length - 1] !== "z" &&
21
- text[text.length - 1] !== "x"
22
- ) {
23
- text += "s";
24
- }
25
- return text;
26
- }
27
-
28
- // There are no proper rules for English
29
- // Jess -> Jess's
30
- // Charles -> Charles's or Charles'
31
- // Jesus -> Jesus'
32
- // Martinez -> Martinez's or Martinez'
33
- // Alex -> Alex's
34
- // Hendrix -> Hendrix'
35
- function formatEnglish(text: string) {
36
- if (text[text.length - 1] === "s") {
37
- return text + "'";
38
- }
39
-
40
- return text + "'s";
41
- }
@@ -1,7 +0,0 @@
1
- const manageTranslations = require("react-intl-translations-manager").default;
2
- manageTranslations({
3
- messagesDirectory: "build/messages",
4
- translationsDirectory: "src/locales",
5
- languages: ["en", "sv", "da", "fi"],
6
- singleMessagesFile: true,
7
- });
package/tsconfig.json DELETED
@@ -1,26 +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-jsx",
21
- "noFallthroughCasesInSwitch": true
22
- },
23
- "include": [
24
- "src"
25
- ]
26
- }
@@ -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
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes