ab-nextjs-components 0.1.13 โ†’ 0.2.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +35 -0
  3. package/ab-app-bar/index.tsx +53 -13
  4. package/ab-app-bar/styles.module.css +68 -4
  5. package/ab-bottom-drawer/index.tsx +71 -0
  6. package/ab-bottom-drawer/styles.module.css +66 -0
  7. package/ab-breadcrumbs/index.tsx +92 -0
  8. package/ab-breadcrumbs/styles.module.css +54 -0
  9. package/ab-button/helpers.ts +6 -1
  10. package/ab-button/index.tsx +8 -2
  11. package/ab-button/styles.module.css +39 -0
  12. package/ab-card/styles.module.css +1 -1
  13. package/ab-carousel/styles.module.css +1 -1
  14. package/ab-chip/index.tsx +16 -4
  15. package/ab-chip/styles.module.css +12 -1
  16. package/ab-confirm-drawer/index.tsx +97 -0
  17. package/ab-confirm-drawer/styles.module.css +41 -0
  18. package/ab-drawer/gestures.ts +134 -0
  19. package/ab-drawer/index.tsx +458 -0
  20. package/ab-drawer/kit.module.css +204 -0
  21. package/ab-drawer/styles.module.css +166 -0
  22. package/ab-drawer/use-ab-drawer.ts +89 -0
  23. package/ab-drawer/use-ab-edge-swipe.ts +155 -0
  24. package/ab-drawer-list/index.tsx +118 -0
  25. package/ab-drawer-list/styles.module.css +65 -0
  26. package/ab-flow-diagram/styles.module.css +2 -2
  27. package/ab-icon/builtin.ts +4 -0
  28. package/ab-icon-button/index.tsx +13 -2
  29. package/ab-icon-button/styles.module.css +1 -1
  30. package/ab-install-snippet/index.tsx +51 -29
  31. package/ab-install-snippet/styles.module.css +34 -2
  32. package/ab-kbd/styles.module.css +1 -1
  33. package/ab-list/index.tsx +107 -0
  34. package/ab-list/styles.module.css +82 -0
  35. package/ab-locale-switcher/index.tsx +103 -10
  36. package/ab-locale-switcher/styles.module.css +24 -4
  37. package/ab-mobile-header/index.tsx +100 -0
  38. package/ab-nav-drawer/index.tsx +158 -0
  39. package/ab-navbar/index.tsx +1 -1
  40. package/ab-navbar/styles.module.css +20 -2
  41. package/ab-navbar/view.tsx +7 -4
  42. package/ab-package-card/index.tsx +49 -2
  43. package/ab-package-card/styles.module.css +40 -0
  44. package/ab-search-drawer/index.tsx +279 -0
  45. package/ab-search-trigger/index.tsx +22 -2
  46. package/ab-search-trigger/styles.module.css +30 -1
  47. package/ab-settings-drawer/index.tsx +160 -0
  48. package/ab-sidebar/index.tsx +6 -3
  49. package/ab-sidebar/styles.module.css +53 -5
  50. package/ab-sidebar/view.tsx +18 -4
  51. package/ab-theme-toggle/index.tsx +21 -6
  52. package/ab-theme-toggle/styles.module.css +18 -3
  53. package/ab-toc/index.tsx +9 -2
  54. package/ab-toc/styles.module.css +20 -8
  55. package/ab-toc-drawer/index.tsx +129 -0
  56. package/ab-version-switcher/index.tsx +143 -0
  57. package/ab-version-switcher/styles.module.css +76 -0
  58. package/index.ts +50 -0
  59. package/package.json +28 -3
  60. package/server/ab-button/index.tsx +6 -2
  61. package/server/ab-button/styles.module.css +39 -0
  62. package/types/index.d.ts +37 -0
