uhc-portal-components-react 0.2.25 → 0.2.26
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.2.26 - 2026-10-22
|
|
6
|
+
|
|
7
|
+
- Keep race and ethnicity outside the universal human profile: trusted
|
|
8
|
+
jurisdictional profiles may enable either, both or neither.
|
|
9
|
+
- Present enabled human demographic concepts as optional additions and omit
|
|
10
|
+
empty optional concepts from read-only views.
|
|
11
|
+
|
|
5
12
|
## 0.2.25 - 2026-10-22
|
|
6
13
|
|
|
7
14
|
- Add one shared read/edit demographics slot whose trusted profile renders
|
|
@@ -4,8 +4,8 @@ export type SubjectDemographicsOption = Readonly<{
|
|
|
4
4
|
}>;
|
|
5
5
|
export type SubjectDemographicsProfile = Readonly<{
|
|
6
6
|
subjectKind: 'human';
|
|
7
|
-
raceOptions
|
|
8
|
-
ethnicityOptions
|
|
7
|
+
raceOptions?: readonly SubjectDemographicsOption[];
|
|
8
|
+
ethnicityOptions?: readonly SubjectDemographicsOption[];
|
|
9
9
|
}> | Readonly<{
|
|
10
10
|
subjectKind: 'animal';
|
|
11
11
|
speciesOptions: readonly SubjectDemographicsOption[];
|
|
@@ -14,6 +14,8 @@ export type SubjectDemographicsProfile = Readonly<{
|
|
|
14
14
|
export type SubjectDemographicsCopy = Readonly<{
|
|
15
15
|
race?: string;
|
|
16
16
|
ethnicity?: string;
|
|
17
|
+
addRace?: string;
|
|
18
|
+
addEthnicity?: string;
|
|
17
19
|
species?: string;
|
|
18
20
|
breed?: string;
|
|
19
21
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubjectDemographicsFields.d.ts","sourceRoot":"","sources":["../src/SubjectDemographicsFields.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,yBAAyB,GAAG,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AO,EAAE,0BAA0B,CAAA;IACnC,IAAI,EAAE,uBAAuB,CAAA;IAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;CACtF,CAAC,+BAgFD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
/**
|
|
3
4
|
* Shared presentation slot for human or animal demographics.
|
|
4
5
|
*
|
|
@@ -7,26 +8,60 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
8
|
* the submitted fields to their own canonical persistence adapters.
|
|
8
9
|
*/
|
|
9
10
|
export function SubjectDemographicsFields({ mode, profile, copy, values, onValuesChange, }) {
|
|
11
|
+
const [visibleHumanFields, setVisibleHumanFields] = useState(() => new Set([
|
|
12
|
+
...(values?.primary ? ['race'] : []),
|
|
13
|
+
...(values?.secondary ? ['ethnicity'] : []),
|
|
14
|
+
]));
|
|
10
15
|
const fields = profile.subjectKind === 'human'
|
|
11
16
|
? [
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
...(profile.raceOptions === undefined ? [] : [{
|
|
18
|
+
concept: 'race',
|
|
19
|
+
valueKey: 'primary',
|
|
20
|
+
name: 'human.race',
|
|
21
|
+
label: requiredCopy(copy.race, 'race'),
|
|
22
|
+
addLabel: mode === 'edit' ? requiredCopy(copy.addRace, 'add_race') : '',
|
|
23
|
+
options: profile.raceOptions,
|
|
24
|
+
value: values?.primary,
|
|
25
|
+
required: false,
|
|
26
|
+
}]),
|
|
27
|
+
...(profile.ethnicityOptions === undefined ? [] : [{
|
|
28
|
+
concept: 'ethnicity',
|
|
29
|
+
valueKey: 'secondary',
|
|
30
|
+
name: 'human.ethnicity',
|
|
31
|
+
label: requiredCopy(copy.ethnicity, 'ethnicity'),
|
|
32
|
+
addLabel: mode === 'edit' ? requiredCopy(copy.addEthnicity, 'add_ethnicity') : '',
|
|
33
|
+
options: profile.ethnicityOptions,
|
|
34
|
+
value: values?.secondary,
|
|
35
|
+
required: false,
|
|
36
|
+
}]),
|
|
14
37
|
]
|
|
15
38
|
: [
|
|
16
|
-
{ name: 'animal.species', label: requiredCopy(copy.species, 'species'), options: profile.speciesOptions, value: values?.primary },
|
|
17
|
-
{ name: 'animal.breed', label: requiredCopy(copy.breed, 'breed'), options: profile.breedOptions, value: values?.secondary },
|
|
39
|
+
{ concept: 'species', valueKey: 'primary', name: 'animal.species', label: requiredCopy(copy.species, 'species'), addLabel: '', options: profile.speciesOptions, value: values?.primary, required: true },
|
|
40
|
+
{ concept: 'breed', valueKey: 'secondary', name: 'animal.breed', label: requiredCopy(copy.breed, 'breed'), addLabel: '', options: profile.breedOptions, value: values?.secondary, required: true },
|
|
18
41
|
];
|
|
19
|
-
return _jsx("div", { className: "uhcp-subject-demographics-fields", "data-subject-kind": profile.subjectKind, children: mode === 'edit'
|
|
20
|
-
? fields.map((field) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
return _jsx("div", { className: "uhcp-subject-demographics-fields", "data-subject-kind": profile.subjectKind, children: mode === 'edit' && profile.subjectKind === 'human'
|
|
43
|
+
? fields.map((field) => visibleHumanFields.has(field.concept)
|
|
44
|
+
? _jsxs("label", { children: [_jsx("span", { children: field.label }), _jsxs("select", { name: field.name, "aria-label": field.label, ...(onValuesChange
|
|
45
|
+
? {
|
|
46
|
+
value: field.value ?? '',
|
|
47
|
+
onChange: (event) => onValuesChange({
|
|
48
|
+
primary: field.valueKey === 'primary' ? event.currentTarget.value : values?.primary,
|
|
49
|
+
secondary: field.valueKey === 'secondary' ? event.currentTarget.value : values?.secondary,
|
|
50
|
+
}),
|
|
51
|
+
}
|
|
52
|
+
: { defaultValue: field.value ?? '' }), children: [_jsx("option", { value: "", disabled: true, children: field.label }), field.options.map((option) => _jsx("option", { value: option.value, children: option.label }, option.value))] })] }, field.name)
|
|
53
|
+
: _jsx("button", { className: "uhcp-subject-demographics-add", type: "button", onClick: () => setVisibleHumanFields((current) => new Set([...current, field.concept])), children: field.addLabel }, field.name))
|
|
54
|
+
: mode === 'edit'
|
|
55
|
+
? fields.map((field) => _jsxs("label", { children: [_jsx("span", { children: field.label }), _jsxs("select", { name: field.name, "aria-label": field.label, required: field.required, ...(onValuesChange
|
|
56
|
+
? {
|
|
57
|
+
value: field.value ?? '',
|
|
58
|
+
onChange: (event) => onValuesChange({
|
|
59
|
+
primary: field.valueKey === 'primary' ? event.currentTarget.value : values?.primary,
|
|
60
|
+
secondary: field.valueKey === 'secondary' ? event.currentTarget.value : values?.secondary,
|
|
61
|
+
}),
|
|
62
|
+
}
|
|
63
|
+
: { defaultValue: field.value ?? '' }), children: [_jsx("option", { value: "", disabled: true, children: field.label }), field.options.map((option) => _jsx("option", { value: option.value, children: option.label }, option.value))] })] }, field.name))
|
|
64
|
+
: _jsx("dl", { children: fields.filter((field) => profile.subjectKind === 'animal' || field.value).map((field) => _jsxs("div", { children: [_jsx("dt", { children: field.label }), _jsx("dd", { children: field.value || '—' })] }, field.name)) }) });
|
|
30
65
|
}
|
|
31
66
|
function requiredCopy(value, field) {
|
|
32
67
|
const normalized = String(value || '').trim();
|