@eml-payments/ui-kit 0.1.0 → 0.1.1
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 +3 -2
- package/dist/components/Button/Button.js +40 -0
- package/dist/components/Button/Button.stories.js +59 -0
- package/dist/components/Button/Button.types.js +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Checkbox/Checkbox.js +21 -0
- package/dist/components/Checkbox/Checkbox.stories.js +45 -0
- package/dist/components/Checkbox/Checkbox.types.js +1 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/Divider/Divider.js +8 -0
- package/dist/components/Divider/Divider.stories.js +20 -0
- package/dist/components/Divider/Divider.types.js +1 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/Ellipsis/Ellipsis.functions.js +8 -0
- package/dist/components/Ellipsis/Ellipsis.js +7 -0
- package/dist/components/Ellipsis/Ellipsis.stories.js +27 -0
- package/dist/components/Ellipsis/Ellipsis.types.js +1 -0
- package/dist/components/Ellipsis/index.js +1 -0
- package/dist/components/Input/Input.js +8 -0
- package/dist/components/Input/Input.stories.js +45 -0
- package/dist/components/Input/Input.types.js +1 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Label/Label.js +9 -0
- package/dist/components/Label/Label.stories.js +17 -0
- package/dist/components/Label/Label.types.js +1 -0
- package/dist/components/Label/index.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.js +14 -0
- package/dist/components/RadioGroup/RadioGroup.stories.js +29 -0
- package/dist/components/RadioGroup/RadioGroup.types.js +1 -0
- package/dist/components/RadioGroup/index.js +2 -0
- package/dist/components/Switch/Switch.js +35 -0
- package/dist/components/Switch/Switch.stories.js +47 -0
- package/dist/components/Switch/Switch.types.js +1 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Table/Table.js +120 -0
- package/dist/components/Table/Table.stories.js +19 -0
- package/dist/components/Table/Table.types.js +1 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.js +10 -0
- package/dist/components/Tooltip/Tooltip.stories.js +19 -0
- package/dist/components/Tooltip/Tooltip.types.js +1 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/config/defaultTheme.js +20 -0
- package/dist/config/index.js +2 -0
- package/dist/config/uikitConfig.js +1 -0
- package/dist/context/UIKitContext.js +4 -0
- package/dist/context/UIKitProvider.js +32 -0
- package/dist/context/useUIKitTheme.js +1 -0
- package/dist/hooks/useToggle.js +6 -0
- package/dist/index.js +6 -0
- package/dist/lib/utils.js +5 -0
- package/dist/stories/Header.js +4 -0
- package/dist/stories/Header.stories.js +26 -0
- package/dist/stories/Page.js +8 -0
- package/dist/stories/Page.stories.js +24 -0
- package/dist/types/components/Button/Button.d.ts +7 -0
- package/dist/types/components/Button/Button.stories.d.ts +16 -0
- package/dist/types/components/Button/Button.types.d.ts +8 -0
- package/dist/types/components/Button/index.d.ts +1 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/types/components/Checkbox/Checkbox.stories.d.ts +13 -0
- package/dist/types/components/Checkbox/Checkbox.types.d.ts +6 -0
- package/dist/types/components/Checkbox/index.d.ts +2 -0
- package/dist/types/components/Divider/Divider.d.ts +3 -0
- package/dist/types/components/Divider/Divider.stories.d.ts +8 -0
- package/dist/types/components/Divider/Divider.types.d.ts +5 -0
- package/dist/types/components/Divider/index.d.ts +1 -0
- package/dist/types/components/Ellipsis/Ellipsis.d.ts +3 -0
- package/dist/types/components/Ellipsis/Ellipsis.functions.d.ts +1 -0
- package/dist/types/components/Ellipsis/Ellipsis.stories.d.ts +7 -0
- package/dist/types/components/Ellipsis/Ellipsis.types.d.ts +7 -0
- package/dist/types/components/Ellipsis/index.d.ts +1 -0
- package/dist/types/components/Input/Input.d.ts +3 -0
- package/dist/types/components/Input/Input.stories.d.ts +15 -0
- package/dist/types/components/Input/Input.types.d.ts +7 -0
- package/dist/types/components/Input/index.d.ts +2 -0
- package/dist/types/components/Label/Label.d.ts +5 -0
- package/dist/types/components/Label/Label.stories.d.ts +7 -0
- package/dist/types/components/Label/Label.types.d.ts +3 -0
- package/dist/types/components/Label/index.d.ts +2 -0
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +5 -0
- package/dist/types/components/RadioGroup/RadioGroup.stories.d.ts +9 -0
- package/dist/types/components/RadioGroup/RadioGroup.types.d.ts +5 -0
- package/dist/types/components/RadioGroup/index.d.ts +2 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -0
- package/dist/types/components/Switch/Switch.stories.d.ts +12 -0
- package/dist/types/components/Switch/Switch.types.d.ts +6 -0
- package/dist/types/components/Switch/index.d.ts +2 -0
- package/dist/types/components/Table/Table.d.ts +36 -0
- package/dist/types/components/Table/Table.stories.d.ts +9 -0
- package/dist/types/components/Table/Table.types.d.ts +4 -0
- package/dist/types/components/Table/index.d.ts +2 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +7 -0
- package/dist/types/components/Tooltip/Tooltip.stories.d.ts +9 -0
- package/dist/types/components/Tooltip/Tooltip.types.d.ts +5 -0
- package/dist/types/components/Tooltip/index.d.ts +1 -0
- package/dist/types/config/defaultTheme.d.ts +2 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/uikitConfig.d.ts +19 -0
- package/dist/types/context/UIKitContext.d.ts +4 -0
- package/dist/types/context/UIKitProvider.d.ts +5 -0
- package/dist/types/context/useUIKitTheme.d.ts +1 -0
- package/dist/types/hooks/useToggle.d.ts +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +1 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/stories/Header.d.ts +12 -0
- package/dist/types/stories/Header.stories.d.ts +18 -0
- package/dist/types/stories/Page.d.ts +3 -0
- package/dist/types/stories/Page.stories.d.ts +12 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/utils/classNames.d.ts +1 -0
- package/dist/utils/classNames.js +3 -0
- package/package.json +75 -74
package/README.md
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
# apprepo.template
|
|
2
|
-
|
|
1
|
+
# apprepo.template
|
|
2
|
+
|
|
3
|
+
Template for new app repos
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { cva } from 'class-variance-authority';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { Loader2Icon } from 'lucide-react';
|
|
7
|
+
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
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
primary: 'bg-[var(--uikit-primary)] text-white ' +
|
|
11
|
+
'hover:bg-[var(--uikit-primary)]/90 ' +
|
|
12
|
+
'focus:bg-[var(--uikit-primary)]',
|
|
13
|
+
secondary: 'bg-white border border-[var(--uikit-secondary)] text-[var(--uikit-secondary)] ' +
|
|
14
|
+
'hover:bg-[var(--uikit-secondary)] hover:text-white ' +
|
|
15
|
+
'focus:bg-white focus:text-[var(--uikit-secondary)] focus:border-[var(--uikit-primary)]',
|
|
16
|
+
outlined: 'bg-transparent border border-[var(--uikit-primary)] text-[var(--uikit-secondary)] ' +
|
|
17
|
+
'focus:border-[var(--uikit-secondary)]',
|
|
18
|
+
ghost: 'bg-transparent text-[var(--uikit-secondary)] ' +
|
|
19
|
+
'hover:bg-transparent hover:border hover:border-[var(--uikit-primary)] ' +
|
|
20
|
+
'focus:text-[var(--uikit-secondary)] focus:border-[var(--uikit-secondary)]',
|
|
21
|
+
destructive: 'bg-[var(--uikit-error)] text-white ' +
|
|
22
|
+
'hover:bg-[var(--uikit-error)]/90 ' +
|
|
23
|
+
'focus:bg-[var(--uikit-error)]',
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
default: 'h-9 px-4 py-2',
|
|
27
|
+
sm: 'h-8 rounded-md px-3 text-xs',
|
|
28
|
+
lg: 'h-10 rounded-md px-8',
|
|
29
|
+
icon: 'h-9 w-9',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: 'primary',
|
|
34
|
+
size: 'default',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
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
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'UIKit/Button',
|
|
5
|
+
component: Button,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
args: {
|
|
8
|
+
children: 'Click me',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const Primary = {
|
|
13
|
+
args: {
|
|
14
|
+
variant: 'primary',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export const Secondary = {
|
|
18
|
+
args: {
|
|
19
|
+
variant: 'secondary',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const Outlined = {
|
|
23
|
+
args: {
|
|
24
|
+
variant: 'outlined',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export const Ghost = {
|
|
28
|
+
args: {
|
|
29
|
+
variant: 'ghost',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export const Destructive = {
|
|
33
|
+
args: {
|
|
34
|
+
variant: 'destructive',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const Loading = {
|
|
38
|
+
args: {
|
|
39
|
+
loading: true,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const WithLoadingText = {
|
|
43
|
+
args: {
|
|
44
|
+
loading: true,
|
|
45
|
+
loadingText: 'Saving',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export const WithIconLeft = {
|
|
49
|
+
render: () => _jsx(Button, { children: "\u26A1Click me" }),
|
|
50
|
+
};
|
|
51
|
+
export const WithIconRight = {
|
|
52
|
+
render: () => _jsx(Button, { children: "Click me\u26A1" }),
|
|
53
|
+
};
|
|
54
|
+
export const DisabledVariants = {
|
|
55
|
+
render: () => (_jsxs("div", { style: { display: 'flex', gap: '12px', flexWrap: 'wrap' }, children: [_jsx(Button, { variant: "primary", disabled: true, children: "Primary" }), _jsx(Button, { variant: "secondary", disabled: true, children: "Secondary" }), _jsx(Button, { variant: "outlined", disabled: true, children: "Outlined" }), _jsx(Button, { variant: "ghost", disabled: true, children: "Ghost" })] })),
|
|
56
|
+
};
|
|
57
|
+
export const AllSizes = {
|
|
58
|
+
render: () => (_jsxs("div", { style: { display: 'flex', gap: '12px', flexWrap: 'wrap' }, children: [_jsx(Button, { size: "sm", children: "Small" }), _jsx(Button, { size: "default", children: "Default" }), _jsx(Button, { size: "lg", children: "Large" }), _jsx(Button, { size: "icon", "aria-label": "Icon", children: "\u26A1" })] })),
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Button';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
4
|
+
import { Check } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
const Checkbox = React.forwardRef(({ className, label, labelPosition = 'left', ...props }, ref) => {
|
|
7
|
+
// Define the position classes for label placement
|
|
8
|
+
const positionClasses = {
|
|
9
|
+
left: 'flex-row',
|
|
10
|
+
right: 'flex-row-reverse',
|
|
11
|
+
top: 'flex-col',
|
|
12
|
+
bottom: 'flex-col-reverse',
|
|
13
|
+
};
|
|
14
|
+
// Combine the position classes with the base classes
|
|
15
|
+
const wrapperClass = cn('inline-flex items-center gap-2', positionClasses[labelPosition]);
|
|
16
|
+
return (_jsxs("div", { className: wrapperClass, children: [label && (_jsx("label", { htmlFor: props.id, className: cn('text-sm font-medium cursor-pointer', {
|
|
17
|
+
'cursor-not-allowed opacity-70': props.disabled,
|
|
18
|
+
}), children: label })), _jsx(CheckboxPrimitive.Root, { ref: ref, className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { className: cn('flex items-center justify-center text-current'), children: _jsx(Check, { className: "h-4 w-4" }) }) })] }));
|
|
19
|
+
});
|
|
20
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
21
|
+
export { Checkbox };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Checkbox } from './Checkbox';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UIKit/Checkbox',
|
|
6
|
+
component: Checkbox,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
checked: false,
|
|
10
|
+
disabled: false,
|
|
11
|
+
labelPosition: 'right',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
export const Default = {
|
|
16
|
+
args: {},
|
|
17
|
+
};
|
|
18
|
+
export const Checked = {
|
|
19
|
+
args: { checked: true },
|
|
20
|
+
};
|
|
21
|
+
export const Disabled = {
|
|
22
|
+
args: { disabled: true },
|
|
23
|
+
};
|
|
24
|
+
export const DisabledChecked = {
|
|
25
|
+
args: { checked: true, disabled: true },
|
|
26
|
+
};
|
|
27
|
+
export const ControlledCheckbox = {
|
|
28
|
+
render: (args) => {
|
|
29
|
+
const [checked, setChecked] = useState(args.checked);
|
|
30
|
+
return _jsx(Checkbox, { ...args, checked: checked, onCheckedChange: (value) => setChecked(value) });
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const WithLabel = {
|
|
34
|
+
args: { label: 'Checkbox Label', id: 'checkbox-label', disabled: true },
|
|
35
|
+
};
|
|
36
|
+
export const WithLabelPosition = {
|
|
37
|
+
args: { label: 'Checkbox Label', labelPosition: 'left', id: 'checkbox-label-position' },
|
|
38
|
+
};
|
|
39
|
+
export const ControlledAndLabel = {
|
|
40
|
+
args: { label: 'Controlled Checkbox', id: 'controlled-checkbox' },
|
|
41
|
+
render: (args) => {
|
|
42
|
+
const [checked, setChecked] = useState(args.checked);
|
|
43
|
+
return _jsx(Checkbox, { ...args, checked: checked, onCheckedChange: (value) => setChecked(value) });
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
export const Divider = ({ orientation = 'horizontal', color = 'var(--uikit-secondary)', className, ...props }) => {
|
|
4
|
+
const orientationStyles = orientation === 'vertical' ? 'w-px h-full' : 'h-px w-full';
|
|
5
|
+
return (_jsx("div", { className: cn(orientationStyles, className), style: {
|
|
6
|
+
backgroundColor: color,
|
|
7
|
+
}, role: "separator", "aria-orientation": orientation, "aria-hidden": "true", ...props }));
|
|
8
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Divider } from './Divider';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'UIKit/Divider',
|
|
5
|
+
component: Divider,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Horizontal = {
|
|
10
|
+
render: () => (_jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "text-sm", children: "Section Above" }), _jsx(Divider, { orientation: "horizontal" }), _jsx("div", { className: "text-sm", children: "Section Below" })] })),
|
|
11
|
+
};
|
|
12
|
+
export const HorizontalCustomColor = {
|
|
13
|
+
render: () => (_jsxs("div", { className: "space-y-4", children: [_jsx("div", { className: "text-sm", children: "Above custom divider" }), _jsx(Divider, { orientation: "horizontal", color: "#f97316" }), _jsx("div", { className: "text-sm", children: "Below custom divider" })] })),
|
|
14
|
+
};
|
|
15
|
+
export const Vertical = {
|
|
16
|
+
render: () => (_jsxs("div", { className: "flex items-center space-x-2 h-8", children: [_jsx("button", { className: "text-sm px-3 py-1", children: "Option A" }), _jsx(Divider, { orientation: "vertical" }), _jsx("button", { className: "text-sm px-3 py-1", children: "Option B" })] })),
|
|
17
|
+
};
|
|
18
|
+
export const VerticalTall = {
|
|
19
|
+
render: () => (_jsxs("div", { className: "flex gap-4 items-stretch h-24", children: [_jsx("div", { className: "flex-1 bg-muted p-2", children: "Column A" }), _jsx(Divider, { orientation: "vertical" }), _jsx("div", { className: "flex-1 bg-muted p-2", children: "Column B" })] })),
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Divider';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function middleEllipsis(text, maxLength) {
|
|
2
|
+
if (text.length <= maxLength)
|
|
3
|
+
return text;
|
|
4
|
+
const visibleChars = maxLength - 3;
|
|
5
|
+
const start = Math.ceil(visibleChars / 2);
|
|
6
|
+
const end = Math.floor(visibleChars / 2);
|
|
7
|
+
return `${text.slice(0, start)}...${text.slice(text.length - end)}`;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../lib/utils';
|
|
3
|
+
import { middleEllipsis } from './Ellipsis.functions';
|
|
4
|
+
export const EllipsisText = ({ text, maxLength = 32, mode = 'end', width = '', className, ...props }) => {
|
|
5
|
+
const content = mode === 'middle' ? middleEllipsis(text, maxLength) : text;
|
|
6
|
+
return (_jsx("span", { className: cn('inline-block overflow-hidden whitespace-nowrap text-ellipsis', mode === 'end' ? 'truncate' : '', width, className), ...props, children: content }));
|
|
7
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EllipsisText } from './Ellipsis';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'UIKit/EllipsisText',
|
|
4
|
+
component: EllipsisText,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
export const EndEllipsis = {
|
|
9
|
+
args: {
|
|
10
|
+
text: 'Pellentesque bibendum interdum bibendum. Vivamus libero dolor.',
|
|
11
|
+
mode: 'end',
|
|
12
|
+
width: 'w-[200px]',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const MiddleEllipsis = {
|
|
16
|
+
args: {
|
|
17
|
+
text: 'FirstnameMiddleInitialLastname',
|
|
18
|
+
mode: 'middle',
|
|
19
|
+
maxLength: 20,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export const NoEllipsisNeeded = {
|
|
23
|
+
args: {
|
|
24
|
+
text: 'Short title',
|
|
25
|
+
mode: 'end',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Ellipsis';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useUIKitTheme } from '../../context/useUIKitTheme';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
export const Input = React.forwardRef(({ type, label, error, className, helperText, icon, ...props }, ref) => {
|
|
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 ? (_jsx("label", { className: cn('text-sm font-medium text-error'), children: error })) : helperText ? (_jsx("label", { className: cn('text-sm font-medium text-foreground'), children: helperText })) : null] }));
|
|
8
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from './Input';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'UIKit/Input',
|
|
5
|
+
component: Input,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
args: {
|
|
8
|
+
type: 'text',
|
|
9
|
+
label: 'Label',
|
|
10
|
+
placeholder: 'Enter text...',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Text = {
|
|
15
|
+
args: { type: 'text', placeholder: 'Enter text...' },
|
|
16
|
+
};
|
|
17
|
+
export const Number = {
|
|
18
|
+
args: { type: 'number', placeholder: 'Enter number...' },
|
|
19
|
+
};
|
|
20
|
+
export const WithValue = {
|
|
21
|
+
args: { value: 'Sample text' },
|
|
22
|
+
};
|
|
23
|
+
export const WithLabel = {
|
|
24
|
+
args: { label: 'Sample Label', placeholder: 'Enter text...' },
|
|
25
|
+
};
|
|
26
|
+
export const PasswordInput = {
|
|
27
|
+
args: { type: 'password', placeholder: 'Enter password...' },
|
|
28
|
+
};
|
|
29
|
+
export const WithHelperText = {
|
|
30
|
+
args: { helperText: 'This is a helper text', placeholder: 'Enter text...' },
|
|
31
|
+
};
|
|
32
|
+
export const Disabled = {
|
|
33
|
+
args: { disabled: true, placeholder: 'Disabled input' },
|
|
34
|
+
};
|
|
35
|
+
export const DisabledWithValue = {
|
|
36
|
+
args: { disabled: true, value: 'Disabled input with value' },
|
|
37
|
+
};
|
|
38
|
+
export const WithError = {
|
|
39
|
+
args: { error: 'Something went wrong' },
|
|
40
|
+
};
|
|
41
|
+
export const withIcon = {
|
|
42
|
+
args: {
|
|
43
|
+
icon: (_jsx("span", { children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M12 6C13.1 6 14 6.9 14 8C14 9.1 13.1 10 12 10C10.9 10 10 9.1 10 8C10 6.9 10.9 6 12 6ZM12 16C14.7 16 17.8 17.29 18 18H6C6.23 17.28 9.31 16 12 16ZM12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z", fill: "black" }) }) })),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
|
|
7
|
+
const Label = React.forwardRef(({ className, ...props }, ref) => (_jsx(LabelPrimitive.Root, { ref: ref, className: cn(labelVariants(), className), ...props })));
|
|
8
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
9
|
+
export { Label };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Label } from './Label';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'UIKit/Label',
|
|
4
|
+
component: Label,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
args: {
|
|
7
|
+
children: 'Label Text',
|
|
8
|
+
htmlFor: 'label-id',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const Default = {
|
|
13
|
+
args: {},
|
|
14
|
+
};
|
|
15
|
+
export const WithCustomStyle = {
|
|
16
|
+
args: { className: 'text-blue-500 font-bold' },
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
4
|
+
import { Circle } from 'lucide-react';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
|
|
7
|
+
return _jsx(RadioGroupPrimitive.Root, { className: cn('grid gap-2', className), ...props, ref: ref });
|
|
8
|
+
});
|
|
9
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
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-3.5 w-3.5 fill-primary" }) }) }));
|
|
12
|
+
});
|
|
13
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
14
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RadioGroup, RadioGroupItem } from './RadioGroup';
|
|
3
|
+
import { Label } from '../Label';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UIKit/RadioGroup',
|
|
6
|
+
component: RadioGroup,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
defaultValue: 'option1',
|
|
10
|
+
disabled: false,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Default = {
|
|
15
|
+
args: {},
|
|
16
|
+
render: (args) => (_jsxs(RadioGroup, { ...args, children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option1", id: "option1" }), _jsx(Label, { htmlFor: "option1", children: "Option 1" })] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option2", id: "option2-disabled" }), _jsx(Label, { htmlFor: "option2-disabled", children: "Option 2" })] })] })),
|
|
17
|
+
};
|
|
18
|
+
export const Horizontal = {
|
|
19
|
+
args: {},
|
|
20
|
+
render: (args) => (_jsxs(RadioGroup, { ...args, className: "flex items-center gap-3", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option1", id: "option1-horizontal" }), _jsx(Label, { htmlFor: "option1-horizontal", children: "Option 1" })] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option2", id: "option2-horizontal" }), _jsx(Label, { htmlFor: "option2-horizontal", children: "Option 2" })] })] })),
|
|
21
|
+
};
|
|
22
|
+
export const Disabled = {
|
|
23
|
+
args: {},
|
|
24
|
+
render: (args) => (_jsxs(RadioGroup, { ...args, disabled: true, children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option1", id: "option1-disabled" }), _jsx(Label, { htmlFor: "option1-disabled", children: "Option 1" })] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option2", id: "option2-disabled" }), _jsx(Label, { htmlFor: "option2-disabled", children: "Option 2" })] })] })),
|
|
25
|
+
};
|
|
26
|
+
export const Size = {
|
|
27
|
+
args: {},
|
|
28
|
+
render: (args) => (_jsxs(RadioGroup, { ...args, className: "flex items-center gap-3", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option1", id: "option1-size" }), _jsx(Label, { htmlFor: "option1-size", children: "Option 1" })] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option2", id: "option2-size", className: "h-5 w-5 [&_svg]:h-3 [&_svg]:w-3" }), _jsx(Label, { htmlFor: "option2-size", children: "Option 2" })] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(RadioGroupItem, { value: "option3", id: "option3-size", className: "h-6 w-6 [&_svg]:h-4 [&_svg]:w-4" }), _jsx(Label, { htmlFor: "option3-size", children: "Option 3" })] })] })),
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
import { Label } from '../Label/Label';
|
|
6
|
+
const sizeClasses = {
|
|
7
|
+
sm: {
|
|
8
|
+
root: 'h-4 w-8',
|
|
9
|
+
thumb: 'h-3 w-3 data-[state=checked]:translate-x-4',
|
|
10
|
+
},
|
|
11
|
+
md: {
|
|
12
|
+
root: 'h-6 w-11',
|
|
13
|
+
thumb: 'h-4 w-4 data-[state=checked]:translate-x-5',
|
|
14
|
+
},
|
|
15
|
+
lg: {
|
|
16
|
+
root: 'h-7 w-14',
|
|
17
|
+
thumb: 'h-5 w-5 data-[state=checked]:translate-x-7',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const Switch = React.forwardRef(({ className, label, labelPosition = 'left', ...props }, ref) => {
|
|
21
|
+
// Define the position classes for label placement
|
|
22
|
+
const positionClasses = {
|
|
23
|
+
left: 'flex-row',
|
|
24
|
+
right: 'flex-row-reverse',
|
|
25
|
+
top: 'flex-col',
|
|
26
|
+
bottom: 'flex-col-reverse',
|
|
27
|
+
};
|
|
28
|
+
// Combine the position classes with the base classses
|
|
29
|
+
const wrapperClass = cn('inline-flex items-center gap-2', positionClasses[labelPosition]);
|
|
30
|
+
return (_jsxs("div", { className: wrapperClass, children: [label && (_jsx(Label, { htmlFor: props.id, className: cn('text-sm font-medium cursor-pointer', {
|
|
31
|
+
'cursor-not-allowed opacity-70': props.disabled,
|
|
32
|
+
}), children: label })), _jsx(SwitchPrimitives.Root, { className: cn('peer inline-flex h-[24px] w-[42px] shrink-0 cursor-pointer items-center rounded-full border-2 border-black shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 bg-transparent', className), ...props, ref: ref, children: _jsx(SwitchPrimitives.Thumb, { className: cn('pointer-events-none block h-[15px] w-[15px] rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[20px] data-[state=checked]:bg-[var(--uikit-primary)] data-[state=unchecked]:translate-x-[2px] data-[state=unchecked]:bg-black') }) })] }));
|
|
33
|
+
});
|
|
34
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
35
|
+
export { Switch };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Switch } from './Switch';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UIKit/Switch',
|
|
6
|
+
component: Switch,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
checked: false,
|
|
10
|
+
disabled: false,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Default = {
|
|
15
|
+
args: {},
|
|
16
|
+
};
|
|
17
|
+
export const Checked = {
|
|
18
|
+
args: { checked: true },
|
|
19
|
+
};
|
|
20
|
+
export const Disabled = {
|
|
21
|
+
args: { disabled: true },
|
|
22
|
+
};
|
|
23
|
+
export const ControlledSwitch = {
|
|
24
|
+
render: (args) => {
|
|
25
|
+
const [checked, setChecked] = useState(args.checked);
|
|
26
|
+
return _jsx(Switch, { ...args, checked: checked, onCheckedChange: (value) => setChecked(value) });
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const WithLabel = {
|
|
30
|
+
args: {
|
|
31
|
+
label: 'Switch Label',
|
|
32
|
+
id: 'switch-label',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const WithLabelPosition = {
|
|
36
|
+
args: { label: 'Switch Label', labelPosition: 'left' },
|
|
37
|
+
};
|
|
38
|
+
export const ControlledAndLabel = {
|
|
39
|
+
args: {
|
|
40
|
+
label: 'Controlled Switch',
|
|
41
|
+
id: 'controlled-switch',
|
|
42
|
+
},
|
|
43
|
+
render: (args) => {
|
|
44
|
+
const [checked, setChecked] = useState(args.checked);
|
|
45
|
+
return (_jsx(Switch, { ...args, id: "controlled-switch", checked: checked, onCheckedChange: (value) => setChecked(value) }));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|