ab-nextjs-components 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -17
- package/README.md +1 -0
- package/ab-app-bar/index.tsx +5 -5
- package/ab-app-bar/styles.module.css +5 -5
- package/ab-bottom-drawer/index.tsx +3 -3
- package/ab-bottom-drawer/styles.module.css +2 -2
- package/ab-bottom-drawer/use-ab-swipe-down.ts +1 -1
- package/ab-breadcrumbs/index.tsx +1 -1
- package/ab-breadcrumbs/styles.module.css +5 -5
- package/ab-button/index.tsx +1 -1
- package/ab-button/styles.module.css +5 -5
- package/ab-callout/index.tsx +1 -1
- package/ab-callout/styles.module.css +1 -1
- package/ab-carousel/helpers.ts +1 -1
- package/ab-carousel/index.tsx +4 -4
- package/ab-carousel/styles.module.css +2 -2
- package/ab-chip/styles.module.css +1 -1
- package/ab-code-block/index.tsx +2 -2
- package/ab-code-block/styles.module.css +1 -1
- package/ab-content-tabs/index.tsx +1 -1
- package/ab-doc-pager/index.tsx +1 -1
- package/ab-drawer/gestures.ts +1 -1
- package/ab-drawer/index.tsx +3 -3
- package/ab-drawer/kit.module.css +13 -13
- package/ab-drawer/styles.module.css +2 -2
- package/ab-drawer/use-ab-edge-swipe.ts +2 -2
- package/ab-flow-diagram/helpers.ts +2 -2
- package/ab-flow-diagram/index.tsx +2 -2
- package/ab-flow-diagram/styles.module.css +3 -3
- package/ab-icon/helpers.ts +1 -1
- package/ab-icon/index.tsx +3 -3
- package/ab-icon/registrar.tsx +1 -1
- package/ab-icon-button/index.tsx +1 -1
- package/ab-install-snippet/styles.module.css +1 -1
- package/ab-link/index.tsx +2 -2
- package/ab-link/locale.ts +1 -1
- package/ab-list/styles.module.css +1 -1
- package/ab-locale-switcher/index.tsx +6 -6
- package/ab-locale-switcher/styles.module.css +5 -5
- package/ab-mobile-header/index.tsx +6 -6
- package/ab-nav-drawer/index.tsx +11 -6
- package/ab-navbar/index.tsx +1 -1
- package/ab-navbar/styles.module.css +1 -1
- package/ab-navbar/view.tsx +1 -1
- package/ab-package-card/index.tsx +3 -3
- package/ab-package-card/previews.tsx +1 -1
- package/ab-package-card/styles.module.css +2 -2
- package/ab-playground-scene/i18n.module.css +1 -1
- package/ab-playground-scene/icons.tsx +1 -1
- package/ab-playground-scene/index.tsx +4 -4
- package/ab-playground-scene/labels.ts +3 -3
- package/ab-playground-scene/scenes.tsx +4 -4
- package/ab-playground-scene/styles.module.css +6 -6
- package/ab-playground-scene/upgraded.tsx +3 -3
- package/ab-playground-scene/welcome.tsx +1 -1
- package/ab-progress-chips/index.tsx +1 -1
- package/ab-search-drawer/index.tsx +4 -4
- package/ab-search-trigger/index.tsx +5 -5
- package/ab-search-trigger/styles.module.css +3 -3
- package/ab-settings-drawer/index.tsx +2 -2
- package/ab-sidebar/active.ts +105 -0
- package/ab-sidebar/index.tsx +10 -6
- package/ab-sidebar/profile-button.tsx +2 -2
- package/ab-sidebar/styles.module.css +4 -4
- package/ab-sidebar/view.tsx +16 -8
- package/ab-theme-mode/index.tsx +3 -3
- package/ab-theme-toggle/index.tsx +6 -6
- package/ab-theme-toggle/styles.module.css +2 -2
- package/ab-toc/index.tsx +3 -3
- package/ab-toc/promo.tsx +2 -2
- package/ab-toc/styles.module.css +1 -1
- package/ab-toc-drawer/index.tsx +1 -1
- package/ab-version-switcher/index.tsx +2 -2
- package/css/dialog.css +1 -1
- package/index.ts +17 -14
- package/package.json +1 -1
- package/server/ab-button/index.tsx +1 -1
- package/server/ab-icon/index.tsx +2 -2
- package/server/ab-sidebar/index.tsx +3 -2
- package/types/index.d.ts +7 -7
|
@@ -42,7 +42,7 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
|
42
42
|
import clsx from 'clsx';
|
|
43
43
|
// 〰️ the engine: AbFlowDiagram's v6 frame mode
|
|
44
44
|
import AbFlowDiagram from '../ab-flow-diagram';
|
|
45
|
-
// 🧱
|
|
45
|
+
// 🧱 the scene data
|
|
46
46
|
import { AB_PLAYGROUND_SCENE_PACKAGES, buildAbPlaygroundCompactScene, buildAbPlaygroundFullScene } from './scenes';
|
|
47
47
|
// 🌍 labels
|
|
48
48
|
import { AB_PLAYGROUND_LOCALES, resolveAbPlaygroundSceneLabels, type AbPlaygroundSceneLabelsInput, type AbPlaygroundSceneName } from './labels';
|
|
@@ -65,10 +65,10 @@ export const AB_PLAYGROUND_FRAMES = {
|
|
|
65
65
|
|
|
66
66
|
// ⚙️ props
|
|
67
67
|
export interface AbPlaygroundSceneProps {
|
|
68
|
-
/** 🗂️ which package scene (
|
|
68
|
+
/** 🗂️ which package scene (the v6 1–7, and illustration 8 `i18n`). */
|
|
69
69
|
name: AbPlaygroundSceneName;
|
|
70
70
|
/** 📐 `'full'` = 760×600 laptop scene, `'compact'` = 350×276 mobile scene. Default `'full'`.
|
|
71
|
-
* 🆕 0.2.3
|
|
71
|
+
* 🆕 0.2.3 `'auto'` = SSR-safe: BOTH are rendered and a CSS media query shows compact below 768px
|
|
72
72
|
* and full from 768px, so phones never flash the full scene and there is no hydration mismatch (no JS decides). */
|
|
73
73
|
variant?: 'full' | 'compact' | 'auto';
|
|
74
74
|
/** ▶️ animate only while its slide is active (default true); reduced motion is always respected. */
|
|
@@ -91,7 +91,7 @@ export interface AbPlaygroundSceneProps {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* 🎨 AbPlaygroundScene — the Welcome "Live Playground" scenes from
|
|
94
|
+
* 🎨 AbPlaygroundScene — the Welcome "Live Playground" scenes from the welcome-v6 mock, faithfully: same rects,
|
|
95
95
|
* same auto-routed wires (route() + rounded()), dotted surface, anchors, travelling pulses, card + header.
|
|
96
96
|
* Server-compatible (AbFlowDiagram's tiny scale island is the only client code). One accessible image (translated alt).
|
|
97
97
|
*/
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
// 🌍 every visible WORD in the scenes (code, package names and file names stay as they are, like the mock).
|
|
40
40
|
// Pass `labels={{ ... }}` (e.g. from next-intl / the Welcome messages) to translate; missing keys fall back to English.
|
|
41
41
|
|
|
42
|
-
/** 🗂️ the 8 scene names (
|
|
43
|
-
/** 🗂️ 0.2.3
|
|
42
|
+
/** 🗂️ the 8 scene names (the v6 1–7 + illustration 8 `i18n`) */
|
|
43
|
+
/** 🗂️ 0.2.3: + `welcome` (v6 s01, every package around the Ab mark) and `all` (v6 s09, the final slide) */
|
|
44
44
|
export type AbPlaygroundSceneName = 'core' | 'components' | 'theme' | 'icons' | 'fonts' | 'animations' | 'hooks' | 'i18n' | 'welcome' | 'all';
|
|
45
45
|
|
|
46
46
|
/** 🌍 the 4 demo locales of the i18n scene, in cycle order (EN → FR → ES → RU, 0.6s each) */
|
|
@@ -83,7 +83,7 @@ export const AB_PLAYGROUND_SCENE_LABELS = {
|
|
|
83
83
|
reduceAnimations: 'reduce animations', list: 'list', stagger: 'stagger', transition: 'transition', fadeSlide: 'fade · slide',
|
|
84
84
|
// 🪝 hooks
|
|
85
85
|
keyboard: 'keyboard', storage: 'storage', copy: 'copy', hooks: 'Hooks', scrollSpy: 'scroll spy',
|
|
86
|
-
// 🌍 i18n (
|
|
86
|
+
// 🌍 i18n (the illustration 8)
|
|
87
87
|
messages: 'messages', switcher: 'switcher', translations: 'translations', provider: 'provider', prefix: 'prefix',
|
|
88
88
|
intlFormat: 'Intl format',
|
|
89
89
|
// 🎠 welcome + all (v6 s01 / s09)
|
|
@@ -46,7 +46,7 @@ import type { AbPlaygroundSceneLabels, AbPlaygroundSceneName } from './labels';
|
|
|
46
46
|
import { buildI18nCompact, buildI18nFull } from './i18n';
|
|
47
47
|
// 🎠 0.2.3: v6 s01 (welcome) + s09 (all)
|
|
48
48
|
import { buildAllCompact, buildAllFull, buildWelcomeCompact, buildWelcomeFull } from './welcome';
|
|
49
|
-
// 🎨 0.2.3
|
|
49
|
+
// 🎨 0.2.3: the upgraded package scenes
|
|
50
50
|
import { buildAnimationsUp, buildComponentsUp, buildCoreUp, buildFontsUp, buildHooksUp, buildIconsUp, buildThemeUp } from './upgraded';
|
|
51
51
|
|
|
52
52
|
// 📦 v6 PKG
|
|
@@ -68,7 +68,7 @@ const N = (x: number, y: number, w: number, h: number, content: ReactNode, capti
|
|
|
68
68
|
export function buildAbPlaygroundFullScene(name: AbPlaygroundSceneName, L: AbPlaygroundSceneLabels, logo: ReactNode, still = 0): AbPlaygroundSceneData {
|
|
69
69
|
seq = 0;
|
|
70
70
|
switch (name) {
|
|
71
|
-
// 🎨 0.2.3
|
|
71
|
+
// 🎨 0.2.3: the Welcome v6 UPGRADED scenes (playground-spec.md rev 2): real export captions,
|
|
72
72
|
// 4 states × 0.6s, reduced-motion still = state 0. Motion = ab-nextjs-animations' state cycle (upgraded.tsx)
|
|
73
73
|
case 'core': return { nodes: buildCoreUp(N, false) };
|
|
74
74
|
case 'components': return { nodes: buildComponentsUp(N, false, logo) };
|
|
@@ -79,7 +79,7 @@ export function buildAbPlaygroundFullScene(name: AbPlaygroundSceneName, L: AbPla
|
|
|
79
79
|
case 'hooks': return { nodes: buildHooksUp(N, false, logo) };
|
|
80
80
|
case 'welcome': return buildWelcomeFull(N, L, logo); // 🎠 v6 s01
|
|
81
81
|
case 'all': return buildAllFull(N, L, logo); // 🎠 v6 s09
|
|
82
|
-
default: return { nodes: buildI18nFull(N, L, still) }; // 🌍
|
|
82
|
+
default: return { nodes: buildI18nFull(N, L, still) }; // 🌍 the illustration 8 (`still` = the reduced-motion locale)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -88,7 +88,7 @@ export function buildAbPlaygroundCompactScene(name: AbPlaygroundSceneName, L: Ab
|
|
|
88
88
|
seq = 0;
|
|
89
89
|
const sc = (...n: AbFlowNode[]): AbPlaygroundSceneData => ({ nodes: n });
|
|
90
90
|
switch (name) {
|
|
91
|
-
// 🎨 0.2.3
|
|
91
|
+
// 🎨 0.2.3: upgraded mobile scenes (3 nodes + hub at y 122 / h 58; bottom caption right of the wire)
|
|
92
92
|
case 'core': return sc(...buildCoreUp(N, true));
|
|
93
93
|
case 'components': return sc(...buildComponentsUp(N, true, logo));
|
|
94
94
|
case 'theme': return sc(...buildThemeUp(N, true));
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
/* ===== AB PLAYGROUND SCENE STYLES ===== */
|
|
40
|
-
/* 🎨
|
|
40
|
+
/* 🎨 the welcome-v6 scene content classes (scenes.py css()), scoped to this module. No motion here:
|
|
41
41
|
wires, pulses and the ease dot all ride ab-nextjs-animations' wire classes (reduced motion included). */
|
|
42
|
-
/* 🎠 0.2.3
|
|
42
|
+
/* 🎠 0.2.3: the card is v6's ORIGINAL --card via theme ≥ 0.3.7 `--ab-color-welcome-card`, so the white /
|
|
43
43
|
warmer gapped-desktop card tokens never leak in (fallbacks = the v6 values) */
|
|
44
44
|
.scene { --ab-flow-card: var(--ab-color-welcome-card, #fff); }
|
|
45
45
|
:global(:is(.dark, [data-theme="dark"])) .scene { --ab-flow-card: var(--ab-color-welcome-card, #241a12); }
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
.pnode { display: flex; flex-direction: column; gap: 9px; align-items: flex-start; width: 100%; padding: 0 14px; box-sizing: border-box; } /* 📦 v6 pnode */
|
|
98
98
|
.swSm { display: block; width: 18px; height: 24px; border-radius: 5px; border: 1px solid var(--ab-flow-line, rgb(107 79 53 / 0.16)); box-sizing: border-box; } /* 🎨 */
|
|
99
99
|
.mchip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; white-space: nowrap; } /* 💊 v6 .mchip */
|
|
100
|
-
/* 🎨 0.2.3
|
|
100
|
+
/* 🎨 0.2.3 the Welcome v6 UPGRADED scenes (upgraded.tsx). Layout + colour only: every bit of motion is
|
|
101
101
|
ab-nextjs-animations' .ab-state-cycle-* (4 states × 600ms = 2.4s), which also owns the still frame + reduced motion. */
|
|
102
102
|
.scene { --ab-state-cycle-duration: var(--ab-wire-pulse-duration, 2400ms); --ab-state-cycle-on-fg: #fff8f5; --ab-state-cycle-off-fg: var(--ab-flow-muted, rgb(33 26 22 / 0.62)); --ab-state-cycle-switch-off: var(--pg-chip); --ab-state-cycle-knob-travel: 22px; }
|
|
103
103
|
.ic { display: inline-flex; flex: none; } /* 🔣 real ab-nextjs-icons SVG */
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
.cyCentre { right: 0; display: flex; justify-content: center; } /* ↔️ centred without transform (the cycle owns transform) */
|
|
108
108
|
.segCycle > span { white-space: nowrap; } /* 🎚️ chips: colours come from .ab-state-cycle-chip */
|
|
109
109
|
.wts { display: flex; gap: 2px; } /* ⭐ weight picker */
|
|
110
|
-
.wt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 4px; border-radius: 7px; border: 1px solid transparent; --ab-state-cycle-hl-border: transparent; } /* ⭐
|
|
110
|
+
.wt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 4px; border-radius: 7px; border: 1px solid transparent; --ab-state-cycle-hl-border: transparent; } /* ⭐ tint only */
|
|
111
111
|
.tog2 { width: 50px; height: 28px; border-radius: 999px; position: relative; flex: none; display: block; } /* 🔀 track (colour = the cycle) */
|
|
112
112
|
.knob { position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff8f5; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); } /* ⚪ */
|
|
113
113
|
.lpTrack { display: block; height: 4px; border-radius: 2px; background: var(--pg-chip); overflow: hidden; } /* ➖ */
|
|
@@ -137,8 +137,8 @@
|
|
|
137
137
|
.radiusTile { display: block; width: 30px; height: 28px; border: 2px solid var(--pg-bronze); box-sizing: border-box; } /* 🔲 */
|
|
138
138
|
/* 🔣 icons */
|
|
139
139
|
.icGrid { display: grid; grid-template-columns: repeat(6, 38px); gap: 8px 10px; } /* 🔣 */
|
|
140
|
-
.icCell { display: flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid transparent; box-sizing: border-box; --ab-state-cycle-hl-border: transparent; } /* 🔣
|
|
141
|
-
/* 📐 0.2.3
|
|
140
|
+
.icCell { display: flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid transparent; box-sizing: border-box; --ab-state-cycle-hl-border: transparent; } /* 🔣 tint only (his cells have no border) */
|
|
141
|
+
/* 📐 0.2.3 variant="auto": both scenes ship, CSS picks one (SSR-safe, no flash, no hydration mismatch) */
|
|
142
142
|
.auto { display: contents; } /* 🫥 no extra box */
|
|
143
143
|
.autoCompact.autoCompact { display: none; } /* 🖥️ ≥ 768px: full */
|
|
144
144
|
@media (width < 768px) {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
// 🎨 0.2.3 (
|
|
39
|
+
// 🎨 0.2.3 (the Welcome v6 "upgraded" designs): the 7 package scenes, 1:1 with
|
|
40
40
|
// ai-mocks/welcome-v6/upgraded/_src/build_upgraded.py + playground-spec.md rev 2 (real export names as captions,
|
|
41
41
|
// 4 states × 0.6s = one 2.4s loop, reduced-motion still = state 0). ALL motion = ab-nextjs-animations' state cycle.
|
|
42
42
|
|
|
@@ -65,7 +65,7 @@ import article from 'ab-nextjs-icons/ab-icons/icons/article';
|
|
|
65
65
|
// 🎨 mock content classes
|
|
66
66
|
import s from './styles.module.css';
|
|
67
67
|
|
|
68
|
-
// 🥉
|
|
68
|
+
// 🥉 the bronze
|
|
69
69
|
const BRONZE = '#A67C52';
|
|
70
70
|
// 🌍 the 4 locale chips
|
|
71
71
|
const LOC = ['EN', 'FR', 'ES', 'RU'];
|
|
@@ -236,7 +236,7 @@ export function buildIconsUp(N: AbPgMk, compact: boolean): AbFlowNode[] {
|
|
|
236
236
|
const wts: Array<[number, number]> = [[100, 0.7], [200, 1.25], [400, 1.9], [700, 2.8]];
|
|
237
237
|
return [
|
|
238
238
|
N(220, 262, 320, 124, <span className={s.icGrid}>{names.map((n, i) => cell(n, i, 22, 38))}</span>, 'abIconNames', true),
|
|
239
|
-
// ⭐
|
|
239
|
+
// ⭐ the weight picker steps with a soft highlight (his `[data-on]` has no chip fill here), same as the grid
|
|
240
240
|
N(40, 100, 210, 96, <span className={s.wts}>{wts.map(([w, sw], i) => <span key={w} {...hl(i, s.wt, 'transparent')}><Ic n="star" sz={22} sw={sw} /><span className={s.m} style={{ fontSize: 9.5 }}>{w}</span></span>)}</span>, 'abIconWeights'),
|
|
241
241
|
N(290, 112, 180, 64, <M><Br>200</Br></M>, 'abIconDefaultWeight'),
|
|
242
242
|
N(510, 104, 210, 84, <M><Br>getAbIconSvg</Br>(<Sg>"anchor"</Sg>)</M>, 'getAbIconSvg()'),
|
|
@@ -47,7 +47,7 @@ import type { AbPlaygroundSceneLabels } from './labels';
|
|
|
47
47
|
// 🎨 shared mock classes (.m, .br, .b1, .tog, .t13…)
|
|
48
48
|
import s from './styles.module.css';
|
|
49
49
|
|
|
50
|
-
// 🥉
|
|
50
|
+
// 🥉 the bronze
|
|
51
51
|
const BRONZE = '#A67C52';
|
|
52
52
|
// 🎨 v6 palette (theme swatches)
|
|
53
53
|
const PALETTE = ['#6B4F35', '#A67C52', '#D9BE9C', '#FFF8F5', '#19120C'];
|
|
@@ -68,7 +68,7 @@ export interface AbProgressChipsProps {
|
|
|
68
68
|
|
|
69
69
|
const DEFAULT_CHIPS: AbProgressChip[] = [
|
|
70
70
|
{ id: 1, code: 'A', name: 'Prep', duration: 20 },
|
|
71
|
-
{ id: 2, code: 'B', name: '
|
|
71
|
+
{ id: 2, code: 'B', name: 'Simmer', duration: 40 },
|
|
72
72
|
{ id: 3, code: 'C', name: 'Plate', duration: 15 },
|
|
73
73
|
];
|
|
74
74
|
|
|
@@ -94,7 +94,7 @@ export interface AbSearchDrawerProps {
|
|
|
94
94
|
defaultQuery?: string; // 🌱 the query on open (default '')
|
|
95
95
|
recentKey?: string | null; // 🕘 localStorage key (default `ab:search:recent`; null = no recents)
|
|
96
96
|
recentLimit?: number; // 🕘 default 4
|
|
97
|
-
recentWhen?: 'always' | 'empty'; // 🕘 'always' = above the results (
|
|
97
|
+
recentWhen?: 'always' | 'empty'; // 🕘 'always' = above the results (the frames, default); 'empty' = only with no query
|
|
98
98
|
labels?: AbSearchDrawerLabels; // 🌍
|
|
99
99
|
returnFocus?: string; // ↩️
|
|
100
100
|
id?: string; // 🆔
|
|
@@ -128,7 +128,7 @@ export function highlightAbSearch(text: string, q: string): ReactNode {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* 🔎 AbSearchDrawer —
|
|
131
|
+
* 🔎 AbSearchDrawer — the search drawer (drawers v2 §4), a bottom-drawer variant.
|
|
132
132
|
*
|
|
133
133
|
* - 📱 below 768px: straight to full height (no 70% stop: the keyboard is up); a hard swipe down closes
|
|
134
134
|
* - 💻 768px and up: centred in the main pane, min(640px, main width), 70% tall; results scroll inside with a 48px fade
|
|
@@ -149,7 +149,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
|
|
|
149
149
|
}; // 🌍
|
|
150
150
|
const auto = useId().replace(/[^A-Za-z0-9_-]/g, ''); // 🆔
|
|
151
151
|
const base = id ?? `ab-search-${auto}`;
|
|
152
|
-
// 🆔
|
|
152
|
+
// 🆔 review P2: group ids come from app data ("@scope/pkg", "a b"); keep only id-safe characters, and the index keeps them unique
|
|
153
153
|
const groupId = (g: AbSearchDrawerGroup, i: number) => `${base}-g-${i}-${String(g.id).replace(/[^A-Za-z0-9_-]/g, '_')}`;
|
|
154
154
|
const input = useRef<HTMLInputElement>(null); // 🔤
|
|
155
155
|
const list = useRef<HTMLDivElement>(null); // 📜
|
|
@@ -172,7 +172,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
|
|
|
172
172
|
const t = setTimeout(() => {
|
|
173
173
|
Promise.resolve().then(() => latest.current(q)) // 🧯 a sync throw becomes a rejection too
|
|
174
174
|
.then((g) => { if (live) { setGroups(g); setActive(g.some((x) => x.items.length) ? 0 : -1); } })
|
|
175
|
-
.catch(() => { if (live) { setGroups([]); setActive(-1); } }); // 🧯
|
|
175
|
+
.catch(() => { if (live) { setGroups([]); setActive(-1); } }); // 🧯 review P2: a failed search shows "no results", never the previous query's results
|
|
176
176
|
}, 150);
|
|
177
177
|
return () => { live = false; clearTimeout(t); };
|
|
178
178
|
}, [query, open]);
|
|
@@ -59,12 +59,12 @@ export interface AbSearchTriggerProps {
|
|
|
59
59
|
onOpen?: () => void; // 🔔 opens your search dialog (button mode)
|
|
60
60
|
href?: string; // 🔗 no onOpen → a link to a search page (also the JS-off path)
|
|
61
61
|
hotkey?: boolean; // ⌨️ listen for ⌘K / Ctrl+K (default true when onOpen is set)
|
|
62
|
-
shortcut?: boolean; // ⌨️ alias of `hotkey` (
|
|
62
|
+
shortcut?: boolean; // ⌨️ alias of `hotkey` (the spec name); `hotkey` wins when both are set
|
|
63
63
|
compact?: boolean; // 📱 icon-only pill (the label stays for screen readers), e.g. the mobile app bar
|
|
64
64
|
comingSoon?: boolean; // 🚧 visible but inert: aria-disabled, no hotkey
|
|
65
65
|
comingSoonLabel?: string; // 🏷️ default "Coming soon"
|
|
66
66
|
variant?: 'pill' | 'field'; // 🔎 0.1.14 (P6): 'field' = the Home 300×36 bordered field (default 'pill', the legacy look)
|
|
67
|
-
/** 📱 0.1.15
|
|
67
|
+
/** 📱 0.1.15: a shorter label (e.g. "Search") that a compact AbAppBar shows below 768px instead of `label`
|
|
68
68
|
* (CSS picks; only one is ever displayed, so the accessible name stays single). Home field only. */
|
|
69
69
|
compactLabel?: string;
|
|
70
70
|
size?: 'md' | 'sm' | 'lg'; // 📱 0.1.14 (P6): 'sm' = the mobile 34px "Search ⌘K" pill (label + key cap stay visible)
|
|
@@ -124,7 +124,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
124
124
|
<>
|
|
125
125
|
<AbIcon name="search" size={20} className={styles.abSearchTriggerIcon} />
|
|
126
126
|
<span className={clsx(styles.abSearchTriggerLabel, compact && styles.abSearchTriggerSrOnly)}>{label}</span>
|
|
127
|
-
{/* 🚧 coming soon tag, or ⌨️ the key hint ONLY while a hotkey is really listening (
|
|
127
|
+
{/* 🚧 coming soon tag, or ⌨️ the key hint ONLY while a hotkey is really listening (#3, D24a) */}
|
|
128
128
|
{comingSoon
|
|
129
129
|
? !compact && <span className={styles.abSearchTriggerSoon}>{comingSoonLabel}</span>
|
|
130
130
|
: listen && !compact && <AbKbd keys={[apple ? '⌘' : 'Ctrl', 'K']} className={styles.abSearchTriggerKbd} />}
|
|
@@ -133,7 +133,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
133
133
|
const common = {
|
|
134
134
|
className: clsx('AbSearchTrigger', styles.abSearchTrigger, !comingSoon && 'ab-motion-interactive', className), // 🏷️
|
|
135
135
|
'data-ab-part': 'search-trigger', // 🧩
|
|
136
|
-
'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // ♿ only announced when bound (
|
|
136
|
+
'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // ♿ only announced when bound (#3)
|
|
137
137
|
'data-compact': compact ? 'true' : undefined, // 📱
|
|
138
138
|
'data-variant': variant === 'field' ? 'field' : undefined, // 🔎 P6
|
|
139
139
|
'data-size': size === 'sm' || size === 'lg' ? size : undefined, // 📱 P6 · 🔍 404 gaps: lg
|
|
@@ -143,7 +143,7 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
|
|
|
143
143
|
// 🚧 coming soon: focusable, announced, inert
|
|
144
144
|
if (comingSoon) return <button type="button" {...common} aria-disabled="true" data-coming-soon="true">{inner}</button>;
|
|
145
145
|
// 🔗 href → ALWAYS a real link, so it works with JS off (D24a: /docs). With onOpen too, JS intercepts
|
|
146
|
-
// the click and opens the dialog instead (
|
|
146
|
+
// the click and opens the dialog instead (#4); modified clicks (new tab, …) keep the link.
|
|
147
147
|
if (href) {
|
|
148
148
|
const onClick = onOpen
|
|
149
149
|
? (e: MouseEvent<HTMLAnchorElement>) => {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
.abSearchTriggerIcon { flex: none; } /* 🔣 */
|
|
65
65
|
.abSearchTriggerSoon { font-size: 12px; opacity: 0.8; } /* 🚧 */
|
|
66
66
|
|
|
67
|
-
/* 📱 compact (
|
|
67
|
+
/* 📱 compact (#3/#16): icon-only round pill for small app bars, no overflow at 390px */
|
|
68
68
|
.abSearchTrigger[data-compact='true'] { flex: none; width: 40px; min-width: 40px; padding: 0; justify-content: center; } /* 🔘 */
|
|
69
69
|
/* 🕶️ visually hidden, still read by screen readers */
|
|
70
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; }
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-button, 10px); /* 🔲 */
|
|
77
77
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); /* 🎨 */
|
|
78
78
|
font-size: 13.5px; line-height: 1; box-shadow: var(--ab-shadow-card, 0 1px 2px rgb(33 26 22 / 0.05)); /* 🔤 🌗 */
|
|
79
|
-
flex: 0 8 auto; min-width: var(--ab-search-trigger-min-width, 160px); /* 🔎 0.4.1 (
|
|
79
|
+
flex: 0 8 auto; min-width: var(--ab-search-trigger-min-width, 160px); /* 🔎 0.4.1 (0.2.24, gap 4): its own space in a flex row; v2: shrinks first (flex-shrink 8) down to 160px, never under */
|
|
80
80
|
}
|
|
81
81
|
.abSearchTrigger[data-size='sm'] {
|
|
82
82
|
flex: none; width: auto; max-width: none; height: 34px; /* 📏 the pill still LOOKS 34px (mock) */
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* 💊 */
|
|
86
86
|
background: var(--ab-color-card, #fff); color: var(--ab-color-faint, #807062); font-size: 13px; line-height: 1; /* 🎨 🔤 */
|
|
87
87
|
}
|
|
88
|
-
/* 👆 0.3.2 (
|
|
88
|
+
/* 👆 0.3.2 (0.2.23 gaps): an invisible 44px-tall hit area around the 34px pill (0.3.3: 6px above + below), so the
|
|
89
89
|
tap target is ≥ 44px (WCAG 2.5.5) without changing the look */
|
|
90
90
|
.abSearchTrigger[data-size='sm']::after { content: ''; position: absolute; inset: -6px 0; } /* 🫥 hit area: 0.3.3 6px above + below → 46px, safely ≥ 44 */
|
|
91
91
|
.abSearchTrigger[data-variant='field']:hover, .abSearchTrigger[data-size='sm']:hover { border-color: color-mix(in srgb, var(--ab-color-accent, #a67c52) 40%, transparent); } /* 🖱️ */
|
|
@@ -86,7 +86,7 @@ export interface AbSettingsDrawerProps {
|
|
|
86
86
|
onLocaleChange: (code: string) => void; // 📣
|
|
87
87
|
labels?: AbSettingsDrawerLabels; // 🏷️
|
|
88
88
|
themes?: readonly AbSettingsTheme[]; // 🎚️ default light, dark, system
|
|
89
|
-
// 👤 0.2.1
|
|
89
|
+
// 👤 0.2.1: the account section is back, on top. `account` = signed in (avatar, name, email);
|
|
90
90
|
// signed out, pass `onSignIn` for a "Sign in" row. Neither = no section.
|
|
91
91
|
account?: AbProfileUser | null;
|
|
92
92
|
onAccount?: () => void; // 👤 tap the signed-in row (e.g. open the profile page)
|
|
@@ -117,7 +117,7 @@ function radioKeys<T>(e: KeyboardEvent, items: readonly T[], current: T, pick: (
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* ⚙️ AbSettingsDrawer —
|
|
120
|
+
* ⚙️ AbSettingsDrawer — the Settings bottom drawer (drawers v2, spec §1): the default bottom sheet, holding
|
|
121
121
|
* ACCOUNT (0.2.1, optional), THEME (a Light / Dark / System segmented radiogroup, 48px) and LANGUAGE (48px radio rows, each label in its
|
|
122
122
|
* own `lang`, the checked one tinted with a check), then optional Help / About rows (0.2.1).
|
|
123
123
|
*
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
*
|
|
27
|
+
* @project: ab-nextjs-components
|
|
28
|
+
* @name: Active nav item matching (0.5.0)
|
|
29
|
+
* @file: ab-sidebar/active.ts
|
|
30
|
+
* @type: Pure helpers (client + server)
|
|
31
|
+
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
32
|
+
*
|
|
33
|
+
* Example usage:
|
|
34
|
+
* 1+|> getAbActiveHrefs(['/docs', '/docs/x'], '/docs/x?tab=1#top') // → Set { '/docs/x' } (longest match only)
|
|
35
|
+
* 2+|> getAbActiveHrefs(['/docs', '/docs/x'], '/docs/x', { match: 'prefix' }) // → Set { '/docs', '/docs/x' }
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
40
|
+
* MOTTO: We'll always do more 😜!!!
|
|
41
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
// 🧠 no 'use client': AbSidebar (both twins) and AbNavDrawer share these, so one rule lights every nav
|
|
45
|
+
|
|
46
|
+
// 🌍 locale-prefix stripping (`/fr/docs` → `/docs`)
|
|
47
|
+
import { stripAbLocalePrefix } from '../ab-link/locale';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 🎯 How an item's href is matched against the current route.
|
|
51
|
+
*
|
|
52
|
+
* - `'best'` (default): prefix matching, but only the **longest** matching href wins, so `/docs` and
|
|
53
|
+
* `/docs/x` never light up together on `/docs/x`. On `/docs/y` (not in the list) `/docs` still lights.
|
|
54
|
+
* - `'prefix'`: every parent of the route is active (the pre-0.5.0 behaviour; can double-highlight).
|
|
55
|
+
* - `'exact'`: only the item whose href equals the route.
|
|
56
|
+
*/
|
|
57
|
+
export type AbActiveMatch = 'best' | 'prefix' | 'exact';
|
|
58
|
+
|
|
59
|
+
/** 🔗 anything with an href, plus an optional per-item override (`exact: true` = never a parent match) */
|
|
60
|
+
export interface AbActiveMatchable { href: string; exact?: boolean }
|
|
61
|
+
|
|
62
|
+
/** ⚙️ options shared by the helpers */
|
|
63
|
+
export interface AbActiveMatchOptions {
|
|
64
|
+
match?: AbActiveMatch; // 🎯 default 'best'
|
|
65
|
+
locales?: readonly string[]; // 🌍 stripped from the current route first (e.g. ['en', 'fr'])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 🧹 normalise a path: drop `?query` and `#hash`, and a trailing slash (but `/` stays `/`) */
|
|
69
|
+
export function normalizeAbHref(href: string): string {
|
|
70
|
+
const path = href.split(/[?#]/)[0] || '/'; // ✂️ query + hash (a bare "?x" is the root)
|
|
71
|
+
const trimmed = path.replace(/\/+$/, ''); // ✂️ trailing slashes
|
|
72
|
+
return trimmed === '' ? '/' : trimmed; // 🏠
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 🎯 does one href match the route? `exact` = equality only; otherwise equality or a parent segment */
|
|
76
|
+
export function matchAbHref(href: string, current: string, exact = false): boolean {
|
|
77
|
+
const h = normalizeAbHref(href); const c = normalizeAbHref(current); // 🧹 both sides
|
|
78
|
+
if (h === c) return true; // ✅ exact
|
|
79
|
+
if (exact || h === '/') return false; // 🙅 "/" only ever matches itself
|
|
80
|
+
return c.startsWith(`${h}/`); // 🌳 a whole-segment parent (`/doc` never matches `/docs`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 🥇 the set of active hrefs (normalised) among `items` for the route `current`.
|
|
85
|
+
* An item's own `exact` wins over `match`; `exact: false` on an item allows prefix matching even when `match='exact'`.
|
|
86
|
+
*/
|
|
87
|
+
export function getAbActiveHrefs(items: ReadonlyArray<AbActiveMatchable | string>, current: string | undefined, options: AbActiveMatchOptions = {}): Set<string> {
|
|
88
|
+
const out = new Set<string>(); // 📦
|
|
89
|
+
if (!current) return out; // 🚫 no route
|
|
90
|
+
const { match = 'best', locales } = options;
|
|
91
|
+
const route = stripAbLocalePrefix(current, locales); // 🌍
|
|
92
|
+
const hits = items
|
|
93
|
+
.map((it) => (typeof it === 'string' ? { href: it } : it)) // 🔁 plain strings welcome
|
|
94
|
+
.filter((it) => matchAbHref(it.href, route, it.exact ?? match === 'exact')) // 🎯 per-item override first
|
|
95
|
+
.map((it) => normalizeAbHref(it.href)); // 🧹
|
|
96
|
+
if (match !== 'best') { hits.forEach((h) => out.add(h)); return out; } // 🌳 prefix / exact: all hits
|
|
97
|
+
const longest = hits.reduce((a, h) => (h.length > a.length ? h : a), ''); // 🥇 the deepest match
|
|
98
|
+
if (longest) out.add(longest); // ✅ one href (two items sharing it both light, which is intended)
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 🌳 flatten nested items (`items` children) into one list, so a child can out-match its parent */
|
|
103
|
+
export function flattenAbNavItems<T extends AbActiveMatchable & { items?: readonly T[] }>(items: readonly T[]): T[] {
|
|
104
|
+
return items.flatMap((it) => [it, ...(it.items ? flattenAbNavItems(it.items) : [])]); // 🔁 depth-first
|
|
105
|
+
}
|
package/ab-sidebar/index.tsx
CHANGED
|
@@ -48,20 +48,23 @@
|
|
|
48
48
|
import { useState, type ReactElement } from 'react';
|
|
49
49
|
// 🧭 current route (fallback when `activeHref` is omitted)
|
|
50
50
|
import { usePathname } from 'next/navigation';
|
|
51
|
-
// 🌍 0.1.13 (
|
|
51
|
+
// 🌍 0.1.13 (#10): locale-stripped pathname
|
|
52
52
|
import { stripAbLocalePrefix, useAbLocales } from '../ab-link';
|
|
53
53
|
// 🔣 client AbIcon (built-in chevrons are always registered)
|
|
54
54
|
import AbIcon from '../ab-icon';
|
|
55
55
|
// 🖼️ shared view
|
|
56
|
-
import { AbSidebarView,
|
|
56
|
+
import { AbSidebarView, createAbSidebarActive, toAbSidebarSections, type AbSidebarBaseProps } from './view';
|
|
57
57
|
// 🎨 styles
|
|
58
58
|
import styles from './styles.module.css';
|
|
59
|
-
// 👤 0.2.1
|
|
59
|
+
// 👤 0.2.1: the bottom-left profile button (≥ 1180px, CSS)
|
|
60
60
|
import AbSidebarProfileButton, { type AbSidebarProfileButtonProps } from './profile-button';
|
|
61
61
|
|
|
62
62
|
// 📦 re-export the shared types
|
|
63
63
|
export type { AbSidebarItem, AbSidebarSection, AbSidebarLink, AbSidebarLabels } from './view';
|
|
64
|
-
export { isAbSidebarActive, toAbSidebarSections } from './view';
|
|
64
|
+
export { isAbSidebarActive, toAbSidebarSections, createAbSidebarActive } from './view';
|
|
65
|
+
// 🎯 0.5.0: the shared active-matching helpers + types (AbNavDrawer uses them too)
|
|
66
|
+
export { getAbActiveHrefs, matchAbHref, normalizeAbHref, flattenAbNavItems } from './active';
|
|
67
|
+
export type { AbActiveMatch, AbActiveMatchable, AbActiveMatchOptions } from './active';
|
|
65
68
|
export { AbSidebarProfileButton, type AbSidebarProfileButtonProps } from './profile-button';
|
|
66
69
|
|
|
67
70
|
/** ⚙️ Client props: the shared ones + collapse control. */
|
|
@@ -69,7 +72,7 @@ export interface AbSidebarProps extends AbSidebarBaseProps {
|
|
|
69
72
|
defaultCollapsed?: boolean; // 🚪 uncontrolled start
|
|
70
73
|
onCollapsedChange?: (collapsed: boolean) => void; // 🔔
|
|
71
74
|
collapsible?: boolean; // 🔘 show the collapse button (default true when sections are given)
|
|
72
|
-
// 👤 0.2.1
|
|
75
|
+
// 👤 0.2.1: opt-in; pass `user` + the AbSettingsDrawer props for a profile button at the bottom left
|
|
73
76
|
profile?: Omit<AbSidebarProfileButtonProps, 'collapsed'>;
|
|
74
77
|
collapseButtonVariant?: 'plain' | 'outlined'; // ⏪ 0.1.14 (P9): 'outlined' = 32×32 bordered `<<` / `>>` (default 'plain' chevron)
|
|
75
78
|
}
|
|
@@ -92,7 +95,8 @@ const AbSidebar = (props: AbSidebarProps): ReactElement => {
|
|
|
92
95
|
onCollapsedChange?.(next); // 🔔
|
|
93
96
|
};
|
|
94
97
|
// 🎯 legacy `page` wins, then activeHref, then the pathname
|
|
95
|
-
const
|
|
98
|
+
const isOn = createAbSidebarActive(toAbSidebarSections(props.sections, props.links), activeHref ?? pathname, props.activeMatch); // 🥇 0.5.0: deepest match by default
|
|
99
|
+
const active = (href: string, value?: string) => (page ? page === value : isOn(href));
|
|
96
100
|
// 🔘 the toggle
|
|
97
101
|
const showToggle = collapsible ?? !!props.sections?.length;
|
|
98
102
|
const toggleLabel = collapsed ? labels?.expand ?? 'Expand sidebar' : labels?.collapse ?? 'Collapse sidebar';
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* SOFTWARE.
|
|
25
25
|
*
|
|
26
26
|
* @project: ab-nextjs-components
|
|
27
|
-
* @name: AbSidebarProfileButton - Client (0.2.1
|
|
27
|
+
* @name: AbSidebarProfileButton - Client (0.2.1)
|
|
28
28
|
* @file: ab-sidebar/profile-button.tsx
|
|
29
29
|
* @type: Client Component
|
|
30
30
|
* @authors: Abraham Ukachi <abrahamukachi@gmail.com>
|
|
@@ -71,7 +71,7 @@ export interface AbSidebarProfileButtonProps extends Omit<AbSettingsDrawerProps,
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* 👤 AbSidebarProfileButton — the bottom-left sidebar control (
|
|
74
|
+
* 👤 AbSidebarProfileButton — the bottom-left sidebar control (replaces the 0.2.1-draft settings icon
|
|
75
75
|
* button): a 40px profile circle (signed out: the profile glyph; signed in: the initials on the container colour, or
|
|
76
76
|
* the photo masked to a circle) + the name when the sidebar is expanded. Tapping it opens AbSettingsDrawer.
|
|
77
77
|
*
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
text-decoration: none; /* 🚫 */
|
|
118
118
|
color: inherit; /* 🖋️ */
|
|
119
119
|
font-weight: 500; /* 🔤 */
|
|
120
|
-
/* 🔤 0.1.13 (
|
|
120
|
+
/* 🔤 0.1.13 (#15): M3 label-large, so names stop inheriting the big body size and wrapping at 280px */
|
|
121
121
|
font-family: var(--md-sys-typescale-label-large-font, inherit);
|
|
122
122
|
font-size: var(--md-sys-typescale-label-large-size, 14px);
|
|
123
123
|
line-height: var(--md-sys-typescale-label-large-line-height, 20px);
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
padding: 0; border-radius: 0; background: none; line-height: 1; /* 🧹 no chip */
|
|
176
176
|
font: 500 10.5px var(--ab-font-code, 'Roboto Mono', ui-monospace, monospace); color: var(--ab-color-faint, #807062); /* ⌨️ */
|
|
177
177
|
}
|
|
178
|
-
/* ♿
|
|
178
|
+
/* ♿ faint on --tint is 3.9:1, so on the active row the text badge takes the row's --accent-text (≥ 4.5:1 on tint) */
|
|
179
179
|
.abSidebar[data-badge='text'] .abSidebarLink[data-active='true'] .abSidebarBadge { color: inherit; }
|
|
180
180
|
/* ⏪ P9: outlined collapse, 32×32, radius 8, 1px --border, --card, --muted */
|
|
181
181
|
.abSidebarToggle[data-variant='outlined'] {
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
.abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarSections { padding-inline: 8px; }
|
|
189
189
|
.abSidebar[data-density='compact'][data-collapsed='true'] .abSidebarLink { width: 40px; height: 40px; } /* 👆 */
|
|
190
190
|
|
|
191
|
-
/* 🏷️ 0.1.15
|
|
191
|
+
/* 🏷️ 0.1.15: the tablet logo row, mock 06 `.sb-logo` = 60px, 0 20px, centred, never shrinks.
|
|
192
192
|
* Height follows core's --ab-header-height (60px at tablet) so it lines up with the main bar. */
|
|
193
193
|
.abSidebarLogo { flex: none; display: flex; align-items: center; box-sizing: border-box; height: var(--ab-header-height, 60px); padding: 0 20px; }
|
|
194
194
|
.abSidebar[data-collapsed='true'] .abSidebarLogo { justify-content: center; padding: 0; } /* 🚪 rail: centred */
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
.abSidebar[data-collapsed='true'] .abSidebarFooter { justify-content: center; } /* 🚪 rail: centred */
|
|
208
208
|
.abSidebar { min-height: 100%; } /* 📏 fill the pane so the footer can reach the bottom */
|
|
209
209
|
.abSidebar[data-density='compact'] .abSidebarFooter { padding: 8px 10px 12px; box-sizing: border-box; width: 100%; } /* 📦 compact: line up with the rows (sections pad 10px) */
|
|
210
|
-
/* 👤 0.2.1
|
|
210
|
+
/* 👤 0.2.1: the profile button: avatar (+ the name when expanded), theme tokens only */
|
|
211
211
|
.abSidebarProfile {
|
|
212
212
|
display: inline-flex; /* 📐 */
|
|
213
213
|
align-items: center; /* ↕️ */
|
package/ab-sidebar/view.tsx
CHANGED
|
@@ -46,16 +46,19 @@ import Link from '../ab-link';
|
|
|
46
46
|
import AbBalloon from '../ab-balloon';
|
|
47
47
|
// 🎨 styles
|
|
48
48
|
import styles from './styles.module.css';
|
|
49
|
+
// 🎯 0.5.0: one active-matching rule for AbSidebar + AbNavDrawer (longest match by default)
|
|
50
|
+
import { flattenAbNavItems, getAbActiveHrefs, matchAbHref, normalizeAbHref, type AbActiveMatch } from './active';
|
|
49
51
|
|
|
50
52
|
/** 🔗 One sidebar destination (G40). `items` = one level of children, shown under the parent. */
|
|
51
53
|
export interface AbSidebarItem {
|
|
52
|
-
id?: string; // 🆔 0.1.13 (
|
|
54
|
+
id?: string; // 🆔 0.1.13 (nit): stable React key when two items share an href (default: `href`)
|
|
53
55
|
href: string; // 🔗
|
|
54
56
|
icon?: string; // 🔣 AbIcons name: outlined, filled when active
|
|
55
|
-
label: ReactNode; // 🏷️ 0.1.13: any node (
|
|
57
|
+
label: ReactNode; // 🏷️ 0.1.13: any node (#15), e.g. a mono package name
|
|
56
58
|
labelText?: string; // ♿ plain-text name for the rail tooltip/aria-label when `label` isn't a string
|
|
57
59
|
badge?: ReactNode; // 🔴 e.g. "New" or a count
|
|
58
60
|
items?: AbSidebarItem[]; // 🌳 children
|
|
61
|
+
exact?: boolean; // 🎯 0.5.0: true = active on its own href only (never as a parent); false = allow parent matching even under activeMatch="exact"
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/** 🗂️ A labelled group of items. */
|
|
@@ -90,7 +93,8 @@ export interface AbSidebarBaseProps {
|
|
|
90
93
|
className?: string; // 🏷️
|
|
91
94
|
id?: string; // 🆔 the list id (aria-controls target), default "ab-sidebar-list"
|
|
92
95
|
sections?: AbSidebarSection[]; // 🗂️ G40
|
|
93
|
-
activeHref?: string; // 🎯 current route (
|
|
96
|
+
activeHref?: string; // 🎯 current route (query, hash and a trailing slash are ignored)
|
|
97
|
+
activeMatch?: AbActiveMatch; // 🎯 0.5.0: 'best' (default, deepest match only), 'prefix' (every parent too) or 'exact'
|
|
94
98
|
collapsed?: boolean; // 🚪 icon rail
|
|
95
99
|
header?: ReactNode; // 🏷️ top slot (brand, workspace switcher…)
|
|
96
100
|
labels?: AbSidebarLabels; // 🌍
|
|
@@ -99,7 +103,7 @@ export interface AbSidebarBaseProps {
|
|
|
99
103
|
density?: 'comfortable' | 'compact'; // 📏 'compact' = 32px rows, 13.5/500, 18px icons, 11px group labels
|
|
100
104
|
activeShape?: 'pill' | 'rounded'; // 🔷 'rounded' = 8px-radius --tint row (default 'pill')
|
|
101
105
|
badgeVariant?: 'chip' | 'text'; // 🏷️ 'text' = plain mono 10.5 --faint meta (e.g. a version), no chip
|
|
102
|
-
// 🏷️ 0.1.15
|
|
106
|
+
// 🏷️ 0.1.15: a 60px logo row above `header` (mock 06 `.sb-logo`). With core ≥ 0.2.1 panes it only shows
|
|
103
107
|
// where the app header is hidden (tabletHeader="main" at 768–1179); elsewhere it always shows
|
|
104
108
|
logo?: ReactNode;
|
|
105
109
|
footer?: ReactNode; // 🦶 0.2.1: a bottom slot pinned to the bottom left (e.g. AbSidebarProfileButton)
|
|
@@ -111,11 +115,15 @@ export interface AbSidebarBaseProps {
|
|
|
111
115
|
brandLabel?: string;
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
/** 🎯 Is `href` the current route, or a parent of it? */
|
|
118
|
+
/** 🎯 Is `href` the current route, or a parent of it? (single-item prefix check; lists use `getAbActiveHrefs`) */
|
|
115
119
|
export function isAbSidebarActive(href: string, activeHref?: string): boolean {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
return !!activeHref && matchAbHref(href, activeHref); // 🌳 query / hash / trailing slash tolerant since 0.5.0
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** 🎯 0.5.0: an `active(href)` checker for a whole sidebar, using `activeMatch` + each item's `exact` */
|
|
124
|
+
export function createAbSidebarActive(groups: AbSidebarSection[], current: string | undefined, match?: AbActiveMatch): (href: string) => boolean {
|
|
125
|
+
const on = getAbActiveHrefs(groups.flatMap((g) => flattenAbNavItems(g.items)), current, { match }); // 🥇 resolved once per render
|
|
126
|
+
return (href) => on.has(normalizeAbHref(href)); // ✅
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
/** 🗂️ sections, or the legacy links as one unlabelled section. */
|
package/ab-theme-mode/index.tsx
CHANGED
|
@@ -60,7 +60,7 @@ export interface AbThemeModeProviderProps {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* 🌗 AbThemeModeProvider — 0.2.3 (
|
|
63
|
+
* 🌗 AbThemeModeProvider — 0.2.3 (Welcome 0.2.21): ONE theme state for the whole app. Each AbThemeToggle
|
|
64
64
|
* (laptop sidebar, Settings sheet) and AbMobileHeader's 3-state button used to run its own engine, so they drifted
|
|
65
65
|
* across 768px. Under this provider they all read and write this one engine (still persisted under the `theme`
|
|
66
66
|
* key, still following the OS in 'system'). Put it once, high in the tree (e.g. around AbAppLayout).
|
|
@@ -80,10 +80,10 @@ export function useAbThemeModeContext(): AbThemeModeContextValue | null {
|
|
|
80
80
|
|
|
81
81
|
// 📦 exports
|
|
82
82
|
/**
|
|
83
|
-
* 🔣 0.3.2 (
|
|
83
|
+
* 🔣 0.3.2 (0.2.23 gaps): the ONE glyph per theme mode, shared by AbMobileHeader's theme button and
|
|
84
84
|
* AbThemeToggle, so the two never drift apart (AbIcons names)
|
|
85
85
|
*/
|
|
86
|
-
export const AB_THEME_MODE_ICONS: Readonly<Record<AbThemeMode, string>> = { light: 'light_mode', dark: 'dark_mode', system: 'brightness_auto' }; // 🌞 🌙 🌗🅰️ (0.3.2,
|
|
86
|
+
export const AB_THEME_MODE_ICONS: Readonly<Record<AbThemeMode, string>> = { light: 'light_mode', dark: 'dark_mode', system: 'brightness_auto' }; // 🌞 🌙 🌗🅰️ (0.3.2, brightness_auto everywhere, was 'computer')
|
|
87
87
|
/** 📏 0.3.2: the glyph size of a single theme icon button (AbMobileHeader + AbThemeToggle variant="icon") */
|
|
88
88
|
export const AB_THEME_ICON_BUTTON_GLYPH = 24; // 📐 px
|
|
89
89
|
|