ab-nextjs-components 0.1.12 → 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 (119) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +22 -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/index.tsx +15 -2
  11. package/ab-button/styles.module.css +31 -0
  12. package/ab-card/index.tsx +89 -0
  13. package/ab-card/styles.module.css +68 -0
  14. package/ab-collapsible/index.tsx +1 -1
  15. package/ab-color/index.tsx +1 -0
  16. package/ab-color/styles.module.css +32 -0
  17. package/ab-demo-box/index.tsx +1 -0
  18. package/ab-demo-box/styles.module.css +32 -0
  19. package/ab-demo-code/index.tsx +1 -0
  20. package/ab-demo-code/styles.module.css +32 -0
  21. package/ab-icon/builtin.ts +15 -1
  22. package/ab-icon/helpers.ts +37 -0
  23. package/ab-icon/index.tsx +14 -8
  24. package/ab-icon/registrar.tsx +68 -0
  25. package/ab-icon-button/index.tsx +8 -3
  26. package/ab-image/index.tsx +1 -0
  27. package/ab-image/styles.module.css +32 -0
  28. package/ab-info/index.tsx +2 -1
  29. package/ab-info/styles.module.css +32 -0
  30. package/ab-input/index.tsx +1 -0
  31. package/ab-input/styles.module.css +1 -0
  32. package/ab-install-snippet/styles.module.css +16 -2
  33. package/ab-kbd/index.tsx +65 -0
  34. package/ab-kbd/styles.module.css +55 -0
  35. package/ab-key-feature/index.tsx +2 -1
  36. package/ab-key-feature/styles.module.css +32 -0
  37. package/ab-like-button/index.tsx +1 -1
  38. package/ab-link/index.tsx +112 -0
  39. package/ab-link/locale.ts +53 -0
  40. package/ab-locale-switcher/index.tsx +17 -0
  41. package/ab-locale-switcher/styles.module.css +11 -0
  42. package/ab-main-headline/index.tsx +1 -0
  43. package/ab-main-headline/styles.module.css +32 -0
  44. package/ab-menu/index.tsx +6 -5
  45. package/ab-menu/styles.module.css +32 -0
  46. package/ab-name/index.tsx +1 -0
  47. package/ab-name/styles.module.css +32 -0
  48. package/ab-navbar/index.tsx +54 -46
  49. package/ab-navbar/styles.module.css +84 -28
  50. package/ab-navbar/view.tsx +163 -0
  51. package/ab-package-card/index.tsx +94 -0
  52. package/ab-package-card/styles.module.css +41 -0
  53. package/ab-page-paginator/index.tsx +1 -0
  54. package/ab-page-paginator/styles.module.css +32 -0
  55. package/ab-page-switcher/index.tsx +1 -0
  56. package/ab-page-switcher/styles.module.css +32 -0
  57. package/ab-preview/index.tsx +1 -0
  58. package/ab-preview/styles.module.css +32 -0
  59. package/ab-price/index.tsx +1 -0
  60. package/ab-price/styles.module.css +32 -0
  61. package/ab-price-tag/index.tsx +1 -0
  62. package/ab-price-tag/styles.module.css +32 -0
  63. package/ab-product/index.tsx +1 -0
  64. package/ab-product/styles.module.css +32 -0
  65. package/ab-product-item/index.tsx +1 -0
  66. package/ab-product-item/styles.module.css +32 -0
  67. package/ab-search-result/index.tsx +1 -0
  68. package/ab-search-result/styles.module.css +32 -0
  69. package/ab-search-trigger/index.tsx +142 -0
  70. package/ab-search-trigger/styles.module.css +70 -0
  71. package/ab-sidebar/index.tsx +88 -49
  72. package/ab-sidebar/styles.module.css +136 -31
  73. package/ab-sidebar/view.tsx +182 -0
  74. package/ab-switch-back/index.tsx +2 -1
  75. package/ab-switch-back/styles.module.css +32 -0
  76. package/ab-tab/index.tsx +2 -1
  77. package/ab-tab/styles.module.css +32 -0
  78. package/ab-tabs/index.tsx +1 -0
  79. package/ab-tabs/styles.module.css +32 -0
  80. package/ab-test-hello/index.tsx +1 -0
  81. package/ab-test-hello/styles.module.css +32 -0
  82. package/ab-text/index.tsx +1 -0
  83. package/ab-text/styles.module.css +32 -0
  84. package/ab-toc/index.tsx +124 -0
  85. package/ab-toc/styles.module.css +54 -0
  86. package/css/chrome-mq.css +32 -0
  87. package/css/doodle.css +32 -0
  88. package/css/logo.css +32 -0
  89. package/css/spinner.css +32 -0
  90. package/css/toast.css +32 -0
  91. package/index.ts +18 -0
  92. package/package.json +27 -10
  93. package/server/ab-avatar/index.tsx +2 -1
  94. package/server/ab-avatar/styles.module.css +32 -0
  95. package/server/ab-badge/index.tsx +1 -0
  96. package/server/ab-badge/styles.module.css +32 -0
  97. package/server/ab-brand/index.tsx +1 -1
  98. package/server/ab-icon/index.tsx +13 -8
  99. package/server/ab-key-feature/index.tsx +2 -1
  100. package/server/ab-key-feature/styles.module.css +32 -0
  101. package/server/ab-name/index.tsx +1 -0
  102. package/server/ab-name/styles.module.css +32 -0
  103. package/server/ab-nav-link/index.tsx +2 -1
  104. package/server/ab-nav-link/styles.module.css +32 -0
  105. package/server/ab-navbar/index.tsx +44 -45
  106. package/server/ab-polygon/index.tsx +1 -0
  107. package/server/ab-polygon/styles.module.css +32 -0
  108. package/server/ab-sidebar/index.tsx +44 -49
  109. package/server/ab-switch-back/index.tsx +2 -1
  110. package/server/ab-switch-back/styles.module.css +32 -0
  111. package/server/ab-test-hello/index.tsx +1 -0
  112. package/server/ab-test-hello/styles.module.css +32 -0
  113. package/server/ab-text/index.tsx +1 -0
  114. package/server/ab-text/styles.module.css +32 -0
  115. package/server/index.ts +1 -0
  116. package/styles.css +32 -0
  117. package/types/index.d.ts +35 -0
  118. package/server/ab-navbar/styles.module.css +0 -35
  119. package/server/ab-sidebar/styles.module.css +0 -41
