buildgrid-ui 1.1.0-alpha.6 → 1.1.0-dev.6
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/dist/buildgrid-ui.es.js +2138 -1821
- package/dist/buildgrid-ui.umd.js +43 -28
- package/dist/components/index.d.ts +3 -0
- package/dist/components/password-input/index.d.ts +1 -0
- package/dist/components/password-input/password-input.d.ts +16 -0
- package/dist/components/progress/index.d.ts +1 -0
- package/dist/components/progress/progress.d.ts +4 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/switch.d.ts +4 -0
- package/dist/index.d.ts +2 -12
- package/package.json +5 -2
- package/src/components/index.ts +3 -0
- package/src/components/password-input/index.ts +1 -0
- package/src/components/password-input/password-input.stories.tsx +22 -0
- package/src/components/password-input/password-input.tsx +98 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.stories.tsx +21 -0
- package/src/components/progress/progress.tsx +26 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.stories.tsx +21 -0
- package/src/components/switch/switch.tsx +26 -0
- package/src/index.ts +2 -12
|
@@ -7,5 +7,8 @@ export * from './card';
|
|
|
7
7
|
export * from './checkbox';
|
|
8
8
|
export * from './dropdown-menu';
|
|
9
9
|
export * from './input';
|
|
10
|
+
export * from './password-input';
|
|
10
11
|
export * from './popover';
|
|
12
|
+
export * from './progress';
|
|
11
13
|
export * from './skeleton';
|
|
14
|
+
export * from './switch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './password-input';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
3
|
+
showStrengthMeter?: boolean;
|
|
4
|
+
strengthLabels?: {
|
|
5
|
+
veryWeak: string;
|
|
6
|
+
weak: string;
|
|
7
|
+
medium: string;
|
|
8
|
+
strong: string;
|
|
9
|
+
veryStrong: string;
|
|
10
|
+
};
|
|
11
|
+
showPasswordLabel?: string;
|
|
12
|
+
hidePasswordLabel?: string;
|
|
13
|
+
strengthTitle?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function PasswordInput(props: PasswordInputProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progress';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const Progress: React.ForwardRefExoticComponent<Omit<ProgressPrimitive.ProgressProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export { Progress };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './switch';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Switch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export * from './components
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './components/avatar';
|
|
4
|
-
export * from './components/badge';
|
|
5
|
-
export * from './components/button';
|
|
6
|
-
export * from './components/card';
|
|
7
|
-
export * from './components/checkbox';
|
|
8
|
-
export * from './components/dropdown-menu';
|
|
9
|
-
export * from './components/input';
|
|
10
|
-
export * from './components/popover';
|
|
11
|
-
export * from './components/skeleton';
|
|
12
|
-
export * from './lib/utils/cn';
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './lib';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buildgrid-ui",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-dev.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"storybook": "storybook dev -p 6006",
|
|
16
16
|
"build-storybook": "storybook build",
|
|
17
17
|
"release": "semantic-release",
|
|
18
|
-
"prepublishOnly": "npm run build"
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"build:publish": "npm run build && npm publish"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [],
|
|
21
22
|
"author": "",
|
|
@@ -26,7 +27,9 @@
|
|
|
26
27
|
"@radix-ui/react-checkbox": "^1.1.3",
|
|
27
28
|
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
|
28
29
|
"@radix-ui/react-popover": "^1.1.4",
|
|
30
|
+
"@radix-ui/react-progress": "^1.1.1",
|
|
29
31
|
"@radix-ui/react-slot": "^1.1.1",
|
|
32
|
+
"@radix-ui/react-switch": "^1.1.2",
|
|
30
33
|
"@shadcn/ui": "^0.0.4",
|
|
31
34
|
"class-variance-authority": "^0.7.1",
|
|
32
35
|
"clsx": "^2.1.1",
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './password-input'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// organize-imports-ignore
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
4
|
+
|
|
5
|
+
import { PasswordInput } from './password-input'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof PasswordInput> = {
|
|
8
|
+
title: 'Components/Input/Password',
|
|
9
|
+
component: PasswordInput,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default meta
|
|
13
|
+
type Story = StoryObj<typeof PasswordInput>
|
|
14
|
+
|
|
15
|
+
const Template = () => {
|
|
16
|
+
return <PasswordInput className="w-96" />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Default: Story = {
|
|
20
|
+
render: Template.bind({}),
|
|
21
|
+
args: {},
|
|
22
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Eye, EyeOff } from 'lucide-react'
|
|
2
|
+
import React, { InputHTMLAttributes, useState } from 'react'
|
|
3
|
+
import { Button } from '../button'
|
|
4
|
+
import { Input } from '../input'
|
|
5
|
+
import { Progress } from '../progress'
|
|
6
|
+
|
|
7
|
+
interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
8
|
+
showStrengthMeter?: boolean
|
|
9
|
+
strengthLabels?: {
|
|
10
|
+
veryWeak: string
|
|
11
|
+
weak: string
|
|
12
|
+
medium: string
|
|
13
|
+
strong: string
|
|
14
|
+
veryStrong: string
|
|
15
|
+
}
|
|
16
|
+
showPasswordLabel?: string
|
|
17
|
+
hidePasswordLabel?: string
|
|
18
|
+
strengthTitle?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function PasswordInput(props: PasswordInputProps) {
|
|
22
|
+
const {
|
|
23
|
+
showStrengthMeter = true,
|
|
24
|
+
className,
|
|
25
|
+
strengthLabels = {
|
|
26
|
+
veryWeak: 'Very weak',
|
|
27
|
+
weak: 'Weak',
|
|
28
|
+
medium: 'Medium',
|
|
29
|
+
strong: 'Strong',
|
|
30
|
+
veryStrong: 'Very strong',
|
|
31
|
+
},
|
|
32
|
+
showPasswordLabel = 'Show password',
|
|
33
|
+
hidePasswordLabel = 'Hide password',
|
|
34
|
+
strengthTitle = 'Password strength',
|
|
35
|
+
...rest
|
|
36
|
+
} = props
|
|
37
|
+
|
|
38
|
+
const [password, setPassword] = useState('')
|
|
39
|
+
const [showPassword, setShowPassword] = useState(false)
|
|
40
|
+
|
|
41
|
+
const calculateStrength = (password: string): number => {
|
|
42
|
+
let strength = 0
|
|
43
|
+
if (password.length >= 8) strength += 25
|
|
44
|
+
if (password.match(/[a-z]/)) strength += 25
|
|
45
|
+
if (password.match(/[A-Z]/)) strength += 25
|
|
46
|
+
if (password.match(/[0-9]/)) strength += 25
|
|
47
|
+
return strength
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const getStrengthLabel = (strength: number): string => {
|
|
51
|
+
if (strength === 0) return strengthLabels.veryWeak
|
|
52
|
+
if (strength <= 25) return strengthLabels.weak
|
|
53
|
+
if (strength <= 50) return strengthLabels.medium
|
|
54
|
+
if (strength <= 75) return strengthLabels.strong
|
|
55
|
+
return strengthLabels.veryStrong
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const strength = calculateStrength(password)
|
|
59
|
+
const strengthLabel = getStrengthLabel(strength)
|
|
60
|
+
|
|
61
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
62
|
+
setPassword(e.target.value)
|
|
63
|
+
props.onChange?.(e)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className="w-fit space-y-4">
|
|
68
|
+
<div className="relative">
|
|
69
|
+
<Input
|
|
70
|
+
{...rest}
|
|
71
|
+
type={showPassword ? 'text' : 'password'}
|
|
72
|
+
value={password}
|
|
73
|
+
onChange={handleChange}
|
|
74
|
+
className={`pr-10 ${className || ''}`}
|
|
75
|
+
/>
|
|
76
|
+
<Button
|
|
77
|
+
type="button"
|
|
78
|
+
variant="ghost"
|
|
79
|
+
size="icon"
|
|
80
|
+
className="absolute right-0 top-0 h-full"
|
|
81
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
82
|
+
aria-label={showPassword ? hidePasswordLabel : showPasswordLabel}
|
|
83
|
+
>
|
|
84
|
+
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
|
85
|
+
</Button>
|
|
86
|
+
</div>
|
|
87
|
+
{showStrengthMeter && (
|
|
88
|
+
<div className="space-y-2">
|
|
89
|
+
<div className="flex justify-between text-sm">
|
|
90
|
+
<span>{strengthTitle}:</span>
|
|
91
|
+
<span>{strengthLabel}</span>
|
|
92
|
+
</div>
|
|
93
|
+
<Progress value={strength} className="h-2" />
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progress'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// organize-imports-ignore
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
4
|
+
|
|
5
|
+
import { Progress } from './progress'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Progress> = {
|
|
8
|
+
component: Progress,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof Progress>
|
|
13
|
+
|
|
14
|
+
const Template = () => {
|
|
15
|
+
return <Progress value={90} />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: Template.bind({}),
|
|
20
|
+
args: {},
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as ProgressPrimitive from '@radix-ui/react-progress'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { cn } from '@/lib/utils/cn'
|
|
5
|
+
|
|
6
|
+
const Progress = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
|
9
|
+
>(({ className, value, ...props }, ref) => (
|
|
10
|
+
<ProgressPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
'relative h-2 w-full overflow-hidden rounded-full bg-primary/20',
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<ProgressPrimitive.Indicator
|
|
19
|
+
className="h-full w-full flex-1 bg-primary transition-all"
|
|
20
|
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
21
|
+
/>
|
|
22
|
+
</ProgressPrimitive.Root>
|
|
23
|
+
))
|
|
24
|
+
Progress.displayName = ProgressPrimitive.Root.displayName
|
|
25
|
+
|
|
26
|
+
export { Progress }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './switch'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// organize-imports-ignore
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
4
|
+
|
|
5
|
+
import { Switch } from './switch'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Switch> = {
|
|
8
|
+
component: Switch,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof Switch>
|
|
13
|
+
|
|
14
|
+
const Template = () => {
|
|
15
|
+
return <Switch />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: Template.bind({}),
|
|
20
|
+
args: {},
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cn } from '@/lib'
|
|
2
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
|
|
5
|
+
const Switch = React.forwardRef<
|
|
6
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<SwitchPrimitives.Root
|
|
10
|
+
className={cn(
|
|
11
|
+
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent 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 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
ref={ref}
|
|
16
|
+
>
|
|
17
|
+
<SwitchPrimitives.Thumb
|
|
18
|
+
className={cn(
|
|
19
|
+
'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
|
|
20
|
+
)}
|
|
21
|
+
/>
|
|
22
|
+
</SwitchPrimitives.Root>
|
|
23
|
+
))
|
|
24
|
+
Switch.displayName = SwitchPrimitives.Root.displayName
|
|
25
|
+
|
|
26
|
+
export { Switch }
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
export * from './components
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './components/avatar'
|
|
4
|
-
export * from './components/badge'
|
|
5
|
-
export * from './components/button'
|
|
6
|
-
export * from './components/card'
|
|
7
|
-
export * from './components/checkbox'
|
|
8
|
-
export * from './components/dropdown-menu'
|
|
9
|
-
export * from './components/input'
|
|
10
|
-
export * from './components/popover'
|
|
11
|
-
export * from './components/skeleton'
|
|
12
|
-
export * from './lib/utils/cn'
|
|
1
|
+
export * from './components'
|
|
2
|
+
export * from './lib'
|