ab-nextjs-components 0.1.11 → 0.1.13

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +30 -0
  3. package/ab-app-bar/index.tsx +181 -0
  4. package/ab-app-bar/styles.module.css +119 -0
  5. package/ab-avatar/index.tsx +2 -1
  6. package/ab-avatar/styles.module.css +32 -0
  7. package/ab-balloon/index.tsx +134 -23
  8. package/ab-balloon/styles.module.css +84 -7
  9. package/ab-brand/index.tsx +1 -1
  10. package/ab-button/helpers.ts +3 -1
  11. package/ab-button/index.tsx +17 -3
  12. package/ab-button/styles.module.css +42 -0
  13. package/ab-card/index.tsx +89 -0
  14. package/ab-card/styles.module.css +68 -0
  15. package/ab-collapsible/index.tsx +1 -1
  16. package/ab-color/index.tsx +1 -0
  17. package/ab-color/styles.module.css +32 -0
  18. package/ab-demo-box/index.tsx +1 -0
  19. package/ab-demo-box/styles.module.css +32 -0
  20. package/ab-demo-code/index.tsx +1 -0
  21. package/ab-demo-code/styles.module.css +32 -0
  22. package/ab-icon/builtin.ts +15 -1
  23. package/ab-icon/helpers.ts +37 -0
  24. package/ab-icon/index.tsx +14 -8
  25. package/ab-icon/registrar.tsx +68 -0
  26. package/ab-icon-button/index.tsx +8 -3
  27. package/ab-image/index.tsx +1 -0
  28. package/ab-image/styles.module.css +32 -0
  29. package/ab-info/index.tsx +2 -1
  30. package/ab-info/styles.module.css +32 -0
  31. package/ab-input/index.tsx +1 -0
  32. package/ab-input/styles.module.css +1 -0
  33. package/ab-install-snippet/styles.module.css +32 -8
  34. package/ab-kbd/index.tsx +65 -0
  35. package/ab-kbd/styles.module.css +55 -0
  36. package/ab-key-feature/index.tsx +2 -1
  37. package/ab-key-feature/styles.module.css +32 -0
  38. package/ab-like-button/index.tsx +1 -1
  39. package/ab-link/index.tsx +112 -0
  40. package/ab-link/locale.ts +53 -0
  41. package/ab-locale-switcher/index.tsx +17 -0
  42. package/ab-locale-switcher/styles.module.css +11 -0
  43. package/ab-main-headline/index.tsx +1 -0
  44. package/ab-main-headline/styles.module.css +32 -0
  45. package/ab-menu/index.tsx +6 -5
  46. package/ab-menu/styles.module.css +32 -0
  47. package/ab-name/index.tsx +1 -0
  48. package/ab-name/styles.module.css +32 -0
  49. package/ab-navbar/index.tsx +54 -46
  50. package/ab-navbar/styles.module.css +84 -28
  51. package/ab-navbar/view.tsx +163 -0
  52. package/ab-package-card/index.tsx +94 -0
  53. package/ab-package-card/styles.module.css +41 -0
  54. package/ab-page-paginator/index.tsx +1 -0
  55. package/ab-page-paginator/styles.module.css +32 -0
  56. package/ab-page-switcher/index.tsx +1 -0
  57. package/ab-page-switcher/styles.module.css +32 -0
  58. package/ab-preview/index.tsx +1 -0
  59. package/ab-preview/styles.module.css +32 -0
  60. package/ab-price/index.tsx +1 -0
  61. package/ab-price/styles.module.css +32 -0
  62. package/ab-price-tag/index.tsx +1 -0
  63. package/ab-price-tag/styles.module.css +32 -0
  64. package/ab-product/index.tsx +1 -0
  65. package/ab-product/styles.module.css +32 -0
  66. package/ab-product-item/index.tsx +1 -0
  67. package/ab-product-item/styles.module.css +32 -0
  68. package/ab-search-result/index.tsx +1 -0
  69. package/ab-search-result/styles.module.css +32 -0
  70. package/ab-search-trigger/index.tsx +142 -0
  71. package/ab-search-trigger/styles.module.css +70 -0
  72. package/ab-sidebar/index.tsx +88 -49
  73. package/ab-sidebar/styles.module.css +136 -31
  74. package/ab-sidebar/view.tsx +182 -0
  75. package/ab-switch-back/index.tsx +2 -1
  76. package/ab-switch-back/styles.module.css +32 -0
  77. package/ab-tab/index.tsx +2 -1
  78. package/ab-tab/styles.module.css +32 -0
  79. package/ab-tabs/index.tsx +1 -0
  80. package/ab-tabs/styles.module.css +32 -0
  81. package/ab-test-hello/index.tsx +1 -0
  82. package/ab-test-hello/styles.module.css +32 -0
  83. package/ab-text/index.tsx +1 -0
  84. package/ab-text/styles.module.css +32 -0
  85. package/ab-toc/index.tsx +124 -0
  86. package/ab-toc/styles.module.css +54 -0
  87. package/css/chrome-mq.css +32 -0
  88. package/css/doodle.css +32 -0
  89. package/css/logo.css +32 -0
  90. package/css/spinner.css +32 -0
  91. package/css/toast.css +32 -0
  92. package/index.ts +18 -0
  93. package/package.json +27 -10
  94. package/server/ab-avatar/index.tsx +2 -1
  95. package/server/ab-avatar/styles.module.css +32 -0
  96. package/server/ab-badge/index.tsx +1 -0
  97. package/server/ab-badge/styles.module.css +32 -0
  98. package/server/ab-brand/index.tsx +1 -1
  99. package/server/ab-button/index.tsx +1 -1
  100. package/server/ab-button/styles.module.css +11 -0
  101. package/server/ab-icon/index.tsx +13 -8
  102. package/server/ab-key-feature/index.tsx +2 -1
  103. package/server/ab-key-feature/styles.module.css +32 -0
  104. package/server/ab-name/index.tsx +1 -0
  105. package/server/ab-name/styles.module.css +32 -0
  106. package/server/ab-nav-link/index.tsx +2 -1
  107. package/server/ab-nav-link/styles.module.css +32 -0
  108. package/server/ab-navbar/index.tsx +44 -45
  109. package/server/ab-polygon/index.tsx +1 -0
  110. package/server/ab-polygon/styles.module.css +32 -0
  111. package/server/ab-sidebar/index.tsx +44 -49
  112. package/server/ab-switch-back/index.tsx +2 -1
  113. package/server/ab-switch-back/styles.module.css +32 -0
  114. package/server/ab-test-hello/index.tsx +1 -0
  115. package/server/ab-test-hello/styles.module.css +32 -0
  116. package/server/ab-text/index.tsx +1 -0
  117. package/server/ab-text/styles.module.css +32 -0
  118. package/server/index.ts +1 -0
  119. package/styles.css +32 -0
  120. package/types/index.d.ts +35 -0
  121. package/server/ab-navbar/styles.module.css +0 -35
  122. package/server/ab-sidebar/styles.module.css +0 -41