@@ -5,68 +5,107 @@
5
5
  * ~~~~~~~~~~~~
6
6
  * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
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
+ *
8
26
  * @project: ab-nextjs-components
9
- * @name: AbSidebar - Client (port of lyd-sidebar; providers stripped)
27
+ * @name: AbSidebar - Client (G40)
10
28
  * @file: ab-sidebar/index.tsx
29
+ * @type: Client Component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * <AbSidebar
34
+ * activeHref="/docs/components"
35
+ * sections={[{ id: 'docs', label: 'Docs', items: [{ href: '/docs/components', icon: 'widgets', label: 'Components' }] }]}
36
+ * />
37
+ */
38
+
39
+ /*
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ * MOTTO: We'll always do more 😜!!!
42
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
43
  */
12
44
 
13
45
  'use client';
14
46
 
15
- import type { ReactElement } from 'react';
16
- import Link from 'next/link';
47
+ // ⚛️ React
48
+ import { useState, type ReactElement } from 'react';
49
+ // 🧭 current route (fallback when `activeHref` is omitted)
17
50
  import { usePathname } from 'next/navigation';
18
- import clsx from 'clsx';
51
+ // 🌍 0.1.13 (Joseph #10): locale-stripped pathname
52
+ import { stripAbLocalePrefix, useAbLocales } from '../ab-link';
53
+ // 🔣 client AbIcon (built-in chevrons are always registered)
54
+ import AbIcon from '../ab-icon';
55
+ // 🖼️ shared view
56
+ import { AbSidebarView, isAbSidebarActive, type AbSidebarBaseProps } from './view';
57
+ // 🎨 styles
19
58
  import styles from './styles.module.css';
