ab-nextjs-components 0.1.9 → 0.1.10

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 (49) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/ab-brand/index.tsx +30 -1
  3. package/ab-brand/styles.module.css +40 -1
  4. package/ab-button/helpers.ts +90 -0
  5. package/ab-button/index.tsx +164 -87
  6. package/ab-button/styles.module.css +79 -1
  7. package/ab-carousel/helpers.ts +146 -0
  8. package/ab-carousel/index.tsx +643 -0
  9. package/ab-carousel/styles.module.css +206 -0
  10. package/ab-chip/index.tsx +75 -0
  11. package/ab-chip/styles.module.css +87 -0
  12. package/ab-collapsible/index.tsx +30 -1
  13. package/ab-collapsible/styles.module.css +40 -1
  14. package/ab-flow-diagram/helpers.ts +77 -0
  15. package/ab-flow-diagram/index.tsx +141 -0
  16. package/ab-flow-diagram/styles.module.css +141 -0
  17. package/ab-icon/builtin.ts +61 -0
  18. package/ab-icon/helpers.ts +102 -0
  19. package/ab-icon/index.tsx +77 -16
  20. package/ab-icon/styles.module.css +53 -9
  21. package/ab-icon-button/index.tsx +110 -46
  22. package/ab-icon-button/styles.module.css +28 -10
  23. package/ab-install-snippet/helpers.ts +62 -0
  24. package/ab-install-snippet/index.tsx +170 -0
  25. package/ab-install-snippet/styles.module.css +104 -0
  26. package/ab-like-button/index.tsx +33 -1
  27. package/ab-like-button/styles.module.css +41 -6
  28. package/ab-linear-progress/index.tsx +5 -1
  29. package/ab-linear-progress/styles.module.css +8 -24
  30. package/ab-locale-switcher/index.tsx +213 -0
  31. package/ab-locale-switcher/styles.module.css +127 -0
  32. package/ab-pill/index.tsx +74 -0
  33. package/ab-progress-chips/index.tsx +30 -1
  34. package/ab-progress-chips/styles.module.css +40 -1
  35. package/ab-searchbar/index.tsx +33 -2
  36. package/ab-searchbar/styles.module.css +41 -5
  37. package/ab-splash/index.tsx +3 -1
  38. package/ab-splash/styles.module.css +2 -5
  39. package/ab-theme-toggle/index.tsx +188 -0
  40. package/ab-theme-toggle/styles.module.css +89 -0
  41. package/css/dialog.css +38 -3
  42. package/index.ts +41 -0
  43. package/package.json +33 -17
  44. package/server/ab-brand/index.tsx +29 -1
  45. package/server/ab-brand/styles.module.css +40 -1
  46. package/server/ab-button/index.tsx +96 -79
  47. package/server/ab-button/styles.module.css +79 -1
  48. package/server/ab-icon/index.tsx +68 -16
  49. package/server/ab-icon/styles.module.css +53 -9
