@iress-oss/ids-mcp-server 6.0.0-alpha.1-canary-20251204032753-fe18cab → 6.0.0-alpha.1-canary-20251204040305-3639454

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 (99) hide show
  1. package/generated/docs/components_components-alert-docs.md +1054 -0
  2. package/generated/docs/components_components-autocomplete-docs.md +3304 -0
  3. package/generated/docs/components_components-autocomplete-recipes-docs.md +98 -0
  4. package/generated/docs/components_components-badge-docs.md +312 -0
  5. package/generated/docs/components_components-button-docs.md +2339 -0
  6. package/generated/docs/components_components-buttongroup-docs.md +980 -0
  7. package/generated/docs/components_components-card-docs.md +1970 -0
  8. package/generated/docs/components_components-checkbox-docs.md +1083 -0
  9. package/generated/docs/components_components-checkboxgroup-docs.md +1597 -0
  10. package/generated/docs/components_components-checkboxgroup-recipes-docs.md +209 -0
  11. package/generated/docs/components_components-col-docs.md +755 -0
  12. package/generated/docs/components_components-container-docs.md +172 -0
  13. package/generated/docs/components_components-divider-docs.md +235 -0
  14. package/generated/docs/components_components-expander-docs.md +428 -0
  15. package/generated/docs/components_components-field-docs.md +3345 -0
  16. package/generated/docs/components_components-filter-docs.md +4091 -0
  17. package/generated/docs/components_components-hide-docs.md +450 -0
  18. package/generated/docs/components_components-icon-docs.md +1017 -0
  19. package/generated/docs/components_components-image-docs.md +168 -0
  20. package/generated/docs/components_components-inline-docs.md +1962 -0
  21. package/generated/docs/components_components-input-docs.md +1388 -0
  22. package/generated/docs/components_components-input-recipes-docs.md +349 -0
  23. package/generated/docs/components_components-inputcurrency-docs.md +636 -0
  24. package/generated/docs/components_components-inputcurrency-recipes-docs.md +208 -0
  25. package/generated/docs/components_components-introduction-docs.md +448 -0
  26. package/generated/docs/components_components-label-docs.md +229 -0
  27. package/generated/docs/components_components-link-docs.md +454 -0
  28. package/generated/docs/components_components-menu-docs.md +2219 -0
  29. package/generated/docs/components_components-menu-menuitem-docs.md +1455 -0
  30. package/generated/docs/components_components-modal-docs.md +2002 -0
  31. package/generated/docs/components_components-panel-docs.md +342 -0
  32. package/generated/docs/components_components-placeholder-docs.md +98 -0
  33. package/generated/docs/components_components-popover-docs.md +1631 -0
  34. package/generated/docs/components_components-popover-recipes-docs.md +537 -0
  35. package/generated/docs/components_components-progress-docs.md +128 -0
  36. package/generated/docs/components_components-provider-docs.md +123 -0
  37. package/generated/docs/components_components-radio-docs.md +499 -0
  38. package/generated/docs/components_components-radiogroup-docs.md +1573 -0
  39. package/generated/docs/components_components-readonly-docs.md +277 -0
  40. package/generated/docs/components_components-richselect-docs.md +6101 -0
  41. package/generated/docs/components_components-row-docs.md +2172 -0
  42. package/generated/docs/components_components-select-docs.md +1110 -0
  43. package/generated/docs/components_components-skeleton-docs.md +467 -0
  44. package/generated/docs/components_components-skeleton-recipes-docs.md +110 -0
  45. package/generated/docs/components_components-skiplink-docs.md +220 -0
  46. package/generated/docs/components_components-slideout-docs.md +1910 -0
  47. package/generated/docs/components_components-slider-docs.md +1284 -0
  48. package/generated/docs/components_components-spinner-docs.md +90 -0
  49. package/generated/docs/components_components-stack-docs.md +730 -0
  50. package/generated/docs/components_components-table-docs.md +4038 -0
  51. package/generated/docs/components_components-tabset-docs.md +955 -0
  52. package/generated/docs/components_components-tabset-tab-docs.md +342 -0
  53. package/generated/docs/components_components-tag-docs.md +410 -0
  54. package/generated/docs/components_components-text-docs.md +593 -0
  55. package/generated/docs/components_components-toaster-docs.md +451 -0
  56. package/generated/docs/components_components-toggle-docs.md +513 -0
  57. package/generated/docs/components_components-tooltip-docs.md +564 -0
  58. package/generated/docs/components_components-validationmessage-docs.md +608 -0
  59. package/generated/docs/components_contact-us-docs.md +9 -0
  60. package/generated/docs/components_foundations-accessibility-docs.md +33 -0
  61. package/generated/docs/components_foundations-consistency-docs.md +44 -0
  62. package/generated/docs/components_foundations-content-docs.md +18 -0
  63. package/generated/docs/components_foundations-introduction-docs.md +17 -0
  64. package/generated/docs/components_foundations-principles-docs.md +60 -0
  65. package/generated/docs/components_foundations-responsive-layout-docs.md +2692 -0
  66. package/generated/docs/components_foundations-user-experience-docs.md +53 -0
  67. package/generated/docs/components_foundations-visual-design-docs.md +39 -0
  68. package/generated/docs/components_foundations-z-index-stacking-docs.md +288 -0
  69. package/generated/docs/components_frequently-asked-questions-docs.md +44 -0
  70. package/generated/docs/components_get-started-develop-docs.md +47 -0
  71. package/generated/docs/components_get-started-using-storybook-docs.md +55 -0
  72. package/generated/docs/components_introduction-docs.md +85 -0
  73. package/generated/docs/components_patterns-form-docs.md +2469 -0
  74. package/generated/docs/components_patterns-form-recipes-docs.md +1597 -0
  75. package/generated/docs/components_patterns-introduction-docs.md +31 -0
  76. package/generated/docs/components_patterns-loading-docs.md +1908 -0
  77. package/generated/docs/components_patterns-shadow-docs.md +195 -0
  78. package/generated/docs/components_resources-code-katas-docs.md +25 -0
  79. package/generated/docs/components_resources-introduction-docs.md +28 -0
  80. package/generated/docs/components_resources-mcp-server-docs.md +23 -0
  81. package/generated/docs/components_resources-migration-guides-from-v4-to-v5-docs.md +142 -0
  82. package/generated/docs/components_styling-props-colour-docs.md +91 -0
  83. package/generated/docs/components_styling-props-elevation-docs.md +69 -0
  84. package/generated/docs/components_styling-props-radius-docs.md +63 -0
  85. package/generated/docs/components_styling-props-reference-docs.md +160 -0
  86. package/generated/docs/components_styling-props-screen-readers-docs.md +66 -0
  87. package/generated/docs/components_styling-props-sizing-docs.md +217 -0
  88. package/generated/docs/components_styling-props-spacing-docs.md +545 -0
  89. package/generated/docs/components_styling-props-typography-docs.md +66 -0
  90. package/generated/docs/components_versions-docs.md +14 -0
  91. package/generated/docs/guidelines.md +3083 -0
  92. package/generated/docs/introduction-docs.md +37 -0
  93. package/generated/docs/tokens_colour-docs.md +479 -0
  94. package/generated/docs/tokens_elevation-docs.md +39 -0
  95. package/generated/docs/tokens_introduction-docs.md +150 -0
  96. package/generated/docs/tokens_radius-docs.md +67 -0
  97. package/generated/docs/tokens_spacing-docs.md +87 -0
  98. package/generated/docs/tokens_typography-docs.md +305 -0
  99. package/package.json +2 -2
