@provex/components 1.6.2 → 1.7.0-rc.20260522201545.020a3eb
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/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/skills/components-integration/SKILL.md +110 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: components-integration
|
|
3
|
+
description: Use when integrating `@provex/components` — when adding a Tooltip that needs to portal correctly, when adding a MenuSelect that survives ancestor CSS transforms, when wiring URL-synced React state via useUrlState, when rendering the standard Card page-shell, or when extending one of the package's primitives. Covers the deliberately narrow scope of the package, the theme-agnostic Chakra pattern, the transform-anchoring gotcha behind MenuSelect's existence, and which primitives have optional peer dependencies.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `@provex/components` Integration
|
|
7
|
+
|
|
8
|
+
A small, focused set of React UI primitives shared across Provex apps. **This is not a general-purpose component library.** It exists to plug gaps the surrounding libraries (Chakra UI, recharts, react-router-dom) leave open. The API stability bar is "we don't break our own apps" — third-party integrators are welcome, but expect occasional churn.
|
|
9
|
+
|
|
10
|
+
## What's actually exported
|
|
11
|
+
|
|
12
|
+
| Component / Hook | Purpose | Why it exists |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `Tooltip` | Drop-in tooltip | Chakra v2's portal misbehaves on mobile and inside certain overflow contexts. Always use this, **never** Chakra's `Tooltip`. |
|
|
15
|
+
| `MenuSelect` | Anchored popover select | Chakra's popover positioning breaks when an ancestor has `transform: ...`. This uses `getBoundingClientRect` + absolute positioning, no transform. |
|
|
16
|
+
| `Card` | Page-shell card | Standard padding, border, surface token; pairs with `Container maxW="container.xl" px={0}` for the canonical layout. |
|
|
17
|
+
| `useUrlState` (`/url-state`) | Round-trip state through query params | Needs react-router context; subpath-imported to avoid loading react-router unless used. |
|
|
18
|
+
|
|
19
|
+
Source files in the repo also define `SubProviderSelector`, `MenuItem`, and a handful of layout helpers — check the root barrel for the current full set.
|
|
20
|
+
|
|
21
|
+
## Tooltip — don't reach for Chakra's
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Tooltip } from '@provex/components'
|
|
25
|
+
|
|
26
|
+
<Tooltip label="Explanation text">
|
|
27
|
+
<Button>Hover me</Button>
|
|
28
|
+
</Tooltip>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If you see Chakra's `Tooltip` imported anywhere in the codebase, that's a bug — replace it with this one. The recharts library also exports a `Tooltip`; always alias it:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Tooltip as RechartsTooltip } from 'recharts'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## MenuSelect — the transform gotcha
|
|
38
|
+
|
|
39
|
+
`MenuSelect` exists because `triggerRef.getBoundingClientRect()` returns *post-transform* coordinates, but child positioning that uses `transform: translateY(...)` measures from the pre-transform anchor. The result is a dropdown that lands ~`trigger.y` off when an ancestor has `transform: scale(...)`, `transform: translate(...)`, or similar.
|
|
40
|
+
|
|
41
|
+
Inside this component, anchoring is done via `bottom: -Npx` and absolute positioning — never `transform`. If you extend it or build something similar, follow the same rule.
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { MenuSelect } from '@provex/components'
|
|
45
|
+
|
|
46
|
+
<MenuSelect
|
|
47
|
+
options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]}
|
|
48
|
+
value={selected}
|
|
49
|
+
onChange={setSelected}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Card — page-shell convention
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Container, Card } from '@chakra-ui/react'
|
|
57
|
+
|
|
58
|
+
<Container maxW="container.xl" px={0}>
|
|
59
|
+
<Card>
|
|
60
|
+
{/* standalone Cards span the container; grid Cards take cell width */}
|
|
61
|
+
</Card>
|
|
62
|
+
</Container>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This is the canonical Provex page-shell. Stats and Activity pages already use it; follow the same shape when adding new pages.
|
|
66
|
+
|
|
67
|
+
## useUrlState — React Router required
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { useUrlState } from '@provex/components/url-state'
|
|
71
|
+
|
|
72
|
+
function FilterPanel() {
|
|
73
|
+
const [filter, setFilter] = useUrlState('filter', { defaultValue: 'all' })
|
|
74
|
+
// filter is reflected in the URL as ?filter=all
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Requires a `react-router-dom` context above it. If you're not using react-router, don't import `/url-state` — react-router won't be loaded.
|
|
79
|
+
|
|
80
|
+
## Peer dependencies — which are optional
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
{
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"react": "^18.3.1",
|
|
86
|
+
"@chakra-ui/react": "^2.0.0 || ^3.0.0", // optional
|
|
87
|
+
"react-router-dom": "^6.0.0 || ^7.0.0", // optional
|
|
88
|
+
"viem": "^2.0.0" // optional
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `react` is hard-required.
|
|
94
|
+
- `@chakra-ui/react` is required only for the components that render Chakra primitives (most of them). If you don't have Chakra in your app, this package won't be useful to you.
|
|
95
|
+
- `react-router-dom` is required only for `useUrlState`. Skip the subpath, skip react-router.
|
|
96
|
+
- `viem` is type-level only — used in a few prop types. Won't trigger a runtime error if absent.
|
|
97
|
+
|
|
98
|
+
## Chakra-version compatibility
|
|
99
|
+
|
|
100
|
+
The components target Chakra v2 idioms but the peer range includes v3. Some components (notably `MenuSelect`) compose Chakra primitives that shifted between v2 and v3 — if you're on v3, expect to test these surfaces specifically. The Provex monorepo is on v2 today.
|
|
101
|
+
|
|
102
|
+
## A landmine to know about: semantic-token fall-through
|
|
103
|
+
|
|
104
|
+
Chakra v2's `whiteAlpha`/`blackAlpha` scales cap at `.900`. Referencing `.950` (or any other non-existent step) resolves to `transparent` at runtime, silently. If a Provex component's hover/focus state looks invisible, check the token chain first via `var(--chakra-colors-X)` in DevTools, before assuming the component is broken.
|
|
105
|
+
|
|
106
|
+
## When NOT to import from this package
|
|
107
|
+
|
|
108
|
+
- **You're not using Chakra** → most components render Chakra primitives and will be confusing or broken.
|
|
109
|
+
- **You want a richer component library** → this package is intentionally narrow. Reach for Chakra, Radix, Mantine, etc.
|
|
110
|
+
- **You want recharts wrappers** → not here. Aliasing recharts' `Tooltip` is your responsibility per-import.
|