@bailaya/react 1.0.12 → 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,31 +33,15 @@ 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
|
-
/**
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(locales.length ? bioMap[locales[0]] : '') ||
|
|
46
|
-
'';
|
|
47
|
-
const lines = splitMultiline(text);
|
|
48
|
-
if (lines.length === 0)
|
|
49
|
-
return null;
|
|
50
|
-
return (react_1.default.createElement("div", { className: "space-y-2" }, lines.map((line, i) => (react_1.default.createElement("p", { key: i, className: paragraphClassName }, line)))));
|
|
51
|
-
}
|
|
52
|
-
/** Convert <br> -> newlines, then split, trim, and filter empty lines */
|
|
53
|
-
function splitMultiline(text) {
|
|
54
|
-
if (!text)
|
|
55
|
-
return [];
|
|
56
|
-
const normalized = text.replace(/<br\s*\/?>/gi, '\n');
|
|
57
|
-
return normalized
|
|
58
|
-
.split(/\r?\n/)
|
|
59
|
-
.map((l) => l.trim())
|
|
60
|
-
.filter(Boolean);
|
|
40
|
+
/** Pick localized text with fallback to first available. */
|
|
41
|
+
function pickLocalizedText(map, locale) {
|
|
42
|
+
const obj = map !== null && map !== void 0 ? map : {};
|
|
43
|
+
if (locale && obj[locale])
|
|
44
|
+
return obj[locale];
|
|
45
|
+
const keys = Object.keys(obj);
|
|
46
|
+
return keys.length ? obj[keys[0]] : '';
|
|
61
47
|
}
|