@@ -0,0 +1,1908 @@
1
+ Loading
2
+ =======
3
+
4
+ Overview
5
+ --------
6
+
7
+ The loading pattern is used to indicate that content is being loaded or processed consistently across Iress products. It can be used in various scenarios, such as loading entire applications, pages, components or server-side validation.
8
+
9
+ * * *
10
+
11
+ Beta
12
+
13
+ **New component**
14
+
15
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
16
+
17
+ [](./iframe.html?id=patterns-loading--wizard)
18
+
19
+ Hide codeRefresh
20
+
21
+ interface PageProps {
22
+ setPage: (page: number) \=> void;
23
+ }
24
+ interface ChartProps {
25
+ money: number | null;
26
+ }
27
+ const API \= {
28
+ initialise: async () \=>
29
+ new Promise<boolean\>((resolve) \=> {
30
+ // Simulate a slow network request.
31
+ setTimeout(() \=> {
32
+ resolve(true);
33
+ }, 3000);
34
+ }),
35
+ data: async () \=>
36
+ new Promise<boolean\>((resolve) \=> {
37
+ // Simulate a slow network request.
38
+ setTimeout(() \=> {
39
+ resolve(true);
40
+ }, 2000);
41
+ }),
42
+ chart: async () \=>
43
+ new Promise<boolean\>((resolve) \=> {
44
+ // Simulate a slow network request.
45
+ setTimeout(() \=> {
46
+ resolve(true);
47
+ }, 2000);
48
+ }),
49
+ chartUpdate: async () \=>
50
+ new Promise<boolean\>((resolve) \=> {
51
+ // Simulate a slow network request.
52
+ setTimeout(() \=> {
53
+ resolve(true);
54
+ }, 2000);
55
+ }),
56
+ };
57
+ const Graph \= () \=> (
58
+ <img
59
+ src\={retirementGraph}
60
+ alt\=""
61
+ style\={{ maxWidth: '100%', height: 'auto' }}
62
+ />
63
+ );
64
+ const Chart \= () \=> {
65
+ const \[chart, setChart\] \= useState(false);
66
+ const \[money, setMoney\] \= useState<number | null\>(null);
67
+ const \[loaded, setLoaded\] \= useState(false);
68
+ const \[updating, setUpdating\] \= useState(false);
69
+ const safeLoaded \= IressLoading.shouldRender(loaded);
70
+ const deferredMoney \= useDeferredValue(money);
71
+ useEffect(() \=> {
72
+ const initialise \= async () \=> {
73
+ const newChart \= await API.chart();
74
+ setChart(newChart);
75
+ setLoaded(() \=> true);
76
+ };
77
+ void initialise();
78
+ }, \[\]);
79
+ useEffect(() \=> {
80
+ if (deferredMoney \=== null) {
81
+ return;
82
+ }
83
+ const update \= async () \=> {
84
+ setUpdating(() \=> true);
85
+ const newChart \= await API.chartUpdate();
86
+ setChart(newChart);
87
+ setUpdating(() \=> false);
88
+ };
89
+ void update();
90
+ }, \[deferredMoney\]);
91
+ return (
92
+ <IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
93
+ {chart && <Graph />}
94
+ <IressPanel\>
95
+ <IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
96
+ > <IressStack gap\="md"\>
97
+ <h3\>Update projection</h3\>
98
+ <IressFormField
99
+ name\="money"
100
+ label\="My money"
101
+ render\={(controlledProps) \=> (
102
+ <IressInputCurrency {...controlledProps} />
103
+ )}
104
+ />
105
+ <IressButton type\="submit"\>Update projection</IressButton\>
106
+ </IressStack\>
107
+ </IressForm\>
108
+ </IressPanel\>
109
+ </IressLoading\>
110
+ );
111
+ };
112
+ const StartPage \= ({ setPage }: PageProps) \=> (
113
+ <IressText\>
114
+ <h2\>Maximise your retirement</h2\>
115
+ <p\>
116
+ Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
117
+ <hr />
118
+ <IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
119
+ </IressText\>
120
+ );
121
+ const RetirementIncomeProjectionPage \= () \=> {
122
+ const \[data, setData\] \= useState(false);
123
+ const loaded \= data !== false;
124
+ const renderLoading \= IressLoading.shouldRender(loaded);
125
+ useEffect(() \=> {
126
+ const initialise \= async () \=> {
127
+ const newData \= await API.data();
128
+ setData(newData);
129
+ };
130
+ void initialise();
131
+ }, \[\]);
132
+ if (renderLoading) {
133
+ return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
134
+ }
135
+ return (
136
+ <IressText\>
137
+ <h2\>Retirement Income Projection</h2\>
138
+ <p\>
139
+ We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
140
+ <Chart />
141
+ </IressText\>
142
+ );
143
+ };
144
+ export const LoadingWizard \= () \=> {
145
+ const \[page, setPage\] \= useState(0);
146
+ const loaded \= page \> 0;
147
+ const renderLoading \= IressLoading.shouldRender(loaded);
148
+ useEffect(() \=> {
149
+ const initialise \= async () \=> {
150
+ await API.initialise();
151
+ setPage(1);
152
+ };
153
+ void initialise();
154
+ }, \[\]);
155
+ if (renderLoading) {
156
+ return <IressLoading pattern\="start-up" loaded\={loaded} />;
157
+ }
158
+ return (
159
+ <IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
160
+ {page \=== 1 && <StartPage setPage\={setPage} />}
161
+ {page \=== 2 && <RetirementIncomeProjectionPage />}
162
+ </IressContainer\>
163
+ );
164
+ };
165
+
166
+ ```
167
+
168
+ Props
169
+ -----
170
+
171
+ Usage
172
+ -----
173
+
174
+ The main prop for the `IressLoading` component is the `pattern` prop. This prop determines the type of loading pattern to be used. The available options are:
175
+
176
+ 1. `component`: This pattern is used to indicate that a specific component is loading. It is typically used when the there is a slower compoent on the page that requires its own loading state. Examples include:
177
+ * Loading a table with a large number of rows
178
+ * Loading a chart with a large number of data points
179
+ 2. `default`: This pattern is used when no other pattern matches a scenario, and will only indicate loading if something is taking a long time to load. It is used when long loading times are not expected. Examples include:
180
+ * Navigation
181
+ 3. `long`: Loading pattern for a component that is expected to take longer than 10 seconds to load. It displays a checklist of items that are being loaded. Examples:
182
+ * Calling multiple slow APIs to load data
183
+ * Loading results from AI
184
+ * Processing a large amount of data as a queue (eg. bulk uploading or large media file uploads)
185
+ 4. `page`: This pattern is used to indicate that a page is loading. It is the most common loading pattern, allowing the users to see the entire content at once where possible. Examples include:
186
+ * Detail page for a record
187
+ * Form/Article page
188
+ * Dashboard page
189
+ 5. `start-up`: This pattern is used to indicate that the application is loading. It is typically used when the application is first launched. Examples include:
190
+ * Loading a new application
191
+ * Switching from a different application to a new application
192
+ * Switching from a client's website to an Iress application
193
+ * Switching themes
194
+ 6. `validate`: This pattern is used to indicate that a server-side validation is in progress. It is typically used when the user is submitting a form or performing an action that requires validation. Examples include:
195
+ * Submitting a form
196
+ * Saving a record
197
+
198
+ It is **recommended** to read the Patterns section of the documentation to understand how to use the loading patterns effectively.
199
+
200
+ ### Be consistent
201
+
202
+ Apart from using the `IressLoading` component, there are a few things you need to do to ensure you are using the loading patterns correctly to ensure consistency across Iress products.
203
+
204
+ * Consider the difference between what the system is doing and what the user is doing. For example, when a user is submitting a form, the system may be calling different APIs and you may be tempted to use the different loading patterns for each API. However, the user is only submitting the form once, so you should only use one loading pattern for the entire form submission process. In most cases, it will be the `page` loading pattern.
205
+ * When switch between different applications, consider using the same loading pattern. This will help mask the loading time and improve the user experience.
206
+
207
+ Behaviour
208
+ ---------
209
+
210
+ The `IressLoading` component is designed to create a seamless experience for users when loading content. They have been designed to meet best practices and improve user perception of loading times.
211
+
212
+ ![Wait times less than 1 second, no loading indicator. Short wait times (1-3 seconds), use a loading indicator. Long wait times (3-10 seconds), use a loading indicator and provide feedback. Wait times longer than 10 seconds should be a background process.](/src/patterns/Loading/assets/ux-collective-loading-time-matrix.webp)
213
+
214
+ Image © [UX Collective](https://uxdesign.cc/loading-progress-indicators-ui-components-series-f4b1fc35339a)
215
+
216
+ * * *
217
+
218
+ To match the above image, the default behaviour of the loading patterns are as follows:
219
+
220
+ * Between 0 - 500ms: No loading indicator, it will be assumed that the content is already loaded.
221
+ * Between 500ms - 2 seconds: A loading indicator will animate in. It will either be a skeleton or a progress bar.
222
+ * Between 2 - 5 seconds: A loading message will animate in.
223
+ * Between 5 - 10 seconds: Some components support additional loading messages. These will animate in and out to indicate that the content is still loading and as well as give the user the perception something is happening in the background.
224
+ * After 10 seconds: Components display a list of messages to indicate what actions the system is doing to complete the user's request. These are checked off as they are completed. This is to give the user the perception that something is happening in the background and to keep them informed of what is happening.
225
+
226
+ In future releases, we will be adding support for the following:
227
+
228
+ * After 10 seconds (background): it is always best not to block the user from using the application even if the system is busy. This will be a future feature of the `long` loading pattern.
229
+
230
+ * * *
231
+
232
+ The `IressLoading` patterns have been built using `IressSkeleton`, `IressSpinner` and `IressProgressBar` and other components, reducing the need to create custom loading components.
233
+
234
+ Patterns
235
+ --------
236
+
237
+ ### `component`
238
+
239
+ The `component` loading pattern is used to indicate that a specific component is loading. It is typically used when the there is a slower component on the page that requires its own loading state. You would usually use this pattern when loading data visualisations such as charts and tables.
240
+
241
+ #### Behavior
242
+
243
+ 1. When `loaded` is false, a skeleton will be displayed immediately (configured using `timeout.skeleton`). This skeleton can be customised using the `template` prop.
244
+ 2. When `loaded` is true, the skeleton will be removed and the `children` will be displayed.
245
+ 3. When `updated` is true, the `children` will be faded out to indicate the component is loading.
246
+ 4. After 1000ms (configured using `timeout.update`), the `Updating...` message will be fade in. This message can be customised using the `updated` prop.
247
+
248
+ #### Custom skeletons
249
+
250
+ The skeleton representing the component should be as simple as possible, it does not need to be a perfect representation of the component. In most cases a simple rectangle is sufficient that takes up the approximate same space as the component that is loading.
251
+
252
+ * * *
253
+
254
+ Beta
255
+
256
+ **New component**
257
+
258
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
259
+
260
+ [](./iframe.html?id=patterns-loading-patterns-component--component)
261
+
262
+ ![](/src/patterns/Loading/mocks/retirement-graph.png)
263
+
264
+ Update
265
+
266
+ Hide codeRefresh
267
+
268
+ const API \= {
269
+ chart: async () \=>
270
+ new Promise<boolean\>((resolve) \=> {
271
+ // Simulate a slow network request.
272
+ setTimeout(() \=> {
273
+ resolve(true);
274
+ }, 2000);
275
+ }),
276
+ chartUpdate: async () \=>
277
+ new Promise<boolean\>((resolve) \=> {
278
+ // Simulate a slow network request.
279
+ setTimeout(() \=> {
280
+ resolve(true);
281
+ }, 2000);
282
+ }),
283
+ };
284
+ const Graph \= () \=> (
285
+ <img
286
+ src\={retirementGraph}
287
+ alt\=""
288
+ style\={{ maxWidth: '100%', height: 'auto' }}
289
+ />
290
+ );
291
+ export const LoadingGraph \= () \=> {
292
+ const \[graph, setGraph\] \= useState(false);
293
+ const \[updating, setUpdating\] \= useState(false);
294
+ const renderLoading \= IressLoading.shouldRender(graph);
295
+ const doUpdate \= useCallback(() \=> {
296
+ const update \= async () \=> {
297
+ await API.chartUpdate();
298
+ setUpdating(false);
299
+ };
300
+ setUpdating(true);
301
+ void update();
302
+ }, \[\]);
303
+ useEffect(() \=> {
304
+ const initialise \= async () \=> {
305
+ setGraph(await API.chart());
306
+ };
307
+ void initialise();
308
+ }, \[\]);
309
+ return (
310
+ <IressLoading
311
+ pattern\="component"
312
+ template\="chart"
313
+ loaded\={!renderLoading}
314
+ update\={updating}
315
+ \>
316
+ <IressStack gap\="md" style\={{ display: 'inline-block' }}\>
317
+ <div\>
318
+ <Graph />
319
+ </div\>
320
+ <IressButton onClick\={doUpdate}\>Update</IressButton\>
321
+ </IressStack\>
322
+ </IressLoading\>
323
+ );
324
+ };
325
+
326
+ ```
327
+
328
+ #### Props
329
+
330
+ | Name | Description | Default | Control |
331
+ | --- | --- | --- | --- |
332
+ | children\* |
333
+ The chart that is being loaded for the first time or being refreshed/updated.
334
+
335
+ ReactNode
336
+
337
+
338
+
339
+ | \- | \- |
340
+ | loaded |
341
+
342
+ If set to `true`, will hide the skeleton and display the chart.
343
+
344
+ boolean
345
+
346
+
347
+
348
+ | \- | \- |
349
+ | pattern |
350
+
351
+ Use `pattern="component"` for the following use cases:
352
+
353
+ * Component that is expected to be slow to load, such as a chart, table or large graphic.
354
+ * Component that can be refreshed/updated with new data.
355
+
356
+ literal
357
+
358
+
359
+
360
+ | \- | \- |
361
+ | screenReaderText |
362
+
363
+ Only screen readers will see this message, it is changed to the `message` after the delay.
364
+
365
+ ReactNode
366
+
367
+
368
+
369
+ |
370
+
371
+ 'Loading...'
372
+
373
+ | \- |
374
+ | template |
375
+
376
+ Which template to use as the skeleton, or you can use a ReactNode to customise the skeleton completely.
377
+
378
+ union
379
+
380
+
381
+
382
+ |
383
+
384
+ 'chart'
385
+
386
+ | \- |
387
+ | timeout |
388
+
389
+ Set the timeouts for showing the skeleton and update messages.
390
+
391
+ { /\*\* \* The time in milliseconds before the skeleton is displayed. \* @default 0 \*/ skeleton?: number; /\*\* \* The time in milliseconds before the update message is displayed. \* @default 1000 \*/ update?: number; }
392
+
393
+ | \- | \- |
394
+ | update |
395
+
396
+ Set the chart to be updated. If a `ReactNode` is provided, it will be displayed as the message. If set to `true`, will display the default message `Updating...`.
397
+
398
+ ReactNode
399
+
400
+
401
+
402
+ | \- | \- |
403
+
404
+ ### `default`
405
+
406
+ The `default` loading pattern is used when no other pattern matches a scenario, and will only indicate loading if something is taking a long time to load. It is used when long loading times are not expected.
407
+
408
+ This pattern is used when the user is navigating between different pages or sections of the application.
409
+
410
+ #### Behavior
411
+
412
+ 1. Displays nothing by default
413
+
414
+ 2. After 3000ms (configured using `timeout`), the `This is taking longer than expected...` message will be slide in from top center. This message can be customised using the `children` prop.
415
+
416
+
417
+ * * *
418
+
419
+ Beta
420
+
421
+ **New component**
422
+
423
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
424
+
425
+ [](./iframe.html?id=patterns-loading-patterns-default--default)
426
+
427
+ This is taking longer than expected...
428
+
429
+ Hide codeRefresh
430
+
431
+ <IressLoading pattern\="default" />
432
+
433
+ ```
434
+
435
+ #### Props
436
+
437
+ | Name | Description | Default | Control |
438
+ | --- | --- | --- | --- |
439
+ | children |
440
+ Message to display when the loading time is longer than expected.
441
+
442
+ ReactNode
443
+
444
+
445
+
446
+ |
447
+
448
+ <IressInline />
449
+
450
+
451
+
452
+ | Set object |
453
+ | pattern |
454
+
455
+ Do not set the `pattern` prop when no other pattern can be applied. It will only show the loading message after a delay, and is intended for use when loading is not expected to take a long time. Example use cases:
456
+
457
+ * Navigating between different routes
458
+ * Calling an API within the page that does not require a loading state
459
+
460
+ literal
461
+
462
+
463
+
464
+ | \- |
465
+
466
+ "default"
467
+
468
+ |
469
+ | screenReaderText |
470
+
471
+ Only screen readers will see this message, it is changed to the `children` message after the delay.
472
+
473
+ ReactNode
474
+
475
+
476
+
477
+ |
478
+
479
+ 'Loading...'
480
+
481
+ | Set object |
482
+ | timeout |
483
+
484
+ Delay in milliseconds before the message is displayed.
485
+
486
+ number
487
+
488
+
489
+
490
+ |
491
+
492
+ 3000
493
+
494
+ | Set number |
495
+
496
+ ### `long`
497
+
498
+ The `long` loading pattern is used to indicate an expected long loading time, usually longer than 10 seconds to complete. It is typically used when calling multiple third-party APIs, AI generation and other long running tasks.
499
+
500
+ It has a required prop, `messageList`, which is an object map where the key is the time you want the message to be marked as completed and the value is the message to display. The messages will be completed (checked off) as the time elapses.
501
+
502
+ #### Behavior
503
+
504
+ 1. When `loaded` is false, a progress bar and check list will be displayed after 500ms (configured using `timeout.message`). This progress bar can be customised using the `renderProgress` prop.
505
+ 2. The messages will rotate until the `loaded` prop is set to true.
506
+ * When a message falls within its elapsed time, it will be displayed with an animated ellipsis, indicating that the system is still working on it.
507
+ * When a message is completed, it will be displayed with a check mark.
508
+ 3. When `loaded` is true, all items in the checklist are completed and the progress bar and message will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
509
+ 4. When `error` is true, the error message will be displayed, overriding the progress bar and checklist. This message can be customised using the `error` prop. The error message will be displayed with a red background.
510
+
511
+ #### Adjusting the progress bar
512
+
513
+ The `long` loading pattern uses a progress bar to indicate that the application is loading alongside an `estimatedFinishTime` prop. This prop is used to indicate the estimated time until the application is fully loaded, and is used to help the user understand how long they will need to wait and assure them something is happening. The progress bar will animate based on the estimated time.
514
+
515
+ If your application is capable of calculating real progress, you can pass the `progress` prop to the `IressLoading` component and that value will be used instead.
516
+
517
+ Once the `loaded` prop is set to true, the progress bar will always be set to 100% and the loading pattern will fade out.
518
+
519
+ * * *
520
+
521
+ Beta
522
+
523
+ **New component**
524
+
525
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
526
+
527
+ [](./iframe.html?id=patterns-loading-patterns-long--long)
528
+
529
+ * Finished: Processing transcript
530
+ * Finished: Noting key information
531
+ * Finished: Generating summary
532
+
533
+ ...
534
+
535
+
536
+ Hide codeRefresh
537
+
538
+ <IressLoading
539
+ messageList\={{
540
+ '3000': 'Processing transcript',
541
+ '5000': 'Noting key information',
542
+ '7000': 'Generating summary'
543
+ }}
544
+ pattern\="long"
545
+ />
546
+
547
+ ```
548
+
549
+ #### Props
550
+
551
+ | Name | Description | Default | Control |
552
+ | --- | --- | --- | --- |
553
+ | children |
554
+ The children are displayed while loading. This will be displayed above the progress bar and checklist.
555
+
556
+ ReactNode
557
+
558
+
559
+
560
+ | \- | Set object |
561
+ | error |
562
+
563
+ An error to display if the loading fails. This will override the `messageList` and show an error message instead.
564
+
565
+ ReactNode
566
+
567
+
568
+
569
+ | \- | Set object |
570
+ | estimatedFinishTime |
571
+
572
+ Estimated time in milliseconds for the loading to finish.
573
+
574
+ number
575
+
576
+
577
+
578
+ |
579
+
580
+ 10000
581
+
582
+ | Set number |
583
+ | loaded |
584
+
585
+ If set to `true`, will start hiding the loading indicator. It is recommended to use this prop if you are using the `IressLoading.shouldRender` hook to achieve a smooth loading experience.
586
+
587
+ boolean
588
+
589
+
590
+
591
+ | \- | Set boolean |
592
+ | messageList |
593
+
594
+ A checklist to display while loading. The key is the time when you want the item to be checked.
595
+
596
+ Record<number, ReactNode>
597
+
598
+ | { } |
599
+
600
+ RAW
601
+
602
+ messageList :
603
+
604
+ {
605
+
606
+ * 3000 : "Processing transcript"
607
+ * 5000 : "Noting key information"
608
+ * 7000 : "Generating summary"
609
+
610
+ }
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+ |
619
+ | pattern |
620
+
621
+ The long loading pattern will display a checklist of items that are being loaded.
622
+
623
+ Use `pattern="long"` for the following use cases:
624
+
625
+ * Calling multiple slow APIs to load data
626
+ * Loading results from AI
627
+ * Processing a large amount of data as a queue (eg. bulk uploading or large media file uploads)
628
+
629
+ literal
630
+
631
+
632
+
633
+ | \- |
634
+
635
+ "long"
636
+
637
+ |
638
+ | progress |
639
+
640
+ If provided, will use this to set the `value` of the progress bar. If not provided, will use the `estimatedFinishTime` to calculate the progress.
641
+
642
+ IressProgressProps\['value'\]
643
+
644
+ | \- | Set object |
645
+ | renderProgress |
646
+
647
+ This is a render prop that allows you to override the default progress rendering. This is useful if you want to use a different progress component or if you want to add additional props to the progress bar.
648
+
649
+ ( props: Pick<IressProgressProps, 'max' | 'sectionTitle' | 'value'>, ) => ReactNode
650
+
651
+ |
652
+
653
+ element
654
+
655
+
656
+
657
+ | \- |
658
+ | timeout |
659
+
660
+ Set the timeouts for showing the progress bar and message.
661
+
662
+ { /\*\* \* The time in milliseconds before this component begins to fade out (if \`loaded\` is set to \`true\`). \* @default 1300 \*/ loaded?: number; /\*\* \* The time in milliseconds before the checklist is displayed. \* @default 500 \*/ message?: number; }
663
+
664
+ | \- | Set object |
665
+
666
+ ### `page`
667
+
668
+ The `page` loading pattern is used to indicate that a page is loading. It is the most common loading pattern, allowing the users to see the entire content at once where possible.
669
+
670
+ #### Behavior
671
+
672
+ 1. When `loaded` is false, a skeleton will be displayed after 500ms (configured using `timeout`). This skeleton can be customised using the `template` prop.
673
+ 2. If `critical` is set whilst `loaded` is false, the critical content will be displayed immediately. This is useful for showing critical content while the rest of the page is loading.
674
+ 3. When `loaded` is true, the skeleton will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
675
+
676
+ #### Custom skeletons
677
+
678
+ The skeleton does not need to be a perfect representation of the page. It is recommended to follow the guidelines below when creating custom `template` skeletons:
679
+
680
+ * If there are multiple rows, only create a skeleton of the first row. This is enough to give the user an idea of what the content will look like.
681
+ * If there are multiple filters, only create a few filters in the general area where they will appear.
682
+ * For cards, keep the skeleton as simple as possible. It does not need to be a perfect representation of the card. In most cases a title, description and image is sufficient.
683
+
684
+ For your convenience, we have provided a few templates that you can use in the `template` prop, including: `page`, `form` and `dashboard`.
685
+
686
+ #### Critical content
687
+
688
+ In some cases it may be useful to show critical content while the rest of the page is loading. This gives the user a preview of what to expect. The example below shows a loading page with critical content by using the `critical` prop.
689
+
690
+ * * *
691
+
692
+ Beta
693
+
694
+ **New component**
695
+
696
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
697
+
698
+ [](./iframe.html?id=patterns-loading-patterns-page--page)
699
+
700
+ Dashboard
701
+ =========
702
+
703
+ * * *
704
+
705
+ Financial update 2025
706
+ ---------------------
707
+
708
+ The ASX update
709
+ --------------
710
+
711
+ In the news
712
+ -----------
713
+
714
+ Loading...
715
+
716
+ Hide codeRefresh
717
+
718
+ const API \= {
719
+ criticalContent: async () \=>
720
+ new Promise<ReactNode\>((resolve) \=> {
721
+ // Simulate a slow network request.
722
+ setTimeout(() \=> {
723
+ resolve(
724
+ <IressContainer\>
725
+ <IressStack gap\="lg"\>
726
+ <IressRow horizontalAlign\="between" verticalAlign\="middle"\>
727
+ <IressText element\="h1" mb\="none"\>
728
+ Dashboard </IressText\>
729
+ <IressInline gap\="lg"\>
730
+ <IressSkeleton textStyle\="typography.body.lg" width\="200px" />
731
+ <IressSkeleton textStyle\="typography.body.lg" width\="200px" />
732
+ </IressInline\>
733
+ </IressRow\>
734
+ <IressDivider />
735
+ <IressRow gutter\="lg"\>
736
+ <IressCol span\="4"\>
737
+ <IressCard
738
+ stretch
739
+ heading\="Financial update 2025"
740
+ media\={<IressSkeleton mode\="rect" height\="300px" />}
741
+ \>
742
+ <IressSkeleton textStyle\="typography.body.md" width\="50%" />
743
+ </IressCard\>
744
+ </IressCol\>
745
+ <IressCol span\="4"\>
746
+ <IressCard
747
+ stretch
748
+ heading\="The ASX update"
749
+ media\={<IressSkeleton mode\="rect" height\="300px" />}
750
+ \>
751
+ <IressSkeleton textStyle\="typography.body.md" width\="50%" />
752
+ </IressCard\>
753
+ </IressCol\>
754
+ <IressCol span\="4"\>
755
+ <IressCard
756
+ stretch
757
+ heading\="In the news"
758
+ media\={<IressSkeleton mode\="rect" height\="300px" />}
759
+ \>
760
+ <IressSkeleton textStyle\="typography.body.md" width\="50%" />
761
+ </IressCard\>
762
+ </IressCol\>
763
+ </IressRow\>
764
+ </IressStack\>
765
+ </IressContainer\>,
766
+ );
767
+ }, 3000);
768
+ }),
769
+ };
770
+ export const LoadingDashboard \= () \=> {
771
+ const \[critical, setCritical\] \= useState<ReactNode | undefined\>();
772
+ useEffect(() \=> {
773
+ const initialise \= async () \=> {
774
+ setCritical(await API.criticalContent());
775
+ };
776
+ void initialise();
777
+ }, \[\]);
778
+ return (
779
+ <IressLoading pattern\="page" critical\={critical} template\="dashboard" />
780
+ );
781
+ };
782
+
783
+ ```
784
+
785
+ #### Props
786
+
787
+ | Name | Description | Default | Control |
788
+ | --- | --- | --- | --- |
789
+ | critical |
790
+ If provided, will switch the skeleton to this template. Use when you have critical content that can be displayed while loading to allow the user to see some content while the rest is loading.
791
+
792
+ ReactNode
793
+
794
+
795
+
796
+ | \- | \- |
797
+ | error |
798
+
799
+ An error to display if the loading fails. This will override the skeleton.
800
+
801
+ ReactNode
802
+
803
+
804
+
805
+ | \- | \- |
806
+ | loaded |
807
+
808
+ If set to `true`, will start hiding the loading indicator. It is recommended to use this prop if you are using the `IressLoading.shouldRender` hook to achieve a smooth loading experience.
809
+
810
+ boolean
811
+
812
+
813
+
814
+ | \- | \- |
815
+ | pattern |
816
+
817
+ Use `pattern="page"` for the following use cases:
818
+
819
+ * Detail page for a record
820
+ * Form page
821
+ * Article page
822
+
823
+ literal
824
+
825
+
826
+
827
+ | \- | \- |
828
+ | screenReaderText |
829
+
830
+ Only screen readers will see this message.
831
+
832
+ ReactNode
833
+
834
+
835
+
836
+ |
837
+
838
+ 'Loading...'
839
+
840
+ | \- |
841
+ | template |
842
+
843
+ Which template to use as the skeleton, or you can use a ReactNode to customise the skeleton completely.
844
+
845
+ union
846
+
847
+
848
+
849
+ |
850
+
851
+ 'page'
852
+
853
+ | \- |
854
+ | timeout |
855
+
856
+ Delay in milliseconds before the skeleton is displayed.
857
+
858
+ number
859
+
860
+
861
+
862
+ |
863
+
864
+ 500
865
+
866
+ | \- |
867
+
868
+ ### `start-up`
869
+
870
+ The `start-up` loading pattern is used to indicate that the application is loading. It is typically used when the application is first launched. This pattern is used when the application is first launched or when switching from a different application to a new application. It is also used when switching from a client's website to an Iress application or switching themes.
871
+
872
+ #### Behavior
873
+
874
+ 1. When `loaded` is false, a progress bar will be displayed after 500ms (configured using `timeout.progress`). This progress bar can be customised using the `renderProgress` prop.
875
+ 2. When `loaded` is false after 2.5 seconds (configured using `timeout.message`), the message will be displayed. This message can be customised using the `children` or `messageList` prop.
876
+ 3. If using `messageList`, the messages will rotate until the `loaded` prop is set to true.
877
+ 4. When `loaded` is true, the progress bar and message will begin fading out. To see the fade out, you will need to use the `IressLoading.shouldRender` hook.
878
+
879
+ #### Adjusting the progress bar
880
+
881
+ The `start-up` loading pattern uses a progress bar to indicate that the application is loading alongside an `estimatedFinishTime` prop. This prop is used to indicate the estimated time until the application is fully loaded, and is used to help the user understand how long they will need to wait and assure them something is happening. The progress bar will animate based on the estimated time.
882
+
883
+ If your application is capable of calculating real progress, you can pass the `progress` prop to the `IressLoading` component and that value will be used instead.
884
+
885
+ Once the `loaded` prop is set to true, the progress bar will always be set to 100% and the loading pattern will fade out.
886
+
887
+ #### Rotating messages
888
+
889
+ The start-up process is often used initialise the application and load any necessary data. This can include loading user preferences, settings, and any other data that is required to make using the application quicker and easier, however this may add burden to the loading time.
890
+
891
+ To compensate for this, you can pass multiple messages to the pattern using the `messageList` prop. The `messageList` accepts an object map where the key is the time you want the message to start displaying (in milliseconsds) and the value is the message to display. The messages will rotate until the `loaded` prop is set to true.
892
+
893
+ * * *
894
+
895
+ Beta
896
+
897
+ **New component**
898
+
899
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
900
+
901
+ [](./iframe.html?id=patterns-loading-patterns-startup--start-up)
902
+
903
+ Hide codeRefresh
904
+
905
+ <IressLoading
906
+ messageList\={{
907
+ '0': <IressText color\="colour.neutral.70"\>Switching applications...</IressText\>,
908
+ '4500': <IressText color\="colour.neutral.70"\>This is taking longer than expected...</IressText\>
909
+ }}
910
+ pattern\="start-up"
911
+ />
912
+
913
+ ```
914
+
915
+ #### Props
916
+
917
+ | Name | Description | Default | Control |
918
+ | --- | --- | --- | --- |
919
+ | children |
920
+ Message to display when the loading time is longer than expected.
921
+
922
+ ReactNode
923
+
924
+
925
+
926
+ |
927
+
928
+ <IressText />
929
+
930
+
931
+
932
+ | Set object |
933
+ | estimatedFinishTime |
934
+
935
+ Estimated time in milliseconds for the loading to finish.
936
+
937
+ number
938
+
939
+
940
+
941
+ |
942
+
943
+ 3000
944
+
945
+ | Set number |
946
+ | loaded |
947
+
948
+ If set to `true`, will start hiding the loading indicator. It is recommended to use this prop if you are using the `IressLoading.shouldRender` hook to achieve a smooth loading experience.
949
+
950
+ boolean
951
+
952
+
953
+
954
+ | \- | Set boolean |
955
+ | messageList |
956
+
957
+ A message list to display while loading. The key is the time when you want the message to change to this message. If using a message list, the `children` will not be displayed.
958
+
959
+ Record<number, ReactNode>
960
+
961
+ | \- |
962
+
963
+ RAW
964
+
965
+ messageList :
966
+
967
+ {
968
+
969
+ * 0 :
970
+
971
+ {...} 6 keys
972
+
973
+ * 4500 :
974
+
975
+ {...} 6 keys
976
+
977
+
978
+ }
979
+
980
+
981
+
982
+
983
+
984
+
985
+
986
+ |
987
+ | pattern |
988
+
989
+ Use `pattern="start-up"` for the following use cases:
990
+
991
+ * Loading an application for the first time
992
+ * Switching from a different application to a new application
993
+ * Switching from a client's website to an Iress application
994
+ * Switching themes
995
+
996
+ literal
997
+
998
+
999
+
1000
+ | \- |
1001
+
1002
+ "start-up"
1003
+
1004
+ |
1005
+ | progress |
1006
+
1007
+ If provided, will use this to set the `value` of the progress bar. If not provided, will use the `estimatedFinishTime` to calculate the progress.
1008
+
1009
+ IressProgressProps\['value'\]
1010
+
1011
+ | \- | Set object |
1012
+ | renderProgress |
1013
+
1014
+ This is a render prop that allows you to override the default progress rendering. This is useful if you want to use a different progress component or if you want to add additional props to the progress bar.
1015
+
1016
+ ( props: Pick< IressProgressProps<number | undefined>, 'min' | 'max' | 'sectionTitle' | 'value' >, ) => ReactNode
1017
+
1018
+ | (props) => <IressProgress {...props} /> | \- |
1019
+ | screenReaderText |
1020
+
1021
+ Only screen readers will see this message, it is changed to the `children` message after the delay.
1022
+
1023
+ ReactNode
1024
+
1025
+
1026
+
1027
+ |
1028
+
1029
+ 'Loading...'
1030
+
1031
+ | Set object |
1032
+ | startFrom |
1033
+
1034
+ Set the start from timer, useful when stringing multiple loading patterns across different pages (eg. logging via a third-party authentication provider)
1035
+
1036
+ number
1037
+
1038
+
1039
+
1040
+ | \- | Set number |
1041
+ | timeout |
1042
+
1043
+ Set the timeouts for showing the progress bar and message.
1044
+
1045
+ { /\*\* \* The time in milliseconds before this component begins to fade out (if \`loaded\` is set to \`true\`). \* @default 200 \*/ loaded?: number; /\*\* \* The time in milliseconds before the message message is displayed. \* @default 2500 \*/ message?: number; /\*\* \* The time in milliseconds before the progress bar is displayed. \* @default 500 \*/ progress?: number; }
1046
+
1047
+ | \- | Set object |
1048
+
1049
+ ### `validate`
1050
+
1051
+ The `validate` loading pattern is used to indicate that a server-side validation is in progress. It is typically used when the user is submitting a form or performing an action that requires validation and the user is not expected to leave the page.
1052
+
1053
+ #### Behavior
1054
+
1055
+ 1. When `loading` is false, the button will be displayed immediately (customised using the `renderButton` prop, or the `children` prop if you do not mind passing in the `loading` prop twice).
1056
+ 2. When `loading` is true, the button will be disabled and a spinner will be displayed.
1057
+ 3. When `loading` is true after 2.5 seconds (configured using `timeout`), the message will be displayed. This message can be customised using the `message` prop. Its placement can be adjusted using the `position` prop.
1058
+
1059
+ #### Message position
1060
+
1061
+ Forms come in all shapes and sizes, and the `IressLoading` component is designed to be flexible enough to work with any form. The `position` prop allows you to adjust the placement of the loading message. The available options are:
1062
+
1063
+ * `top`: The message will be displayed above the button. It is absolute positioned to the top of the button, and will not disrupt the layout of the form.
1064
+ * `bottom` (default): The message will be displayed below the button. It is absolute positioned to the bottom of the button, and will not disrupt the layout of the form.
1065
+ * `right`: The message will be displayed on the right of the button. It is inline, and will push any content to the right of the button down.
1066
+
1067
+ * * *
1068
+
1069
+ Beta
1070
+
1071
+ **New component**
1072
+
1073
+ This component is new, please provide feedback to the Frontend Enablement team if you encounter any issues.
1074
+
1075
+ [](./iframe.html?id=patterns-loading-patterns-validate--validate)
1076
+
1077
+ Submit
1078
+
1079
+ This is taking longer than expected...
1080
+
1081
+ Cancel
1082
+
1083
+ Hide codeRefresh
1084
+
1085
+ <IressInline gap\="sm"\>
1086
+ <IressLoading
1087
+ loading
1088
+ pattern\="validate"
1089
+ />
1090
+ <IressButton mode\="tertiary"\>
1091
+ Cancel </IressButton\>
1092
+ </IressInline\>
1093
+
1094
+ ```
1095
+
1096
+ #### Props
1097
+
1098
+ | Name | Description | Default | Control |
1099
+ | --- | --- | --- | --- |
1100
+ | loading |
1101
+ When true, button is in loading state. If provided a string, will be used as the loading text for screen readers.
1102
+
1103
+ IressButtonProps\['loading'\]
1104
+
1105
+ |
1106
+
1107
+ false
1108
+
1109
+ |
1110
+
1111
+ true
1112
+
1113
+ |
1114
+ | message |
1115
+
1116
+ Set the message to be displayed when the button is in the loading state.
1117
+
1118
+ ReactNode
1119
+
1120
+
1121
+
1122
+ |
1123
+
1124
+ 'This is taking longer than expected...'
1125
+
1126
+ | Set object |
1127
+ | pattern |
1128
+
1129
+ Use `pattern="validate"` for the following use cases:
1130
+
1131
+ * Submitting a form
1132
+ * Saving a record
1133
+
1134
+ literal
1135
+
1136
+
1137
+
1138
+ |
1139
+
1140
+ 'validate'
1141
+
1142
+ |
1143
+
1144
+ "validate"
1145
+
1146
+ |
1147
+ | position |
1148
+
1149
+ This sets where the loading message will be displayed.
1150
+
1151
+ * `bottom` - The loading message will be displayed below the button. It will be absolute positioned.
1152
+ * `top` - The loading message will be displayed above the button. It will be absolute positioned.
1153
+ * `right` - The loading message will be displayed to the right of the button. It will be inline positioned.
1154
+
1155
+ union
1156
+
1157
+
1158
+
1159
+ |
1160
+
1161
+ 'bottom'
1162
+
1163
+ |
1164
+
1165
+ bottomtopright
1166
+
1167
+ |
1168
+ | renderButton |
1169
+
1170
+ This is a render prop that allows you to override the default button rendering. This is useful if you want to use a different button component or if you want to add additional props to the button.
1171
+
1172
+ (props: Pick<IressButtonProps, 'loading'>) => ReactNode
1173
+
1174
+ | (props: Pick<IressButtonProps, 'className' | 'loading'>) => ( <IressButton {...props} type="submit"> Submit </IressButton> ) | \- |
1175
+ | timeout |
1176
+
1177
+ The time in milliseconds before the loading message is displayed.
1178
+
1179
+ number
1180
+
1181
+
1182
+
1183
+ |
1184
+
1185
+ 2500
1186
+
1187
+ | Set number |
1188
+
1189
+ Suspense
1190
+ --------
1191
+
1192
+ Since React 18, React has introduced a new way to handle loading states using `Suspense`, allowing you to lazy load components in an efficient manner.
1193
+
1194
+ The `IressLoadingSuspense` component is a wrapper around the `IressLoading` component that uses `Suspense` to handle loading states. It is used in the same way as the `IressLoading` component, however you do not need to pass the `loaded` prop or use the `IressLoading.shouldRender` hook. The `IressLoadingSuspense` component will automatically handle the loading state for you.
1195
+
1196
+ The wizard example can be translated to use `IressLoadingSuspense` as follows (it includes the slow and fast examples).
1197
+
1198
+ **Differences in behaviour**
1199
+
1200
+ * The `IressLoadingSuspense` component will automatically handle the loading state for you, so you do not need to pass the `loaded` prop or use the `IressLoading.shouldRender` hook.
1201
+ * Nested suspense components will be handled by the highest `IressLoadingSuspense` component. This means that if you have multiple nested `IressLoadingSuspense` components, only the top most one will display a loading state. You can see this in the example when you click the Next button, you no longer see the component loading pattern due to it being nested under the page loading pattern.
1202
+
1203
+ [](./iframe.html?id=patterns-loading-suspense--suspense)
1204
+
1205
+ Hide codeRefresh
1206
+
1207
+ interface PageProps {
1208
+ setPage: (page: number) \=> void;
1209
+ }
1210
+ interface ChartProps {
1211
+ money: number | null;
1212
+ }
1213
+ const API \= {
1214
+ getHomePage: async () \=> {
1215
+ await new Promise((resolve) \=> {
1216
+ setTimeout(resolve, 3000);
1217
+ });
1218
+ return 1;
1219
+ },
1220
+ getRetirementIncomeProjection: async () \=> {
1221
+ await new Promise((resolve) \=> {
1222
+ setTimeout(resolve, 2000);
1223
+ });
1224
+ return true;
1225
+ },
1226
+ getChart: async () \=> {
1227
+ await new Promise((resolve) \=> {
1228
+ const chartImage \= new Image();
1229
+ chartImage.src \= retirementGraph;
1230
+ setTimeout(resolve, 1000);
1231
+ });
1232
+ return true;
1233
+ },
1234
+ chartUpdate: async () \=>
1235
+ new Promise<boolean\>((resolve) \=> {
1236
+ // Simulate a slow network request.
1237
+ setTimeout(() \=> {
1238
+ resolve(true);
1239
+ }, 2000);
1240
+ }),
1241
+ };
1242
+ const Graph \= () \=> (
1243
+ <img
1244
+ src\={retirementGraph}
1245
+ alt\=""
1246
+ style\={{ maxWidth: '100%', height: 'auto' }}
1247
+ />
1248
+ );
1249
+ const Chart \= () \=> {
1250
+ const initialChart \= IressLoadingSuspense.use(API.getChart);
1251
+ const \[updatedChart, setUpdatedChart\] \= useState<boolean | undefined\>();
1252
+ const \[money, setMoney\] \= useState<number | null\>(null);
1253
+ const \[updating, setUpdating\] \= useState(false);
1254
+ const deferredMoney \= useDeferredValue(money);
1255
+ const chart \= updatedChart ?? initialChart;
1256
+ useEffect(() \=> {
1257
+ if (deferredMoney \=== null) {
1258
+ return;
1259
+ }
1260
+ const update \= async () \=> {
1261
+ setUpdating(() \=> true);
1262
+ const newChart \= await API.chartUpdate();
1263
+ setUpdatedChart(newChart);
1264
+ setUpdating(() \=> false);
1265
+ };
1266
+ void update();
1267
+ }, \[deferredMoney\]);
1268
+ return (
1269
+ <IressLoadingSuspense pattern\="component" update\={updating}\>
1270
+ {chart && <Graph />}
1271
+ <IressPanel\>
1272
+ <IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
1273
+ > <IressStack gap\="md"\>
1274
+ <h3\>Update projection</h3\>
1275
+ <IressFormField
1276
+ name\="money"
1277
+ label\="My money"
1278
+ render\={(controlledProps) \=> (
1279
+ <IressInputCurrency {...controlledProps} />
1280
+ )}
1281
+ />
1282
+ <IressButton type\="submit"\>Update projection</IressButton\>
1283
+ </IressStack\>
1284
+ </IressForm\>
1285
+ </IressPanel\>
1286
+ </IressLoadingSuspense\>
1287
+ );
1288
+ };
1289
+ const StartPage \= ({ setPage }: PageProps) \=> (
1290
+ <IressText\>
1291
+ <h2\>Maximise your retirement</h2\>
1292
+ <p\>
1293
+ Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
1294
+ <hr />
1295
+ <IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
1296
+ </IressText\>
1297
+ );
1298
+ const RetirementIncomeProjectionPage \= () \=> {
1299
+ const promise \= API.getRetirementIncomeProjection;
1300
+ IressLoadingSuspense.use(promise);
1301
+ IressLoadingSuspense.uncache(promise);
1302
+ return (
1303
+ <IressText\>
1304
+ <h2\>Retirement Income Projection</h2\>
1305
+ <p\>
1306
+ We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
1307
+ <Chart />
1308
+ </IressText\>
1309
+ );
1310
+ };
1311
+ const HomePage \= () \=> {
1312
+ const promise \= API.getHomePage;
1313
+ const startPage \= IressLoadingSuspense.use(promise);
1314
+ IressLoadingSuspense.uncache(promise);
1315
+ const \[movedPage, setMovedPage\] \= useState<number | undefined\>();
1316
+ const page \= movedPage ?? startPage;
1317
+ return (
1318
+ <IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
1319
+ {page \=== 1 && (
1320
+ <IressLoadingSuspense pattern\="page" template\="form"\>
1321
+ {page \=== 1 && <StartPage setPage\={setMovedPage} />}
1322
+ </IressLoadingSuspense\>
1323
+ )}
1324
+ {page \=== 2 && (
1325
+ <IressLoadingSuspense pattern\="page" template\="form"\>
1326
+ <RetirementIncomeProjectionPage />
1327
+ </IressLoadingSuspense\>
1328
+ )}
1329
+ </IressContainer\>
1330
+ );
1331
+ };
1332
+ export const LoadingSuspenseWizard \= () \=> (
1333
+ <IressLoadingSuspense pattern\="start-up"\>
1334
+ <HomePage />
1335
+ </IressLoadingSuspense\>
1336
+ );
1337
+
1338
+ ```
1339
+
1340
+ #### Props
1341
+
1342
+ | Name | Description | Default | Control |
1343
+ | --- | --- | --- | --- |
1344
+ | children |
1345
+ The content that will be rendered inside the Suspense boundary. Typically includes lazy-loaded components and components that use the `use` or `IressLoadingSuspense.use` hook.
1346
+
1347
+ ReactNode
1348
+
1349
+
1350
+
1351
+ | \- | \- |
1352
+ | delay |
1353
+
1354
+ Duration (in milliseconds) to delay unmounting the fallback to allow the fade-out animation to complete. By default it uses the default delay of the pattern.
1355
+
1356
+ number
1357
+
1358
+
1359
+
1360
+ | \- | \- |
1361
+ | onLoaded |
1362
+
1363
+ By default it uses the default delay of the pattern.
1364
+
1365
+ () => void
1366
+
1367
+ | \- | \- |
1368
+ | startFrom |
1369
+
1370
+ Duration (in milliseconds) before showing the loading pattern. Default is 500ms, meaning a user will not even see the loading indicator if the page loads before this time.
1371
+
1372
+ number
1373
+
1374
+
1375
+
1376
+ | \- | \- |
1377
+
1378
+ [](./iframe.html?id=patterns-loading-suspense--fast-suspense)
1379
+
1380
+ Hide codeRefresh
1381
+
1382
+ interface PageProps {
1383
+ setPage: (page: number) \=> void;
1384
+ }
1385
+ interface ChartProps {
1386
+ money: number | null;
1387
+ }
1388
+ const API \= {
1389
+ getHomePage: async () \=> {
1390
+ await new Promise((resolve) \=> {
1391
+ setTimeout(resolve, 300);
1392
+ });
1393
+ return 1;
1394
+ },
1395
+ getRetirementIncomeProjection: async () \=> {
1396
+ await new Promise((resolve) \=> {
1397
+ setTimeout(resolve, 200);
1398
+ });
1399
+ return true;
1400
+ },
1401
+ getChart: async () \=> {
1402
+ await new Promise((resolve) \=> {
1403
+ const chartImage \= new Image();
1404
+ chartImage.onload \= resolve;
1405
+ chartImage.src \= retirementGraph;
1406
+ });
1407
+ return true;
1408
+ },
1409
+ chartUpdate: async () \=>
1410
+ new Promise<boolean\>((resolve) \=> {
1411
+ setTimeout(() \=> {
1412
+ resolve(true);
1413
+ }, 200);
1414
+ }),
1415
+ };
1416
+ const Graph \= () \=> (
1417
+ <img
1418
+ src\={retirementGraph}
1419
+ alt\=""
1420
+ style\={{ maxWidth: '100%', height: 'auto' }}
1421
+ />
1422
+ );
1423
+ const Chart \= () \=> {
1424
+ const initialChart \= IressLoadingSuspense.use(API.getChart);
1425
+ const \[updatedChart, setUpdatedChart\] \= useState<boolean | undefined\>();
1426
+ const \[money, setMoney\] \= useState<number | null\>(null);
1427
+ const \[updating, setUpdating\] \= useState(false);
1428
+ const deferredMoney \= useDeferredValue(money);
1429
+ const chart \= updatedChart ?? initialChart;
1430
+ useEffect(() \=> {
1431
+ if (deferredMoney \=== null) {
1432
+ return;
1433
+ }
1434
+ const update \= async () \=> {
1435
+ setUpdating(() \=> true);
1436
+ const newChart \= await API.chartUpdate();
1437
+ setUpdatedChart(newChart);
1438
+ setUpdating(() \=> false);
1439
+ };
1440
+ void update();
1441
+ }, \[deferredMoney\]);
1442
+ return (
1443
+ <IressLoadingSuspense pattern\="component" update\={updating}\>
1444
+ {chart && <Graph />}
1445
+ <IressPanel\>
1446
+ <IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
1447
+ > <IressStack gap\="md"\>
1448
+ <h3\>Update projection</h3\>
1449
+ <IressFormField
1450
+ name\="money"
1451
+ label\="My money"
1452
+ render\={(controlledProps) \=> (
1453
+ <IressInputCurrency {...controlledProps} />
1454
+ )}
1455
+ />
1456
+ <IressButton type\="submit"\>Update projection</IressButton\>
1457
+ </IressStack\>
1458
+ </IressForm\>
1459
+ </IressPanel\>
1460
+ </IressLoadingSuspense\>
1461
+ );
1462
+ };
1463
+ const StartPage \= ({ setPage }: PageProps) \=> (
1464
+ <IressText\>
1465
+ <h2\>Maximise your retirement</h2\>
1466
+ <p\>
1467
+ Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
1468
+ <hr />
1469
+ <IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
1470
+ </IressText\>
1471
+ );
1472
+ const RetirementIncomeProjectionPage \= () \=> {
1473
+ IressLoadingSuspense.use(API.getRetirementIncomeProjection);
1474
+ return (
1475
+ <IressText\>
1476
+ <h2\>Retirement Income Projection</h2\>
1477
+ <p\>
1478
+ We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
1479
+ <Chart />
1480
+ </IressText\>
1481
+ );
1482
+ };
1483
+ const HomePage \= () \=> {
1484
+ const startPage \= IressLoadingSuspense.use(API.getHomePage);
1485
+ const \[movedPage, setMovedPage\] \= useState<number | undefined\>();
1486
+ const page \= movedPage ?? startPage;
1487
+ return (
1488
+ <IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
1489
+ {page \=== 1 && (
1490
+ <IressLoadingSuspense pattern\="page" template\="form"\>
1491
+ {page \=== 1 && <StartPage setPage\={setMovedPage} />}
1492
+ </IressLoadingSuspense\>
1493
+ )}
1494
+ {page \=== 2 && (
1495
+ <IressLoadingSuspense pattern\="page" template\="form"\>
1496
+ <RetirementIncomeProjectionPage />
1497
+ </IressLoadingSuspense\>
1498
+ )}
1499
+ </IressContainer\>
1500
+ );
1501
+ };
1502
+ export const LoadingSuspenseWizardFast \= () \=> (
1503
+ <IressLoadingSuspense pattern\="start-up"\>
1504
+ <HomePage />
1505
+ </IressLoadingSuspense\>
1506
+ );
1507
+
1508
+ ```
1509
+
1510
+ #### Props
1511
+
1512
+ | Name | Description | Default | Control |
1513
+ | --- | --- | --- | --- |
1514
+ | children |
1515
+ The content that will be rendered inside the Suspense boundary. Typically includes lazy-loaded components and components that use the `use` or `IressLoadingSuspense.use` hook.
1516
+
1517
+ ReactNode
1518
+
1519
+
1520
+
1521
+ | \- | \- |
1522
+ | delay |
1523
+
1524
+ Duration (in milliseconds) to delay unmounting the fallback to allow the fade-out animation to complete. By default it uses the default delay of the pattern.
1525
+
1526
+ number
1527
+
1528
+
1529
+
1530
+ | \- | \- |
1531
+ | onLoaded |
1532
+
1533
+ By default it uses the default delay of the pattern.
1534
+
1535
+ () => void
1536
+
1537
+ | \- | \- |
1538
+ | startFrom |
1539
+
1540
+ Duration (in milliseconds) before showing the loading pattern. Default is 500ms, meaning a user will not even see the loading indicator if the page loads before this time.
1541
+
1542
+ number
1543
+
1544
+
1545
+
1546
+ | \- | \- |
1547
+
1548
+ Hooks
1549
+ -----
1550
+
1551
+ ### `IressLoading.shouldRender`
1552
+
1553
+ The `IressLoading.shouldRender` hook is used to determine whether the loading pattern should be displayed or not. It is used to control the visibility of the loading pattern based on the `loaded` prop.
1554
+
1555
+ Its main function is to delay the un-mounting of the loading pattern when the `loaded` prop is set to true to allow for a fade out animation.
1556
+
1557
+ const \[loaded, setLoaded\] \= useState(false);
1558
+ const renderLoading \= IressLoading.shouldRender(loaded);
1559
+ // Use renderLoading instead of !loaded for the smooth transition.
1560
+ if (renderLoading) return <IressLoading pattern\="page" loaded\={loaded} />;
1561
+ else return <IressText\>Content is loaded</IressText\>;
1562
+
1563
+ ```
1564
+
1565
+ ### `IressLoadingSuspense.use`
1566
+
1567
+ The `IressLoadingSuspense.use` hook is a polyfill for the React 19 `use` hook, allowing you to have similar functionality in React 18. It is used to handle loading states when using `IressLoadingSuspense`.
1568
+
1569
+ It is not as smart as the `use` hook in React 19, it will cache the result of the promise and will not re-fetch the data if the component is re-mounted. You can clear a function's results in the cache by using the `IressLoadingSuspense.uncache` function.
1570
+
1571
+ Avoid in React 19
1572
+ -----------------
1573
+
1574
+ If you are using React 19, it is recommended to use the built-in `use` hook instead of this one. In future releases, this hook will be deprecated and removed from the library.
1575
+
1576
+ const HomePage \= () \=> {
1577
+ const pageData \= IressLoadingSuspense.use(API.fetchPage('home'));
1578
+ return (
1579
+ <IressText\>
1580
+ <h2\>{pageData.title}</h2\>
1581
+ <p\>{pageData.description}</p\>
1582
+ </IressText\>
1583
+ );
1584
+ };
1585
+ export const App \= () \=> (
1586
+ <IressLoadingSuspense pattern\="start-up"\>
1587
+ <HomePage />
1588
+ </IressLoadingSuspense\>
1589
+ );
1590
+
1591
+ ```
1592
+
1593
+ Examples
1594
+ --------
1595
+
1596
+ Below are some examples of how to use the `IressLoading` component in different scenarios.
1597
+
1598
+ ### Wizard
1599
+
1600
+ Here you can see how a wizard can use the `IressLoading` component at different stages of the application. The first example shows a `slow` wizard, and the second example shows how the same code looks when the requests are fast. The main difference is you see minimal loading inidicators in the second example, improving the perception that the system is fast.
1601
+
1602
+ [](./iframe.html?id=patterns-loading--wizard)
1603
+
1604
+ Hide codeRefresh
1605
+
1606
+ interface PageProps {
1607
+ setPage: (page: number) \=> void;
1608
+ }
1609
+ interface ChartProps {
1610
+ money: number | null;
1611
+ }
1612
+ const API \= {
1613
+ initialise: async () \=>
1614
+ new Promise<boolean\>((resolve) \=> {
1615
+ // Simulate a slow network request.
1616
+ setTimeout(() \=> {
1617
+ resolve(true);
1618
+ }, 3000);
1619
+ }),
1620
+ data: async () \=>
1621
+ new Promise<boolean\>((resolve) \=> {
1622
+ // Simulate a slow network request.
1623
+ setTimeout(() \=> {
1624
+ resolve(true);
1625
+ }, 2000);
1626
+ }),
1627
+ chart: async () \=>
1628
+ new Promise<boolean\>((resolve) \=> {
1629
+ // Simulate a slow network request.
1630
+ setTimeout(() \=> {
1631
+ resolve(true);
1632
+ }, 2000);
1633
+ }),
1634
+ chartUpdate: async () \=>
1635
+ new Promise<boolean\>((resolve) \=> {
1636
+ // Simulate a slow network request.
1637
+ setTimeout(() \=> {
1638
+ resolve(true);
1639
+ }, 2000);
1640
+ }),
1641
+ };
1642
+ const Graph \= () \=> (
1643
+ <img
1644
+ src\={retirementGraph}
1645
+ alt\=""
1646
+ style\={{ maxWidth: '100%', height: 'auto' }}
1647
+ />
1648
+ );
1649
+ const Chart \= () \=> {
1650
+ const \[chart, setChart\] \= useState(false);
1651
+ const \[money, setMoney\] \= useState<number | null\>(null);
1652
+ const \[loaded, setLoaded\] \= useState(false);
1653
+ const \[updating, setUpdating\] \= useState(false);
1654
+ const safeLoaded \= IressLoading.shouldRender(loaded);
1655
+ const deferredMoney \= useDeferredValue(money);
1656
+ useEffect(() \=> {
1657
+ const initialise \= async () \=> {
1658
+ const newChart \= await API.chart();
1659
+ setChart(newChart);
1660
+ setLoaded(() \=> true);
1661
+ };
1662
+ void initialise();
1663
+ }, \[\]);
1664
+ useEffect(() \=> {
1665
+ if (deferredMoney \=== null) {
1666
+ return;
1667
+ }
1668
+ const update \= async () \=> {
1669
+ setUpdating(() \=> true);
1670
+ const newChart \= await API.chartUpdate();
1671
+ setChart(newChart);
1672
+ setUpdating(() \=> false);
1673
+ };
1674
+ void update();
1675
+ }, \[deferredMoney\]);
1676
+ return (
1677
+ <IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
1678
+ {chart && <Graph />}
1679
+ <IressPanel\>
1680
+ <IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
1681
+ > <IressStack gap\="md"\>
1682
+ <h3\>Update projection</h3\>
1683
+ <IressFormField
1684
+ name\="money"
1685
+ label\="My money"
1686
+ render\={(controlledProps) \=> (
1687
+ <IressInputCurrency {...controlledProps} />
1688
+ )}
1689
+ />
1690
+ <IressButton type\="submit"\>Update projection</IressButton\>
1691
+ </IressStack\>
1692
+ </IressForm\>
1693
+ </IressPanel\>
1694
+ </IressLoading\>
1695
+ );
1696
+ };
1697
+ const StartPage \= ({ setPage }: PageProps) \=> (
1698
+ <IressText\>
1699
+ <h2\>Maximise your retirement</h2\>
1700
+ <p\>
1701
+ Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
1702
+ <hr />
1703
+ <IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
1704
+ </IressText\>
1705
+ );
1706
+ const RetirementIncomeProjectionPage \= () \=> {
1707
+ const \[data, setData\] \= useState(false);
1708
+ const loaded \= data !== false;
1709
+ const renderLoading \= IressLoading.shouldRender(loaded);
1710
+ useEffect(() \=> {
1711
+ const initialise \= async () \=> {
1712
+ const newData \= await API.data();
1713
+ setData(newData);
1714
+ };
1715
+ void initialise();
1716
+ }, \[\]);
1717
+ if (renderLoading) {
1718
+ return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
1719
+ }
1720
+ return (
1721
+ <IressText\>
1722
+ <h2\>Retirement Income Projection</h2\>
1723
+ <p\>
1724
+ We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
1725
+ <Chart />
1726
+ </IressText\>
1727
+ );
1728
+ };
1729
+ export const LoadingWizard \= () \=> {
1730
+ const \[page, setPage\] \= useState(0);
1731
+ const loaded \= page \> 0;
1732
+ const renderLoading \= IressLoading.shouldRender(loaded);
1733
+ useEffect(() \=> {
1734
+ const initialise \= async () \=> {
1735
+ await API.initialise();
1736
+ setPage(1);
1737
+ };
1738
+ void initialise();
1739
+ }, \[\]);
1740
+ if (renderLoading) {
1741
+ return <IressLoading pattern\="start-up" loaded\={loaded} />;
1742
+ }
1743
+ return (
1744
+ <IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
1745
+ {page \=== 1 && <StartPage setPage\={setPage} />}
1746
+ {page \=== 2 && <RetirementIncomeProjectionPage />}
1747
+ </IressContainer\>
1748
+ );
1749
+ };
1750
+
1751
+ ```
1752
+
1753
+ #### Props
1754
+
1755
+ [](./iframe.html?id=patterns-loading--fast-wizard)
1756
+
1757
+ Hide codeRefresh
1758
+
1759
+ interface PageProps {
1760
+ setPage: (page: number) \=> void;
1761
+ }
1762
+ interface ChartProps {
1763
+ money: number | null;
1764
+ }
1765
+ const API \= {
1766
+ initialise: async () \=>
1767
+ new Promise<boolean\>((resolve) \=> {
1768
+ // Simulate a fast network request.
1769
+ setTimeout(() \=> {
1770
+ resolve(true);
1771
+ }, 300);
1772
+ }),
1773
+ data: async () \=>
1774
+ new Promise<boolean\>((resolve) \=> {
1775
+ // Simulate a fast network request.
1776
+ setTimeout(() \=> {
1777
+ resolve(true);
1778
+ }, 300);
1779
+ }),
1780
+ chart: async () \=>
1781
+ new Promise<boolean\>((resolve) \=> {
1782
+ // Simulate a fast network request.
1783
+ setTimeout(() \=> {
1784
+ resolve(true);
1785
+ }, 300);
1786
+ }),
1787
+ chartUpdate: async () \=>
1788
+ new Promise<boolean\>((resolve) \=> {
1789
+ // Simulate a fast network request.
1790
+ setTimeout(() \=> {
1791
+ resolve(true);
1792
+ }, 300);
1793
+ }),
1794
+ };
1795
+ const Graph \= () \=> (
1796
+ <img
1797
+ src\={retirementGraph}
1798
+ alt\=""
1799
+ style\={{ maxWidth: '100%', height: 'auto' }}
1800
+ />
1801
+ );
1802
+ const Chart \= () \=> {
1803
+ const \[chart, setChart\] \= useState(false);
1804
+ const \[money, setMoney\] \= useState<number | null\>(null);
1805
+ const \[loaded, setLoaded\] \= useState(false);
1806
+ const \[updating, setUpdating\] \= useState(false);
1807
+ const safeLoaded \= IressLoading.shouldRender(loaded);
1808
+ const deferredMoney \= useDeferredValue(money);
1809
+ useEffect(() \=> {
1810
+ const initialise \= async () \=> {
1811
+ const newChart \= await API.chart();
1812
+ setChart(newChart);
1813
+ const testImg \= new Image();
1814
+ testImg.onload \= () \=> setLoaded(true);
1815
+ testImg.src \= retirementGraph;
1816
+ };
1817
+ void initialise();
1818
+ }, \[\]);
1819
+ useEffect(() \=> {
1820
+ if (deferredMoney \=== null) {
1821
+ return;
1822
+ }
1823
+ const update \= async () \=> {
1824
+ setUpdating(() \=> true);
1825
+ const newChart \= await API.chartUpdate();
1826
+ setChart(newChart);
1827
+ setUpdating(() \=> false);
1828
+ };
1829
+ void update();
1830
+ }, \[deferredMoney\]);
1831
+ return (
1832
+ <IressLoading pattern\="component" loaded\={!safeLoaded} update\={updating}\>
1833
+ {chart && <Graph />}
1834
+ <IressPanel\>
1835
+ <IressForm<ChartProps> onSubmit={(projectionData) \=> setMoney(projectionData.money)}
1836
+ > <IressStack gap\="md"\>
1837
+ <h3\>Update projection</h3\>
1838
+ <IressFormField
1839
+ name\="money"
1840
+ label\="My money"
1841
+ render\={(controlledProps) \=> (
1842
+ <IressInputCurrency {...controlledProps} />
1843
+ )}
1844
+ />
1845
+ <IressButton type\="submit"\>Update projection</IressButton\>
1846
+ </IressStack\>
1847
+ </IressForm\>
1848
+ </IressPanel\>
1849
+ </IressLoading\>
1850
+ );
1851
+ };
1852
+ const StartPage \= ({ setPage }: PageProps) \=> (
1853
+ <IressText\>
1854
+ <h2\>Maximise your retirement</h2\>
1855
+ <p\>
1856
+ Maximize your retirement in Australia by contributing to your super early and making voluntary top-ups to benefit from compounding. Take advantage of employer contributions, government co-contributions, and tax benefits. Diversify your investments and review your strategy regularly to stay on track. Consider additional income streams and seek professional advice for a secure future. </p\>
1857
+ <hr />
1858
+ <IressButton onClick\={() \=> setPage(2)}\>Next</IressButton\>
1859
+ </IressText\>
1860
+ );
1861
+ const RetirementIncomeProjectionPage \= () \=> {
1862
+ const \[data, setData\] \= useState(false);
1863
+ const loaded \= data !== false;
1864
+ const renderLoading \= IressLoading.shouldRender(loaded);
1865
+ useEffect(() \=> {
1866
+ const initialise \= async () \=> {
1867
+ const newData \= await API.data();
1868
+ setData(newData);
1869
+ };
1870
+ void initialise();
1871
+ }, \[\]);
1872
+ if (renderLoading) {
1873
+ return <IressLoading pattern\="page" template\="form" loaded\={loaded} />;
1874
+ }
1875
+ return (
1876
+ <IressText\>
1877
+ <h2\>Retirement Income Projection</h2\>
1878
+ <p\>
1879
+ We've got enough information to provide you with a retirement income projection. This will help you understand how much you can expect to receive in retirement based on your current super balance, your contributions, and your investment strategy. </p\>
1880
+ <Chart />
1881
+ </IressText\>
1882
+ );
1883
+ };
1884
+ export const LoadingWizardFast \= () \=> {
1885
+ const \[page, setPage\] \= useState(0);
1886
+ const loaded \= page \> 0;
1887
+ const renderLoading \= IressLoading.shouldRender(loaded);
1888
+ useEffect(() \=> {
1889
+ const initialise \= async () \=> {
1890
+ await API.initialise();
1891
+ setPage(1);
1892
+ };
1893
+ void initialise();
1894
+ }, \[\]);
1895
+ if (renderLoading) {
1896
+ return <IressLoading pattern\="start-up" loaded\={loaded} />;
1897
+ }
1898
+ return (
1899
+ <IressContainer style\={{ maxWidth: '600px', paddingBlock: '3rem' }}\>
1900
+ {page \=== 1 && <StartPage setPage\={setPage} />}
1901
+ {page \=== 2 && <RetirementIncomeProjectionPage />}
1902
+ </IressContainer\>
1903
+ );
1904
+ };
1905
+
1906
+ ```
1907
+
1908
+ #### Props