back-testing-react 1.0.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 (53) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/index.js +132 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/dist/esm/index.js +132 -0
  5. package/dist/esm/index.js.map +1 -0
  6. package/dist/types.d.ts +2 -0
  7. package/package.json +49 -0
  8. package/rollup.config.js +42 -0
  9. package/src/components/back-testing-cat-legend/back-testing-cat-legend.css +36 -0
  10. package/src/components/back-testing-cat-legend/back-testing-cat-legend.stories.tsx +12 -0
  11. package/src/components/back-testing-cat-legend/back-testing-cat-legend.tsx +23 -0
  12. package/src/components/back-testing-cat-legend/back-testing-cat-legend.types.ts +3 -0
  13. package/src/components/back-testing-cat-legend/index.ts +1 -0
  14. package/src/components/back-testing-map/back-testing-map.css +39 -0
  15. package/src/components/back-testing-map/back-testing-map.service.ts +63 -0
  16. package/src/components/back-testing-map/back-testing-map.stories.tsx +427 -0
  17. package/src/components/back-testing-map/back-testing-map.tsx +503 -0
  18. package/src/components/back-testing-map/back-testing-map.types.ts +176 -0
  19. package/src/components/back-testing-map/index.ts +1 -0
  20. package/src/components/back-testing-storm-legend/back-testing-storm-legend.css +3 -0
  21. package/src/components/back-testing-storm-legend/back-testing-storm-legend.stories.tsx +98 -0
  22. package/src/components/back-testing-storm-legend/back-testing-storm-legend.tsx +28 -0
  23. package/src/components/back-testing-storm-legend/back-testing-storm-legend.types.ts +6 -0
  24. package/src/components/back-testing-storm-legend/index.ts +1 -0
  25. package/src/components/index.ts +3 -0
  26. package/src/index.ts +1 -0
  27. package/src/stories/Button.stories.ts +53 -0
  28. package/src/stories/Button.tsx +37 -0
  29. package/src/stories/Configure.mdx +364 -0
  30. package/src/stories/Header.stories.ts +33 -0
  31. package/src/stories/Header.tsx +56 -0
  32. package/src/stories/Page.stories.ts +32 -0
  33. package/src/stories/Page.tsx +73 -0
  34. package/src/stories/assets/accessibility.png +0 -0
  35. package/src/stories/assets/accessibility.svg +1 -0
  36. package/src/stories/assets/addon-library.png +0 -0
  37. package/src/stories/assets/assets.png +0 -0
  38. package/src/stories/assets/avif-test-image.avif +0 -0
  39. package/src/stories/assets/context.png +0 -0
  40. package/src/stories/assets/discord.svg +1 -0
  41. package/src/stories/assets/docs.png +0 -0
  42. package/src/stories/assets/figma-plugin.png +0 -0
  43. package/src/stories/assets/github.svg +1 -0
  44. package/src/stories/assets/share.png +0 -0
  45. package/src/stories/assets/styling.png +0 -0
  46. package/src/stories/assets/testing.png +0 -0
  47. package/src/stories/assets/theming.png +0 -0
  48. package/src/stories/assets/tutorials.svg +1 -0
  49. package/src/stories/assets/youtube.svg +1 -0
  50. package/src/stories/button.css +30 -0
  51. package/src/stories/header.css +32 -0
  52. package/src/stories/page.css +69 -0
  53. package/tsconfig.json +20 -0
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "back-testing-react",
3
+ "version": "1.0.0",
4
+ "description": "Parametric back testing application developed by NormanMax Insurance Solutions",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "rollup": "rollup -c --bundleConfigAsCjs",
10
+ "storybook": "storybook dev -p 6006",
11
+ "build-storybook": "storybook build"
12
+ },
13
+ "author": "Alex Dubuisson",
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "@babel/preset-typescript": "^7.26.0",
17
+ "@chromatic-com/storybook": "^3.2.2",
18
+ "@rollup/plugin-commonjs": "^28.0.1",
19
+ "@rollup/plugin-node-resolve": "^15.3.0",
20
+ "@rollup/plugin-terser": "^0.4.4",
21
+ "@rollup/plugin-typescript": "^12.1.1",
22
+ "@storybook/addon-essentials": "^8.4.2",
23
+ "@storybook/addon-interactions": "^8.4.2",
24
+ "@storybook/addon-onboarding": "^8.4.2",
25
+ "@storybook/blocks": "^8.4.2",
26
+ "@storybook/react": "^8.4.2",
27
+ "@storybook/react-vite": "^8.4.2",
28
+ "@storybook/test": "^8.4.2",
29
+ "@types/react": "^18.3.12",
30
+ "react": "^18.3.1",
31
+ "rollup": "^4.25.0",
32
+ "rollup-plugin-dts": "^6.1.1",
33
+ "rollup-plugin-peer-deps-external": "^2.2.4",
34
+ "rollup-plugin-postcss": "^4.0.2",
35
+ "storybook": "^8.4.2",
36
+ "tslib": "^2.8.1",
37
+ "typescript": "^5.6.3"
38
+ },
39
+ "dependencies": {
40
+ "@emotion/react": "^11.13.3",
41
+ "@emotion/styled": "^11.13.0",
42
+ "@mapbox/search-js-core": "^1.0.0-beta.22",
43
+ "@mui/material": "^6.1.6",
44
+ "@turf/turf": "^7.1.0",
45
+ "@types/react-dom": "^18.3.1",
46
+ "mapbox-gl": "^3.8.0",
47
+ "react-dom": "^18.3.1"
48
+ }
49
+ }
@@ -0,0 +1,42 @@
1
+ import resolve from "@rollup/plugin-node-resolve";
2
+ import commonjs from "@rollup/plugin-commonjs";
3
+ import typescript from "@rollup/plugin-typescript";
4
+ import dts from "rollup-plugin-dts";
5
+ import terser from "@rollup/plugin-terser";
6
+ import peerDepsExternal from "rollup-plugin-peer-deps-external";
7
+
8
+ const packageJson = require("./package.json");
9
+ import postcss from 'rollup-plugin-postcss'
10
+
11
+ export default [
12
+ {
13
+ input: "src/index.ts",
14
+ output: [
15
+ {
16
+ file: packageJson.main,
17
+ format: "cjs",
18
+ sourcemap: true,
19
+ },
20
+ {
21
+ file: packageJson.module,
22
+ format: "esm",
23
+ sourcemap: true,
24
+ },
25
+ ],
26
+ plugins: [
27
+ peerDepsExternal(),
28
+ resolve(),
29
+ commonjs(),
30
+ typescript({ tsconfig: "./tsconfig.json" }),
31
+ terser(),
32
+ postcss(),
33
+ ],
34
+ external: ["react", "react-dom"],
35
+ },
36
+ {
37
+ input: "src/index.ts",
38
+ output: [{ file: "dist/types.d.ts", format: "es" }],
39
+ plugins: [dts.default()],
40
+ external: [/\.css$/],
41
+ },
42
+ ];
@@ -0,0 +1,36 @@
1
+ .legend{
2
+ --legend-font-size: 10px;
3
+ --legend-padding: 5px;
4
+ width: 250px;
5
+ height: 20px;
6
+ position:absolute;
7
+ z-index:10;
8
+ background-color: white;
9
+ padding: 0;
10
+ display:inline-flex;
11
+ border-radius:3px;
12
+ box-shadow: 2px 2px 6px gray;
13
+ }
14
+
15
+ .legend > .item-container {
16
+ display:inline-flex;
17
+ padding:0;
18
+ position:absolute;
19
+ top: 5px;
20
+ left: 5px;
21
+ }
22
+
23
+ .legend > .item-container:hover > item {
24
+ opacity: 0.2;
25
+ }
26
+
27
+ .legend > .item-container > .item {
28
+ height: var(--legend-font-size);
29
+ width:30px;
30
+ display:inline-flex;
31
+ padding:0;
32
+ }
33
+
34
+ .legend > .item-container > .item:hover {
35
+ opacity: 1 !important;
36
+ }
@@ -0,0 +1,12 @@
1
+ import { StoryFn, Meta } from "@storybook/react";
2
+ import BackTestingCatLegend from "./back-testing-cat-legend";
3
+
4
+ export default {
5
+ title: "ReactComponentLibrary/BackTestingCATLegend",
6
+ component: BackTestingCatLegend,
7
+ } as Meta<typeof BackTestingCatLegend>;
8
+
9
+ const Template: StoryFn<typeof BackTestingCatLegend> = (args) => <BackTestingCatLegend {...args} />;
10
+
11
+ export const CatLegendTest = Template.bind({});
12
+ CatLegendTest.args = {};
@@ -0,0 +1,23 @@
1
+ import { Tooltip } from '@mui/material';
2
+ import { generateCATColor } from '../back-testing-map/back-testing-map.types';
3
+ import './back-testing-cat-legend.css'
4
+ import { BackTestingCatLegendProps } from './back-testing-cat-legend.types';
5
+
6
+ const BackTestingCatLegend = (props: BackTestingCatLegendProps) => {
7
+ return(
8
+ <div className={props.className + " legend"}>
9
+ <div className="item-container">
10
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Category 5</span>}><span className="item" style={{backgroundColor:generateCATColor(5)}}/></Tooltip>
11
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Category 4</span>}><span className="item" style={{backgroundColor:generateCATColor(4)}}/></Tooltip>
12
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Category 3</span>}><span className="item" style={{backgroundColor:generateCATColor(3)}}/></Tooltip>
13
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Category 2</span>}><span className="item" style={{backgroundColor:generateCATColor(2)}}/></Tooltip>
14
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Category 1</span>}><span className="item" style={{backgroundColor:generateCATColor(1)}}/></Tooltip>
15
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Tropical Storm</span>}><span className="item" style={{backgroundColor:generateCATColor(0)}}/></Tooltip>
16
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Tropical Depression</span>}><span className="item" style={{backgroundColor:generateCATColor(-1)}}/></Tooltip>
17
+ <Tooltip title={<span style={{ fontSize:'1.25em', padding:'2px' }}>Tropical Expression</span>}><span className="item" style={{backgroundColor:generateCATColor(-2)}}/></Tooltip>
18
+ </div>
19
+ </div>
20
+ );
21
+ }
22
+
23
+ export default BackTestingCatLegend
@@ -0,0 +1,3 @@
1
+ export interface BackTestingCatLegendProps {
2
+ className?: string
3
+ }
@@ -0,0 +1 @@
1
+ export {default} from './back-testing-cat-legend';
@@ -0,0 +1,39 @@
1
+ body{
2
+ padding: 0;
3
+ margin: 0;
4
+ }
5
+
6
+ .map__wrapper{
7
+ width: 100%;
8
+ height: 100vh;
9
+ display: grid;
10
+ grid-template-columns: 1fr;
11
+ }
12
+
13
+ .map__wrapper > div {
14
+ position: relative;
15
+ grid-row-start: 1;
16
+ grid-column-start: 1;
17
+ }
18
+
19
+ .map__wrapper > div.map__views {
20
+ position: relative;
21
+ width: fit-content;
22
+ height: fit-content;
23
+ margin-left: auto;
24
+ right: 20px;
25
+ top: 15px;
26
+ }
27
+
28
+ .map__wrapper .cat__legend{
29
+ top: 15px;
30
+ margin-left: calc( calc( 100% - 250px)/2);
31
+ }
32
+
33
+ .map__wrapper div.mapboxgl-ctrl-attrib-inner{
34
+ display:none;
35
+ }
36
+
37
+ .map__wrapper div.mapboxgl-ctrl-bottom-left{
38
+ display:none;
39
+ }
@@ -0,0 +1,63 @@
1
+ import { Point } from "geojson";
2
+ import { PayoutRequest } from "./back-testing-map.types";
3
+
4
+ const API_ROOT_URI='https://api-uat.nms3939.com'
5
+
6
+ export class AppConfig {
7
+ public static readonly endpoints = {
8
+ auth: {
9
+ generateAuthToken : '/auth/generateAuthToken'
10
+ },
11
+ rating: {
12
+ rate: '/rating/rate',
13
+ hazardTool: '/rating/hazardTool'
14
+ },
15
+ backTesting: {
16
+ payouts: '/backTesting/payouts',
17
+ getMapAccessToken: '/backTesting/getMapToken'
18
+ }
19
+ }
20
+ }
21
+
22
+ export interface StormPayout {
23
+ name: string;
24
+ year: number;
25
+ windspeedMPH: number;
26
+ proxyPayout: number;
27
+ anemometerPayout: number;
28
+ category: number;
29
+ ciacPayout: number;
30
+ maxRecovery: number;
31
+ maxRecoveryAmount: number;
32
+ color?: string;
33
+ stormTrack:{
34
+ NAME: string;
35
+ SEASON: number;
36
+ ISO_TIME: string,
37
+ USA_WIND: number;
38
+ USA_SSHS: number;
39
+ LOCATION: Point
40
+ }[]
41
+ }
42
+
43
+ export interface PayoutResponse {
44
+ status: number;
45
+ payouts: StormPayout[];
46
+ }
47
+
48
+ export const fetchPayouts = async (request: PayoutRequest, apiKey: string) => {
49
+ const url = API_ROOT_URI + AppConfig.endpoints.backTesting.payouts;
50
+
51
+ const response = await fetch(url, {
52
+ method: "POST",
53
+ headers: {
54
+ "Content-Type": "application/json",
55
+ "x-api-key": apiKey
56
+ },
57
+ body: JSON.stringify(request),
58
+ });
59
+
60
+ const result: PayoutResponse = await response.json();
61
+ return result;
62
+
63
+ };
@@ -0,0 +1,427 @@
1
+ import { StoryFn, Meta } from "@storybook/react";
2
+ import BackTestingMap from "./back-testing-map";
3
+ import { Payout } from "./back-testing-map.types";
4
+
5
+ export default {
6
+ title: "ReactComponentLibrary/BackTestingMap",
7
+ component: BackTestingMap,
8
+ } as Meta<typeof BackTestingMap>;
9
+
10
+ const Template: StoryFn<typeof BackTestingMap> = (args) => <BackTestingMap {...args} />;
11
+
12
+ export const MapTest = Template.bind({});
13
+ MapTest.args = {
14
+ location: {longitude:-80.188332,latitude:25.781441},
15
+ ciacRadius: 15,
16
+ limit: 1250000,
17
+ anemometerCode: 'BBH',
18
+ ciacPayouts: defaultCiacPayoutTable(),
19
+ proxyPayouts: defaultProxyPayoutTable(),
20
+ anemometerPayouts: defaultAnemometerPayoutTable()
21
+ };
22
+
23
+ function defaultProxyPayoutTable() {
24
+ const retVal : Payout[] = [
25
+ {
26
+ "category": 74,
27
+ "payout": 0.05
28
+ },
29
+ {
30
+ "category": 75,
31
+ "payout": 0.055
32
+ },
33
+ {
34
+ "category": 76,
35
+ "payout": 0.06
36
+ },
37
+ {
38
+ "category": 77,
39
+ "payout": 0.065
40
+ },
41
+ {
42
+ "category": 78,
43
+ "payout": 0.07
44
+ },
45
+ {
46
+ "category": 79,
47
+ "payout": 0.075
48
+ },
49
+ {
50
+ "category": 80,
51
+ "payout": 0.08
52
+ },
53
+ {
54
+ "category": 81,
55
+ "payout": 0.085
56
+ },
57
+ {
58
+ "category": 82,
59
+ "payout": 0.09
60
+ },
61
+ {
62
+ "category": 83,
63
+ "payout": 0.095
64
+ },
65
+ {
66
+ "category": 84,
67
+ "payout": 0.1
68
+ },
69
+ {
70
+ "category": 85,
71
+ "payout": 0.11
72
+ },
73
+ {
74
+ "category": 86,
75
+ "payout": 0.12
76
+ },
77
+ {
78
+ "category": 87,
79
+ "payout": 0.13
80
+ },
81
+ {
82
+ "category": 88,
83
+ "payout": 0.14
84
+ },
85
+ {
86
+ "category": 89,
87
+ "payout": 0.15
88
+ },
89
+ {
90
+ "category": 90,
91
+ "payout": 0.16
92
+ },
93
+ {
94
+ "category": 91,
95
+ "payout": 0.17
96
+ },
97
+ {
98
+ "category": 92,
99
+ "payout": 0.18
100
+ },
101
+ {
102
+ "category": 93,
103
+ "payout": 0.19
104
+ },
105
+ {
106
+ "category": 94,
107
+ "payout": 0.2
108
+ },
109
+ {
110
+ "category": 95,
111
+ "payout": 0.22
112
+ },
113
+ {
114
+ "category": 96,
115
+ "payout": 0.24
116
+ },
117
+ {
118
+ "category": 97,
119
+ "payout": 0.26
120
+ },
121
+ {
122
+ "category": 98,
123
+ "payout": 0.28
124
+ },
125
+ {
126
+ "category": 99,
127
+ "payout": 0.3
128
+ },
129
+ {
130
+ "category": 100,
131
+ "payout": 0.32
132
+ },
133
+ {
134
+ "category": 101,
135
+ "payout": 0.34
136
+ },
137
+ {
138
+ "category": 102,
139
+ "payout": 0.36
140
+ },
141
+ {
142
+ "category": 103,
143
+ "payout": 0.38
144
+ },
145
+ {
146
+ "category": 104,
147
+ "payout": 0.4
148
+ },
149
+ {
150
+ "category": 105,
151
+ "payout": 0.42
152
+ },
153
+ {
154
+ "category": 106,
155
+ "payout": 0.44
156
+ },
157
+ {
158
+ "category": 107,
159
+ "payout": 0.46
160
+ },
161
+ {
162
+ "category": 108,
163
+ "payout": 0.48
164
+ },
165
+ {
166
+ "category": 109,
167
+ "payout": 0.5
168
+ },
169
+ {
170
+ "category": 110,
171
+ "payout": 0.55
172
+ },
173
+ {
174
+ "category": 111,
175
+ "payout": 0.6
176
+ },
177
+ {
178
+ "category": 112,
179
+ "payout": 0.65
180
+ },
181
+ {
182
+ "category": 113,
183
+ "payout": 0.7
184
+ },
185
+ {
186
+ "category": 114,
187
+ "payout": 0.75
188
+ },
189
+ {
190
+ "category": 115,
191
+ "payout": 0.8
192
+ },
193
+ {
194
+ "category": 116,
195
+ "payout": 0.85
196
+ },
197
+ {
198
+ "category": 117,
199
+ "payout": 0.9
200
+ },
201
+ {
202
+ "category": 118,
203
+ "payout": 0.95
204
+ },
205
+ {
206
+ "category": 119,
207
+ "payout": 1
208
+ }
209
+ ]
210
+ return retVal
211
+ }
212
+
213
+ function defaultAnemometerPayoutTable() {
214
+ const retVal : Payout[] = [
215
+ {
216
+ "category": 74,
217
+ "payout": 0.05
218
+ },
219
+ {
220
+ "category": 75,
221
+ "payout": 0.055
222
+ },
223
+ {
224
+ "category": 76,
225
+ "payout": 0.06
226
+ },
227
+ {
228
+ "category": 77,
229
+ "payout": 0.065
230
+ },
231
+ {
232
+ "category": 78,
233
+ "payout": 0.07
234
+ },
235
+ {
236
+ "category": 79,
237
+ "payout": 0.075
238
+ },
239
+ {
240
+ "category": 80,
241
+ "payout": 0.08
242
+ },
243
+ {
244
+ "category": 81,
245
+ "payout": 0.085
246
+ },
247
+ {
248
+ "category": 82,
249
+ "payout": 0.09
250
+ },
251
+ {
252
+ "category": 83,
253
+ "payout": 0.095
254
+ },
255
+ {
256
+ "category": 84,
257
+ "payout": 0.1
258
+ },
259
+ {
260
+ "category": 85,
261
+ "payout": 0.11
262
+ },
263
+ {
264
+ "category": 86,
265
+ "payout": 0.12
266
+ },
267
+ {
268
+ "category": 87,
269
+ "payout": 0.13
270
+ },
271
+ {
272
+ "category": 88,
273
+ "payout": 0.14
274
+ },
275
+ {
276
+ "category": 89,
277
+ "payout": 0.15
278
+ },
279
+ {
280
+ "category": 90,
281
+ "payout": 0.16
282
+ },
283
+ {
284
+ "category": 91,
285
+ "payout": 0.17
286
+ },
287
+ {
288
+ "category": 92,
289
+ "payout": 0.18
290
+ },
291
+ {
292
+ "category": 93,
293
+ "payout": 0.19
294
+ },
295
+ {
296
+ "category": 94,
297
+ "payout": 0.2
298
+ },
299
+ {
300
+ "category": 95,
301
+ "payout": 0.22
302
+ },
303
+ {
304
+ "category": 96,
305
+ "payout": 0.24
306
+ },
307
+ {
308
+ "category": 97,
309
+ "payout": 0.26
310
+ },
311
+ {
312
+ "category": 98,
313
+ "payout": 0.28
314
+ },
315
+ {
316
+ "category": 99,
317
+ "payout": 0.3
318
+ },
319
+ {
320
+ "category": 100,
321
+ "payout": 0.32
322
+ },
323
+ {
324
+ "category": 101,
325
+ "payout": 0.34
326
+ },
327
+ {
328
+ "category": 102,
329
+ "payout": 0.36
330
+ },
331
+ {
332
+ "category": 103,
333
+ "payout": 0.38
334
+ },
335
+ {
336
+ "category": 104,
337
+ "payout": 0.4
338
+ },
339
+ {
340
+ "category": 105,
341
+ "payout": 0.42
342
+ },
343
+ {
344
+ "category": 106,
345
+ "payout": 0.44
346
+ },
347
+ {
348
+ "category": 107,
349
+ "payout": 0.46
350
+ },
351
+ {
352
+ "category": 108,
353
+ "payout": 0.48
354
+ },
355
+ {
356
+ "category": 109,
357
+ "payout": 0.5
358
+ },
359
+ {
360
+ "category": 110,
361
+ "payout": 0.55
362
+ },
363
+ {
364
+ "category": 111,
365
+ "payout": 0.6
366
+ },
367
+ {
368
+ "category": 112,
369
+ "payout": 0.65
370
+ },
371
+ {
372
+ "category": 113,
373
+ "payout": 0.7
374
+ },
375
+ {
376
+ "category": 114,
377
+ "payout": 0.75
378
+ },
379
+ {
380
+ "category": 115,
381
+ "payout": 0.8
382
+ },
383
+ {
384
+ "category": 116,
385
+ "payout": 0.85
386
+ },
387
+ {
388
+ "category": 117,
389
+ "payout": 0.9
390
+ },
391
+ {
392
+ "category": 118,
393
+ "payout": 0.95
394
+ },
395
+ {
396
+ "category": 119,
397
+ "payout": 1
398
+ }
399
+ ]
400
+ return retVal
401
+ }
402
+
403
+ function defaultCiacPayoutTable() {
404
+ const retVal : Payout[] = [
405
+ {
406
+ "category": 1,
407
+ "payout": 0.1
408
+ },
409
+ {
410
+ "category": 2,
411
+ "payout": 0.25
412
+ },
413
+ {
414
+ "category": 3,
415
+ "payout": 0.5
416
+ },
417
+ {
418
+ "category": 4,
419
+ "payout": 0.75
420
+ },
421
+ {
422
+ "category": 5,
423
+ "payout": 1
424
+ }
425
+ ]
426
+ return retVal;
427
+ }