@ews-admin/global-design-system 1.25.0 → 1.27.0
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/components/SecureLoader/SecureLoader.d.ts +18 -0
- package/dist/components/SecureLoader/SecureLoader.d.ts.map +1 -0
- package/dist/components/SecureLoader/index.d.ts +3 -0
- package/dist/components/SecureLoader/index.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +32 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +47 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/phone.d.ts +14 -0
- package/dist/utils/phone.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/components/SecureLoader/SecureLoader.tsx +37 -0
- package/src/components/SecureLoader/index.ts +2 -0
- package/src/index.ts +4 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/phone.ts +45 -0
package/dist/index.js
CHANGED
|
@@ -226,6 +226,46 @@ function formatPhoneNumberWithCountryCode(phoneNumber, countryCode = "+221") {
|
|
|
226
226
|
return "";
|
|
227
227
|
return `${countryCode}${cleaned}`;
|
|
228
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* National digit groups used to display a phone number, per country code:
|
|
231
|
+
* Senegal numbers have 9 national digits (77 123 45 67, 33 823 45 67), Chad
|
|
232
|
+
* numbers 8 (66 12 34 56).
|
|
233
|
+
*/
|
|
234
|
+
const DISPLAY_DIGIT_GROUPS = {
|
|
235
|
+
"+221": [2, 3, 2, 2],
|
|
236
|
+
"+235": [2, 2, 2, 2],
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Formats a phone number for display only: the country code, then the
|
|
240
|
+
* national digits in their usual groups. Do not use it for values sent to the
|
|
241
|
+
* API, form values or tel: links; formatPhoneNumberWithCountryCode gives the
|
|
242
|
+
* unspaced value for those. A number from another country, or of an
|
|
243
|
+
* unexpected length, is returned as formatPhoneNumberWithCountryCode returns it.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* formatPhoneNumberForDisplay("221771234567") // "+221 77 123 45 67" (backend's storage format)
|
|
247
|
+
* formatPhoneNumberForDisplay("771234567") // "+221 77 123 45 67"
|
|
248
|
+
* formatPhoneNumberForDisplay("+23566123456") // "+235 66 12 34 56"
|
|
249
|
+
* formatPhoneNumberForDisplay("+22177123") // "+22177123" (unexpected length, unchanged)
|
|
250
|
+
*/
|
|
251
|
+
function formatPhoneNumberForDisplay(phoneNumber, countryCode = "+221") {
|
|
252
|
+
const canonical = formatPhoneNumberWithCountryCode(phoneNumber, countryCode);
|
|
253
|
+
const code = COUNTRY_CODES.find(({ code: c }) => canonical.startsWith(c))?.code;
|
|
254
|
+
const groups = code ? DISPLAY_DIGIT_GROUPS[code] : undefined;
|
|
255
|
+
if (!code || !groups)
|
|
256
|
+
return canonical;
|
|
257
|
+
const national = canonical.slice(code.length).replace(/[\s-]/g, "");
|
|
258
|
+
const expectedLength = groups.reduce((sum, size) => sum + size, 0);
|
|
259
|
+
if (!/^\d+$/.test(national) || national.length !== expectedLength)
|
|
260
|
+
return canonical;
|
|
261
|
+
const parts = [];
|
|
262
|
+
let start = 0;
|
|
263
|
+
for (const size of groups) {
|
|
264
|
+
parts.push(national.slice(start, start + size));
|
|
265
|
+
start += size;
|
|
266
|
+
}
|
|
267
|
+
return `${code} ${parts.join(" ")}`;
|
|
268
|
+
}
|
|
229
269
|
|
|
230
270
|
/**
|
|
231
271
|
* Default currency for price formatting
|
|
@@ -35210,6 +35250,12 @@ const TagList = ({ items, maxVisible = DEFAULT_MAX, showMoreLabel, showLessLabel
|
|
|
35210
35250
|
*/
|
|
35211
35251
|
const PaymentDueBanner = ({ title, subtitle, warning, ctaLabel, onCtaClick, onDismiss, dismissLabel = "Close", }) => (jsxRuntime.jsx("div", { "data-testid": "payment-banner", className: "overflow-hidden bg-gradient-to-r from-red-600 to-red-700 shadow-lg", children: jsxRuntime.jsx("div", { className: "px-6 py-8 sm:px-8", children: jsxRuntime.jsxs("div", { className: "flex flex-col space-y-6 sm:flex-row sm:items-center sm:justify-between sm:space-y-0", children: [jsxRuntime.jsxs("div", { className: "flex items-center space-x-4", children: [jsxRuntime.jsx(TriangleAlert, { className: "w-8 h-8 text-white shrink-0" }), jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [jsxRuntime.jsx("h3", { className: "text-2xl font-bold text-white", children: title }), subtitle && (jsxRuntime.jsx("p", { className: "mt-2 text-base text-red-100", children: subtitle })), warning && (jsxRuntime.jsx("p", { className: "mt-1 text-sm font-medium text-red-200", children: warning }))] })] }), jsxRuntime.jsxs("div", { className: "flex flex-col flex-shrink-0 gap-3 sm:flex-row sm:gap-4 sm:items-center", children: [jsxRuntime.jsx("button", { onClick: onCtaClick, className: "w-full px-8 py-3 text-base font-semibold text-red-600 bg-white rounded-lg shadow-sm transition-all duration-200 sm:w-auto hover:bg-red-50 hover:shadow-md", children: ctaLabel }), onDismiss && (jsxRuntime.jsx("button", { onClick: onDismiss, className: "self-start p-2 rounded-full transition-colors bg-white/10 hover:bg-white/20 sm:self-auto", "aria-label": dismissLabel, children: jsxRuntime.jsx(X, { className: "w-5 h-5 text-white" }) }))] })] }) }) }));
|
|
35212
35252
|
|
|
35253
|
+
/**
|
|
35254
|
+
* Full-screen loader (lock icon with a spinner) shown while the user's
|
|
35255
|
+
* session is being checked.
|
|
35256
|
+
*/
|
|
35257
|
+
const SecureLoader = ({ label, description }) => (jsxRuntime.jsx("div", { "data-testid": "secure-loader", className: "flex min-h-screen items-center justify-center bg-gray-100", children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center rounded-lg bg-white p-6 shadow-lg", children: [jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsx(Lock, { className: "h-16 w-16 text-gray-500" }), jsxRuntime.jsx("div", { className: "absolute bottom-2 right-1 h-6 w-6 animate-spin rounded-full border-4 border-gray-300 border-t-green-500" })] }), jsxRuntime.jsx("p", { className: "mt-4 text-lg text-gray-600", children: label }), description && (jsxRuntime.jsx("p", { className: "mt-2 text-sm text-gray-500", children: description }))] }) }));
|
|
35258
|
+
|
|
35213
35259
|
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, }) => {
|
|
35214
35260
|
const [filteredSpecialties, setFilteredSpecialties] = React.useState([]);
|
|
35215
35261
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
@@ -39995,6 +40041,7 @@ exports.SearchX = SearchX;
|
|
|
39995
40041
|
exports.SearchXIcon = SearchX;
|
|
39996
40042
|
exports.Section = Section;
|
|
39997
40043
|
exports.SectionIcon = Section;
|
|
40044
|
+
exports.SecureLoader = SecureLoader;
|
|
39998
40045
|
exports.Select = Select;
|
|
39999
40046
|
exports.Send = Send;
|
|
40000
40047
|
exports.SendHorizonal = SendHorizontal;
|
|
@@ -40865,6 +40912,7 @@ exports.extractCountryCodeFromPhoneNumber = extractCountryCodeFromPhoneNumber;
|
|
|
40865
40912
|
exports.formatCurrency = formatCurrency;
|
|
40866
40913
|
exports.formatDate = formatDate;
|
|
40867
40914
|
exports.formatNumeric = formatNumeric;
|
|
40915
|
+
exports.formatPhoneNumberForDisplay = formatPhoneNumberForDisplay;
|
|
40868
40916
|
exports.formatPhoneNumberWithCountryCode = formatPhoneNumberWithCountryCode;
|
|
40869
40917
|
exports.generateId = generateId;
|
|
40870
40918
|
exports.getDefaultCountryCode = getDefaultCountryCode;
|