ab-nextjs-components 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +52 -0
  3. package/ab-app-bar/index.tsx +210 -0
  4. package/ab-app-bar/styles.module.css +158 -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-bottom-drawer/index.tsx +71 -0
  10. package/ab-bottom-drawer/styles.module.css +66 -0
  11. package/ab-brand/index.tsx +1 -1
  12. package/ab-breadcrumbs/index.tsx +92 -0
  13. package/ab-breadcrumbs/styles.module.css +54 -0
  14. package/ab-button/helpers.ts +6 -1
  15. package/ab-button/index.tsx +23 -4
  16. package/ab-button/styles.module.css +70 -0
  17. package/ab-card/index.tsx +89 -0
  18. package/ab-card/styles.module.css +68 -0
  19. package/ab-carousel/styles.module.css +1 -1
  20. package/ab-chip/index.tsx +16 -4
  21. package/ab-chip/styles.module.css +12 -1
  22. package/ab-collapsible/index.tsx +1 -1
  23. package/ab-color/index.tsx +1 -0
  24. package/ab-color/styles.module.css +32 -0
  25. package/ab-confirm-drawer/index.tsx +97 -0
  26. package/ab-confirm-drawer/styles.module.css +41 -0
  27. package/ab-demo-box/index.tsx +1 -0
  28. package/ab-demo-box/styles.module.css +32 -0
  29. package/ab-demo-code/index.tsx +1 -0
  30. package/ab-demo-code/styles.module.css +32 -0
  31. package/ab-drawer/index.tsx +307 -0
  32. package/ab-drawer/styles.module.css +127 -0
  33. package/ab-drawer/use-ab-drawer.ts +89 -0
  34. package/ab-drawer-list/index.tsx +118 -0
  35. package/ab-drawer-list/styles.module.css +65 -0
  36. package/ab-flow-diagram/styles.module.css +2 -2
  37. package/ab-icon/builtin.ts +19 -1
  38. package/ab-icon/helpers.ts +37 -0
  39. package/ab-icon/index.tsx +14 -8
  40. package/ab-icon/registrar.tsx +68 -0
  41. package/ab-icon-button/index.tsx +19 -3
  42. package/ab-icon-button/styles.module.css +1 -1
  43. package/ab-image/index.tsx +1 -0
  44. package/ab-image/styles.module.css +32 -0
  45. package/ab-info/index.tsx +2 -1
  46. package/ab-info/styles.module.css +32 -0
  47. package/ab-input/index.tsx +1 -0
  48. package/ab-input/styles.module.css +1 -0
  49. package/ab-install-snippet/index.tsx +51 -29
  50. package/ab-install-snippet/styles.module.css +50 -4
  51. package/ab-kbd/index.tsx +65 -0
  52. package/ab-kbd/styles.module.css +55 -0
  53. package/ab-key-feature/index.tsx +2 -1
  54. package/ab-key-feature/styles.module.css +32 -0
  55. package/ab-like-button/index.tsx +1 -1
  56. package/ab-link/index.tsx +112 -0
  57. package/ab-link/locale.ts +53 -0
  58. package/ab-list/index.tsx +107 -0
  59. package/ab-list/styles.module.css +82 -0
  60. package/ab-locale-switcher/index.tsx +59 -10
  61. package/ab-locale-switcher/styles.module.css +15 -4
  62. package/ab-main-headline/index.tsx +1 -0
  63. package/ab-main-headline/styles.module.css +32 -0
  64. package/ab-menu/index.tsx +6 -5
  65. package/ab-menu/styles.module.css +32 -0
  66. package/ab-name/index.tsx +1 -0
  67. package/ab-name/styles.module.css +32 -0
  68. package/ab-navbar/index.tsx +54 -46
  69. package/ab-navbar/styles.module.css +102 -28
  70. package/ab-navbar/view.tsx +166 -0
  71. package/ab-package-card/index.tsx +141 -0
  72. package/ab-package-card/styles.module.css +81 -0
  73. package/ab-page-paginator/index.tsx +1 -0
  74. package/ab-page-paginator/styles.module.css +32 -0
  75. package/ab-page-switcher/index.tsx +1 -0
  76. package/ab-page-switcher/styles.module.css +32 -0
  77. package/ab-preview/index.tsx +1 -0
  78. package/ab-preview/styles.module.css +32 -0
  79. package/ab-price/index.tsx +1 -0
  80. package/ab-price/styles.module.css +32 -0
  81. package/ab-price-tag/index.tsx +1 -0
  82. package/ab-price-tag/styles.module.css +32 -0
  83. package/ab-product/index.tsx +1 -0
  84. package/ab-product/styles.module.css +32 -0
  85. package/ab-product-item/index.tsx +1 -0
  86. package/ab-product-item/styles.module.css +32 -0
  87. package/ab-search-result/index.tsx +1 -0
  88. package/ab-search-result/styles.module.css +32 -0
  89. package/ab-search-trigger/index.tsx +157 -0
  90. package/ab-search-trigger/styles.module.css +96 -0
  91. package/ab-sidebar/index.tsx +91 -49
  92. package/ab-sidebar/styles.module.css +179 -31
  93. package/ab-sidebar/view.tsx +192 -0
  94. package/ab-switch-back/index.tsx +2 -1
  95. package/ab-switch-back/styles.module.css +32 -0
  96. package/ab-tab/index.tsx +2 -1
  97. package/ab-tab/styles.module.css +32 -0
  98. package/ab-tabs/index.tsx +1 -0
  99. package/ab-tabs/styles.module.css +32 -0
  100. package/ab-test-hello/index.tsx +1 -0
  101. package/ab-test-hello/styles.module.css +32 -0
  102. package/ab-text/index.tsx +1 -0
  103. package/ab-text/styles.module.css +32 -0
  104. package/ab-theme-toggle/index.tsx +21 -6
  105. package/ab-theme-toggle/styles.module.css +18 -3
  106. package/ab-toc/index.tsx +131 -0
  107. package/ab-toc/styles.module.css +66 -0
  108. package/ab-version-switcher/index.tsx +143 -0
  109. package/ab-version-switcher/styles.module.css +76 -0
  110. package/css/chrome-mq.css +32 -0
  111. package/css/doodle.css +32 -0
  112. package/css/logo.css +32 -0
  113. package/css/spinner.css +32 -0
  114. package/css/toast.css +32 -0
  115. package/index.ts +45 -0
  116. package/package.json +42 -10
  117. package/server/ab-avatar/index.tsx +2 -1
  118. package/server/ab-avatar/styles.module.css +32 -0
  119. package/server/ab-badge/index.tsx +1 -0
  120. package/server/ab-badge/styles.module.css +32 -0
  121. package/server/ab-brand/index.tsx +1 -1
  122. package/server/ab-button/index.tsx +6 -2
  123. package/server/ab-button/styles.module.css +39 -0
  124. package/server/ab-icon/index.tsx +13 -8
  125. package/server/ab-key-feature/index.tsx +2 -1
  126. package/server/ab-key-feature/styles.module.css +32 -0
  127. package/server/ab-name/index.tsx +1 -0
  128. package/server/ab-name/styles.module.css +32 -0
  129. package/server/ab-nav-link/index.tsx +2 -1
  130. package/server/ab-nav-link/styles.module.css +32 -0
  131. package/server/ab-navbar/index.tsx +44 -45
  132. package/server/ab-polygon/index.tsx +1 -0
  133. package/server/ab-polygon/styles.module.css +32 -0
  134. package/server/ab-sidebar/index.tsx +44 -49
  135. package/server/ab-switch-back/index.tsx +2 -1
  136. package/server/ab-switch-back/styles.module.css +32 -0
  137. package/server/ab-test-hello/index.tsx +1 -0
  138. package/server/ab-test-hello/styles.module.css +32 -0
  139. package/server/ab-text/index.tsx +1 -0
  140. package/server/ab-text/styles.module.css +32 -0
  141. package/server/index.ts +1 -0
  142. package/styles.css +32 -0
  143. package/types/index.d.ts +54 -0
  144. package/server/ab-navbar/styles.module.css +0 -35
  145. package/server/ab-sidebar/styles.module.css +0 -41
