@ai-matrx/tap-target 0.1.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 ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-08-29
4
+
5
+ - Created the package, ported verbatim from the Matrx frontend tap-target
6
+ system (`components/icons/TapTargetButton.tsx` + `tap-buttons.tsx` +
7
+ `TapTargetLabeled.tsx` and the `.matrx-tap-*` block of `app/globals.css`):
8
+ the 44×44 invisible ring / 28px pill geometry (32/20px group geometry),
9
+ glass/transparent/solid/destructive/group variants, inline labels, the
10
+ button/label/link trigger resolver, tooltip wiring, the ref-forwarding
11
+ `Wrap` resolver required for Radix `asChild`, and ~60 pre-composed
12
+ one-tag buttons.
13
+ - Coupling inversions (the only behavior deltas vs. the original):
14
+ - `next/link` → an injectable link component: module-level
15
+ `setTapTargetLinkComponent(Component)` plus a per-instance
16
+ `linkComponent` prop; internal hrefs fall back to a plain `<a>` when
17
+ nothing is registered; external href behavior (`target="_blank"`,
18
+ `rel="noopener noreferrer"`) unchanged. The registration lives in a
19
+ `Symbol.for` slot on `globalThis` so it is shared across the `.` /
20
+ `./buttons` bundles and the ESM/CJS boundary.
21
+ - `cn` from `@/lib/utils` → a tiny local class join, no dependency.
22
+ - `@/components/ui/tooltip` → inlined Radix wrapper on the
23
+ `@radix-ui/react-tooltip` dependency; the host-specific
24
+ `useNestedPortalContainer` is dropped (content portals to
25
+ `document.body`). `TooltipProvider` is re-exported for host mounting.
26
+ - **The CSS ships as part of the package**: the `.matrx-tap-*` geometry +
27
+ press-feedback block is exported as `./styles.css` — import once at app
28
+ root.
29
+ - Subpaths: `.` (primitives + `TapTargetLabeled` + link registration),
30
+ `./buttons` (the pre-composed set, opt-in), `./styles.css`,
31
+ `./package.json`.
32
+ - Peer `react >= 18`; dependency `@radix-ui/react-tooltip`. ESM + CommonJS
33
+ with `"use client"` stamped on built chunks; the release gate installs the
34
+ packed tarball into an empty project, loads both subpaths through both
35
+ `import` and `require`, asserts `dist/styles.css` exists and resolves, and
36
+ proves the link registration crosses the ESM/CJS boundary.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI Matrix Engine
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @ai-matrx/tap-target
2
+
3
+ The AI Matrx tap-target button system: an **invisible 44×44 touch ring** over a
4
+ **32×32 visible pill** (28px pill inside the ring; 32/20px in the slim group
5
+ geometry), with press feedback, mobile tap hygiene (no 300ms delay, no iOS gray
6
+ flash), and correct **ref forwarding for Radix `asChild` triggers**.
7
+
8
+ - **Primitives** — `TapTargetButton` (glass), `TapTargetButtonTransparent`,
9
+ `TapTargetButtonSolid`, `TapTargetButtonDestructive`,
10
+ `TapTargetButtonForGroup` + `TapTargetButtonGroup`, and the
11
+ `TapTargetLabeled` caption wrapper.
12
+ - **~60 pre-composed buttons** — `BugTapButton`, `PlusTapButton`,
13
+ `TrashTapButton`, … one import, one tag, zero configuration, all glyphs
14
+ inlined. Opt-in via the `./buttons` subpath.
15
+ - Every button can be a **button, label, or link** (`as="label"`, `href`),
16
+ carries automatic **tooltip wiring** from `ariaLabel`, and supports an
17
+ inline caption (`label`) that widens the pill.
18
+
19
+ ```bash
20
+ npm install @ai-matrx/tap-target
21
+ ```
22
+
23
+ Peer: `react >= 18`. `@radix-ui/react-tooltip` is a regular dependency
24
+ (small and behavior-critical — tooltips are part of the product).
25
+
26
+ ## Setup — two one-time steps
27
+
28
+ **1. Import the stylesheet once at your app root. The CSS is part of the
29
+ product** — the 44×44 ring / pill geometry and press feedback live in it, and
30
+ nothing renders correctly without it:
31
+
32
+ ```tsx
33
+ // app/layout.tsx (or your root entry)
34
+ import "@ai-matrx/tap-target/styles.css";
35
+ ```
36
+
37
+ Tailwind users migrating from the in-repo Matrx copy can keep their existing
38
+ `globals.css` `.matrx-tap-*` block until the C9 swap removes it — the rules are
39
+ identical; just don't load both forever.
40
+
41
+ **2. Mount a tooltip provider near the root** (skip if your app already mounts
42
+ `@radix-ui/react-tooltip`'s provider):
43
+
44
+ ```tsx
45
+ import { TooltipProvider } from "@ai-matrx/tap-target";
46
+
47
+ <TooltipProvider delayDuration={300}>{children}</TooltipProvider>
48
+ ```
49
+
50
+ ## Link component registration
51
+
52
+ `href` on any tap button renders a link. External hrefs (`http(s):`, `mailto:`,
53
+ `tel:`) always render `<a target="_blank" rel="noopener noreferrer">`. Internal
54
+ hrefs render through your router's link component — register it once at
55
+ startup:
56
+
57
+ ```tsx
58
+ import Link from "next/link";
59
+ import { setTapTargetLinkComponent } from "@ai-matrx/tap-target";
60
+
61
+ setTapTargetLinkComponent(Link); // e.g. in a client boot component
62
+ ```
63
+
64
+ Without a registration, internal hrefs fall back to a plain `<a>` (still a
65
+ working link — no prefetch, no client-side routing). A per-instance override
66
+ is also available: `<TapTargetButton href="/tasks" linkComponent={Link} />`.
67
+
68
+ ## Usage
69
+
70
+ ```tsx
71
+ import { TapTargetButton, TapTargetButtonGroup, TapTargetButtonForGroup } from "@ai-matrx/tap-target";
72
+ import { PlusTapButton, TrashTapButton } from "@ai-matrx/tap-target/buttons";
73
+
74
+ // Pre-composed (preferred): one tag, tooltip auto-derives from ariaLabel
75
+ <PlusTapButton onClick={add} ariaLabel="Add a task" />
76
+
77
+ // Variants: glass (default) | transparent | solid | group
78
+ <TrashTapButton variant="solid" bgColor="bg-destructive" iconColor="text-destructive-foreground" />
79
+
80
+ // Links
81
+ <PlusTapButton href="/tasks/new" ariaLabel="New task" />
82
+
83
+ // Inline caption (widens the pill, tooltip off — the label self-describes)
84
+ <PlusTapButton label="Add" />
85
+
86
+ // Grouped slim buttons in one shared glass shell
87
+ <TapTargetButtonGroup>
88
+ <TapTargetButtonForGroup ariaLabel="Undo" icon={<UndoIcon />} />
89
+ <TapTargetButtonForGroup ariaLabel="Redo" icon={<RedoIcon />} />
90
+ </TapTargetButtonGroup>
91
+
92
+ // Custom glyph via the primitive
93
+ <TapTargetButton ariaLabel="Custom" icon={<MyIcon className="h-4 w-4" />} />
94
+ ```
95
+
96
+ Refs forward to the underlying `<button>`, so every button works as a Radix
97
+ `asChild` trigger (DropdownMenu, Popover, Tooltip, …):
98
+
99
+ ```tsx
100
+ <DropdownMenuTrigger asChild>
101
+ <MoreHorizontalTapButton />
102
+ </DropdownMenuTrigger>
103
+ ```
104
+
105
+ ## Subpaths
106
+
107
+ | Subpath | What it is |
108
+ |---|---|
109
+ | `.` | Primitives, `TapTargetLabeled`, link registration, tooltip re-exports. |
110
+ | `./buttons` | The ~60 pre-composed buttons (heavy — every glyph inlined; opt-in). |
111
+ | `./styles.css` | The REQUIRED geometry/feedback stylesheet — import once at app root. |
112
+ | `./package.json` | The manifest. |
113
+
114
+ ## Styling notes
115
+
116
+ - Geometry and press feedback come from `styles.css` (`.matrx-tap-*`). To
117
+ retune every tap button, that file is the single source of truth — never
118
+ per-button size overrides.
119
+ - Variant **decoration** uses Tailwind-style utility classes on the pill
120
+ (`bg-primary`, `hover:bg-muted`, `text-foreground`, and the Matrx
121
+ `matrx-glass-thin-border` / `matrx-glass-interactive` glass classes). In a
122
+ Tailwind app these resolve against your theme tokens; make sure your
123
+ Tailwind build scans this package (Tailwind v4:
124
+ `@source "../node_modules/@ai-matrx/tap-target";`) and provide the two
125
+ `matrx-glass-*` classes (or accept an undecorated glass pill).
126
+ - Never wrap a tap button in extra `p-*`/`m-*`/`gap-*` — the invisible ring
127
+ already reserves the spacing.