@ntix/components-scorad 1.0.5 → 2.0.1

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.
package/dist/index.d.ts CHANGED
@@ -1,20 +1,517 @@
1
- export * from './component';
2
- export * from './componentsScoradLogger';
3
- export * from './constants';
4
- export * from './extent';
5
- export * from './getScoradScore';
6
- export * from './HTMLScoradValueElement';
7
- export * from './intensity';
8
- export * from './label';
9
- export * from './options';
10
- export * from './ScoradData';
11
- export * from './ScoradExtentData';
12
- export * from './ScoradExtentWeights';
13
- export * from './ScoradIntensityData';
14
- export * from './ScoradResources';
15
- export * from './ScoradScore';
16
- export * from './ScoradSubjectiveData';
17
- export * from './selectScoradWeights';
18
- export * from './subjective';
19
- export * from './validateScoradData';
20
- export * from './weightings';
1
+ import { EventEmitter } from '@ntix/components-core';
2
+ import { Failure } from '@ntix/components-core';
3
+ import { HTMLComponentElement } from '@ntix/components-core';
4
+ import { HTMLLiteralResult } from '@ntix/components-renderer';
5
+ import { ILogger } from '@ntix/components-core';
6
+ import { LogLevel } from '@ntix/components-core';
7
+ import { Result } from '@ntix/components-core';
8
+ import { Success } from '@ntix/components-core';
9
+
10
+ /**
11
+ Internal logger instance for @ntix/components-scorad.
12
+ */
13
+ export declare const componentsScoradLogger: ILogger;
14
+
15
+ export { Failure }
16
+
17
+ /**
18
+ * Calculates the final composite SCORAD score (A/5 + 7B/2 + C) from the raw data.
19
+ * @param data - The complete ScoradData input object.
20
+ * @returns The final SCORAD score, rounded to two decimal places.
21
+ */
22
+ export declare const getScoradScore: (data: ScoradData | null | undefined) => Result<ScoradScore>;
23
+
24
+ /**
25
+ * Root component for calculating and displaying the total SCORAD (SCORing Atopic Dermatitis).
26
+ *
27
+ * This component aggregates data from Extent, Intensity, and Subjective sub-components
28
+ * to calculate the final clinical score.
29
+ */
30
+ export declare class HTMLScoradElement extends HTMLComponentElement<HTMLScoradValueElement<ScoradData>> {
31
+ connectedCallback(): void;
32
+ /**
33
+ * Value is readonly
34
+ * @group Properties
35
+ */
36
+ readonly: boolean;
37
+ /**
38
+ * The current value of the component.
39
+ * @group Properties
40
+ */
41
+ value: ScoradData;
42
+ /**
43
+ * Show the errors from validation on the components
44
+ * @group Properties
45
+ * */
46
+ showErrors: boolean;
47
+ afterRender(): void;
48
+ render(): HTMLLiteralResult;
49
+ /**
50
+ * Fired immediately as the user interacts with the input (high frequency).
51
+ *
52
+ * @param detail - The current value during input.
53
+ * @group Events
54
+ */
55
+ readonly valueInput: EventEmitter<ScoradData>;
56
+ /**
57
+ * Fired when the value is finalized or "committed" by the user.
58
+ *
59
+ * @param detail - The final updated value.
60
+ * @group Events
61
+ */
62
+ readonly valueChange: EventEmitter<ScoradData>;
63
+ }
64
+
65
+ /**
66
+ * Interactive SVG component for calculating the 'Extent' (A) section of the SCORAD score.
67
+ *
68
+ * Users can interact with different body regions (head, trunk, limbs) via pointer gestures
69
+ * or keyboard input to define the percentage of affected surface area. The component
70
+ * supports different surface area weightings based on the `child` attribute.
71
+ */
72
+ export declare class HTMLScoradExtentElement extends HTMLComponentElement<HTMLScoradValueElement<ScoradExtentData>> {
73
+ connectedCallback(): void;
74
+ disconnectedCallback(): void;
75
+ private handleFocusIn;
76
+ private handleFocusOut;
77
+ /**
78
+ * Extent score is to be weighted as a child or adult
79
+ * @group Properties
80
+ */
81
+ child: boolean;
82
+ /**
83
+ * Value is readonly
84
+ * @group Properties
85
+ */
86
+ readonly: boolean;
87
+ private committedValue;
88
+ /**
89
+ * The current value of the component.
90
+ * @group Properties
91
+ */
92
+ value: ScoradExtentData;
93
+ /**
94
+ * Subjective SCORAD score (A)
95
+ * @group Properties
96
+ */
97
+ score?: number;
98
+ setValue: (value: ScoradExtentData) => void;
99
+ /**
100
+ * validation errors
101
+ * shows as has-errors attribute
102
+ * @group Properties
103
+ */
104
+ errors?: Record<string, string>;
105
+ afterRender(): void;
106
+ resizeCallback(): void;
107
+ render(): HTMLLiteralResult;
108
+ /**
109
+ * Fired immediately as the user interacts with the input (high frequency).
110
+ *
111
+ * @param detail - The current value during input.
112
+ * @group Events
113
+ */
114
+ readonly valueInput: EventEmitter<ScoradExtentData>;
115
+ /**
116
+ * Fired when the value is finalized or "committed" by the user.
117
+ *
118
+ * @param detail - The final updated value.
119
+ * @group Events
120
+ */
121
+ readonly valueChange: EventEmitter<ScoradExtentData>;
122
+ }
123
+
124
+ /**
125
+ * Component for assessing the 'Intensity' (B) criteria of the SCORAD score.
126
+ *
127
+ * It renders a list of clinical signs (e.g., Erythema, Edema, Oozing) and allows
128
+ * the user to grade each on a scale of 0 to 3 using integrated option pickers.
129
+ */
130
+ export declare class HTMLScoradIntensityElement extends HTMLComponentElement<HTMLScoradValueElement<ScoradIntensityData>> {
131
+ connectedCallback(): void;
132
+ /**
133
+ * Value is readonly
134
+ * @group Properties
135
+ */
136
+ readonly: boolean;
137
+ /**
138
+ * The current value of the component.
139
+ * @group Properties
140
+ */
141
+ value: ScoradIntensityData;
142
+ /**
143
+ * Subjective SCORAD score (B)
144
+ * @group Properties
145
+ */
146
+ score?: number;
147
+ /**
148
+ * validation errors
149
+ * shows as has-errors attribute
150
+ * @group Properties
151
+ */
152
+ errors?: Record<string, string>;
153
+ afterRender(): void;
154
+ render(): HTMLLiteralResult;
155
+ renderLevel(name: keyof ScoradIntensityData): HTMLLiteralResult;
156
+ /**
157
+ * Fired immediately as the user interacts with the input (high frequency).
158
+ *
159
+ * @param detail - The current value during input.
160
+ * @group Events
161
+ */
162
+ readonly valueInput: EventEmitter<ScoradIntensityData>;
163
+ /**
164
+ * Fired when the value is finalized or "committed" by the user.
165
+ *
166
+ * @param detail - The final updated value.
167
+ * @group Events
168
+ */
169
+ readonly valueChange: EventEmitter<ScoradIntensityData>;
170
+ }
171
+
172
+ export declare class HTMLScoradLabelElement extends HTMLComponentElement<HTMLScoradLabelElementEventMap> {
173
+ connectedCallback(): void;
174
+ diconnectedCallback(): void;
175
+ private handleClick;
176
+ text: string;
177
+ description?: string;
178
+ render(): HTMLLiteralResult;
179
+ }
180
+
181
+ export declare interface HTMLScoradLabelElementEventMap extends HTMLElementEventMap {
182
+ }
183
+
184
+ export declare class HTMLScoradOptionsElement extends HTMLComponentElement<HTMLScoradValueElement<number>> {
185
+ connectedCallback(): void;
186
+ disconnectedCallback(): void;
187
+ private handleFocusIn;
188
+ private handleFocusOut;
189
+ private handleClick;
190
+ private handleKeydown;
191
+ min: number;
192
+ max: number;
193
+ hideText: boolean;
194
+ showHue: boolean;
195
+ committedValue: number;
196
+ value: number;
197
+ setValue: (value: number) => void;
198
+ readonly: boolean;
199
+ text: readonly string[];
200
+ render(): HTMLLiteralResult;
201
+ afterRender(): void;
202
+ readonly valueInput: EventEmitter<number>;
203
+ readonly valueChange: EventEmitter<number>;
204
+ }
205
+
206
+ /**
207
+ * Component for assessing the 'Subjective' (C) criteria of the SCORAD score.
208
+ *
209
+ * It provides visual analog scales (VAS) for patients to self-report symptoms
210
+ * such as pruritus (itching) and insomnia (sleep loss) over the last 3 days.
211
+ */
212
+ export declare class HTMLScoradSubjectiveElement extends HTMLComponentElement<HTMLScoradValueElement<ScoradSubjectiveData>> {
213
+ connectedCallback(): void;
214
+ /**
215
+ * Value is readonly
216
+ * @group Properties
217
+ */
218
+ readonly: boolean;
219
+ /**
220
+ * The current value of the component.
221
+ * @group Properties
222
+ */
223
+ value: ScoradSubjectiveData;
224
+ /**
225
+ * Subjective SCORAD score (C)
226
+ * @group Properties
227
+ */
228
+ score?: number;
229
+ /**
230
+ * validation errors
231
+ * shows as has-errors attribute
232
+ * @group Properties
233
+ */
234
+ errors?: Record<string, string>;
235
+ afterRender(): void;
236
+ render(): HTMLLiteralResult;
237
+ renderLevel(name: keyof ScoradSubjectiveData): HTMLLiteralResult;
238
+ /**
239
+ * Fired immediately as the user interacts with the input (high frequency).
240
+ *
241
+ * @param detail - The current value during input.
242
+ * @group Events
243
+ */
244
+ readonly valueInput: EventEmitter<ScoradSubjectiveData>;
245
+ /**
246
+ * Fired when the value is finalized or "committed" by the user.
247
+ *
248
+ * @param detail - The final updated value.
249
+ * @group Events
250
+ */
251
+ readonly valueChange: EventEmitter<ScoradSubjectiveData>;
252
+ }
253
+
254
+ /**
255
+ * @module
256
+ * @group Components
257
+ */
258
+ /**
259
+ * Common interface for SCORAD input elements.
260
+ *
261
+ * This interface defines the standard reactive contract for components that manage a generic score value.
262
+ *
263
+ * @template T - The data type of the SCORAD value
264
+ */
265
+ export declare interface HTMLScoradValueElement<T> extends HTMLElementEventMap {
266
+ /**
267
+ * Value is readonly
268
+ */
269
+ readonly: boolean;
270
+ /**
271
+ * The current value of the component.
272
+ *
273
+ * @group Properties
274
+ */
275
+ readonly value: T;
276
+ /**
277
+ * Fired immediately as the user interacts with the input (high frequency).
278
+ *
279
+ * @param detail - The current value of type {@link T} during input.
280
+ * @group Events
281
+ */
282
+ readonly 'value-input': CustomEvent<T>;
283
+ /**
284
+ * Fired when the value is finalized or "committed" by the user.
285
+ *
286
+ * @param detail - The final updated value of type {@link T}.
287
+ * @group Events
288
+ */
289
+ readonly 'value-change': CustomEvent<T>;
290
+ }
291
+
292
+ /**
293
+ * A toggle component to switch between 'Adult' and 'Child' SCORAD calculation weightings.
294
+ * This component maps a boolean state to specific clinical weighting logic,
295
+ * primarily influencing the surface area calculation in the Extent (Section A) component.
296
+ */
297
+ export declare class HTMLScoradWeightingsElement extends HTMLComponentElement<HTMLScoradValueElement<boolean>> {
298
+ connectedCallback(): void;
299
+ /**
300
+ * Value is readonly
301
+ * @group Properties
302
+ */
303
+ readonly: boolean;
304
+ /**
305
+ * The current value of the component.
306
+ * @group Properties
307
+ */
308
+ value: boolean;
309
+ afterRender(): void;
310
+ render(): HTMLLiteralResult;
311
+ /**
312
+ * Fired immediately as the user interacts with the input (high frequency).
313
+ *
314
+ * @param detail - The current value during input.
315
+ * @group Events
316
+ */
317
+ readonly valueInput: EventEmitter<boolean>;
318
+ /**
319
+ * Fired when the value is finalized or "committed" by the user.
320
+ *
321
+ * @param detail - The final updated value.
322
+ * @group Events
323
+ */
324
+ readonly valueChange: EventEmitter<boolean>;
325
+ }
326
+
327
+ export { LogLevel }
328
+
329
+ export { Result }
330
+
331
+ /**
332
+ Configuration map for the Body Surface Area (BSA) weights for adult SCORAD Extent (A) calculation.
333
+ The values are decimals representing the percentage of total BSA.
334
+ */
335
+ export declare const SCORAD_ADULT_WEIGHTS: ScoradExtentWeights;
336
+
337
+ /**
338
+ Configuration map for the Body Surface Area (BSA) weights for child SCORAD Extent (A) calculation.
339
+ The head and neck area is proportionally larger than in adults.
340
+ */
341
+ export declare const SCORAD_CHILD_WEIGHTS: ScoradExtentWeights;
342
+
343
+ /** Global default state for a complete SCORAD assessment.
344
+ Uses adult weighting by default.
345
+ */
346
+ export declare const SCORAD_DEFAULT: ScoradData;
347
+
348
+ /** Initial state for SCORAD Extent data.
349
+ All regions are initialized as non-null to satisfy record constraints.
350
+ */
351
+ export declare const SCORAD_EXTENT_DEFAULT: ScoradExtentData;
352
+
353
+ /** Maximum percentage value allowed for any body region in the Extent (A) calculation. */
354
+ export declare const SCORAD_EXTENT_MAX_VALUE: number;
355
+
356
+ /** Initial state for SCORAD Intensity data.
357
+ Represents a baseline where no clinical signs have been graded.
358
+ */
359
+ export declare const SCORAD_INTENSITY_DEFAULT: ScoradIntensityData;
360
+
361
+ /** Maximum grade (0-3) allowed for clinical signs in the Intensity (B) calculation. */
362
+ export declare const SCORAD_INTENSITY_MAX_VALUE: number;
363
+
364
+ /** Initial state for SCORAD Subjective data.
365
+ Represents a baseline for pruritus and sleeplessness.
366
+ */
367
+ export declare const SCORAD_SUBJECTIVE_DEFAULT: ScoradSubjectiveData;
368
+
369
+ /** Maximum value (0-10) allowed for patient-reported symptoms in the Subjective (C) calculation. */
370
+ export declare const SCORAD_SUBJECTIVE_MAX_VALUE: number;
371
+
372
+ /**
373
+ * The complete data model for the SCORAD index, containing all three components (A, B, C).
374
+ */
375
+ export declare type ScoradData = {
376
+ child: boolean;
377
+ extent: ScoradExtentData;
378
+ intensity: ScoradIntensityData;
379
+ subjective: ScoradSubjectiveData;
380
+ };
381
+
382
+ /**
383
+ * @module
384
+ * @group Data
385
+ */
386
+ /**
387
+ * Represents the raw percentage affected (0-100) for each of the six SCORAD regions.
388
+ */
389
+ export declare type ScoradExtentData = {
390
+ /** Percentage (0-100) of the Head and Neck region affected. */
391
+ headNeck: number;
392
+ /** Percentage (0-100) of the Anterior Trunk region affected. */
393
+ anteriorTrunk: number;
394
+ /** Percentage (0-100) of the Posterior Trunk region affected. */
395
+ posteriorTrunk: number;
396
+ /** Percentage (0-100) of the Genital region affected. */
397
+ genitals: number;
398
+ /** Percentage (0-100) of the Upper Limbs region affected. */
399
+ upperLimbs: number;
400
+ /** Percentage (0-100) of the Lower Limbs region affected. */
401
+ lowerLimbs: number;
402
+ };
403
+
404
+ /**
405
+ * Defines the type for the fixed BSA weights.
406
+ */
407
+ export declare type ScoradExtentWeights = Readonly<ScoradExtentData>;
408
+
409
+ /**
410
+ * @module
411
+ * @group Data
412
+ */
413
+ /**
414
+ * Represents the single assessment of the six clinical signs from a representative lesion area.
415
+ * Used for calculating the Intensity Score (B).
416
+ */
417
+ export declare type ScoradIntensityData = {
418
+ /** Erythema (Redness). */
419
+ erythema: number;
420
+ /** Oedema and Papulation (Swelling/Bumps). */
421
+ oedemaPapulation: number;
422
+ /** Oozing and Crusting. */
423
+ oozingCrusting: number;
424
+ /** Excoriations (Scratch marks). */
425
+ excoriations: number;
426
+ /** Lichenification (Skin thickening). */
427
+ lichenification: number;
428
+ /** Xerosis (Dryness). */
429
+ xerosis: number;
430
+ };
431
+
432
+ /**
433
+ A single resource item containing UI text strings.
434
+ */
435
+ export declare type ScoradResource = {
436
+ text: string;
437
+ description: string;
438
+ };
439
+
440
+ /**
441
+ A recursive type that mirrors the structure of a SCORAD data record,
442
+ replacing leaf values with ScoradResource objects.
443
+ */
444
+ export declare type ScoradResourceMap<T> = {
445
+ readonly [P in keyof T]: T[P] extends object ? (P extends "intensity" | "subjective" ? ScoradResourceMap<T[P]> & {
446
+ levels: readonly string[];
447
+ } : ScoradResourceMap<T[P]>) & {
448
+ text: string;
449
+ } : ScoradResource;
450
+ };
451
+
452
+ /**
453
+ Localization and UI resources for the SCORAD component.
454
+ Maps data keys to human-readable labels and descriptions for display in the UI.
455
+ */
456
+ export declare const ScoradResources: ScoradResourceMap<ScoradData>;
457
+
458
+ /**
459
+ * @module
460
+ * @group Data
461
+ */
462
+ /** Computed SCORAD values representing the three clinical sections and the final sum.
463
+ */
464
+ export declare type ScoradScore = {
465
+ /** Extent (Surface Area): The percentage of body surface area affected, weighted by age.
466
+ */
467
+ A: number;
468
+ /** Intensity: The sum of the six clinical sign grades (Erythema, Oedema, etc.).
469
+ */
470
+ B: number;
471
+ /** Subjective Symptoms: The sum of patient-reported pruritus and sleeplessness scores.
472
+ */
473
+ C: number;
474
+ /** The final calculated score using the standard formula: A/5 + 7B/2 + C.
475
+ */
476
+ total: number;
477
+ };
478
+
479
+ /**
480
+ * @module
481
+ * @group Data
482
+ */
483
+ /**
484
+ * Represents the patient-reported scores for subjective symptoms (Itch/Sleeplessness).
485
+ * Used for calculating the Subjective Score (C).
486
+ */
487
+ export declare type ScoradSubjectiveData = {
488
+ /** Visual Analog Scale (VAS) score (0-10) for Pruritus (Itch) over the last 3 days/nights. */
489
+ pruritus: number;
490
+ /** Visual Analog Scale (VAS) score (0-10) for Sleeplessness over the last 3 days/nights. */
491
+ sleeplessness: number;
492
+ };
493
+
494
+ /**
495
+ * Select the weights by the data passed
496
+ *
497
+ * @param data scorad data
498
+ * @returns weights to use
499
+ */
500
+ export declare const selectScoradWeights: (data: ScoradData | null | undefined) => ScoradExtentWeights;
501
+
502
+ export { Success }
503
+
504
+ /**
505
+ * Validates all fields within the ScoradData object against their allowed clinical bounds.
506
+ * Returns an array of error messages.
507
+ *
508
+ * @param data - The complete ScoradData input object.
509
+ * @returns Result.
510
+ */
511
+ export declare const validateScoradData: {
512
+ (data: ScoradData | null | undefined): Result<ScoradData>;
513
+ formatError(name: string, key: string, max: number, value: number): string;
514
+ isValid(n: number, max: number): boolean;
515
+ };
516
+
517
+ export { }
@@ -24,12 +24,12 @@ This interface defines the standard reactive contract for components that manage
24
24
 