@@ -1,3 +1,42 @@
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: ab-progress-chips - styles
28
+ * @file: ab-progress-chips/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
+
1
40
  .abProgressChips {
2
41
  display: flex;
3
42
  flex-wrap: wrap;
@@ -29,7 +68,7 @@
29
68
  height: 3px;
30
69
  background: var(--ab-primary, #6750a4);
31
70
  width: var(--chip-progress, 0%);
32
- transition: width 0.2s linear;
71
+ --ab-motion-easing: linear; /* 📏 fill motion = .ab-motion-size (ab-nextjs-animations) */
33
72
  }
34
73
  .abProgressChipName {
35
74
  font-size: 0.8125rem;
@@ -5,17 +5,48 @@
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
27
  * @name: AbSearchbar - Client (port of lyd-searchbar)
10
28
  * @file: ab-searchbar/index.tsx
29
+ * @type: TypeScript (React)
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
31
  */
12
32
 
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+
13
40
  'use client';
14
41
 
15
42
  import type { CSSProperties, KeyboardEvent, ReactElement } from 'react';
16
43
  import { useId, useRef, useState } from 'react';
17
44
  import clsx from 'clsx';
18
45
  import styles from './styles.module.css';
46
+ import { AB_MOTION } from 'ab-nextjs-animations/motion'; // 🎬 transition class names (ab-nextjs-animations >= 0.2.4)
47
+ import 'ab-nextjs-animations/motion/styles.css'; // 🎨 .ab-motion-*
48
+ import { AB_SPIN_CLASS } from 'ab-nextjs-animations/spin'; // 🌀 spinner (ab-nextjs-animations >= 0.2.4)
49
+ import 'ab-nextjs-animations/spin/styles.css'; // 🌀 .ab-spin
19
50
 
20
51
  export interface AbSearchbarProps {
21
52
  className?: string;
@@ -99,7 +130,7 @@ const AbSearchbar = ({
99
130
  <div
100
131
  hidden={hidden}
101
132
  style={style}
102
- className={clsx('AbSearchbar', styles.abSearchbar, disabled && styles.isDisabled, className)}
133
+ className={clsx('AbSearchbar', styles.abSearchbar, AB_MOTION.colors, disabled && styles.isDisabled, className)}
103
134
  data-busy={busy ? 'true' : 'false'}
104
135
  >
105
136
  <span className={clsx('material-symbols-rounded', styles.abSearchbarIcon)} aria-hidden>
@@ -124,7 +155,7 @@ const AbSearchbar = ({
124
155
  }}
125
156
  onKeyUp={(e) => onKeyUp?.(e.currentTarget.value, e)}
126
157
  />
127
- {busy ? <span className={styles.abSearchbarSpinner} aria-hidden /> : null}
158
+ {busy ? <span className={clsx(styles.abSearchbarSpinner, AB_SPIN_CLASS)} aria-hidden /> : null}
128
159
  {current && !disabled ? (
129
160
  <button type="button" className={styles.abSearchbarClear} aria-label={clearLabel} onClick={clear}>
130
161
  <span className="material-symbols-rounded" aria-hidden>close</span>
@@ -1,3 +1,42 @@
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: ab-searchbar - styles
28
+ * @file: ab-searchbar/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
+
1
40
  .abSearchbar {
2
41
  position: relative;
3
42
  display: flex;
@@ -10,7 +49,7 @@
10
49
  border-radius: 9999px;
11
50
  overflow: hidden;
12
51
  background: color-mix(in srgb, var(--ab-surface-container-high, #e6e0e9) 90%, transparent);
13
- transition: background 0.3s ease;
52
+ --ab-motion-duration: 300ms; /* 🎨 focus fade = .ab-motion-colors (ab-nextjs-animations) */
14
53
  }
15
54
  .abSearchbar:focus-within {
16
55
  background: var(--ab-surface-container-high, #e6e0e9);
@@ -65,10 +104,7 @@
65
104
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
66
105
  border-top-color: currentColor;
67
106
  border-radius: 50%;
68
- animation: abSearchbarSpin 0.7s linear infinite;
69
- }
70
- @keyframes abSearchbarSpin {
71
- to { transform: rotate(360deg); }
107
+ /* 🌀 rotation = .ab-spin (ab-nextjs-animations) */
72
108
  }
73
109
  .isDisabled {
74
110
  opacity: 0.55;
@@ -60,6 +60,8 @@ import {
60
60
  } from './gate';
61
61
  // 🎨 package-shipped styles
62
62
  import styles from './styles.module.css';
63
+ import { AB_MOTION } from 'ab-nextjs-animations/motion'; // 🎬 fade-out transition (ab-nextjs-animations >= 0.2.4)
64
+ import 'ab-nextjs-animations/motion/styles.css'; // 🌫️ .ab-motion-colors (covers opacity)
63
65
 
64
66
  // 📦 re-export the gate so `import { abSplashGateScript } from 'ab-nextjs-components/ab-splash'` works
65
67
  export * from './gate';
@@ -125,7 +127,7 @@ export default function AbSplash({ className, wordmark = 'Elements', maxMs }: Ab
125
127
 
126
128
  return (
127
129
  // 💦 the overlay (decorative → hidden from assistive tech)
128
- <div ref={ref} className={clsx('AbSplash', styles.abSplash, className)} aria-hidden="true">
130
+ <div ref={ref} className={clsx('AbSplash', styles.abSplash, AB_MOTION.colors, className)} aria-hidden="true">
129
131
  {/* 🅰️ mark + wordmark */}
130
132
  <AbLogo wordmark={wordmark} alt="" className={styles.abSplash__brand} />
131
133
  {/* 📶 progress */}
@@ -49,7 +49,7 @@
49
49
  gap: 2.25rem; /* ↕️ brand ↔ bar */
50
50
  background-color: #FFF8F3; /* ☀️ light surface (matches the splash mocks) */
51
51
  color: #A67C52; /* 🎨 bronze brand */
52
- transition: opacity 200ms ease; /* 🌫️ fade-out */
52
+ --ab-motion-duration: 200ms; /* 🌫️ fade-out = .ab-motion-colors (ab-nextjs-animations; off under reduced motion) */
53
53
  animation: abSplashFailsafe 0s linear 1.2s forwards; /* ⏱️ never longer than 1.2 s, even without hydration */
54
54
  }
55
55
 
@@ -95,10 +95,7 @@
95
95
  --ab-linear-progress-color: #A67C52; /* 🎨 bronze bar in both themes */
96
96
  }
97
97
 
98
- /* ♿ reduced motion: no fade */
99
- @media (prefers-reduced-motion: reduce) {
100
- .abSplash { transition: none; }
101
- }
98
+ /* ♿ reduced motion: no fade (handled by ab-nextjs-animations .ab-motion-colors) */
102
99
 
103
100
  /* ⏱️ failsafe keyframes */
104
101
  @keyframes abSplashFailsafe {
@@ -0,0 +1,188 @@
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: AbThemeToggle - Client (G9/G34)
28
+ * @file: ab-theme-toggle/index.tsx
29
+ * @type: Component (client) — light / dark / system
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> <AbThemeToggle labels={{ group: t('theme.label'), light: t('theme.light'), dark: t('theme.dark'), system: t('theme.system') }} />
34
+ */
35
+
36
+ /*
37
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
+ * MOTTO: We'll always do more 😜!!!
39
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
+ */
41
+
42
+ 'use client';
43
+
44
+ // ⚛️ React
45
+ import type { CSSProperties, KeyboardEvent, ReactNode } from 'react';
46
+ import { useRef } from 'react';
47
+ // 🧵 classes
48
+ import clsx from 'clsx';
49
+ // 🌗 theme engine (hooks ≥ 0.1.6, deep import = tree-shaken)
50
+ import { useAbThemeMode, AB_THEME_MODES, type AbThemeMode } from 'ab-nextjs-hooks/useAbTheme';
51
+ // 🔣 icons (SVG once G2 lands)
52
+ import AbIcon from '../ab-icon';
53
+ // 🎨 styles
54
+ import styles from './styles.module.css';
55
+ import { AB_MOTION } from 'ab-nextjs-animations/motion'; // 🎬 transition class names (ab-nextjs-animations >= 0.2.4)
56
+ import 'ab-nextjs-animations/motion/styles.css'; // 🎨 .ab-motion-*
57
+
58
+ // 📦 re-export the mode type for consumers
59
+ export type { AbThemeMode } from 'ab-nextjs-hooks/useAbTheme';
60
+
61
+ // 🏷️ i18n labels (required: no English defaults baked into a11y names)
62
+ export interface AbThemeToggleLabels {
63
+ group: string; // 🗂️ "Theme"
64
+ light: string; // 🌞 "Light"
65
+ dark: string; // 🌙 "Dark"
66
+ system: string; // 🖥️ "System"
67
+ }
68
+
69
+ // ⚙️ props
70
+ export interface AbThemeToggleProps {
71
+ labels: AbThemeToggleLabels; // 🏷️
72
+ variant?: 'segmented' | 'icon'; // 🎨 pill of radios, or one cycling icon button
73
+ modes?: readonly AbThemeMode[]; // 🎚️ default light, dark, system
74
+ value?: AbThemeMode; // 🎛️ controlled
75
+ onChange?: (mode: AbThemeMode) => void; // 📣
76
+ defaultMode?: AbThemeMode; // 🌱 before hydration (default 'light')
77
+ icons?: Partial<Record<AbThemeMode, ReactNode>>; // 🖼️ override glyphs
78
+ size?: 'sm' | 'md'; // 📏 sm = 32px, md = 40px segments (hit area ≥ 24px either way)
79
+ className?: string; // 🏷️
80
+ style?: CSSProperties; // 🎨
81
+ }
82
+
83
+ // 🔣 default glyphs (AbIcons names)
84
+ const DEFAULT_ICON_NAMES: Record<AbThemeMode, string> = { light: 'light_mode', dark: 'dark_mode', system: 'computer' };
85
+
86
+ /**
87
+ * @name getNextAbThemeMode
88
+ * @description 🔁 Radio-group arrow logic (pure): wraps, RTL flips Left/Right.
89
+ */
90
+ export function getNextAbThemeMode(modes: readonly AbThemeMode[], current: AbThemeMode, key: string, dir: 'ltr' | 'rtl' = 'ltr'): AbThemeMode | null {
91
+ const i = Math.max(0, modes.indexOf(current)); // 📍
92
+ const forward = dir === 'rtl' ? 'ArrowLeft' : 'ArrowRight'; // ➡️
93
+ const backward = dir === 'rtl' ? 'ArrowRight' : 'ArrowLeft'; // ⬅️
94
+ if (key === forward || key === 'ArrowDown') return modes[(i + 1) % modes.length]; // ⏭️
95
+ if (key === backward || key === 'ArrowUp') return modes[(i - 1 + modes.length) % modes.length]; // ⏮️
96
+ if (key === 'Home') return modes[0]; // ⏮️⏮️
97
+ if (key === 'End') return modes[modes.length - 1]; // ⏭️⏭️
98
+ return null; // 🙅
99
+ }
100
+
101
+ export function AbThemeToggle(props: AbThemeToggleProps) {
102
+ // 🧩 props
103
+ const { labels, variant = 'segmented', modes = AB_THEME_MODES, value, onChange, defaultMode = 'light', icons, size = 'md', className, style } = props;
104
+ // 🌗 engine: persists + applies to <html>
105
+ const engine = useAbThemeMode(defaultMode);
106
+ // 🎛️ controlled or engine-driven
107
+ const current = (value ?? engine.mode) as AbThemeMode;
108
+ // 📍 refs to move focus with the selection
109
+ const refs = useRef<Array<HTMLButtonElement | null>>([]);
110
+
111
+ // ✍️ select a mode
112
+ const select = (mode: AbThemeMode) => {
113
+ if (value === undefined) engine.setMode(mode); // 🎚️ uncontrolled: apply + persist
114
+ onChange?.(mode); // 📣
115
+ };
116
+
117
+ // 🖼️ glyph for a mode (decorative: the label names it)
118
+ const glyph = (mode: AbThemeMode) => icons?.[mode] ?? <AbIcon name={DEFAULT_ICON_NAMES[mode]} size={20} />;
119
+
120
+ // 🔘 single cycling button variant
121
+ if (variant === 'icon') {
122
+ const next = modes[(Math.max(0, modes.indexOf(current)) + 1) % modes.length]; // ⏭️
123
+ return (
124
+ <button
125
+ type="button" // 🧾
126
+ className={clsx('AbThemeToggle', styles.icon, AB_MOTION.colors, className)} // 🏷️
127
+ style={style} // 🎨
128
+ data-ab-part="theme-toggle" // 🗂️
129
+ data-mode={current} // 🎚️
130
+ data-size={size} // 📏
131
+ aria-label={`${labels.group}: ${labels[current]}`} // ♿ "Theme: Dark"
132
+ title={`${labels.group}: ${labels[current]}`} // 💬
133
+ onClick={() => select(next)} // 🔁
134
+ >
135
+ <span aria-hidden="true">{glyph(current)}</span>
136
+ </button>
137
+ );
138
+ }
139
+
140
+ // ⌨️ roving radio keys
141
+ const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
142
+ const dir = (event.currentTarget.closest('[dir]')?.getAttribute('dir') === 'rtl' ? 'rtl' : 'ltr') as 'ltr' | 'rtl'; // 🌍
143
+ const target = getNextAbThemeMode(modes, current, event.key, dir); // 🎯
144
+ if (!target) return; // 🙅 other keys untouched
145
+ event.preventDefault(); // 🛑 no scroll
146
+ select(target); // ✅ selection follows focus (radio pattern)
147
+ refs.current[modes.indexOf(target)]?.focus(); // 🎯
148
+ };
149
+
150
+ // 🎛️ segmented radiogroup
151
+ return (
152
+ <div
153
+ role="radiogroup" // ♿
154
+ aria-label={labels.group} // 🏷️
155
+ className={clsx('AbThemeToggle', styles.group, className)} // 🏷️
156
+ style={style} // 🎨
157
+ data-ab-part="theme-toggle" // 🗂️
158
+ data-mode={current} // 🎚️
159
+ data-size={size} // 📏
160
+ onKeyDown={onKeyDown} // ⌨️
161
+ >
162
+ {modes.map((mode, i) => {
163
+ const checked = mode === current; // ✅
164
+ return (
165
+ <button
166
+ key={mode} // 🔑
167
+ ref={(el) => { refs.current[i] = el; }} // 📍
168
+ type="button" // 🧾
169
+ role="radio" // ♿
170
+ aria-checked={checked} // ✅
171
+ aria-label={labels[mode]} // 🏷️
172
+ title={labels[mode]} // 💬
173
+ tabIndex={checked ? 0 : -1} // ⌨️ roving: one tab stop
174
+ className={clsx(styles.segment, AB_MOTION.colors)} // 🎨 + colour fade (ab-nextjs-animations)
175
+ data-ab-part="theme-option" // 🗂️
176
+ data-mode={mode} // 🎚️
177
+ onClick={() => select(mode)} // 🖱️
178
+ >
179
+ <span aria-hidden="true">{glyph(mode)}</span>
180
+ </button>
181
+ );
182
+ })}
183
+ </div>
184
+ );
185
+ }
186
+
187
+ // 📦 default export
188
+ export default AbThemeToggle;
@@ -0,0 +1,89 @@
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: AbThemeToggle - Styles
28
+ * @file: ab-theme-toggle/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
+ /* 💊 segmented pill */
40
+ .group {
41
+ display: inline-flex; /* 📐 row */
42
+ gap: 2px; /* 🧱 */
43
+ padding: 3px; /* 🧱 */
44
+ border-radius: 9999px; /* 💊 */
45
+ border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* 🖊️ */
46
+ background: var(--ab-color-surface-container, transparent); /* 🎨 */
47
+ }
48
+
49
+ /* 🔘 each option; md = 40px, sm = 32px (both ≥ 24px target, WCAG 2.5.8) */
50
+ .segment,
51
+ .icon {
52
+ display: inline-grid; /* 📐 */
53
+ place-items: center; /* 🎯 */
54
+ width: 40px; /* 📏 */
55
+ height: 40px; /* 📏 */
56
+ padding: 0; /* 🧹 */
57
+ border: 0; /* 🧹 */
58
+ border-radius: 9999px; /* 💊 */
59
+ color: var(--ab-color-on-surface-variant, currentColor); /* 🎨 */
60
+ background: transparent; /* 🫥 */
61
+ cursor: pointer; /* 👆 */
62
+ --ab-motion-duration: var(--ab-motion-duration-short, 160ms); /* 🎞️ colour fade = .ab-motion-colors (ab-nextjs-animations) */
63
+ }
64
+ [data-size='sm'] .segment,
65
+ .icon[data-size='sm'] {
66
+ width: 32px; /* 📏 */
67
+ height: 32px; /* 📏 */
68
+ }
69
+
70
+ /* ✅ selected */
71
+ .segment[aria-checked='true'] {
72
+ color: var(--ab-color-on-primary, #fff); /* 🎨 */
73
+ background: var(--ab-color-primary, #A67C52); /* 🥉 bronze */
74
+ }
75
+
76
+ /* 🖱️ hover (unselected only) */
77
+ .segment[aria-checked='false']:hover,
78
+ .icon:hover {
79
+ background: color-mix(in srgb, currentColor 10%, transparent); /* 🌫️ */
80
+ }
81
+
82
+ /* ♿ visible focus ring (theme token, G18) */
83
+ .segment:focus-visible,
84
+ .icon:focus-visible {
85
+ outline: 2px solid var(--ab-focus-ring, var(--ab-color-primary, #A67C52)); /* 💍 */
86
+ outline-offset: 2px; /* ↔️ */
87
+ }
88
+
89
+ /* 🧘 reduced motion: handled by ab-nextjs-animations (.ab-motion-colors) */
package/css/dialog.css CHANGED
@@ -1,7 +1,41 @@
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: Dialog chrome styles (moved out of ab-nextjs-theme)
28
+ * @file: css/dialog.css
29
+ * @type: CSS
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
1
33
  /*
2
- * ab-nextjs-components — chrome styles moved out of ab-nextjs-theme
3
- * Copyright (c) 2026 Abraham Ukachi. MIT.
4
- */
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
5
39
 
6
40
  /* Dialogs */
7
41
  #dialogs, .Dialogs {
@@ -104,6 +138,7 @@ li.dialog-list-item {
104
138
  transform-origin: left;
105
139
  opacity: var(--opacity-dialog-list-item, 0.68);
106
140
  user-select: none;
141
+ /* ⚠️ named motion exception (James review): consumer-rendered markup, no component can add an ab-motion-* class; pinned in __tests__/motion-from-animations.test.tsx */
107
142
  transition: all 0.2s ease-in-out;
108
143
  }
109
144
 
package/index.ts CHANGED
@@ -5,11 +5,38 @@
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
27
  * @name: Components - Package Catalog
10
28
  * @file: index.ts
29
+ * @type: Package catalog + barrel
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
11
31
  */
12
32
 
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more 😜!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+
13
40
  import type { ComponentCatalogEntry } from './types'
14
41
 
15
42
  /**
@@ -24,6 +51,8 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
24
51
  { name: 'AbLinearProgress', file: 'ab-linear-progress/index.tsx', kind: 'client', status: 'Done' },
25
52
  // 💦 AbSplash: subpath-only (`ab-nextjs-components/ab-splash`)
26
53
  { name: 'AbSplash', file: 'ab-splash/index.tsx', kind: 'client', status: 'Done' },
54
+ // 🎠 G31 AbCarousel (Welcome v6): subpath-only (`ab-nextjs-components/ab-carousel`), needs ab-nextjs-hooks >= 0.1.6
55
+ { name: 'AbCarousel', file: 'ab-carousel/index.tsx', kind: 'client', status: 'Done' },
27
56
  { name: 'AbButton', file: 'ab-button/index.tsx', kind: 'client', status: 'Done' },
28
57
  { name: 'AbIconButton', file: 'ab-icon-button/index.tsx', kind: 'client', status: 'Done' },
29
58
  { name: 'AbInput', file: 'ab-input/index.tsx', kind: 'client', status: 'Done' },
@@ -75,6 +104,18 @@ const supportedComponents: Array<ComponentCatalogEntry> = [
75
104
  { name: 'AbTestHello', file: 'server/ab-test-hello/index.tsx', kind: 'server', status: 'Done' },
76
105
  { name: 'AbKeyFeature', file: 'server/ab-key-feature/index.tsx', kind: 'server', status: 'Done' },
77
106
  { name: 'AbSwitchBack', file: 'server/ab-switch-back/index.tsx', kind: 'server', status: 'Done' },
107
+ // 🆕 Welcome v6 (AbThemeToggle)
108
+ { name: 'AbThemeToggle', file: 'ab-theme-toggle/index.tsx', kind: 'client', status: 'Done' },
109
+ // 🆕 Welcome v6 (AbChip)
110
+ { name: 'AbChip', file: 'ab-chip/index.tsx', kind: 'server', status: 'Done' },
111
+ // 🆕 Welcome v6 (AbPill)
112
+ { name: 'AbPill', file: 'ab-pill/index.tsx', kind: 'server', status: 'Done' },
113
+ // 🆕 Welcome v6 (AbInstallSnippet)
114
+ { name: 'AbInstallSnippet', file: 'ab-install-snippet/index.tsx', kind: 'client', status: 'Done' },
115
+ // 🆕 Welcome v6 (AbLocaleSwitcher)
116
+ { name: 'AbLocaleSwitcher', file: 'ab-locale-switcher/index.tsx', kind: 'client', status: 'Done' },
117
+ // 🆕 Welcome v6 (AbFlowDiagram)
118
+ { name: 'AbFlowDiagram', file: 'ab-flow-diagram/index.tsx', kind: 'server', status: 'Done' },
78
119
  ]
79
120
 
80
121
  const abComponents = { supportedComponents }