@ews-admin/global-design-system 1.1.18 → 1.1.19
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 +4 -0
- package/dist/index.esm.js +14 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -32
- package/dist/index.js.map +1 -1
- package/dist/molecules/SpecialtySearchAutocomplete/SpecialtySearchAutocomplete.d.ts +4 -0
- package/dist/molecules/SpecialtySearchAutocomplete/SpecialtySearchAutocomplete.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/molecules/SpecialtySearchAutocomplete/SpecialtySearchAutocomplete.tsx +46 -52
|
@@ -8,11 +8,15 @@ export interface Specialty {
|
|
|
8
8
|
export interface SpecialtySearchAutocompleteProps {
|
|
9
9
|
selectedSpecialties: Specialty[];
|
|
10
10
|
onSpecialtiesChange: (specialties: Specialty[]) => void;
|
|
11
|
+
specialties: Specialty[];
|
|
11
12
|
placeholder?: string;
|
|
12
13
|
className?: string;
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
maxSelections?: number;
|
|
15
16
|
showSelectedCount?: boolean;
|
|
17
|
+
title?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
getSelectedCountText?: (count: number) => React.ReactNode;
|
|
16
20
|
}
|
|
17
21
|
export declare const SpecialtySearchAutocomplete: React.FC<SpecialtySearchAutocompleteProps>;
|
|
18
22
|
//# sourceMappingURL=SpecialtySearchAutocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecialtySearchAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/molecules/SpecialtySearchAutocomplete/SpecialtySearchAutocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAED,MAAM,WAAW,gCAAgC;IAC/C,mBAAmB,EAAE,SAAS,EAAE,CAAC;IACjC,mBAAmB,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SpecialtySearchAutocomplete.d.ts","sourceRoot":"","sources":["../../../src/molecules/SpecialtySearchAutocomplete/SpecialtySearchAutocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAED,MAAM,WAAW,gCAAgC;IAC/C,mBAAmB,EAAE,SAAS,EAAE,CAAC;IACjC,mBAAmB,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IACxD,WAAW,EAAE,SAAS,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAC3D;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAChD,gCAAgC,CAyKjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -13,11 +13,15 @@ export interface Specialty {
|
|
|
13
13
|
export interface SpecialtySearchAutocompleteProps {
|
|
14
14
|
selectedSpecialties: Specialty[];
|
|
15
15
|
onSpecialtiesChange: (specialties: Specialty[]) => void;
|
|
16
|
+
specialties: Specialty[];
|
|
16
17
|
placeholder?: string;
|
|
17
18
|
className?: string;
|
|
18
19
|
disabled?: boolean;
|
|
19
20
|
maxSelections?: number;
|
|
20
21
|
showSelectedCount?: boolean;
|
|
22
|
+
title?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
getSelectedCountText?: (count: number) => React.ReactNode;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
export const SpecialtySearchAutocomplete: React.FC<
|
|
@@ -25,56 +29,43 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
25
29
|
> = ({
|
|
26
30
|
selectedSpecialties = [],
|
|
27
31
|
onSpecialtiesChange,
|
|
32
|
+
specialties: availableSpecialties,
|
|
28
33
|
placeholder = "Search and select medical specialties...",
|
|
29
34
|
className = "",
|
|
30
35
|
disabled = false,
|
|
31
36
|
maxSelections,
|
|
32
37
|
showSelectedCount = true,
|
|
38
|
+
title = "Medical Specialties",
|
|
39
|
+
label = "Select Specialties",
|
|
40
|
+
getSelectedCountText,
|
|
33
41
|
}) => {
|
|
34
|
-
const [
|
|
42
|
+
const [filteredSpecialties, setFilteredSpecialties] = useState<Specialty[]>(
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
35
45
|
const [isLoading, setIsLoading] = useState(false);
|
|
36
46
|
|
|
37
|
-
//
|
|
38
|
-
const fetchSpecialties = useCallback(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{ id: "3", code: "ENDO", label: "Endocrinology" },
|
|
49
|
-
{ id: "4", code: "GAST", label: "Gastroenterology" },
|
|
50
|
-
{ id: "5", code: "HEMA", label: "Hematology" },
|
|
51
|
-
{ id: "6", code: "NEUR", label: "Neurology" },
|
|
52
|
-
{ id: "7", code: "ONCO", label: "Oncology" },
|
|
53
|
-
{ id: "8", code: "ORTH", label: "Orthopedics" },
|
|
54
|
-
{ id: "9", code: "PED", label: "Pediatrics" },
|
|
55
|
-
{ id: "10", code: "PSYC", label: "Psychiatry" },
|
|
56
|
-
{ id: "11", code: "RAD", label: "Radiology" },
|
|
57
|
-
{ id: "12", code: "SURG", label: "Surgery" },
|
|
58
|
-
{ id: "13", code: "UROL", label: "Urology" },
|
|
59
|
-
{ id: "14", code: "GYN", label: "Gynecology" },
|
|
60
|
-
{ id: "15", code: "OPHT", label: "Ophthalmology" },
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
// Filter based on search term
|
|
64
|
-
const filtered = mockSpecialties.filter(
|
|
65
|
-
(specialty) =>
|
|
66
|
-
specialty.label.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
67
|
-
specialty.code.toLowerCase().includes(searchTerm.toLowerCase())
|
|
68
|
-
);
|
|
47
|
+
// Filter specialties based on search term
|
|
48
|
+
const fetchSpecialties = useCallback(
|
|
49
|
+
async (searchTerm: string) => {
|
|
50
|
+
setIsLoading(true);
|
|
51
|
+
try {
|
|
52
|
+
// Filter based on search term
|
|
53
|
+
const filtered = availableSpecialties.filter(
|
|
54
|
+
(specialty) =>
|
|
55
|
+
specialty.label.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
56
|
+
specialty.code.toLowerCase().includes(searchTerm.toLowerCase())
|
|
57
|
+
);
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
59
|
+
setFilteredSpecialties(filtered);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Error filtering specialties:", error);
|
|
62
|
+
setFilteredSpecialties([]);
|
|
63
|
+
} finally {
|
|
64
|
+
setIsLoading(false);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[availableSpecialties]
|
|
68
|
+
);
|
|
78
69
|
|
|
79
70
|
// Initial load
|
|
80
71
|
useEffect(() => {
|
|
@@ -94,9 +85,9 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
94
85
|
|
|
95
86
|
const getEntityById = useCallback(
|
|
96
87
|
async (id: string): Promise<Specialty | undefined> => {
|
|
97
|
-
return
|
|
88
|
+
return availableSpecialties.find((specialty) => specialty.id === id);
|
|
98
89
|
},
|
|
99
|
-
[
|
|
90
|
+
[availableSpecialties]
|
|
100
91
|
);
|
|
101
92
|
|
|
102
93
|
return (
|
|
@@ -107,20 +98,20 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
107
98
|
<Stethoscope className="w-4 h-4 text-secondary-600" />
|
|
108
99
|
</div>
|
|
109
100
|
<h3 className="text-lg font-semibold text-gray-900">
|
|
110
|
-
Medical Specialties
|
|
101
|
+
{title || "Medical Specialties"}
|
|
111
102
|
</h3>
|
|
112
103
|
</div>
|
|
113
104
|
|
|
114
105
|
{/* Label */}
|
|
115
106
|
<div>
|
|
116
|
-
<label className="block text-sm font-medium text-gray-700
|
|
117
|
-
Select Specialties
|
|
107
|
+
<label className="block mb-2 text-sm font-medium text-gray-700">
|
|
108
|
+
{label || "Select Specialties"}
|
|
118
109
|
</label>
|
|
119
110
|
</div>
|
|
120
111
|
|
|
121
112
|
{/* MultiSearchAutocomplete component */}
|
|
122
113
|
<MultiSearchAutocomplete<Specialty>
|
|
123
|
-
items={
|
|
114
|
+
items={filteredSpecialties}
|
|
124
115
|
selectedItems={selectedSpecialties}
|
|
125
116
|
onSelectionChange={handleSelectionChange}
|
|
126
117
|
onSearch={fetchSpecialties}
|
|
@@ -134,7 +125,7 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
134
125
|
keepOpenOnSelect={true}
|
|
135
126
|
className="w-full"
|
|
136
127
|
renderSelectedItem={(specialty) => (
|
|
137
|
-
<span className="inline-flex items-center px-3 py-1 text-sm font-medium rounded-full bg-ews-primary/10 text-ews-primary border
|
|
128
|
+
<span className="inline-flex items-center px-3 py-1 text-sm font-medium rounded-full border bg-ews-primary/10 text-ews-primary border-ews-primary/20">
|
|
138
129
|
{specialty.label}
|
|
139
130
|
</span>
|
|
140
131
|
)}
|
|
@@ -142,7 +133,7 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
142
133
|
<div className="flex items-center space-x-3">
|
|
143
134
|
<div
|
|
144
135
|
className={cn(
|
|
145
|
-
"w-5 h-5 border-2
|
|
136
|
+
"flex justify-center items-center w-5 h-5 rounded border-2",
|
|
146
137
|
isSelected
|
|
147
138
|
? "bg-ews-primary border-ews-primary"
|
|
148
139
|
: "border-ews-gray-300"
|
|
@@ -186,10 +177,13 @@ export const SpecialtySearchAutocomplete: React.FC<
|
|
|
186
177
|
|
|
187
178
|
{/* Selected count display */}
|
|
188
179
|
{showSelectedCount && selectedSpecialties.length > 0 && (
|
|
189
|
-
<div className="flex items-center
|
|
180
|
+
<div className="flex justify-between items-center text-sm text-gray-600">
|
|
190
181
|
<span>
|
|
191
|
-
{
|
|
192
|
-
|
|
182
|
+
{getSelectedCountText
|
|
183
|
+
? getSelectedCountText(selectedSpecialties.length)
|
|
184
|
+
: `${selectedSpecialties.length} specialty${
|
|
185
|
+
selectedSpecialties.length !== 1 ? "ies" : ""
|
|
186
|
+
} selected`}
|
|
193
187
|
</span>
|
|
194
188
|
{maxSelections && (
|
|
195
189
|
<span className="text-gray-400">
|