@@ -0,0 +1,54 @@
1
+ /*
2
+ * @license MIT
3
+ * ~~~~~~~~~~~~
4
+ * ab-nextjs-components
5
+ * ~~~~~~~~~~~~
6
+ * Copyright (c) 2026 Abraham Ukachi. The abElements Project.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the 'Software'), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ *
26
+ * @project: ab-nextjs-components
27
+ * @name: AbBreadcrumbs styles
28
+ * @file: ab-breadcrumbs/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
+
40
+ /* ๐ŸŽš๏ธ knobs (mock .crumb; theme tokens from ab-nextjs-theme 0.3.5) */
41
+ .abCrumbs {
42
+ --ab-crumbs-color: var(--ab-color-faint, #807062); /* ๐Ÿ–‹๏ธ --faint โ™ฟ AA fallback (James) */
43
+ --ab-crumbs-current: var(--ab-color-text, var(--ab-color-on-surface, #211a16)); /* ๐Ÿ–‹๏ธ --text */
44
+ --ab-crumbs-hover: var(--ab-color-accent-text, var(--ab-color-bronze-text, #8b6340)); /* ๐Ÿ–ฑ๏ธ --accent-t */
45
+ --ab-crumbs-ring: var(--ab-color-accent, var(--ab-color-bronze, #a67c52)); /* โ™ฟ --accent */
46
+ min-width: 0; font-size: 13px; color: var(--ab-crumbs-color); /* ๐Ÿ”ค */
47
+ }
48
+ .abCrumbsList { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; min-width: 0; } /* ๐Ÿ“ */
49
+ .abCrumb { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; } /* ๐Ÿž */
50
+ .abCrumbSep { width: 16px; height: 16px; flex: none; } /* โ€บ */
51
+ .abCrumbCurrent { color: var(--ab-crumbs-current); font-weight: 650; overflow: hidden; text-overflow: ellipsis; } /* ๐ŸŽฏ */
52
+ .abCrumbLink { color: inherit; text-decoration: none; border-radius: 4px; } /* ๐Ÿ”— */
53
+ .abCrumbLink:hover { color: var(--ab-crumbs-hover); } /* ๐Ÿ–ฑ๏ธ */
54
+ .abCrumbLink:focus-visible { outline: 2px solid var(--ab-crumbs-ring); outline-offset: 2px; } /* โ™ฟ */
@@ -39,7 +39,12 @@
39
39
  // ๐ŸŽจ visual types shared by the client + server twins
40
40
  // ๐Ÿฅ‰ 'filled' (0.1.12): solid bronze, painted by ab-nextjs-theme โ‰ฅ 0.3.3's
41
41
  // `button[data-type="filled"]` rule (fallback in styles.module.css โ†’ .isFilled)
42
- export type AbButtonType = 'contained' | 'filled' | 'outlined' | 'text';
42
+ // โšช 'secondary' (0.1.14, P16): the Home "Browse packages" button: --card bg, 1px --border hairline, --text
43
+ export type AbButtonType = 'contained' | 'filled' | 'outlined' | 'text' | 'secondary';
44
+ // ๐Ÿ”ท 0.1.14 (P16): 'pill' = the legacy 999px look (default) ยท 'rounded' = the Home 10px button
45
+ export type AbButtonShape = 'pill' | 'rounded';
46
+ // ๐Ÿ“ 0.1.14 (P16): 'md' = 40px (44px under 768px, the touch CTA); undefined keeps the legacy sizing
47
+ export type AbButtonSize = 'md';
43
48
  // ๐ŸŽจ colour roles
44
49
  export type AbButtonColor = 'primary' | 'secondary' | 'tertiary' | 'white' | 'black';
45
50
  // ๐Ÿท๏ธ badge tones (G22): neutral grey or bronze accent
@@ -54,11 +54,11 @@ import {
54
54
  getAbButtonSrReason,
55
55
  type AbButtonBadgeTone,
56
56
  type AbButtonColor,
57
- type AbButtonType,
57
+ type AbButtonType, type AbButtonShape, type AbButtonSize,
58
58
  } from './helpers';
59
59
 
60
60
  // ๐Ÿ“ฆ re-export the shared types (pre-G22 import paths keep working)
61
- export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMode } from './helpers';
61
+ export type { AbButtonBadgeTone, AbButtonColor, AbButtonType, AbButtonDisabledMode, AbButtonShape, AbButtonSize } from './helpers';
62
62
 
63
63
  // โš™๏ธ props
64
64
  export interface AbButtonProps {
@@ -71,6 +71,8 @@ export interface AbButtonProps {
71
71
  style?: CSSProperties; // ๐ŸŽจ
72
72
  iconStyle?: CSSProperties; // ๐ŸŽจ Material icon style
73
73
  rounded?: boolean; // ๐Ÿ’Š
74
+ shape?: AbButtonShape; // ๐Ÿ”ท 0.1.14 (P16): 'rounded' = Home 10px radius (overrides `rounded`)
75
+ size?: AbButtonSize; // ๐Ÿ“ 0.1.14 (P16): 'md' = 40px / 44px on touch widths
74
76
  raised?: boolean; // ๐Ÿ”๏ธ
75
77
  shrinks?: boolean; // ๐Ÿค
76
78
  expands?: boolean; // ๐Ÿ”
@@ -117,6 +119,8 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
117
119
  style, // ๐ŸŽจ
118
120
  iconStyle, // ๐ŸŽจ
119
121
  rounded = true, // ๐Ÿ’Š
122
+ shape, // ๐Ÿ”ท
123
+ size, // ๐Ÿ“
120
124
  raised = false, // ๐Ÿ”๏ธ
121
125
  shrinks = false, // ๐Ÿค
122
126
  expands = false, // ๐Ÿ”
@@ -167,6 +171,8 @@ const AbButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, AbButtonProps
167
171
  'data-iconpos': iconPosition, // โ†”๏ธ
168
172
  'data-color': color, // ๐ŸŽจ
169
173
  'data-disabled-mode': mode, // ๐Ÿšฆ
174
+ 'data-shape': shape, // ๐Ÿ”ท P16 (omitted when undefined)
175
+ 'data-size': size, // ๐Ÿ“ P16
170
176
  };
171
177
 
172
178
  // ๐Ÿ”ฃ legacy Material icon (decorative)
@@ -181,3 +181,42 @@ a.abButton[data-type="outlined"] {
181
181
  line-height: 32px; /* ๐Ÿ“ */
182
182
  }
183
183
  a.abButton.abButtonRounded { border-radius: 9999px; } /* ๐Ÿ’Š */
184
+
185
+ /* ===== ๐Ÿ”ท 0.1.14 (P16, Home fidelity spec ยง4 CTAs): shape="rounded" ยท size="md" ยท type="secondary" =====
186
+ * Doubled class (0,3,0+) beats the theme's `button[data-type="filled"]` (0,1,1) and its :hover (0,3,1 โ†’ we use 0,5,0). */
187
+ .abButton.abButton[data-shape="rounded"] {
188
+ gap: 6px; /* ๐Ÿงฑ icon โ†” label */
189
+ border-radius: var(--ab-radius-button, 10px); /* ๐Ÿ”ท */
190
+ padding: 0 var(--ab-button-padding-inline, 16px); /* ๐Ÿ“ฆ */
191
+ font-size: 14px; font-weight: 650; line-height: 1; white-space: nowrap; /* ๐Ÿ”ค */
192
+ overflow: visible; /* ๐ŸŒ— the primary shadow must show */
193
+ }
194
+ .abButton.abButton[data-size="md"] { height: var(--ab-button-height, 40px); box-sizing: border-box; } /* ๐Ÿ“ */
195
+ .abButton.abButton[data-shape="rounded"] .abButtonSlot { width: 18px; height: 18px; } /* ๐Ÿ–ผ๏ธ 18px icons */
196
+ .abButton.abButton[data-shape="rounded"] .abButtonSlot svg { width: 100%; height: 100%; }
197
+ /* ๐Ÿฅ‰ primary (filled) */
198
+ .abButton.abButton[data-shape="rounded"][data-type="filled"] {
199
+ background: var(--ab-color-btn, #8b6340); color: var(--ab-color-btn-text, #fff); /* ๐ŸŽจ AA (theme 0.3.5) */
200
+ border: 0; box-shadow: var(--ab-shadow-button, 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 4px 12px rgb(139 99 64 / 0.25)); /* โœจ */
201
+ }
202
+ .abButton.abButton[data-shape="rounded"][data-type="filled"]:not(:disabled, [aria-disabled="true"]):hover {
203
+ background: color-mix(in srgb, var(--ab-color-btn, #8b6340) 90%, #000); /* ๐Ÿ–ฑ๏ธ */
204
+ }
205
+ /* โšช secondary */
206
+ .abButton.abButton[data-type="secondary"] {
207
+ border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); background: var(--ab-color-card, #fff); color: var(--ab-color-text, #211a16); /* ๐ŸŽจ */
208
+ box-sizing: border-box;
209
+ }
210
+ .abButton.abButton[data-type="secondary"]:not(:disabled, [aria-disabled="true"]):hover {
211
+ background: linear-gradient(var(--ab-color-hover, rgb(166 124 82 / 0.08)), var(--ab-color-hover, rgb(166 124 82 / 0.08))), var(--ab-color-card, #fff); /* ๐Ÿ–ฑ๏ธ tint over the card */
212
+ }
213
+ .abButton.abButton[data-shape="rounded"]:not(:disabled, [aria-disabled="true"]):active { transform: translateY(1px); } /* ๐Ÿ‘‡ */
214
+ .abButton.abButton[data-shape="rounded"]:focus-visible { outline: 2px solid var(--ab-color-accent, #a67c52); outline-offset: 2px; } /* โ™ฟ */
215
+ /* ๐Ÿ“ฑ touch widths: 44px, 14.5px (mock .M .btn; the app sets flex: 1) */
216
+ @media (max-width: 767px) {
217
+ .abButton.abButton[data-size="md"] { height: var(--ab-button-height-touch, 44px); }
218
+ .abButton.abButton[data-shape="rounded"][data-size="md"] { font-size: 14.5px; }
219
+ }
220
+ @media (prefers-reduced-motion: reduce) {
221
+ .abButton.abButton[data-shape="rounded"]:active { transform: none; } /* โ™ฟ no nudge */
222
+ }
@@ -58,7 +58,7 @@
58
58
  .abCardLink::after { content: ''; position: absolute; inset: 0; border-radius: inherit; } /* ๐Ÿงฒ whole card clickable */
59
59
  .abCard[data-linked='true']:hover { background: var(--ab-color-surface-container, rgb(0 0 0 / 0.06)); } /* ๐Ÿ–ฑ๏ธ */
60
60
  .abCard:focus-within:has(.abCardLink:focus-visible) {
61
- outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-primary, #8f4c38); /* โ™ฟ ring on the card */
61
+ outline: var(--ab-focus-ring-width, 2px) solid var(--ab-color-accent, var(--ab-color-primary, #8f4c38)); /* โ™ฟ ring on the card */
62
62
  outline-offset: var(--ab-focus-ring-offset, 2px); /* โ™ฟ */
63
63
  }
64
64
  .abCardLink:focus-visible { outline: none; } /* โ™ฟ the card shows the ring */
@@ -101,7 +101,7 @@
101
101
  /* ๐ŸŽจ hover / ๐Ÿค press motion: .ab-motion-interactive + .ab-motion-press (ab-nextjs-animations) */
102
102
  }
103
103
  .nav:hover {
104
- background-color: color-mix(in srgb, currentColor 8%, transparent); /* ๐ŸŒซ๏ธ */
104
+ background-color: var(--ab-color-hover, color-mix(in srgb, currentColor 8%, transparent)); /* ๐ŸŒซ๏ธ */
105
105
  }
106
106
  .nav[data-variant='filled'] {
107
107
  border-color: transparent;
package/ab-chip/index.tsx CHANGED
@@ -48,6 +48,8 @@ import styles from './styles.module.css';
48
48
 
49
49
  // ๐ŸŽจ dot colours
50
50
  export type AbChipDot = 'sage' | 'bronze';
51
+ // ๐ŸŽจ 0.1.14 (P16): Home chip tones ยท 'accent' = --tint bg + --accent-text ยท 'sage' = the `beta` chip
52
+ export type AbChipTone = 'neutral' | 'accent' | 'sage';
51
53
 
52
54
  // โš™๏ธ props
53
55
  export interface AbChipProps {
@@ -57,14 +59,24 @@ export interface AbChipProps {
57
59
  as?: 'span' | 'li'; // ๐Ÿงฑ 'li' inside a <ul> for lists of chips
58
60
  className?: string; // ๐Ÿท๏ธ
59
61
  style?: CSSProperties; // ๐ŸŽจ
62
+ size?: 'md' | 'sm'; // ๐Ÿ“ 0.1.14 (P16): 'sm' = the 20px Home chip (version, count, New)
63
+ shape?: 'pill' | 'rounded'; // ๐Ÿ”ท 0.1.14: 'rounded' = 6px radius (default pill)
64
+ mono?: boolean; // โŒจ๏ธ 0.1.14: Roboto Mono 11/600 (versions, package names)
65
+ tone?: AbChipTone; // ๐ŸŽจ 0.1.14 (default 'neutral' = the legacy outline chip)
60
66
  }
61
67
 
62
68
  /** ๐Ÿท๏ธ Static chip: plain text, never interactive (use AbButton for actions). */
63
- export function AbChip({ children, dot, icon, as: Tag = 'span', className, style }: AbChipProps): ReactElement {
64
- const tone = dot === true ? 'bronze' : dot || undefined; // ๐ŸŽจ resolve dot colour
69
+ export function AbChip({ children, dot, icon, as: Tag = 'span', className, style, size = 'md', shape = 'pill', mono = false, tone = 'neutral' }: AbChipProps): ReactElement {
70
+ const dotTone = dot === true ? 'bronze' : dot || undefined; // ๐ŸŽจ resolve dot colour
65
71
  return (
66
- <Tag className={clsx('AbChip', styles.chip, className)} style={style} data-ab-part="chip">
67
- {tone ? <span className={styles.dot} data-tone={tone} aria-hidden="true" /> : null /* ๐ŸŸข decorative */}
72
+ <Tag
73
+ className={clsx('AbChip', styles.chip, mono && styles.mono, className)} style={style} data-ab-part="chip"
74
+ data-size={size === 'sm' ? 'sm' : undefined} // ๐Ÿ“ P16
75
+ data-shape={shape === 'rounded' ? 'rounded' : undefined} // ๐Ÿ”ท
76
+ data-tone={tone === 'neutral' ? undefined : tone} // ๐ŸŽจ
77
+ data-mono={mono ? 'true' : undefined} // โŒจ๏ธ
78
+ >
79
+ {dotTone ? <span className={styles.dot} data-tone={dotTone} aria-hidden="true" /> : null /* ๐ŸŸข decorative */}
68
80
  {icon ? <span className={styles.icon} aria-hidden="true">{icon}</span> : null /* ๐Ÿ–ผ๏ธ decorative */}
69
81
  <span>{children}</span>
70
82
  </Tag>
@@ -43,7 +43,7 @@
43
43
  gap: 0.375rem; /* ๐Ÿงฑ */
44
44
  padding: 0.25rem 0.75rem; /* ๐Ÿงฑ */
45
45
  border-radius: 9999px; /* ๐Ÿ’Š */
46
- border: 1px solid var(--ab-color-outline-variant, rgb(0 0 0 / 0.12)); /* ๐Ÿ–Š๏ธ */
46
+ border: 1px solid var(--ab-color-border, var(--ab-color-outline-variant, rgb(0 0 0 / 0.12))); /* ๐Ÿ–Š๏ธ */
47
47
  background: var(--ab-color-surface-container, transparent); /* ๐ŸŽจ */
48
48
  color: var(--ab-color-on-surface, currentColor); /* ๐ŸŽจ */
49
49
  font-size: 0.875rem; /* ๐Ÿ”ก */
@@ -85,3 +85,14 @@
85
85
  width: 1em; /* ๐Ÿ“ */
86
86
  height: 1em; /* ๐Ÿ“ */
87
87
  }
88
+
89
+ /* ===== ๐Ÿ  0.1.14 (P16, Home spec ยง2/ยง4): size="sm" ยท shape="rounded" ยท mono ยท tone ===== */
90
+ .chip[data-size='sm'] {
91
+ height: var(--ab-chip-height, 20px); box-sizing: border-box; /* ๐Ÿ“ */
92
+ padding: 0 var(--ab-chip-padding-inline, 7px); gap: 4px; /* ๐Ÿ“ฆ */
93
+ border: 0; font-size: 11px; font-weight: 600; line-height: 1; /* ๐Ÿ”ค mock .chip */
94
+ }
95
+ .chip[data-shape='rounded'] { border-radius: var(--ab-radius-chip, 6px); } /* ๐Ÿ”ท */
96
+ .chip[data-mono='true'] { font-family: var(--ab-font-code, 'Roboto Mono', ui-monospace, monospace); } /* โŒจ๏ธ */
97
+ .chip[data-tone='accent'] { background: var(--ab-color-tint, #f4e7db); color: var(--ab-color-accent-text, #88603d); border-color: transparent; } /* ๐Ÿฅ‰ */
98
+ .chip[data-tone='sage'] { background: rgb(119 141 121 / 0.12); color: var(--ab-color-sage-accent, #566a58); border-color: transparent; } /* ๐ŸŒฟ beta โ™ฟ AA (John): fallback = theme 0.3.5 light value */
@@ -0,0 +1,97 @@
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: AbConfirmDrawer (G53 preset)
28
+ * @file: ab-confirm-drawer/index.tsx
29
+ * @type: Client component
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ *
32
+ * Example usage:
33
+ * 1+|> <AbConfirmDrawer scope="main" open={d.open} onClose={d.close} title="Discard changes?"
34
+ * -|> message="Your edits will be lost." confirmLabel="Discard" tone="danger" onConfirm={discard} />
35
+ */
36
+
37
+ /*
38
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
40
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ */
42
+
43
+
44
+ 'use client';
45
+
46
+ // โš›๏ธ React
47
+ import type { ReactElement, ReactNode } from 'react';
48
+ // ๐Ÿงต classes
49
+ import clsx from 'clsx';
50
+ // ๐Ÿ—„๏ธ the drawer
51
+ import AbDrawer, { type AbDrawerProps } from '../ab-drawer';
52
+ // ๐Ÿ”˜ the house buttons
53
+ import AbButton from '../ab-button';
54
+ // ๐ŸŽจ styles
55
+ import styles from './styles.module.css';
56
+
57
+ /** โš™๏ธ props: every AbDrawer prop (minus children / footer), plus the decision */
58
+ export interface AbConfirmDrawerProps extends Omit<AbDrawerProps, 'children' | 'footer'> {
59
+ message?: ReactNode; // ๐Ÿ“ what happens if you confirm
60
+ confirmLabel?: string; // โœ… default "Confirm"
61
+ cancelLabel?: string; // โŒ default "Cancel"
62
+ onConfirm: () => void; // โœ… the drawer closes after it (unless `closeOnConfirm={false}`)
63
+ onCancel?: () => void; // โŒ default: just close
64
+ tone?: 'default' | 'danger'; // ๐ŸŽจ `danger` = destructive confirm
65
+ busy?: boolean; // โณ disables both buttons + spinner on confirm
66
+ closeOnConfirm?: boolean; // ๐Ÿšช default true
67
+ }
68
+
69
+ /**
70
+ * โ“ AbConfirmDrawer โ€” a yes / no decision that belongs to a region (e.g. "Discard changes?" inside main).
71
+ * Defaults to `side="bottom"`; Escape / scrim / close = cancel. For an app-wide blocking decision use a
72
+ * centred dialog instead (layout-rule guide, "Drawer, menu or dialog?").
73
+ */
74
+ const AbConfirmDrawer = ({ message, confirmLabel = 'Confirm', cancelLabel = 'Cancel', onConfirm, onCancel, tone = 'default', busy = false, closeOnConfirm = true, onClose, className, side = 'bottom', ...drawer }: AbConfirmDrawerProps): ReactElement => {
75
+ const cancel = () => { onCancel?.(); onClose(); }; // โŒ then ๐Ÿšช
76
+ const confirm = () => { onConfirm(); if (closeOnConfirm) onClose(); }; // โœ… then ๐Ÿšช
77
+ return (
78
+ <AbDrawer
79
+ {...drawer}
80
+ side={side}
81
+ onClose={cancel} // โŽ‹ Escape / scrim / โœ• all mean "no"
82
+ className={clsx('AbConfirmDrawer', className)}
83
+ footer={
84
+ <>
85
+ <AbButton type="text" label={cancelLabel} onClick={cancel} disabled={busy} />
86
+ <AbButton type="filled" label={confirmLabel} onClick={confirm} isLoading={busy} disabled={busy} className={tone === 'danger' ? styles.abConfirmDanger : undefined} />
87
+ </>
88
+ }
89
+ >
90
+ {message != null && <div className={styles.abConfirmMessage} data-ab-part="confirm-message">{message}</div>}
91
+ </AbDrawer>
92
+ );
93
+ };
94
+
95
+ // ๐Ÿ“ฆ exports
96
+ export default AbConfirmDrawer;
97
+ export { AbConfirmDrawer };
@@ -0,0 +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: AbConfirmDrawer styles
28
+ * @file: ab-confirm-drawer/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
+
40
+ .abConfirmMessage { margin: 0; line-height: 1.5; } /* ๐Ÿ“ */
41
+ .abConfirmDanger { --ab-button-background-color: var(--ab-color-error, #b3261e); --ab-button-text-color: var(--ab-color-on-error, #fff); } /* ๐Ÿšจ destructive */
@@ -0,0 +1,134 @@
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: AbDrawer gestures
28
+ * @file: ab-drawer/gestures.ts
29
+ * @type: TypeScript โ€” pure swipe / snap resolvers
30
+ * @authors: Abraham Ukachi <abrahamukachi@gmail.com>
31
+ */
32
+
33
+ /*
34
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
35
+ * MOTTO: We'll always do more ๐Ÿ˜œ!!!
36
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37
+ */
38
+
39
+ // ๐Ÿค drawers v2 (John, God 01:22): the thresholds and decisions behind every drawer swipe, as pure functions,
40
+ // so the rules are unit-tested without a DOM and the components only feed them numbers.
41
+
42
+ /** ๐ŸŽš๏ธ the spec numbers (drawer-spec.md "Gestures" + "Edge zones") */
43
+ export const AB_SWIPE = {
44
+ ratio: 0.3, // ๐Ÿ“ 30% of the travel / sheet / drawer width
45
+ velocity: 0.5, // โšก px per ms: at or above this a release counts as a fast swipe
46
+ edge: 24, // ๐Ÿงฑ edge zone width (px) for the side-drawer swipes
47
+ standaloneInset: 16, // ๐Ÿ“ฑ iOS standalone: the zone starts 16px in (the system owns the very edge)
48
+ slop: 8, // ๐Ÿซณ px of movement before a press becomes a drag (taps stay taps)
49
+ secondSwipe: 24, // โœŒ๏ธ px: after a gentle return to S1, a swipe down this long closes (the "second swipe")
50
+ } as const;
51
+
52
+ /** ๐Ÿงฒ bottom-sheet snap states: S1 (`partial`, 70%), S2 (`full`) or gone */
53
+ export type AbSheetSnap = 'partial' | 'full';
54
+ /** ๐Ÿ what a release resolves to */
55
+ export type AbSheetRelease = AbSheetSnap | 'closed';
56
+
57
+ /** ๐Ÿ“ฅ one release of a bottom-sheet drag */
58
+ export interface AbSheetReleaseInput {
59
+ from: AbSheetSnap; // ๐Ÿงฒ where the drag started
60
+ dy: number; // โ†•๏ธ total movement, + = down
61
+ velocity: number; // โšก px/ms at release, + = down
62
+ partialHeight: number; // ๐Ÿ“ S1 height (70% of the app height)
63
+ fullHeight: number; // ๐Ÿ“ S2 height (app height minus the safe-area top)
64
+ returned?: boolean; // โœŒ๏ธ the sheet came back to S1 from S2 with a gentle drag (so the next swipe down closes)
65
+ }
66
+
67
+ /**
68
+ * ๐Ÿงฒ resolveAbSheetRelease โ€” where a released bottom sheet goes (spec ยง1 "Gestures"):
69
+ * - โฌ†๏ธ up past 30% of S1โ†’S2, or faster than 0.5px/ms โ†’ `full`
70
+ * - โฌ‡๏ธ at S2: fast (โ‰ฅ 0.5px/ms) or past 30% of the sheet โ†’ `closed`; a gentle drag โ†’ back to `partial`
71
+ * - โฌ‡๏ธ at S1: fast or past 30% of S1 โ†’ `closed`; after a gentle return from S2 any real swipe down (โ‰ฅ 24px) โ†’ `closed`
72
+ * - otherwise it springs back to where it was
73
+ */
74
+ export function resolveAbSheetRelease({ from, dy, velocity, partialHeight, fullHeight, returned = false }: AbSheetReleaseInput): AbSheetRelease {
75
+ const fast = Math.abs(velocity) >= AB_SWIPE.velocity; // โšก
76
+ if (dy < 0) { // โฌ†๏ธ up
77
+ if (from === 'full') return 'full'; // ๐Ÿงฑ already at the top
78
+ const travel = Math.max(1, fullHeight - partialHeight); // ๐Ÿ“ S1 โ†’ S2 distance
79
+ return -dy > AB_SWIPE.ratio * travel || (fast && velocity < 0) ? 'full' : 'partial'; // ๐Ÿงฒ
80
+ }
81
+ if (from === 'full') { // โฌ‡๏ธ from S2
82
+ if ((fast && velocity > 0) || dy > AB_SWIPE.ratio * fullHeight) return 'closed'; // ๐Ÿ’จ hard swipe
83
+ return dy > AB_SWIPE.slop ? 'partial' : 'full'; // ๐Ÿซณ gentle โ†’ S1 (a tap jitter stays at S2)
84
+ }
85
+ // โฌ‡๏ธ from S1
86
+ if ((fast && velocity > 0) || dy > AB_SWIPE.ratio * partialHeight) return 'closed'; // ๐Ÿ’จ
87
+ if (returned && dy >= AB_SWIPE.secondSwipe) return 'closed'; // โœŒ๏ธ the second swipe
88
+ return 'partial'; // ๐Ÿงฒ spring back
89
+ }
90
+
91
+ /** ๐Ÿ“ฅ one release of a side-drawer swipe (edge swipe to open, or a swipe on the sheet to close) */
92
+ export interface AbSideReleaseInput {
93
+ distance: number; // โ†”๏ธ movement in the opening / closing direction (px, + = that way)
94
+ velocity: number; // โšก px/ms in that same direction
95
+ width: number; // ๐Ÿ“ the drawer width (320 left, 296 right)
96
+ }
97
+
98
+ /** โ†”๏ธ resolveAbSideRelease โ€” does a side swipe commit? Past 30% of the width, or faster than 0.5px/ms that way. */
99
+ export function resolveAbSideRelease({ distance, velocity, width }: AbSideReleaseInput): boolean {
100
+ if (distance <= 0) return false; // ๐Ÿšซ wrong way (or nowhere)
101
+ return distance > AB_SWIPE.ratio * width || velocity >= AB_SWIPE.velocity; // โœ…
102
+ }
103
+
104
+ /** ๐Ÿงฑ isInAbEdgeZone โ€” does a press at `x` start inside the `edge` zone of a box [left, right]? */
105
+ export function isInAbEdgeZone(x: number, edge: 'left' | 'right', box: { left: number; right: number }, standalone = false): boolean {
106
+ const inset = standalone ? AB_SWIPE.standaloneInset : 0; // ๐Ÿ“ฑ iOS standalone: 16px in
107
+ const d = edge === 'left' ? x - box.left : box.right - x; // ๐Ÿ“ distance from that edge
108
+ return d >= inset && d <= inset + AB_SWIPE.edge; // ๐ŸŽฏ
109
+ }
110
+
111
+ /** โšก a tiny velocity tracker: feed it samples, read px/ms over the last ~100ms */
112
+ export function createAbVelocityTracker(windowMs = 100): { add: (pos: number, t: number) => void; velocity: () => number; reset: () => void } {
113
+ let samples: Array<[number, number]> = []; // ๐Ÿงบ [pos, time]
114
+ return {
115
+ add(pos, t) { samples.push([pos, t]); samples = samples.filter(([, ts]) => t - ts <= windowMs); }, // โž• keep the window
116
+ velocity() {
117
+ if (samples.length < 2) return 0; // ๐Ÿซฅ
118
+ const [p0, t0] = samples[0]; const [p1, t1] = samples[samples.length - 1]; // ๐Ÿ“ first / last
119
+ return t1 > t0 ? (p1 - p0) / (t1 - t0) : 0; // โšก
120
+ },
121
+ reset() { samples = []; }, // ๐Ÿงน
122
+ };
123
+ }
124
+
125
+ /** ๐ŸŽ  isInAbHorizontalScroller โ€” is `el` inside something that scrolls sideways (a code block, a carousel)?
126
+ * Edge swipes started there are ignored, so they never fight the user's horizontal scroll. */
127
+ export function isInAbHorizontalScroller(el: Element | null, stop?: Element | null): boolean {
128
+ for (let n = el; n && n !== stop && n !== document.documentElement; n = n.parentElement) {
129
+ if (n.closest('[data-ab-no-edge-swipe]') === n) return true; // ๐Ÿ™… explicit opt-out
130
+ const ox = getComputedStyle(n).overflowX; // ๐Ÿ”Ž
131
+ if ((ox === 'auto' || ox === 'scroll') && n.scrollWidth > n.clientWidth) return true; // ๐ŸŽ 
132
+ }
133
+ return false;
134
+ }