@eml-payments/ui-kit 0.1.7 → 0.1.8
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 +149 -3
- package/dist/src/components/Button/Button.d.ts +3 -0
- package/dist/src/components/Button/Button.js +11 -0
- package/dist/{components → src/components}/Button/Button.types.d.ts +1 -1
- package/dist/{components/Button/Button.d.ts → src/components/Button/ButtonVariants.d.ts} +0 -3
- package/dist/{components/Button/Button.js → src/components/Button/ButtonVariants.js} +0 -9
- package/dist/{components → src/components}/Checkbox/Checkbox.d.ts +1 -1
- package/dist/{components → src/components}/Checkbox/Checkbox.js +1 -3
- package/dist/{components → src/components}/Checkbox/Checkbox.types.d.ts +2 -2
- package/dist/{components → src/components}/Divider/Divider.d.ts +1 -1
- package/dist/{components → src/components}/Ellipsis/Ellipsis.d.ts +1 -1
- package/dist/{components → src/components}/Ellipsis/Ellipsis.functions.js +2 -1
- package/dist/{components → src/components}/Input/Input.d.ts +1 -1
- package/dist/{components → src/components}/Input/Input.js +2 -1
- package/dist/{components → src/components}/Input/Input.types.d.ts +1 -1
- package/dist/{components → src/components}/Label/Label.types.d.ts +2 -1
- package/dist/src/components/Pills/Pills.d.ts +2 -0
- package/dist/src/components/Pills/Pills.js +31 -0
- package/dist/src/components/Pills/Pills.stories.d.ts +14 -0
- package/dist/src/components/Pills/Pills.stories.js +76 -0
- package/dist/src/components/Pills/Pills.types.d.ts +9 -0
- package/dist/src/components/Pills/index.d.ts +2 -0
- package/dist/src/components/Pills/index.js +2 -0
- package/dist/{components → src/components}/RadioGroup/RadioGroup.js +1 -1
- package/dist/src/components/RadioGroup/RadioGroup.types.d.ts +5 -0
- package/dist/src/components/Select/Select.d.ts +14 -0
- package/dist/src/components/Select/Select.js +25 -0
- package/dist/src/components/Select/Select.stories.d.ts +10 -0
- package/dist/src/components/Select/Select.stories.js +33 -0
- package/dist/src/components/Select/Select.types.d.ts +11 -0
- package/dist/src/components/Select/index.d.ts +2 -0
- package/dist/src/components/Select/index.js +2 -0
- package/dist/src/components/SelectWrapper/SelectWrapper.d.ts +2 -0
- package/dist/src/components/SelectWrapper/SelectWrapper.js +8 -0
- package/dist/src/components/SelectWrapper/SelectWrapper.stories.d.ts +12 -0
- package/dist/src/components/SelectWrapper/SelectWrapper.stories.js +83 -0
- package/dist/src/components/SelectWrapper/SelectWrapper.types.d.ts +15 -0
- package/dist/src/components/SelectWrapper/index.d.ts +2 -0
- package/dist/src/components/SelectWrapper/index.js +2 -0
- package/dist/src/components/SelectWrapper/select.d.ts +13 -0
- package/dist/src/components/SelectWrapper/select.js +25 -0
- package/dist/{components → src/components}/Switch/Switch.d.ts +1 -1
- package/dist/{components → src/components}/Switch/Switch.js +15 -15
- package/dist/{components → src/components}/Switch/Switch.types.d.ts +2 -2
- package/dist/src/components/Table/Pagination/PaginationControls.d.ts +2 -0
- package/dist/src/components/Table/Pagination/PaginationControls.js +11 -0
- package/dist/src/components/Table/Pagination/PaginationControls.types.d.ts +9 -0
- package/dist/src/components/Table/Pagination/PaginationControls.types.js +1 -0
- package/dist/src/components/Table/Pagination/index.d.ts +2 -0
- package/dist/src/components/Table/Pagination/index.js +2 -0
- package/dist/src/components/Table/Table.d.ts +4 -0
- package/dist/src/components/Table/Table.js +32 -0
- package/dist/src/components/Table/Table.stories.d.ts +20 -0
- package/dist/src/components/Table/Table.stories.js +75 -0
- package/dist/src/components/Table/Table.types.d.ts +22 -0
- package/dist/src/components/Table/Table.types.js +1 -0
- package/dist/src/components/Table/hooks/useTableController.d.ts +13 -0
- package/dist/src/components/Table/hooks/useTableController.js +69 -0
- package/dist/src/components/Table/table.helpers.d.ts +4 -0
- package/dist/src/components/Table/table.helpers.js +24 -0
- package/dist/{components → src/components}/Tooltip/Tooltip.stories.d.ts +2 -2
- package/dist/{components → src/components}/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/src/components/Tooltip/Tooltip.types.js +1 -0
- package/dist/src/components/index.d.ts +10 -0
- package/dist/src/components/index.js +10 -0
- package/dist/src/config/defaultTheme.d.ts +2 -0
- package/dist/{config → src/config}/uikitConfig.d.ts +1 -1
- package/dist/src/config/uikitConfig.js +1 -0
- package/dist/{context → src/context}/UIKitContext.d.ts +1 -1
- package/dist/src/context/UIKitProvider.d.ts +5 -0
- package/dist/{context → src/context}/UIKitProvider.js +8 -4
- package/dist/{index.d.ts → src/index.d.ts} +1 -3
- package/dist/{index.js → src/index.js} +1 -3
- package/dist/src/lib/utils.d.ts +2 -0
- package/dist/src/lib/utils.js +5 -0
- package/package.json +21 -3
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +0 -5
- package/dist/components/Table/Table.d.ts +0 -36
- package/dist/components/Table/Table.js +0 -120
- package/dist/components/Table/Table.stories.d.ts +0 -9
- package/dist/components/Table/Table.stories.js +0 -19
- package/dist/components/Table/Table.types.d.ts +0 -4
- package/dist/config/defaultTheme.d.ts +0 -2
- package/dist/context/UIKitProvider.d.ts +0 -5
- package/dist/index.css +0 -1
- package/dist/stories/Header.stories.d.ts +0 -18
- package/dist/stories/Header.stories.js +0 -26
- package/dist/stories/Page.stories.d.ts +0 -12
- package/dist/stories/Page.stories.js +0 -24
- /package/dist/{components → src/components}/Button/Button.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Button/Button.stories.js +0 -0
- /package/dist/{components → src/components}/Button/Button.types.js +0 -0
- /package/dist/{components → src/components}/Button/index.d.ts +0 -0
- /package/dist/{components → src/components}/Button/index.js +0 -0
- /package/dist/{components → src/components}/Checkbox/Checkbox.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Checkbox/Checkbox.stories.js +0 -0
- /package/dist/{components → src/components}/Checkbox/Checkbox.types.js +0 -0
- /package/dist/{components → src/components}/Checkbox/index.d.ts +0 -0
- /package/dist/{components → src/components}/Checkbox/index.js +0 -0
- /package/dist/{components → src/components}/Divider/Divider.js +0 -0
- /package/dist/{components → src/components}/Divider/Divider.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Divider/Divider.stories.js +0 -0
- /package/dist/{components → src/components}/Divider/Divider.types.d.ts +0 -0
- /package/dist/{components → src/components}/Divider/Divider.types.js +0 -0
- /package/dist/{components → src/components}/Divider/index.d.ts +0 -0
- /package/dist/{components → src/components}/Divider/index.js +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.functions.d.ts +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.js +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.stories.js +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.types.d.ts +0 -0
- /package/dist/{components → src/components}/Ellipsis/Ellipsis.types.js +0 -0
- /package/dist/{components → src/components}/Ellipsis/index.d.ts +0 -0
- /package/dist/{components → src/components}/Ellipsis/index.js +0 -0
- /package/dist/{components → src/components}/Input/Input.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Input/Input.stories.js +0 -0
- /package/dist/{components → src/components}/Input/Input.types.js +0 -0
- /package/dist/{components → src/components}/Input/index.d.ts +0 -0
- /package/dist/{components → src/components}/Input/index.js +0 -0
- /package/dist/{components → src/components}/Label/Label.d.ts +0 -0
- /package/dist/{components → src/components}/Label/Label.js +0 -0
- /package/dist/{components → src/components}/Label/Label.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Label/Label.stories.js +0 -0
- /package/dist/{components → src/components}/Label/Label.types.js +0 -0
- /package/dist/{components → src/components}/Label/index.d.ts +0 -0
- /package/dist/{components → src/components}/Label/index.js +0 -0
- /package/dist/{components/RadioGroup/RadioGroup.types.js → src/components/Pills/Pills.types.js} +0 -0
- /package/dist/{components → src/components}/RadioGroup/RadioGroup.d.ts +0 -0
- /package/dist/{components → src/components}/RadioGroup/RadioGroup.stories.d.ts +0 -0
- /package/dist/{components → src/components}/RadioGroup/RadioGroup.stories.js +0 -0
- /package/dist/{components/Switch/Switch.types.js → src/components/RadioGroup/RadioGroup.types.js} +0 -0
- /package/dist/{components → src/components}/RadioGroup/index.d.ts +0 -0
- /package/dist/{components → src/components}/RadioGroup/index.js +0 -0
- /package/dist/{components/Table/Table.types.js → src/components/Select/Select.types.js} +0 -0
- /package/dist/{components/Tooltip/Tooltip.types.js → src/components/SelectWrapper/SelectWrapper.types.js} +0 -0
- /package/dist/{components → src/components}/Switch/Switch.stories.d.ts +0 -0
- /package/dist/{components → src/components}/Switch/Switch.stories.js +0 -0
- /package/dist/{config/uikitConfig.js → src/components/Switch/Switch.types.js} +0 -0
- /package/dist/{components → src/components}/Switch/index.d.ts +0 -0
- /package/dist/{components → src/components}/Switch/index.js +0 -0
- /package/dist/{components → src/components}/Table/index.d.ts +0 -0
- /package/dist/{components → src/components}/Table/index.js +0 -0
- /package/dist/{components → src/components}/Tooltip/Tooltip.d.ts +0 -0
- /package/dist/{components → src/components}/Tooltip/Tooltip.js +0 -0
- /package/dist/{components → src/components}/Tooltip/Tooltip.stories.js +0 -0
- /package/dist/{components → src/components}/Tooltip/index.d.ts +0 -0
- /package/dist/{components → src/components}/Tooltip/index.js +0 -0
- /package/dist/{config → src/config}/defaultTheme.js +0 -0
- /package/dist/{config → src/config}/index.d.ts +0 -0
- /package/dist/{config → src/config}/index.js +0 -0
- /package/dist/{context → src/context}/UIKitContext.js +0 -0
- /package/dist/{context → src/context}/useUIKitTheme.d.ts +0 -0
- /package/dist/{context → src/context}/useUIKitTheme.js +0 -0
- /package/dist/{hooks → src/hooks}/useToggle.d.ts +0 -0
- /package/dist/{hooks → src/hooks}/useToggle.js +0 -0
- /package/dist/{stories → src/stories}/Header.d.ts +0 -0
- /package/dist/{stories → src/stories}/Header.js +0 -0
- /package/dist/{stories → src/stories}/Page.d.ts +0 -0
- /package/dist/{stories → src/stories}/Page.js +0 -0
- /package/dist/{types → src/types}/index.d.ts +0 -0
- /package/dist/{types → src/types}/index.js +0 -0
- /package/dist/{utils → src/utils}/classNames.d.ts +0 -0
- /package/dist/{utils → src/utils}/classNames.js +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
|
|
2
|
+
# @eml-payments/ui-kit
|
|
3
|
+
|
|
4
|
+
A fully-typed, design token-driven React UI Kit for modern web apps, powered by TailwindCSS, HeadlessUI, and Tanstack Table.
|
|
5
|
+
Built for fast integration, deep customization, and a great developer experience.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- **Full TypeScript support** — all types exported
|
|
12
|
+
- **Design token based theming** (via context provider)
|
|
13
|
+
- **Easy theme override** (colors, radius, fonts, etc)
|
|
14
|
+
- **Composable, accessible components** (Button, Input, Table, etc)
|
|
15
|
+
- **Powered by TailwindCSS, HeadlessUI, Tanstack Table**
|
|
16
|
+
- **Ready-to-use Storybook with live playground**
|
|
17
|
+
- **Clean API, tree-shakable, zero CSS conflicts**
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🚀 Installation
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm install @eml-payments/ui-kit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> **Note:**
|
|
28
|
+
> You must also have `react` and `react-dom` (v18+), and TailwindCSS set up in your app.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🎨 Usage
|
|
33
|
+
|
|
34
|
+
1. **Import the CSS for styles and tokens:**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import "@eml-payments/ui-kit/style.css";
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
2. **Wrap your app in the `UIKitProvider` (optional: pass your design tokens):**
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import React from "react";
|
|
44
|
+
import { UIKitProvider } from "@eml-payments/ui-kit";
|
|
45
|
+
|
|
46
|
+
const theme = {
|
|
47
|
+
colors: {
|
|
48
|
+
primary: "#0A5FFF",
|
|
49
|
+
success: "#16c784",
|
|
50
|
+
error: "#d7263d",
|
|
51
|
+
// ...override any design token here
|
|
52
|
+
},
|
|
53
|
+
radius: "10px",
|
|
54
|
+
fontFamily: "Inter, sans-serif"
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default function App() {
|
|
58
|
+
return (
|
|
59
|
+
<UIKitProvider config={theme}>
|
|
60
|
+
{/* Your app code */}
|
|
61
|
+
</UIKitProvider>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
3. **Use components anywhere under the provider:**
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Button, Input, Table } from "@eml-payments/ui-kit";
|
|
70
|
+
|
|
71
|
+
<Button variant="primary">Primary Button</Button>
|
|
72
|
+
<Input label="Email" placeholder="user@email.com" />
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🛠️ Theming & Configuration
|
|
78
|
+
|
|
79
|
+
You can fully override the theme tokens using the `config` prop:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
type UIKitConfig = {
|
|
83
|
+
colors?: {
|
|
84
|
+
primary?: string;
|
|
85
|
+
secondary?: string;
|
|
86
|
+
accent?: string;
|
|
87
|
+
success?: string;
|
|
88
|
+
warning?: string;
|
|
89
|
+
error?: string;
|
|
90
|
+
[key: string]: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
radius?: string; // e.g. "8px"
|
|
93
|
+
fontFamily?: string;
|
|
94
|
+
// ...extend as needed
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Any value not set falls back to a sensible default.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 📚 Documentation & Storybook
|
|
103
|
+
|
|
104
|
+
- **Interactive Docs & Playground:**
|
|
105
|
+
run locally: `npm run storybook`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 📦 Components
|
|
110
|
+
|
|
111
|
+
- `Button` — variants: primary, secondary, ghost, destructive, loading
|
|
112
|
+
- `Input` — label, error state
|
|
113
|
+
- `Table` — full Tanstack Table v8 support, any data shape
|
|
114
|
+
|
|
115
|
+
(…and more coming soon!)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🧩 Example: Table
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import { Table } from "@eml-payments/ui-kit";
|
|
123
|
+
|
|
124
|
+
const columns = [
|
|
125
|
+
{ header: "Name", accessorKey: "name" },
|
|
126
|
+
{ header: "Email", accessorKey: "email" },
|
|
127
|
+
];
|
|
128
|
+
const data = [
|
|
129
|
+
{ name: "Alice", email: "alice@email.com" },
|
|
130
|
+
{ name: "Bob", email: "bob@email.com" },
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
<Table columns={columns} data={data} />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🤝 Contributing
|
|
139
|
+
|
|
140
|
+
We welcome PRs and issues!
|
|
141
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 📝 License
|
|
146
|
+
|
|
147
|
+
MIT © EML Payments
|
|
148
|
+
|
|
149
|
+
---
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
import { Loader2Icon } from 'lucide-react';
|
|
6
|
+
import { buttonVariants } from '@/components/Button/ButtonVariants';
|
|
7
|
+
export const Button = React.forwardRef(({ variant, size, asChild = false, loading = false, children, className, loadingText, ...props }, ref) => {
|
|
8
|
+
const Comp = asChild ? Slot : 'button';
|
|
9
|
+
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size }), className), ref: ref, disabled: loading || props.disabled, ...props, children: _jsxs("span", { className: "flex items-center gap-2", children: [loading && _jsx(Loader2Icon, { className: "animate-spin" }), loading ? loadingText : children] }) }));
|
|
10
|
+
});
|
|
11
|
+
Button.displayName = 'Button';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
-
import { buttonVariants } from './
|
|
2
|
+
import { type buttonVariants } from './ButtonVariants';
|
|
3
3
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
asChild?: boolean;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ButtonProps } from './Button.types';
|
|
3
1
|
export declare const buttonVariants: (props?: ({
|
|
4
2
|
variant?: "primary" | "secondary" | "outlined" | "ghost" | "destructive" | null | undefined;
|
|
5
3
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
4
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
-
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
4
1
|
import { cva } from 'class-variance-authority';
|
|
5
|
-
import { cn } from '../../lib/utils';
|
|
6
|
-
import { Loader2Icon } from 'lucide-react';
|
|
7
2
|
export const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0', {
|
|
8
3
|
variants: {
|
|
9
4
|
variant: {
|
|
@@ -34,7 +29,3 @@ export const buttonVariants = cva('inline-flex items-center justify-center gap-2
|
|
|
34
29
|
size: 'default',
|
|
35
30
|
},
|
|
36
31
|
});
|
|
37
|
-
export const Button = React.forwardRef(({ variant, size, asChild = false, loading = false, children, className, loadingText, ...props }, ref) => {
|
|
38
|
-
const Comp = asChild ? Slot : 'button';
|
|
39
|
-
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size }), className), ref: ref, disabled: loading || props.disabled, ...props, children: _jsxs("span", { className: "flex items-center gap-2", children: [loading && _jsx(Loader2Icon, { className: "animate-spin" }), loading ? loadingText : children] }) }));
|
|
40
|
-
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
3
|
-
import { CheckboxProps } from './Checkbox.types';
|
|
3
|
+
import type { CheckboxProps } from './Checkbox.types';
|
|
4
4
|
declare const Checkbox: React.ForwardRefExoticComponent<Omit<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & CheckboxProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
export { Checkbox };
|
|
@@ -4,18 +4,16 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
4
4
|
import { Check } from 'lucide-react';
|
|
5
5
|
import { cn } from '../../lib/utils';
|
|
6
6
|
const Checkbox = React.forwardRef(({ className, label, labelPosition = 'left', ...props }, ref) => {
|
|
7
|
-
// Define the position classes for label placement
|
|
8
7
|
const positionClasses = {
|
|
9
8
|
left: 'flex-row',
|
|
10
9
|
right: 'flex-row-reverse',
|
|
11
10
|
top: 'flex-col',
|
|
12
11
|
bottom: 'flex-col-reverse',
|
|
13
12
|
};
|
|
14
|
-
// Combine the position classes with the base classes
|
|
15
13
|
const wrapperClass = cn('inline-flex items-center gap-2', positionClasses[labelPosition]);
|
|
16
14
|
return (_jsxs("div", { className: wrapperClass, children: [label && (_jsx("label", { htmlFor: props.id, className: cn('text-sm font-medium cursor-pointer', {
|
|
17
15
|
'cursor-not-allowed opacity-70': props.disabled,
|
|
18
|
-
}), children: label })), _jsx(CheckboxPrimitive.Root, { ref: ref, className: cn('peer h-
|
|
16
|
+
}), children: label })), _jsx(CheckboxPrimitive.Root, { ref: ref, className: cn('peer h-[20px] w-[20px] shrink-0 rounded-sm border-2 border-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:text-[var(--uikit-primary)]', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { className: cn('flex items-center justify-center text-current'), children: _jsx(Check, { className: "h-[18px] w-[18px]", strokeWidth: 3 }) }) })] }));
|
|
19
17
|
});
|
|
20
18
|
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
21
19
|
export { Checkbox };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
2
|
-
import { Checkbox as ShadCBCheckbox } from '@radix-ui/react-checkbox';
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { Checkbox as ShadCBCheckbox } from '@radix-ui/react-checkbox';
|
|
3
3
|
export interface CheckboxProps extends ComponentProps<typeof ShadCBCheckbox> {
|
|
4
4
|
label?: string;
|
|
5
5
|
labelPosition?: 'left' | 'right' | 'top' | 'bottom';
|
|
@@ -4,5 +4,6 @@ import { useUIKitTheme } from '../../context/useUIKitTheme';
|
|
|
4
4
|
import { cn } from '../../lib/utils';
|
|
5
5
|
export const Input = React.forwardRef(({ type, label, error, className, helperText, icon, ...props }, ref) => {
|
|
6
6
|
const theme = useUIKitTheme();
|
|
7
|
-
return (_jsxs("div", { className: cn(className), children: [label && _jsx("label", { className: cn('text-sm font-medium text-foreground'), children: label }), _jsxs("div", { className: "relative", children: [_jsx("input", { type: type, style: { fontFamily: theme.fontFamily }, className: cn('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm transition ', { 'border-error focus-visible:ring-error': error }, className), ref: ref, onChange: props.onChange, ...props }), icon && _jsx("span", { className: "absolute inset-y-0 right-3 flex items-center pl-3", children: icon })] }), error
|
|
7
|
+
return (_jsxs("div", { className: cn(className), children: [label && _jsx("label", { className: cn('text-sm font-medium text-foreground'), children: label }), _jsxs("div", { className: "relative", children: [_jsx("input", { type: type, style: { fontFamily: theme.fontFamily }, className: cn('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm transition ', { 'border-error focus-visible:ring-error': error }, className), ref: ref, onChange: props.onChange, ...props }), icon && _jsx("span", { className: "absolute inset-y-0 right-3 flex items-center pl-3", children: icon })] }), error && _jsx("label", { className: cn('text-sm font-medium text-error'), children: error }), !error && helperText && (_jsx("label", { className: cn('text-sm font-medium text-foreground'), children: helperText }))] }));
|
|
8
8
|
});
|
|
9
|
+
Input.displayName = 'Input';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import { Label } from '../Label';
|
|
4
|
+
import { IoCloseCircleSharp } from 'react-icons/io5';
|
|
5
|
+
export const Pills = ({ label, size = 'default', variant = 'filled', color = 'primary', onClick, disabled = false, className = '', }) => {
|
|
6
|
+
// Define styles for the pill based on variant and color
|
|
7
|
+
const pillStyles = {
|
|
8
|
+
filled: {
|
|
9
|
+
primary: 'bg-[var(--uikit-primary)] text-white',
|
|
10
|
+
secondary: 'bg-[var(--uikit-secondary)] text-white',
|
|
11
|
+
warning: 'bg-[var(--uikit-warning)] text-white',
|
|
12
|
+
error: 'bg-[var(--uikit-error)] text-white',
|
|
13
|
+
info: 'bg-[var(--uikit-info)] text-white',
|
|
14
|
+
success: 'bg-[var(--uikit-success)] text-white',
|
|
15
|
+
},
|
|
16
|
+
outlined: {
|
|
17
|
+
primary: 'border border-[var(--uikit-primary)] text-[var(--uikit-primary)]',
|
|
18
|
+
secondary: 'border border-[var(--uikit-secondary)] text-[var(--uikit-secondary)]',
|
|
19
|
+
warning: 'border border-[var(--uikit-warning)] text-[var(--uikit-warning)]',
|
|
20
|
+
error: 'border border-[var(--uikit-error)] text-[var(--uikit-error)]',
|
|
21
|
+
info: 'border border-[var(--uikit-info)] text-[var(--uikit-info)]',
|
|
22
|
+
success: 'border border-[var(--uikit-success)] text-[var(--uikit-success)]',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs("div", { className: cn('inline-flex items-center rounded-full px-[4px] py-[3px] text-sm font-medium', {
|
|
26
|
+
'py-[4px]': size === 'default',
|
|
27
|
+
'opacity-50 cursor-not-allowed': disabled,
|
|
28
|
+
}, pillStyles[variant][color], className), children: [_jsx(Label, { className: cn('text-sm font-medium px-[6px]', {
|
|
29
|
+
'opacity-50 cursor-not-allowed': disabled,
|
|
30
|
+
}), children: label }), _jsx(IoCloseCircleSharp, { size: 24, onClick: onClick, className: "cursor-pointer", role: "button" })] }));
|
|
31
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PillsProps } from './Pills.types';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<PillsProps>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<PillsProps>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Small: Story;
|
|
8
|
+
export declare const Outlined: Story;
|
|
9
|
+
export declare const Disabled: Story;
|
|
10
|
+
export declare const Secondary: Story;
|
|
11
|
+
export declare const Warning: Story;
|
|
12
|
+
export declare const Error: Story;
|
|
13
|
+
export declare const Info: Story;
|
|
14
|
+
export declare const Success: Story;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pills } from './Pills';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'UIKit/Pills',
|
|
5
|
+
component: Pills,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
args: {
|
|
8
|
+
label: 'Label',
|
|
9
|
+
size: 'default',
|
|
10
|
+
variant: 'filled',
|
|
11
|
+
color: 'primary',
|
|
12
|
+
onClick: () => console.log('Pill clicked'),
|
|
13
|
+
disabled: false,
|
|
14
|
+
className: '',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
export const Default = {
|
|
19
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
20
|
+
};
|
|
21
|
+
export const Small = {
|
|
22
|
+
args: {
|
|
23
|
+
size: 'small',
|
|
24
|
+
label: 'Small Pill',
|
|
25
|
+
},
|
|
26
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
27
|
+
};
|
|
28
|
+
export const Outlined = {
|
|
29
|
+
args: {
|
|
30
|
+
variant: 'outlined',
|
|
31
|
+
label: 'Outlined Pill',
|
|
32
|
+
},
|
|
33
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
34
|
+
};
|
|
35
|
+
export const Disabled = {
|
|
36
|
+
args: {
|
|
37
|
+
disabled: true,
|
|
38
|
+
label: 'Disabled Pill',
|
|
39
|
+
},
|
|
40
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
41
|
+
};
|
|
42
|
+
export const Secondary = {
|
|
43
|
+
args: {
|
|
44
|
+
color: 'secondary',
|
|
45
|
+
label: 'Secondary Pill',
|
|
46
|
+
},
|
|
47
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
48
|
+
};
|
|
49
|
+
export const Warning = {
|
|
50
|
+
args: {
|
|
51
|
+
color: 'warning',
|
|
52
|
+
label: 'Warning Pill',
|
|
53
|
+
},
|
|
54
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
55
|
+
};
|
|
56
|
+
export const Error = {
|
|
57
|
+
args: {
|
|
58
|
+
color: 'error',
|
|
59
|
+
label: 'Error Pill',
|
|
60
|
+
},
|
|
61
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
62
|
+
};
|
|
63
|
+
export const Info = {
|
|
64
|
+
args: {
|
|
65
|
+
color: 'info',
|
|
66
|
+
label: 'Info Pill',
|
|
67
|
+
},
|
|
68
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
69
|
+
};
|
|
70
|
+
export const Success = {
|
|
71
|
+
args: {
|
|
72
|
+
color: 'success',
|
|
73
|
+
label: 'Success Pill',
|
|
74
|
+
},
|
|
75
|
+
render: (args) => _jsx(Pills, { ...args }),
|
|
76
|
+
};
|
|
@@ -8,7 +8,7 @@ const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
|
|
|
8
8
|
});
|
|
9
9
|
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
10
10
|
const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => {
|
|
11
|
-
return (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn('aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx(Circle, { className: "h-
|
|
11
|
+
return (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn('aspect-square h-4 w-4 rounded-full border-2 border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx(Circle, { className: "h-2 w-2 fill-[var(--uikit-primary)] text-transparent" }) }) }));
|
|
12
12
|
});
|
|
13
13
|
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
14
14
|
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
3
|
+
import type { SelectTriggerProps } from './Select.types';
|
|
4
|
+
declare const Select: React.FC<SelectPrimitive.SelectProps>;
|
|
5
|
+
declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
|
|
7
|
+
declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & SelectTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
4
|
+
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
const Select = SelectPrimitive.Root;
|
|
7
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
8
|
+
const SelectValue = SelectPrimitive.Value;
|
|
9
|
+
const SelectTrigger = React.forwardRef(({ className, children, size = 'md', error, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', { 'h-9': size === 'md', 'h-7': size === 'sm' }, { 'border-[var(--uikit-error)]': error }, className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })] })));
|
|
10
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
11
|
+
const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn('flex cursor-default items-center justify-center py-1', className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
|
|
12
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
13
|
+
const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn('flex cursor-default items-center justify-center py-1', className), ...props, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
|
|
14
|
+
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
15
|
+
const SelectContent = React.forwardRef(({ className, children, position = 'popper', ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn('relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]', position === 'popper' &&
|
|
16
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn('p-1', position === 'popper' &&
|
|
17
|
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
|
|
18
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
19
|
+
const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn('px-2 py-1.5 text-sm font-semibold', className), ...props })));
|
|
20
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
21
|
+
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn('relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
|
|
22
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
23
|
+
const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn('-mx-1 my-1 h-px bg-muted', className), ...props })));
|
|
24
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
25
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SelectProps } from './Select.types';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<SelectProps>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<SelectProps>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Disabled: Story;
|
|
8
|
+
export declare const WithLabel: Story;
|
|
9
|
+
export declare const Size: Story;
|
|
10
|
+
export declare const WithError: Story;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectItem, SelectScrollUpButton, SelectScrollDownButton, } from './Select';
|
|
3
|
+
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
4
|
+
import { Label } from '../Label';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'UIKit/Select',
|
|
7
|
+
component: Select,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
args: {
|
|
10
|
+
placeholder: 'Select an option...',
|
|
11
|
+
disabled: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
export const Default = {
|
|
16
|
+
render: (args) => (_jsxs(Select, { ...args, children: [_jsx(SelectTrigger, { className: "w-[320px]", children: _jsx(SelectValue, { placeholder: "Select an option..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectScrollUpButton, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) }), _jsxs(SelectGroup, { children: [_jsx(SelectItem, { value: "option1", children: "Option 1" }), _jsx(SelectItem, { value: "option2", children: "Option 2" }), _jsx(SelectItem, { value: "option3", children: "Option 3" })] })] })] })),
|
|
17
|
+
};
|
|
18
|
+
export const Disabled = {
|
|
19
|
+
args: {
|
|
20
|
+
disabled: true,
|
|
21
|
+
},
|
|
22
|
+
render: (args) => (_jsxs(Select, { ...args, children: [_jsx(SelectTrigger, { className: "w-[320px]", children: _jsx(SelectValue, { placeholder: "Select an option..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectScrollUpButton, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) }), _jsxs(SelectGroup, { children: [_jsx(SelectItem, { value: "option1", children: "Option 1" }), _jsx(SelectItem, { value: "option2", children: "Option 2" }), _jsx(SelectItem, { value: "option3", children: "Option 3" })] })] })] })),
|
|
23
|
+
};
|
|
24
|
+
export const WithLabel = {
|
|
25
|
+
render: (args) => (_jsx("div", { className: "w-[320px]", children: _jsxs(Select, { ...args, children: [_jsx(Label, { className: "mb-2", children: "Select an option" }), _jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Select an option..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectScrollUpButton, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) }), _jsxs(SelectGroup, { children: [_jsx(SelectItem, { value: "option1", children: "Option 1" }), _jsx(SelectItem, { value: "option2", children: "Option 2" }), _jsx(SelectItem, { value: "option3", children: "Option 3" })] })] })] }) })),
|
|
26
|
+
};
|
|
27
|
+
export const Size = {
|
|
28
|
+
args: {},
|
|
29
|
+
render: (args) => (_jsxs(Select, { ...args, children: [_jsx(SelectTrigger, { className: "w-[320px]", size: "md", children: _jsx(SelectValue, { placeholder: "Select an option..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectScrollUpButton, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) }), _jsxs(SelectGroup, { children: [_jsx(SelectItem, { value: "option1", children: "Option 1" }), _jsx(SelectItem, { value: "option2", children: "Option 2" }), _jsx(SelectItem, { value: "option3", children: "Option 3" })] })] })] })),
|
|
30
|
+
};
|
|
31
|
+
export const WithError = {
|
|
32
|
+
render: (args) => (_jsxs(Select, { ...args, children: [_jsx(SelectTrigger, { className: "w-[320px]", error: true, children: _jsx(SelectValue, { placeholder: "Select an option..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectScrollUpButton, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) }), _jsx(SelectScrollDownButton, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) }), _jsxs(SelectGroup, { children: [_jsx(SelectItem, { value: "option1", children: "Option 1" }), _jsx(SelectItem, { value: "option2", children: "Option 2" }), _jsx(SelectItem, { value: "option3", children: "Option 3" })] })] })] })),
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { SelectTrigger as ShadCNSelectTrigger } from '@radix-ui/react-select';
|
|
3
|
+
export interface SelectProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectTriggerProps extends ComponentProps<typeof ShadCNSelectTrigger> {
|
|
9
|
+
error?: boolean;
|
|
10
|
+
size?: 'sm' | 'md';
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import { Label } from '../Label';
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
|
|
5
|
+
export const SelectWrapper = ({ label, options, value, onChange, size = 'default', disabled = false, error = false, placeholder = '', className = '', }) => {
|
|
6
|
+
// Component implementation goes here
|
|
7
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 w-full", children: [label && _jsx(Label, { className: "text-sm font-medium", children: label }), _jsxs(Select, { value: value, onValueChange: onChange, disabled: disabled, children: [_jsx(SelectTrigger, { "aria-invalid": error, className: cn('w-full', error && 'border-[var(--uikit-error)] ring-1 ring-[var(--uikit-error)]', size === 'small' ? 'h-8' : 'h-10', className), children: _jsx(SelectValue, { placeholder: placeholder }) }), _jsx(SelectContent, { children: options.map((option) => (_jsx(SelectItem, { value: option.value, className: cn(size === 'small' ? 'h-8' : 'h-10'), children: _jsx("span", { children: option.label }) }, option.value))) })] }), error && _jsx("span", { className: "text-[var(--uikit-error)] text-sm", children: "This field is required." })] }));
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SelectWrapperProps } from './SelectWrapper.types';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<SelectWrapperProps>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<SelectWrapperProps>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithValue: Story;
|
|
8
|
+
export declare const Disabled: Story;
|
|
9
|
+
export declare const Error: Story;
|
|
10
|
+
export declare const WithLabel: Story;
|
|
11
|
+
export declare const WithPlaceholder: Story;
|
|
12
|
+
export declare const WithSize: Story;
|