taleem-browser 0.2.0 → 1.0.0-rc.1
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/README.md +156 -133
- package/dist/taleem-browser.esm.js +260 -315
- package/dist/taleem-browser.umd.js +260 -315
- package/package.json +4 -4
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
// node_modules/taleem-slides/src/slides/TitleSlide.js
|
|
2
2
|
var TitleSlide = {
|
|
3
3
|
type: "titleSlide",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!Array.isArray(rawSlide.data)) {
|
|
9
|
-
throw new Error(`TitleSlide: data must be an array`);
|
|
10
|
-
}
|
|
11
|
-
const titleItem = rawSlide.data.find((d) => d.name === "title");
|
|
12
|
-
if (!titleItem || typeof titleItem.content !== "string") {
|
|
13
|
-
throw new Error(`TitleSlide: missing or invalid title content`);
|
|
4
|
+
fromJSON(raw) {
|
|
5
|
+
const title = raw.data?.find((d) => d.name === "title")?.content;
|
|
6
|
+
if (!title) {
|
|
7
|
+
throw new Error("titleSlide: requires title");
|
|
14
8
|
}
|
|
15
|
-
const title = titleItem.content;
|
|
16
9
|
return Object.freeze({
|
|
17
10
|
type: "titleSlide",
|
|
18
11
|
render() {
|
|
19
12
|
return `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
<section class="slide titleSlide">
|
|
14
|
+
<h1>${title}</h1>
|
|
15
|
+
</section>
|
|
16
|
+
`;
|
|
24
17
|
}
|
|
25
18
|
});
|
|
26
19
|
}
|
|
@@ -39,11 +32,11 @@ var TitleAndSubtitleSlide = {
|
|
|
39
32
|
type: "titleAndSubtitle",
|
|
40
33
|
render() {
|
|
41
34
|
return `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
<section class="slide titleAndSubtitle">
|
|
36
|
+
<h1>${title}</h1>
|
|
37
|
+
<h2>${subtitle}</h2>
|
|
38
|
+
</section>
|
|
39
|
+
`;
|
|
47
40
|
}
|
|
48
41
|
});
|
|
49
42
|
}
|
|
@@ -62,11 +55,11 @@ var TitleAndParaSlide = {
|
|
|
62
55
|
type: "titleAndPara",
|
|
63
56
|
render() {
|
|
64
57
|
return `
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
<section class="slide titleAndPara">
|
|
59
|
+
<h1>${title}</h1>
|
|
60
|
+
<p>${para}</p>
|
|
61
|
+
</section>
|
|
62
|
+
`;
|
|
70
63
|
}
|
|
71
64
|
});
|
|
72
65
|
}
|
|
@@ -82,14 +75,19 @@ var BulletListSlide = {
|
|
|
82
75
|
}
|
|
83
76
|
return Object.freeze({
|
|
84
77
|
type: "bulletList",
|
|
85
|
-
|
|
78
|
+
bullets,
|
|
79
|
+
render({ visibleCount = bullets.length, activeIndex = null } = {}) {
|
|
86
80
|
return `
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
<section class="slide bulletList">
|
|
82
|
+
<ul>
|
|
83
|
+
${bullets.map((text, i) => {
|
|
84
|
+
if (i >= visibleCount) return "";
|
|
85
|
+
const cls = i === activeIndex ? "is-active" : activeIndex !== null && i < activeIndex ? "is-dim" : "";
|
|
86
|
+
return `<li class="${cls}">${text}</li>`;
|
|
87
|
+
}).join("")}
|
|
88
|
+
</ul>
|
|
89
|
+
</section>
|
|
90
|
+
`;
|
|
93
91
|
}
|
|
94
92
|
});
|
|
95
93
|
}
|
|
@@ -102,17 +100,21 @@ var TwoColumnTextSlide = {
|
|
|
102
100
|
const left = raw.data?.filter((d) => d.name === "left").map((d) => d.content);
|
|
103
101
|
const right = raw.data?.filter((d) => d.name === "right").map((d) => d.content);
|
|
104
102
|
if (!left?.length || !right?.length) {
|
|
105
|
-
throw new Error("twoColumnText: requires left and right
|
|
103
|
+
throw new Error("twoColumnText: requires left and right");
|
|
106
104
|
}
|
|
107
105
|
return Object.freeze({
|
|
108
106
|
type: "twoColumnText",
|
|
109
107
|
render() {
|
|
110
108
|
return `
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
</
|
|
115
|
-
|
|
109
|
+
<section class="slide twoColumnText">
|
|
110
|
+
<div class="col left">
|
|
111
|
+
${left.map((v) => `<div>${v}</div>`).join("")}
|
|
112
|
+
</div>
|
|
113
|
+
<div class="col right">
|
|
114
|
+
${right.map((v) => `<div>${v}</div>`).join("")}
|
|
115
|
+
</div>
|
|
116
|
+
</section>
|
|
117
|
+
`;
|
|
116
118
|
}
|
|
117
119
|
});
|
|
118
120
|
}
|
|
@@ -126,12 +128,13 @@ var ImageSlide = {
|
|
|
126
128
|
if (!src) throw new Error("imageSlide: image required");
|
|
127
129
|
return Object.freeze({
|
|
128
130
|
type: "imageSlide",
|
|
131
|
+
src,
|
|
129
132
|
render() {
|
|
130
133
|
return `
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
<section class="slide imageSlide">
|
|
135
|
+
<img src="${src}" alt="" />
|
|
136
|
+
</section>
|
|
137
|
+
`;
|
|
135
138
|
}
|
|
136
139
|
});
|
|
137
140
|
}
|
|
@@ -147,12 +150,13 @@ var FillImageSlide = {
|
|
|
147
150
|
}
|
|
148
151
|
return Object.freeze({
|
|
149
152
|
type: "fillImage",
|
|
153
|
+
image,
|
|
150
154
|
render() {
|
|
151
155
|
return `
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
<section class="slide fillImage">
|
|
157
|
+
<img src="${image}" alt="" />
|
|
158
|
+
</section>
|
|
159
|
+
`;
|
|
156
160
|
}
|
|
157
161
|
});
|
|
158
162
|
}
|
|
@@ -169,13 +173,15 @@ var ImageWithTitleSlide = {
|
|
|
169
173
|
}
|
|
170
174
|
return Object.freeze({
|
|
171
175
|
type: "imageWithTitle",
|
|
176
|
+
src,
|
|
177
|
+
title,
|
|
172
178
|
render() {
|
|
173
179
|
return `
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
<section class="slide imageWithTitle">
|
|
181
|
+
<img src="${src}" alt="" />
|
|
182
|
+
<h1>${title}</h1>
|
|
183
|
+
</section>
|
|
184
|
+
`;
|
|
179
185
|
}
|
|
180
186
|
});
|
|
181
187
|
}
|
|
@@ -192,13 +198,15 @@ var ImageWithCaptionSlide = {
|
|
|
192
198
|
}
|
|
193
199
|
return Object.freeze({
|
|
194
200
|
type: "imageWithCaption",
|
|
201
|
+
src,
|
|
202
|
+
caption,
|
|
195
203
|
render() {
|
|
196
204
|
return `
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
<figure class="slide imageWithCaption">
|
|
206
|
+
<img src="${src}" alt="" />
|
|
207
|
+
<figcaption>${caption}</figcaption>
|
|
208
|
+
</figure>
|
|
209
|
+
`;
|
|
202
210
|
}
|
|
203
211
|
});
|
|
204
212
|
}
|
|
@@ -210,20 +218,24 @@ var ImageLeftBulletsRightSlide = {
|
|
|
210
218
|
fromJSON(raw) {
|
|
211
219
|
const image = raw.data?.find((d) => d.name === "image")?.content;
|
|
212
220
|
const bullets = raw.data?.filter((d) => d.name === "bullet").map((d) => d.content);
|
|
213
|
-
if (!image || !bullets
|
|
221
|
+
if (!image || !bullets || bullets.length === 0) {
|
|
214
222
|
throw new Error("imageLeftBulletsRight: image and bullets required");
|
|
215
223
|
}
|
|
216
224
|
return Object.freeze({
|
|
217
225
|
type: "imageLeftBulletsRight",
|
|
218
|
-
|
|
226
|
+
image,
|
|
227
|
+
bullets,
|
|
228
|
+
render({ visibleCount = bullets.length } = {}) {
|
|
219
229
|
return `
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
<section class="slide imageLeftBulletsRight">
|
|
231
|
+
<img src="${image}" alt="" />
|
|
232
|
+
<ul>
|
|
233
|
+
${bullets.map(
|
|
234
|
+
(text, i) => i < visibleCount ? `<li>${text}</li>` : ""
|
|
235
|
+
).join("")}
|
|
236
|
+
</ul>
|
|
237
|
+
</section>
|
|
238
|
+
`;
|
|
227
239
|
}
|
|
228
240
|
});
|
|
229
241
|
}
|
|
@@ -235,20 +247,24 @@ var ImageRightBulletsLeftSlide = {
|
|
|
235
247
|
fromJSON(raw) {
|
|
236
248
|
const image = raw.data?.find((d) => d.name === "image")?.content;
|
|
237
249
|
const bullets = raw.data?.filter((d) => d.name === "bullet").map((d) => d.content);
|
|
238
|
-
if (!image || !bullets
|
|
250
|
+
if (!image || !bullets || bullets.length === 0) {
|
|
239
251
|
throw new Error("imageRightBulletsLeft: image and bullets required");
|
|
240
252
|
}
|
|
241
253
|
return Object.freeze({
|
|
242
254
|
type: "imageRightBulletsLeft",
|
|
243
|
-
|
|
255
|
+
image,
|
|
256
|
+
bullets,
|
|
257
|
+
render({ visibleCount = bullets.length } = {}) {
|
|
244
258
|
return `
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
</
|
|
251
|
-
|
|
259
|
+
<section class="slide imageRightBulletsLeft">
|
|
260
|
+
<ul>
|
|
261
|
+
${bullets.map(
|
|
262
|
+
(text, i) => i < visibleCount ? `<li>${text}</li>` : ""
|
|
263
|
+
).join("")}
|
|
264
|
+
</ul>
|
|
265
|
+
<img src="${image}" alt="" />
|
|
266
|
+
</section>
|
|
267
|
+
`;
|
|
252
268
|
}
|
|
253
269
|
});
|
|
254
270
|
}
|
|
@@ -258,20 +274,26 @@ var ImageRightBulletsLeftSlide = {
|
|
|
258
274
|
var TableSlide = {
|
|
259
275
|
type: "table",
|
|
260
276
|
fromJSON(raw) {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
277
|
+
const headers = raw.data?.find((d) => d.name === "header")?.content;
|
|
278
|
+
const rows = raw.data?.find((d) => d.name === "row")?.content;
|
|
279
|
+
if (!headers || !rows?.length) {
|
|
280
|
+
throw new Error("table: requires headers and at least one row");
|
|
264
281
|
}
|
|
265
282
|
return Object.freeze({
|
|
266
283
|
type: "table",
|
|
267
284
|
render() {
|
|
268
285
|
return `
|
|
269
|
-
|
|
286
|
+
<table class="slide table">
|
|
287
|
+
<thead>
|
|
288
|
+
<tr>${headers.map((h) => `<th>${h}</th>`).join("")}</tr>
|
|
289
|
+
</thead>
|
|
290
|
+
<tbody>
|
|
270
291
|
${rows.map(
|
|
271
|
-
(
|
|
292
|
+
(r) => `<tr>${r.map((c) => `<td>${c}</td>`).join("")}</tr>`
|
|
272
293
|
).join("")}
|
|
273
|
-
</
|
|
274
|
-
|
|
294
|
+
</tbody>
|
|
295
|
+
</table>
|
|
296
|
+
`;
|
|
275
297
|
}
|
|
276
298
|
});
|
|
277
299
|
}
|
|
@@ -282,19 +304,21 @@ var StatisticSlide = {
|
|
|
282
304
|
type: "statistic",
|
|
283
305
|
fromJSON(raw) {
|
|
284
306
|
const label = raw.data?.find((d) => d.name === "label")?.content;
|
|
285
|
-
const
|
|
286
|
-
if (!label ||
|
|
287
|
-
throw new Error("statistic: requires
|
|
307
|
+
const number = raw.data?.find((d) => d.name === "number")?.content;
|
|
308
|
+
if (!label || number === void 0) {
|
|
309
|
+
throw new Error("statistic: requires number and label");
|
|
288
310
|
}
|
|
289
311
|
return Object.freeze({
|
|
290
312
|
type: "statistic",
|
|
313
|
+
label,
|
|
314
|
+
number,
|
|
291
315
|
render() {
|
|
292
316
|
return `
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
317
|
+
<section class="slide statistic">
|
|
318
|
+
<div class="stat-value">${number}</div>
|
|
319
|
+
<div class="stat-label">${label}</div>
|
|
320
|
+
</section>
|
|
321
|
+
`;
|
|
298
322
|
}
|
|
299
323
|
});
|
|
300
324
|
}
|
|
@@ -304,18 +328,22 @@ var StatisticSlide = {
|
|
|
304
328
|
var BigNumberSlide = {
|
|
305
329
|
type: "bigNumber",
|
|
306
330
|
fromJSON(raw) {
|
|
307
|
-
const
|
|
331
|
+
const number = raw.data?.find((d) => d.name === "number")?.content;
|
|
308
332
|
const label = raw.data?.find((d) => d.name === "label")?.content;
|
|
309
|
-
if (!
|
|
333
|
+
if (!number) {
|
|
334
|
+
throw new Error("bigNumber: number required");
|
|
335
|
+
}
|
|
310
336
|
return Object.freeze({
|
|
311
337
|
type: "bigNumber",
|
|
338
|
+
number,
|
|
339
|
+
label,
|
|
312
340
|
render() {
|
|
313
341
|
return `
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
342
|
+
<section class="slide bigNumber">
|
|
343
|
+
<div class="number">${number}</div>
|
|
344
|
+
${label ? `<div class="label">${label}</div>` : ""}
|
|
345
|
+
</section>
|
|
346
|
+
`;
|
|
319
347
|
}
|
|
320
348
|
});
|
|
321
349
|
}
|
|
@@ -325,32 +353,33 @@ var BigNumberSlide = {
|
|
|
325
353
|
var BarChartSlide = {
|
|
326
354
|
type: "barChart",
|
|
327
355
|
fromJSON(raw) {
|
|
328
|
-
const bars = raw.data?.filter((d) => d.name === "bar")
|
|
356
|
+
const bars = raw.data?.filter((d) => d.name === "bar").map((d) => ({
|
|
357
|
+
label: d.label,
|
|
358
|
+
value: d.value
|
|
359
|
+
}));
|
|
329
360
|
if (!bars || bars.length === 0) {
|
|
330
361
|
throw new Error("barChart: requires at least one bar");
|
|
331
362
|
}
|
|
332
|
-
bars.forEach((b, i) => {
|
|
333
|
-
if (typeof b.content !== "object" || typeof b.content.label !== "string" || typeof b.content.value !== "number") {
|
|
334
|
-
throw new Error(`barChart: invalid bar at index ${i}`);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
363
|
return Object.freeze({
|
|
338
364
|
type: "barChart",
|
|
339
|
-
|
|
365
|
+
bars,
|
|
366
|
+
render({ visibleCount = bars.length, activeIndex = null } = {}) {
|
|
340
367
|
return `
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
368
|
+
<section class="slide barChart">
|
|
369
|
+
<ul class="bars">
|
|
370
|
+
${bars.map((b, i) => {
|
|
371
|
+
if (i >= visibleCount) return "";
|
|
372
|
+
const cls = i === activeIndex ? "is-active" : activeIndex !== null && i < activeIndex ? "is-dim" : "";
|
|
373
|
+
return `
|
|
374
|
+
<li class="bar ${cls}">
|
|
375
|
+
<span class="bar-label">${b.label}</span>
|
|
376
|
+
<span class="bar-value">${b.value}</span>
|
|
377
|
+
</li>
|
|
378
|
+
`;
|
|
379
|
+
}).join("")}
|
|
380
|
+
</ul>
|
|
381
|
+
</section>
|
|
382
|
+
`;
|
|
354
383
|
}
|
|
355
384
|
});
|
|
356
385
|
}
|
|
@@ -360,22 +389,35 @@ var BarChartSlide = {
|
|
|
360
389
|
var DonutChartSlide = {
|
|
361
390
|
type: "donutChart",
|
|
362
391
|
fromJSON(raw) {
|
|
363
|
-
const segments =
|
|
364
|
-
|
|
392
|
+
const segments = [];
|
|
393
|
+
let current = null;
|
|
394
|
+
for (const d of raw.data || []) {
|
|
395
|
+
if (d.name === "percent") {
|
|
396
|
+
current = { percent: d.content };
|
|
397
|
+
segments.push(current);
|
|
398
|
+
} else if (current && d.name === "label") {
|
|
399
|
+
current.label = d.content;
|
|
400
|
+
} else if (current && d.name === "color") {
|
|
401
|
+
current.color = d.content;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!segments.length) {
|
|
365
405
|
throw new Error("donutChart: requires at least one segment");
|
|
366
406
|
}
|
|
367
407
|
return Object.freeze({
|
|
368
408
|
type: "donutChart",
|
|
369
|
-
|
|
409
|
+
segments,
|
|
410
|
+
render({ visibleCount = segments.length } = {}) {
|
|
370
411
|
return `
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
</
|
|
378
|
-
|
|
412
|
+
<section class="slide donutChart">
|
|
413
|
+
<ul>
|
|
414
|
+
${segments.map((s, i) => {
|
|
415
|
+
if (i >= visibleCount) return "";
|
|
416
|
+
return `<li>${s.label}: ${s.percent}%</li>`;
|
|
417
|
+
}).join("")}
|
|
418
|
+
</ul>
|
|
419
|
+
</section>
|
|
420
|
+
`;
|
|
379
421
|
}
|
|
380
422
|
});
|
|
381
423
|
}
|
|
@@ -385,18 +427,22 @@ var DonutChartSlide = {
|
|
|
385
427
|
var QuoteSlide = {
|
|
386
428
|
type: "quoteSlide",
|
|
387
429
|
fromJSON(raw) {
|
|
388
|
-
const
|
|
430
|
+
const quote = raw.data?.find((d) => d.name === "quote")?.content;
|
|
389
431
|
const author = raw.data?.find((d) => d.name === "author")?.content;
|
|
390
|
-
if (!
|
|
432
|
+
if (!quote) {
|
|
433
|
+
throw new Error("quoteSlide: quote required");
|
|
434
|
+
}
|
|
391
435
|
return Object.freeze({
|
|
392
436
|
type: "quoteSlide",
|
|
437
|
+
quote,
|
|
438
|
+
author,
|
|
393
439
|
render() {
|
|
394
440
|
return `
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
441
|
+
<blockquote class="slide quoteSlide">
|
|
442
|
+
<p>${quote}</p>
|
|
443
|
+
${author ? `<footer>${author}</footer>` : ""}
|
|
444
|
+
</blockquote>
|
|
445
|
+
`;
|
|
400
446
|
}
|
|
401
447
|
});
|
|
402
448
|
}
|
|
@@ -414,16 +460,19 @@ var QuoteWithImageSlide = {
|
|
|
414
460
|
}
|
|
415
461
|
return Object.freeze({
|
|
416
462
|
type: "quoteWithImage",
|
|
463
|
+
quote,
|
|
464
|
+
image,
|
|
465
|
+
author,
|
|
417
466
|
render() {
|
|
418
467
|
return `
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
468
|
+
<section class="slide quoteWithImage">
|
|
469
|
+
<img src="${image}" alt="" />
|
|
470
|
+
<blockquote>
|
|
471
|
+
<p>${quote}</p>
|
|
472
|
+
${author ? `<footer>${author}</footer>` : ""}
|
|
473
|
+
</blockquote>
|
|
474
|
+
</section>
|
|
475
|
+
`;
|
|
427
476
|
}
|
|
428
477
|
});
|
|
429
478
|
}
|
|
@@ -433,20 +482,27 @@ var QuoteWithImageSlide = {
|
|
|
433
482
|
var CornerWordsSlide = {
|
|
434
483
|
type: "cornerWordsSlide",
|
|
435
484
|
fromJSON(raw) {
|
|
436
|
-
const
|
|
437
|
-
if (!
|
|
438
|
-
throw new Error("cornerWordsSlide: requires at least one
|
|
485
|
+
const cards = raw.data?.filter((d) => d.name === "card").map((d) => ({ icon: d.icon, label: d.label }));
|
|
486
|
+
if (!cards || cards.length === 0) {
|
|
487
|
+
throw new Error("cornerWordsSlide: requires at least one card");
|
|
439
488
|
}
|
|
440
489
|
return Object.freeze({
|
|
441
490
|
type: "cornerWordsSlide",
|
|
442
|
-
|
|
491
|
+
cards,
|
|
492
|
+
render({ visibleCount = cards.length } = {}) {
|
|
443
493
|
return `
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
494
|
+
<section class="slide cornerWordsSlide">
|
|
495
|
+
${cards.map((c, i) => {
|
|
496
|
+
if (i >= visibleCount) return "";
|
|
497
|
+
return `
|
|
498
|
+
<span class="corner-card corner-${i + 1}">
|
|
499
|
+
<span class="icon">${c.icon}</span>
|
|
500
|
+
<span class="label">${c.label}</span>
|
|
501
|
+
</span>
|
|
502
|
+
`;
|
|
503
|
+
}).join("")}
|
|
504
|
+
</section>
|
|
505
|
+
`;
|
|
450
506
|
}
|
|
451
507
|
});
|
|
452
508
|
}
|
|
@@ -456,16 +512,19 @@ var CornerWordsSlide = {
|
|
|
456
512
|
var ContactSlide = {
|
|
457
513
|
type: "contactSlide",
|
|
458
514
|
fromJSON(raw) {
|
|
459
|
-
const items = raw.data?.map((d) =>
|
|
460
|
-
if (!items
|
|
515
|
+
const items = raw.data?.map((d) => d.content);
|
|
516
|
+
if (!items || items.length === 0) {
|
|
517
|
+
throw new Error("contactSlide: content required");
|
|
518
|
+
}
|
|
461
519
|
return Object.freeze({
|
|
462
520
|
type: "contactSlide",
|
|
521
|
+
items,
|
|
463
522
|
render() {
|
|
464
523
|
return `
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
524
|
+
<section class="slide contactSlide">
|
|
525
|
+
${items.map((text) => `<div>${text}</div>`).join("")}
|
|
526
|
+
</section>
|
|
527
|
+
`;
|
|
469
528
|
}
|
|
470
529
|
});
|
|
471
530
|
}
|
|
@@ -475,43 +534,33 @@ var ContactSlide = {
|
|
|
475
534
|
var EqSlide = {
|
|
476
535
|
type: "eq",
|
|
477
536
|
fromJSON(raw) {
|
|
478
|
-
|
|
479
|
-
|
|
537
|
+
const lines = raw.data?.filter((d) => d.name === "line").map((d) => ({
|
|
538
|
+
type: d.type,
|
|
539
|
+
content: d.content
|
|
540
|
+
}));
|
|
541
|
+
if (!lines || lines.length === 0) {
|
|
542
|
+
throw new Error("eq: requires at least one line");
|
|
480
543
|
}
|
|
481
544
|
return Object.freeze({
|
|
482
545
|
type: "eq",
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
<section class="slide eq">
|
|
486
|
-
${raw.data.map((d) => `<div>${d.content}</div>`).join("")}
|
|
487
|
-
</section>
|
|
488
|
-
`;
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
// node_modules/taleem-slides/src/slides/SvgPointerSlide.js
|
|
495
|
-
var SvgPointerSlide = {
|
|
496
|
-
type: "svgPointer",
|
|
497
|
-
fromJSON(raw) {
|
|
498
|
-
const svg = raw.data?.find((d) => d.name === "svg")?.content;
|
|
499
|
-
if (!svg) throw new Error("svgPointer: svg required");
|
|
500
|
-
return Object.freeze({
|
|
501
|
-
type: "svgPointer",
|
|
502
|
-
render() {
|
|
546
|
+
lines,
|
|
547
|
+
render({ visibleCount = lines.length, activeIndex = null } = {}) {
|
|
503
548
|
return `
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
549
|
+
<section class="slide eq">
|
|
550
|
+
${lines.map((l, i) => {
|
|
551
|
+
if (i >= visibleCount) return "";
|
|
552
|
+
const cls = i === activeIndex ? "is-active" : activeIndex !== null && i < activeIndex ? "is-dim" : "";
|
|
553
|
+
return `<div class="eq-line ${cls}">${l.content}</div>`;
|
|
554
|
+
}).join("")}
|
|
555
|
+
</section>
|
|
556
|
+
`;
|
|
508
557
|
}
|
|
509
558
|
});
|
|
510
559
|
}
|
|
511
560
|
};
|
|
512
561
|
|
|
513
|
-
// node_modules/taleem-slides/src/
|
|
514
|
-
var
|
|
562
|
+
// node_modules/taleem-slides/src/SlideTemplates.js
|
|
563
|
+
var SlideTemplates = {
|
|
515
564
|
titleSlide: TitleSlide,
|
|
516
565
|
titleAndSubtitle: TitleAndSubtitleSlide,
|
|
517
566
|
titleAndPara: TitleAndParaSlide,
|
|
@@ -532,114 +581,30 @@ var registry = {
|
|
|
532
581
|
quoteWithImage: QuoteWithImageSlide,
|
|
533
582
|
cornerWordsSlide: CornerWordsSlide,
|
|
534
583
|
contactSlide: ContactSlide,
|
|
535
|
-
eq: EqSlide
|
|
536
|
-
svgPointer: SvgPointerSlide
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
// node_modules/taleem-slides/src/slideManager/SlideManager.js
|
|
540
|
-
var SlideManager = class {
|
|
541
|
-
#slides;
|
|
542
|
-
constructor(slides) {
|
|
543
|
-
if (!Array.isArray(slides)) {
|
|
544
|
-
throw new Error("SlideManager: slides must be an array");
|
|
545
|
-
}
|
|
546
|
-
this.#slides = slides;
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Render a single slide by index.
|
|
550
|
-
*
|
|
551
|
-
* @param {number} index
|
|
552
|
-
* @param {number} [showAt]
|
|
553
|
-
* @returns {string} HTML
|
|
554
|
-
*/
|
|
555
|
-
renderSlide(index, showAt) {
|
|
556
|
-
const slide = this.#slides[index];
|
|
557
|
-
if (!slide) {
|
|
558
|
-
throw new Error(`SlideManager: invalid slide index ${index}`);
|
|
559
|
-
}
|
|
560
|
-
if (typeof slide.render !== "function") {
|
|
561
|
-
throw new Error(
|
|
562
|
-
`SlideManager: slide at index ${index} has no render() method`
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
return slide.render(showAt);
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Render all slides as a static HTML dump.
|
|
569
|
-
*
|
|
570
|
-
* @returns {string} HTML
|
|
571
|
-
*/
|
|
572
|
-
renderAll() {
|
|
573
|
-
return this.#slides.map((slide, index) => {
|
|
574
|
-
if (typeof slide.render !== "function") {
|
|
575
|
-
throw new Error(
|
|
576
|
-
`SlideManager: slide at index ${index} has no render() method`
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
return slide.render();
|
|
580
|
-
}).join("\n");
|
|
581
|
-
}
|
|
584
|
+
eq: EqSlide
|
|
582
585
|
};
|
|
583
586
|
|
|
584
|
-
// node_modules/taleem-slides/src/
|
|
585
|
-
function
|
|
586
|
-
|
|
587
|
-
|
|
587
|
+
// node_modules/taleem-slides/src/getSlideTemplate.js
|
|
588
|
+
function getSlideTemplate(type) {
|
|
589
|
+
const template = SlideTemplates[type];
|
|
590
|
+
if (!template) {
|
|
591
|
+
throw new Error(`Unknown slide template type "${type}"`);
|
|
588
592
|
}
|
|
589
|
-
|
|
590
|
-
throw new Error(
|
|
591
|
-
`slideBuilder: unsupported deck version "${deckV1Json.version}"`
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
if (!Array.isArray(deckV1Json.deck)) {
|
|
595
|
-
throw new Error("slideBuilder: deck must be an array");
|
|
596
|
-
}
|
|
597
|
-
const slides = deckV1Json.deck.map((rawSlide, index) => {
|
|
598
|
-
if (!rawSlide || typeof rawSlide !== "object") {
|
|
599
|
-
throw new Error(`slideBuilder: slide ${index} is not an object`);
|
|
600
|
-
}
|
|
601
|
-
const { type } = rawSlide;
|
|
602
|
-
if (!type || typeof type !== "string") {
|
|
603
|
-
throw new Error(`slideBuilder: slide ${index} has no valid type`);
|
|
604
|
-
}
|
|
605
|
-
const builder = registry[type];
|
|
606
|
-
if (!builder) {
|
|
607
|
-
throw new Error(
|
|
608
|
-
`slideBuilder: unsupported slide type "${type}" at index ${index}`
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
try {
|
|
612
|
-
return builder.fromJSON(rawSlide, index);
|
|
613
|
-
} catch (err) {
|
|
614
|
-
throw new Error(
|
|
615
|
-
`slideBuilder: failed to build slide "${type}" at index ${index}
|
|
616
|
-
${err.message}`
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
slides.forEach(Object.freeze);
|
|
621
|
-
Object.freeze(slides);
|
|
622
|
-
return new SlideManager(slides);
|
|
593
|
+
return template;
|
|
623
594
|
}
|
|
624
595
|
|
|
625
|
-
// src/
|
|
626
|
-
var TALEEM_BROWSER_VERSION = "0.1.3";
|
|
627
|
-
var TALEEM_CSS_URL = "https://github.com/bilza2023/taleem-browser/releases/download/v0.1.3/taleem.css";
|
|
628
|
-
|
|
629
|
-
// src/index.js
|
|
596
|
+
// src/createBrowser.js
|
|
630
597
|
function createTaleemBrowser({ mount, deck }) {
|
|
631
598
|
if (!mount) {
|
|
632
599
|
throw new Error("taleem-browser: mount is required");
|
|
633
600
|
}
|
|
634
601
|
if (!deck || !Array.isArray(deck.deck)) {
|
|
635
|
-
throw new Error("taleem-browser: valid deck
|
|
602
|
+
throw new Error("taleem-browser: valid deck-v1 required");
|
|
636
603
|
}
|
|
637
604
|
const root = typeof mount === "string" ? document.querySelector(mount) : mount;
|
|
638
605
|
if (!root) {
|
|
639
|
-
throw new Error("taleem-browser: mount
|
|
606
|
+
throw new Error("taleem-browser: mount not found");
|
|
640
607
|
}
|
|
641
|
-
let currentIndex = 0;
|
|
642
|
-
const total = deck.deck.length;
|
|
643
608
|
root.innerHTML = `
|
|
644
609
|
<div class="taleem-browser-bg"></div>
|
|
645
610
|
<div class="taleem-browser-slide"></div>
|
|
@@ -647,45 +612,27 @@ function createTaleemBrowser({ mount, deck }) {
|
|
|
647
612
|
const bgEl = root.querySelector(".taleem-browser-bg");
|
|
648
613
|
const slideEl = root.querySelector(".taleem-browser-slide");
|
|
649
614
|
applyBackground(bgEl, deck.background);
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
function next() {
|
|
655
|
-
if (currentIndex < total - 1) {
|
|
656
|
-
currentIndex++;
|
|
657
|
-
render();
|
|
615
|
+
const slides = deck.deck.map((slideJSON, i) => {
|
|
616
|
+
if (!slideJSON.type) {
|
|
617
|
+
throw new Error(`taleem-browser: slide ${i} missing type`);
|
|
658
618
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
currentIndex--;
|
|
663
|
-
render();
|
|
619
|
+
const Template = getSlideTemplate(slideJSON.type);
|
|
620
|
+
if (!Template) {
|
|
621
|
+
throw new Error(`taleem-browser: unknown slide type "${slideJSON.type}"`);
|
|
664
622
|
}
|
|
665
|
-
|
|
666
|
-
|
|
623
|
+
return Template.fromJSON(slideJSON);
|
|
624
|
+
});
|
|
625
|
+
const total = slides.length;
|
|
626
|
+
function render(index, renderState = {}) {
|
|
667
627
|
if (index < 0 || index >= total) return;
|
|
668
|
-
|
|
669
|
-
render();
|
|
628
|
+
const slide = slides[index];
|
|
629
|
+
slideEl.innerHTML = slide.render(renderState);
|
|
670
630
|
}
|
|
671
|
-
function getIndex() {
|
|
672
|
-
return currentIndex;
|
|
673
|
-
}
|
|
674
|
-
function getTotal() {
|
|
675
|
-
return total;
|
|
676
|
-
}
|
|
677
|
-
function destroy() {
|
|
678
|
-
root.innerHTML = "";
|
|
679
|
-
}
|
|
680
|
-
render();
|
|
681
631
|
return {
|
|
682
|
-
next,
|
|
683
|
-
prev,
|
|
684
|
-
goTo,
|
|
685
|
-
getIndex,
|
|
686
|
-
getTotal,
|
|
687
632
|
render,
|
|
688
|
-
|
|
633
|
+
getTotal() {
|
|
634
|
+
return total;
|
|
635
|
+
}
|
|
689
636
|
};
|
|
690
637
|
}
|
|
691
638
|
function applyBackground(el, bg = {}) {
|
|
@@ -699,7 +646,5 @@ function applyBackground(el, bg = {}) {
|
|
|
699
646
|
el.style.opacity = bg.backgroundImageOpacity !== void 0 ? bg.backgroundImageOpacity : 1;
|
|
700
647
|
}
|
|
701
648
|
export {
|
|
702
|
-
TALEEM_BROWSER_VERSION,
|
|
703
|
-
TALEEM_CSS_URL,
|
|
704
649
|
createTaleemBrowser
|
|
705
650
|
};
|