@@ -0,0 +1,182 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: AbSidebar - Shared view (client + server)
28
+ * @file: ab-sidebar/view.tsx
29
+ * @type: React Component (no hooks)
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+ // ⚛️ React
40
+ import type { ComponentType, ReactElement, ReactNode } from 'react';
41
+ // 🧵 classes
42
+ import clsx from 'clsx';
43
+ // 🔗 G42: injectable link
44
+ import Link from '../ab-link';
45
+ // 🎈 rail tooltips (accessible balloon, 0.1.13)
46
+ import AbBalloon from '../ab-balloon';
47
+ // 🎨 styles
48
+ import styles from './styles.module.css';
49
+
50
+ /** 🔗 One sidebar destination (G40). `items` = one level of children, shown under the parent. */
51
+ export interface AbSidebarItem {
52
+ id?: string; // 🆔 0.1.13 (James nit): stable React key when two items share an href (default: `href`)
53
+ href: string; // 🔗
54
+ icon?: string; // 🔣 AbIcons name: outlined, filled when active
55
+ label: ReactNode; // 🏷️ 0.1.13: any node (Joseph #15), e.g. a mono package name
56
+ labelText?: string; // ♿ plain-text name for the rail tooltip/aria-label when `label` isn't a string
57
+ badge?: ReactNode; // 🔴 e.g. "New" or a count
58
+ items?: AbSidebarItem[]; // 🌳 children
59
+ }
60
+
61
+ /** 🗂️ A labelled group of items. */
62
+ export interface AbSidebarSection {
63
+ id: string; // 🆔
64
+ label?: string; // 🏷️ heading (omit for an unlabelled group)
65
+ items: AbSidebarItem[]; // 🔗
66
+ }
67
+
68
+ /** 🕰️ Legacy (≤ 0.1.12) link shape; still accepted via `links`. */
69
+ export type AbSidebarLink = {
70
+ href: string;
71
+ icon: string;
72
+ value: string;
73
+ label: string;
74
+ };
75
+
76
+ /** 🌍 Translatable strings. */
77
+ export interface AbSidebarLabels {
78
+ nav?: string; // ♿ nav aria-label (default "Sidebar")
79
+ collapse?: string; // ◀️ (default "Collapse sidebar")
80
+ expand?: string; // ▶️ (default "Expand sidebar")
81
+ }
82
+
83
+ /** 🔣 What the view needs from an icon component (client and server AbIcon both fit). */
84
+ export type AbSidebarIconComponent = ComponentType<{ name: string; variant?: 'outlined' | 'filled'; size?: number; className?: string }>;
85
+
86
+ /** ⚙️ Props shared by the client and server AbSidebar. */
87
+ export interface AbSidebarBaseProps {
88
+ className?: string; // 🏷️
89
+ id?: string; // 🆔 the list id (aria-controls target), default "ab-sidebar-list"
90
+ sections?: AbSidebarSection[]; // 🗂️ G40
91
+ activeHref?: string; // 🎯 current route (exact or a parent prefix)
92
+ collapsed?: boolean; // 🚪 icon rail
93
+ header?: ReactNode; // 🏷️ top slot (brand, workspace switcher…)
94
+ labels?: AbSidebarLabels; // 🌍
95
+ locales?: readonly string[]; // 🌍 0.1.13: stripped from the pathname (default: AbLinkProvider's)
96
+ // 🕰️ legacy API (≤ 0.1.12)
97
+ type?: 'customer' | 'admin';
98
+ page?: string;
99
+ links?: AbSidebarLink[];
100
+ brandHref?: string;
101
+ brandLabel?: string;
102
+ }
103
+
104
+ /** 🎯 Is `href` the current route, or a parent of it? */
105
+ export function isAbSidebarActive(href: string, activeHref?: string): boolean {
106
+ if (!activeHref) return false; // 🚫
107
+ if (href === activeHref) return true; // ✅ exact
108
+ return href !== '/' && activeHref.startsWith(`${href.replace(/\/$/, '')}/`); // 🌳 parent
109
+ }
110
+
111
+ /** 🗂️ sections, or the legacy links as one unlabelled section. */
112
+ export function toAbSidebarSections(sections?: AbSidebarSection[], links?: AbSidebarLink[]): AbSidebarSection[] {
113
+ if (sections?.length) return sections; // ✅ v2
114
+ return links?.length ? [{ id: 'links', items: links.map(({ href, icon, label }) => ({ href, icon, label })) }] : []; // 🕰️
115
+ }
116
+
117
+ /** 🖼️ Render-only sidebar used by both twins. `active` decides the current item; `toggle` is the client's button. */
118
+ export function AbSidebarView({ props, Icon, active, toggle }: {
119
+ props: AbSidebarBaseProps;
120
+ Icon: AbSidebarIconComponent;
121
+ active: (href: string, legacyValue?: string) => boolean;
122
+ toggle?: ReactNode;
123
+ }): ReactElement {
124
+ const { className, id = 'ab-sidebar-list', sections, collapsed = false, header, labels, type = 'customer', links, brandHref = '/', brandLabel = 'abElements' } = props;
125
+ const groups = toAbSidebarSections(sections, links); // 🗂️
126
+ // 🕰️ legacy value lookup (page === link.value)
127
+ const valueOf = (href: string) => links?.find((l) => l.href === href)?.value;
128
+
129
+ // 🔗 one item (+ children)
130
+ const renderItem = (item: AbSidebarItem, depth: number): ReactElement => {
131
+ const on = active(item.href, valueOf(item.href)); // 🎯
132
+ const text = item.labelText ?? (typeof item.label === 'string' ? item.label : undefined); // ♿ plain name
133
+ const link = (
134
+ <Link
135
+ href={item.href}
136
+ className={styles.abSidebarLink}
137
+ data-ab-part="item"
138
+ data-active={on ? 'true' : 'false'}
139
+ data-depth={depth}
140
+ aria-current={on ? 'page' : undefined} // ♿
141
+ aria-label={collapsed ? text : undefined} // ♿ rail: the label is visually hidden
142
+ >
143
+ {item.icon && <Icon name={item.icon} variant={on ? 'filled' : 'outlined'} size={20} className={styles.abSidebarIcon} />}
144
+ <span className={styles.abSidebarLabel}>{item.label}</span>
145
+ {item.badge != null && <span className={styles.abSidebarBadge} data-ab-part="badge">{item.badge}</span>}
146
+ </Link>
147
+ );
148
+ return (
149
+ <li key={item.id ?? item.href}>
150
+ {/* 🎈 rail: a balloon names the icon on hover / focus */}
151
+ {collapsed && depth === 0 ? <AbBalloon title={text ?? item.href} placement="end">{link}</AbBalloon> : link}
152
+ {!collapsed && item.items?.length ? (
153
+ <ul className={styles.abSidebarList} data-ab-part="children">{item.items.map((c) => renderItem(c, depth + 1))}</ul>
154
+ ) : null}
155
+ </li>
156
+ );
157
+ };
158
+
159
+ return (
160
+ <nav
161
+ data-type={type} // 🕰️
162
+ data-ab-part={collapsed ? 'rail' : 'sidebar'} // 🧩
163
+ data-collapsed={collapsed ? 'true' : 'false'} // 🚪
164
+ className={clsx('AbSidebar', styles.abSidebar, className)} // 🏷️
165
+ aria-label={labels?.nav ?? 'Sidebar'} // ♿
166
+ >
167
+ {/* 🏷️ header slot, or the legacy brand link */}
168
+ <div className={styles.abSidebarHeader}>
169
+ {header ?? (links?.length && !sections?.length ? <Link href={brandHref} className={styles.abSidebarBrand}>{brandLabel}</Link> : null)}
170
+ {toggle}
171
+ </div>
172
+ <div id={id} className={styles.abSidebarSections}>
173
+ {groups.map((g) => (
174
+ <section key={g.id} className={styles.abSidebarSection} data-ab-part="section" aria-labelledby={g.label ? `${id}-${g.id}` : undefined}>
175
+ {g.label && <h2 id={`${id}-${g.id}`} className={styles.abSidebarHeading}>{g.label}</h2>}
176
+ <ul className={styles.abSidebarList}>{g.items.map((it) => renderItem(it, 0))}</ul>
177
+ </section>
178
+ ))}
179
+ </div>
180
+ </nav>
181
+ );
182
+ }
@@ -8,12 +8,13 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbSwitchBack - Client (port of lyd-switch-back)
10
10
  * @file: ab-switch-back/index.tsx
