@vendure-io/ui 1.0.5 → 1.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/README.md +49 -0
- package/package.json +3 -2
- package/src/lib/base-ui.ts +53 -0
package/README.md
CHANGED
|
@@ -29,8 +29,57 @@ import { cn } from "@vendure-io/ui/lib/utils";
|
|
|
29
29
|
| `@vendure-io/ui/components/ui/*` | shadcn/ui primitives (button, dialog, input, etc.) |
|
|
30
30
|
| `@vendure-io/ui/components/custom/*` | Vendure-specific components |
|
|
31
31
|
| `@vendure-io/ui/lib/*` | Utilities (`cn`, etc.) |
|
|
32
|
+
| `@vendure-io/ui/lib/base-ui` | `@base-ui/react` primitive namespaces (see below) |
|
|
32
33
|
| `@vendure-io/ui/hooks/*` | Shared React hooks |
|
|
33
34
|
|
|
35
|
+
## Customizing wrapper components
|
|
36
|
+
|
|
37
|
+
The components under `components/ui/*` are thin wrappers around [`@base-ui/react`](https://base-ui.com/) primitives. To override a single subcomponent (e.g. swap `DialogTitle` for one with a different font) while re-using the rest, import the underlying primitive namespace from `@vendure-io/ui/lib/base-ui` rather than from `@base-ui/react` directly:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// In your own dialog.tsx
|
|
41
|
+
import { DialogPrimitive } from "@vendure-io/ui/lib/base-ui";
|
|
42
|
+
import {
|
|
43
|
+
Dialog,
|
|
44
|
+
DialogClose,
|
|
45
|
+
DialogContent,
|
|
46
|
+
DialogDescription,
|
|
47
|
+
DialogFooter,
|
|
48
|
+
DialogHeader,
|
|
49
|
+
DialogOverlay,
|
|
50
|
+
DialogPortal,
|
|
51
|
+
DialogTrigger,
|
|
52
|
+
} from "@vendure-io/ui/components/ui/dialog";
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
Dialog,
|
|
56
|
+
DialogClose,
|
|
57
|
+
DialogContent,
|
|
58
|
+
DialogDescription,
|
|
59
|
+
DialogFooter,
|
|
60
|
+
DialogHeader,
|
|
61
|
+
DialogOverlay,
|
|
62
|
+
DialogPortal,
|
|
63
|
+
DialogTrigger,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
|
67
|
+
return (
|
|
68
|
+
<DialogPrimitive.Title
|
|
69
|
+
data-slot="dialog-title"
|
|
70
|
+
className={cn("font-display text-lg", className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Each primitive is exposed as a TypeScript namespace, so you get both the runtime component (`<DialogPrimitive.Title />`) and its prop types (`DialogPrimitive.Title.Props`) from the same import. This means you don't need `@base-ui/react` as a direct dependency in your project — `@vendure-io/ui` is the single source of truth for both wrappers and primitives.
|
|
78
|
+
|
|
79
|
+
Available primitives include `AccordionPrimitive`, `AlertDialogPrimitive`, `AvatarPrimitive`, `ButtonPrimitive`, `CheckboxPrimitive`, `CollapsiblePrimitive`, `ComboboxPrimitive`, `ContextMenuPrimitive`, `DialogPrimitive`, `InputPrimitive`, `MenuPrimitive`, `MenubarPrimitive`, `NavigationMenuPrimitive`, `PopoverPrimitive`, `PreviewCardPrimitive`, `ProgressPrimitive`, `RadioPrimitive`, `RadioGroupPrimitive`, `ScrollAreaPrimitive`, `SelectPrimitive`, `SeparatorPrimitive`, `SliderPrimitive`, `SwitchPrimitive`, `TabsPrimitive`, `TogglePrimitive`, `ToggleGroupPrimitive`, `TooltipPrimitive`, plus the `mergeProps` and `useRender` helpers.
|
|
80
|
+
|
|
81
|
+
> Where two wrappers share the same base-ui primitive (e.g. both `dialog` and `sheet` are built on `Dialog`; both `dropdown-menu` and `menubar` on `Menu`), the primitive is exposed under its canonical base-ui name only.
|
|
82
|
+
|
|
34
83
|
## License
|
|
35
84
|
|
|
36
85
|
See [LICENSE.md](../../LICENSE.md) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure-io/ui",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"directory": "packages/ui"
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
13
14
|
"exports": {
|
|
14
15
|
"./components/ui/*": "./src/components/ui/*.tsx",
|
|
15
16
|
"./components/custom/*": "./src/components/custom/*.tsx",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@base-ui/react": "^1.2.0",
|
|
47
|
-
"@vendure-io/design-tokens": "^1.1.
|
|
48
|
+
"@vendure-io/design-tokens": "^1.1.2",
|
|
48
49
|
"class-variance-authority": "^0.7.1",
|
|
49
50
|
"clsx": "^2.1.1",
|
|
50
51
|
"cmdk": "^1.1.1",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports of `@base-ui/react` primitive namespaces.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: the wrapper components in `@vendure-io/ui/components/ui/*`
|
|
5
|
+
* are intentionally thin layers over `@base-ui/react` primitives. Consumers
|
|
6
|
+
* (notably `@vendure/dashboard`) often need to override a single subcomponent
|
|
7
|
+
* — e.g. swap `DialogTitle` for one that uses a different font — while
|
|
8
|
+
* re-exporting the rest of the wrapper. To do that they need access to the
|
|
9
|
+
* underlying primitive's types and components (e.g. `Dialog.Title.Props`).
|
|
10
|
+
*
|
|
11
|
+
* Exposing the primitives here means consumers can drop `@base-ui/react` as
|
|
12
|
+
* a direct dependency entirely — `@vendure-io/ui` becomes the single source
|
|
13
|
+
* of truth for both the wrapper and the primitive substrate.
|
|
14
|
+
*
|
|
15
|
+
* Each primitive is a TS namespace, so both values (`<DialogPrimitive.Title />`)
|
|
16
|
+
* and types (`DialogPrimitive.Title.Props`) are available from the same
|
|
17
|
+
* import.
|
|
18
|
+
*
|
|
19
|
+
* Where two wrapper files share a base-ui primitive (e.g. `Dialog` is used
|
|
20
|
+
* by both `dialog.tsx` and `sheet.tsx`; `Menu` by `dropdown-menu.tsx` and
|
|
21
|
+
* `menubar.tsx`), we expose the canonical base-ui name only — they resolve
|
|
22
|
+
* to the same underlying type.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export { Accordion as AccordionPrimitive } from '@base-ui/react/accordion';
|
|
26
|
+
export { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';
|
|
27
|
+
export { Avatar as AvatarPrimitive } from '@base-ui/react/avatar';
|
|
28
|
+
export { Button as ButtonPrimitive } from '@base-ui/react/button';
|
|
29
|
+
export { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox';
|
|
30
|
+
export { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible';
|
|
31
|
+
export { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox';
|
|
32
|
+
export { ContextMenu as ContextMenuPrimitive } from '@base-ui/react/context-menu';
|
|
33
|
+
export { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
34
|
+
export { Input as InputPrimitive } from '@base-ui/react/input';
|
|
35
|
+
export { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
36
|
+
export { Menubar as MenubarPrimitive } from '@base-ui/react/menubar';
|
|
37
|
+
export { mergeProps } from '@base-ui/react/merge-props';
|
|
38
|
+
export { NavigationMenu as NavigationMenuPrimitive } from '@base-ui/react/navigation-menu';
|
|
39
|
+
export { Popover as PopoverPrimitive } from '@base-ui/react/popover';
|
|
40
|
+
export { PreviewCard as PreviewCardPrimitive } from '@base-ui/react/preview-card';
|
|
41
|
+
export { Progress as ProgressPrimitive } from '@base-ui/react/progress';
|
|
42
|
+
export { Radio as RadioPrimitive } from '@base-ui/react/radio';
|
|
43
|
+
export { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';
|
|
44
|
+
export { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area';
|
|
45
|
+
export { Select as SelectPrimitive } from '@base-ui/react/select';
|
|
46
|
+
export { Separator as SeparatorPrimitive } from '@base-ui/react/separator';
|
|
47
|
+
export { Slider as SliderPrimitive } from '@base-ui/react/slider';
|
|
48
|
+
export { Switch as SwitchPrimitive } from '@base-ui/react/switch';
|
|
49
|
+
export { Tabs as TabsPrimitive } from '@base-ui/react/tabs';
|
|
50
|
+
export { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
|
|
51
|
+
export { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group';
|
|
52
|
+
export { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
53
|
+
export { useRender } from '@base-ui/react/use-render';
|