@africode/core 5.0.1 → 5.0.2
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/COMPONENT_SCHEMA.json +103 -69
- package/components/base.d.ts +1 -1
- package/components/base.js +71 -21
- package/core/a2ui-schema-manager.js +9 -2
- package/core/a2ui.js +131 -43
- package/core/actions.js +27 -0
- package/core/bun-runtime.js +207 -724
- package/core/compliance.js +6 -5
- package/core/config.js +7 -5
- package/core/enhanced-hmr.js +16 -14
- package/core/file-router.js +42 -282
- package/core/hmr.js +8 -7
- package/core/html.d.ts +15 -101
- package/core/html.js +53 -129
- package/core/lipa-namba-journey.js +74 -12
- package/core/logging.js +14 -0
- package/core/middleware.js +82 -0
- package/core/nida-cig-middleware.js +13 -8
- package/core/plugins/index.js +345 -312
- package/core/request-identity.js +44 -0
- package/core/sdk.js +22 -0
- package/core/session-store.js +68 -0
- package/core/state.js +34 -0
- package/core/websocket.js +22 -20
- package/dist/africode.js +108 -112
- package/dist/africode.js.map +6 -6
- package/dist/build-info.json +3 -3
- package/dist/components.js +351 -351
- package/dist/components.js.map +6 -6
- package/package.json +3 -3
- package/scripts/generate-component-schema.js +1 -1
package/COMPONENT_SCHEMA.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "5.0.0",
|
|
3
|
-
"timestamp": "2026-05-
|
|
3
|
+
"timestamp": "2026-05-03T12:18:29.985Z",
|
|
4
4
|
"components": [
|
|
5
5
|
{
|
|
6
|
-
"tagName": "af-
|
|
6
|
+
"tagName": "af-accordion",
|
|
7
|
+
"className": "AfriAccordion",
|
|
7
8
|
"filePath": "components\\accordion.js",
|
|
8
9
|
"slots": [
|
|
9
10
|
"default"
|
|
@@ -18,11 +19,12 @@
|
|
|
18
19
|
},
|
|
19
20
|
"events": [],
|
|
20
21
|
"cssCustomProperties": [],
|
|
21
|
-
"example": "<af-
|
|
22
|
+
"example": "<af-accordion></af-accordion>",
|
|
22
23
|
"securityNotes": "Sanitizes slot content"
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
|
-
"tagName": "af-
|
|
26
|
+
"tagName": "af-alert",
|
|
27
|
+
"className": "AfriAlert",
|
|
26
28
|
"filePath": "components\\alert.js",
|
|
27
29
|
"slots": [
|
|
28
30
|
"default"
|
|
@@ -40,11 +42,12 @@
|
|
|
40
42
|
},
|
|
41
43
|
"events": [],
|
|
42
44
|
"cssCustomProperties": [],
|
|
43
|
-
"example": "<af-
|
|
45
|
+
"example": "<af-alert></af-alert>",
|
|
44
46
|
"securityNotes": "Sanitizes slot content"
|
|
45
47
|
},
|
|
46
48
|
{
|
|
47
|
-
"tagName": "af-
|
|
49
|
+
"tagName": "af-auth",
|
|
50
|
+
"className": "AfriAuth",
|
|
48
51
|
"filePath": "components\\auth.js",
|
|
49
52
|
"slots": [
|
|
50
53
|
"default"
|
|
@@ -52,11 +55,12 @@
|
|
|
52
55
|
"attributes": {},
|
|
53
56
|
"events": [],
|
|
54
57
|
"cssCustomProperties": [],
|
|
55
|
-
"example": "<af-
|
|
58
|
+
"example": "<af-auth></af-auth>",
|
|
56
59
|
"securityNotes": "Sanitizes slot content"
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
|
-
"tagName": "af-
|
|
62
|
+
"tagName": "af-avatar",
|
|
63
|
+
"className": "AfriAvatar",
|
|
60
64
|
"filePath": "components\\avatar.js",
|
|
61
65
|
"slots": [
|
|
62
66
|
"default"
|
|
@@ -80,11 +84,12 @@
|
|
|
80
84
|
},
|
|
81
85
|
"events": [],
|
|
82
86
|
"cssCustomProperties": [],
|
|
83
|
-
"example": "<af-
|
|
87
|
+
"example": "<af-avatar></af-avatar>",
|
|
84
88
|
"securityNotes": "Sanitizes slot content"
|
|
85
89
|
},
|
|
86
90
|
{
|
|
87
|
-
"tagName": "af-
|
|
91
|
+
"tagName": "af-badge",
|
|
92
|
+
"className": "AfriBadge",
|
|
88
93
|
"filePath": "components\\badge.js",
|
|
89
94
|
"slots": [
|
|
90
95
|
"default"
|
|
@@ -102,11 +107,12 @@
|
|
|
102
107
|
},
|
|
103
108
|
"events": [],
|
|
104
109
|
"cssCustomProperties": [],
|
|
105
|
-
"example": "<af-
|
|
110
|
+
"example": "<af-badge></af-badge>",
|
|
106
111
|
"securityNotes": "Sanitizes slot content"
|
|
107
112
|
},
|
|
108
113
|
{
|
|
109
|
-
"tagName": "af-
|
|
114
|
+
"tagName": "af-button",
|
|
115
|
+
"className": "AfriButton",
|
|
110
116
|
"filePath": "components\\button.js",
|
|
111
117
|
"slots": [
|
|
112
118
|
"default"
|
|
@@ -143,11 +149,12 @@
|
|
|
143
149
|
}
|
|
144
150
|
],
|
|
145
151
|
"cssCustomProperties": [],
|
|
146
|
-
"example": "<af-
|
|
152
|
+
"example": "<af-button></af-button>",
|
|
147
153
|
"securityNotes": "Sanitizes slot content"
|
|
148
154
|
},
|
|
149
155
|
{
|
|
150
|
-
"tagName": "af-
|
|
156
|
+
"tagName": "af-card",
|
|
157
|
+
"className": "AfriCard",
|
|
151
158
|
"filePath": "components\\card.js",
|
|
152
159
|
"slots": [
|
|
153
160
|
"default"
|
|
@@ -168,11 +175,12 @@
|
|
|
168
175
|
},
|
|
169
176
|
"events": [],
|
|
170
177
|
"cssCustomProperties": [],
|
|
171
|
-
"example": "<af-
|
|
178
|
+
"example": "<af-card></af-card>",
|
|
172
179
|
"securityNotes": "Sanitizes slot content"
|
|
173
180
|
},
|
|
174
181
|
{
|
|
175
|
-
"tagName": "af-
|
|
182
|
+
"tagName": "af-cultural-card",
|
|
183
|
+
"className": "CulturalCard",
|
|
176
184
|
"filePath": "components\\cultural-card.js",
|
|
177
185
|
"slots": [
|
|
178
186
|
"default"
|
|
@@ -187,11 +195,12 @@
|
|
|
187
195
|
},
|
|
188
196
|
"events": [],
|
|
189
197
|
"cssCustomProperties": [],
|
|
190
|
-
"example": "<af-
|
|
198
|
+
"example": "<af-cultural-card></af-cultural-card>",
|
|
191
199
|
"securityNotes": "Sanitizes slot content"
|
|
192
200
|
},
|
|
193
201
|
{
|
|
194
|
-
"tagName": "af-
|
|
202
|
+
"tagName": "af-divider",
|
|
203
|
+
"className": "AfriDivider",
|
|
195
204
|
"filePath": "components\\divider.js",
|
|
196
205
|
"slots": [
|
|
197
206
|
"default"
|
|
@@ -212,11 +221,12 @@
|
|
|
212
221
|
},
|
|
213
222
|
"events": [],
|
|
214
223
|
"cssCustomProperties": [],
|
|
215
|
-
"example": "<af-
|
|
224
|
+
"example": "<af-divider></af-divider>",
|
|
216
225
|
"securityNotes": "Sanitizes slot content"
|
|
217
226
|
},
|
|
218
227
|
{
|
|
219
|
-
"tagName": "af-
|
|
228
|
+
"tagName": "af-dropdown",
|
|
229
|
+
"className": "AfriDropdown",
|
|
220
230
|
"filePath": "components\\dropdown.js",
|
|
221
231
|
"slots": [
|
|
222
232
|
"default"
|
|
@@ -231,11 +241,12 @@
|
|
|
231
241
|
},
|
|
232
242
|
"events": [],
|
|
233
243
|
"cssCustomProperties": [],
|
|
234
|
-
"example": "<af-
|
|
244
|
+
"example": "<af-dropdown></af-dropdown>",
|
|
235
245
|
"securityNotes": "Sanitizes slot content"
|
|
236
246
|
},
|
|
237
247
|
{
|
|
238
|
-
"tagName": "af-
|
|
248
|
+
"tagName": "af-error-boundary",
|
|
249
|
+
"className": "AfriErrorBoundary",
|
|
239
250
|
"filePath": "components\\error-boundary.js",
|
|
240
251
|
"slots": [
|
|
241
252
|
"default"
|
|
@@ -250,11 +261,12 @@
|
|
|
250
261
|
},
|
|
251
262
|
"events": [],
|
|
252
263
|
"cssCustomProperties": [],
|
|
253
|
-
"example": "<af-
|
|
264
|
+
"example": "<af-error-boundary></af-error-boundary>",
|
|
254
265
|
"securityNotes": "Sanitizes slot content"
|
|
255
266
|
},
|
|
256
267
|
{
|
|
257
|
-
"tagName": "af-
|
|
268
|
+
"tagName": "af-form",
|
|
269
|
+
"className": "AfriForm",
|
|
258
270
|
"filePath": "components\\form.js",
|
|
259
271
|
"slots": [
|
|
260
272
|
"default"
|
|
@@ -278,11 +290,12 @@
|
|
|
278
290
|
},
|
|
279
291
|
"events": [],
|
|
280
292
|
"cssCustomProperties": [],
|
|
281
|
-
"example": "<af-
|
|
293
|
+
"example": "<af-form></af-form>",
|
|
282
294
|
"securityNotes": "Sanitizes slot content"
|
|
283
295
|
},
|
|
284
296
|
{
|
|
285
|
-
"tagName": "af-
|
|
297
|
+
"tagName": "af-grid",
|
|
298
|
+
"className": "AfriGrid",
|
|
286
299
|
"filePath": "components\\grid.js",
|
|
287
300
|
"slots": [
|
|
288
301
|
"default"
|
|
@@ -324,11 +337,12 @@
|
|
|
324
337
|
},
|
|
325
338
|
"events": [],
|
|
326
339
|
"cssCustomProperties": [],
|
|
327
|
-
"example": "<af-
|
|
340
|
+
"example": "<af-grid></af-grid>",
|
|
328
341
|
"securityNotes": "Sanitizes slot content"
|
|
329
342
|
},
|
|
330
343
|
{
|
|
331
|
-
"tagName": "af-
|
|
344
|
+
"tagName": "af-hero",
|
|
345
|
+
"className": "AfriHero",
|
|
332
346
|
"filePath": "components\\hero.js",
|
|
333
347
|
"slots": [
|
|
334
348
|
"default"
|
|
@@ -349,11 +363,12 @@
|
|
|
349
363
|
},
|
|
350
364
|
"events": [],
|
|
351
365
|
"cssCustomProperties": [],
|
|
352
|
-
"example": "<af-
|
|
366
|
+
"example": "<af-hero></af-hero>",
|
|
353
367
|
"securityNotes": "Sanitizes slot content"
|
|
354
368
|
},
|
|
355
369
|
{
|
|
356
|
-
"tagName": "af-
|
|
370
|
+
"tagName": "af-icon",
|
|
371
|
+
"className": "AfriIcon",
|
|
357
372
|
"filePath": "components\\icon.js",
|
|
358
373
|
"slots": [
|
|
359
374
|
"default"
|
|
@@ -368,11 +383,12 @@
|
|
|
368
383
|
},
|
|
369
384
|
"events": [],
|
|
370
385
|
"cssCustomProperties": [],
|
|
371
|
-
"example": "<af-
|
|
386
|
+
"example": "<af-icon></af-icon>",
|
|
372
387
|
"securityNotes": "Sanitizes slot content"
|
|
373
388
|
},
|
|
374
389
|
{
|
|
375
|
-
"tagName": "af-
|
|
390
|
+
"tagName": "af-input",
|
|
391
|
+
"className": "AfriInput",
|
|
376
392
|
"filePath": "components\\input.js",
|
|
377
393
|
"slots": [
|
|
378
394
|
"default"
|
|
@@ -417,11 +433,12 @@
|
|
|
417
433
|
},
|
|
418
434
|
"events": [],
|
|
419
435
|
"cssCustomProperties": [],
|
|
420
|
-
"example": "<af-
|
|
436
|
+
"example": "<af-input></af-input>",
|
|
421
437
|
"securityNotes": "Sanitizes slot content"
|
|
422
438
|
},
|
|
423
439
|
{
|
|
424
|
-
"tagName": "af-
|
|
440
|
+
"tagName": "af-kanga-card",
|
|
441
|
+
"className": "KangaCard",
|
|
425
442
|
"filePath": "components\\kanga-card.js",
|
|
426
443
|
"slots": [
|
|
427
444
|
"default"
|
|
@@ -439,11 +456,12 @@
|
|
|
439
456
|
},
|
|
440
457
|
"events": [],
|
|
441
458
|
"cssCustomProperties": [],
|
|
442
|
-
"example": "<af-
|
|
459
|
+
"example": "<af-kanga-card></af-kanga-card>",
|
|
443
460
|
"securityNotes": "Sanitizes slot content"
|
|
444
461
|
},
|
|
445
462
|
{
|
|
446
|
-
"tagName": "af-
|
|
463
|
+
"tagName": "af-language-switcher",
|
|
464
|
+
"className": "AfriLanguageSwitcher",
|
|
447
465
|
"filePath": "components\\language-switcher.js",
|
|
448
466
|
"slots": [
|
|
449
467
|
"default"
|
|
@@ -455,11 +473,12 @@
|
|
|
455
473
|
},
|
|
456
474
|
"events": [],
|
|
457
475
|
"cssCustomProperties": [],
|
|
458
|
-
"example": "<af-
|
|
476
|
+
"example": "<af-language-switcher></af-language-switcher>",
|
|
459
477
|
"securityNotes": "Sanitizes slot content"
|
|
460
478
|
},
|
|
461
479
|
{
|
|
462
|
-
"tagName": "af-
|
|
480
|
+
"tagName": "af-loader",
|
|
481
|
+
"className": "AfriLoader",
|
|
463
482
|
"filePath": "components\\loader.js",
|
|
464
483
|
"slots": [
|
|
465
484
|
"default"
|
|
@@ -477,11 +496,12 @@
|
|
|
477
496
|
},
|
|
478
497
|
"events": [],
|
|
479
498
|
"cssCustomProperties": [],
|
|
480
|
-
"example": "<af-
|
|
499
|
+
"example": "<af-loader></af-loader>",
|
|
481
500
|
"securityNotes": "Sanitizes slot content"
|
|
482
501
|
},
|
|
483
502
|
{
|
|
484
|
-
"tagName": "af-
|
|
503
|
+
"tagName": "af-modal",
|
|
504
|
+
"className": "AfriModal",
|
|
485
505
|
"filePath": "components\\modal.js",
|
|
486
506
|
"slots": [
|
|
487
507
|
"default"
|
|
@@ -505,11 +525,12 @@
|
|
|
505
525
|
},
|
|
506
526
|
"events": [],
|
|
507
527
|
"cssCustomProperties": [],
|
|
508
|
-
"example": "<af-
|
|
528
|
+
"example": "<af-modal></af-modal>",
|
|
509
529
|
"securityNotes": "Sanitizes slot content"
|
|
510
530
|
},
|
|
511
531
|
{
|
|
512
|
-
"tagName": "af-
|
|
532
|
+
"tagName": "af-motion",
|
|
533
|
+
"className": "MotionComponent",
|
|
513
534
|
"filePath": "components\\motion.js",
|
|
514
535
|
"slots": [
|
|
515
536
|
"default"
|
|
@@ -524,11 +545,12 @@
|
|
|
524
545
|
},
|
|
525
546
|
"events": [],
|
|
526
547
|
"cssCustomProperties": [],
|
|
527
|
-
"example": "<af-
|
|
548
|
+
"example": "<af-motion></af-motion>",
|
|
528
549
|
"securityNotes": "Sanitizes slot content"
|
|
529
550
|
},
|
|
530
551
|
{
|
|
531
|
-
"tagName": "af-
|
|
552
|
+
"tagName": "af-navbar",
|
|
553
|
+
"className": "AfriNavbar",
|
|
532
554
|
"filePath": "components\\navbar.js",
|
|
533
555
|
"slots": [
|
|
534
556
|
"default"
|
|
@@ -546,11 +568,12 @@
|
|
|
546
568
|
},
|
|
547
569
|
"events": [],
|
|
548
570
|
"cssCustomProperties": [],
|
|
549
|
-
"example": "<af-
|
|
571
|
+
"example": "<af-navbar></af-navbar>",
|
|
550
572
|
"securityNotes": "Sanitizes slot content"
|
|
551
573
|
},
|
|
552
574
|
{
|
|
553
|
-
"tagName": "af-
|
|
575
|
+
"tagName": "af-pattern-showcase",
|
|
576
|
+
"className": "PatternShowcase",
|
|
554
577
|
"filePath": "components\\pattern-showcase.js",
|
|
555
578
|
"slots": [
|
|
556
579
|
"default"
|
|
@@ -565,11 +588,12 @@
|
|
|
565
588
|
},
|
|
566
589
|
"events": [],
|
|
567
590
|
"cssCustomProperties": [],
|
|
568
|
-
"example": "<af-
|
|
591
|
+
"example": "<af-pattern-showcase></af-pattern-showcase>",
|
|
569
592
|
"securityNotes": "Sanitizes slot content"
|
|
570
593
|
},
|
|
571
594
|
{
|
|
572
|
-
"tagName": "af-
|
|
595
|
+
"tagName": "af-progress",
|
|
596
|
+
"className": "AfriProgress",
|
|
573
597
|
"filePath": "components\\progress.js",
|
|
574
598
|
"slots": [
|
|
575
599
|
"default"
|
|
@@ -596,11 +620,12 @@
|
|
|
596
620
|
},
|
|
597
621
|
"events": [],
|
|
598
622
|
"cssCustomProperties": [],
|
|
599
|
-
"example": "<af-
|
|
623
|
+
"example": "<af-progress></af-progress>",
|
|
600
624
|
"securityNotes": "Sanitizes slot content"
|
|
601
625
|
},
|
|
602
626
|
{
|
|
603
|
-
"tagName": "af-
|
|
627
|
+
"tagName": "af-react",
|
|
628
|
+
"className": "AfriReact",
|
|
604
629
|
"filePath": "components\\react.js",
|
|
605
630
|
"slots": [
|
|
606
631
|
"default"
|
|
@@ -612,11 +637,12 @@
|
|
|
612
637
|
},
|
|
613
638
|
"events": [],
|
|
614
639
|
"cssCustomProperties": [],
|
|
615
|
-
"example": "<af-
|
|
640
|
+
"example": "<af-react></af-react>",
|
|
616
641
|
"securityNotes": "Sanitizes slot content"
|
|
617
642
|
},
|
|
618
643
|
{
|
|
619
|
-
"tagName": "af-
|
|
644
|
+
"tagName": "af-section",
|
|
645
|
+
"className": "AfriSection",
|
|
620
646
|
"filePath": "components\\section.js",
|
|
621
647
|
"slots": [
|
|
622
648
|
"default"
|
|
@@ -624,11 +650,12 @@
|
|
|
624
650
|
"attributes": {},
|
|
625
651
|
"events": [],
|
|
626
652
|
"cssCustomProperties": [],
|
|
627
|
-
"example": "<af-
|
|
653
|
+
"example": "<af-section></af-section>",
|
|
628
654
|
"securityNotes": "Sanitizes slot content"
|
|
629
655
|
},
|
|
630
656
|
{
|
|
631
|
-
"tagName": "af-
|
|
657
|
+
"tagName": "af-select",
|
|
658
|
+
"className": "AfriSelect",
|
|
632
659
|
"filePath": "components\\select.js",
|
|
633
660
|
"slots": [
|
|
634
661
|
"default"
|
|
@@ -658,11 +685,12 @@
|
|
|
658
685
|
},
|
|
659
686
|
"events": [],
|
|
660
687
|
"cssCustomProperties": [],
|
|
661
|
-
"example": "<af-
|
|
688
|
+
"example": "<af-select></af-select>",
|
|
662
689
|
"securityNotes": "Sanitizes slot content"
|
|
663
690
|
},
|
|
664
691
|
{
|
|
665
|
-
"tagName": "af-
|
|
692
|
+
"tagName": "af-sidebar",
|
|
693
|
+
"className": "AfriSidebar",
|
|
666
694
|
"filePath": "components\\sidebar.js",
|
|
667
695
|
"slots": [
|
|
668
696
|
"default"
|
|
@@ -674,11 +702,12 @@
|
|
|
674
702
|
},
|
|
675
703
|
"events": [],
|
|
676
704
|
"cssCustomProperties": [],
|
|
677
|
-
"example": "<af-
|
|
705
|
+
"example": "<af-sidebar></af-sidebar>",
|
|
678
706
|
"securityNotes": "Sanitizes slot content"
|
|
679
707
|
},
|
|
680
708
|
{
|
|
681
|
-
"tagName": "af-
|
|
709
|
+
"tagName": "af-skeleton",
|
|
710
|
+
"className": "AfriSkeleton",
|
|
682
711
|
"filePath": "components\\skeleton.js",
|
|
683
712
|
"slots": [
|
|
684
713
|
"default"
|
|
@@ -699,11 +728,12 @@
|
|
|
699
728
|
},
|
|
700
729
|
"events": [],
|
|
701
730
|
"cssCustomProperties": [],
|
|
702
|
-
"example": "<af-
|
|
731
|
+
"example": "<af-skeleton></af-skeleton>",
|
|
703
732
|
"securityNotes": "Sanitizes slot content"
|
|
704
733
|
},
|
|
705
734
|
{
|
|
706
|
-
"tagName": "af-
|
|
735
|
+
"tagName": "af-table",
|
|
736
|
+
"className": "AfriTable",
|
|
707
737
|
"filePath": "components\\table.js",
|
|
708
738
|
"slots": [
|
|
709
739
|
"default"
|
|
@@ -721,11 +751,12 @@
|
|
|
721
751
|
},
|
|
722
752
|
"events": [],
|
|
723
753
|
"cssCustomProperties": [],
|
|
724
|
-
"example": "<af-
|
|
754
|
+
"example": "<af-table></af-table>",
|
|
725
755
|
"securityNotes": "Sanitizes slot content"
|
|
726
756
|
},
|
|
727
757
|
{
|
|
728
|
-
"tagName": "af-
|
|
758
|
+
"tagName": "af-tabs",
|
|
759
|
+
"className": "AfriTabs",
|
|
729
760
|
"filePath": "components\\tabs.js",
|
|
730
761
|
"slots": [
|
|
731
762
|
"default"
|
|
@@ -737,11 +768,12 @@
|
|
|
737
768
|
},
|
|
738
769
|
"events": [],
|
|
739
770
|
"cssCustomProperties": [],
|
|
740
|
-
"example": "<af-
|
|
771
|
+
"example": "<af-tabs></af-tabs>",
|
|
741
772
|
"securityNotes": "Sanitizes slot content"
|
|
742
773
|
},
|
|
743
774
|
{
|
|
744
|
-
"tagName": "af-
|
|
775
|
+
"tagName": "af-theme-toggle",
|
|
776
|
+
"className": "Theme-toggleComponent",
|
|
745
777
|
"filePath": "components\\theme-toggle.js",
|
|
746
778
|
"slots": [
|
|
747
779
|
"default"
|
|
@@ -749,11 +781,12 @@
|
|
|
749
781
|
"attributes": {},
|
|
750
782
|
"events": [],
|
|
751
783
|
"cssCustomProperties": [],
|
|
752
|
-
"example": "<af-
|
|
784
|
+
"example": "<af-theme-toggle></af-theme-toggle>",
|
|
753
785
|
"securityNotes": "Sanitizes slot content"
|
|
754
786
|
},
|
|
755
787
|
{
|
|
756
|
-
"tagName": "af-
|
|
788
|
+
"tagName": "af-toast",
|
|
789
|
+
"className": "AfriToast",
|
|
757
790
|
"filePath": "components\\toast.js",
|
|
758
791
|
"slots": [
|
|
759
792
|
"default"
|
|
@@ -771,11 +804,12 @@
|
|
|
771
804
|
},
|
|
772
805
|
"events": [],
|
|
773
806
|
"cssCustomProperties": [],
|
|
774
|
-
"example": "<af-
|
|
807
|
+
"example": "<af-toast></af-toast>",
|
|
775
808
|
"securityNotes": "Sanitizes slot content"
|
|
776
809
|
},
|
|
777
810
|
{
|
|
778
|
-
"tagName": "af-
|
|
811
|
+
"tagName": "af-tooltip",
|
|
812
|
+
"className": "AfriTooltip",
|
|
779
813
|
"filePath": "components\\tooltip.js",
|
|
780
814
|
"slots": [
|
|
781
815
|
"default"
|
|
@@ -790,7 +824,7 @@
|
|
|
790
824
|
},
|
|
791
825
|
"events": [],
|
|
792
826
|
"cssCustomProperties": [],
|
|
793
|
-
"example": "<af-
|
|
827
|
+
"example": "<af-tooltip></af-tooltip>",
|
|
794
828
|
"securityNotes": "Sanitizes slot content"
|
|
795
829
|
}
|
|
796
830
|
],
|
package/components/base.d.ts
CHANGED
package/components/base.js
CHANGED
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
import { html } from '../core/html.js';
|
|
11
11
|
|
|
12
|
+
const BaseHTMLElement = globalThis.HTMLElement ?? class {};
|
|
13
|
+
const hasConstructableStylesheets = typeof CSSStyleSheet !== 'undefined';
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* Base class for AfriCode components
|
|
14
17
|
* All components extend this to inherit common functionality
|
|
15
18
|
*/
|
|
16
|
-
export class AfriCodeComponent extends
|
|
19
|
+
export class AfriCodeComponent extends BaseHTMLElement {
|
|
17
20
|
constructor() {
|
|
18
21
|
super();
|
|
19
22
|
this.attachShadow({ mode: 'open' });
|
|
@@ -84,8 +87,11 @@ export class AfriCodeComponent extends HTMLElement {
|
|
|
84
87
|
* @param {CSSStyleSheet} sheet - A Constructable Stylesheet instance
|
|
85
88
|
*/
|
|
86
89
|
static injectGlobalSheet(sheet) {
|
|
90
|
+
if (!hasConstructableStylesheets) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
87
94
|
if (!(sheet instanceof CSSStyleSheet)) {
|
|
88
|
-
console.error('[AfriCode] injectGlobalSheet requires a CSSStyleSheet instance.');
|
|
89
95
|
return;
|
|
90
96
|
}
|
|
91
97
|
if (!AfriCodeComponent.globalSheets.includes(sheet)) {
|
|
@@ -98,37 +104,77 @@ export class AfriCodeComponent extends HTMLElement {
|
|
|
98
104
|
* Optimized to fetch only once per session.
|
|
99
105
|
* Also adopts any globally injected sheets (e.g. Tailwind utilities).
|
|
100
106
|
*/
|
|
101
|
-
async loadStyles() {
|
|
107
|
+
async loadStyles(css = '') {
|
|
102
108
|
const styleUrl = '/styles/africanity.css';
|
|
109
|
+
if (!this.shadowRoot) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const canAdoptStyleSheets = hasConstructableStylesheets && 'adoptedStyleSheets' in this.shadowRoot;
|
|
114
|
+
const sourceKey = typeof css === 'string' && css.length > 0 ? css : styleUrl;
|
|
115
|
+
const stylesheetText = typeof css === 'string' && css.length > 0 ? css : null;
|
|
103
116
|
|
|
104
117
|
// 1. Check cache first
|
|
105
|
-
if (AfriCodeComponent.styleCache.has(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
if (AfriCodeComponent.styleCache.has(sourceKey)) {
|
|
119
|
+
const cached = AfriCodeComponent.styleCache.get(sourceKey);
|
|
120
|
+
if (canAdoptStyleSheets) {
|
|
121
|
+
this.shadowRoot.adoptedStyleSheets = [
|
|
122
|
+
cached,
|
|
123
|
+
...AfriCodeComponent.globalSheets
|
|
124
|
+
];
|
|
125
|
+
} else {
|
|
126
|
+
this._applyFallbackStyle(cached?.cssText || cached?.text || cached || '');
|
|
127
|
+
}
|
|
110
128
|
return;
|
|
111
129
|
}
|
|
112
130
|
|
|
113
131
|
// 2. Fetch if not cached (Single Request)
|
|
114
132
|
try {
|
|
115
|
-
|
|
116
|
-
const css = await response.text();
|
|
133
|
+
let resolvedCss = stylesheetText;
|
|
117
134
|
|
|
118
|
-
|
|
119
|
-
|
|
135
|
+
if (!resolvedCss) {
|
|
136
|
+
const response = await fetch(styleUrl);
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
throw new Error(`Unable to load stylesheet: ${response.status}`);
|
|
139
|
+
}
|
|
140
|
+
resolvedCss = await response.text();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (canAdoptStyleSheets) {
|
|
144
|
+
const styleSheet = new CSSStyleSheet();
|
|
145
|
+
styleSheet.replaceSync(resolvedCss);
|
|
146
|
+
|
|
147
|
+
// Cache it
|
|
148
|
+
AfriCodeComponent.styleCache.set(sourceKey, styleSheet);
|
|
149
|
+
|
|
150
|
+
// Apply core + any global sheets
|
|
151
|
+
this.shadowRoot.adoptedStyleSheets = [
|
|
152
|
+
styleSheet,
|
|
153
|
+
...AfriCodeComponent.globalSheets
|
|
154
|
+
];
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this._applyFallbackStyle(resolvedCss);
|
|
159
|
+
AfriCodeComponent.styleCache.set(sourceKey, { text: resolvedCss });
|
|
160
|
+
} catch (err) {
|
|
161
|
+
this._applyFallbackStyle(stylesheetText || '');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
120
164
|
|
|
121
|
-
|
|
122
|
-
|
|
165
|
+
_applyFallbackStyle(css) {
|
|
166
|
+
if (!this.shadowRoot) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
123
169
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} catch (err) {
|
|
130
|
-
console.warn('AfriCode: Failed to load core styles', err);
|
|
170
|
+
let style = this.shadowRoot.querySelector('style[data-africode-core-styles]');
|
|
171
|
+
if (!style) {
|
|
172
|
+
style = document.createElement('style');
|
|
173
|
+
style.setAttribute('data-africode-core-styles', '');
|
|
174
|
+
this.shadowRoot.prepend(style);
|
|
131
175
|
}
|
|
176
|
+
|
|
177
|
+
style.textContent = css;
|
|
132
178
|
}
|
|
133
179
|
|
|
134
180
|
/**
|
|
@@ -175,6 +221,10 @@ export class AfriCodeComponent extends HTMLElement {
|
|
|
175
221
|
* @param {typeof HTMLElement} component - Component class
|
|
176
222
|
*/
|
|
177
223
|
export function registerComponent(name, component) {
|
|
224
|
+
if (typeof customElements === 'undefined') {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
178
228
|
if (!customElements.get(name)) {
|
|
179
229
|
customElements.define(name, component);
|
|
180
230
|
}
|