11
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
12
  */
12
13
 
13
14
  'use client';
14
15
 
15
16
  import type { ReactElement, ReactNode } from 'react';
16
- import Link from 'next/link';
17
+ import Link from '../ab-link'; // 🔗 G42: injectable via AbLinkProvider (default next/link)
17
18
  import Image from 'next/image';
18
19
  import clsx from 'clsx';
19
20
  import styles from './styles.module.css';
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: styles.module.css
28
+ * @file: ab-switch-back/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abSwitchBack {
2
34
  display: grid;
3
35
  grid-template-columns: 1fr;
package/ab-tab/index.tsx CHANGED
@@ -8,13 +8,14 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbTab - Client (port of lyd-tab)
10
10
  * @file: ab-tab/index.tsx
11
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
12
  */
12
13
 
13
14
  'use client';
14
15
 
15
16
  import type { MouseEvent, ReactElement, ReactNode } from 'react';
16
17
  import { forwardRef } from 'react';
17
- import Link from 'next/link';
18
+ import Link from '../ab-link'; // 🔗 G42: injectable via AbLinkProvider (default next/link)
18
19
  import clsx from 'clsx';
19
20
  import styles from './styles.module.css';
20
21
 
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: styles.module.css
28
+ * @file: ab-tab/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abTab {
2
34
  position: relative;
3
35
  display: flex;
package/ab-tabs/index.tsx CHANGED
@@ -8,6 +8,7 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbTabs - Client (port of lyd-tabs)
10
10
  * @file: ab-tabs/index.tsx
11
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
12
  */
12
13
 
13
14
  'use client';
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: styles.module.css
28
+ * @file: ab-tabs/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abTabs {
2
34
  position: relative;
3
35
  display: flex;
@@ -8,6 +8,7 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbTestHello - Client (port of lyd-test-hello)
10
10
  * @file: ab-test-hello/index.tsx
11
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
12
  */
12
13
 
13
14
  'use client';
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: styles.module.css
28
+ * @file: ab-test-hello/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abTestHello {
2
34
  display: flex;
3
35
  flex-direction: column;
package/ab-text/index.tsx CHANGED
@@ -8,6 +8,7 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbText - Client (port of lyd-text; i18n stripped — pass value)
10
10
  * @file: ab-text/index.tsx
11
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
12
  */
12
13
 
13
14
  'use client';
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: styles.module.css
28
+ * @file: ab-text/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abText {
2
34
  display: inline;
3
35
  }
@@ -0,0 +1,124 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: AbToc (G46)
28
+ * @file: ab-toc/index.tsx
29
+ * @type: React Component (server-safe)
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * // 📏 core 0.1.6 panes: the page never scrolls, the main pane does (G55), so spy on and scroll IT
34
+ * const { mainScrollElement } = useAbPage(); // ✅ state from core, safe in render
35
+ * // without core: resolve the DOM node in an EFFECT, never during render (SSR + hydration safe)
36
+ * // const [main, setMain] = useState<HTMLElement | null>(null); useEffect(() => setMain(getAbMainScroller()), []);
37
+ * const activeId = useAbScrollSpy(items.map((i) => i.id), { root: mainScrollElement });
38
+ * <AbToc items={items} activeId={activeId} onNavigate={(id) => scrollToAbSection(id, { container: mainScrollElement })} />
39
+ */
40
+
41
+ /*
42
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
+ * MOTTO: We'll always do more 😜!!!
44
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45
+ */
46
+
47
+ // ⚛️ React
48
+ import type { ReactElement } from 'react';
49
+ // 🧵 classes
50
+ import clsx from 'clsx';
51
+ // 🎨 styles
52
+ import styles from './styles.module.css';
53
+
54
+ /** 📜 0.1.13 (D35/G55): core 0.1.6 marks the panes main scroller with this attribute (components doesn't depend on core). */
55
+ export const AB_MAIN_SCROLLER_SELECTOR = '[data-ab-part="main-content"]';
56
+
57
+ /**
58
+ * 📜 getAbMainScroller — the element that scrolls the page content: the core panes main pane when present,
59
+ * else `null` (= the window). Pass `from` (e.g. the heading) to pick the pane that contains it.
60
+ * Use it as `useAbScrollSpy({ root })` / `scrollToAbSection(id, { container })`.
61
+ *
62
+ * ⚠️ Call it only in an effect or an event handler, **never during render**: it reads the DOM, so a render
63
+ * call returns `null` on the server and the element on the client (hydration mismatch). (James nit)
64
+ */
65
+ export function getAbMainScroller(from?: Element | null): HTMLElement | null {
66
+ if (typeof document === 'undefined') return null; // 🖥️ SSR
67
+ const own = from?.closest<HTMLElement>(AB_MAIN_SCROLLER_SELECTOR); // 🎯 the pane holding `from`
68
+ return own ?? document.querySelector<HTMLElement>(AB_MAIN_SCROLLER_SELECTOR); // 🔎 first main pane, or null
69
+ }
70
+
71
+ /** 📑 one heading */
72
+ export interface AbTocItem {
73
+ id: string; // 🆔 the heading id (link target)
74
+ label: string; // 🏷️
75
+ level?: 2 | 3 | 4; // 📏 indent (default 2)
76
+ }
77
+
78
+ /** ⚙️ props */
79
+ export interface AbTocProps {
80
+ items: AbTocItem[]; // 📑
81
+ activeId?: string | null; // 🎯 e.g. from useAbScrollSpy (hooks 0.1.7)
82
+ title?: string; // 🏷️ default "On this page"
83
+ label?: string; // 🏷️ 0.1.13 (Joseph #16): alias of `title`; `title` wins when both are set
84
+ onNavigate?: (id: string) => void; // 🔔 e.g. scrollToAbSection(id, { container }) (hooks 0.1.7); without it a plain #id jump, which scrolls the nearest scroller (the main pane in core 0.1.6 panes)
85
+ id?: string; // 🆔 root id (default "ab-toc"); the title gets `${id}-title`
86
+ className?: string; // 🏷️
87
+ }
88
+
89
+ /**
90
+ * 📑 AbToc (G46): "On this page" list of plain `#id` links (works without JS), the current one marked with
91
+ * aria-current="location". Pair with `useAbScrollSpy` from ab-nextjs-hooks 0.1.7 for `activeId`.
92
+ * No hooks here, so it also renders on the server.
93
+ */
94
+ const AbToc = ({ items, activeId, label, title = label ?? 'On this page', onNavigate, id = 'ab-toc', className }: AbTocProps): ReactElement | null => {
95
+ if (!items.length) return null; // 🙈 nothing to list
96
+ const headingId = `${id}-title`; // 🆔
97
+ return (
98
+ <nav id={id} className={clsx('AbToc', styles.abToc, className)} data-ab-part="toc" aria-labelledby={headingId}>
99
+ <p id={headingId} className={styles.abTocTitle}>{title}</p>
100
+ <ol className={styles.abTocList}>
101
+ {items.map((it) => {
102
+ const on = it.id === activeId; // 🎯
103
+ return (
104
+ <li key={it.id} data-level={it.level ?? 2}>
105
+ <a
106
+ href={`#${it.id}`} // 🔗 JS-off friendly
107
+ className={styles.abTocLink}
108
+ data-active={on ? 'true' : 'false'}
109
+ aria-current={on ? 'location' : undefined} // ♿
110
+ onClick={onNavigate ? (e) => { e.preventDefault(); onNavigate(it.id); } : undefined}
111
+ >
112
+ {it.label}
113
+ </a>
114
+ </li>
115
+ );
116
+ })}
117
+ </ol>
118
+ </nav>
119
+ );
120
+ };
121
+
122
+ // 📦 exports
123
+ export default AbToc;
124
+ export { AbToc };
@@ -0,0 +1,54 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: AbToc - Styles (G46)
28
+ * @file: ab-toc/styles.module.css
29
+ * @type: CSS Module
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+ .abToc { font-size: 14px; } /* 📑 */
40
+ .abTocTitle { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; } /* 🏷️ */
41
+ .abTocList { list-style: none; margin: 0; padding: 0; border-inline-start: var(--ab-divider-hairline, 1px solid rgb(0 0 0 / 0.12)); } /* ➖ */
42
+ .abTocList > li[data-level='3'] { padding-inline-start: 12px; } /* 📏 */
43
+ .abTocList > li[data-level='4'] { padding-inline-start: 24px; } /* 📏 */
44
+ .abTocLink {
45
+ display: block; /* 📐 */
46
+ margin-inline-start: -1px; /* ➖ sit on the rail */
47
+ padding: 4px 12px; /* 📦 */
48
+ border-inline-start: 2px solid transparent; /* ➖ */
49
+ color: var(--ab-color-on-surface-variant, inherit); /* 🖋️ */
50
+ text-decoration: none; /* 🚫 */
51
+ }
52
+ .abTocLink:hover { color: var(--ab-color-on-surface, inherit); } /* 🖱️ */
53
+ .abTocLink[data-active='true'] { border-inline-start-color: var(--ab-color-primary, currentColor); color: var(--ab-color-primary, inherit); font-weight: 600; } /* 🎯 */
54
+ .abTocLink:focus-visible { outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); outline-offset: var(--ab-focus-ring-offset, 2px); } /* ♿ */
package/css/chrome-mq.css CHANGED
@@ -1,3 +1,35 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: chrome-mq.css
28
+ * @file: css/chrome-mq.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  /*
2
34
  * ab-nextjs-components — chrome styles moved out of ab-nextjs-theme
3
35
  * Copyright (c) 2026 Abraham Ukachi. MIT.