@@ -8,6 +8,7 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbProductItem - Client (Adapt of lyd-product-item; providers stripped)
10
10
  * @file: ab-product-item/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-product-item/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abProductItem {
2
34
  display: flex;
3
35
  gap: 0.75rem;
@@ -8,6 +8,7 @@
8
8
  * @project: ab-nextjs-components
9
9
  * @name: AbSearchResult - Client (port of lyd-search-result)
10
10
  * @file: ab-search-result/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-search-result/styles.module.css
29
+ * @type: CSS Stylesheet
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  .abSearchResult {
2
34
  position: relative;
3
35
  display: flex;
@@ -0,0 +1,157 @@
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: index.tsx
28
+ * @file: ab-search-trigger/index.tsx
29
+ * @type: Component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+ 'use client';
40
+
41
+ // ⚛️ React
42
+ import { useEffect, useSyncExternalStore, type MouseEvent, type ReactElement } from 'react';
43
+ // 🧵 classes
44
+ import clsx from 'clsx';
45
+ // 🔗 G42 link (href fallback)
46
+ import Link from '../ab-link';
47
+ // 🔣 icon (search is a built-in)
48
+ import AbIcon from '../ab-icon';
49
+ // ⌨️ key hint
50
+ import AbKbd from '../ab-kbd';
51
+ // 🎬 hover / press motion from the package
52
+ import 'ab-nextjs-animations/motion/styles.css';
53
+ // 🎨 styles
54
+ import styles from './styles.module.css';
55
+
56
+ /** ⚙️ props */
57
+ export interface AbSearchTriggerProps {
58
+ label?: string; // 🏷️ placeholder text (default "Search")
59
+ onOpen?: () => void; // 🔔 opens your search dialog (button mode)
60
+ href?: string; // 🔗 no onOpen → a link to a search page (also the JS-off path)
61
+ hotkey?: boolean; // ⌨️ listen for ⌘K / Ctrl+K (default true when onOpen is set)
62
+ shortcut?: boolean; // ⌨️ alias of `hotkey` (Joseph's spec name); `hotkey` wins when both are set
63
+ compact?: boolean; // 📱 icon-only pill (the label stays for screen readers), e.g. the mobile app bar
64
+ comingSoon?: boolean; // 🚧 visible but inert: aria-disabled, no hotkey
65
+ comingSoonLabel?: string; // 🏷️ default "Coming soon"
66
+ variant?: 'pill' | 'field'; // 🔎 0.1.14 (P6): 'field' = the Home 300×36 bordered field (default 'pill', the legacy look)
67
+ size?: 'md' | 'sm'; // 📱 0.1.14 (P6): 'sm' = the mobile 34px "Search ⌘K" pill (label + key cap stay visible)
68
+ className?: string; // 🏷️
69
+ }
70
+
71
+ // 🔕 nothing to subscribe to
72
+ const noopSubscribe = () => () => {};
73
+
74
+ /** 🍎 Apple platforms show ⌘, everyone else Ctrl. */
75
+ export function isAbApplePlatform(nav?: { platform?: string; userAgent?: string; userAgentData?: { platform?: string } }): boolean {
76
+ const p = nav?.userAgentData?.platform ?? nav?.platform ?? nav?.userAgent ?? ''; // 🔍
77
+ return /mac|iphone|ipad|ipod/i.test(p); // 🍎
78
+ }
79
+
80
+ /**
81
+ * 🔎 AbSearchTrigger (G44): a search "field" that opens your dialog. Shows ⌘K on Apple, Ctrl K elsewhere,
82
+ * announces `aria-keyshortcuts="Meta+K Control+K"`, and falls back to a link when there's no `onOpen`.
83
+ * Note: the hotkey is a local listener; G48 `useAbHotkey` is deliberately not in hooks 0.1.7.
84
+ */
85
+ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, compact = false, comingSoon = false, comingSoonLabel = 'Coming soon', variant = 'pill', size = 'md', className }: AbSearchTriggerProps): ReactElement => {
86
+ // 🍎 SSR renders "Ctrl"; hydration then reads the platform (useSyncExternalStore: no mismatch, no effect)
87
+ const apple = useSyncExternalStore(
88
+ noopSubscribe, // 🔕 the platform never changes
89
+ () => isAbApplePlatform(navigator as Navigator & { userAgentData?: { platform?: string } }), // 🖥️ client
90
+ () => false, // 🖨️ server
91
+ );
92
+ // ⌨️ ⌘K / Ctrl+K
93
+ const listen = !comingSoon && !!onOpen && (hotkey ?? shortcut ?? true);
94
+ useEffect(() => {
95
+ if (!listen) return;
96
+ const onKey = (e: KeyboardEvent) => {
97
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
98
+ e.preventDefault(); // 🚫 browser search bar
99
+ onOpen?.(); // 🔔
100
+ }
101
+ };
102
+ window.addEventListener('keydown', onKey); // 👂
103
+ return () => window.removeEventListener('keydown', onKey); // 🧹
104
+ }, [listen, onOpen]);
105
+
106
+ // 🏠 P6: the Home looks (field / sm pill) show ONE key cap ("⌘ K" / "⌘K") and keep "coming soon" out of the field
107
+ const home = variant === 'field' || size === 'sm';
108
+ const keyCap = (apple ? '⌘' : 'Ctrl') + (size === 'sm' ? '' : ' ') + 'K'; // ⌨️ mock: "⌘ K" (field) · "⌘K" (sm)
109
+ // 🧩 inner content
110
+ const inner = home ? (
111
+ <>
112
+ <AbIcon name="search" size={size === 'sm' ? 17 : 18} className={styles.abSearchTriggerIcon} />
113
+ <span className={styles.abSearchTriggerLabel}>{label}</span>
114
+ {/* 🚧 coming soon: tooltip + announced, never painted inside the field (spec §4) */}
115
+ {comingSoon ? <span className={styles.abSearchTriggerSrOnly}>, {comingSoonLabel}</span> : listen && <AbKbd className={styles.abSearchTriggerCap}>{keyCap}</AbKbd>}
116
+ </>
117
+ ) : (
118
+ <>
119
+ <AbIcon name="search" size={20} className={styles.abSearchTriggerIcon} />
120
+ <span className={clsx(styles.abSearchTriggerLabel, compact && styles.abSearchTriggerSrOnly)}>{label}</span>
121
+ {/* 🚧 coming soon tag, or ⌨️ the key hint ONLY while a hotkey is really listening (James #3, D24a) */}
122
+ {comingSoon
123
+ ? !compact && <span className={styles.abSearchTriggerSoon}>{comingSoonLabel}</span>
124
+ : listen && !compact && <AbKbd keys={[apple ? '⌘' : 'Ctrl', 'K']} className={styles.abSearchTriggerKbd} />}
125
+ </>
126
+ );
127
+ const common = {
128
+ className: clsx('AbSearchTrigger', styles.abSearchTrigger, !comingSoon && 'ab-motion-interactive', className), // 🏷️
129
+ 'data-ab-part': 'search-trigger', // 🧩
130
+ 'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // ♿ only announced when bound (James #3)
131
+ 'data-compact': compact ? 'true' : undefined, // 📱
132
+ 'data-variant': variant === 'field' ? 'field' : undefined, // 🔎 P6
133
+ 'data-size': size === 'sm' ? 'sm' : undefined, // 📱 P6
134
+ title: home && comingSoon ? comingSoonLabel : undefined, // 💬 P6: "coming soon" lives in the tooltip
135
+ };
136
+
137
+ // 🚧 coming soon: focusable, announced, inert
138
+ if (comingSoon) return <button type="button" {...common} aria-disabled="true" data-coming-soon="true">{inner}</button>;
139
+ // 🔗 href → ALWAYS a real link, so it works with JS off (D24a: /docs). With onOpen too, JS intercepts
140
+ // the click and opens the dialog instead (James #4); modified clicks (new tab, …) keep the link.
141
+ if (href) {
142
+ const onClick = onOpen
143
+ ? (e: MouseEvent<HTMLAnchorElement>) => {
144
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; // 🖱️ let the browser handle it
145
+ e.preventDefault(); // 🚫 navigation
146
+ onOpen(); // 🔔
147
+ }
148
+ : undefined;
149
+ return <Link href={href} {...common} onClick={onClick} aria-haspopup={onOpen ? 'dialog' : undefined}>{inner}</Link>;
150
+ }
151
+ // 🔘 dialog opener
152
+ return <button type="button" {...common} aria-haspopup="dialog" onClick={onOpen}>{inner}</button>;
153
+ };
154
+
155
+ // 📦 exports
156
+ export default AbSearchTrigger;
157
+ export { AbSearchTrigger };
@@ -0,0 +1,96 @@
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: AbSearchTrigger - Styles (G44)
28
+ * @file: ab-search-trigger/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
+ /* 🔎 pill "field" */
40
+ .abSearchTrigger {
41
+ display: inline-flex; /* 📐 */
42
+ align-items: center; /* ↕️ */
43
+ gap: 8px; /* ↔️ */
44
+ min-width: 0; /* 📏 */
45
+ width: 100%; /* 📏 */
46
+ max-width: 360px; /* 📏 */
47
+ height: 40px; /* 📏 */
48
+ padding: 0 8px 0 12px; /* 📦 */
49
+ border: 0; /* 🚫 */
50
+ border-radius: 999px; /* 🟢 */
51
+ background: var(--ab-color-surface-container-high, rgb(0 0 0 / 0.06)); /* 🎨 */
52
+ color: var(--ab-color-on-surface-variant, inherit); /* 🖋️ */
53
+ font: inherit; /* 🔤 */
54
+ text-decoration: none; /* 🚫 */
55
+ cursor: pointer; /* 👆 */
56
+ box-sizing: border-box; /* 📦 */
57
+ }
58
+ .abSearchTrigger:focus-visible {
59
+ outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* ♿ */
60
+ outline-offset: var(--ab-focus-ring-offset, 2px); /* ♿ */
61
+ }
62
+ .abSearchTrigger[aria-disabled='true'] { cursor: default; opacity: 0.72; } /* 🚧 */
63
+ .abSearchTriggerLabel { flex: 1; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* 🏷️ */
64
+ .abSearchTriggerIcon { flex: none; } /* 🔣 */
65
+ .abSearchTriggerSoon { font-size: 12px; opacity: 0.8; } /* 🚧 */
66
+
67
+ /* 📱 compact (Joseph #3/#16): icon-only round pill for small app bars, no overflow at 390px */
68
+ .abSearchTrigger[data-compact='true'] { flex: none; width: 40px; min-width: 40px; padding: 0; justify-content: center; } /* 🔘 */
69
+ /* 🕶️ visually hidden, still read by screen readers */
70
+ .abSearchTriggerSrOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; flex: none; }
71
+
72
+ /* ===== 🏠 0.1.14 (P6, Home spec §4): variant="field" (300×36) · size="sm" (mobile 34px pill) ===== */
73
+ .abSearchTrigger[data-variant='field'] {
74
+ width: var(--ab-search-trigger-width, 300px); max-width: 100%; height: 36px; /* 📏 desktop 360 / tablet 260 via the var */
75
+ gap: 8px; padding: 0 6px 0 10px; /* 📦 */
76
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-button, 10px); /* 🔲 */
77
+ background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); /* 🎨 */
78
+ font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* 🔤 🌗 */
79
+ }
80
+ .abSearchTrigger[data-size='sm'] {
81
+ flex: none; width: auto; max-width: none; height: 34px; /* 📏 */
82
+ gap: 6px; padding: 0 6px 0 10px; /* 📦 */
83
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* 💊 */
84
+ background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); font-size: 13px; line-height: 1; /* 🎨 🔤 */
85
+ }
86
+ .abSearchTrigger[data-variant='field']:hover, .abSearchTrigger[data-size='sm']:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); } /* 🖱️ */
87
+ .abSearchTrigger[data-variant='field']:focus-visible, .abSearchTrigger[data-size='sm']:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* ♿ */
88
+ /* ⌨️ the single key cap (mock `kbd`): 20px, radius 5, 2px bottom border, 11/600 --muted */
89
+ .abSearchTriggerCap.abSearchTriggerCap {
90
+ flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; /* 📐 */
91
+ min-width: 20px; height: 20px; padding: 0 5px; margin-left: 2px; /* 📏 */
92
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-bottom-width: 2px; border-radius: var(--ab-radius-kbd, 5px); /* 🔲 */
93
+ background: var(--ab-color-kbd, #fff); color: var(--ab-color-muted, #6b5b50); font: 600 11px/1 var(--ab-font-body, inherit); /* 🔤 Inter: fine for ⌘ (spec §2) */
94
+ }
95
+ .abSearchTrigger[data-size='sm'] .abSearchTriggerCap { min-width: 18px; height: 18px; font-size: 10px; } /* 📱 */
96
+ .abSearchTrigger[data-variant='field'][aria-disabled='true'], .abSearchTrigger[data-size='sm'][aria-disabled='true'] { opacity: 1; } /* 🚧 the Home field looks the same while search is coming soon (the tooltip says so) */
@@ -5,68 +5,110 @@
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)
69
+ collapseButtonVariant?: 'plain' | 'outlined'; // ⏪ 0.1.14 (P9): 'outlined' = 32×32 bordered `<<` / `>>` (default 'plain' chevron)
35
70
  }
