@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.
- 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 +54 -70
package/dist/index.d.ts
CHANGED
|
@@ -384,11 +384,15 @@ interface Specialty {
|
|
|
384
384
|
interface SpecialtySearchAutocompleteProps {
|
|
385
385
|
selectedSpecialties: Specialty[];
|
|
386
386
|
onSpecialtiesChange: (specialties: Specialty[]) => void;
|
|
387
|
+
specialties: Specialty[];
|
|
387
388
|
placeholder?: string;
|
|
388
389
|
className?: string;
|
|
389
390
|
disabled?: boolean;
|
|
390
391
|
maxSelections?: number;
|
|
391
392
|
showSelectedCount?: boolean;
|
|
393
|
+
title?: string;
|
|
394
|
+
label?: string;
|
|
395
|
+
getSelectedCountText?: (count: number) => React.ReactNode;
|
|
392
396
|
}
|
|
393
397
|
declare const SpecialtySearchAutocomplete: React.FC<SpecialtySearchAutocompleteProps>;
|
|
394
398
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1944,46 +1944,26 @@ const ThemeDebugger = ({ className = "", }) => {
|
|
|
1944
1944
|
: "bg-gray-200 text-gray-700"}`, children: "MED" })] }), jsxs("div", { className: "grid grid-cols-2 gap-2 mt-4", children: [jsx("div", { className: "bg-ews-primary text-white p-2 rounded text-center", children: "Primary" }), jsx("div", { className: "bg-ews-secondary text-white p-2 rounded text-center", children: "Secondary" }), jsx("div", { className: "bg-ews-success text-white p-2 rounded text-center", children: "Success" }), jsx("div", { className: "bg-ews-warning text-white p-2 rounded text-center", children: "Warning" })] })] })] }));
|
|
1945
1945
|
};
|
|
1946
1946
|
|
|
1947
|
-
const SpecialtySearchAutocomplete = ({ selectedSpecialties = [], onSpecialtiesChange, placeholder = "Search and select medical specialties...", className = "", disabled = false, maxSelections, showSelectedCount = true, }) => {
|
|
1948
|
-
const [
|
|
1947
|
+
const SpecialtySearchAutocomplete = ({ selectedSpecialties = [], onSpecialtiesChange, specialties: availableSpecialties, placeholder = "Search and select medical specialties...", className = "", disabled = false, maxSelections, showSelectedCount = true, title = "Medical Specialties", label = "Select Specialties", getSelectedCountText, }) => {
|
|
1948
|
+
const [filteredSpecialties, setFilteredSpecialties] = useState([]);
|
|
1949
1949
|
const [isLoading, setIsLoading] = useState(false);
|
|
1950
|
-
//
|
|
1950
|
+
// Filter specialties based on search term
|
|
1951
1951
|
const fetchSpecialties = useCallback(async (searchTerm) => {
|
|
1952
1952
|
setIsLoading(true);
|
|
1953
1953
|
try {
|
|
1954
|
-
// Simulate API delay
|
|
1955
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
1956
|
-
// Mock data - replace with actual API call
|
|
1957
|
-
const mockSpecialties = [
|
|
1958
|
-
{ id: "1", code: "CARD", label: "Cardiology" },
|
|
1959
|
-
{ id: "2", code: "DERM", label: "Dermatology" },
|
|
1960
|
-
{ id: "3", code: "ENDO", label: "Endocrinology" },
|
|
1961
|
-
{ id: "4", code: "GAST", label: "Gastroenterology" },
|
|
1962
|
-
{ id: "5", code: "HEMA", label: "Hematology" },
|
|
1963
|
-
{ id: "6", code: "NEUR", label: "Neurology" },
|
|
1964
|
-
{ id: "7", code: "ONCO", label: "Oncology" },
|
|
1965
|
-
{ id: "8", code: "ORTH", label: "Orthopedics" },
|
|
1966
|
-
{ id: "9", code: "PED", label: "Pediatrics" },
|
|
1967
|
-
{ id: "10", code: "PSYC", label: "Psychiatry" },
|
|
1968
|
-
{ id: "11", code: "RAD", label: "Radiology" },
|
|
1969
|
-
{ id: "12", code: "SURG", label: "Surgery" },
|
|
1970
|
-
{ id: "13", code: "UROL", label: "Urology" },
|
|
1971
|
-
{ id: "14", code: "GYN", label: "Gynecology" },
|
|
1972
|
-
{ id: "15", code: "OPHT", label: "Ophthalmology" },
|
|
1973
|
-
];
|
|
1974
1954
|
// Filter based on search term
|
|
1975
|
-
const filtered =
|
|
1955
|
+
const filtered = availableSpecialties.filter((specialty) => specialty.label.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
1976
1956
|
specialty.code.toLowerCase().includes(searchTerm.toLowerCase()));
|
|
1977
|
-
|
|
1957
|
+
setFilteredSpecialties(filtered);
|
|
1978
1958
|
}
|
|
1979
1959
|
catch (error) {
|
|
1980
|
-
console.error("Error
|
|
1981
|
-
|
|
1960
|
+
console.error("Error filtering specialties:", error);
|
|
1961
|
+
setFilteredSpecialties([]);
|
|
1982
1962
|
}
|
|
1983
1963
|
finally {
|
|
1984
1964
|
setIsLoading(false);
|
|
1985
1965
|
}
|
|
1986
|
-
}, []);
|
|
1966
|
+
}, [availableSpecialties]);
|
|
1987
1967
|
// Initial load
|
|
1988
1968
|
useEffect(() => {
|
|
1989
1969
|
fetchSpecialties("");
|
|
@@ -1996,11 +1976,13 @@ const SpecialtySearchAutocomplete = ({ selectedSpecialties = [], onSpecialtiesCh
|
|
|
1996
1976
|
onSpecialtiesChange(items);
|
|
1997
1977
|
}, [onSpecialtiesChange, maxSelections]);
|
|
1998
1978
|
const getEntityById = useCallback(async (id) => {
|
|
1999
|
-
return
|
|
2000
|
-
}, [
|
|
2001
|
-
return (jsxs("div", { className: cn("space-y-3", className), children: [jsxs("div", { className: "flex items-center space-x-2", children: [jsx("div", { className: "flex justify-center items-center w-8 h-8 rounded-lg bg-secondary-100", children: jsx(Stethoscope, { className: "w-4 h-4 text-secondary-600" }) }), jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Medical Specialties" })] }), jsx("div", { children: jsx("label", { className: "block text-sm font-medium text-gray-700
|
|
1979
|
+
return availableSpecialties.find((specialty) => specialty.id === id);
|
|
1980
|
+
}, [availableSpecialties]);
|
|
1981
|
+
return (jsxs("div", { className: cn("space-y-3", className), children: [jsxs("div", { className: "flex items-center space-x-2", children: [jsx("div", { className: "flex justify-center items-center w-8 h-8 rounded-lg bg-secondary-100", children: jsx(Stethoscope, { className: "w-4 h-4 text-secondary-600" }) }), jsx("h3", { className: "text-lg font-semibold text-gray-900", children: title || "Medical Specialties" })] }), jsx("div", { children: jsx("label", { className: "block mb-2 text-sm font-medium text-gray-700", children: label || "Select Specialties" }) }), jsx(MultiSearchAutocomplete, { items: filteredSpecialties, selectedItems: selectedSpecialties, onSelectionChange: handleSelectionChange, onSearch: fetchSpecialties, getEntityById: getEntityById, getPrimaryText: (specialty) => specialty.label, getSecondaryText: (specialty) => specialty.code, placeholder: placeholder, disabled: disabled, loading: isLoading, multiple: true, keepOpenOnSelect: true, className: "w-full", renderSelectedItem: (specialty) => (jsx("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", children: specialty.label })), renderListItem: (specialty, isSelected) => (jsxs("div", { className: "flex items-center space-x-3", children: [jsx("div", { className: cn("flex justify-center items-center w-5 h-5 rounded border-2", isSelected
|
|
2002
1982
|
? "bg-ews-primary border-ews-primary"
|
|
2003
|
-
: "border-ews-gray-300"), children: isSelected && (jsx("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: jsx("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) })) }),
|
|
1983
|
+
: "border-ews-gray-300"), children: isSelected && (jsx("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: jsx("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) })) }), jsx("span", { className: cn("font-medium", isSelected ? "text-ews-primary" : "text-gray-900"), children: specialty.label })] })) }), showSelectedCount && selectedSpecialties.length > 0 && (jsxs("div", { className: "flex justify-between items-center text-sm text-gray-600", children: [jsx("span", { children: getSelectedCountText
|
|
1984
|
+
? getSelectedCountText(selectedSpecialties.length)
|
|
1985
|
+
: `${selectedSpecialties.length} specialty${selectedSpecialties.length !== 1 ? "ies" : ""} selected` }), maxSelections && (jsxs("span", { className: "text-gray-400", children: [selectedSpecialties.length, "/", maxSelections] }))] }))] }));
|
|
2004
1986
|
};
|
|
2005
1987
|
|
|
2006
1988
|
export { ArrowRight, Button, Check, DoctorIcon, DropdownMultiSelect, Icon, Input, Logo, Modal, MultiSearchAutocomplete, PatientIcon, Search, SearchAutocomplete, Select, SpecialtySearchAutocomplete, ThemeDebugger, ThemeProvider, ThemeToggle, UserIcon, cn, debounce, formatCurrency, formatDate, formatNumeric, generateId, isValidPhoneNumber, useDebounce, useDebouncedCallback, useSelectField, useTheme };
|