@bailaya/react 1.0.13 → 1.0.14
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.
|
@@ -3,7 +3,7 @@ import type { Instructor } from '@bailaya/core';
|
|
|
3
3
|
export interface InstructorListProps {
|
|
4
4
|
/** Optional studio ID to override the default configured ID */
|
|
5
5
|
overrideId?: string;
|
|
6
|
-
/** Locale code (e.g., "en", "es") for picking the
|
|
6
|
+
/** Locale code (e.g., "en", "es") for picking the bio */
|
|
7
7
|
locale?: string;
|
|
8
8
|
/** Root container wrapper */
|
|
9
9
|
className?: string;
|
|
@@ -17,7 +17,7 @@ export interface InstructorListProps {
|
|
|
17
17
|
bodyClassName?: string;
|
|
18
18
|
/** Instructor name heading */
|
|
19
19
|
nameClassName?: string;
|
|
20
|
-
/** Instructor bio paragraph
|
|
20
|
+
/** Instructor bio paragraph */
|
|
21
21
|
bioClassName?: string;
|
|
22
22
|
/**
|
|
23
23
|
* Optional custom render function for each instructor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstructorList.d.ts","sourceRoot":"","sources":["../../src/components/InstructorList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,WAAW,mBAAmB;IAChC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,
|
|
1
|
+
{"version":3,"file":"InstructorList.d.ts","sourceRoot":"","sources":["../../src/components/InstructorList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,WAAW,mBAAmB;IAChC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,KAAK,CAAC,SAAS,CAAC;CACvD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqDxD,CAAC"}
|
|
@@ -17,11 +17,13 @@ const LoadingIcon_1 = require("./ui/LoadingIcon");
|
|
|
17
17
|
*/
|
|
18
18
|
const InstructorList = ({ overrideId, locale, className = 'mt-6 md:mt-12 space-y-8', itemClassName = 'flex flex-col md:flex-row items-center rounded-lg border border-[#DCDCDC] shadow-lg overflow-hidden', imageWrapperClassName = 'w-full p-4 pb-0 md:pb-4 md:w-1/3 aspect-square', imageClassName = 'w-full h-full rounded-xl object-cover', bodyClassName = 'p-6 flex-1 text-left', nameClassName = 'text-xl md:text-3xl font-geologica font-semibold text-[#2A2343]', bioClassName = 'mt-2 text-xs md:text-xl font-sourcesans font-semibold text-[#464646]', renderItem, }) => {
|
|
19
19
|
const { data: instructors, loading: isLoading, error } = (0, useInstructors_1.useInstructors)(overrideId);
|
|
20
|
-
if (isLoading)
|
|
20
|
+
if (isLoading) {
|
|
21
21
|
return react_1.default.createElement("div", { className: className },
|
|
22
22
|
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
23
|
-
|
|
23
|
+
}
|
|
24
|
+
if (error) {
|
|
24
25
|
return react_1.default.createElement("div", { className: className }, error.message);
|
|
26
|
+
}
|
|
25
27
|
return (react_1.default.createElement("div", { className: className }, instructors === null || instructors === void 0 ? void 0 : instructors.map((instr) => {
|
|
26
28
|
var _a;
|
|
27
29
|
return renderItem ? (renderItem(instr)) : (react_1.default.createElement("div", { key: instr.id, className: itemClassName },
|
|
@@ -31,24 +33,10 @@ const InstructorList = ({ overrideId, locale, className = 'mt-6 md:mt-12 space-y
|
|
|
31
33
|
react_1.default.createElement("h3", { className: nameClassName },
|
|
32
34
|
instr.name,
|
|
33
35
|
instr.lastname ? ` ${instr.lastname}` : ''),
|
|
34
|
-
|
|
36
|
+
instr.bio && (react_1.default.createElement("p", { className: bioClassName }, pickLocalizedText(instr.bio, locale))))));
|
|
35
37
|
})));
|
|
36
38
|
};
|
|
37
39
|
exports.InstructorList = InstructorList;
|
|
38
|
-
/** Safely render localized bio as multiple <p> paragraphs. */
|
|
39
|
-
function renderBioParagraphs(bio, locale, bioClassName) {
|
|
40
|
-
const text = pickLocalizedText(bio, locale);
|
|
41
|
-
if (!text)
|
|
42
|
-
return null;
|
|
43
|
-
const lines = splitMultiline(text);
|
|
44
|
-
if (lines.length === 0)
|
|
45
|
-
return null;
|
|
46
|
-
// Keep the original classes on the first paragraph.
|
|
47
|
-
const firstClass = bioClassName;
|
|
48
|
-
// For subsequent paragraphs, remove any mt-* to avoid stacking big gaps.
|
|
49
|
-
const restClass = bioClassName.replace(/\bmt-\d+\b/g, '').trim() || bioClassName;
|
|
50
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, lines.map((line, i) => (react_1.default.createElement("p", { key: i, className: i === 0 ? firstClass : restClass }, line)))));
|
|
51
|
-
}
|
|
52
40
|
/** Pick localized text with fallback to first available. */
|
|
53
41
|
function pickLocalizedText(map, locale) {
|
|
54
42
|
const obj = map !== null && map !== void 0 ? map : {};
|
|
@@ -57,13 +45,3 @@ function pickLocalizedText(map, locale) {
|
|
|
57
45
|
const keys = Object.keys(obj);
|
|
58
46
|
return keys.length ? obj[keys[0]] : '';
|
|
59
47
|
}
|
|
60
|
-
/** Convert <br> -> newlines, then split, trim, and filter empty lines */
|
|
61
|
-
function splitMultiline(text) {
|
|
62
|
-
if (!text)
|
|
63
|
-
return [];
|
|
64
|
-
const normalized = text.replace(/<br\s*\/?>/gi, '\n');
|
|
65
|
-
return normalized
|
|
66
|
-
.split(/\r?\n/)
|
|
67
|
-
.map((l) => l.trim())
|
|
68
|
-
.filter(Boolean);
|
|
69
|
-
}
|