@ews-admin/global-design-system 1.1.18 → 1.1.20

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.
@@ -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;CAC7B;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAChD,gCAAgC,CAmLjC,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,CA+JjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ews-admin/global-design-system",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "EWS Global Design System - Reusable components for EWS applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -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 [specialties, setSpecialties] = useState<Specialty[]>([]);
42
+ const [filteredSpecialties, setFilteredSpecialties] = useState<Specialty[]>(
43
+ []
44
+ );
35
45
  const [isLoading, setIsLoading] = useState(false);
36
46
 
37
- // Mock API call - replace with actual API
38
- const fetchSpecialties = useCallback(async (searchTerm: string) => {
39
- setIsLoading(true);
40
- try {
41
- // Simulate API delay
42
- await new Promise((resolve) => setTimeout(resolve, 300));
43
-
44
- // Mock data - replace with actual API call
45
- const mockSpecialties: Specialty[] = [
46
- { id: "1", code: "CARD", label: "Cardiology" },
47
- { id: "2", code: "DERM", label: "Dermatology" },
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
- setSpecialties(filtered);
71
- } catch (error) {
72
- console.error("Error fetching specialties:", error);
73
- setSpecialties([]);
74
- } finally {
75
- setIsLoading(false);
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 specialties.find((specialty) => specialty.id === id);
88
+ return availableSpecialties.find((specialty) => specialty.id === id);
98
89
  },
99
- [specialties]
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 mb-2">
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={specialties}
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 border-ews-primary/20">
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 rounded flex items-center justify-center",
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"
@@ -162,34 +153,27 @@ export const SpecialtySearchAutocomplete: React.FC<
162
153
  </svg>
163
154
  )}
164
155
  </div>
165
- <div className="flex flex-col">
166
- <span
167
- className={cn(
168
- "font-medium",
169
- isSelected ? "text-ews-primary" : "text-gray-900"
170
- )}
171
- >
172
- {specialty.label}
173
- </span>
174
- <span
175
- className={cn(
176
- "text-sm",
177
- isSelected ? "text-ews-primary/70" : "text-gray-500"
178
- )}
179
- >
180
- {specialty.code}
181
- </span>
182
- </div>
156
+ <span
157
+ className={cn(
158
+ "font-medium",
159
+ isSelected ? "text-ews-primary" : "text-gray-900"
160
+ )}
161
+ >
162
+ {specialty.label}
163
+ </span>
183
164
  </div>
184
165
  )}
185
166
  />
186
167
 
187
168
  {/* Selected count display */}
188
169
  {showSelectedCount && selectedSpecialties.length > 0 && (
189
- <div className="flex items-center justify-between text-sm text-gray-600">
170
+ <div className="flex justify-between items-center text-sm text-gray-600">
190
171
  <span>
191
- {selectedSpecialties.length} specialty
192
- {selectedSpecialties.length !== 1 ? "ies" : ""} selected
172
+ {getSelectedCountText
173
+ ? getSelectedCountText(selectedSpecialties.length)
174
+ : `${selectedSpecialties.length} specialty${
175
+ selectedSpecialties.length !== 1 ? "ies" : ""
176
+ } selected`}
193
177
  </span>
194
178
  {maxSelections && (
195
179
  <span className="text-gray-400">