36
71
 
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
- );
72
+ /**
73
+ * 🧭 AbSidebar (client, G40): sections, filled icon on the active item, aria-current, an icon rail with balloon
74
+ * tooltips, and a collapse button (aria-expanded + aria-controls; hidden when JS is off).
75
+ */
76
+ const AbSidebar = (props: AbSidebarProps): ReactElement => {
77
+ const { collapsed: controlled, defaultCollapsed = false, onCollapsedChange, collapsible, collapseButtonVariant = 'plain', activeHref, page, labels, id = 'ab-sidebar-list' } = props;
78
+ const outlined = collapseButtonVariant === 'outlined'; // ⏪ P9
79
+ // 🧭 route
80
+ const appLocales = useAbLocales(); // 🌍 from AbLinkProvider
81
+ const pathname = stripAbLocalePrefix(usePathname() ?? '', props.locales ?? appLocales); // 🧭 `/fr/docs` → `/docs`
82
+ // 🚪 controlled or not
83
+ const [inner, setInner] = useState(defaultCollapsed);
84
+ const collapsed = controlled ?? inner;
85
+ const setCollapsed = (next: boolean) => {
86
+ if (controlled === undefined) setInner(next); // 🧠 uncontrolled
87
+ onCollapsedChange?.(next); // 🔔
88
+ };
89
+ // 🎯 legacy `page` wins, then activeHref, then the pathname
90
+ const active = (href: string, value?: string) => (page ? page === value : isAbSidebarActive(href, activeHref ?? pathname));
91
+ // 🔘 the toggle
92
+ const showToggle = collapsible ?? !!props.sections?.length;
93
+ const toggleLabel = collapsed ? labels?.expand ?? 'Expand sidebar' : labels?.collapse ?? 'Collapse sidebar';
94
+ const toggle = showToggle ? (
95
+ <button
96
+ type="button"
97
+ className={styles.abSidebarToggle} // 🙈 hidden under (scripting: none)
98
+ data-ab-part="collapse"
99
+ data-variant={outlined ? 'outlined' : undefined} // ⏪ P9
100
+ aria-expanded={!collapsed} // ♿
101
+ aria-controls={id} // ♿
102
+ aria-label={toggleLabel} // 🏷️
103
+ onClick={() => setCollapsed(!collapsed)}
104
+ >
105
+ <AbIcon name={outlined ? (collapsed ? 'keyboard_double_arrow_right' : 'keyboard_double_arrow_left') : collapsed ? 'chevron_right' : 'chevron_left'} size={outlined ? 18 : 20} />
106
+ </button>
107
+ ) : undefined;
108
+
109
+ return <AbSidebarView props={{ ...props, collapsed }} Icon={AbIcon} active={active} toggle={toggle} />;
69
110
  };
70
111
 
112
+ // 📦 exports
71
113
  export default AbSidebar;
72
114
  export { AbSidebar };