25
25
  | Event | Modifier | Type | Description |
26
26
  | ------ | ------ | ------ | ------ |
27
- | <a id="value-change"></a> `value-change` | `readonly` | `CustomEvent`\<`T`\> | Fired when the value is finalized or "committed" by the user. **Param** The final updated value of type [T](#t). |
28
- | <a id="value-input"></a> `value-input` | `readonly` | `CustomEvent`\<`T`\> | Fired immediately as the user interacts with the input (high frequency). **Param** The current value of type [T](#t) during input. |
27
+ | <a id="property-value-change"></a> `value-change` | `readonly` | `CustomEvent`\<`T`\> | Fired when the value is finalized or "committed" by the user. **Param** The final updated value of type [T](#t). |
28
+ | <a id="property-value-input"></a> `value-input` | `readonly` | `CustomEvent`\<`T`\> | Fired immediately as the user interacts with the input (high frequency). **Param** The current value of type [T](#t) during input. |
29
29
 
30
30
  #### Properties
31
31
 
32
32
  | Property | Modifier | Type | Description |
33
33
  | ------ | ------ | ------ | ------ |
34
- | <a id="readonly"></a> `readonly` | `public` | `boolean` | Value is readonly |
35
- | <a id="value"></a> `value` | `readonly` | `T` | The current value of the component. |
34
+ | <a id="property-readonly"></a> `readonly` | `public` | `boolean` | Value is readonly |
35
+ | <a id="property-value"></a> `value` | `readonly` | `T` | The current value of the component. |
@@ -17,7 +17,7 @@ A single resource item containing UI text strings.
17
17
  ### ScoradResourceMap
18
18
 
19
19
  ```ts
20
- type ScoradResourceMap<T> = { [P in keyof T]: T[P] extends object ? ScoradResourceMap<T[P]> : ScoradResource };
20
+ type ScoradResourceMap<T> = { readonly [P in keyof T]: T[P] extends object ? (P extends "intensity" | "subjective" ? ScoradResourceMap<T[P]> & { levels: readonly string[] } : ScoradResourceMap<T[P]>) & { text: string } : ScoradResource };
21
21
  ```
22
22
 
23
23
  A recursive type that mirrors the structure of a SCORAD data record,
@@ -10,5 +10,4 @@
10
10
  const componentsScoradLogger: ILogger;
11
11
  ```
12
12
 
13
- Internal logger instance for @ntix/components-scorad.
14
- Configured with a dedicated namespace and the resolved logLevel.
13
+ Internal logger instance for @ntix/components-scorad.