20
59
 
21
- export type AbSidebarLink = {
22
- href: string;
23
- icon: string;
24
- value: string;
25
- label: string;
26
- };
60
+ // 📦 re-export the shared types
61
+ export type { AbSidebarItem, AbSidebarSection, AbSidebarLink, AbSidebarLabels } from './view';
62
+ export { isAbSidebarActive, toAbSidebarSections } from './view';
27
63
 
28
- export interface AbSidebarProps {
29
- className?: string;
30
- type?: 'customer' | 'admin';
31
- page?: string;
32
- links?: AbSidebarLink[];
33
- brandHref?: string;
34
- brandLabel?: string;
64
+ /** ⚙️ Client props: the shared ones + collapse control. */
65
+ export interface AbSidebarProps extends AbSidebarBaseProps {
66
+ defaultCollapsed?: boolean; // 🚪 uncontrolled start
67
+ onCollapsedChange?: (collapsed: boolean) => void; // 🔔
68
+ collapsible?: boolean; // 🔘 show the collapse button (default true when sections are given)
35
69
  }
36
70
 
37
- const AbSidebar = ({
38
- className,
39
- type = 'customer',
40
- page,
41
- links = [],
42
- brandHref = '/',
43
- brandLabel = 'abElements',
44
- }: AbSidebarProps): ReactElement => {
45
- const pathname = usePathname() ?? '';
46
- return (
47
- <nav data-type={type} data-ab-part="sidebar" className={clsx('AbSidebar', styles.abSidebar, className)} aria-label="Sidebar">
48
- <Link href={brandHref} className={styles.abSidebarBrand}>
49
- <span className="material-symbols-rounded" aria-hidden>apps</span>
50
- <span>{brandLabel}</span>
51
- </Link>
52
- <ul className={styles.abSidebarList}>
53
- {links.map((link) => {
54
- const active = page ? page === link.value : pathname === link.href || pathname.startsWith(`${link.href}/`);
55
- return (
56
- <li key={link.value}>
57
- <Link href={link.href} data-active={active ? 'true' : 'false'} className={styles.abSidebarLink}>
58
- <span className={clsx('material-symbols-rounded', styles.abSidebarIcon)} aria-hidden>
59
- {link.icon}
60
- </span>
61
- <span>{link.label}</span>
62
- </Link>
63
- </li>
64
- );
65
- })}
66
- </ul>
67
- </nav>
68
- );
71
+ /**
72
+ * 🧭 AbSidebar (client, G40): sections, filled icon on the active item, aria-current, an icon rail with balloon
73
+ * tooltips, and a collapse button (aria-expanded + aria-controls; hidden when JS is off).
74
+ */
75
+ const AbSidebar = (props: AbSidebarProps): ReactElement => {
76
+ const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, activeHref, page, labels, id = 'ab-sidebar-list' } = props;
77
+ // 🧭 route
78
+ const appLocales = useAbLocales(); // 🌍 from AbLinkProvider
79
+ const pathname = stripAbLocalePrefix(usePathname() ?? '', props.locales ?? appLocales); // 🧭 `/fr/docs` → `/docs`
80
+ // 🚪 controlled or not
81
+ const [inner, setInner] = useState(defaultCollapsed);
82
+ const collapsed = controlled ?? inner;
83
+ const setCollapsed = (next: boolean) => {
84
+ if (controlled === undefined) setInner(next); // 🧠 uncontrolled
85
+ onCollapsedChange?.(next); // 🔔
86
+ };
87
+ // 🎯 legacy `page` wins, then activeHref, then the pathname
88
+ const active = (href: string, value?: string) => (page ? page === value : isAbSidebarActive(href, activeHref ?? pathname));
89
+ // 🔘 the toggle
90
+ const showToggle = collapsible ?? !!props.sections?.length;
91
+ const toggleLabel = collapsed ? labels?.expand ?? 'Expand sidebar' : labels?.collapse ?? 'Collapse sidebar';
92
+ const toggle = showToggle ? (
93
+ <button
94
+ type="button"
95
+ className={styles.abSidebarToggle} // 🙈 hidden under (scripting: none)
96
+ data-ab-part="collapse"
97
+ aria-expanded={!collapsed} // ♿
98
+ aria-controls={id} // ♿
99
+ aria-label={toggleLabel} // 🏷️
100
+ onClick={() => setCollapsed(!collapsed)}
101
+ >
102
+ <AbIcon name={collapsed ? 'chevron_right' : 'chevron_left'} size={20} />
103
+ </button>
104
+ ) : undefined;
105
+
106
+ return <AbSidebarView props={{ ...props, collapsed }} Icon={AbIcon} active={active} toggle={toggle} />;
69
107
  };
70
108
 
109
+ // 📦 exports
71
110
  export default AbSidebar;
72
111
  export { AbSidebar };
@@ -1,41 +1,146 @@
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 - Styles (G40)
28
+ * @file: ab-sidebar/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
+ /* 🧭 shell */
1
40
  .abSidebar {
2
- display: flex;
3
- flex-direction: column;
4
- gap: 1rem;
5
- width: 100%;
6
- max-width: 16rem;
7
- padding: 1rem 0.75rem;
8
- box-sizing: border-box;
41
+ display: flex; /* 📐 */
42
+ flex-direction: column; /* ⬇️ */
43
+ gap: 12px; /* ↕️ */
44
+ width: 100%; /* 📏 */
45
+ max-width: 280px; /* 📏 docs-shell sidebar */
46
+ padding: 12px; /* 📦 */
47
+ box-sizing: border-box; /* 📦 */
9
48
  }
49
+ .abSidebar[data-collapsed='true'] {
50
+ max-width: 72px; /* 🚪 rail */
51
+ align-items: center; /* ↔️ */
52
+ }
53
+ /* 🏷️ header row: brand/slot + toggle */
54
+ .abSidebarHeader {
55
+ display: flex; /* 📐 */
56
+ align-items: center; /* ↕️ */
57
+ justify-content: space-between; /* ↔️ */
58
+ gap: 8px; /* ↔️ */
59
+ min-height: 40px; /* 📏 */
60
+ }
61
+ .abSidebarHeader:empty { display: none; } /* 🙈 */
10
62
  .abSidebarBrand {
11
- display: flex;
12
- align-items: center;
13
- gap: 0.5rem;
14
- font-weight: 700;
15
- text-decoration: none;
16
- color: inherit;
63
+ font-weight: 700; /* 🔤 */
64
+ text-decoration: none; /* 🚫 */
65
+ color: inherit; /* 🖋️ */
66
+ }
67
+ /* 🔘 collapse button */
68
+ .abSidebarToggle {
69
+ display: inline-grid; /* 📐 */
70
+ place-items: center; /* 🎯 */
71
+ width: 40px; /* 📏 */
72
+ height: 40px; /* 📏 */
73
+ border: 0; /* 🚫 */
74
+ border-radius: 999px; /* 🟢 */
75
+ background: transparent; /* 🎨 */
76
+ color: inherit; /* 🖋️ */
77
+ cursor: pointer; /* 👆 */
78
+ }
79
+ .abSidebarToggle:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* 🖱️ */
80
+ .abSidebarToggle:focus-visible,
81
+ .abSidebarLink:focus-visible {
82
+ outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* ♿ */
83
+ outline-offset: var(--ab-focus-ring-offset, 2px); /* ♿ */
17
84
  }
85
+ @media (scripting: none) {
86
+ .abSidebarToggle { display: none; } /* 🚫 JS off: no toggle */
87
+ }
88
+ /* 🗂️ sections */
89
+ .abSidebarSections { display: flex; flex-direction: column; gap: 16px; width: 100%; }
90
+ .abSidebarSection { display: flex; flex-direction: column; gap: 4px; }
91
+ .abSidebarHeading {
92
+ margin: 0; /* 🚫 */
93
+ padding: 0 12px; /* 📦 */
94
+ font-size: 12px; /* 🔤 */
95
+ font-weight: 600; /* 🔤 */
96
+ letter-spacing: 0.04em; /* 🔤 */
97
+ text-transform: uppercase; /* 🔠 */
98
+ opacity: 0.7; /* 🌫️ */
99
+ }
100
+ .abSidebar[data-collapsed='true'] .abSidebarHeading { display: none; } /* 🚪 */
18
101
  .abSidebarList {
19
- display: flex;
20
- flex-direction: column;
21
- gap: 0.25rem;
22
- list-style: none;
23
- margin: 0;
24
- padding: 0;
102
+ display: flex; /* 📐 */
103
+ flex-direction: column; /* ⬇️ */
104
+ gap: 2px; /* ↕️ */
105
+ list-style: none; /* 🚫 */
106
+ margin: 0; /* 🚫 */
107
+ padding: 0; /* 🚫 */
25
108
  }
109
+ /* 🔗 item */
26
110
  .abSidebarLink {
27
- display: flex;
28
- align-items: center;
29
- gap: 0.6rem;
30
- padding: 0.55rem 0.75rem;
31
- border-radius: 0.75rem;
32
- text-decoration: none;
33
- color: inherit;
34
- opacity: 0.75;
35
- font-weight: 600;
111
+ display: flex; /* 📐 */
112
+ align-items: center; /* ↕️ */
113
+ gap: 12px; /* ↔️ */
114
+ min-height: 40px; /* 👆 target */
115
+ padding: 0 12px; /* 📦 */
116
+ border-radius: 999px; /* 🟢 */
117
+ text-decoration: none; /* 🚫 */
118
+ color: inherit; /* 🖋️ */
119
+ font-weight: 500; /* 🔤 */
120
+ /* 🔤 0.1.13 (Joseph #15): M3 label-large, so names stop inheriting the big body size and wrapping at 280px */
121
+ font-family: var(--md-sys-typescale-label-large-font, inherit);
122
+ font-size: var(--md-sys-typescale-label-large-size, 14px);
123
+ line-height: var(--md-sys-typescale-label-large-line-height, 20px);
124
+ letter-spacing: var(--md-sys-typescale-label-large-tracking, 0.1px);
36
125
  }
126
+ .abSidebarLabel { min-width: 0; overflow-wrap: anywhere; } /* 🚫 no overflow, ReactNode-friendly */
127
+ .abSidebarLink[data-depth='1'] { padding-inline-start: 44px; font-size: 14px; } /* 🌳 */
128
+ .abSidebarLink:hover { background: color-mix(in srgb, currentColor 8%, transparent); } /* 🖱️ */
37
129
  .abSidebarLink[data-active='true'] {
38
- opacity: 1;
39
- background: color-mix(in srgb, var(--ab-primary, #6750a4) 14%, transparent);
130
+ background: var(--ab-color-secondary-container, color-mix(in srgb, #8f4c38 14%, transparent)); /* 🎯 */
131
+ color: var(--ab-color-on-secondary-container, inherit); /* 🖋️ */
132
+ font-weight: 600; /* 🔤 */
133
+ }
134
+ .abSidebarIcon { flex: none; } /* 🔣 */
135
+ .abSidebarBadge {
136
+ margin-inline-start: auto; /* ➡️ */
137
+ padding: 0 6px; /* 📦 */
138
+ border-radius: 999px; /* 🟢 */
139
+ font-size: 11px; /* 🔤 */
140
+ line-height: 18px; /* 📏 */
141
+ background: var(--ab-color-tertiary-container, rgb(0 0 0 / 0.08)); /* 🎨 */
40
142
  }
41
- .abSidebarIcon { font-size: 1.25rem; }
143
+ /* 🚪 rail: icons only (labels stay for screen readers via aria-label) */
144
+ .abSidebar[data-collapsed='true'] .abSidebarLink { width: 48px; justify-content: center; padding: 0; }
145
+ .abSidebar[data-collapsed='true'] .abSidebarLabel,
146
+ .abSidebar[data-collapsed='true'] .abSidebarBadge { display: none; }
@@ -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;